From a3c4468b5a58c3850d92c113d1c731261937da7a Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 30 Jul 2012 13:25:21 +0200 Subject: [PATCH] Update ember with emberjs/ember.js#718 merged --- assets/javascripts/vendor/ember-data.js | 16 +- assets/javascripts/vendor/ember.js | 258 ++++++++++++++-------- public/javascripts/vendor.js | 274 +++++++++++++++--------- 3 files changed, 340 insertions(+), 208 deletions(-) diff --git a/assets/javascripts/vendor/ember-data.js b/assets/javascripts/vendor/ember-data.js index d8dee4fa..82dd91f1 100644 --- a/assets/javascripts/vendor/ember-data.js +++ b/assets/javascripts/vendor/ember-data.js @@ -3132,8 +3132,8 @@ DS.Model = Ember.Object.extend(Ember.Evented, { if (cachedValue) { var key = association.options.key || get(this, 'namingConvention').keyToJSONKey(name), ids = data.get(key) || []; - - var clientIds; + + var clientIds; if(association.options.embedded) { clientIds = store.loadMany(association.type, ids).clientIds; } else { @@ -3141,7 +3141,7 @@ DS.Model = Ember.Object.extend(Ember.Evented, { return store.clientIdForId(association.type, id); }); } - + set(cachedValue, 'content', Ember.A(clientIds)); cachedValue.fetch(); } @@ -3766,7 +3766,7 @@ DS.FixtureAdapter = DS.Adapter.extend({ return ids.indexOf(item.id) !== -1; }); } - + if (fixtures) { this.simulateRemoteCall(function() { store.loadMany(type, fixtures); @@ -3786,7 +3786,7 @@ DS.FixtureAdapter = DS.Adapter.extend({ findQuery: function(store, type, query, array) { var fixtures = this.fixturesForType(type); - + Ember.assert("Unable to find fixtures for model type "+type.toString(), !!fixtures); fixtures = this.queryFixtures(fixtures, query); @@ -3847,7 +3847,7 @@ var get = Ember.get, set = Ember.set; DS.RESTAdapter = DS.Adapter.extend({ bulkCommit: false, - + createRecord: function(store, type, record) { var root = this.rootForType(type); @@ -4036,9 +4036,7 @@ DS.RESTAdapter = DS.Adapter.extend({ data: query, success: function(json) { this.sideload(store, type, json, plural); - setTimeout(function() { - recordArray.load(json[plural]); - }, 10); + recordArray.load(json[plural]); } }); }, diff --git a/assets/javascripts/vendor/ember.js b/assets/javascripts/vendor/ember.js index 9a40c062..27a9fb7f 100644 --- a/assets/javascripts/vendor/ember.js +++ b/assets/javascripts/vendor/ember.js @@ -1,5 +1,5 @@ -// Version: v0.9.8.1-672-gd7e24ac -// Last commit: d7e24ac (2012-07-26 09:35:30 -0700) +// Version: v0.9.8.1-675-g417213d +// Last commit: 417213d (2012-07-30 13:06:36 +0200) (function() { @@ -142,8 +142,8 @@ window.ember_deprecateFunc = Ember.deprecateFunc("ember_deprecateFunc is deprec })(); -// Version: v0.9.8.1-672-gd7e24ac -// Last commit: d7e24ac (2012-07-26 09:35:30 -0700) +// Version: v0.9.8.1-675-g417213d +// Last commit: 417213d (2012-07-30 13:06:36 +0200) (function() { @@ -3485,7 +3485,7 @@ Ember.RunLoop = RunLoop; call. Ember.run(function(){ - // code to be execute within a RunLoop + // code to be execute within a RunLoop }); @name run @@ -3523,7 +3523,7 @@ var run = Ember.run; an lower-level way to use a RunLoop instead of using Ember.run(). Ember.run.begin(); - // code to be execute within a RunLoop + // code to be execute within a RunLoop Ember.run.end(); @@ -3539,7 +3539,7 @@ Ember.run.begin = function() { instead of using Ember.run(). Ember.run.begin(); - // code to be execute within a RunLoop + // code to be execute within a RunLoop Ember.run.end(); @returns {void} @@ -5272,7 +5272,7 @@ Ember.inspect = function(obj) { /** Compares two objects, returning true if they are logically equal. This is a deeper comparison than a simple triple equal. For sets it will compare the - internal objects. For any other object that implements `isEqual()` it will + internal objects. For any other object that implements `isEqual()` it will respect that method. Ember.isEqual('hello', 'hello'); => true @@ -5455,7 +5455,7 @@ Ember.String = { > beta > gamma - @param {String} str + @param {String} str The string to split @returns {String} split string @@ -5464,7 +5464,7 @@ Ember.String = { /** Converts a camelized string into all lower case separated by underscores. - + 'innerHTML'.decamelize() => 'inner_html' 'action_name'.decamelize() => 'action_name' 'css-class-name'.decamelize() => 'css-class-name' @@ -5481,7 +5481,7 @@ Ember.String = { /** Replaces underscores or spaces with dashes. - + 'innerHTML'.dasherize() => 'inner-html' 'action_name'.dasherize() => 'action-name' 'css-class-name'.dasherize() => 'css-class-name' @@ -5648,7 +5648,7 @@ if (Ember.EXTEND_PROTOTYPES) { /** The `property` extension of Javascript's Function prototype is available - when Ember.EXTEND_PROTOTYPES is true, which is the default. + when Ember.EXTEND_PROTOTYPES is true, which is the default. Computed properties allow you to treat a function like a property: @@ -5703,7 +5703,7 @@ if (Ember.EXTEND_PROTOTYPES) { /** The `observes` extension of Javascript's Function prototype is available - when Ember.EXTEND_PROTOTYPES is true, which is the default. + when Ember.EXTEND_PROTOTYPES is true, which is the default. You can observe property changes simply by adding the `observes` call to the end of your method declarations in classes that you write. @@ -5714,7 +5714,7 @@ if (Ember.EXTEND_PROTOTYPES) { // Executes whenever the "value" property changes }.observes('value') }); - + @see Ember.Observable */ Function.prototype.observes = function() { @@ -5724,7 +5724,7 @@ if (Ember.EXTEND_PROTOTYPES) { /** The `observesBefore` extension of Javascript's Function prototype is - available when Ember.EXTEND_PROTOTYPES is true, which is the default. + available when Ember.EXTEND_PROTOTYPES is true, which is the default. You can get notified when a property changes is about to happen by by adding the `observesBefore` call to the end of your method @@ -5735,7 +5735,7 @@ if (Ember.EXTEND_PROTOTYPES) { // Executes whenever the "value" property is about to change }.observesBefore('value') }); - + @see Ember.Observable */ Function.prototype.observesBefore = function() { @@ -7329,7 +7329,7 @@ Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable, colors.clear(); => [] colors.length(); => 0 - @returns {Ember.Array} An empty Array. + @returns {Ember.Array} An empty Array. */ clear: function () { var len = get(this, 'length'); @@ -7537,15 +7537,15 @@ var get = Ember.get, set = Ember.set, defineProperty = Ember.defineProperty; @class ## Overview - + This mixin provides properties and property observing functionality, core features of the Ember object model. - + Properties and observers allow one object to observe changes to a property on another object. This is one of the fundamental ways that models, controllers and views communicate with each other in an Ember application. - + Any object that has this mixin applied can be used in observer operations. That includes Ember.Object and most objects you will interact with as you write your Ember application. @@ -7553,16 +7553,16 @@ var get = Ember.get, set = Ember.set, defineProperty = Ember.defineProperty; Note that you will not generally apply this mixin to classes yourself, but you will use the features provided by this module frequently, so it is important to understand how to use it. - + ## Using get() and set() - + Because of Ember's support for bindings and observers, you will always access properties using the get method, and set properties using the set method. This allows the observing objects to be notified and computed properties to be handled properly. - + More documentation about `get` and `set` are below. - + ## Observing Property Changes You typically observe property changes simply by adding the `observes` @@ -7574,7 +7574,7 @@ var get = Ember.get, set = Ember.set, defineProperty = Ember.defineProperty; // Executes whenever the "value" property changes }.observes('value') }); - + Although this is the most common way to add an observer, this capability is actually built into the Ember.Object class on top of two methods defined in this mixin: `addObserver` and `removeObserver`. You can use @@ -7587,12 +7587,12 @@ var get = Ember.get, set = Ember.set, defineProperty = Ember.defineProperty; This will call the `targetAction` method on the `targetObject` to be called whenever the value of the `propertyKey` changes. - - Note that if `propertyKey` is a computed property, the observer will be - called when any of the property dependencies are changed, even if the + + Note that if `propertyKey` is a computed property, the observer will be + called when any of the property dependencies are changed, even if the resulting value of the computed property is unchanged. This is necessary because computed properties are not computed until `get` is called. - + @extends Ember.Mixin */ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { @@ -7606,7 +7606,7 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { This method is usually similar to using object[keyName] or object.keyName, however it supports both computed properties and the unknownProperty handler. - + Because `get` unifies the syntax for accessing all these kinds of properties, it can make many refactorings easier, such as replacing a simple property with a computed property, or vice versa. @@ -7802,11 +7802,11 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { Ember.propertyDidChange(this, keyName); return this; }, - + /** Convenience method to call `propertyWillChange` and `propertyDidChange` in succession. - + @param {String} keyName The property key to be notified about. @returns {Ember.Observable} */ @@ -7898,7 +7898,7 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { This method will be called when a client attempts to get the value of a property that has not been defined in one of the typical ways. Override this method to create "virtual" properties. - + @param {String} key The name of the unknown property that was requested. @returns {Object} The property value or undefined. Default is undefined. */ @@ -7910,7 +7910,7 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { This method will be called when a client attempts to set the value of a property that has not been defined in one of the typical ways. Override this method to create "virtual" properties. - + @param {String} key The name of the unknown property to be set. @param {Object} value The value the unknown property is to be set to. */ @@ -7943,9 +7943,9 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { /** Retrieves the value of a property, or a default value in the case that the property returns undefined. - + person.getWithDefault('lastName', 'Doe'); - + @param {String} keyName The name of the property to retrieve @param {Object} defaultValue The value to return if the property value is undefined @returns {Object} The property value or the defaultValue. @@ -7956,10 +7956,10 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { /** Set the value of a property to the current value plus some amount. - + person.incrementProperty('age'); team.incrementProperty('score', 2); - + @param {String} keyName The name of the property to increment @param {Object} increment The amount to increment by. Defaults to 1 @returns {Object} The new property value @@ -7969,13 +7969,13 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { set(this, keyName, (get(this, keyName) || 0)+increment); return get(this, keyName); }, - + /** Set the value of a property to the current value minus some amount. - + player.decrementProperty('lives'); orc.decrementProperty('health', 5); - + @param {String} keyName The name of the property to decrement @param {Object} increment The amount to decrement by. Defaults to 1 @returns {Object} The new property value @@ -7989,9 +7989,9 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { /** Set the value of a boolean property to the opposite of it's current value. - + starship.toggleProperty('warpDriveEnaged'); - + @param {String} keyName The name of the property to toggle @returns {Object} The new property value */ @@ -11479,7 +11479,7 @@ var invokeForState = { `Ember.View` is the class in Ember responsible for encapsulating templates of HTML content, combining templates with data to render as sections of a page's DOM, and registering and responding to user-initiated events. - + ## HTML Tag The default HTML tag name used for a view's DOM representation is `div`. This can be customized by setting the `tagName` property. The following view class: @@ -11505,7 +11505,7 @@ var invokeForState = {
`class` attribute values can also be set by providing a `classNameBindings` property - set to an array of properties names for the view. The return value of these properties + set to an array of properties names for the view. The return value of these properties will be added as part of the value for the view's `class` attribute. These properties can be computed properties: @@ -11534,7 +11534,7 @@ var invokeForState = {
- When using boolean class name bindings you can supply a string value other than the + When using boolean class name bindings you can supply a string value other than the property name for use as the `class` HTML attribute by appending the preferred value after a ":" character when defining the binding: @@ -11612,11 +11612,11 @@ var invokeForState = {
- Updates to the the value of a class name binding will result in automatic update + Updates to the the value of a class name binding will result in automatic update of the HTML `class` attribute in the view's rendered HTML representation. If the value becomes `false` or `undefined` the class name will be removed. - Both `classNames` and `classNameBindings` are concatenated properties. + Both `classNames` and `classNameBindings` are concatenated properties. See `Ember.Object` documentation for more information about concatenated properties. ## HTML Attributes @@ -11662,7 +11662,7 @@ var invokeForState = { }.property() }) - Updates to the the property of an attribute binding will result in automatic update + Updates to the the property of an attribute binding will result in automatic update of the HTML attribute in the view's rendered HTML representation. `attributeBindings` is a concatenated property. See `Ember.Object` documentation @@ -11753,7 +11753,7 @@ var invokeForState = { primary templates, layouts can be any function that accepts an optional context parameter and returns a string of HTML that will be inserted inside view's tag. Views whose HTML element is self closing (e.g. ``) cannot have a layout and this property will be ignored. - + Most typically in Ember a layout will be a compiled Ember.Handlebars template. A view's layout can be set directly with the `layout` property or reference an @@ -11778,7 +11778,7 @@ var invokeForState = { See `Handlebars.helpers.yield` for more information. ## Responding to Browser Events - Views can respond to user-initiated events in one of three ways: method implementation, + Views can respond to user-initiated events in one of three ways: method implementation, through an event manager, and through `{{action}}` helper use in their template or layout. ### Method Implementation @@ -11795,8 +11795,8 @@ var invokeForState = { ### Event Managers Views can define an object as their `eventManager` property. This object can then implement methods that match the desired event names. Matching events that occur - on the view's rendered HTML or the rendered HTML of any of its DOM descendants - will trigger this method. A `jQuery.Event` object will be passed as the first + on the view's rendered HTML or the rendered HTML of any of its DOM descendants + will trigger this method. A `jQuery.Event` object will be passed as the first argument to the method and an `Ember.View` object as the second. The `Ember.View` will be the view whose rendered HTML was interacted with. This may be the view with the `eventManager` property or one of its descendent views. @@ -11830,7 +11830,7 @@ var invokeForState = { Similarly a view's event manager will take precedence for events of any views rendered as a descendent. A method name that matches an event name will not be called - if the view instance was rendered inside the HTML representation of a view that has + if the view instance was rendered inside the HTML representation of a view that has an `eventManager` property defined that handles events of the name. Events not handled by the event manager will still trigger method calls on the descendent. @@ -11852,7 +11852,7 @@ var invokeForState = { // eventManager doesn't handle click events }, mouseEnter: function(event){ - // will never be called if rendered inside + // will never be called if rendered inside // an OuterView. } }) @@ -11873,7 +11873,7 @@ var invokeForState = { Form events: 'submit', 'change', 'focusIn', 'focusOut', 'input' HTML5 drag and drop events: 'dragStart', 'drag', 'dragEnter', 'dragLeave', 'drop', 'dragEnd' - + ## Handlebars `{{view}}` Helper Other `Ember.View` instances can be included as part of a view's template by using the `{{view}}` Handlebars helper. See `Handlebars.helpers.view` for additional information. @@ -12090,6 +12090,10 @@ Ember.View = Ember.Object.extend(Ember.Evented, _parentView: null, + // allow navigation between the next and previous views + prevView: null, + nextView: null, + // return the current view, not including virtual views concreteView: Ember.computed(function() { if (!this.isVirtual) { return this; } @@ -13401,10 +13405,22 @@ var DOMManager = { }); }, - after: function(view, nextView) { - nextView._insertElementLater(function() { - var element = view.$(); - element.after(nextView.$()); + after: function(parentView, view, newView) { + newView._insertElementLater(function() { + var nextView; + var prevView = view; + while (prevView !== null && prevView.get('state') !== 'inDOM') { + prevView=prevView.get('prevView'); + } + var element; + if (prevView === null) { + element = parentView.$(); + element.prepend(newView.$()); + } else { + element = prevView.$(); + element.after(newView.$()); + } + }); }, @@ -13677,7 +13693,13 @@ Ember.View.states.inBuffer = { var buffer = view.buffer; childView = this.createChildView(childView, options); - view._childViews.push(childView); + var childViews = get(view, '_childViews'); + + if (childViews.length > 0) { + childViews[childViews.length-1].nextView = childView; + childView.prevView = childViews[childViews.length-1]; + } + childViews.push(childView); childView.renderToBuffer(buffer); @@ -14096,6 +14118,10 @@ Ember.ContainerView = Ember.View.extend({ view = this.createChildView(viewName); } + if (idx>0) { + _childViews[idx-1].nextView = view; + view.prevView = _childViews[idx-1]; + } _childViews[idx] = view; }, this); @@ -14211,7 +14237,7 @@ Ember.ContainerView = Ember.View.extend({ */ _scheduleInsertion: function(view, prev) { if (prev) { - prev.domManager.after(prev, view); + prev.domManager.after(this, prev, view); } else { this.domManager.prepend(this, view); } @@ -14532,6 +14558,15 @@ Ember.CollectionView = Ember.ContainerView.extend( if (removingAll) { childView.removedFromDOM = true; } childView.destroy(); } + + // If there is an element before the ones we deleted + if (start>0) { + childViews[start-1].set('nextView', start0 ? childViews[start-1] : null); + } }, /** @@ -14572,6 +14607,11 @@ Ember.CollectionView = Ember.ContainerView.extend( contentIndex: idx }); + // link together the chain of addedViews + if (addedViews.length>0) { + view.set('prevView', addedViews[addedViews.length-1]); + addedViews[addedViews.length-1].set('nextView', view); + } addedViews.push(view); } } else { @@ -14582,6 +14622,20 @@ Ember.CollectionView = Ember.ContainerView.extend( addedViews.push(emptyView); set(this, 'emptyView', emptyView); } + + if (added>0) { + // if there is a childview before the ones we're adding + if (start>0) { + childViews.objectAt(start-1).set('nextView', addedViews[0]); + addedViews[0].set('prevView', childViews.objectAt(start-1)); + } + // if there is a childview after the ones we're adding + if (start - @@ -18803,7 +18871,7 @@ EmberHandlebars.ViewHelper = Ember.Object.create({ }) aView.appendTo('body') - + Will result in HTML structure:
@@ -18877,7 +18945,7 @@ EmberHandlebars.ViewHelper = Ember.Object.create({ Will result in the following HTML:
-
+
hi
@@ -19037,7 +19105,7 @@ var get = Ember.get, getPath = Ember.Handlebars.getPath, fmt = Ember.String.fmt;

Howdy Mary

Howdy Sara

- + @name Handlebars.helpers.collection @param {String} path @param {Hash} options @@ -19358,7 +19426,7 @@ ActionHelper.registerAction = function(actionName, options) { The `{{action}}` helper registers an HTML element within a template for DOM event handling and forwards that interaction to the Application's router, the template's `Ember.View` instance, or supplied `target` option (see 'Specifiying a Target'). - + User interaction with that element will invoke the supplied action name on the appropriate target. @@ -19403,7 +19471,7 @@ ActionHelper.registerAction = function(actionName, options) { If you need the default handler to trigger you should either register your own event handler, or use event methods on your view class. See Ember.View 'Responding to Browser Events' for more information. - + ### Specifying DOM event type By default the `{{action}}` helper registers for DOM `click` events. You can @@ -19423,23 +19491,23 @@ ActionHelper.registerAction = function(actionName, options) { `Ember.EventDispatcher` instance will be created when a new `Ember.Application` is created. Having an instance of `Ember.Application` will satisfy this requirement. - - + + ### Specifying a Target There are several possible target objects for `{{action}}` helpers: - + In a typical `Ember.Router`-backed Application where views are managed through use of the `{{outlet}}` helper, actions will be forwarded to the current state of the Applications's Router. See Ember.Router 'Responding to User-initiated Events' for more information. - + If you manaully set the `target` property on the controller of a template's `Ember.View` instance, the specifed `controller.target` will become the target for any actions. Likely custom values for a controller's `target` are the controller itself or a StateManager other than the Application's Router. - + If the templates's view lacks a controller property the view itself is the target. - + Finally, a `target` option can be provided to the helper to change which object will receive the method call. This option must be a string representing a path to an object: @@ -19494,7 +19562,7 @@ ActionHelper.registerAction = function(actionName, options) { Will throw `Uncaught TypeError: Cannot call method 'call' of undefined` when "click me" is clicked. - + ### Specifying a context By default the `{{action}}` helper passes the current Handlebars context @@ -19702,7 +19770,7 @@ var set = Ember.set, get = Ember.get; /** @class - Creates an HTML input of type 'checkbox' with HTML related properties + Creates an HTML input of type 'checkbox' with HTML related properties applied directly to the input. {{view Ember.Checkbox classNames="applicaton-specific-checkbox"}} @@ -19721,7 +19789,7 @@ var set = Ember.set, get = Ember.get; through the Ember object or by interacting with its rendered element representation via the mouse, keyboard, or touch. Updating the value of the checkbox via jQuery will result in the checked value of the object and its element losing synchronization. - + ## Layout and LayoutName properties Because HTML `input` elements are self closing `layout` and `layoutName` properties will not be applied. See `Ember.View`'s layout section for more information. @@ -19833,7 +19901,7 @@ var get = Ember.get, set = Ember.set; ## Layout and LayoutName properties Because HTML `input` elements are self closing `layout` and `layoutName` properties will not be applied. See `Ember.View`'s layout section for more information. - + @extends Ember.TextSupport */ Ember.TextField = Ember.View.extend(Ember.TextSupport, @@ -20010,7 +20078,7 @@ var get = Ember.get, set = Ember.set; ## Layout and LayoutName properties - Because HTML `textarea` elements do not contain inner HTML the `layout` and `layoutName` + Because HTML `textarea` elements do not contain inner HTML the `layout` and `layoutName` properties will not be applied. See `Ember.View`'s layout section for more information. @extends Ember.TextSupport @@ -20570,8 +20638,8 @@ Ember.onLoad('application', bootstrap); })(); -// Version: v0.9.8.1-672-gd7e24ac -// Last commit: d7e24ac (2012-07-26 09:35:30 -0700) +// Version: v0.9.8.1-675-g417213d +// Last commit: 417213d (2012-07-30 13:06:36 +0200) (function() { diff --git a/public/javascripts/vendor.js b/public/javascripts/vendor.js index e4336783..758a1f56 100644 --- a/public/javascripts/vendor.js +++ b/public/javascripts/vendor.js @@ -1952,8 +1952,8 @@ Handlebars.VM = { Handlebars.template = Handlebars.VM.template; ; -// Version: v0.9.8.1-672-gd7e24ac -// Last commit: d7e24ac (2012-07-26 09:35:30 -0700) +// Version: v0.9.8.1-675-g417213d +// Last commit: 417213d (2012-07-30 13:06:36 +0200) (function() { @@ -2096,8 +2096,8 @@ window.ember_deprecateFunc = Ember.deprecateFunc("ember_deprecateFunc is deprec })(); -// Version: v0.9.8.1-672-gd7e24ac -// Last commit: d7e24ac (2012-07-26 09:35:30 -0700) +// Version: v0.9.8.1-675-g417213d +// Last commit: 417213d (2012-07-30 13:06:36 +0200) (function() { @@ -5439,7 +5439,7 @@ Ember.RunLoop = RunLoop; call. Ember.run(function(){ - // code to be execute within a RunLoop + // code to be execute within a RunLoop }); @name run @@ -5477,7 +5477,7 @@ var run = Ember.run; an lower-level way to use a RunLoop instead of using Ember.run(). Ember.run.begin(); - // code to be execute within a RunLoop + // code to be execute within a RunLoop Ember.run.end(); @@ -5493,7 +5493,7 @@ Ember.run.begin = function() { instead of using Ember.run(). Ember.run.begin(); - // code to be execute within a RunLoop + // code to be execute within a RunLoop Ember.run.end(); @returns {void} @@ -7226,7 +7226,7 @@ Ember.inspect = function(obj) { /** Compares two objects, returning true if they are logically equal. This is a deeper comparison than a simple triple equal. For sets it will compare the - internal objects. For any other object that implements `isEqual()` it will + internal objects. For any other object that implements `isEqual()` it will respect that method. Ember.isEqual('hello', 'hello'); => true @@ -7409,7 +7409,7 @@ Ember.String = { > beta > gamma - @param {String} str + @param {String} str The string to split @returns {String} split string @@ -7418,7 +7418,7 @@ Ember.String = { /** Converts a camelized string into all lower case separated by underscores. - + 'innerHTML'.decamelize() => 'inner_html' 'action_name'.decamelize() => 'action_name' 'css-class-name'.decamelize() => 'css-class-name' @@ -7435,7 +7435,7 @@ Ember.String = { /** Replaces underscores or spaces with dashes. - + 'innerHTML'.dasherize() => 'inner-html' 'action_name'.dasherize() => 'action-name' 'css-class-name'.dasherize() => 'css-class-name' @@ -7602,7 +7602,7 @@ if (Ember.EXTEND_PROTOTYPES) { /** The `property` extension of Javascript's Function prototype is available - when Ember.EXTEND_PROTOTYPES is true, which is the default. + when Ember.EXTEND_PROTOTYPES is true, which is the default. Computed properties allow you to treat a function like a property: @@ -7657,7 +7657,7 @@ if (Ember.EXTEND_PROTOTYPES) { /** The `observes` extension of Javascript's Function prototype is available - when Ember.EXTEND_PROTOTYPES is true, which is the default. + when Ember.EXTEND_PROTOTYPES is true, which is the default. You can observe property changes simply by adding the `observes` call to the end of your method declarations in classes that you write. @@ -7668,7 +7668,7 @@ if (Ember.EXTEND_PROTOTYPES) { // Executes whenever the "value" property changes }.observes('value') }); - + @see Ember.Observable */ Function.prototype.observes = function() { @@ -7678,7 +7678,7 @@ if (Ember.EXTEND_PROTOTYPES) { /** The `observesBefore` extension of Javascript's Function prototype is - available when Ember.EXTEND_PROTOTYPES is true, which is the default. + available when Ember.EXTEND_PROTOTYPES is true, which is the default. You can get notified when a property changes is about to happen by by adding the `observesBefore` call to the end of your method @@ -7689,7 +7689,7 @@ if (Ember.EXTEND_PROTOTYPES) { // Executes whenever the "value" property is about to change }.observesBefore('value') }); - + @see Ember.Observable */ Function.prototype.observesBefore = function() { @@ -9283,7 +9283,7 @@ Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable, colors.clear(); => [] colors.length(); => 0 - @returns {Ember.Array} An empty Array. + @returns {Ember.Array} An empty Array. */ clear: function () { var len = get(this, 'length'); @@ -9491,15 +9491,15 @@ var get = Ember.get, set = Ember.set, defineProperty = Ember.defineProperty; @class ## Overview - + This mixin provides properties and property observing functionality, core features of the Ember object model. - + Properties and observers allow one object to observe changes to a property on another object. This is one of the fundamental ways that models, controllers and views communicate with each other in an Ember application. - + Any object that has this mixin applied can be used in observer operations. That includes Ember.Object and most objects you will interact with as you write your Ember application. @@ -9507,16 +9507,16 @@ var get = Ember.get, set = Ember.set, defineProperty = Ember.defineProperty; Note that you will not generally apply this mixin to classes yourself, but you will use the features provided by this module frequently, so it is important to understand how to use it. - + ## Using get() and set() - + Because of Ember's support for bindings and observers, you will always access properties using the get method, and set properties using the set method. This allows the observing objects to be notified and computed properties to be handled properly. - + More documentation about `get` and `set` are below. - + ## Observing Property Changes You typically observe property changes simply by adding the `observes` @@ -9528,7 +9528,7 @@ var get = Ember.get, set = Ember.set, defineProperty = Ember.defineProperty; // Executes whenever the "value" property changes }.observes('value') }); - + Although this is the most common way to add an observer, this capability is actually built into the Ember.Object class on top of two methods defined in this mixin: `addObserver` and `removeObserver`. You can use @@ -9541,12 +9541,12 @@ var get = Ember.get, set = Ember.set, defineProperty = Ember.defineProperty; This will call the `targetAction` method on the `targetObject` to be called whenever the value of the `propertyKey` changes. - - Note that if `propertyKey` is a computed property, the observer will be - called when any of the property dependencies are changed, even if the + + Note that if `propertyKey` is a computed property, the observer will be + called when any of the property dependencies are changed, even if the resulting value of the computed property is unchanged. This is necessary because computed properties are not computed until `get` is called. - + @extends Ember.Mixin */ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { @@ -9560,7 +9560,7 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { This method is usually similar to using object[keyName] or object.keyName, however it supports both computed properties and the unknownProperty handler. - + Because `get` unifies the syntax for accessing all these kinds of properties, it can make many refactorings easier, such as replacing a simple property with a computed property, or vice versa. @@ -9756,11 +9756,11 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { Ember.propertyDidChange(this, keyName); return this; }, - + /** Convenience method to call `propertyWillChange` and `propertyDidChange` in succession. - + @param {String} keyName The property key to be notified about. @returns {Ember.Observable} */ @@ -9852,7 +9852,7 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { This method will be called when a client attempts to get the value of a property that has not been defined in one of the typical ways. Override this method to create "virtual" properties. - + @param {String} key The name of the unknown property that was requested. @returns {Object} The property value or undefined. Default is undefined. */ @@ -9864,7 +9864,7 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { This method will be called when a client attempts to set the value of a property that has not been defined in one of the typical ways. Override this method to create "virtual" properties. - + @param {String} key The name of the unknown property to be set. @param {Object} value The value the unknown property is to be set to. */ @@ -9897,9 +9897,9 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { /** Retrieves the value of a property, or a default value in the case that the property returns undefined. - + person.getWithDefault('lastName', 'Doe'); - + @param {String} keyName The name of the property to retrieve @param {Object} defaultValue The value to return if the property value is undefined @returns {Object} The property value or the defaultValue. @@ -9910,10 +9910,10 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { /** Set the value of a property to the current value plus some amount. - + person.incrementProperty('age'); team.incrementProperty('score', 2); - + @param {String} keyName The name of the property to increment @param {Object} increment The amount to increment by. Defaults to 1 @returns {Object} The new property value @@ -9923,13 +9923,13 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { set(this, keyName, (get(this, keyName) || 0)+increment); return get(this, keyName); }, - + /** Set the value of a property to the current value minus some amount. - + player.decrementProperty('lives'); orc.decrementProperty('health', 5); - + @param {String} keyName The name of the property to decrement @param {Object} increment The amount to decrement by. Defaults to 1 @returns {Object} The new property value @@ -9943,9 +9943,9 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { /** Set the value of a boolean property to the opposite of it's current value. - + starship.toggleProperty('warpDriveEnaged'); - + @param {String} keyName The name of the property to toggle @returns {Object} The new property value */ @@ -13433,7 +13433,7 @@ var invokeForState = { `Ember.View` is the class in Ember responsible for encapsulating templates of HTML content, combining templates with data to render as sections of a page's DOM, and registering and responding to user-initiated events. - + ## HTML Tag The default HTML tag name used for a view's DOM representation is `div`. This can be customized by setting the `tagName` property. The following view class: @@ -13459,7 +13459,7 @@ var invokeForState = {
`class` attribute values can also be set by providing a `classNameBindings` property - set to an array of properties names for the view. The return value of these properties + set to an array of properties names for the view. The return value of these properties will be added as part of the value for the view's `class` attribute. These properties can be computed properties: @@ -13488,7 +13488,7 @@ var invokeForState = {
- When using boolean class name bindings you can supply a string value other than the + When using boolean class name bindings you can supply a string value other than the property name for use as the `class` HTML attribute by appending the preferred value after a ":" character when defining the binding: @@ -13566,11 +13566,11 @@ var invokeForState = {
- Updates to the the value of a class name binding will result in automatic update + Updates to the the value of a class name binding will result in automatic update of the HTML `class` attribute in the view's rendered HTML representation. If the value becomes `false` or `undefined` the class name will be removed. - Both `classNames` and `classNameBindings` are concatenated properties. + Both `classNames` and `classNameBindings` are concatenated properties. See `Ember.Object` documentation for more information about concatenated properties. ## HTML Attributes @@ -13616,7 +13616,7 @@ var invokeForState = { }.property() }) - Updates to the the property of an attribute binding will result in automatic update + Updates to the the property of an attribute binding will result in automatic update of the HTML attribute in the view's rendered HTML representation. `attributeBindings` is a concatenated property. See `Ember.Object` documentation @@ -13707,7 +13707,7 @@ var invokeForState = { primary templates, layouts can be any function that accepts an optional context parameter and returns a string of HTML that will be inserted inside view's tag. Views whose HTML element is self closing (e.g. ``) cannot have a layout and this property will be ignored. - + Most typically in Ember a layout will be a compiled Ember.Handlebars template. A view's layout can be set directly with the `layout` property or reference an @@ -13732,7 +13732,7 @@ var invokeForState = { See `Handlebars.helpers.yield` for more information. ## Responding to Browser Events - Views can respond to user-initiated events in one of three ways: method implementation, + Views can respond to user-initiated events in one of three ways: method implementation, through an event manager, and through `{{action}}` helper use in their template or layout. ### Method Implementation @@ -13749,8 +13749,8 @@ var invokeForState = { ### Event Managers Views can define an object as their `eventManager` property. This object can then implement methods that match the desired event names. Matching events that occur - on the view's rendered HTML or the rendered HTML of any of its DOM descendants - will trigger this method. A `jQuery.Event` object will be passed as the first + on the view's rendered HTML or the rendered HTML of any of its DOM descendants + will trigger this method. A `jQuery.Event` object will be passed as the first argument to the method and an `Ember.View` object as the second. The `Ember.View` will be the view whose rendered HTML was interacted with. This may be the view with the `eventManager` property or one of its descendent views. @@ -13784,7 +13784,7 @@ var invokeForState = { Similarly a view's event manager will take precedence for events of any views rendered as a descendent. A method name that matches an event name will not be called - if the view instance was rendered inside the HTML representation of a view that has + if the view instance was rendered inside the HTML representation of a view that has an `eventManager` property defined that handles events of the name. Events not handled by the event manager will still trigger method calls on the descendent. @@ -13806,7 +13806,7 @@ var invokeForState = { // eventManager doesn't handle click events }, mouseEnter: function(event){ - // will never be called if rendered inside + // will never be called if rendered inside // an OuterView. } }) @@ -13827,7 +13827,7 @@ var invokeForState = { Form events: 'submit', 'change', 'focusIn', 'focusOut', 'input' HTML5 drag and drop events: 'dragStart', 'drag', 'dragEnter', 'dragLeave', 'drop', 'dragEnd' - + ## Handlebars `{{view}}` Helper Other `Ember.View` instances can be included as part of a view's template by using the `{{view}}` Handlebars helper. See `Handlebars.helpers.view` for additional information. @@ -14044,6 +14044,10 @@ Ember.View = Ember.Object.extend(Ember.Evented, _parentView: null, + // allow navigation between the next and previous views + prevView: null, + nextView: null, + // return the current view, not including virtual views concreteView: Ember.computed(function() { if (!this.isVirtual) { return this; } @@ -15355,10 +15359,22 @@ var DOMManager = { }); }, - after: function(view, nextView) { - nextView._insertElementLater(function() { - var element = view.$(); - element.after(nextView.$()); + after: function(parentView, view, newView) { + newView._insertElementLater(function() { + var nextView; + var prevView = view; + while (prevView !== null && prevView.get('state') !== 'inDOM') { + prevView=prevView.get('prevView'); + } + var element; + if (prevView === null) { + element = parentView.$(); + element.prepend(newView.$()); + } else { + element = prevView.$(); + element.after(newView.$()); + } + }); }, @@ -15631,7 +15647,13 @@ Ember.View.states.inBuffer = { var buffer = view.buffer; childView = this.createChildView(childView, options); - view._childViews.push(childView); + var childViews = get(view, '_childViews'); + + if (childViews.length > 0) { + childViews[childViews.length-1].nextView = childView; + childView.prevView = childViews[childViews.length-1]; + } + childViews.push(childView); childView.renderToBuffer(buffer); @@ -16050,6 +16072,10 @@ Ember.ContainerView = Ember.View.extend({ view = this.createChildView(viewName); } + if (idx>0) { + _childViews[idx-1].nextView = view; + view.prevView = _childViews[idx-1]; + } _childViews[idx] = view; }, this); @@ -16165,7 +16191,7 @@ Ember.ContainerView = Ember.View.extend({ */ _scheduleInsertion: function(view, prev) { if (prev) { - prev.domManager.after(prev, view); + prev.domManager.after(this, prev, view); } else { this.domManager.prepend(this, view); } @@ -16486,6 +16512,15 @@ Ember.CollectionView = Ember.ContainerView.extend( if (removingAll) { childView.removedFromDOM = true; } childView.destroy(); } + + // If there is an element before the ones we deleted + if (start>0) { + childViews[start-1].set('nextView', start0 ? childViews[start-1] : null); + } }, /** @@ -16526,6 +16561,11 @@ Ember.CollectionView = Ember.ContainerView.extend( contentIndex: idx }); + // link together the chain of addedViews + if (addedViews.length>0) { + view.set('prevView', addedViews[addedViews.length-1]); + addedViews[addedViews.length-1].set('nextView', view); + } addedViews.push(view); } } else { @@ -16536,6 +16576,20 @@ Ember.CollectionView = Ember.ContainerView.extend( addedViews.push(emptyView); set(this, 'emptyView', emptyView); } + + if (added>0) { + // if there is a childview before the ones we're adding + if (start>0) { + childViews.objectAt(start-1).set('nextView', addedViews[0]); + addedViews[0].set('prevView', childViews.objectAt(start-1)); + } + // if there is a childview after the ones we're adding + if (start - @@ -20757,7 +20825,7 @@ EmberHandlebars.ViewHelper = Ember.Object.create({ }) aView.appendTo('body') - + Will result in HTML structure:
@@ -20831,7 +20899,7 @@ EmberHandlebars.ViewHelper = Ember.Object.create({ Will result in the following HTML:
-
+
hi
@@ -20991,7 +21059,7 @@ var get = Ember.get, getPath = Ember.Handlebars.getPath, fmt = Ember.String.fmt;

Howdy Mary

Howdy Sara

- + @name Handlebars.helpers.collection @param {String} path @param {Hash} options @@ -21312,7 +21380,7 @@ ActionHelper.registerAction = function(actionName, options) { The `{{action}}` helper registers an HTML element within a template for DOM event handling and forwards that interaction to the Application's router, the template's `Ember.View` instance, or supplied `target` option (see 'Specifiying a Target'). - + User interaction with that element will invoke the supplied action name on the appropriate target. @@ -21357,7 +21425,7 @@ ActionHelper.registerAction = function(actionName, options) { If you need the default handler to trigger you should either register your own event handler, or use event methods on your view class. See Ember.View 'Responding to Browser Events' for more information. - + ### Specifying DOM event type By default the `{{action}}` helper registers for DOM `click` events. You can @@ -21377,23 +21445,23 @@ ActionHelper.registerAction = function(actionName, options) { `Ember.EventDispatcher` instance will be created when a new `Ember.Application` is created. Having an instance of `Ember.Application` will satisfy this requirement. - - + + ### Specifying a Target There are several possible target objects for `{{action}}` helpers: - + In a typical `Ember.Router`-backed Application where views are managed through use of the `{{outlet}}` helper, actions will be forwarded to the current state of the Applications's Router. See Ember.Router 'Responding to User-initiated Events' for more information. - + If you manaully set the `target` property on the controller of a template's `Ember.View` instance, the specifed `controller.target` will become the target for any actions. Likely custom values for a controller's `target` are the controller itself or a StateManager other than the Application's Router. - + If the templates's view lacks a controller property the view itself is the target. - + Finally, a `target` option can be provided to the helper to change which object will receive the method call. This option must be a string representing a path to an object: @@ -21448,7 +21516,7 @@ ActionHelper.registerAction = function(actionName, options) { Will throw `Uncaught TypeError: Cannot call method 'call' of undefined` when "click me" is clicked. - + ### Specifying a context By default the `{{action}}` helper passes the current Handlebars context @@ -21656,7 +21724,7 @@ var set = Ember.set, get = Ember.get; /** @class - Creates an HTML input of type 'checkbox' with HTML related properties + Creates an HTML input of type 'checkbox' with HTML related properties applied directly to the input. {{view Ember.Checkbox classNames="applicaton-specific-checkbox"}} @@ -21675,7 +21743,7 @@ var set = Ember.set, get = Ember.get; through the Ember object or by interacting with its rendered element representation via the mouse, keyboard, or touch. Updating the value of the checkbox via jQuery will result in the checked value of the object and its element losing synchronization. - + ## Layout and LayoutName properties Because HTML `input` elements are self closing `layout` and `layoutName` properties will not be applied. See `Ember.View`'s layout section for more information. @@ -21787,7 +21855,7 @@ var get = Ember.get, set = Ember.set; ## Layout and LayoutName properties Because HTML `input` elements are self closing `layout` and `layoutName` properties will not be applied. See `Ember.View`'s layout section for more information. - + @extends Ember.TextSupport */ Ember.TextField = Ember.View.extend(Ember.TextSupport, @@ -21964,7 +22032,7 @@ var get = Ember.get, set = Ember.set; ## Layout and LayoutName properties - Because HTML `textarea` elements do not contain inner HTML the `layout` and `layoutName` + Because HTML `textarea` elements do not contain inner HTML the `layout` and `layoutName` properties will not be applied. See `Ember.View`'s layout section for more information. @extends Ember.TextSupport @@ -22524,8 +22592,8 @@ Ember.onLoad('application', bootstrap); })(); -// Version: v0.9.8.1-672-gd7e24ac -// Last commit: d7e24ac (2012-07-26 09:35:30 -0700) +// Version: v0.9.8.1-675-g417213d +// Last commit: 417213d (2012-07-30 13:06:36 +0200) (function() { @@ -25671,8 +25739,8 @@ DS.Model = Ember.Object.extend(Ember.Evented, { if (cachedValue) { var key = association.options.key || get(this, 'namingConvention').keyToJSONKey(name), ids = data.get(key) || []; - - var clientIds; + + var clientIds; if(association.options.embedded) { clientIds = store.loadMany(association.type, ids).clientIds; } else { @@ -25680,7 +25748,7 @@ DS.Model = Ember.Object.extend(Ember.Evented, { return store.clientIdForId(association.type, id); }); } - + set(cachedValue, 'content', Ember.A(clientIds)); cachedValue.fetch(); } @@ -26305,7 +26373,7 @@ DS.FixtureAdapter = DS.Adapter.extend({ return ids.indexOf(item.id) !== -1; }); } - + if (fixtures) { this.simulateRemoteCall(function() { store.loadMany(type, fixtures); @@ -26325,7 +26393,7 @@ DS.FixtureAdapter = DS.Adapter.extend({ findQuery: function(store, type, query, array) { var fixtures = this.fixturesForType(type); - + Ember.assert("Unable to find fixtures for model type "+type.toString(), !!fixtures); fixtures = this.queryFixtures(fixtures, query); @@ -26386,7 +26454,7 @@ var get = Ember.get, set = Ember.set; DS.RESTAdapter = DS.Adapter.extend({ bulkCommit: false, - + createRecord: function(store, type, record) { var root = this.rootForType(type); @@ -26575,9 +26643,7 @@ DS.RESTAdapter = DS.Adapter.extend({ data: query, success: function(json) { this.sideload(store, type, json, plural); - setTimeout(function() { - recordArray.load(json[plural]); - }, 10); + recordArray.load(json[plural]); } }); },