snippets Wordpress:命名style.css

Wordpress:命名style.css

Wordpress: style_ini.snippets
/*
Theme Name: WebsiteName
Theme URI: http://websiteaddress.com/
Author: Kaio Andrade
Author URI: http://kaioandrade.com
Description: Website description
Version: 1.0-wpcom
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: 
Tags:

This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned with others.
*/

body{
	background: red;
}

snippets 部分帖子

部分帖子

partial posts.snippets
function pageLoad(sender, args) {
       if (args.get_isPartialLoad()) {
               //copy code here
       }

snippets 根据包含url部分的链接添加类 - 适合动态导航

根据包含url部分的链接添加类 - 适合动态导航

pathname.snippets
jQuery(function($) {
  $('.sidebar #menuElem li a[href^="/' + location.pathname.split("/")[1] + '"]').addClass('active');
});
location.snippets
var pathname = window.location.pathname;

current path after URL but not including URL variables 
(so all slashes/pages after .com
but no ?x= or &x= or google.com bits)

var url = window.location.href
includes variables (?x=...)

snippets 调整

调整

resize.snippets
// RELOAD ON RESIZE 
// reload page on resize to sort out css changes to slider nav
    $(window).resize(function() {
      if($(window).width() > 750){ // to keep jeremy's phone from wigging ;)
        location.href = location.href; 
      }
	});

snippets 列出并计算与其他计算机的连接数

列出并计算与其他计算机的连接数

number_of_connections_linux.snippets
lsof -i4 | grep -i ipv4 | grep -o -- '->.*' | sort | uniq -c | sort -g

snippets 分拣机

分拣机

sorter.snippets
<div class="unsorted">
    <div rel="5">
      Div 5 here
    </div>
    <div rel="3">
       Div 3 Here
    </div>
     <div rel="4.5">
       Div 4.5 here
    </div>
    <div rel="4">
      Div 4 Here
     </div> </div>
<div class="sorted"></div>
This script will give you the desired output:

$(document).ready(function () {
    var sortedDivs = $(".unsorted").find("div").toArray().sort(sorter);
    $.each(sortedDivs, function (index, value) {
        $(".sorted").append(value);
    });
});

function sorter(a, b) {
    return a.getAttribute('rel') - b.getAttribute('rel');
};

snippets 滚动的东西

滚动的东西

scroll.snippets
$(document).ready(function() {
    
    /* Every time the window is scrolled ... */
    $(window).scroll( function(){
    
        /* Check the location of each desired element */
        $('.hideme').each( function(i){
            
            var bottom_of_object = $(this).position().top + $(this).outerHeight();
            var bottom_of_window = $(window).scrollTop() + $(window).height();
            
            /* If the object is completely visible in the window, fade it it */
            if( bottom_of_window > bottom_of_object ){
                
                $(this).animate({'opacity':'1'},500);
                    
            }
            
        }); 
    
    });
fade-scroll.snippets
jQuery(function($) {

  $(window).load(function(){
    $("ul.gallery li:lt(12)").each(function(i) {
      $(this).delay((i++) * 50).fadeTo(500, 1);
    })
  });

  $(window).scroll( function(){
    $("ul.gallery li").each( function(i) {
      var bottom_of_object = $(this).position().top + $(this).outerHeight();
      var bottom_of_window = $(window).scrollTop() + $(window).height();
      if( bottom_of_window > bottom_of_object ) {
        $(this).fadeTo(500, 1);
      }
    }); 
  });

});
fade-in-LIs.snippets
// FLOWING-IN ICONS
	  		$(function() {
			$('ul#matrix li').each(function(i) {
				$(this).delay((i++) * 100).fadeTo(500, 1); 
			})
		});

snippets 包括()

包括()

contains.snippets
  $('h3').each(function(){
    	var txt1 = $(this).html();
      $("h3:contains(txt1)").css("text-decoration", "underline");
      console.log(txt1);
  });
  
  // more general contains
	$('.sidebar li').each(function(){
		$('.sidebar li:contains("Meeting Info")').attr('rel','1');
		$('.sidebar li:contains("Registration")').attr('rel','2');
		$('.sidebar li:contains("Hotel")').attr('rel','3');
		$('.sidebar li:contains("Travel")').attr('rel','4');
		$('.sidebar li:contains("Special Events")').attr('rel','5');
		$('.sidebar li:contains("Accreditation")').attr('rel','6');
		$('.sidebar li:contains("Objectives")').attr('rel','7');
		$('.sidebar li:contains("Scientific")').attr('rel','8');
		$('.sidebar li:contains("Location")').attr('rel','9');
		$('.sidebar li:contains("Format")').attr('rel','10');
		$('.sidebar li:contains("Schedule")').attr('rel','11');
	});

snippets 根据文本设置类

根据文本设置类

class-by-text.snippets
  $('._list1 li').each(function() { 
     var value = $(this).text();
     if(value == 'Site Map') {
        $(this).addClass('active'); 
     }
  });

snippets 在其他东西之前/之后插入东西

在其他东西之前/之后插入东西

insertAfter.snippets
.insertAfter 
.insertBefore 

<p> is what I said... </p>
<div id="foo">FOO!</div>
 
<script>
$( "p" ).insertAfter( "#foo" );
$( "<p>Test</p>" ).insertBefore( ".inner" );
</script>

displays specified content (entire element of whatever so in this case the entire <p> -- </p> before or after the entire specified #foo element instead of before

unlike after() where you have to say "<p>---</p>" in stead of "classname" for the target
clone.snippets
$( "b" ).clone().prependTo( "p" );
append.snippets
$("#logo").append("<img src='http://intranet.wjweiser.com/Shared/static/WeiserImageLibrary/ClientLogos/wjw.png' />");

puts specified content at the end of the element specified:

PRE-APPENDING
=============
<div id="logo">
  Other stuff we want to have still here and just stick the image after.
</div>

POST-APPEND!
=============
<div id="logo">
  Other stuff we want to have still here and just stick the image after.
  <img src='http://intranet.wjweiser.com/Shared/static/WeiserImageLibrary/ClientLogos/wjw.png' />
</div>

PREPEND
============
$( ".container" ).prepend( $( "h2" ) );