This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Checkbox Hack */ | |
input[type=checkbox] { | |
position: absolute; | |
top: -9999px; | |
left: -9999px; | |
} | |
label { | |
-webkit-appearance: push-button; | |
appearance: button; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Check if all images are loaded | |
- Callback occurs when all images are loaded | |
- image load errors are ignored (complete will be true) | |
- Use: | |
$('.wrap img').imagesLoaded(function(){ | |
alert('all images loaded'); | |
}); | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
/* | |
String.allIndexOf(searchstring, ignoreCase) | |
String [String] - the string to search within for the searchstring | |
searchstring [String] - the desired string with which to find starting indexes | |
ignoreCase [Boolean] - set to true to make both the string and searchstring case insensitive | |
Use: | |
var s = "The rain in Spain stays mainly in the plain"; | |
s.allIndexOf("ain"); // result [ 5,14,25,40 ] | |
s.allIndexOf("the"); // result [ 34 ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://wowmotty.blogspot.com/2011/10/jquery-rename-attribute-renameattr.html | |
// ********* | |
jQuery.fn.extend({ | |
renameAttr: function( name, newName, removeData ) { | |
var val; | |
return this.each(function() { | |
val = jQuery.attr( this, name ); | |
jQuery.attr( this, newName, val ); | |
jQuery.removeAttr( this, name ); | |
// remove original data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://wowmotty.blogspot.com/2011/10/adding-swipe-support.html | |
// ********** | |
var target = $('#box'), | |
// allow movement if < 1000 ms (1 sec) | |
maxTime = 1000, | |
// swipe movement of 50 pixels triggers the swipe | |
maxDistance = 50, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/************************************************ | |
Adding WordPress Quicktag Buttons to a WP Plugin | |
************************************************/ | |
?> | |
<style> | |
/* Simulate the input buttons styles */ | |
#ed_toolbar button { | |
display: inline-block; | |
vertical-align: middle; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code I paste into the Firebug Console after I run the Visual Event | |
// bookmarklet (http://www.sprymedia.co.uk/article/Visual+Event) | |
// so I can cycle through the layers - Use arrow keys to cycle | |
var veColors = [ 'black', 'orange', 'purple', 'green', 'blue', 'yellow', 'red' ], | |
veColorLength= veColors.length - 1, | |
veLayerIndex = 0; | |
function showVeLayer(nxt){ | |
veLayerIndex += (nxt) ? 1 : -1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Enable or disable DOM objects | |
* This is a basic script - it won't determine | |
* if an object can be enabled or disabled | |
* | |
* Use: $('button').disable(); | |
* $('button').enable(); | |
*/ | |
(function($){ | |
$.fn.extend( { | |
enable : function(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Find & return only duplicates from an Array | |
* also returned is an object with the # of duplicates found | |
* myArray = ["ccc", "aaa", "bbb", "aaa", "aaa", "aaa", "aaa", "bbb"]; | |
* x = myArray.getDuplicates(); | |
* // x = [ array of duplicates, associative object with # found] | |
* // x = [ ['aaa','bbb'] , { 'aaa' : 5, 'bbb' : 2 } ] | |
* alert(x[0]) // x[0] = ['aaa','bbb'] & alerts aaa,bbb | |
* alert(x[1]['aaa']) // alerts 5; | |
*/ | |
Array.prototype.getDuplicates = function(sort) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Return a unique array | |
* myArray = ["ccc","aaa","bbb","aaa"]; | |
* x = myArray.getUnique(); // x = ["ccc","aaa","bbb"] | |
* y = myArray.getUnique(true); // y = ["aaa","bbb","ccc"] | |
*/ | |
// Slightly faster version than getUnique2; Modified from | |
// http://dreaminginjavascript.wordpress.com/2008/08/22/eliminating-duplicates/ | |
Array.prototype.getUnique1 = function(s){ | |
var c, a = [], o = {}, i, j = 0, l = this.length; | |
for(i=0; i<l; ++i){ |