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(Backbone){ | |
Backbone.inherit = function(){ | |
var classes = Array.prototype.slice.call(arguments, 0); | |
// prerequisites | |
if( !classes.length ) return; | |
var Class = classes.pop(); | |
// loop through objects | |
for( var i in classes){ |
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
body.loading:after { | |
/* with no content, nothing is rendered */ | |
content: ""; | |
position: fixed; | |
/* element stretched to cover during rotation an aspect ratio up to 1/10 */ | |
top: -500%; | |
left: -500%; | |
right: -500%; | |
bottom: -500%; | |
z-index: 9999; |
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
_.mixin({ | |
// Uppercase the first character of each word in a string | |
// From: http://phpjs.org/functions/ucwords/ | |
ucwords : function(str) { | |
return (str + '').replace(/^([a-z])|\s+([a-z])/g, function ($1) { | |
return $1.toUpperCase(); | |
}); | |
} | |
}); |
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
_.mixin({ | |
// - Sort a list alphabetically | |
sortByName : function(a, b) { | |
var x = a.name.toLowerCase(); | |
var y = b.name.toLowerCase(); | |
return ((x < y) ? -1 : ((x > y) ? 1 : 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
_.mixin({ | |
// - Check if a number is an integer | |
isInteger : function(s){ return parseInt(s,10)===s; } | |
}); |
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
_.mixin({ | |
// - Takes an array-like object and turns it into a real Array | |
// to make all the Array.prototype goodness available. | |
toArray : function ( a ) { | |
return [].slice.call( a ); | |
// alternatively: | |
//Array.prototype.slice.call( a ); | |
} | |
}); |
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
_.mixin({ | |
// `toNumber` takes a value given as `numeric` parameter and tries to turn it into a number. | |
// If it is not possible it returns 0 (or other value given as `fallback`). | |
toNumber : function (numeric, fallback) { | |
return isNaN(numeric) ? (fallback || 0) : Number(numeric); | |
} | |
}); |
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
_.mixin({ | |
// parses a query string and returns the parameters in a javascript object | |
getParams : function(query){ | |
var query = {}; | |
data.replace( | |
new RegExp("([^?=&]+)(=([^&]*))?", "g"), | |
function($0, $1, $2, $3) { query[$1] = decodeURIComponent($3); } | |
); | |
return query; | |
} |
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 uniqueCode(){ | |
var characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; | |
var ticks = (new Date()).getTime().toString(); | |
var code = ""; | |
for (var i = 0; i < characters.length; i += 2) { | |
if ((i + 2) <= ticks.length) { | |
var number = parseInt(ticks.substr(i, 2)); | |
if (number > characters.length - 1) { | |
var one = number.toString().substr(0, 1); | |
var two = number.toString().substr(1, 1); |