-
-
Save patrickandre/6985123 to your computer and use it in GitHub Desktop.
Revisions
-
Limin Shen revised this gist
Apr 8, 2013 . 2 changed files with 24 additions and 53 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,37 +1,29 @@ /** * Implement Foo Object. * - Take a JSON object as an input parameter * - Create a copy this JSON object as itself. * - Chainable */ var foo = new Foo({ version : '1.0' }); // add components foo .set({ type : 'Foo', container : '#foo' }) // add features .addItem(['item1','item3']) .addItem('item2'); /** * Expect output */ foo = { version : '1.0', type : 'Foo', container : '#foo', items : ['item1', 'item3', 'item2'] } 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 charactersOriginal file line number Diff line number Diff line change @@ -1,41 +1,20 @@ /** * Foo Object */ var Foo = function (config) { var options = JSON.parse( JSON.stringify(config) ); options.items = []; _.extend(this, options); }; Foo.prototype.set = function (config) { _.extend(this, config); return this; }; Foo.prototype.addItem = function (items) { items = _(items).isArray() ? items : [items]; this.items = _.union(this.items, items); return this; }; -
Limin Shen revised this gist
Apr 7, 2013 . 1 changed file with 8 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,12 +2,15 @@ * Component Object */ var Component = function (config) { this.components = _(config).isArray() ? config : [config]; } Component.prototype.addFeature = function (owner, name) { name = _(name).isArray() ? name : [name]; _(this.components).forEach(function (component) { if ( !component.features ) { component.features = {}; } var path = component.features; path[owner] = path[owner] || []; @@ -24,8 +27,9 @@ Component.prototype.addFeature = function (owner, name) { * Firebird Object */ var Firebird = function (config) { var options = JSON.parse( JSON.stringify(config) ); options.components = {}; _.extend(this, options); }; Firebird.prototype.addComponent = function (id, config) { -
Limin Shen revised this gist
Apr 7, 2013 . No changes.There are no files selected for viewing
-
Limin Shen revised this gist
Apr 7, 2013 . 2 changed files with 43 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,9 @@ /** * Implement Firebird Object. * - Take a JSON object as an input parameter * - Create a copy this JSON object as itself. * - Chainable */ var firebird = new Firebird({ version : '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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ /** * Component Object */ var Component = function (config) { this = config; } Component.prototype.addFeature = function (owner, name) { name = _(name).isArray() ? name : [name]; _(this).forEach(function (component) { var path = component.features; path[owner] = path[owner] || []; _(name).forEach(function (newName) { if ( !_(path[owner]).contains(newName) ) { path[owner].push(newName); } }); }); return this; }; /** * Firebird Object */ var Firebird = function (config) { this = JSON.parse( JSON.stringify(config) ); this.components = {}; }; Firebird.prototype.addComponent = function (id, config) { this.components[id] = _.extend({}, config, { id : id }); return new Component(this.components[id]); }; -
Limin Shen revised this gist
Apr 7, 2013 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,9 +4,9 @@ var firebird = new Firebird({ // add components firebird .addComponent('list1', { type : 'contentList', container : '#container-123' }) // add features .addFeature('list', ['pagination','item']) @@ -19,9 +19,9 @@ firebird = { version : '1.0', components : { reviewList1 : { id : 'list1', type : 'contentList', container : '#container-123', features : { list : ['pagination', 'item'], item : ['stars'] -
Limin Shen revised this gist
Apr 7, 2013 . No changes.There are no files selected for viewing
-
Limin Shen renamed this gist
Apr 7, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Limin Shen revised this gist
Apr 7, 2013 . 2 changed files with 31 additions and 37 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ var firebird = new Firebird({ version : '1.0' }); // add components firebird .addComponent('reviewList1', { type : 'contentList', container : '#BVRRContainer' }) // add features .addFeature('list', ['pagination','item']) .addFeature('item', 'stars'); /** * Expect output */ firebird = { version : '1.0', components : { reviewList1 : { id : 'reviewList1', type : 'contentList', container : '#BVRRContainer', features : { list : ['pagination', 'item'], item : ['stars'] } } } } 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 charactersOriginal file line number Diff line number Diff line change @@ -1,37 +0,0 @@ -
Limin Shen created this gist
Apr 7, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ var firebird = new Firebird(fbJson); // add components firebird .addComponent('reviewList1', { type : 'contentList', container : '#BVRRContainer' }) // add features .addFeature('list', ['pagination','item']) .addFeature('item', 'stars'); /** * Expect output * * firebird = { * components : { * reviewList1 : { * id : 'reviewList1', * type : 'contentList', * container : '#BVRRContainer', * features : { * list : ['pagination', 'item'], * item : ['stars'] * } * } * } * } } } * } } * } * } */