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 FooModel = Y.Base.create('fooModel', Y.Model, [], { | |
| idAttribute : 'uid' | |
| }, { | |
| ATTRS : { | |
| uid : {} | |
| foo : {} | |
| } | |
| }); | |
| var foo = new FooModel({ uid: '1', foo: 'foo' }); |
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
| <script type="text/template" id="template-user"> | |
| <div class="user"> | |
| <h3>{name}</h3> | |
| <p>{lifeStory}</p> | |
| </div> | |
| </script> | |
| <script> | |
| YUI().use('node', function(Y){ | |
| var user = { name: 'Eric', lifeStory: 'codes all day' }, | |
| template = Y.one('template-user').getContent(); |
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
| YUI().use('gallery-markout', function(Y){ | |
| var collection = ['a', 'b', 'c'], | |
| list = Y.Markout().ul({ id: 'my-list' }); | |
| Y.each(collection, function(){ | |
| list.li({ 'class': 'item'}, this); | |
| }); | |
| list.node().appendTo('body'); | |
| }); |
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
| /** | |
| Model Resource | |
| @module model-resource | |
| **/ | |
| var ModelResource, | |
| isFunction = Y.Lang.isFunction, | |
| noop = function(){}; |
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
| // *** Place *** // | |
| Place = Y.Base.create('place', Y.Model, [YQLSync], { | |
| idAttribute : 'woeid', | |
| query : 'SELECT * FROM geo.places WHERE woeid={id}', | |
| parse : function (results) { | |
| if ( ! results) { return; } | |
| var data = results.place; |
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
| handlePlace : function (req) { | |
| var params = req.params, | |
| page = (parseInt(params.page, 10) || 1) - 1; | |
| // redirect crufty URL to a clearer one | |
| if (params.page && page <= 0) { | |
| return this.replace('/place/' + params.id + '/'); | |
| } | |
| this.place.set('id', params.id); |
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
| // *** YQLSync *** // | |
| YQLSync = function(){}; | |
| YQLSync.prototype = { | |
| query : '', | |
| cache : new Y.CacheOffline, | |
| buildQuery : function () { | |
| return sub(this.query, { id: this.get('id') }); |
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
| { | |
| "font_face": "Inconsolata", | |
| "font_size": 14, | |
| "font_options": [], | |
| "translate_tabs_to_spaces": true, | |
| "ensure_newline_at_eof_on_save": true, | |
| "fallback_encoding": "UTF-8" | |
| } |
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
| morePhotos : function () { | |
| var photos = this.photos, | |
| newPhotos = new Photos(); | |
| newPhotos.load({ | |
| place : this.place, | |
| start : photos.size() | |
| }, Y.bind(function(){ | |
| var allPhotos = photos.toArray().concat(newPhotos.toArray()); | |
| photos.refresh(allPhotos); |
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
| YUI 3 at: /Users/eferraiuolo/Tools/yui/yui3 | |
| YUI 3 Gallery at: /Users/eferraiuolo/Tools/yui/yui3-gallery | |
| REST Model Sync Test Server running at: http://localhost:3000/ |