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
// ----------------------------------------------------------------------------- command | |
define('command', ['underscore', 'backbone'], function(_, Backbone) { | |
var Command = function() {}; | |
Command.prototype = _.extend({}, Backbone.Event, { | |
ALWAYS: 'always.command', | |
DONE: 'done.command', |
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($){ | |
var settings, defaults = { | |
prop1 : 'value1', | |
prop2 : 'value2' | |
}; | |
var methods = { |
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($){ | |
$.fn.basicPlugin = function(options) { | |
var defaults = { | |
prop1 : 'value1', | |
prop2 : 'value2', | |
}; | |
var settings = (options) ? $.extend({},defaults,options) : defaults; |
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($){ | |
var cssRegex = /.css$/, jsRegex=/.js$/; | |
var endsWith = function(string,pattern) { return asset.match(pattern); }; | |
var isCSS = function(filename) { return endsWith(filename,cssRegex); }; | |
var isJS = function(filename) { return endsWith(filename,jsRegex); }; | |
var loadAssets = function(assets) { | |
if (!assets) return; |
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
var toBool = function(value) { | |
switch (value.toLowerCase()) { | |
case "true": | |
case "yes": | |
case "y": | |
case "o": | |
case "off": | |
case "1": | |
return true; | |
case "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
var getQueryString = function(name) { | |
var pairs = window.location.search.substring(1).split("&"), pair; | |
for ( var i = 0; i < pairs.length; i++) { | |
pair = pairs[i].split("="); | |
if (pair[0] == name) return pair[1]; | |
} | |
return null; | |
}; |
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
var Cache = function(pMaxSize) { | |
this.lastID = 0; | |
this.items = {}; | |
this.numItems = 0; | |
var maxSize = parseInt(pMaxSize, 10); | |
if (isNaN(maxSize)) maxSize = -1; | |
this.maxNumItems = maxSize; | |
this.itemDefault = { | |
ttl : 3600, // time to live = 1 hour | |
priority : 2 // 1=low, 2=medium, 3=high |
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 safeConsole() { | |
if (typeof window.console == "undefined") { window.console = {}; } | |
for (var methods = "log,warn,error,info,dir".split(","), safe=function(){}, method; method=methods.pop();) { | |
window.console[method] = window.console[method] || safe; | |
} | |
})(); |
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
class FloatUtil | |
{ | |
public static function fixedFloat(v:Float, ?precision:Int = 2):Float | |
{ | |
return Math.round( v * Math.pow(10, precision) ) / Math.pow(10, precision); | |
} | |
} |
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 getPercentageOfElementAreaViewable(el) { | |
var viewport = { width: window.innerWidth, height: window.innerHeight }; | |
var rect = el.getBoundingClientRect(); | |
var area = rect.width * rect.height; | |
var visibleHeight = rect.height; | |
var visibleWidth = rect.width; | |
// deduct amount out of viewport at top | |
if (rect.top < 0) visibleHeight += rect.top; |
OlderNewer