This file contains 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
/* jQuery selector to match exact text inside an element | |
* http://wowmotty.blogspot.com/2010/05/jquery-selectors-adding-contains-exact.html | |
* :containsExact() - case insensitive | |
* :containsExactCase() - case sensitive | |
* :containsRegex() - set by user ( use: $(el).find(':containsRegex("/(red|blue|yellow)/gi")') ) | |
*/ | |
$.extend( $.expr[":"], { | |
containsExact: $.expr.createPseudo ? | |
$.expr.createPseudo(function(text) { | |
return function(elem) { |
This file contains 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
/* Javascript function to convert rgb format to a hex color | |
* call : rgb2hex( "rgb(0, 70, 255)" ); | |
* returns: #0046ff | |
*/ | |
function rgb2hex(rgb){ | |
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); | |
return "#" + | |
("0" + parseInt(rgb[1],10).toString(16)).slice(-2) + | |
("0" + parseInt(rgb[2],10).toString(16)).slice(-2) + | |
("0" + parseInt(rgb[3],10).toString(16)).slice(-2); |
This file contains 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
/* Returns URL parameter | |
* url: http://www.somesite.com?name=hello&id=11111 | |
* z = gup('name'); // z = hello; s = string, or leave blank to target window location | |
* Original code from Netlobo.com (http://www.netlobo.com/url_query_string_javascript.html) | |
*/ | |
function gup(n,s){ | |
n = n.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]"); | |
var p = (new RegExp("[\\?&]"+n+"=([^&#]*)")).exec(s || window.location.href); | |
return (p===null) ? "" : p[1]; | |
} |
This file contains 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){ |
This file contains 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 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 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 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 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 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 |
OlderNewer