app/assets/javascripts/rightnow_oms/vendor/ember.js in rightnow_oms-0.1.2 vs app/assets/javascripts/rightnow_oms/vendor/ember.js in rightnow_oms-0.1.3

- old
+ new

@@ -9768,13 +9768,13 @@ MyApp.listController.set('content', data); }); Then, create a view that binds to your new controller: - {{#collection contentBinding="MyApp.listController"}} - {{content.firstName}} {{content.lastName}} - {{/collection}} + {{#each MyApp.listController}} + {{firstName}} {{lastName}} + {{/each}} The advantage of using an array controller is that you only have to set up your view bindings once; to change what's displayed, simply swap out the `content` property on the controller. @@ -12605,11 +12605,11 @@ // at view initialization time. This happens in Ember.ContainerView's init // method. Ember.View.childViewsProperty = childViewsProperty; Ember.View.applyAttributeBindings = function(elem, name, value) { - var type = typeof value; + var type = Ember.typeOf(value); var currentValue = elem.attr(name); // if this changes, also change the logic in ember-handlebars/lib/helpers/binding.js if ((type === 'string' || (type === 'number' && !isNaN(value))) && value !== currentValue) { elem.attr(name, value); @@ -13338,62 +13338,71 @@ ember_assert("Ember requires jQuery 1.6 or 1.7", window.jQuery && jQuery().jquery.match(/^1\.[67](.\d+)?$/)); Ember.$ = window.jQuery; })({}); (function(exports) { -var get = Ember.get, set = Ember.set; +var get = Ember.get, set = Ember.set, getPath = Ember.getPath; Ember.State = Ember.Object.extend({ isState: true, parentState: null, start: null, + name: null, + path: Ember.computed(function() { + var parentPath = getPath(this, 'parentState.path'), + path = get(this, 'name'); + if (parentPath) { + path = parentPath + '.' + path; + } + + return path; + }).property().cacheable(), + init: function() { var states = get(this, 'states'), foundStates; + var name; // As a convenience, loop over the properties // of this state and look for any that are other // Ember.State instances or classes, and move them // to the `states` hash. This avoids having to // create an explicit separate hash. if (!states) { states = {}; - for (var name in this) { - if (name === "constructor") { continue; } - value = this.setupChild(name, this[name]); - if (value) { - foundStates = true; - states[name] = value; - } + for (name in this) { + if (name === "constructor") { continue; } + this.setupChild(states, name, this[name]); } - if (foundStates) { set(this, 'states', states); } + set(this, 'states', states); } else { - for (var name in states) { - this.setupChild(name, states[name]); + for (name in states) { + this.setupChild(states, name, states[name]); } } set(this, 'routes', {}); }, - setupChild: function(name, value) { + setupChild: function(states, name, value) { if (!value) { return false; } if (Ember.State.detect(value)) { - value = value.create(); + value = value.create({ + name: name + }); + } else if (value.isState) { + set(value, 'name', name); } if (value.isState) { set(value, 'parentState', this); - set(value, 'name', (get(this, 'name') || '') + '.' + name); - return value; + states[name] = value; } - - return false; }, enter: Ember.K, exit: Ember.K }); @@ -13419,11 +13428,11 @@ init: function() { this._super(); var initialState = get(this, 'initialState'); - if (!initialState && get(this, 'start')) { + if (!initialState && getPath(this, 'states.start')) { initialState = 'start'; } if (initialState) { this.goToState(initialState); @@ -13433,10 +13442,19 @@ currentState: null, /** @property + If set to true, `errorOnUnhandledEvents` will cause an exception to be + raised if you attempt to send an event to a state manager that is not + handled by the current state or any of its parent states. + */ + errorOnUnhandledEvent: true, + + /** + @property + If the current state is a view state or the descendent of a view state, this property will be the view associated with it. If there is no view state active in this state manager, this value will be null. */ currentView: Ember.computed(function() { @@ -13467,11 +13485,15 @@ if (action) { if (log) { console.log(fmt("STATEMANAGER: Sending event '%@' to state %@.", [event, currentState.name])); } action.call(currentState, this, context); } else { var parentState = get(currentState, 'parentState'); - if (parentState) { this.sendRecursively(event, parentState, context); } + if (parentState) { + this.sendRecursively(event, parentState, context); + } else if (get(this, 'errorOnUnhandledEvent')) { + throw new Ember.Error(this.toString() + " could not respond to event " + event + " in state " + getPath(this, 'currentState.name') + "."); + } } }, findStatesByRoute: function(state, route) { if (!route || route === "") { return undefined; } @@ -13595,11 +13617,11 @@ if (!initialState) { initialState = 'start'; } // right now, start states cannot be entered asynchronously - while (startState = get(startState, initialState)) { + while (startState = get(get(startState, 'states'), initialState)) { enteredState = startState; if (log) { console.log("STATEMANAGER: Entering " + startState.name); } startState.enter(stateManager); @@ -13742,21 +13764,10 @@ }; // If we have the W3C range API, this process is relatively straight forward. if (supportsRange) { - // IE 9 supports ranges but doesn't define createContextualFragment - if (!Range.prototype.createContextualFragment) { - Range.prototype.createContextualFragment = function(html) { - var frag = document.createDocumentFragment(), - div = document.createElement("div"); - frag.appendChild(div); - div.outerHTML = html; - return frag; - }; - } - // Get a range for the current morph. Optionally include the starting and // ending placeholders. rangeFor = function(morph, outerToo) { var range = document.createRange(); var before = document.getElementById(morph.start); @@ -14013,10 +14024,11 @@ }; afterFunc = function(html) { // get the real starting node. see realNode for details. var end = document.getElementById(this.end); + var insertBefore = end.nextSibling; var parentNode = end.parentNode; var nextSibling; var node; // get the first node for the HTML string, even in cases like @@ -14026,11 +14038,11 @@ // copy the nodes for the HTML between the starting and ending // placeholder. while (node) { nextSibling = node.nextSibling; - parentNode.insertBefore(node, end.nextSibling); + parentNode.insertBefore(node, insertBefore); node = nextSibling; } }; prependFunc = function(html) { @@ -15508,11 +15520,18 @@ itemHash.template = fn; delete options.fn; } if (inverse && inverse !== Handlebars.VM.noop) { - hash.emptyView = Ember.View.extend({ + var emptyViewClass = Ember.View; + + if (hash.emptyViewClass) { + emptyViewClass = Ember.View.detect(emptyViewClass) ? + hash.emptyViewClass : getPath(this, hash.emptyViewClass); + } + + hash.emptyView = emptyViewClass.extend({ template: inverse, tagName: itemHash.tagName }); } @@ -15606,9 +15625,14 @@ }); Ember.Handlebars.registerHelper('each', function(path, options) { options.hash.contentBinding = path; options.hash.preserveContext = true; + + // Set up emptyView as a metamorph with no tag + options.hash.itemTagName = ''; + options.hash.emptyViewClass = Ember.View.extend(Ember.Metamorph); + return Ember.Handlebars.helpers.collection.call(this, 'Ember.Handlebars.EachView', options); }); })({});