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
// requirejs config in main.js | |
require.config({ | |
paths: { | |
jquery: 'components/jquery/jquery', | |
es5shim: 'components/es5-shim/es5-shim', | |
es5sham: 'components/es5-shim/es5-sham' | |
}, | |
map: { | |
'*': { | |
'flight/component': 'components/flight/lib/component', |
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
require.config({ | |
dir: "../../release/js/", | |
optimize: "uglify", | |
paths: { | |
jquery: 'vendor/jquery/jquery-1.9.0', | |
underscore: 'vendor/underscore', | |
backbone: 'vendor/backbone/backbone', | |
text: 'vendor/require/plugins/text', | |
cordova: 'vendor/android/cordova-2.3.0' |
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
(def my-apply | |
(fn [function sequence] | |
(eval (cons function sequence)))) | |
;; exercises | |
;; chapter 1 | |
;; 3. add squares | |
(defn add-squares [& args] | |
(apply + (map * args args))) |
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
define(function (require, exports, module) { | |
var lib1 = require('lib1'); | |
var lib2 = require('lib2'); | |
// your code goes here | |
// exports = ...; | |
}); |
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
(function ($) { | |
var startPos, curPos, endPos, dragTimer, dragEl, dragOffset; | |
var isTouchable = (function () { return !!('ontouchstart' in window); })(); | |
var events = { | |
touchstart: "mousedown", | |
touchmove: "mousemove", | |
touchend: "mouseup" | |
}; |
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
// modules (one per file) | |
(function (namespace) { | |
"use strict"; | |
// implementation | |
})(namespace); | |
// files.js (loaded in dev) |
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
// resources gathered around inheritance and Object.create | |
// http://ericleads.com/2012/09/stop-using-constructor-functions-in-javascript/ | |
// https://speakerdeck.com/anguscroll/parlez-vous-javascript | |
// http://dailyjs.com/2012/06/04/js101-object-create/ | |
// inheritance via prototype | |
// both constructors A, B are initialized | |
function A() { | |
console.log("init A"); | |
this.log = "A"; |
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
//viewport for https://github.com/scttnlsn/backbone.viewkit | |
var NamedViewSelector = Backbone.ViewKit.ViewPort.extend({ | |
constructor: function (options) { | |
options || (options = {}); | |
this._views = options.views || {}; | |
_.each(this._views, function(view) { | |
view.viewSelector = this; | |
}, this); |
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
(function () { | |
"use strict"; | |
var Logger = this.Logger = function ($el) { | |
this.$logger = $el; | |
this.timers = {}; | |
} | |
Logger.prototype.stop = function (label) { |
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
(function () { | |
"use strict"; | |
/** | |
* DB constructor | |
* | |
* @param {Object} options | |
* @param {Function} callback | |
*/ |