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
Handlebars.registerHelper('loc', function(property, fn) { | |
var str; | |
// we are bound to a value, it is now the context | |
if (fn.contexts && typeof fn.contexts[0] === 'string') { | |
str = fn.contexts[0]; | |
// Convention, start all localization keys with _ | |
} else if (property[0] === '_') { | |
str = property; |
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
// <== BOOTSTRAP | |
var App = Ember.Application.create(); | |
App.stateManager = Ember.StateManager.create(); | |
DS.fixtureAdapter.createRecord = function(store, type, record) { | |
var json = record.toJSON(); | |
json.id = 1; | |
store.didCreateRecord(record, json); |
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
<!doctype html> | |
<html><head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> | |
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script> | |
<script type='text/javascript' src="http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js"></script> | |
<script type='text/javascript' src="http://cloud.github.com/downloads/emberjs/ember.js/ember-latest.js"></script> | |
</head><body> | |
<script type="text/x-handlebars" data-template-name="application"> | |
<h1>Application</h1> | |
<a href="#/dashboard">Dashboard</a> |
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
test("filtered property on hasMany assoctiation", function() { | |
var File = DS.Model.extend({ | |
primaryKey: 'name', | |
name: DS.attr('string'), | |
status: DS.attr('string') | |
}); | |
var Project = DS.Model.extend({ | |
primaryKey: 'name', |
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
Species = DS.Model.extend({ | |
name: DS.attr('string') | |
}); | |
Person = DS.Model.extend({ | |
name: DS.attr('string'), | |
species: DS.belongsTo(Species, { embedded: true }) | |
tags: DS.hasMany(Tag, { embedded: true }) | |
}); |
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
App.ajax = (url, settings)-> | |
deferred = $.Deferred() | |
settings.xhr = -> | |
xhr = $.ajaxSettings.xhr() | |
if 'onprogress' of xhr | |
context = this | |
xhr.onprogress = (e)-> | |
Ember.run(deferred, deferred.notifyWith, context, [e.loaded/e.total]) | |
xhr | |
jqXHR = $.ajax(url, settings) |
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
App = Ember.Application.create({}); | |
App.loginController = Ember.Object.create({ | |
// do login stuff | |
}); | |
App.LoginFormView = Ember.View.extend({ | |
login: null, | |
password: null, |
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
App.LoginState = Ember.State.extend({ | |
enter: function() { | |
App.loginView = App.LoginView.create(); | |
App.loginView.appendTo('#content.container'); | |
}, | |
submit: function(a, params) { | |
App.loginView.loggingIn(); |
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
findAll: function(store, type) { | |
var root = this.rootForType(type); | |
this.ajax(root, "GET", { | |
success: function(json) { | |
store.loadMany(type, json["objects"]); | |
store.typeMapFor(type).modelArrays.forEach( function(item) { | |
item.set('isLoaded', true); | |
}); | |