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
//********** CLASS ********** | |
hasClass = function (el, cl) { | |
var regex = new RegExp('(?:\\s|^)' + cl + '(?:\\s|$)'); | |
return !!el.className.match(regex); | |
}, | |
addClass = function (el, cl) { | |
el.className += ' ' + cl; | |
}, | |
removeClass = function (el, cl) { | |
var regex = new RegExp('(?:\\s|^)' + cl + '(?:\\s|$)'); |
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
//USE CASE | |
$('#q').selectRange(0, 10); | |
$('#q').selectRange(searchVal.indexOf('{'), (searchVal.indexOf('}')+1)); | |
//Source here : http://plugins.jquery.com/project/selectRange | |
$.fn.selectRange = function(start, end) { | |
var e = document.getElementById($(this).attr('id')); // I don't know why... but $(this) don't want to work today :-/ | |
if (!e) return; |
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 shuffle = function() { | |
var allElems = this.get(), | |
getRandom = function(max) { | |
return Math.floor(Math.random() * max); | |
}, | |
shuffled = $.map(allElems, function(){ | |
var random = getRandom(allElems.length), | |
randEl = $(allElems[random]).clone(true)[0]; | |
allElems.splice(random, 1); | |
return randEl; |
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
email --- ^[\_]*([a-z0-9]+(\.|\_*)?)+@([a-z][a-z0-9\-]+(\.|\-*\.))+[a-z]{2,6}$ | |
domain --- ^([a-z][a-z0-9\-]+(\.|\-*\.))+[a-z]{2,6}$ | |
Year 1900-2099 --- ^(19|20)[\d]{2,2}$ | |
Date (dd mm yyyy, d/m/yyyy, etc.) --- ^([1-9]|0[1-9]|[12][0-9]|3[01])\D([1-9]|0[1-9]|1[012])\D(19[0-9][0-9]|20[0-9][0-9])$ | |
IP v4 --- ^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]){3}$ |
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
/************** inline-block ********************/ | |
li { | |
width: 200px; | |
min-height: 250px; | |
border: 1px solid #000; | |
display: -moz-inline-stack; | |
display: inline-block; | |
vertical-align: top; | |
margin: 5px; | |
zoom: 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
/* Smartphones (portrait and landscape) ----------- */ | |
@media only screen | |
and (min-device-width : 320px) | |
and (max-device-width : 480px) { | |
/* Styles */ | |
} | |
/* Smartphones (landscape) ----------- */ | |
@media only screen | |
and (min-width : 321px) { |
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 Plugin Boilerplate | |
// A boilerplate for jumpstarting jQuery plugins development | |
// version 1.1, May 14th, 2011 | |
// by Stefan Gabos | |
// remember to change every instance of "pluginName" to the name of your plugin! | |
(function($) { | |
// here we go! | |
$.pluginName = function(element, options) { |
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 html = (function () {/* | |
<!DOCTYPE html> | |
<html> | |
<body> | |
<h1>Hello, world!</h1> | |
</body> | |
</html> | |
*/}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[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
$('#favorite').click(function(e){ | |
e.preventDefault(); | |
var url = 'http://github.com'; | |
var title = 'GitHub'; | |
var ctrl = (window.navigator.userAgent.toLowerCase()).indexOf('mac') !== -1 ? 'Command' : 'Ctrl'; | |
var info = 'Sorry, your browser is not supported. Please use' + ctrl + '+D to add favorite'; | |
try { | |
window.external.addFavorite(url, title); |
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 ua = navigator.userAgent; | |
if( ua.indexOf("Android") >= 0 ) { | |
var androidversion = parseFloat(ua.slice(ua.indexOf("Android")+8)); | |
if (androidversion < 2.3) { | |
// do whatever | |
} | |
} |
OlderNewer