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
#!/env/node | |
/** | |
* Measure the effect of "bloat" (repeated property chunks in a stylesheet, as might | |
* be introduced by a preprocessor and @mixin directives) in a randomly generated | |
* style sheet. Uses a small pool of property names and possible values for the purposes | |
* of the benchmark. Can configure the "bloat" factor by tweaking DUPE_FACTOR. That | |
* factor determines what % of the rules generated will be treated as repeatable, | |
* mixin-like rules. | |
* |
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
// @browsertest-depend library.js.rm.models.Model.js | |
// @browsertest-depend library.js.view.View.js | |
// @browsertest-depend library.js.view.mixin.Skeleton.js | |
// @browsertest-depend test.js.library.view.GraphPersonDirectoryFixture.js | |
// @browsertest-depend test.js.library.view.ViewDemo.html | |
// @browsertest-depend test.js.library.view.ViewDemo.css | |
module('View.Layout'); | |
function defineViews() { |
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
var Track = Backbone.Model.extend(), | |
TrackList = Backbone.Collection.extend({ | |
model: Track | |
}), | |
Album = Backbone.RelationalModel.extend({ | |
relations: { | |
trackList: TrackList | |
} | |
}); |
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
var album_json = { | |
name: "My Album", | |
releaseYear: "2010", | |
trackList: [ | |
{ | |
name: "My First Track", | |
order: 0, | |
duration: 3600, | |
streamUrl: "http://example.com/stream.mp3"} | |
] |
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
var model = new Album(album_json); | |
model.set({ | |
trackList: [{ | |
name: "A different track", | |
order: 0, | |
duration: 1800, | |
streamUrl: "http://example.com/stream2.mp3"}] | |
}); |
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
{ | |
"album_id": "1", | |
"name": "My Track", | |
"duration": 3600, | |
"streamUrl": "http://example.com/stream.mp3" | |
} |
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 delegateModelEvents(from, to, eventKey) { | |
from.bind('all', function(eventName) { | |
var args = _.toArray(arguments); | |
if (eventKey) { | |
args[0] = eventKey + ':' + args[0]; | |
} | |
to.trigger.apply(to, 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
album.bind('trackList:change:name', function(track) { ... }); |
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
var Track = Backbone.Model.extend(), | |
TrackList = Backbone.Collection.extend({ | |
model: Track | |
}), | |
Album = Backbone.Model.extend(); |
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
var Multiton = (function() { | |
var _instances = {}, | |
_products, _default; | |
function create_instance(name) { | |
var prefix = 'Product_', | |
product_name; | |
product_name = prefix + name.slice(0, 1).toUpperCase() + name.substring(1); | |
if (typeof _products[product_name] === 'function') { |
OlderNewer