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
// Inline assignment inside an 'if' statement works with most programming languages. | |
// However, in JavaScript there's a gotcha. | |
// This works in Safari, Firefox & Chrome...but will destroy your life in IE. | |
if(thing=functionThatReturnsThing()) { | |
doStuff(); | |
} | |
// Do this instead | |
var thing=functionThatReturnsThing(); |
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
// Backbone.js 0.9.1 | |
// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc. | |
// Backbone may be freely distributed under the MIT license. | |
// For all details and documentation: | |
// http://backbonejs.org | |
// | |
// HACKED TO BE PROTOTYPE.JS COMPATIBLE BY [SUBIMAGE AT GMAIL DOT COM] | |
// REQUIRES PROTOTYPE >= 1.7.1 | |
// !!! TODO needs tests! |
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
Backbone.BaseCollection = Backbone.Collection.extend({ | |
// Holds id of locally deleted items we ignore if we | |
// 'freshen' the collection and changes haven't propagated yet. | |
_localDeletedIds: [], | |
// Take an array of raw objects | |
// If the ID matches a model in the collection, set that model | |
// If the ID is not found in the collection, add it | |
// If a model in the collection is no longer available, remove it | |
// | |
// Keeps local changes, in case we've added things in the meantime. |
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
// Splits an array into equal sized chunks | |
Array.prototype.chunk = function(pieces) { | |
pieces = pieces || 2; | |
var len = this.length; | |
var mid = (len/pieces); | |
var chunks = []; | |
var start = 0; | |
for(var i=0;i<pieces;i++) { | |
var last = start+mid; | |
if (!len%pieces >= i) { |
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
/** | |
* Take string input in varName and determine whether it is defined object in Javascript | |
* ...like isDefined('foo.bar.baz'); | |
* Better than doing if(foo && foo.bar && foo.bar.baz){} | |
* @param {String} varName | |
* @return {boolean} | |
* @author Bilal Soylu | |
*/ | |
function isDefined(varName) { | |
var retStatus = 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
//Ext.ns('CbMobile', 'CbMobile.views'); | |
new Ext.Application({ | |
name: 'CbMobile', | |
SIDEBAR_WIDTH: 320, | |
MENU_WIDTH: 250, | |
MENU_HEIGHT: 200, | |
launch: function() { | |
var app = this; |
NewerOlder