Skip to content

Instantly share code, notes, and snippets.

View ericf's full-sized avatar

Eric Ferraiuolo ericf

View GitHub Profile
var FooModel = Y.Base.create('fooModel', Y.Model, [], {
idAttribute : 'uid'
}, {
ATTRS : {
uid : {}
foo : {}
}
});
var foo = new FooModel({ uid: '1', foo: 'foo' });
<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();
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');
});
/**
Model Resource
@module model-resource
**/
var ModelResource,
isFunction = Y.Lang.isFunction,
noop = function(){};
// *** 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;
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);
// *** YQLSync *** //
YQLSync = function(){};
YQLSync.prototype = {
query : '',
cache : new Y.CacheOffline,
buildQuery : function () {
return sub(this.query, { id: this.get('id') });
@ericf
ericf / gist:1103394
Created July 25, 2011 01:50
Sublime Text 2 User Settings
{
"font_face": "Inconsolata",
"font_size": 14,
"font_options": [],
"translate_tabs_to_spaces": true,
"ensure_newline_at_eof_on_save": true,
"fallback_encoding": "UTF-8"
}
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);
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/