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
/*This code returns the path of the currently executing javascript file. This path can then be used to find relative paths to other files like the css files and images that are specific to this js file. | |
Should come in handy when making jQuery plugins if your script file makes used of script specific css. You can simply use string manipulation to create the relative path for your css. | |
Recommended use at the top of your plugin. | |
*/ | |
var jsFilePath = $("head").find("script:last").attr('src'); |
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
/*Sample code to calculate the max-width of an element via jquery that can be applied to all browsers*/ | |
/*Append the element to the body/anywhere else you want to append the element to, in order to allow the browser to render the initial width of the element*/ | |
var $element = ('<div></div>'); | |
$('body').append($element); | |
if($element.width()>someWidth){ | |
/*since the max-width property does not work in IE, | |
we set the max width by comparison after the element is added to the dom*/ | |
$element.css({'width':someWidth}); |
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
<!DOCTYPE html> | |
<!-- | |
The below script tag can be used to load the compressed/minified version of | |
the jQuery API fromt he Google CDN network. This can help in speeding up the | |
user's browsing experience if the jQuery library has already been cache'd in | |
the user's browser when used by some other website. So, instead of the browser | |
loading the API from your own website, it resuses the cache's version of the | |
jQuery API. | |
--> | |
<html> |
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
(function(jQuery){ | |
jQuery.fn.roundall=function(radius){ | |
return this.each(function(){ | |
$(this).css({'-moz-border-radius':radius,'border-radius':radius,'-webkit-border-radius':radius}); | |
}); | |
}; | |
})(jQuery); |
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
.overlay{ | |
position:absolute; | |
left:0px; | |
top:0px; | |
height:0px; | |
width:100%; | |
height:100%; | |
background-color:#fafafa | |
} |
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
//Displays the sourcecode for the currently | |
//selected element's first click handler | |
//in Google Chrome | |
$($0).data('events')['click'][0]['handler']; |
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
var logEnabled = true; | |
//Hack for IE. The window.console object is not available until the | |
//console window has been opened at least once | |
//Associated stackoverflow post - http://stackoverflow.com/questions/10961430/ie9-not-running-javascript-onload/12924439#12924439 | |
if(!window.console){ | |
console={}; | |
console.log = 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
function randomize(arr) { | |
for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x); | |
return arr; | |
}; |
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
foreach ($aMapLikeCollection as $key => $value) { | |
} |
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
$( | |
//Setting the value of a radio button programmatically | |
$('input[type=radio]').prop('checked', true); | |
); |
OlderNewer