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
//Observe input events | |
// Do your stuff after 1 seconds of last user input | |
$(document).on('input keyup', '.observe', function () { | |
var $this = $(this); | |
var delay = 500; // 0.5 seconds delay after last input | |
clearTimeout($this.data('timer')); | |
$this.data('timer', setTimeout(function () { | |
$this.removeData('timer'); | |
// Do your stuff after 0.5 seconds of last user input |
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 findById(source, id) { | |
for (var i = 0; i < source.length; i++) { | |
if (source[i].name === id) { | |
return source[i]; | |
} | |
} | |
throw "Couldn't find object with id: " + id; | |
} |
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 getBase64Image(img) { | |
// Create an empty canvas element | |
var canvas = document.createElement("canvas"); | |
canvas.width = img.width; | |
canvas.height = img.height; | |
// Copy the image contents to the canvas | |
var ctx = canvas.getContext("2d"); | |
ctx.drawImage(img, 0, 0); |
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
// Speed up calls to hasOwnProperty | |
var hasOwnProperty = Object.prototype.hasOwnProperty; | |
function is_empty(obj) { | |
// null and undefined are empty | |
if (obj == null) return true; | |
// Assume if it has a length property with a non-zero value | |
// that that property is correct. | |
if (obj.length && obj.length > 0) return false; |
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
/** | |
* Parse Query String | |
* @param {string} name of value | |
* @return {string} | |
* @uses : var year = parseQueryString("year"); // returns "2013" | |
*/ | |
function parseQueryString ( name ) { | |
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); | |
var regexS = "[\\?&]"+name+"=([^&#]*)"; | |
var regex = new RegExp( regexS ); |
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
// url = "http://localhost/index.php?module=search¶m1=4"; | |
function jsonObjFromURL (url){ | |
var parameters = url.split("?"), | |
jsObject = {}, | |
jsObjectParams = {}, | |
paramPair; | |
jsObject.baseURL = parameters[0]; |
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
/** | |
* Use: $.wait(1000).then( goMakeTea ); | |
**/ | |
$.wait = function(duration) { | |
return $.Deferred(function(def){ | |
setTimeout(def.resolve, duration); | |
}); | |
} |
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
Show hidden characters
{ | |
"auto_complete_commit_on_tab": true, | |
"bold_folder_labels": true, | |
"caret_style": "phase", | |
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme", | |
"draw_minimap_border": true, | |
"draw_white_space": "all", | |
"ensure_newline_at_eof_on_save": true, | |
"fade_fold_buttons": false, | |
"file_exclude_patterns": |
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
//Filename: boilerplate.js | |
define([ | |
// These are path alias that we configured in our bootstrap | |
'jquery', // lib/jquery/jquery | |
'underscore', // lib/underscore/underscore | |
'backbone' // lib/backbone/backbone | |
], function($, _, Backbone){ | |
// Above we have passed in jQuery, Underscore and Backbone | |
// They will not be accessible in the global scope |
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
.myDiv .clearfix:after { | |
content: "."; | |
display: block; | |
height: 0; | |
clear: both; | |
visibility: hidden; | |
} |
OlderNewer