dist/ember.js in ember-source-1.12.2 vs dist/ember.js in ember-source-1.13.0.beta.1
- old
+ new
@@ -3,11 +3,11 @@
* @copyright Copyright 2011-2015 Tilde Inc. and contributors
* Portions Copyright 2006-2011 Strobe Inc.
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
* @license Licensed under MIT license
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
- * @version 1.12.2
+ * @version 1.13.0-beta.1
*/
(function() {
var enifed, requireModule, eriuqer, requirejs, Ember;
var mainContext = this;
@@ -1115,11 +1115,11 @@
'use strict';
var Registry;
/**
- A lightweight container used to instantiate and cache objects.
+ A container used to instantiate and cache objects.
Every `Container` must be associated with a `Registry`, which is referenced
to determine the factory and options that should be used to instantiate
objects.
@@ -1129,11 +1129,11 @@
@private
@class Container
*/
function Container(registry, options) {
this._registry = registry || (function () {
- Ember['default'].deprecate("A container should only be created for an already instantiated " + "registry. For backward compatibility, an isolated registry will " + "be instantiated just for this container.");
+ Ember['default'].deprecate('A container should only be created for an already instantiated registry. For backward compatibility, an isolated registry will be instantiated just for this container.');
// TODO - See note above about transpiler import workaround.
if (!Registry) {
Registry = requireModule('container/registry')['default'];
}
@@ -1460,11 +1460,11 @@
instanceInitializersFeatureEnabled = true;
/**
- A lightweight registry used to store factory and option information keyed
+ A registry used to store factory and option information keyed
by type.
A `Registry` stores the factory and option information needed by a
`Container` to instantiate and cache objects.
@@ -1487,10 +1487,11 @@
this._factoryTypeInjections = dictionary['default'](null);
this._factoryInjections = dictionary['default'](null);
this._normalizeCache = dictionary['default'](null);
this._resolveCache = dictionary['default'](null);
+ this._failCache = dictionary['default'](null);
this._options = dictionary['default'](null);
this._typeOptions = dictionary['default'](null);
}
@@ -1614,21 +1615,21 @@
lookup: function (fullName, options) {
Ember['default'].assert('Create a container on the registry (with `registry.container()`) before calling `lookup`.', this._defaultContainer);
if (instanceInitializersFeatureEnabled) {
- Ember['default'].deprecate('`lookup` was called on a Registry. The `initializer` API no longer receives a container, and you should use an `instanceInitializer` to look up objects from the container.', false, { url: "http://emberjs.com/guides/deprecations#toc_deprecate-access-to-instances-in-initializers" });
+ Ember['default'].deprecate('`lookup` was called on a Registry. The `initializer` API no longer receives a container, and you should use an `instanceInitializer` to look up objects from the container.', false, { url: 'http://emberjs.com/guides/deprecations#toc_deprecate-access-to-instances-in-initializers' });
}
return this._defaultContainer.lookup(fullName, options);
},
lookupFactory: function (fullName) {
Ember['default'].assert('Create a container on the registry (with `registry.container()`) before calling `lookupFactory`.', this._defaultContainer);
if (instanceInitializersFeatureEnabled) {
- Ember['default'].deprecate('`lookupFactory` was called on a Registry. The `initializer` API no longer receives a container, and you should use an `instanceInitializer` to look up objects from the container.', false, { url: "http://emberjs.com/guides/deprecations#toc_deprecate-access-to-instances-in-initializers" });
+ Ember['default'].deprecate('`lookupFactory` was called on a Registry. The `initializer` API no longer receives a container, and you should use an `instanceInitializer` to look up objects from the container.', false, { url: 'http://emberjs.com/guides/deprecations#toc_deprecate-access-to-instances-in-initializers' });
}
return this._defaultContainer.lookupFactory(fullName);
},
@@ -1657,10 +1658,11 @@
if (this._resolveCache[normalizedName]) {
throw new Error('Cannot re-register: `' + fullName + '`, as it has already been resolved.');
}
+ delete this._failCache[normalizedName];
this.registrations[normalizedName] = factory;
this._options[normalizedName] = options || {};
},
/**
@@ -1680,10 +1682,11 @@
var normalizedName = this.normalize(fullName);
delete this.registrations[normalizedName];
delete this._resolveCache[normalizedName];
+ delete this._failCache[normalizedName];
delete this._options[normalizedName];
},
/**
Given a fullName return the corresponding factory.
@@ -2053,11 +2056,11 @@
normalizeInjectionsHash: function (hash) {
var injections = [];
for (var key in hash) {
if (hash.hasOwnProperty(key)) {
- Ember['default'].assert("Expected a proper full name, given '" + hash[key] + "'", this.validateFullName(hash[key]));
+ Ember['default'].assert('Expected a proper full name, given \'' + hash[key] + '\'', this.validateFullName(hash[key]));
injections.push({
property: key,
fullName: hash[key]
});
@@ -2103,14 +2106,22 @@
function resolve(registry, normalizedName) {
var cached = registry._resolveCache[normalizedName];
if (cached) {
return cached;
}
+ if (registry._failCache[normalizedName]) {
+ return;
+ }
var resolved = registry.resolver(normalizedName) || registry.registrations[normalizedName];
- registry._resolveCache[normalizedName] = resolved;
+ if (resolved) {
+ registry._resolveCache[normalizedName] = resolved;
+ } else {
+ registry._failCache[normalizedName] = true;
+ }
+
return resolved;
}
function has(registry, fullName) {
return registry.resolve(fullName) !== undefined;
@@ -2316,879 +2327,944 @@
module.exports = DAG;
} else if (typeof this !== 'undefined') {
this['DAG'] = DAG;
}
});
-enifed("dom-helper",
- ["./morph-range","./morph-attr","./dom-helper/build-html-dom","./dom-helper/classes","./dom-helper/prop","exports"],
- function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __exports__) {
- "use strict";
- var Morph = __dependency1__["default"];
- var AttrMorph = __dependency2__["default"];
- var buildHTMLDOM = __dependency3__.buildHTMLDOM;
- var svgNamespace = __dependency3__.svgNamespace;
- var svgHTMLIntegrationPoints = __dependency3__.svgHTMLIntegrationPoints;
- var addClasses = __dependency4__.addClasses;
- var removeClasses = __dependency4__.removeClasses;
- var normalizeProperty = __dependency5__.normalizeProperty;
- var isAttrRemovalValue = __dependency5__.isAttrRemovalValue;
+enifed('dom-helper', ['exports', './htmlbars-runtime/morph', './morph-attr', './dom-helper/build-html-dom', './dom-helper/classes', './dom-helper/prop'], function (exports, Morph, AttrMorph, build_html_dom, classes, prop) {
- var doc = typeof document === 'undefined' ? false : document;
+ 'use strict';
- var deletesBlankTextNodes = doc && (function(document){
- var element = document.createElement('div');
- element.appendChild( document.createTextNode('') );
- var clonedElement = element.cloneNode(true);
- return clonedElement.childNodes.length === 0;
- })(doc);
+ var doc = typeof document === "undefined" ? false : document;
- var ignoresCheckedAttribute = doc && (function(document){
- var element = document.createElement('input');
- element.setAttribute('checked', 'checked');
- var clonedElement = element.cloneNode(false);
- return !clonedElement.checked;
- })(doc);
+ var deletesBlankTextNodes = doc && (function (document) {
+ var element = document.createElement("div");
+ element.appendChild(document.createTextNode(""));
+ var clonedElement = element.cloneNode(true);
+ return clonedElement.childNodes.length === 0;
+ })(doc);
- var canRemoveSvgViewBoxAttribute = doc && (doc.createElementNS ? (function(document){
- var element = document.createElementNS(svgNamespace, 'svg');
- element.setAttribute('viewBox', '0 0 100 100');
- element.removeAttribute('viewBox');
- return !element.getAttribute('viewBox');
- })(doc) : true);
+ var ignoresCheckedAttribute = doc && (function (document) {
+ var element = document.createElement("input");
+ element.setAttribute("checked", "checked");
+ var clonedElement = element.cloneNode(false);
+ return !clonedElement.checked;
+ })(doc);
- var canClone = doc && (function(document){
- var element = document.createElement('div');
- element.appendChild( document.createTextNode(' '));
- element.appendChild( document.createTextNode(' '));
- var clonedElement = element.cloneNode(true);
- return clonedElement.childNodes[0].nodeValue === ' ';
- })(doc);
+ var canRemoveSvgViewBoxAttribute = doc && (doc.createElementNS ? (function (document) {
+ var element = document.createElementNS(build_html_dom.svgNamespace, "svg");
+ element.setAttribute("viewBox", "0 0 100 100");
+ element.removeAttribute("viewBox");
+ return !element.getAttribute("viewBox");
+ })(doc) : true);
- // This is not the namespace of the element, but of
- // the elements inside that elements.
- function interiorNamespace(element){
- if (
- element &&
- element.namespaceURI === svgNamespace &&
- !svgHTMLIntegrationPoints[element.tagName]
- ) {
- return svgNamespace;
- } else {
- return null;
- }
+ var canClone = doc && (function (document) {
+ var element = document.createElement("div");
+ element.appendChild(document.createTextNode(" "));
+ element.appendChild(document.createTextNode(" "));
+ var clonedElement = element.cloneNode(true);
+ return clonedElement.childNodes[0].nodeValue === " ";
+ })(doc);
+
+ // This is not the namespace of the element, but of
+ // the elements inside that elements.
+ function interiorNamespace(element) {
+ if (element && element.namespaceURI === build_html_dom.svgNamespace && !build_html_dom.svgHTMLIntegrationPoints[element.tagName]) {
+ return build_html_dom.svgNamespace;
+ } else {
+ return null;
}
+ }
- // The HTML spec allows for "omitted start tags". These tags are optional
- // when their intended child is the first thing in the parent tag. For
- // example, this is a tbody start tag:
- //
- // <table>
- // <tbody>
- // <tr>
- //
- // The tbody may be omitted, and the browser will accept and render:
- //
- // <table>
- // <tr>
- //
- // However, the omitted start tag will still be added to the DOM. Here
- // we test the string and context to see if the browser is about to
- // perform this cleanup.
- //
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#optional-tags
- // describes which tags are omittable. The spec for tbody and colgroup
- // explains this behavior:
- //
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/tables.html#the-tbody-element
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/tables.html#the-colgroup-element
- //
+ // The HTML spec allows for "omitted start tags". These tags are optional
+ // when their intended child is the first thing in the parent tag. For
+ // example, this is a tbody start tag:
+ //
+ // <table>
+ // <tbody>
+ // <tr>
+ //
+ // The tbody may be omitted, and the browser will accept and render:
+ //
+ // <table>
+ // <tr>
+ //
+ // However, the omitted start tag will still be added to the DOM. Here
+ // we test the string and context to see if the browser is about to
+ // perform this cleanup.
+ //
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#optional-tags
+ // describes which tags are omittable. The spec for tbody and colgroup
+ // explains this behavior:
+ //
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/tables.html#the-tbody-element
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/tables.html#the-colgroup-element
+ //
- var omittedStartTagChildTest = /<([\w:]+)/;
- function detectOmittedStartTag(string, contextualElement){
- // Omitted start tags are only inside table tags.
- if (contextualElement.tagName === 'TABLE') {
- var omittedStartTagChildMatch = omittedStartTagChildTest.exec(string);
- if (omittedStartTagChildMatch) {
- var omittedStartTagChild = omittedStartTagChildMatch[1];
- // It is already asserted that the contextual element is a table
- // and not the proper start tag. Just see if a tag was omitted.
- return omittedStartTagChild === 'tr' ||
- omittedStartTagChild === 'col';
- }
+ var omittedStartTagChildTest = /<([\w:]+)/;
+ function detectOmittedStartTag(string, contextualElement) {
+ // Omitted start tags are only inside table tags.
+ if (contextualElement.tagName === "TABLE") {
+ var omittedStartTagChildMatch = omittedStartTagChildTest.exec(string);
+ if (omittedStartTagChildMatch) {
+ var omittedStartTagChild = omittedStartTagChildMatch[1];
+ // It is already asserted that the contextual element is a table
+ // and not the proper start tag. Just see if a tag was omitted.
+ return omittedStartTagChild === "tr" || omittedStartTagChild === "col";
}
}
+ }
- function buildSVGDOM(html, dom){
- var div = dom.document.createElement('div');
- div.innerHTML = '<svg>'+html+'</svg>';
- return div.firstChild.childNodes;
+ function buildSVGDOM(html, dom) {
+ var div = dom.document.createElement("div");
+ div.innerHTML = "<svg>" + html + "</svg>";
+ return div.firstChild.childNodes;
+ }
+
+ var guid = 1;
+
+ function ElementMorph(element, dom, namespace) {
+ this.element = element;
+ this.dom = dom;
+ this.namespace = namespace;
+ this.guid = "element" + guid++;
+
+ this.state = {};
+ this.isDirty = true;
+ }
+
+ // renderAndCleanup calls `clear` on all items in the morph map
+ // just before calling `destroy` on the morph.
+ //
+ // As a future refactor this could be changed to set the property
+ // back to its original/default value.
+ ElementMorph.prototype.clear = function () {};
+
+ ElementMorph.prototype.destroy = function () {
+ this.element = null;
+ this.dom = null;
+ };
+
+ /*
+ * A class wrapping DOM functions to address environment compatibility,
+ * namespaces, contextual elements for morph un-escaped content
+ * insertion.
+ *
+ * When entering a template, a DOMHelper should be passed:
+ *
+ * template(context, { hooks: hooks, dom: new DOMHelper() });
+ *
+ * TODO: support foreignObject as a passed contextual element. It has
+ * a namespace (svg) that does not match its internal namespace
+ * (xhtml).
+ *
+ * @class DOMHelper
+ * @constructor
+ * @param {HTMLDocument} _document The document DOM methods are proxied to
+ */
+ function DOMHelper(_document) {
+ this.document = _document || document;
+ if (!this.document) {
+ throw new Error("A document object must be passed to the DOMHelper, or available on the global scope");
}
+ this.canClone = canClone;
+ this.namespace = null;
+ }
- /*
- * A class wrapping DOM functions to address environment compatibility,
- * namespaces, contextual elements for morph un-escaped content
- * insertion.
- *
- * When entering a template, a DOMHelper should be passed:
- *
- * template(context, { hooks: hooks, dom: new DOMHelper() });
- *
- * TODO: support foreignObject as a passed contextual element. It has
- * a namespace (svg) that does not match its internal namespace
- * (xhtml).
- *
- * @class DOMHelper
- * @constructor
- * @param {HTMLDocument} _document The document DOM methods are proxied to
- */
- function DOMHelper(_document){
- this.document = _document || document;
- if (!this.document) {
- throw new Error("A document object must be passed to the DOMHelper, or available on the global scope");
- }
- this.canClone = canClone;
- this.namespace = null;
+ var prototype = DOMHelper.prototype;
+ prototype.constructor = DOMHelper;
+
+ prototype.getElementById = function (id, rootNode) {
+ rootNode = rootNode || this.document;
+ return rootNode.getElementById(id);
+ };
+
+ prototype.insertBefore = function (element, childElement, referenceChild) {
+ return element.insertBefore(childElement, referenceChild);
+ };
+
+ prototype.appendChild = function (element, childElement) {
+ return element.appendChild(childElement);
+ };
+
+ prototype.childAt = function (element, indices) {
+ var child = element;
+
+ for (var i = 0; i < indices.length; i++) {
+ child = child.childNodes.item(indices[i]);
}
- var prototype = DOMHelper.prototype;
- prototype.constructor = DOMHelper;
+ return child;
+ };
- prototype.getElementById = function(id, rootNode) {
- rootNode = rootNode || this.document;
- return rootNode.getElementById(id);
- };
+ // Note to a Fellow Implementor:
+ // Ahh, accessing a child node at an index. Seems like it should be so simple,
+ // doesn't it? Unfortunately, this particular method has caused us a surprising
+ // amount of pain. As you'll note below, this method has been modified to walk
+ // the linked list of child nodes rather than access the child by index
+ // directly, even though there are two (2) APIs in the DOM that do this for us.
+ // If you're thinking to yourself, "What an oversight! What an opportunity to
+ // optimize this code!" then to you I say: stop! For I have a tale to tell.
+ //
+ // First, this code must be compatible with simple-dom for rendering on the
+ // server where there is no real DOM. Previously, we accessed a child node
+ // directly via `element.childNodes[index]`. While we *could* in theory do a
+ // full-fidelity simulation of a live `childNodes` array, this is slow,
+ // complicated and error-prone.
+ //
+ // "No problem," we thought, "we'll just use the similar
+ // `childNodes.item(index)` API." Then, we could just implement our own `item`
+ // method in simple-dom and walk the child node linked list there, allowing
+ // us to retain the performance advantages of the (surely optimized) `item()`
+ // API in the browser.
+ //
+ // Unfortunately, an enterprising soul named Samy Alzahrani discovered that in
+ // IE8, accessing an item out-of-bounds via `item()` causes an exception where
+ // other browsers return null. This necessitated a... check of
+ // `childNodes.length`, bringing us back around to having to support a
+ // full-fidelity `childNodes` array!
+ //
+ // Worst of all, Kris Selden investigated how browsers are actualy implemented
+ // and discovered that they're all linked lists under the hood anyway. Accessing
+ // `childNodes` requires them to allocate a new live collection backed by that
+ // linked list, which is itself a rather expensive operation. Our assumed
+ // optimization had backfired! That is the danger of magical thinking about
+ // the performance of native implementations.
+ //
+ // And this, my friends, is why the following implementation just walks the
+ // linked list, as surprised as that may make you. Please ensure you understand
+ // the above before changing this and submitting a PR.
+ //
+ // Tom Dale, January 18th, 2015, Portland OR
+ prototype.childAtIndex = function (element, index) {
+ var node = element.firstChild;
- prototype.insertBefore = function(element, childElement, referenceChild) {
- return element.insertBefore(childElement, referenceChild);
- };
+ for (var idx = 0; node && idx < index; idx++) {
+ node = node.nextSibling;
+ }
- prototype.appendChild = function(element, childElement) {
- return element.appendChild(childElement);
- };
+ return node;
+ };
- prototype.childAt = function(element, indices) {
- var child = element;
+ prototype.appendText = function (element, text) {
+ return element.appendChild(this.document.createTextNode(text));
+ };
- for (var i = 0; i < indices.length; i++) {
- child = child.childNodes.item(indices[i]);
- }
+ prototype.setAttribute = function (element, name, value) {
+ element.setAttribute(name, String(value));
+ };
- return child;
- };
+ prototype.getAttribute = function (element, name) {
+ return element.getAttribute(name);
+ };
- // Note to a Fellow Implementor:
- // Ahh, accessing a child node at an index. Seems like it should be so simple,
- // doesn't it? Unfortunately, this particular method has caused us a surprising
- // amount of pain. As you'll note below, this method has been modified to walk
- // the linked list of child nodes rather than access the child by index
- // directly, even though there are two (2) APIs in the DOM that do this for us.
- // If you're thinking to yourself, "What an oversight! What an opportunity to
- // optimize this code!" then to you I say: stop! For I have a tale to tell.
- //
- // First, this code must be compatible with simple-dom for rendering on the
- // server where there is no real DOM. Previously, we accessed a child node
- // directly via `element.childNodes[index]`. While we *could* in theory do a
- // full-fidelity simulation of a live `childNodes` array, this is slow,
- // complicated and error-prone.
- //
- // "No problem," we thought, "we'll just use the similar
- // `childNodes.item(index)` API." Then, we could just implement our own `item`
- // method in simple-dom and walk the child node linked list there, allowing
- // us to retain the performance advantages of the (surely optimized) `item()`
- // API in the browser.
- //
- // Unfortunately, an enterprising soul named Samy Alzahrani discovered that in
- // IE8, accessing an item out-of-bounds via `item()` causes an exception where
- // other browsers return null. This necessitated a... check of
- // `childNodes.length`, bringing us back around to having to support a
- // full-fidelity `childNodes` array!
- //
- // Worst of all, Kris Selden investigated how browsers are actualy implemented
- // and discovered that they're all linked lists under the hood anyway. Accessing
- // `childNodes` requires them to allocate a new live collection backed by that
- // linked list, which is itself a rather expensive operation. Our assumed
- // optimization had backfired! That is the danger of magical thinking about
- // the performance of native implementations.
- //
- // And this, my friends, is why the following implementation just walks the
- // linked list, as surprised as that may make you. Please ensure you understand
- // the above before changing this and submitting a PR.
- //
- // Tom Dale, January 18th, 2015, Portland OR
- prototype.childAtIndex = function(element, index) {
- var node = element.firstChild;
+ prototype.setAttributeNS = function (element, namespace, name, value) {
+ element.setAttributeNS(namespace, name, String(value));
+ };
- for (var idx = 0; node && idx < index; idx++) {
- node = node.nextSibling;
- }
+ prototype.getAttributeNS = function (element, namespace, name) {
+ return element.getAttributeNS(namespace, name);
+ };
- return node;
+ if (canRemoveSvgViewBoxAttribute) {
+ prototype.removeAttribute = function (element, name) {
+ element.removeAttribute(name);
};
-
- prototype.appendText = function(element, text) {
- return element.appendChild(this.document.createTextNode(text));
+ } else {
+ prototype.removeAttribute = function (element, name) {
+ if (element.tagName === "svg" && name === "viewBox") {
+ element.setAttribute(name, null);
+ } else {
+ element.removeAttribute(name);
+ }
};
+ }
- prototype.setAttribute = function(element, name, value) {
- element.setAttribute(name, String(value));
- };
+ prototype.setPropertyStrict = function (element, name, value) {
+ if (value === undefined) {
+ value = null;
+ }
- prototype.setAttributeNS = function(element, namespace, name, value) {
- element.setAttributeNS(namespace, name, String(value));
- };
+ if (value === null && (name === "value" || name === "type" || name === "src")) {
+ value = "";
+ }
- if (canRemoveSvgViewBoxAttribute){
- prototype.removeAttribute = function(element, name) {
+ element[name] = value;
+ };
+
+ prototype.getPropertyStrict = function (element, name) {
+ return element[name];
+ };
+
+ prototype.setProperty = function (element, name, value, namespace) {
+ var lowercaseName = name.toLowerCase();
+ if (element.namespaceURI === build_html_dom.svgNamespace || lowercaseName === "style") {
+ if (prop.isAttrRemovalValue(value)) {
element.removeAttribute(name);
- };
- } else {
- prototype.removeAttribute = function(element, name) {
- if (element.tagName === 'svg' && name === 'viewBox') {
- element.setAttribute(name, null);
+ } else {
+ if (namespace) {
+ element.setAttributeNS(namespace, name, value);
} else {
- element.removeAttribute(name);
+ element.setAttribute(name, value);
}
- };
- }
-
- prototype.setPropertyStrict = function(element, name, value) {
- element[name] = value;
- };
-
- prototype.setProperty = function(element, name, value, namespace) {
- var lowercaseName = name.toLowerCase();
- if (element.namespaceURI === svgNamespace || lowercaseName === 'style') {
- if (isAttrRemovalValue(value)) {
+ }
+ } else {
+ var normalized = prop.normalizeProperty(element, name);
+ if (normalized) {
+ element[normalized] = value;
+ } else {
+ if (prop.isAttrRemovalValue(value)) {
element.removeAttribute(name);
} else {
- if (namespace) {
+ if (namespace && element.setAttributeNS) {
element.setAttributeNS(namespace, name, value);
} else {
element.setAttribute(name, value);
}
}
- } else {
- var normalized = normalizeProperty(element, name);
- if (normalized) {
- element[normalized] = value;
+ }
+ }
+ };
+
+ if (doc && doc.createElementNS) {
+ // Only opt into namespace detection if a contextualElement
+ // is passed.
+ prototype.createElement = function (tagName, contextualElement) {
+ var namespace = this.namespace;
+ if (contextualElement) {
+ if (tagName === "svg") {
+ namespace = build_html_dom.svgNamespace;
} else {
- if (isAttrRemovalValue(value)) {
- element.removeAttribute(name);
- } else {
- if (namespace && element.setAttributeNS) {
- element.setAttributeNS(namespace, name, value);
- } else {
- element.setAttribute(name, value);
- }
- }
+ namespace = interiorNamespace(contextualElement);
}
}
+ if (namespace) {
+ return this.document.createElementNS(namespace, tagName);
+ } else {
+ return this.document.createElement(tagName);
+ }
};
+ prototype.setAttributeNS = function (element, namespace, name, value) {
+ element.setAttributeNS(namespace, name, String(value));
+ };
+ } else {
+ prototype.createElement = function (tagName) {
+ return this.document.createElement(tagName);
+ };
+ prototype.setAttributeNS = function (element, namespace, name, value) {
+ element.setAttribute(name, String(value));
+ };
+ }
- if (doc && doc.createElementNS) {
- // Only opt into namespace detection if a contextualElement
- // is passed.
- prototype.createElement = function(tagName, contextualElement) {
- var namespace = this.namespace;
- if (contextualElement) {
- if (tagName === 'svg') {
- namespace = svgNamespace;
- } else {
- namespace = interiorNamespace(contextualElement);
- }
- }
- if (namespace) {
- return this.document.createElementNS(namespace, tagName);
+ prototype.addClasses = classes.addClasses;
+ prototype.removeClasses = classes.removeClasses;
+
+ prototype.setNamespace = function (ns) {
+ this.namespace = ns;
+ };
+
+ prototype.detectNamespace = function (element) {
+ this.namespace = interiorNamespace(element);
+ };
+
+ prototype.createDocumentFragment = function () {
+ return this.document.createDocumentFragment();
+ };
+
+ prototype.createTextNode = function (text) {
+ return this.document.createTextNode(text);
+ };
+
+ prototype.createComment = function (text) {
+ return this.document.createComment(text);
+ };
+
+ prototype.repairClonedNode = function (element, blankChildTextNodes, isChecked) {
+ if (deletesBlankTextNodes && blankChildTextNodes.length > 0) {
+ for (var i = 0, len = blankChildTextNodes.length; i < len; i++) {
+ var textNode = this.document.createTextNode(""),
+ offset = blankChildTextNodes[i],
+ before = this.childAtIndex(element, offset);
+ if (before) {
+ element.insertBefore(textNode, before);
} else {
- return this.document.createElement(tagName);
+ element.appendChild(textNode);
}
- };
- prototype.setAttributeNS = function(element, namespace, name, value) {
- element.setAttributeNS(namespace, name, String(value));
- };
- } else {
- prototype.createElement = function(tagName) {
- return this.document.createElement(tagName);
- };
- prototype.setAttributeNS = function(element, namespace, name, value) {
- element.setAttribute(name, String(value));
- };
+ }
}
+ if (ignoresCheckedAttribute && isChecked) {
+ element.setAttribute("checked", "checked");
+ }
+ };
- prototype.addClasses = addClasses;
- prototype.removeClasses = removeClasses;
+ prototype.cloneNode = function (element, deep) {
+ var clone = element.cloneNode(!!deep);
+ return clone;
+ };
- prototype.setNamespace = function(ns) {
- this.namespace = ns;
- };
+ prototype.AttrMorphClass = AttrMorph['default'];
- prototype.detectNamespace = function(element) {
- this.namespace = interiorNamespace(element);
- };
+ prototype.createAttrMorph = function (element, attrName, namespace) {
+ return new this.AttrMorphClass(element, attrName, this, namespace);
+ };
- prototype.createDocumentFragment = function(){
- return this.document.createDocumentFragment();
- };
+ prototype.ElementMorphClass = ElementMorph;
- prototype.createTextNode = function(text){
- return this.document.createTextNode(text);
- };
+ prototype.createElementMorph = function (element, namespace) {
+ return new this.ElementMorphClass(element, this, namespace);
+ };
- prototype.createComment = function(text){
- return this.document.createComment(text);
- };
+ prototype.createUnsafeAttrMorph = function (element, attrName, namespace) {
+ var morph = this.createAttrMorph(element, attrName, namespace);
+ morph.escaped = false;
+ return morph;
+ };
- prototype.repairClonedNode = function(element, blankChildTextNodes, isChecked){
- if (deletesBlankTextNodes && blankChildTextNodes.length > 0) {
- for (var i=0, len=blankChildTextNodes.length;i<len;i++){
- var textNode = this.document.createTextNode(''),
- offset = blankChildTextNodes[i],
- before = this.childAtIndex(element, offset);
- if (before) {
- element.insertBefore(textNode, before);
- } else {
- element.appendChild(textNode);
- }
- }
- }
- if (ignoresCheckedAttribute && isChecked) {
- element.setAttribute('checked', 'checked');
- }
- };
+ prototype.MorphClass = Morph['default'];
- prototype.cloneNode = function(element, deep){
- var clone = element.cloneNode(!!deep);
- return clone;
- };
+ prototype.createMorph = function (parent, start, end, contextualElement) {
+ if (contextualElement && contextualElement.nodeType === 11) {
+ throw new Error("Cannot pass a fragment as the contextual element to createMorph");
+ }
- prototype.createAttrMorph = function(element, attrName, namespace){
- return new AttrMorph(element, attrName, this, namespace);
- };
+ if (!contextualElement && parent && parent.nodeType === 1) {
+ contextualElement = parent;
+ }
+ var morph = new this.MorphClass(this, contextualElement);
+ morph.firstNode = start;
+ morph.lastNode = end;
+ return morph;
+ };
- prototype.createUnsafeAttrMorph = function(element, attrName, namespace){
- var morph = this.createAttrMorph(element, attrName, namespace);
- morph.escaped = false;
- return morph;
- };
+ prototype.createFragmentMorph = function (contextualElement) {
+ if (contextualElement && contextualElement.nodeType === 11) {
+ throw new Error("Cannot pass a fragment as the contextual element to createMorph");
+ }
- prototype.createMorph = function(parent, start, end, contextualElement){
- if (contextualElement && contextualElement.nodeType === 11) {
- throw new Error("Cannot pass a fragment as the contextual element to createMorph");
- }
+ var fragment = this.createDocumentFragment();
+ return Morph['default'].create(this, contextualElement, fragment);
+ };
- if (!contextualElement && parent.nodeType === 1) {
- contextualElement = parent;
- }
- var morph = new Morph(this, contextualElement);
- morph.firstNode = start;
- morph.lastNode = end;
- morph.state = {};
- morph.isDirty = true;
- return morph;
- };
+ prototype.replaceContentWithMorph = function (element) {
+ var firstChild = element.firstChild;
- prototype.createUnsafeMorph = function(parent, start, end, contextualElement){
- var morph = this.createMorph(parent, start, end, contextualElement);
- morph.parseTextAsHTML = true;
+ if (!firstChild) {
+ var comment = this.createComment("");
+ this.appendChild(element, comment);
+ return Morph['default'].create(this, element, comment);
+ } else {
+ var morph = Morph['default'].attach(this, element, firstChild, element.lastChild);
+ morph.clear();
return morph;
- };
+ }
+ };
- // This helper is just to keep the templates good looking,
- // passing integers instead of element references.
- prototype.createMorphAt = function(parent, startIndex, endIndex, contextualElement){
- var single = startIndex === endIndex;
- var start = this.childAtIndex(parent, startIndex);
- var end = single ? start : this.childAtIndex(parent, endIndex);
- return this.createMorph(parent, start, end, contextualElement);
- };
+ prototype.createUnsafeMorph = function (parent, start, end, contextualElement) {
+ var morph = this.createMorph(parent, start, end, contextualElement);
+ morph.parseTextAsHTML = true;
+ return morph;
+ };
- prototype.createUnsafeMorphAt = function(parent, startIndex, endIndex, contextualElement) {
- var morph = this.createMorphAt(parent, startIndex, endIndex, contextualElement);
- morph.parseTextAsHTML = true;
- return morph;
- };
+ // This helper is just to keep the templates good looking,
+ // passing integers instead of element references.
+ prototype.createMorphAt = function (parent, startIndex, endIndex, contextualElement) {
+ var single = startIndex === endIndex;
+ var start = this.childAtIndex(parent, startIndex);
+ var end = single ? start : this.childAtIndex(parent, endIndex);
+ return this.createMorph(parent, start, end, contextualElement);
+ };
- prototype.insertMorphBefore = function(element, referenceChild, contextualElement) {
- var insertion = this.document.createComment('');
- element.insertBefore(insertion, referenceChild);
- return this.createMorph(element, insertion, insertion, contextualElement);
- };
+ prototype.createUnsafeMorphAt = function (parent, startIndex, endIndex, contextualElement) {
+ var morph = this.createMorphAt(parent, startIndex, endIndex, contextualElement);
+ morph.parseTextAsHTML = true;
+ return morph;
+ };
- prototype.appendMorph = function(element, contextualElement) {
- var insertion = this.document.createComment('');
- element.appendChild(insertion);
- return this.createMorph(element, insertion, insertion, contextualElement);
- };
+ prototype.insertMorphBefore = function (element, referenceChild, contextualElement) {
+ var insertion = this.document.createComment("");
+ element.insertBefore(insertion, referenceChild);
+ return this.createMorph(element, insertion, insertion, contextualElement);
+ };
- prototype.insertBoundary = function(fragment, index) {
- // this will always be null or firstChild
- var child = index === null ? null : this.childAtIndex(fragment, index);
- this.insertBefore(fragment, this.createTextNode(''), child);
- };
+ prototype.appendMorph = function (element, contextualElement) {
+ var insertion = this.document.createComment("");
+ element.appendChild(insertion);
+ return this.createMorph(element, insertion, insertion, contextualElement);
+ };
- prototype.parseHTML = function(html, contextualElement) {
- var childNodes;
+ prototype.insertBoundary = function (fragment, index) {
+ // this will always be null or firstChild
+ var child = index === null ? null : this.childAtIndex(fragment, index);
+ this.insertBefore(fragment, this.createTextNode(""), child);
+ };
- if (interiorNamespace(contextualElement) === svgNamespace) {
- childNodes = buildSVGDOM(html, this);
- } else {
- var nodes = buildHTMLDOM(html, contextualElement, this);
- if (detectOmittedStartTag(html, contextualElement)) {
- var node = nodes[0];
- while (node && node.nodeType !== 1) {
- node = node.nextSibling;
- }
- childNodes = node.childNodes;
- } else {
- childNodes = nodes;
+ prototype.parseHTML = function (html, contextualElement) {
+ var childNodes;
+
+ if (interiorNamespace(contextualElement) === build_html_dom.svgNamespace) {
+ childNodes = buildSVGDOM(html, this);
+ } else {
+ var nodes = build_html_dom.buildHTMLDOM(html, contextualElement, this);
+ if (detectOmittedStartTag(html, contextualElement)) {
+ var node = nodes[0];
+ while (node && node.nodeType !== 1) {
+ node = node.nextSibling;
}
+ childNodes = node.childNodes;
+ } else {
+ childNodes = nodes;
}
+ }
- // Copy node list to a fragment.
- var fragment = this.document.createDocumentFragment();
+ // Copy node list to a fragment.
+ var fragment = this.document.createDocumentFragment();
- if (childNodes && childNodes.length > 0) {
- var currentNode = childNodes[0];
+ if (childNodes && childNodes.length > 0) {
+ var currentNode = childNodes[0];
- // We prepend an <option> to <select> boxes to absorb any browser bugs
- // related to auto-select behavior. Skip past it.
- if (contextualElement.tagName === 'SELECT') {
- currentNode = currentNode.nextSibling;
- }
+ // We prepend an <option> to <select> boxes to absorb any browser bugs
+ // related to auto-select behavior. Skip past it.
+ if (contextualElement.tagName === "SELECT") {
+ currentNode = currentNode.nextSibling;
+ }
- while (currentNode) {
- var tempNode = currentNode;
- currentNode = currentNode.nextSibling;
+ while (currentNode) {
+ var tempNode = currentNode;
+ currentNode = currentNode.nextSibling;
- fragment.appendChild(tempNode);
- }
+ fragment.appendChild(tempNode);
}
+ }
- return fragment;
- };
+ return fragment;
+ };
- var parsingNode;
+ var parsingNode;
- // Used to determine whether a URL needs to be sanitized.
- prototype.protocolForURL = function(url) {
- if (!parsingNode) {
- parsingNode = this.document.createElement('a');
- }
+ // Used to determine whether a URL needs to be sanitized.
+ prototype.protocolForURL = function (url) {
+ if (!parsingNode) {
+ parsingNode = this.document.createElement("a");
+ }
- parsingNode.href = url;
- return parsingNode.protocol;
- };
+ parsingNode.href = url;
+ return parsingNode.protocol;
+ };
- __exports__["default"] = DOMHelper;
- });
-enifed("dom-helper/build-html-dom",
- ["exports"],
- function(__exports__) {
- "use strict";
- /* global XMLSerializer:false */
- var svgHTMLIntegrationPoints = {foreignObject: 1, desc: 1, title: 1};
- __exports__.svgHTMLIntegrationPoints = svgHTMLIntegrationPoints;var svgNamespace = 'http://www.w3.org/2000/svg';
- __exports__.svgNamespace = svgNamespace;
- var doc = typeof document === 'undefined' ? false : document;
+ exports['default'] = DOMHelper;
- // Safari does not like using innerHTML on SVG HTML integration
- // points (desc/title/foreignObject).
- var needsIntegrationPointFix = doc && (function(document) {
- if (document.createElementNS === undefined) {
- return;
- }
- // In FF title will not accept innerHTML.
- var testEl = document.createElementNS(svgNamespace, 'title');
- testEl.innerHTML = "<div></div>";
- return testEl.childNodes.length === 0 || testEl.childNodes[0].nodeType !== 1;
- })(doc);
+});
+enifed('dom-helper/build-html-dom', ['exports'], function (exports) {
- // Internet Explorer prior to 9 does not allow setting innerHTML if the first element
- // is a "zero-scope" element. This problem can be worked around by making
- // the first node an invisible text node. We, like Modernizr, use ­
- var needsShy = doc && (function(document) {
- var testEl = document.createElement('div');
- testEl.innerHTML = "<div></div>";
- testEl.firstChild.innerHTML = "<script><\/script>";
- return testEl.firstChild.innerHTML === '';
- })(doc);
+ 'use strict';
- // IE 8 (and likely earlier) likes to move whitespace preceeding
- // a script tag to appear after it. This means that we can
- // accidentally remove whitespace when updating a morph.
- var movesWhitespace = doc && (function(document) {
- var testEl = document.createElement('div');
- testEl.innerHTML = "Test: <script type='text/x-placeholder'><\/script>Value";
- return testEl.childNodes[0].nodeValue === 'Test:' &&
- testEl.childNodes[2].nodeValue === ' Value';
- })(doc);
+ /* global XMLSerializer:false */
+ var svgHTMLIntegrationPoints = { foreignObject: 1, desc: 1, title: 1 };
+ var svgNamespace = 'http://www.w3.org/2000/svg';
- var tagNamesRequiringInnerHTMLFix = doc && (function(document) {
- var tagNamesRequiringInnerHTMLFix;
- // IE 9 and earlier don't allow us to set innerHTML on col, colgroup, frameset,
- // html, style, table, tbody, tfoot, thead, title, tr. Detect this and add
- // them to an initial list of corrected tags.
- //
- // Here we are only dealing with the ones which can have child nodes.
- //
- var tableNeedsInnerHTMLFix;
- var tableInnerHTMLTestElement = document.createElement('table');
- try {
- tableInnerHTMLTestElement.innerHTML = '<tbody></tbody>';
- } catch (e) {
- } finally {
- tableNeedsInnerHTMLFix = (tableInnerHTMLTestElement.childNodes.length === 0);
- }
- if (tableNeedsInnerHTMLFix) {
- tagNamesRequiringInnerHTMLFix = {
- colgroup: ['table'],
- table: [],
- tbody: ['table'],
- tfoot: ['table'],
- thead: ['table'],
- tr: ['table', 'tbody']
- };
- }
+ var doc = typeof document === 'undefined' ? false : document;
- // IE 8 doesn't allow setting innerHTML on a select tag. Detect this and
- // add it to the list of corrected tags.
- //
- var selectInnerHTMLTestElement = document.createElement('select');
- selectInnerHTMLTestElement.innerHTML = '<option></option>';
- if (!selectInnerHTMLTestElement.childNodes[0]) {
- tagNamesRequiringInnerHTMLFix = tagNamesRequiringInnerHTMLFix || {};
- tagNamesRequiringInnerHTMLFix.select = [];
- }
- return tagNamesRequiringInnerHTMLFix;
- })(doc);
+ // Safari does not like using innerHTML on SVG HTML integration
+ // points (desc/title/foreignObject).
+ var needsIntegrationPointFix = doc && (function (document) {
+ if (document.createElementNS === undefined) {
+ return;
+ }
+ // In FF title will not accept innerHTML.
+ var testEl = document.createElementNS(svgNamespace, 'title');
+ testEl.innerHTML = '<div></div>';
+ return testEl.childNodes.length === 0 || testEl.childNodes[0].nodeType !== 1;
+ })(doc);
- function scriptSafeInnerHTML(element, html) {
- // without a leading text node, IE will drop a leading script tag.
- html = '­'+html;
+ // Internet Explorer prior to 9 does not allow setting innerHTML if the first element
+ // is a "zero-scope" element. This problem can be worked around by making
+ // the first node an invisible text node. We, like Modernizr, use ­
+ var needsShy = doc && (function (document) {
+ var testEl = document.createElement('div');
+ testEl.innerHTML = '<div></div>';
+ testEl.firstChild.innerHTML = '<script></script>';
+ return testEl.firstChild.innerHTML === '';
+ })(doc);
- element.innerHTML = html;
+ // IE 8 (and likely earlier) likes to move whitespace preceeding
+ // a script tag to appear after it. This means that we can
+ // accidentally remove whitespace when updating a morph.
+ var movesWhitespace = doc && (function (document) {
+ var testEl = document.createElement('div');
+ testEl.innerHTML = 'Test: <script type=\'text/x-placeholder\'></script>Value';
+ return testEl.childNodes[0].nodeValue === 'Test:' && testEl.childNodes[2].nodeValue === ' Value';
+ })(doc);
- var nodes = element.childNodes;
+ var tagNamesRequiringInnerHTMLFix = doc && (function (document) {
+ var tagNamesRequiringInnerHTMLFix;
+ // IE 9 and earlier don't allow us to set innerHTML on col, colgroup, frameset,
+ // html, style, table, tbody, tfoot, thead, title, tr. Detect this and add
+ // them to an initial list of corrected tags.
+ //
+ // Here we are only dealing with the ones which can have child nodes.
+ //
+ var tableNeedsInnerHTMLFix;
+ var tableInnerHTMLTestElement = document.createElement('table');
+ try {
+ tableInnerHTMLTestElement.innerHTML = '<tbody></tbody>';
+ } catch (e) {} finally {
+ tableNeedsInnerHTMLFix = tableInnerHTMLTestElement.childNodes.length === 0;
+ }
+ if (tableNeedsInnerHTMLFix) {
+ tagNamesRequiringInnerHTMLFix = {
+ colgroup: ['table'],
+ table: [],
+ tbody: ['table'],
+ tfoot: ['table'],
+ thead: ['table'],
+ tr: ['table', 'tbody']
+ };
+ }
- // Look for ­ to remove it.
- var shyElement = nodes[0];
- while (shyElement.nodeType === 1 && !shyElement.nodeName) {
- shyElement = shyElement.firstChild;
- }
- // At this point it's the actual unicode character.
- if (shyElement.nodeType === 3 && shyElement.nodeValue.charAt(0) === "\u00AD") {
- var newValue = shyElement.nodeValue.slice(1);
- if (newValue.length) {
- shyElement.nodeValue = shyElement.nodeValue.slice(1);
- } else {
- shyElement.parentNode.removeChild(shyElement);
- }
- }
-
- return nodes;
+ // IE 8 doesn't allow setting innerHTML on a select tag. Detect this and
+ // add it to the list of corrected tags.
+ //
+ var selectInnerHTMLTestElement = document.createElement('select');
+ selectInnerHTMLTestElement.innerHTML = '<option></option>';
+ if (!selectInnerHTMLTestElement.childNodes[0]) {
+ tagNamesRequiringInnerHTMLFix = tagNamesRequiringInnerHTMLFix || {};
+ tagNamesRequiringInnerHTMLFix.select = [];
}
+ return tagNamesRequiringInnerHTMLFix;
+ })(doc);
- function buildDOMWithFix(html, contextualElement){
- var tagName = contextualElement.tagName;
+ function scriptSafeInnerHTML(element, html) {
+ // without a leading text node, IE will drop a leading script tag.
+ html = '­' + html;
- // Firefox versions < 11 do not have support for element.outerHTML.
- var outerHTML = contextualElement.outerHTML || new XMLSerializer().serializeToString(contextualElement);
- if (!outerHTML) {
- throw "Can't set innerHTML on "+tagName+" in this browser";
+ element.innerHTML = html;
+
+ var nodes = element.childNodes;
+
+ // Look for ­ to remove it.
+ var shyElement = nodes[0];
+ while (shyElement.nodeType === 1 && !shyElement.nodeName) {
+ shyElement = shyElement.firstChild;
+ }
+ // At this point it's the actual unicode character.
+ if (shyElement.nodeType === 3 && shyElement.nodeValue.charAt(0) === 'Â') {
+ var newValue = shyElement.nodeValue.slice(1);
+ if (newValue.length) {
+ shyElement.nodeValue = shyElement.nodeValue.slice(1);
+ } else {
+ shyElement.parentNode.removeChild(shyElement);
}
+ }
- html = fixSelect(html, contextualElement);
+ return nodes;
+ }
- var wrappingTags = tagNamesRequiringInnerHTMLFix[tagName.toLowerCase()];
+ function buildDOMWithFix(html, contextualElement) {
+ var tagName = contextualElement.tagName;
- var startTag = outerHTML.match(new RegExp("<"+tagName+"([^>]*)>", 'i'))[0];
- var endTag = '</'+tagName+'>';
+ // Firefox versions < 11 do not have support for element.outerHTML.
+ var outerHTML = contextualElement.outerHTML || new XMLSerializer().serializeToString(contextualElement);
+ if (!outerHTML) {
+ throw 'Can\'t set innerHTML on ' + tagName + ' in this browser';
+ }
- var wrappedHTML = [startTag, html, endTag];
+ html = fixSelect(html, contextualElement);
- var i = wrappingTags.length;
- var wrappedDepth = 1 + i;
- while(i--) {
- wrappedHTML.unshift('<'+wrappingTags[i]+'>');
- wrappedHTML.push('</'+wrappingTags[i]+'>');
- }
+ var wrappingTags = tagNamesRequiringInnerHTMLFix[tagName.toLowerCase()];
- var wrapper = document.createElement('div');
- scriptSafeInnerHTML(wrapper, wrappedHTML.join(''));
- var element = wrapper;
- while (wrappedDepth--) {
- element = element.firstChild;
- while (element && element.nodeType !== 1) {
- element = element.nextSibling;
- }
- }
- while (element && element.tagName !== tagName) {
+ var startTag = outerHTML.match(new RegExp('<' + tagName + '([^>]*)>', 'i'))[0];
+ var endTag = '</' + tagName + '>';
+
+ var wrappedHTML = [startTag, html, endTag];
+
+ var i = wrappingTags.length;
+ var wrappedDepth = 1 + i;
+ while (i--) {
+ wrappedHTML.unshift('<' + wrappingTags[i] + '>');
+ wrappedHTML.push('</' + wrappingTags[i] + '>');
+ }
+
+ var wrapper = document.createElement('div');
+ scriptSafeInnerHTML(wrapper, wrappedHTML.join(''));
+ var element = wrapper;
+ while (wrappedDepth--) {
+ element = element.firstChild;
+ while (element && element.nodeType !== 1) {
element = element.nextSibling;
}
- return element ? element.childNodes : [];
}
+ while (element && element.tagName !== tagName) {
+ element = element.nextSibling;
+ }
+ return element ? element.childNodes : [];
+ }
- var buildDOM;
- if (needsShy) {
- buildDOM = function buildDOM(html, contextualElement, dom){
- html = fixSelect(html, contextualElement);
+ var buildDOM;
+ if (needsShy) {
+ buildDOM = function buildDOM(html, contextualElement, dom) {
+ html = fixSelect(html, contextualElement);
- contextualElement = dom.cloneNode(contextualElement, false);
- scriptSafeInnerHTML(contextualElement, html);
- return contextualElement.childNodes;
- };
- } else {
- buildDOM = function buildDOM(html, contextualElement, dom){
- html = fixSelect(html, contextualElement);
+ contextualElement = dom.cloneNode(contextualElement, false);
+ scriptSafeInnerHTML(contextualElement, html);
+ return contextualElement.childNodes;
+ };
+ } else {
+ buildDOM = function buildDOM(html, contextualElement, dom) {
+ html = fixSelect(html, contextualElement);
- contextualElement = dom.cloneNode(contextualElement, false);
- contextualElement.innerHTML = html;
- return contextualElement.childNodes;
- };
+ contextualElement = dom.cloneNode(contextualElement, false);
+ contextualElement.innerHTML = html;
+ return contextualElement.childNodes;
+ };
+ }
+
+ function fixSelect(html, contextualElement) {
+ if (contextualElement.tagName === 'SELECT') {
+ html = '<option></option>' + html;
}
- function fixSelect(html, contextualElement) {
- if (contextualElement.tagName === 'SELECT') {
- html = "<option></option>" + html;
- }
+ return html;
+ }
- return html;
- }
+ var buildIESafeDOM;
+ if (tagNamesRequiringInnerHTMLFix || movesWhitespace) {
+ buildIESafeDOM = function buildIESafeDOM(html, contextualElement, dom) {
+ // Make a list of the leading text on script nodes. Include
+ // script tags without any whitespace for easier processing later.
+ var spacesBefore = [];
+ var spacesAfter = [];
+ if (typeof html === 'string') {
+ html = html.replace(/(\s*)(<script)/g, function (match, spaces, tag) {
+ spacesBefore.push(spaces);
+ return tag;
+ });
- var buildIESafeDOM;
- if (tagNamesRequiringInnerHTMLFix || movesWhitespace) {
- buildIESafeDOM = function buildIESafeDOM(html, contextualElement, dom) {
- // Make a list of the leading text on script nodes. Include
- // script tags without any whitespace for easier processing later.
- var spacesBefore = [];
- var spacesAfter = [];
- if (typeof html === 'string') {
- html = html.replace(/(\s*)(<script)/g, function(match, spaces, tag) {
- spacesBefore.push(spaces);
- return tag;
- });
+ html = html.replace(/(<\/script>)(\s*)/g, function (match, tag, spaces) {
+ spacesAfter.push(spaces);
+ return tag;
+ });
+ }
- html = html.replace(/(<\/script>)(\s*)/g, function(match, tag, spaces) {
- spacesAfter.push(spaces);
- return tag;
- });
- }
+ // Fetch nodes
+ var nodes;
+ if (tagNamesRequiringInnerHTMLFix[contextualElement.tagName.toLowerCase()]) {
+ // buildDOMWithFix uses string wrappers for problematic innerHTML.
+ nodes = buildDOMWithFix(html, contextualElement);
+ } else {
+ nodes = buildDOM(html, contextualElement, dom);
+ }
- // Fetch nodes
- var nodes;
- if (tagNamesRequiringInnerHTMLFix[contextualElement.tagName.toLowerCase()]) {
- // buildDOMWithFix uses string wrappers for problematic innerHTML.
- nodes = buildDOMWithFix(html, contextualElement);
- } else {
- nodes = buildDOM(html, contextualElement, dom);
+ // Build a list of script tags, the nodes themselves will be
+ // mutated as we add test nodes.
+ var i, j, node, nodeScriptNodes;
+ var scriptNodes = [];
+ for (i = 0; i < nodes.length; i++) {
+ node = nodes[i];
+ if (node.nodeType !== 1) {
+ continue;
}
-
- // Build a list of script tags, the nodes themselves will be
- // mutated as we add test nodes.
- var i, j, node, nodeScriptNodes;
- var scriptNodes = [];
- for (i=0;i<nodes.length;i++) {
- node=nodes[i];
- if (node.nodeType !== 1) {
- continue;
+ if (node.tagName === 'SCRIPT') {
+ scriptNodes.push(node);
+ } else {
+ nodeScriptNodes = node.getElementsByTagName('script');
+ for (j = 0; j < nodeScriptNodes.length; j++) {
+ scriptNodes.push(nodeScriptNodes[j]);
}
- if (node.tagName === 'SCRIPT') {
- scriptNodes.push(node);
- } else {
- nodeScriptNodes = node.getElementsByTagName('script');
- for (j=0;j<nodeScriptNodes.length;j++) {
- scriptNodes.push(nodeScriptNodes[j]);
- }
- }
}
+ }
- // Walk the script tags and put back their leading text nodes.
- var scriptNode, textNode, spaceBefore, spaceAfter;
- for (i=0;i<scriptNodes.length;i++) {
- scriptNode = scriptNodes[i];
- spaceBefore = spacesBefore[i];
- if (spaceBefore && spaceBefore.length > 0) {
- textNode = dom.document.createTextNode(spaceBefore);
- scriptNode.parentNode.insertBefore(textNode, scriptNode);
- }
-
- spaceAfter = spacesAfter[i];
- if (spaceAfter && spaceAfter.length > 0) {
- textNode = dom.document.createTextNode(spaceAfter);
- scriptNode.parentNode.insertBefore(textNode, scriptNode.nextSibling);
- }
+ // Walk the script tags and put back their leading text nodes.
+ var scriptNode, textNode, spaceBefore, spaceAfter;
+ for (i = 0; i < scriptNodes.length; i++) {
+ scriptNode = scriptNodes[i];
+ spaceBefore = spacesBefore[i];
+ if (spaceBefore && spaceBefore.length > 0) {
+ textNode = dom.document.createTextNode(spaceBefore);
+ scriptNode.parentNode.insertBefore(textNode, scriptNode);
}
- return nodes;
- };
- } else {
- buildIESafeDOM = buildDOM;
- }
-
- var buildHTMLDOM;
- if (needsIntegrationPointFix) {
- buildHTMLDOM = function buildHTMLDOM(html, contextualElement, dom){
- if (svgHTMLIntegrationPoints[contextualElement.tagName]) {
- return buildIESafeDOM(html, document.createElement('div'), dom);
- } else {
- return buildIESafeDOM(html, contextualElement, dom);
+ spaceAfter = spacesAfter[i];
+ if (spaceAfter && spaceAfter.length > 0) {
+ textNode = dom.document.createTextNode(spaceAfter);
+ scriptNode.parentNode.insertBefore(textNode, scriptNode.nextSibling);
}
- };
- } else {
- buildHTMLDOM = buildIESafeDOM;
- }
+ }
- __exports__.buildHTMLDOM = buildHTMLDOM;
- });
-enifed("dom-helper/classes",
- ["exports"],
- function(__exports__) {
- "use strict";
- var doc = typeof document === 'undefined' ? false : document;
+ return nodes;
+ };
+ } else {
+ buildIESafeDOM = buildDOM;
+ }
- // PhantomJS has a broken classList. See https://github.com/ariya/phantomjs/issues/12782
- var canClassList = doc && (function(){
- var d = document.createElement('div');
- if (!d.classList) {
- return false;
+ var buildHTMLDOM;
+ if (needsIntegrationPointFix) {
+ buildHTMLDOM = function buildHTMLDOM(html, contextualElement, dom) {
+ if (svgHTMLIntegrationPoints[contextualElement.tagName]) {
+ return buildIESafeDOM(html, document.createElement('div'), dom);
+ } else {
+ return buildIESafeDOM(html, contextualElement, dom);
}
- d.classList.add('boo');
- d.classList.add('boo', 'baz');
- return (d.className === 'boo baz');
- })();
+ };
+ } else {
+ buildHTMLDOM = buildIESafeDOM;
+ }
- function buildClassList(element) {
- var classString = (element.getAttribute('class') || '');
- return classString !== '' && classString !== ' ' ? classString.split(' ') : [];
- }
+ exports.svgHTMLIntegrationPoints = svgHTMLIntegrationPoints;
+ exports.svgNamespace = svgNamespace;
+ exports.buildHTMLDOM = buildHTMLDOM;
- function intersect(containingArray, valuesArray) {
- var containingIndex = 0;
- var containingLength = containingArray.length;
- var valuesIndex = 0;
- var valuesLength = valuesArray.length;
+});
+enifed('dom-helper/classes', ['exports'], function (exports) {
- var intersection = new Array(valuesLength);
+ 'use strict';
- // TODO: rewrite this loop in an optimal manner
- for (;containingIndex<containingLength;containingIndex++) {
- valuesIndex = 0;
- for (;valuesIndex<valuesLength;valuesIndex++) {
- if (valuesArray[valuesIndex] === containingArray[containingIndex]) {
- intersection[valuesIndex] = containingIndex;
- break;
- }
- }
- }
+ var doc = typeof document === 'undefined' ? false : document;
- return intersection;
+ // PhantomJS has a broken classList. See https://github.com/ariya/phantomjs/issues/12782
+ var canClassList = doc && (function () {
+ var d = document.createElement('div');
+ if (!d.classList) {
+ return false;
}
+ d.classList.add('boo');
+ d.classList.add('boo', 'baz');
+ return d.className === 'boo baz';
+ })();
- function addClassesViaAttribute(element, classNames) {
- var existingClasses = buildClassList(element);
+ function buildClassList(element) {
+ var classString = element.getAttribute('class') || '';
+ return classString !== '' && classString !== ' ' ? classString.split(' ') : [];
+ }
- var indexes = intersect(existingClasses, classNames);
- var didChange = false;
+ function intersect(containingArray, valuesArray) {
+ var containingIndex = 0;
+ var containingLength = containingArray.length;
+ var valuesIndex = 0;
+ var valuesLength = valuesArray.length;
- for (var i=0, l=classNames.length; i<l; i++) {
- if (indexes[i] === undefined) {
- didChange = true;
- existingClasses.push(classNames[i]);
+ var intersection = new Array(valuesLength);
+
+ // TODO: rewrite this loop in an optimal manner
+ for (; containingIndex < containingLength; containingIndex++) {
+ valuesIndex = 0;
+ for (; valuesIndex < valuesLength; valuesIndex++) {
+ if (valuesArray[valuesIndex] === containingArray[containingIndex]) {
+ intersection[valuesIndex] = containingIndex;
+ break;
}
}
+ }
- if (didChange) {
- element.setAttribute('class', existingClasses.length > 0 ? existingClasses.join(' ') : '');
+ return intersection;
+ }
+
+ function addClassesViaAttribute(element, classNames) {
+ var existingClasses = buildClassList(element);
+
+ var indexes = intersect(existingClasses, classNames);
+ var didChange = false;
+
+ for (var i = 0, l = classNames.length; i < l; i++) {
+ if (indexes[i] === undefined) {
+ didChange = true;
+ existingClasses.push(classNames[i]);
}
}
- function removeClassesViaAttribute(element, classNames) {
- var existingClasses = buildClassList(element);
+ if (didChange) {
+ element.setAttribute('class', existingClasses.length > 0 ? existingClasses.join(' ') : '');
+ }
+ }
- var indexes = intersect(classNames, existingClasses);
- var didChange = false;
- var newClasses = [];
+ function removeClassesViaAttribute(element, classNames) {
+ var existingClasses = buildClassList(element);
- for (var i=0, l=existingClasses.length; i<l; i++) {
- if (indexes[i] === undefined) {
- newClasses.push(existingClasses[i]);
- } else {
- didChange = true;
- }
- }
+ var indexes = intersect(classNames, existingClasses);
+ var didChange = false;
+ var newClasses = [];
- if (didChange) {
- element.setAttribute('class', newClasses.length > 0 ? newClasses.join(' ') : '');
+ for (var i = 0, l = existingClasses.length; i < l; i++) {
+ if (indexes[i] === undefined) {
+ newClasses.push(existingClasses[i]);
+ } else {
+ didChange = true;
}
}
- var addClasses, removeClasses;
- if (canClassList) {
- addClasses = function addClasses(element, classNames) {
- if (element.classList) {
- if (classNames.length === 1) {
- element.classList.add(classNames[0]);
- } else if (classNames.length === 2) {
- element.classList.add(classNames[0], classNames[1]);
- } else {
- element.classList.add.apply(element.classList, classNames);
- }
+ if (didChange) {
+ element.setAttribute('class', newClasses.length > 0 ? newClasses.join(' ') : '');
+ }
+ }
+
+ var addClasses, removeClasses;
+ if (canClassList) {
+ addClasses = function addClasses(element, classNames) {
+ if (element.classList) {
+ if (classNames.length === 1) {
+ element.classList.add(classNames[0]);
+ } else if (classNames.length === 2) {
+ element.classList.add(classNames[0], classNames[1]);
} else {
- addClassesViaAttribute(element, classNames);
+ element.classList.add.apply(element.classList, classNames);
}
- };
- removeClasses = function removeClasses(element, classNames) {
- if (element.classList) {
- if (classNames.length === 1) {
- element.classList.remove(classNames[0]);
- } else if (classNames.length === 2) {
- element.classList.remove(classNames[0], classNames[1]);
- } else {
- element.classList.remove.apply(element.classList, classNames);
- }
+ } else {
+ addClassesViaAttribute(element, classNames);
+ }
+ };
+ removeClasses = function removeClasses(element, classNames) {
+ if (element.classList) {
+ if (classNames.length === 1) {
+ element.classList.remove(classNames[0]);
+ } else if (classNames.length === 2) {
+ element.classList.remove(classNames[0], classNames[1]);
} else {
- removeClassesViaAttribute(element, classNames);
+ element.classList.remove.apply(element.classList, classNames);
}
- };
- } else {
- addClasses = addClassesViaAttribute;
- removeClasses = removeClassesViaAttribute;
- }
+ } else {
+ removeClassesViaAttribute(element, classNames);
+ }
+ };
+ } else {
+ addClasses = addClassesViaAttribute;
+ removeClasses = removeClassesViaAttribute;
+ }
- __exports__.addClasses = addClasses;
- __exports__.removeClasses = removeClasses;
- });
-enifed("dom-helper/prop",
- ["exports"],
- function(__exports__) {
- "use strict";
- function isAttrRemovalValue(value) {
- return value === null || value === undefined;
- }
+ exports.addClasses = addClasses;
+ exports.removeClasses = removeClasses;
- __exports__.isAttrRemovalValue = isAttrRemovalValue;// TODO should this be an o_create kind of thing?
- var propertyCaches = {};
- __exports__.propertyCaches = propertyCaches;
- function normalizeProperty(element, attrName) {
- var tagName = element.tagName;
- var key;
- var cache = propertyCaches[tagName];
- if (!cache) {
- // TODO should this be an o_create kind of thing?
- cache = {};
- for (key in element) {
- cache[key.toLowerCase()] = key;
- }
- propertyCaches[tagName] = cache;
- }
+});
+enifed('dom-helper/prop', ['exports'], function (exports) {
- // presumes that the attrName has been lowercased.
- return cache[attrName];
+ 'use strict';
+
+ exports.isAttrRemovalValue = isAttrRemovalValue;
+ exports.normalizeProperty = normalizeProperty;
+
+ function isAttrRemovalValue(value) {
+ return value === null || value === undefined;
+ }
+
+ // TODO should this be an o_create kind of thing?
+ var propertyCaches = {};function normalizeProperty(element, attrName) {
+ var tagName = element.tagName;
+ var key;
+ var cache = propertyCaches[tagName];
+ if (!cache) {
+ // TODO should this be an o_create kind of thing?
+ cache = {};
+ for (key in element) {
+ cache[key.toLowerCase()] = key;
+ }
+ propertyCaches[tagName] = cache;
}
- __exports__.normalizeProperty = normalizeProperty;
- });
+ // presumes that the attrName has been lowercased.
+ return cache[attrName];
+ }
+
+ exports.propertyCaches = propertyCaches;
+
+});
enifed('ember-application', ['ember-metal/core', 'ember-runtime/system/lazy_load', 'ember-application/system/resolver', 'ember-application/system/application', 'ember-application/ext/controller'], function (Ember, lazy_load, DefaultResolver, Application) {
'use strict';
Ember['default'].Application = Application['default'];
@@ -3212,44 +3288,44 @@
var missing = [];
for (i = 0, l = needs.length; i < l; i++) {
dependency = needs[i];
- Ember['default'].assert(utils.inspect(controller) + "#needs must not specify dependencies with periods in their names (" + dependency + ")", dependency.indexOf('.') === -1);
+ Ember['default'].assert(utils.inspect(controller) + "#needs must not specify dependencies with periods in their names (" + dependency + ")", dependency.indexOf(".") === -1);
- if (dependency.indexOf(':') === -1) {
+ if (dependency.indexOf(":") === -1) {
dependency = "controller:" + dependency;
}
// Structure assert to still do verification but not string concat in production
if (!container._registry.has(dependency)) {
missing.push(dependency);
}
}
if (missing.length) {
- throw new EmberError['default'](utils.inspect(controller) + " needs [ " + missing.join(', ') + " ] but " + (missing.length > 1 ? 'they' : 'it') + " could not be found");
+ throw new EmberError['default'](utils.inspect(controller) + " needs [ " + missing.join(", ") + " ] but " + (missing.length > 1 ? "they" : "it") + " could not be found");
}
}
var defaultControllersComputedProperty = computed.computed(function () {
var controller = this;
return {
- needs: property_get.get(controller, 'needs'),
- container: property_get.get(controller, 'container'),
+ needs: property_get.get(controller, "needs"),
+ container: property_get.get(controller, "container"),
unknownProperty: function (controllerName) {
var needs = this.needs;
var dependency, i, l;
for (i = 0, l = needs.length; i < l; i++) {
dependency = needs[i];
if (dependency === controllerName) {
- return this.container.lookup('controller:' + controllerName);
+ return this.container.lookup("controller:" + controllerName);
}
}
- var errorMessage = utils.inspect(controller) + '#needs does not include `' + controllerName + '`. To access the ' + controllerName + ' controller from ' + utils.inspect(controller) + ', ' + utils.inspect(controller) + ' should have a `needs` property that is an array of the controllers it has access to.';
+ var errorMessage = utils.inspect(controller) + "#needs does not include `" + controllerName + "`. To access the " + controllerName + " controller from " + utils.inspect(controller) + ", " + utils.inspect(controller) + " should have a `needs` property that is an array of the controllers it has access to.";
throw new ReferenceError(errorMessage);
},
setUnknownProperty: function (key, value) {
throw new Error("You cannot overwrite the value of `controllers." + key + "` of " + utils.inspect(controller));
}
@@ -3259,11 +3335,11 @@
/**
@class ControllerMixin
@namespace Ember
*/
ControllerMixin['default'].reopen({
- concatenatedProperties: ['needs'],
+ concatenatedProperties: ["needs"],
/**
An array of other controller objects available inside
instances of this controller via the `controllers`
property:
@@ -3299,22 +3375,22 @@
@default []
*/
needs: [],
init: function () {
- var needs = property_get.get(this, 'needs');
- var length = property_get.get(needs, 'length');
+ var needs = property_get.get(this, "needs");
+ var length = property_get.get(needs, "length");
if (length > 0) {
- Ember['default'].assert(' `' + utils.inspect(this) + ' specifies `needs`, but does ' + "not have a container. Please ensure this controller was " + "instantiated with a container.", this.container || this.controllers !== defaultControllersComputedProperty);
+ Ember['default'].assert(" `" + utils.inspect(this) + " specifies `needs`, but does " + "not have a container. Please ensure this controller was " + "instantiated with a container.", this.container || this.controllers !== defaultControllersComputedProperty);
if (this.container) {
verifyNeedsDependencies(this, this.container, needs);
}
// if needs then initialize controllers proxy
- property_get.get(this, 'controllers');
+ property_get.get(this, "controllers");
}
this._super.apply(this, arguments);
},
@@ -3323,11 +3399,11 @@
@see {Ember.Route#controllerFor}
@deprecated Use `needs` instead
*/
controllerFor: function (controllerName) {
Ember['default'].deprecate("Controller#controllerFor is deprecated, please use Controller#needs instead");
- return controllerFor['default'](property_get.get(this, 'container'), controllerName);
+ return controllerFor['default'](property_get.get(this, "container"), controllerName);
},
/**
Stores the instances of other controllers available from within
this controller. Any controller listed by name in the `needs`
@@ -3423,15 +3499,15 @@
// Why do we need to register the instance in the first place?
// Because we need a good way for the root route (a.k.a ApplicationRoute)
// to notify us when it has created the root-most view. That view is then
// appended to the rootElement, in the case of apps, to the fixture harness
// in tests, or rendered to a string in the case of FastBoot.
- this.registry.register('-application-instance:main', this, { instantiate: false });
+ this.registry.register("-application-instance:main", this, { instantiate: false });
},
router: computed.computed(function () {
- return this.container.lookup('router:main');
+ return this.container.lookup("router:main");
}).readOnly(),
/**
Instantiates and sets up the router, specifically overriding the default
location. This is useful for manually starting the app in FastBoot or
@@ -3440,14 +3516,14 @@
@param options
@private
*/
overrideRouterLocation: function (options) {
var location = options && options.location;
- var router = property_get.get(this, 'router');
+ var router = property_get.get(this, "router");
if (location) {
- property_set.set(router, 'location', location);
+ property_set.set(router, "location", location);
}
},
/**
This hook is called by the root-most Route (a.k.a. the ApplicationRoute)
@@ -3468,11 +3544,11 @@
current URL of the page to determine the initial URL to start routing to.
To start the app at a specific URL, call `handleURL` instead.
@private
*/
startRouting: function () {
- var router = property_get.get(this, 'router');
+ var router = property_get.get(this, "router");
var isModuleBasedResolver = !!this.registry.resolver.moduleBasedResolver;
router.startRouting(isModuleBasedResolver);
this._didSetupRouter = true;
},
@@ -3487,11 +3563,11 @@
if (this._didSetupRouter) {
return;
}
this._didSetupRouter = true;
- var router = property_get.get(this, 'router');
+ var router = property_get.get(this, "router");
var isModuleBasedResolver = !!this.registry.resolver.moduleBasedResolver;
router.setupRouter(isModuleBasedResolver);
},
/**
@@ -3500,37 +3576,37 @@
have called `setupRouter()` before calling this method.
@param url {String} the URL the router should route to
@private
*/
handleURL: function (url) {
- var router = property_get.get(this, 'router');
+ var router = property_get.get(this, "router");
this.setupRouter();
return router.handleURL(url);
},
/**
@private
*/
setupEventDispatcher: function () {
- var dispatcher = this.container.lookup('event_dispatcher:main');
+ var dispatcher = this.container.lookup("event_dispatcher:main");
dispatcher.setup(this.customEvents, this.rootElement);
return dispatcher;
},
/**
@private
*/
willDestroy: function () {
this._super.apply(this, arguments);
- run['default'](this.container, 'destroy');
+ run['default'](this.container, "destroy");
}
});
});
-enifed('ember-application/system/application', ['exports', 'dag-map', 'container/registry', 'ember-metal', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-runtime/system/lazy_load', 'ember-runtime/system/namespace', 'ember-runtime/mixins/deferred', 'ember-application/system/resolver', 'ember-metal/platform/create', 'ember-metal/run_loop', 'ember-metal/utils', 'ember-runtime/controllers/controller', 'ember-metal/enumerable_utils', 'ember-runtime/controllers/object_controller', 'ember-runtime/controllers/array_controller', 'ember-views/system/renderer', 'dom-helper', 'ember-views/views/select', 'ember-routing-views/views/outlet', 'ember-views/views/view', 'ember-views/views/metamorph_view', 'ember-views/system/event_dispatcher', 'ember-views/system/jquery', 'ember-routing/system/route', 'ember-routing/system/router', 'ember-routing/location/hash_location', 'ember-routing/location/history_location', 'ember-routing/location/auto_location', 'ember-routing/location/none_location', 'ember-routing/system/cache', 'ember-application/system/application-instance', 'ember-extension-support/container_debug_adapter', 'ember-metal/environment'], function (exports, DAG, Registry, Ember, property_get, property_set, lazy_load, Namespace, DeferredMixin, DefaultResolver, create, run, utils, Controller, EnumerableUtils, ObjectController, ArrayController, Renderer, DOMHelper, SelectView, outlet, EmberView, _MetamorphView, EventDispatcher, jQuery, Route, Router, HashLocation, HistoryLocation, AutoLocation, NoneLocation, BucketCache, ApplicationInstance, ContainerDebugAdapter, environment) {
+enifed('ember-application/system/application', ['exports', 'dag-map', 'container/registry', 'ember-metal', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-runtime/system/lazy_load', 'ember-runtime/system/namespace', 'ember-runtime/mixins/deferred', 'ember-application/system/resolver', 'ember-metal/platform/create', 'ember-metal/run_loop', 'ember-metal/utils', 'ember-runtime/controllers/controller', 'ember-metal/enumerable_utils', 'ember-runtime/controllers/object_controller', 'ember-runtime/controllers/array_controller', 'ember-metal-views/renderer', 'ember-htmlbars/system/dom-helper', 'ember-views/views/select', 'ember-routing-views/views/outlet', 'ember-views/views/view', 'ember-views/system/event_dispatcher', 'ember-views/system/jquery', 'ember-routing/system/route', 'ember-routing/system/router', 'ember-routing/location/hash_location', 'ember-routing/location/history_location', 'ember-routing/location/auto_location', 'ember-routing/location/none_location', 'ember-routing/system/cache', 'ember-application/system/application-instance', 'ember-extension-support/container_debug_adapter', 'ember-metal/environment'], function (exports, DAG, Registry, Ember, property_get, property_set, lazy_load, Namespace, DeferredMixin, DefaultResolver, create, run, utils, Controller, EnumerableUtils, ObjectController, ArrayController, Renderer, DOMHelper, SelectView, outlet, EmberView, EventDispatcher, jQuery, Route, Router, HashLocation, HistoryLocation, AutoLocation, NoneLocation, BucketCache, ApplicationInstance, ContainerDebugAdapter, environment) {
'use strict';
/**
@module ember
@@ -3771,12 +3847,11 @@
// decremented by the Application's own `initialize` method.
this._readinessDeferrals = 1;
this.Router = (this.Router || Router['default']).extend();
- this.buildDefaultInstance();
- this.waitForDOMReady();
+ this.waitForDOMReady(this.buildDefaultInstance());
},
/**
Build and configure the registry for the current application.
@@ -3829,17 +3904,17 @@
If you are asynchronously loading code, you should call
`deferReadiness()` to defer booting, and then call
`advanceReadiness()` once all of your code has finished
loading.
@private
- @method waitForDOMReady
+ @method scheduleInitialize
*/
- waitForDOMReady: function () {
+ waitForDOMReady: function (_instance) {
if (!this.$ || this.$.isReady) {
- run['default'].schedule('actions', this, 'domReady');
+ run['default'].schedule('actions', this, 'domReady', _instance);
} else {
- this.$().ready(run['default'].bind(this, 'domReady'));
+ this.$().ready(run['default'].bind(this, 'domReady', _instance));
}
},
/**
Use this to defer readiness until some condition is true.
@@ -3858,12 +3933,12 @@
However, if the setup requires a loading UI, it might be better
to use the router for this purpose.
@method deferReadiness
*/
deferReadiness: function () {
- Ember['default'].assert("You must call deferReadiness on an instance of Ember.Application", this instanceof Application);
- Ember['default'].assert("You cannot defer readiness since the `ready()` hook has already been called.", this._readinessDeferrals > 0);
+ Ember['default'].assert('You must call deferReadiness on an instance of Ember.Application', this instanceof Application);
+ Ember['default'].assert('You cannot defer readiness since the `ready()` hook has already been called.', this._readinessDeferrals > 0);
this._readinessDeferrals++;
},
/**
Call `advanceReadiness` after any asynchronous setup logic has completed.
@@ -3871,11 +3946,11 @@
or the application will never become ready and routing will not begin.
@method advanceReadiness
@see {Ember.Application#deferReadiness}
*/
advanceReadiness: function () {
- Ember['default'].assert("You must call advanceReadiness on an instance of Ember.Application", this instanceof Application);
+ Ember['default'].assert('You must call advanceReadiness on an instance of Ember.Application', this instanceof Application);
this._readinessDeferrals--;
if (this._readinessDeferrals === 0) {
run['default'].once(this, this.didBecomeReady);
}
@@ -3991,19 +4066,23 @@
Initialize the application. This happens automatically.
Run any initializers and run the application load hook. These hooks may
choose to defer readiness. For example, an authentication hook might want
to defer readiness until the auth token has been retrieved.
@private
- @method domReady
+ @method _initialize
*/
- domReady: function () {
+ domReady: function (_instance) {
if (this.isDestroyed) {
return;
}
- this.boot();
+ var app = this;
+ this.boot().then(function () {
+ app.runInstanceInitializers(_instance);
+ });
+
return this;
},
boot: function () {
if (this._bootPromise) {
@@ -4082,11 +4161,13 @@
this._bootResolver = null;
function handleReset() {
run['default'](instance, 'destroy');
- run['default'].schedule('actions', this, 'domReady', this.buildDefaultInstance());
+ this.buildDefaultInstance();
+
+ run['default'].schedule('actions', this, 'domReady');
}
run['default'].join(this, handleReset);
},
@@ -4095,20 +4176,20 @@
@method runInitializers
*/
runInitializers: function (registry) {
var App = this;
this._runInitializer('initializers', function (name, initializer) {
- Ember['default'].assert("No application initializer named '" + name + "'", !!initializer);
+ Ember['default'].assert('No application initializer named \'' + name + '\'', !!initializer);
initializer.initialize(registry, App);
});
},
runInstanceInitializers: function (instance) {
this._runInitializer('instanceInitializers', function (name, initializer) {
- Ember['default'].assert("No instance initializer named '" + name + "'", !!initializer);
+ Ember['default'].assert('No instance initializer named \'' + name + '\'', !!initializer);
initializer.initialize(instance);
});
},
_runInitializer: function (bucketName, cb) {
@@ -4135,11 +4216,10 @@
if (this.autoboot) {
if (environment['default'].hasDOM) {
this.__deprecatedInstance__.setupEventDispatcher();
}
- this.runInstanceInitializers(this.__deprecatedInstance__);
this.ready(); // user hook
this.__deprecatedInstance__.startRouting();
if (!Ember['default'].testing) {
// Eagerly name all classes that are already loaded
@@ -4152,12 +4232,12 @@
this._bootResolver.resolve();
},
/**
- Called when the Application has become ready, immediately before routing
- begins. The call will be delayed until the DOM has become ready.
+ Called when the Application has become ready.
+ The call will be delayed until the DOM has become ready.
@event ready
*/
ready: function () {
return this;
},
@@ -4367,11 +4447,10 @@
return {};
} });
registry.injection('view', '_viewRegistry', '-view-registry:main');
- registry.register('view:default', _MetamorphView['default']);
registry.register('view:toplevel', EmberView['default'].extend());
registry.register('route:basic', Route['default'], { instantiate: false });
registry.register('event_dispatcher:main', EventDispatcher['default']);
@@ -4443,11 +4522,11 @@
resolve.normalize = function (fullName) {
if (resolver.normalize) {
return resolver.normalize(fullName);
} else {
- Ember['default'].deprecate('The Resolver should now provide a \'normalize\' function');
+ Ember['default'].deprecate('The Resolver should now provide a \'normalize\' function', false);
return fullName;
}
};
resolve.__resolver__ = resolver;
@@ -4497,13 +4576,13 @@
var attrs = {};
attrs[bucketName] = create['default'](this[bucketName]);
this.reopenClass(attrs);
}
- Ember['default'].assert("The " + humanName + " '" + initializer.name + "' has already been registered", !this[bucketName][initializer.name]);
- Ember['default'].assert("An " + humanName + " cannot be registered without an initialize function", utils.canInvoke(initializer, 'initialize'));
- Ember['default'].assert("An " + humanName + " cannot be registered without a name property", initializer.name !== undefined);
+ Ember['default'].assert('The ' + humanName + ' \'' + initializer.name + '\' has already been registered', !this[bucketName][initializer.name]);
+ Ember['default'].assert('An ' + humanName + ' cannot be registered without an initialize function', utils.canInvoke(initializer, 'initialize'));
+ Ember['default'].assert('An ' + humanName + ' cannot be registered without a name property', initializer.name !== undefined);
this[bucketName][initializer.name] = initializer;
};
}
@@ -4530,11 +4609,12 @@
resolve: null, // required
parseName: null, // required
lookupDescription: null, // required
makeToString: null, // required
resolveOther: null, // required
- _logLookup: null });exports['default'] = EmberObject['default'].extend({
+ _logLookup: null // required
+ });exports['default'] = EmberObject['default'].extend({
/**
This will be set to the Application instance when it is
created.
@property namespace
*/
@@ -4547,11 +4627,11 @@
var _fullName$split = fullName.split(':', 2);
var type = _fullName$split[0];
var name = _fullName$split[1];
- Ember['default'].assert("Tried to normalize a container name without a colon (:) in it." + " You probably tried to lookup a name that did not contain a type," + " a colon, and a name. A proper lookup name would be `view:post`.", fullName.split(':').length === 2);
+ Ember['default'].assert('Tried to normalize a container name without a colon (:) in it.' + ' You probably tried to lookup a name that did not contain a type,' + ' a colon, and a name. A proper lookup name would be `view:post`.', fullName.split(':').length === 2);
if (type !== 'template') {
var result = name;
if (result.indexOf('.') > -1) {
@@ -4818,20 +4898,54 @@
});
exports.Resolver = Resolver;
});
-enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/utils', 'ember-metal/error', 'ember-metal/logger', 'ember-metal/environment'], function (exports, Ember, utils, EmberError, Logger, environment) {
+enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'ember-metal/logger', 'ember-metal/environment'], function (exports, Ember, EmberError, Logger, environment) {
'use strict';
exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags;
+ /**
+ Will call `Ember.warn()` if ENABLE_ALL_FEATURES, ENABLE_OPTIONAL_FEATURES, or
+ any specific FEATURES flag is truthy.
+
+ This method is called automatically in debug canary builds.
+
+ @private
+ @method _warnIfUsingStrippedFeatureFlags
+ @return {void}
+ */
+ function isPlainFunction(test) {
+ return typeof test === "function" && test.PrototypeMixin === undefined;
+ }
+
+ /**
+ Define an assertion that will throw an exception if the condition is not
+ met. Ember build tools will remove any calls to `Ember.assert()` when
+ doing a production build. Example:
+
+ ```javascript
+ // Test for truthiness
+ Ember.assert('Must pass a valid object', obj);
+
+ // Fail unconditionally
+ Ember.assert('This code path should never be run');
+ ```
+
+ @method assert
+ @param {String} desc A description of the assertion. This will become
+ the text of the Error thrown if the assertion fails.
+ @param {Boolean|Function} test Must be truthy for the assertion to pass. If
+ falsy, an exception will be thrown. If this is a function, it will be executed and
+ its return value will be used as condition.
+ */
Ember['default'].assert = function (desc, test) {
var throwAssertion;
- if (utils.typeOf(test) === 'function') {
+ if (isPlainFunction(test)) {
throwAssertion = !test();
} else {
throwAssertion = !test;
}
@@ -4850,11 +4964,11 @@
will be displayed.
*/
Ember['default'].warn = function (message, test) {
if (!test) {
Logger['default'].warn("WARNING: " + message);
- if ('trace' in Logger['default']) {
+ if ("trace" in Logger['default']) {
Logger['default'].trace();
}
}
};
@@ -4887,11 +5001,11 @@
in a `url` to the transition guide on the emberjs.com website.
*/
Ember['default'].deprecate = function (message, test, options) {
var noDeprecation;
- if (typeof test === 'function') {
+ if (isPlainFunction(test)) {
noDeprecation = test();
} else {
noDeprecation = test;
}
@@ -4911,27 +5025,27 @@
} catch (e) {
error = e;
}
if (arguments.length === 3) {
- Ember['default'].assert('options argument to Ember.deprecate should be an object', options && typeof options === 'object');
+ Ember['default'].assert("options argument to Ember.deprecate should be an object", options && typeof options === "object");
if (options.url) {
- message += ' See ' + options.url + ' for more details.';
+ message += " See " + options.url + " for more details.";
}
}
if (Ember['default'].LOG_STACKTRACE_ON_DEPRECATION && error.stack) {
var stack;
- var stackStr = '';
+ var stackStr = "";
- if (error['arguments']) {
+ if (error["arguments"]) {
// Chrome
- stack = error.stack.replace(/^\s+at\s+/gm, '').replace(/^([^\(]+?)([\n$])/gm, '{anonymous}($1)$2').replace(/^Object.<anonymous>\s*\(([^\)]+)\)/gm, '{anonymous}($1)').split('\n');
+ stack = error.stack.replace(/^\s+at\s+/gm, "").replace(/^([^\(]+?)([\n$])/gm, "{anonymous}($1)$2").replace(/^Object.<anonymous>\s*\(([^\)]+)\)/gm, "{anonymous}($1)").split("\n");
stack.shift();
} else {
// Firefox
- stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').replace(/^\(/gm, '{anonymous}(').split('\n');
+ stack = error.stack.replace(/(?:\n@:0)?\s+$/m, "").replace(/^\(/gm, "{anonymous}(").split("\n");
}
stackStr = "\n " + stack.slice(2).join("\n ");
message = message + stackStr;
}
@@ -4983,60 +5097,48 @@
@since 1.5.0
*/
Ember['default'].runInDebug = function (func) {
func();
};
-
- /**
- Will call `Ember.warn()` if ENABLE_ALL_FEATURES, ENABLE_OPTIONAL_FEATURES, or
- any specific FEATURES flag is truthy.
-
- This method is called automatically in debug canary builds.
-
- @private
- @method _warnIfUsingStrippedFeatureFlags
- @return {void}
- */
-
function _warnIfUsingStrippedFeatureFlags(FEATURES, featuresWereStripped) {
if (featuresWereStripped) {
- Ember['default'].warn('Ember.ENV.ENABLE_ALL_FEATURES is only available in canary builds.', !Ember['default'].ENV.ENABLE_ALL_FEATURES);
- Ember['default'].warn('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.', !Ember['default'].ENV.ENABLE_OPTIONAL_FEATURES);
+ Ember['default'].warn("Ember.ENV.ENABLE_ALL_FEATURES is only available in canary builds.", !Ember['default'].ENV.ENABLE_ALL_FEATURES);
+ Ember['default'].warn("Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.", !Ember['default'].ENV.ENABLE_OPTIONAL_FEATURES);
for (var key in FEATURES) {
- if (FEATURES.hasOwnProperty(key) && key !== 'isEnabled') {
- Ember['default'].warn('FEATURE["' + key + '"] is set as enabled, but FEATURE flags are only available in canary builds.', !FEATURES[key]);
+ if (FEATURES.hasOwnProperty(key) && key !== "isEnabled") {
+ Ember['default'].warn("FEATURE[\"" + key + "\"] is set as enabled, but FEATURE flags are only available in canary builds.", !FEATURES[key]);
}
}
}
}
if (!Ember['default'].testing) {
// Complain if they're using FEATURE flags in builds other than canary
- Ember['default'].FEATURES['features-stripped-test'] = true;
+ Ember['default'].FEATURES["features-stripped-test"] = true;
var featuresWereStripped = true;
- delete Ember['default'].FEATURES['features-stripped-test'];
+ delete Ember['default'].FEATURES["features-stripped-test"];
_warnIfUsingStrippedFeatureFlags(Ember['default'].ENV.FEATURES, featuresWereStripped);
// Inform the developer about the Ember Inspector if not installed.
- var isFirefox = typeof InstallTrigger !== 'undefined';
+ var isFirefox = environment['default'].isFirefox;
var isChrome = environment['default'].isChrome;
- if (typeof window !== 'undefined' && (isFirefox || isChrome) && window.addEventListener) {
+ if (typeof window !== "undefined" && (isFirefox || isChrome) && window.addEventListener) {
window.addEventListener("load", function () {
if (document.documentElement && document.documentElement.dataset && !document.documentElement.dataset.emberExtension) {
var downloadURL;
if (isChrome) {
- downloadURL = 'https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi';
+ downloadURL = "https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi";
} else if (isFirefox) {
- downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/';
+ downloadURL = "https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/";
}
- Ember['default'].debug('For more advanced debugging, install the Ember Inspector from ' + downloadURL);
+ Ember['default'].debug("For more advanced debugging, install the Ember Inspector from " + downloadURL);
}
}, false);
}
}
@@ -5048,11 +5150,11 @@
so that if `ember.js` (which must be output for backwards compat reasons) is
used a nice helpful warning message will be printed out.
*/
var runningNonEmberDebugJS = true;
if (runningNonEmberDebugJS) {
- Ember['default'].warn('Please use `ember.debug.js` instead of `ember.js` for development and debugging.');
+ Ember['default'].warn("Please use `ember.debug.js` instead of `ember.js` for development and debugging.");
}
exports.runningNonEmberDebugJS = runningNonEmberDebugJS;
});
@@ -5070,11 +5172,11 @@
Ember['default'].DataAdapter = DataAdapter['default'];
Ember['default'].ContainerDebugAdapter = ContainerDebugAdapter['default'];
});
-enifed('ember-extension-support/container_debug_adapter', ['exports', 'ember-metal/core', 'ember-runtime/system/native_array', 'ember-metal/utils', 'ember-runtime/system/string', 'ember-runtime/system/namespace', 'ember-runtime/system/object'], function (exports, Ember, native_array, utils, string, Namespace, EmberObject) {
+enifed('ember-extension-support/container_debug_adapter', ['exports', 'ember-metal/core', 'ember-runtime/system/native_array', 'ember-runtime/utils', 'ember-runtime/system/string', 'ember-runtime/system/namespace', 'ember-runtime/system/object'], function (exports, Ember, native_array, utils, string, Namespace, EmberObject) {
'use strict';
exports['default'] = EmberObject['default'].extend({
/**
@@ -5101,11 +5203,11 @@
@method canCatalogEntriesByType
@param {String} type The type. e.g. "model", "controller", "route"
@return {boolean} whether a list is available for this type.
*/
canCatalogEntriesByType: function (type) {
- if (type === 'model' || type === 'template') {
+ if (type === "model" || type === "template") {
return false;
}
return true;
},
@@ -5117,22 +5219,22 @@
@return {Array} An array of strings.
*/
catalogEntriesByType: function (type) {
var namespaces = native_array.A(Namespace['default'].NAMESPACES);
var types = native_array.A();
- var typeSuffixRegex = new RegExp(string.classify(type) + "$");
+ var typeSuffixRegex = new RegExp("" + string.classify(type) + "$");
namespaces.forEach(function (namespace) {
if (namespace !== Ember['default']) {
for (var key in namespace) {
if (!namespace.hasOwnProperty(key)) {
continue;
}
if (typeSuffixRegex.test(key)) {
var klass = namespace[key];
- if (utils.typeOf(klass) === 'class') {
- types.push(string.dasherize(key.replace(typeSuffixRegex, '')));
+ if (utils.typeOf(klass) === "class") {
+ types.push(string.dasherize(key.replace(typeSuffixRegex, "")));
}
}
}
}
});
@@ -5212,37 +5314,38 @@
@param {Function} typesUpdated Callback to call when a type has changed.
Takes an array of objects containing wrapped types.
@return {Function} Method to call to remove all observers
*/
watchModelTypes: function (typesAdded, typesUpdated) {
+ var _this = this;
+
var modelTypes = this.getModelTypes();
- var self = this;
var releaseMethods = native_array.A();
var typesToSend;
typesToSend = modelTypes.map(function (type) {
var klass = type.klass;
- var wrapped = self.wrapModelType(klass, type.name);
- releaseMethods.push(self.observeModelType(klass, typesUpdated));
+ var wrapped = _this.wrapModelType(klass, type.name);
+ releaseMethods.push(_this.observeModelType(klass, typesUpdated));
return wrapped;
});
typesAdded(typesToSend);
var release = function () {
releaseMethods.forEach(function (fn) {
- fn();
+ return fn();
});
- self.releaseMethods.removeObject(release);
+ _this.releaseMethods.removeObject(release);
};
this.releaseMethods.pushObject(release);
return release;
},
_nameToClass: function (type) {
- if (typeof type === 'string') {
- type = this.container.lookupFactory('model:' + type);
+ if (typeof type === "string") {
+ type = this.container.lookupFactory("model:" + type);
}
return type;
},
/**
@@ -5261,29 +5364,30 @@
index: the array index where the records were removed
count: the number of records removed
@return {Function} Method to call to remove all observers
*/
watchRecords: function (type, recordsAdded, recordsUpdated, recordsRemoved) {
- var self = this;
+ var _this2 = this;
+
var releaseMethods = native_array.A();
var records = this.getRecords(type);
var release;
var recordUpdated = function (updatedRecord) {
recordsUpdated([updatedRecord]);
};
var recordsToSend = records.map(function (record) {
- releaseMethods.push(self.observeRecord(record, recordUpdated));
- return self.wrapRecord(record);
+ releaseMethods.push(_this2.observeRecord(record, recordUpdated));
+ return _this2.wrapRecord(record);
});
var contentDidChange = function (array, idx, removedCount, addedCount) {
for (var i = idx; i < idx + addedCount; i++) {
var record = array.objectAt(i);
- var wrapped = self.wrapRecord(record);
- releaseMethods.push(self.observeRecord(record, recordUpdated));
+ var wrapped = _this2.wrapRecord(record);
+ releaseMethods.push(_this2.observeRecord(record, recordUpdated));
recordsAdded([wrapped]);
}
if (removedCount) {
recordsRemoved(idx, removedCount);
@@ -5291,18 +5395,18 @@
};
var observer = { didChange: contentDidChange, willChange: function () {
return this;
} };
- records.addArrayObserver(self, observer);
+ records.addArrayObserver(this, observer);
release = function () {
releaseMethods.forEach(function (fn) {
fn();
});
- records.removeArrayObserver(self, observer);
- self.releaseMethods.removeObject(release);
+ records.removeArrayObserver(_this2, observer);
+ _this2.releaseMethods.removeObject(release);
};
recordsAdded(recordsToSend);
this.releaseMethods.pushObject(release);
@@ -5355,29 +5459,30 @@
@param {Function} typesUpdated Called when a type is modified.
@return {Function} The function to call to remove observers
*/
observeModelType: function (type, typesUpdated) {
- var self = this;
+ var _this3 = this;
+
var records = this.getRecords(type);
var onChange = function () {
- typesUpdated([self.wrapModelType(type)]);
+ typesUpdated([_this3.wrapModelType(type)]);
};
var observer = {
didChange: function () {
- run['default'].scheduleOnce('actions', this, onChange);
+ run['default'].scheduleOnce("actions", this, onChange);
},
willChange: function () {
return this;
}
};
records.addArrayObserver(this, observer);
var release = function () {
- records.removeArrayObserver(self, observer);
+ records.removeArrayObserver(_this3, observer);
};
return release;
},
@@ -5401,11 +5506,11 @@
var records = this.getRecords(type);
var typeToSend;
typeToSend = {
name: name || type.toString(),
- count: property_get.get(records, 'length'),
+ count: property_get.get(records, "length"),
columns: this.columnsForType(type),
object: type
};
return typeToSend;
@@ -5416,29 +5521,30 @@
@private
@method getModelTypes
@return {Array} Array of model types
*/
getModelTypes: function () {
- var self = this;
- var containerDebugAdapter = this.get('containerDebugAdapter');
+ var _this4 = this;
+
+ var containerDebugAdapter = this.get("containerDebugAdapter");
var types;
- if (containerDebugAdapter.canCatalogEntriesByType('model')) {
- types = containerDebugAdapter.catalogEntriesByType('model');
+ if (containerDebugAdapter.canCatalogEntriesByType("model")) {
+ types = containerDebugAdapter.catalogEntriesByType("model");
} else {
types = this._getObjectsOnNamespaces();
}
// New adapters return strings instead of classes
types = native_array.A(types).map(function (name) {
return {
- klass: self._nameToClass(name),
+ klass: _this4._nameToClass(name),
name: name
};
});
types = native_array.A(types).filter(function (type) {
- return self.detect(type.klass);
+ return _this4.detect(type.klass);
});
return native_array.A(types);
},
@@ -5448,28 +5554,29 @@
@private
@method _getObjectsOnNamespaces
@return {Array} Array of model type strings
*/
_getObjectsOnNamespaces: function () {
+ var _this5 = this;
+
var namespaces = native_array.A(Namespace['default'].NAMESPACES);
var types = native_array.A();
- var self = this;
namespaces.forEach(function (namespace) {
for (var key in namespace) {
if (!namespace.hasOwnProperty(key)) {
continue;
}
// Even though we will filter again in `getModelTypes`,
// we should not call `lookupContainer` on non-models
// (especially when `Ember.MODEL_FACTORY_INJECTIONS` is `true`)
- if (!self.detect(namespace[key])) {
+ if (!_this5.detect(namespace[key])) {
continue;
}
var name = string.dasherize(key);
if (!(namespace instanceof Application['default']) && namespace.toString()) {
- name = namespace + '/' + name;
+ name = "" + namespace + "/" + name;
}
types.push(name);
}
});
return types;
@@ -5564,43 +5671,35 @@
return function () {};
}
});
});
-enifed('ember-htmlbars', ['ember-metal/core', 'ember-template-compiler', 'ember-htmlbars/system/make-view-helper', 'ember-htmlbars/system/make_bound_helper', 'ember-htmlbars/helpers', 'ember-htmlbars/helpers/view', 'ember-htmlbars/helpers/component', 'ember-htmlbars/helpers/yield', 'ember-htmlbars/helpers/with', 'ember-htmlbars/helpers/log', 'ember-htmlbars/helpers/debugger', 'ember-htmlbars/helpers/bind-attr', 'ember-htmlbars/helpers/if_unless', 'ember-htmlbars/helpers/loc', 'ember-htmlbars/helpers/partial', 'ember-htmlbars/helpers/template', 'ember-htmlbars/helpers/input', 'ember-htmlbars/helpers/text_area', 'ember-htmlbars/helpers/collection', 'ember-htmlbars/helpers/each', 'ember-htmlbars/helpers/unbound', 'ember-htmlbars/system/bootstrap', 'ember-htmlbars/compat'], function (Ember, ember_template_compiler, makeViewHelper, makeBoundHelper, helpers, view, component, _yield, _with, log, _debugger, bind_attr, if_unless, loc, partial, template, input, text_area, collection, each, unbound) {
+enifed('ember-htmlbars', ['ember-metal/core', 'ember-template-compiler', 'ember-htmlbars/system/make-view-helper', 'ember-htmlbars/system/make_bound_helper', 'ember-htmlbars/helpers', 'ember-htmlbars/helpers/if_unless', 'ember-htmlbars/helpers/with', 'ember-htmlbars/helpers/loc', 'ember-htmlbars/helpers/log', 'ember-htmlbars/helpers/each', 'ember-htmlbars/helpers/-bind-attr-class', 'ember-htmlbars/helpers/-normalize-class', 'ember-htmlbars/helpers/-concat', 'ember-htmlbars/helpers/-join-classes', 'ember-htmlbars/helpers/-legacy-each-with-controller', 'ember-htmlbars/system/dom-helper', 'ember-htmlbars/system/bootstrap', 'ember-htmlbars/compat'], function (Ember, ember_template_compiler, makeViewHelper, makeBoundHelper, helpers, if_unless, withHelper, locHelper, logHelper, eachHelper, bindAttrClassHelper, normalizeClassHelper, concatHelper, joinClassesHelper, legacyEachWithControllerHelper, DOMHelper) {
'use strict';
- helpers.registerHelper('view', view.viewHelper);
-
- helpers.registerHelper('component', component.componentHelper);
-
- helpers.registerHelper('yield', _yield.yieldHelper);
- helpers.registerHelper('with', _with.withHelper);
- helpers.registerHelper('if', if_unless.ifHelper);
- helpers.registerHelper('unless', if_unless.unlessHelper);
- helpers.registerHelper('log', log.logHelper);
- helpers.registerHelper('debugger', _debugger.debuggerHelper);
- helpers.registerHelper('loc', loc.locHelper);
- helpers.registerHelper('partial', partial.partialHelper);
- helpers.registerHelper('template', template.templateHelper);
- helpers.registerHelper('bind-attr', bind_attr.bindAttrHelper);
- helpers.registerHelper('bindAttr', bind_attr.bindAttrHelperDeprecated);
- helpers.registerHelper('input', input.inputHelper);
- helpers.registerHelper('textarea', text_area.textareaHelper);
- helpers.registerHelper('collection', collection.collectionHelper);
- helpers.registerHelper('each', each.eachHelper);
- helpers.registerHelper('unbound', unbound.unboundHelper);
+ helpers.registerHelper("if", if_unless.ifHelper);
+ helpers.registerHelper("unless", if_unless.unlessHelper);
+ helpers.registerHelper("with", withHelper['default']);
+ helpers.registerHelper("loc", locHelper['default']);
+ helpers.registerHelper("log", logHelper['default']);
+ helpers.registerHelper("each", eachHelper['default']);
+ helpers.registerHelper("-bind-attr-class", bindAttrClassHelper['default']);
+ helpers.registerHelper("-normalize-class", normalizeClassHelper['default']);
+ helpers.registerHelper("-concat", concatHelper['default']);
+ helpers.registerHelper("-join-classes", joinClassesHelper['default']);
+ helpers.registerHelper("-legacy-each-with-controller", legacyEachWithControllerHelper['default']);
Ember['default'].HTMLBars = {
_registerHelper: helpers.registerHelper,
template: ember_template_compiler.template,
compile: ember_template_compiler.compile,
precompile: ember_template_compiler.precompile,
makeViewHelper: makeViewHelper['default'],
makeBoundHelper: makeBoundHelper['default'],
- registerPlugin: ember_template_compiler.registerPlugin
+ registerPlugin: ember_template_compiler.registerPlugin,
+ DOMHelper: DOMHelper['default']
};
});
enifed('ember-htmlbars/compat', ['exports', 'ember-metal/core', 'ember-htmlbars/helpers', 'ember-htmlbars/compat/helper', 'ember-htmlbars/compat/handlebars-get', 'ember-htmlbars/compat/make-bound-helper', 'ember-htmlbars/compat/register-bound-helper', 'ember-htmlbars/system/make-view-helper', 'ember-htmlbars/utils/string'], function (exports, Ember, helpers, helper, compatHandlebarsGet, compatMakeBoundHelper, compatRegisterBoundHelper, makeViewHelper, string) {
@@ -5625,12 +5724,10 @@
});
enifed('ember-htmlbars/compat/handlebars-get', ['exports'], function (exports) {
'use strict';
-
- exports['default'] = handlebarsGet;
/**
@module ember
@submodule ember-htmlbars
*/
@@ -5644,109 +5741,135 @@
@param {Object} root The object to look up the property on
@param {String} path The path to be lookedup
@param {Object} options The template's option hash
@deprecated
*/
+ exports['default'] = handlebarsGet;
+
function handlebarsGet(root, path, options) {
Ember.deprecate('Usage of Ember.Handlebars.get is deprecated, use a Component or Ember.Handlebars.makeBoundHelper instead.');
- return options.data.view.getStream(path).value();
+ return options.legacyGetPath(path);
}
});
-enifed('ember-htmlbars/compat/helper', ['exports', 'ember-metal/merge', 'ember-htmlbars/helpers', 'ember-views/views/view', 'ember-views/views/component', 'ember-htmlbars/system/make-view-helper', 'ember-htmlbars/compat/make-bound-helper', 'ember-metal/streams/utils'], function (exports, merge, helpers, View, Component, makeViewHelper, makeBoundHelper, utils) {
+enifed('ember-htmlbars/compat/helper', ['exports', 'ember-htmlbars/helpers', 'ember-views/views/view', 'ember-views/views/component', 'ember-htmlbars/system/make-view-helper', 'ember-htmlbars/compat/make-bound-helper', 'ember-metal/streams/utils', 'ember-htmlbars/keywords'], function (exports, helpers, View, Component, makeViewHelper, makeBoundHelper, utils, keywords) {
'use strict';
exports.registerHandlebarsCompatibleHelper = registerHandlebarsCompatibleHelper;
exports.handlebarsHelper = handlebarsHelper;
var slice = [].slice;
function calculateCompatType(item) {
if (utils.isStream(item)) {
- return 'ID';
+ return "ID";
} else {
var itemType = typeof item;
return itemType.toUpperCase();
}
}
+ function pathFor(param) {
+ if (utils.isStream(param)) {
+ // param arguments to helpers may have their path prefixes with self. For
+ // example {{box-thing foo}} may have a param path of `self.foo` depending
+ // on scope.
+ if (param.source && param.source.dependee && param.source.dependee.label === "self") {
+ return param.path.slice(5);
+ } else {
+ return param.path;
+ }
+ } else {
+ return param;
+ }
+ }
+
/**
Wraps an Handlebars helper with an HTMLBars helper for backwards compatibility.
@class HandlebarsCompatibleHelper
@constructor
@private
*/
function HandlebarsCompatibleHelper(fn) {
- this.helperFunction = function helperFunc(params, hash, options, env) {
- var param, blockResult, fnResult;
- var context = env.data.view;
+ this.helperFunction = function helperFunc(params, hash, options, env, scope) {
+ var param, fnResult;
+ var hasBlock = options.template && options.template.yield;
+
var handlebarsOptions = {
hash: {},
types: new Array(params.length),
hashTypes: {}
};
- merge['default'](handlebarsOptions, options);
- merge['default'](handlebarsOptions, env);
-
handlebarsOptions.hash = {};
- if (options.isBlock) {
+ if (hasBlock) {
handlebarsOptions.fn = function () {
- blockResult = options.template.render(context, env, options.morph.contextualElement);
+ options.template.yield();
};
- if (options.inverse) {
+ if (options.inverse.yield) {
handlebarsOptions.inverse = function () {
- blockResult = options.inverse.render(context, env, options.morph.contextualElement);
+ options.inverse.yield();
};
}
}
for (var prop in hash) {
param = hash[prop];
-
handlebarsOptions.hashTypes[prop] = calculateCompatType(param);
-
- if (utils.isStream(param)) {
- handlebarsOptions.hash[prop] = param._label;
- } else {
- handlebarsOptions.hash[prop] = param;
- }
+ handlebarsOptions.hash[prop] = pathFor(param);
}
var args = new Array(params.length);
for (var i = 0, l = params.length; i < l; i++) {
param = params[i];
-
handlebarsOptions.types[i] = calculateCompatType(param);
-
- if (utils.isStream(param)) {
- args[i] = param._label;
- } else {
- args[i] = param;
- }
+ args[i] = pathFor(param);
}
+
+ handlebarsOptions.legacyGetPath = function (path) {
+ return env.hooks.get(env, scope, path).value();
+ };
+
+ handlebarsOptions.data = {
+ view: env.view
+ };
+
args.push(handlebarsOptions);
fnResult = fn.apply(this, args);
- return options.isBlock ? blockResult : fnResult;
+ if (options.element) {
+ Ember.deprecate("Returning a string of attributes from a helper inside an element is deprecated.");
+ applyAttributes(env.dom, options.element, fnResult);
+ } else if (!options.template.yield) {
+ return fnResult;
+ }
};
this.isHTMLBars = true;
}
HandlebarsCompatibleHelper.prototype = {
preprocessArguments: function () {}
};
-
function registerHandlebarsCompatibleHelper(name, value) {
+ if (value && value.isLegacyViewHelper) {
+ keywords.registerKeyword(name, function (morph, env, scope, params, hash, template, inverse, visitor) {
+ Ember.assert("You can only pass attributes (such as name=value) not bare " + "values to a helper for a View found in '" + value.viewClass + "'", params.length === 0);
+
+ env.hooks.keyword("view", morph, env, scope, [value.viewClass], hash, template, inverse, visitor);
+ return true;
+ });
+ return;
+ }
+
var helper;
if (value && value.isHTMLBars) {
helper = value;
} else {
@@ -5767,124 +5890,104 @@
helpers['default'][name] = boundFn;
}
}
+ function applyAttributes(dom, element, innerString) {
+ var string = "<" + element.tagName + " " + innerString + "></div>";
+ var fragment = dom.parseHTML(string, dom.createElement(element.tagName));
+
+ var attrs = fragment.firstChild.attributes;
+
+ for (var i = 0, l = attrs.length; i < l; i++) {
+ element.setAttributeNode(attrs[i].cloneNode());
+ }
+ }
+
exports['default'] = HandlebarsCompatibleHelper;
});
-enifed('ember-htmlbars/compat/make-bound-helper', ['exports', 'ember-metal/core', 'ember-metal/mixin', 'ember-htmlbars/system/helper', 'ember-metal/streams/stream', 'ember-metal/streams/utils'], function (exports, Ember, mixin, Helper, Stream, utils) {
+enifed('ember-htmlbars/compat/make-bound-helper', ['exports', 'ember-metal/streams/utils'], function (exports, utils) {
'use strict';
- exports['default'] = makeBoundHelper;
+
/**
@module ember
@submodule ember-htmlbars
*/
- function makeBoundHelper(fn, compatMode) {
- var dependentKeys = [];
- for (var i = 1; i < arguments.length; i++) {
- dependentKeys.push(arguments[i]);
+ //import Helper from "ember-htmlbars/system/helper";
+
+ /**
+ A helper function used by `registerBoundHelper`. Takes the
+ provided Handlebars helper function fn and returns it in wrapped
+ bound helper form.
+
+ The main use case for using this outside of `registerBoundHelper`
+ is for registering helpers on the container:
+
+ ```js
+ var boundHelperFn = Ember.Handlebars.makeBoundHelper(function(word) {
+ return word.toUpperCase();
+ });
+
+ container.register('helper:my-bound-helper', boundHelperFn);
+ ```
+
+ In the above example, if the helper function hadn't been wrapped in
+ `makeBoundHelper`, the registered helper would be unbound.
+
+ @method makeBoundHelper
+ @for Ember.Handlebars
+ @param {Function} function
+ @param {String} dependentKeys*
+ @since 1.2.0
+ @deprecated
+ */
+ exports['default'] = makeBoundHelper;
+ function makeBoundHelper(fn) {
+ for (var _len = arguments.length, dependentKeys = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
+ dependentKeys[_key - 1] = arguments[_key];
}
- function helperFunc(params, hash, options, env) {
- var view = env.data.view;
- var numParams = params.length;
- var param;
+ return {
+ _dependentKeys: dependentKeys,
- Ember['default'].assert("registerBoundHelper-generated helpers do not support use with Handlebars blocks.", !options.template);
+ isHandlebarsCompat: true,
+ isHTMLBars: true,
- for (var prop in hash) {
- if (mixin.IS_BINDING.test(prop)) {
- hash[prop.slice(0, -7)] = view.getStream(hash[prop]);
- delete hash[prop];
- }
- }
+ helperFunction: function (params, hash, templates) {
+ Ember.assert("registerBoundHelper-generated helpers do not support use with Handlebars blocks.", !templates.template.yield);
- function valueFn() {
var args = utils.readArray(params);
var properties = new Array(params.length);
+
for (var i = 0, l = params.length; i < l; i++) {
- param = params[i];
+ var param = params[i];
if (utils.isStream(param)) {
- properties[i] = param._label;
+ properties[i] = param.label;
} else {
properties[i] = param;
}
}
- args.push({
- hash: utils.readHash(hash),
- data: { properties: properties }
- });
- return fn.apply(view, args);
+ args.push({ hash: utils.readHash(hash), templates: templates, data: { properties: properties } });
+ return fn.apply(undefined, args);
}
-
- // If none of the hash parameters are bound, act as an unbound helper.
- // This prevents views from being unnecessarily created
- var hasStream = utils.scanArray(params) || utils.scanHash(hash);
- if (hasStream) {
- var lazyValue = new Stream['default'](valueFn);
-
- for (i = 0; i < numParams; i++) {
- param = params[i];
- if (utils.isStream(param)) {
- param.subscribe(lazyValue.notify, lazyValue);
- }
- }
-
- for (prop in hash) {
- param = hash[prop];
- if (utils.isStream(param)) {
- param.subscribe(lazyValue.notify, lazyValue);
- }
- }
-
- if (numParams > 0) {
- var firstParam = params[0];
- // Only bother with subscriptions if the first argument
- // is a stream itself, and not a primitive.
- if (utils.isStream(firstParam)) {
- var onDependentKeyNotify = function onDependentKeyNotify(stream) {
- stream.value();
- lazyValue.notify();
- };
- for (i = 0; i < dependentKeys.length; i++) {
- var childParam = firstParam.get(dependentKeys[i]);
- childParam.value();
- childParam.subscribe(onDependentKeyNotify);
- }
- }
- }
-
- return lazyValue;
- } else {
- return valueFn();
- }
- }
-
- return new Helper['default'](helperFunc);
+ };
}
});
enifed('ember-htmlbars/compat/register-bound-helper', ['exports', 'ember-htmlbars/helpers', 'ember-htmlbars/compat/make-bound-helper'], function (exports, helpers, makeBoundHelper) {
'use strict';
- exports['default'] = registerBoundHelper;
- /**
- @module ember
- @submodule ember-htmlbars
- */
- var slice = [].slice;
-
/**
Register a bound handlebars helper. Bound helpers behave similarly to regular
handlebars helpers, with the added ability to re-render when the underlying data
changes.
@@ -5990,981 +6093,2979 @@
@for Ember.Handlebars
@param {String} name
@param {Function} function
@param {String} dependentKeys*
*/
+ exports['default'] = registerBoundHelper;
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
+
+ var slice = [].slice;
function registerBoundHelper(name, fn) {
var boundHelperArgs = slice.call(arguments, 1);
var boundFn = makeBoundHelper['default'].apply(this, boundHelperArgs);
helpers['default'][name] = boundFn;
}
});
-enifed('ember-htmlbars/env', ['exports', 'ember-metal/environment', 'dom-helper', 'ember-htmlbars/hooks/inline', 'ember-htmlbars/hooks/content', 'ember-htmlbars/hooks/component', 'ember-htmlbars/hooks/block', 'ember-htmlbars/hooks/element', 'ember-htmlbars/hooks/subexpr', 'ember-htmlbars/hooks/attribute', 'ember-htmlbars/hooks/concat', 'ember-htmlbars/hooks/get', 'ember-htmlbars/hooks/set', 'ember-htmlbars/helpers'], function (exports, environment, DOMHelper, inline, content, component, block, element, subexpr, attribute, concat, get, set, helpers) {
+enifed('ember-htmlbars/env', ['exports', 'ember-metal/environment', 'htmlbars-runtime', 'ember-metal/merge', 'ember-htmlbars/hooks/subexpr', 'ember-htmlbars/hooks/concat', 'ember-htmlbars/hooks/link-render-node', 'ember-htmlbars/hooks/create-fresh-scope', 'ember-htmlbars/hooks/bind-shadow-scope', 'ember-htmlbars/hooks/bind-self', 'ember-htmlbars/hooks/bind-scope', 'ember-htmlbars/hooks/bind-local', 'ember-htmlbars/hooks/update-self', 'ember-htmlbars/hooks/get-root', 'ember-htmlbars/hooks/get-child', 'ember-htmlbars/hooks/get-value', 'ember-htmlbars/hooks/get-cell-or-value', 'ember-htmlbars/hooks/cleanup-render-node', 'ember-htmlbars/hooks/destroy-render-node', 'ember-htmlbars/hooks/did-render-node', 'ember-htmlbars/hooks/will-cleanup-tree', 'ember-htmlbars/hooks/did-cleanup-tree', 'ember-htmlbars/hooks/classify', 'ember-htmlbars/hooks/component', 'ember-htmlbars/hooks/lookup-helper', 'ember-htmlbars/hooks/has-helper', 'ember-htmlbars/hooks/invoke-helper', 'ember-htmlbars/hooks/element', 'ember-htmlbars/helpers', 'ember-htmlbars/keywords', 'ember-htmlbars/system/dom-helper', 'ember-htmlbars/keywords/debugger', 'ember-htmlbars/keywords/with', 'ember-htmlbars/keywords/outlet', 'ember-htmlbars/keywords/real_outlet', 'ember-htmlbars/keywords/customized_outlet', 'ember-htmlbars/keywords/unbound', 'ember-htmlbars/keywords/view', 'ember-htmlbars/keywords/component', 'ember-htmlbars/keywords/partial', 'ember-htmlbars/keywords/input', 'ember-htmlbars/keywords/textarea', 'ember-htmlbars/keywords/collection', 'ember-htmlbars/keywords/template', 'ember-htmlbars/keywords/legacy-yield', 'ember-htmlbars/keywords/mut', 'ember-htmlbars/keywords/each', 'ember-htmlbars/keywords/readonly'], function (exports, environment, htmlbars_runtime, merge, subexpr, concat, linkRenderNode, createFreshScope, bindShadowScope, bindSelf, bindScope, bindLocal, updateSelf, getRoot, getChild, getValue, getCellOrValue, cleanupRenderNode, destroyRenderNode, didRenderNode, willCleanupTree, didCleanupTree, classify, component, lookupHelper, hasHelper, invokeHelper, element, helpers, keywords, DOMHelper, debuggerKeyword, withKeyword, outlet, realOutlet, customizedOutlet, unbound, view, componentKeyword, partial, input, textarea, collection, templateKeyword, legacyYield, mut, each, readonly) {
'use strict';
- exports['default'] = {
- hooks: {
- get: get['default'],
- set: set['default'],
- inline: inline['default'],
- content: content['default'],
- block: block['default'],
- element: element['default'],
- subexpr: subexpr['default'],
- component: component['default'],
- attribute: attribute['default'],
- concat: concat['default']
- },
+ var emberHooks = merge['default']({}, htmlbars_runtime.hooks);
+ emberHooks.keywords = keywords['default'];
- helpers: helpers['default'],
+ merge['default'](emberHooks, {
+ linkRenderNode: linkRenderNode['default'],
+ createFreshScope: createFreshScope['default'],
+ bindShadowScope: bindShadowScope['default'],
+ bindSelf: bindSelf['default'],
+ bindScope: bindScope['default'],
+ bindLocal: bindLocal['default'],
+ updateSelf: updateSelf['default'],
+ getRoot: getRoot['default'],
+ getChild: getChild['default'],
+ getValue: getValue['default'],
+ getCellOrValue: getCellOrValue['default'],
+ subexpr: subexpr['default'],
+ concat: concat['default'],
+ cleanupRenderNode: cleanupRenderNode['default'],
+ destroyRenderNode: destroyRenderNode['default'],
+ willCleanupTree: willCleanupTree['default'],
+ didCleanupTree: didCleanupTree['default'],
+ didRenderNode: didRenderNode['default'],
+ classify: classify['default'],
+ component: component['default'],
+ lookupHelper: lookupHelper['default'],
+ hasHelper: hasHelper['default'],
+ invokeHelper: invokeHelper['default'],
+ element: element['default']
+ });keywords.registerKeyword("debugger", debuggerKeyword['default']);
+ keywords.registerKeyword("with", withKeyword['default']);
+ keywords.registerKeyword("outlet", outlet['default']);
+ keywords.registerKeyword("@real_outlet", realOutlet['default']);
+ keywords.registerKeyword("@customized_outlet", customizedOutlet['default']);
+ keywords.registerKeyword("unbound", unbound['default']);
+ keywords.registerKeyword("view", view['default']);
+ keywords.registerKeyword("component", componentKeyword['default']);
+ keywords.registerKeyword("partial", partial['default']);
+ keywords.registerKeyword("template", templateKeyword['default']);
+ keywords.registerKeyword("input", input['default']);
+ keywords.registerKeyword("textarea", textarea['default']);
+ keywords.registerKeyword("collection", collection['default']);
+ keywords.registerKeyword("legacy-yield", legacyYield['default']);
+ keywords.registerKeyword("mut", mut['default']);
+ keywords.registerKeyword("@mut", mut.privateMut);
+ keywords.registerKeyword("each", each['default']);
+ keywords.registerKeyword("readonly", readonly['default']);
+ exports['default'] = {
+ hooks: emberHooks,
+ helpers: helpers['default'],
useFragmentCache: true
};
var domHelper = environment['default'].hasDOM ? new DOMHelper['default']() : null;
exports.domHelper = domHelper;
});
-enifed('ember-htmlbars/helpers', ['exports', 'ember-metal/platform/create', 'ember-htmlbars/system/helper'], function (exports, o_create, Helper) {
+enifed('ember-htmlbars/helpers', ['exports', 'ember-metal/platform/create'], function (exports, o_create) {
'use strict';
exports.registerHelper = registerHelper;
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
+
+ /**
+ @private
+ @method _registerHelper
+ @for Ember.HTMLBars
+ @param {String} name
+ @param {Object|Function} helperFunc the helper function to add
+ */
var helpers = o_create['default'](null);
function registerHelper(name, helperFunc) {
- var helper;
-
- if (helperFunc && helperFunc.isHelper) {
- helper = helperFunc;
- } else {
- helper = new Helper['default'](helperFunc);
- }
-
- helpers[name] = helper;
+ helpers[name] = helperFunc;
}
exports['default'] = helpers;
});
-enifed('ember-htmlbars/helpers/bind-attr', ['exports', 'ember-metal/core', 'ember-runtime/system/string', 'ember-views/attr_nodes/attr_node', 'ember-views/attr_nodes/legacy_bind', 'ember-metal/keys', 'ember-htmlbars/helpers', 'ember-metal/enumerable_utils', 'ember-metal/streams/utils', 'ember-views/streams/class_name_binding'], function (exports, Ember, string, AttrNode, LegacyBindAttrNode, keys, helpers, enumerable_utils, utils, class_name_binding) {
+enifed('ember-htmlbars/helpers/-bind-attr-class', ['exports', 'ember-metal/property_get', 'ember-metal/utils'], function (exports, property_get, utils) {
'use strict';
- exports.bindAttrHelper = bindAttrHelper;
- exports.bindAttrHelperDeprecated = bindAttrHelperDeprecated;
+
+ exports['default'] = bindAttrClassHelper;
/**
@module ember
@submodule ember-htmlbars
*/
- function bindAttrHelper(params, hash, options, env) {
- var element = options.element;
+ function bindAttrClassHelper(params) {
+ var value = params[0];
- Ember['default'].assert("You must specify at least one hash argument to bind-attr", !!keys['default'](hash).length);
+ if (utils.isArray(value)) {
+ value = property_get.get(value, 'length') !== 0;
+ }
- var view = env.data.view;
+ if (value === true) {
+ return params[1];
+ }if (value === false || value === undefined || value === null) {
+ return '';
+ } else {
+ return value;
+ }
+ }
- // Handle classes differently, as we can bind multiple classes
- var classNameBindings = hash['class'];
- if (classNameBindings !== null && classNameBindings !== undefined) {
- if (!utils.isStream(classNameBindings)) {
- classNameBindings = applyClassNameBindings(classNameBindings, view);
+});
+enifed('ember-htmlbars/helpers/-concat', ['exports'], function (exports) {
+
+ 'use strict';
+
+ /** @private
+ This private helper is used by the legacy class bindings AST transformer
+ to concatenate class names together.
+ */
+ exports['default'] = concat;
+
+ function concat(params, hash) {
+ return params.join(hash.separator);
+ }
+
+});
+enifed('ember-htmlbars/helpers/-join-classes', ['exports'], function (exports) {
+
+ 'use strict';
+
+ /** @private
+ this private helper is used to join and compact a list of class names
+ */
+
+ exports['default'] = joinClasses;
+
+ function joinClasses(classNames) {
+ var result = [];
+
+ for (var i = 0, l = classNames.length; i < l; i++) {
+ var className = classNames[i];
+ if (className) {
+ result.push(className);
}
+ }
- var classView = new AttrNode['default']('class', classNameBindings);
- classView._morph = env.dom.createAttrMorph(element, 'class');
+ return result.join(' ');
+ }
- Ember['default'].assert('You cannot set `class` manually and via `{{bind-attr}}` helper on the same element. ' + 'Please use `{{bind-attr}}`\'s `:static-class` syntax instead.', !element.getAttribute('class'));
+});
+enifed('ember-htmlbars/helpers/-legacy-each-with-controller', ['exports', 'ember-metal/property_get', 'ember-metal/enumerable_utils', 'ember-htmlbars/utils/normalize-self'], function (exports, property_get, enumerable_utils, normalizeSelf) {
- view.appendChild(classView);
+ 'use strict';
+
+ exports['default'] = legacyEachWithControllerHelper;
+
+ function legacyEachWithControllerHelper(params, hash, blocks) {
+ var list = params[0];
+ var keyPath = hash.key;
+
+ // TODO: Correct falsy semantics
+ if (!list || property_get.get(list, "length") === 0) {
+ if (blocks.inverse.yield) {
+ blocks.inverse.yield();
+ }
+ return;
}
- var attrKeys = keys['default'](hash);
+ enumerable_utils.forEach(list, function (item, i) {
+ var self;
- var attr, path, lazyValue, attrView;
- for (var i = 0, l = attrKeys.length; i < l; i++) {
- attr = attrKeys[i];
- if (attr === 'class') {
- continue;
+ if (blocks.template.arity === 0) {
+ Ember.deprecate(deprecation);
+ self = normalizeSelf['default'](item);
+ self = bindController(self, true);
}
- path = hash[attr];
- if (utils.isStream(path)) {
- lazyValue = path;
+
+ var key = keyPath ? property_get.get(item, keyPath) : String(i);
+ blocks.template.yieldItem(key, [item, i], self);
+ });
+ }
+
+ function bindController(controller, isSelf) {
+ return {
+ controller: controller,
+ hasBoundController: true,
+ self: controller ? controller : undefined
+ };
+ }
+
+ var deprecation = "Using the context switching form of {{each}} is deprecated. Please use the keyword form (`{{#each items as |item|}}`) instead.";
+
+ exports.deprecation = deprecation;
+
+});
+enifed('ember-htmlbars/helpers/-normalize-class', ['exports', 'ember-runtime/system/string', 'ember-metal/path_cache'], function (exports, string, path_cache) {
+
+ 'use strict';
+
+
+
+ /** @private
+ This private helper is used by ComponentNode to convert the classNameBindings
+ microsyntax into a class name.
+
+ When a component or view is created, we normalize class name bindings into a
+ series of attribute nodes that use this helper.
+ */
+ exports['default'] = normalizeClass;
+ function normalizeClass(params, hash) {
+ var propName = params[0];
+ var value = params[1];
+ var activeClass = hash.activeClass;
+ var inactiveClass = hash.inactiveClass;
+
+ // When using the colon syntax, evaluate the truthiness or falsiness
+ // of the value to determine which className to return
+ if (activeClass || inactiveClass) {
+ if (!!value) {
+ return activeClass;
} else {
- Ember['default'].assert(string.fmt("You must provide an expression as the value of bound attribute." + " You specified: %@=%@", [attr, path]), typeof path === 'string');
- lazyValue = view.getStream(path);
+ return inactiveClass;
}
- attrView = new LegacyBindAttrNode['default'](attr, lazyValue);
- attrView._morph = env.dom.createAttrMorph(element, attr);
+ // If value is a Boolean and true, return the dasherized property
+ // name.
+ } else if (value === true) {
+ // Only apply to last segment in the path
+ if (propName && path_cache.isPath(propName)) {
+ var segments = propName.split(".");
+ propName = segments[segments.length - 1];
+ }
- Ember['default'].assert('You cannot set `' + attr + '` manually and via `{{bind-attr}}` helper on the same element.', !element.getAttribute(attr));
+ return string.dasherize(propName);
- view.appendChild(attrView);
+ // If the value is not false, undefined, or null, return the current
+ // value of the property.
+ } else if (value !== false && value != null) {
+ return value;
+
+ // Nothing to display. Return null so that the old class is removed
+ // but no new class is added.
+ } else {
+ return null;
}
}
- function applyClassNameBindings(classNameBindings, view) {
- var arrayOfClassNameBindings = classNameBindings.split(' ');
- var boundClassNameBindings = enumerable_utils.map(arrayOfClassNameBindings, function (classNameBinding) {
- return class_name_binding.streamifyClassNameBinding(view, classNameBinding);
- });
- var concatenatedClassNames = utils.concat(boundClassNameBindings, ' ');
- return concatenatedClassNames;
- }
+});
+enifed('ember-htmlbars/helpers/bind-attr', function () {
+ 'use strict';
+
/**
+ @module ember
+ @submodule ember-htmlbars
+ */
+
+ /**
+ `bind-attr` allows you to create a binding between DOM element attributes and
+ Ember objects. For example:
+
+ ```handlebars
+ <img {{bind-attr src=imageUrl alt=imageTitle}}>
+ ```
+
+ The above handlebars template will fill the `<img>`'s `src` attribute with
+ the value of the property referenced with `imageUrl` and its `alt`
+ attribute with the value of the property referenced with `imageTitle`.
+
+ If the rendering context of this template is the following object:
+
+ ```javascript
+ {
+ imageUrl: 'http://lolcats.info/haz-a-funny',
+ imageTitle: 'A humorous image of a cat'
+ }
+ ```
+
+ The resulting HTML output will be:
+
+ ```html
+ <img src="http://lolcats.info/haz-a-funny" alt="A humorous image of a cat">
+ ```
+
+ `bind-attr` cannot redeclare existing DOM element attributes. The use of `src`
+ in the following `bind-attr` example will be ignored and the hard coded value
+ of `src="/failwhale.gif"` will take precedence:
+
+ ```handlebars
+ <img src="/failwhale.gif" {{bind-attr src=imageUrl alt=imageTitle}}>
+ ```
+
+ ### `bind-attr` and the `class` attribute
+
+ `bind-attr` supports a special syntax for handling a number of cases unique
+ to the `class` DOM element attribute. The `class` attribute combines
+ multiple discrete values into a single attribute as a space-delimited
+ list of strings. Each string can be:
+
+ * a string return value of an object's property.
+ * a boolean return value of an object's property
+ * a hard-coded value
+
+ A string return value works identically to other uses of `bind-attr`. The
+ return value of the property will become the value of the attribute. For
+ example, the following view and template:
+
+ ```javascript
+ AView = View.extend({
+ someProperty: function() {
+ return "aValue";
+ }.property()
+ })
+ ```
+
+ ```handlebars
+ <img {{bind-attr class=view.someProperty}}>
+ ```
+
+ Result in the following rendered output:
+
+ ```html
+ <img class="aValue">
+ ```
+
+ A boolean return value will insert a specified class name if the property
+ returns `true` and remove the class name if the property returns `false`.
+
+ A class name is provided via the syntax
+ `somePropertyName:class-name-if-true`.
+
+ ```javascript
+ AView = View.extend({
+ someBool: true
+ })
+ ```
+
+ ```handlebars
+ <img {{bind-attr class="view.someBool:class-name-if-true"}}>
+ ```
+
+ Result in the following rendered output:
+
+ ```html
+ <img class="class-name-if-true">
+ ```
+
+ An additional section of the binding can be provided if you want to
+ replace the existing class instead of removing it when the boolean
+ value changes:
+
+ ```handlebars
+ <img {{bind-attr class="view.someBool:class-name-if-true:class-name-if-false"}}>
+ ```
+
+ A hard-coded value can be used by prepending `:` to the desired
+ class name: `:class-name-to-always-apply`.
+
+ ```handlebars
+ <img {{bind-attr class=":class-name-to-always-apply"}}>
+ ```
+
+ Results in the following rendered output:
+
+ ```html
+ <img class="class-name-to-always-apply">
+ ```
+
+ All three strategies - string return value, boolean return value, and
+ hard-coded value – can be combined in a single declaration:
+
+ ```handlebars
+ <img {{bind-attr class=":class-name-to-always-apply view.someBool:class-name-if-true view.someProperty"}}>
+ ```
+
+ @method bind-attr
+ @for Ember.Handlebars.helpers
+ @deprecated
+ @param {Hash} options
+ @return {String} HTML string
+ */
+
+ /**
See `bind-attr`
@method bindAttr
@for Ember.Handlebars.helpers
@deprecated
@param {Function} context
@param {Hash} options
@return {String} HTML string
*/
- function bindAttrHelperDeprecated() {
- Ember['default'].deprecate("The 'bindAttr' view helper is deprecated in favor of 'bind-attr'");
- return helpers['default']['bind-attr'].helperFunction.apply(this, arguments);
+});
+enifed('ember-htmlbars/helpers/each', ['exports', 'ember-metal/property_get', 'ember-metal/enumerable_utils', 'ember-htmlbars/utils/normalize-self', 'ember-views/streams/should_display'], function (exports, property_get, enumerable_utils, normalizeSelf, shouldDisplay) {
+
+ 'use strict';
+
+ exports['default'] = eachHelper;
+
+ function eachHelper(params, hash, blocks) {
+ var list = params[0];
+ var keyPath = hash.key;
+
+ if (shouldDisplay['default'](list)) {
+ enumerable_utils.forEach(list, function (item, i) {
+ var self;
+ if (blocks.template.arity === 0) {
+ Ember.deprecate(deprecation);
+ self = normalizeSelf['default'](item);
+ }
+
+ var key = keyPath ? property_get.get(item, keyPath) : String(i);
+ blocks.template.yieldItem(key, [item, i], self);
+ });
+ } else if (blocks.inverse.yield) {
+ blocks.inverse.yield();
+ }
}
- exports['default'] = bindAttrHelper;
+ var deprecation = "Using the context switching form of {{each}} is deprecated. Please use the keyword form (`{{#each items as |item|}}`) instead.";
+ exports.deprecation = deprecation;
+
});
-enifed('ember-htmlbars/helpers/collection', ['exports', 'ember-metal/core', 'ember-metal/mixin', 'ember-runtime/system/string', 'ember-metal/property_get', 'ember-views/views/collection_view', 'ember-views/streams/utils', 'ember-metal/enumerable_utils', 'ember-views/streams/class_name_binding', 'ember-htmlbars/system/merge-view-bindings'], function (exports, Ember, mixin, string, property_get, CollectionView, utils, enumerable_utils, class_name_binding, mergeViewBindings) {
+enifed('ember-htmlbars/helpers/if_unless', ['exports', 'ember-metal/core', 'ember-views/streams/should_display'], function (exports, Ember, shouldDisplay) {
'use strict';
- exports.collectionHelper = collectionHelper;
+ exports.ifHelper = ifHelper;
+ exports.unlessHelper = unlessHelper;
- function collectionHelper(params, hash, options, env) {
- var path = params[0];
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
- Ember['default'].deprecate("Using the {{collection}} helper without specifying a class has been" + " deprecated as the {{each}} helper now supports the same functionality.", path !== 'collection');
+ function ifHelper(params, hash, options) {
+ return ifUnless(params, hash, options, shouldDisplay['default'](params[0]));
+ }
- Ember['default'].assert("You cannot pass more than one argument to the collection helper", params.length <= 1);
+ /**
+ @method unless
+ @for Ember.Handlebars.helpers
+ */
+ function unlessHelper(params, hash, options) {
+ return ifUnless(params, hash, options, !shouldDisplay['default'](params[0]));
+ }
- var data = env.data;
- var template = options.template;
- var inverse = options.inverse;
- var view = data.view;
+ function ifUnless(params, hash, options, truthy) {
+ Ember['default'].assert("The block form of the `if` and `unless` helpers expect exactly one " + "argument, e.g. `{{#if newMessages}} You have new messages. {{/if}}.`", !options.template.yield || params.length === 1);
- // This should be deterministic, and should probably come from a
- // parent view and not the controller.
- var controller = property_get.get(view, 'controller');
- var container = controller && controller.container ? controller.container : view.container;
+ Ember['default'].assert("The inline form of the `if` and `unless` helpers expect two or " + "three arguments, e.g. `{{if trialExpired 'Expired' expiryDate}}` " + "or `{{unless isFirstLogin 'Welcome back!'}}`.", !!options.template.yield || params.length === 2 || params.length === 3);
- // If passed a path string, convert that into an object.
- // Otherwise, just default to the standard class.
- var collectionClass;
- if (path) {
- collectionClass = utils.readViewFactory(path, container);
- Ember['default'].assert(string.fmt("%@ #collection: Could not find collection class %@", [data.view, path]), !!collectionClass);
+ if (truthy) {
+ if (options.template.yield) {
+ options.template.yield();
+ } else {
+ return params[1];
+ }
} else {
- collectionClass = CollectionView['default'];
+ if (options.inverse.yield) {
+ options.inverse.yield();
+ } else {
+ return params[2];
+ }
}
+ }
- var itemHash = {};
- var match;
+});
+enifed('ember-htmlbars/helpers/loc', ['exports', 'ember-runtime/system/string'], function (exports, string) {
- // Extract item view class if provided else default to the standard class
- var collectionPrototype = collectionClass.proto();
- var itemViewClass;
+ 'use strict';
- if (hash.itemView) {
- itemViewClass = utils.readViewFactory(hash.itemView, container);
- } else if (hash.itemViewClass) {
- itemViewClass = utils.readViewFactory(hash.itemViewClass, container);
- } else {
- itemViewClass = collectionPrototype.itemViewClass;
- }
- if (typeof itemViewClass === 'string') {
- itemViewClass = container.lookupFactory('view:' + itemViewClass);
- }
- Ember['default'].assert(string.fmt("%@ #collection: Could not find itemViewClass %@", [data.view, itemViewClass]), !!itemViewClass);
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
- delete hash.itemViewClass;
- delete hash.itemView;
+ /**
+ Calls [Ember.String.loc](/api/classes/Ember.String.html#method_loc) with the
+ provided string.
+ This is a convenient way to localize text within a template:
+ ```javascript
+ Ember.STRINGS = {
+ '_welcome_': 'Bonjour'
+ };
+ ```
+ ```handlebars
+ <div class='message'>
+ {{loc '_welcome_'}}
+ </div>
+ ```
+ ```html
+ <div class='message'>
+ Bonjour
+ </div>
+ ```
+ See [Ember.String.loc](/api/classes/Ember.String.html#method_loc) for how to
+ set up localized string references.
+ @method loc
+ @for Ember.Handlebars.helpers
+ @param {String} str The string to format
+ @see {Ember.String#loc}
+ */
+ exports['default'] = locHelper;
+ function locHelper(params) {
+ return string.loc.apply(null, params);
+ }
- // Go through options passed to the {{collection}} helper and extract options
- // that configure item views instead of the collection itself.
- for (var prop in hash) {
- if (prop === 'itemController' || prop === 'itemClassBinding') {
- continue;
+});
+enifed('ember-htmlbars/helpers/log', ['exports', 'ember-metal/logger'], function (exports, Logger) {
+
+ 'use strict';
+
+
+
+ /**
+ `log` allows you to output the value of variables in the current rendering
+ context. `log` also accepts primitive types such as strings or numbers.
+ ```handlebars
+ {{log "myVariable:" myVariable }}
+ ```
+ @method log
+ @for Ember.Handlebars.helpers
+ @param {String} property
+ */
+ exports['default'] = logHelper;
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
+
+ function logHelper(values) {
+ Logger['default'].log.apply(null, values);
+ }
+
+});
+enifed('ember-htmlbars/helpers/with', ['exports', 'ember-htmlbars/utils/normalize-self', 'ember-views/streams/should_display'], function (exports, normalizeSelf, shouldDisplay) {
+
+ 'use strict';
+
+
+
+ /**
+ Use the `{{with}}` helper when you want to alias a property to a new name. This is helpful
+ for semantic clarity as it allows you to retain default scope or to reference a property from another
+ `{{with}}` block.
+ If the aliased property is "falsey", for example: `false`, `undefined` `null`, `""`, `0` or
+ an empty array, the block will not be rendered.
+ ```handlebars
+ // will only render if user.posts contains items
+ {{#with user.posts as |blogPosts|}}
+ <div class="notice">
+ There are {{blogPosts.length}} blog posts written by {{user.name}}.
+ </div>
+ {{#each post in blogPosts}}
+ <li>{{post.title}}</li>
+ {{/each}}
+ {{/with}}
+ ```
+ Without the `as` operator, it would be impossible to reference `user.name` in the example above.
+ NOTE: The alias should not reuse a name from the bound property path.
+ For example: `{{#with foo.bar as foo}}` is not supported because it attempts to alias using
+ the first part of the property path, `foo`. Instead, use `{{#with foo.bar as baz}}`.
+ ### `controller` option
+ Adding `controller='something'` instructs the `{{with}}` helper to create and use an instance of
+ the specified controller wrapping the aliased keyword.
+ This is very similar to using an `itemController` option with the `{{each}}` helper.
+ ```handlebars
+ {{#with users.posts controller='userBlogPosts' as |posts|}}
+ {{!- `posts` is wrapped in our controller instance }}
+ {{/with}}
+ ```
+ In the above example, the `posts` keyword is now wrapped in the `userBlogPost` controller,
+ which provides an elegant way to decorate the context with custom
+ functions/properties.
+ @method with
+ @for Ember.Handlebars.helpers
+ @param {Function} context
+ @param {Hash} options
+ @return {String} HTML string
+ */
+
+ exports['default'] = withHelper;
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
+
+ function withHelper(params, hash, options) {
+ if (shouldDisplay['default'](params[0])) {
+ var preserveContext = false;
+
+ if (options.template.arity !== 0) {
+ preserveContext = true;
}
- if (hash.hasOwnProperty(prop)) {
- match = prop.match(/^item(.)(.*)$/);
- if (match) {
- var childProp = match[1].toLowerCase() + match[2];
- if (mixin.IS_BINDING.test(prop)) {
- itemHash[childProp] = view._getBindingForStream(hash[prop]);
- } else {
- itemHash[childProp] = hash[prop];
- }
- delete hash[prop];
+ if (preserveContext) {
+ this.yield([params[0]]);
+ } else {
+ var _self = normalizeSelf['default'](params[0]);
+ if (hash.controller) {
+ _self = {
+ hasBoundController: true,
+ controller: hash.controller,
+ self: _self
+ };
}
+
+ this.yield([], _self);
}
+ } else if (options.inverse && options.inverse.yield) {
+ options.inverse.yield([]);
}
+ }
- if (template) {
- itemHash.template = template;
- delete options.template;
- }
+});
+enifed('ember-htmlbars/hooks/bind-local', ['exports', 'ember-metal/streams/stream', 'ember-metal/streams/proxy-stream'], function (exports, Stream, ProxyStream) {
- var emptyViewClass;
- if (inverse) {
- emptyViewClass = property_get.get(collectionPrototype, 'emptyViewClass');
- emptyViewClass = emptyViewClass.extend({
- template: inverse,
- tagName: itemHash.tagName
- });
- } else if (hash.emptyViewClass) {
- emptyViewClass = utils.readViewFactory(hash.emptyViewClass, container);
- }
- if (emptyViewClass) {
- hash.emptyView = emptyViewClass;
- }
+ 'use strict';
- var viewOptions = mergeViewBindings['default'](view, {}, itemHash);
- if (hash.itemClassBinding) {
- var itemClassBindings = hash.itemClassBinding.split(' ');
- viewOptions.classNameBindings = enumerable_utils.map(itemClassBindings, function (classBinding) {
- return class_name_binding.streamifyClassNameBinding(view, classBinding);
- });
- }
- hash.itemViewClass = itemViewClass;
- hash._itemViewProps = viewOptions;
+ exports['default'] = bindLocal;
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
- options.helperName = options.helperName || 'collection';
+ function bindLocal(env, scope, key, value) {
+ var isExisting = scope.locals.hasOwnProperty(key);
- return env.helpers.view.helperFunction.call(this, [collectionClass], hash, options, env);
+ if (isExisting) {
+ var existing = scope.locals[key];
+
+ if (existing !== value) {
+ existing.setSource(value);
+ }
+
+ existing.notify();
+ } else {
+ var newValue = Stream['default'].wrap(value, ProxyStream['default'], key);
+ scope.locals[key] = newValue;
+ }
}
});
-enifed('ember-htmlbars/helpers/component', ['exports', 'ember-metal/core', 'ember-metal/streams/utils', 'ember-views/streams/utils', 'ember-metal/error', 'ember-views/views/bound_component_view', 'ember-htmlbars/system/merge-view-bindings', 'ember-htmlbars/system/append-templated-view'], function (exports, Ember, utils, streams__utils, EmberError, BoundComponentView, mergeViewBindings, appendTemplatedView) {
+enifed('ember-htmlbars/hooks/bind-scope', ['exports'], function (exports) {
+ 'use strict';
+
+ exports['default'] = bindScope;
+
+ function bindScope(env, scope) {}
+
+});
+enifed('ember-htmlbars/hooks/bind-self', ['exports', 'ember-metal/streams/proxy-stream', 'ember-htmlbars/utils/subscribe'], function (exports, ProxyStream, subscribe) {
+
'use strict';
- exports.componentHelper = componentHelper;
- function componentHelper(params, hash, options, env) {
- Ember['default'].assert("The `component` helper expects exactly one argument, plus name/property values.", params.length === 1);
- var view = env.data.view;
- var componentNameParam = params[0];
- var container = view.container || utils.read(view._keywords.view).container;
+ exports['default'] = bindSelf;
- var props = {
- helperName: options.helperName || 'component'
- };
- if (options.template) {
- props.template = options.template;
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
+
+ function bindSelf(env, scope, _self) {
+ var self = _self;
+
+ if (self && self.hasBoundController) {
+ var controller = self.controller;
+
+ self = self.self;
+
+ newStream(scope.locals, "controller", controller || self);
}
- var viewClass;
- if (utils.isStream(componentNameParam)) {
- viewClass = BoundComponentView['default'];
- props = { _boundComponentOptions: Ember['default'].merge(hash, props) };
- props._boundComponentOptions.componentNameStream = componentNameParam;
- } else {
- viewClass = streams__utils.readComponentFactory(componentNameParam, container);
- if (!viewClass) {
- throw new EmberError['default']('HTMLBars error: Could not find component named "' + componentNameParam + '".');
- }
- mergeViewBindings['default'](view, props, hash);
+ if (self && self.isView) {
+ scope.view = self;
+ newStream(scope.locals, "view", self, null);
+ newStream(scope.locals, "controller", scope.locals.view.getKey("controller"));
+ newStream(scope, "self", scope.locals.view.getKey("context"), null, true);
+ return;
}
- appendTemplatedView['default'](view, options.morph, viewClass, props);
+ newStream(scope, "self", self, null, true);
+
+ if (!scope.locals.controller) {
+ scope.locals.controller = scope.self;
+ }
}
+ function newStream(scope, key, newValue, renderNode, isSelf) {
+ var stream = new ProxyStream['default'](newValue, isSelf ? "" : key);
+ if (renderNode) {
+ subscribe['default'](renderNode, scope, stream);
+ }
+ scope[key] = stream;
+ }
+
});
-enifed('ember-htmlbars/helpers/debugger', ['exports', 'ember-metal/logger'], function (exports, Logger) {
+enifed('ember-htmlbars/hooks/bind-shadow-scope', ['exports', 'ember-views/views/component', 'ember-metal/streams/proxy-stream', 'ember-htmlbars/utils/subscribe'], function (exports, Component, ProxyStream, subscribe) {
'use strict';
- exports.debuggerHelper = debuggerHelper;
- function debuggerHelper(params, hash, options, env) {
- /* jshint unused: false */
- var view = env.data.view;
+ exports['default'] = bindShadowScope;
- /* jshint unused: false */
- var context = view.get('context');
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
- /* jshint unused: false */
- function get(path) {
- return view.getStream(path).value();
+ function bindShadowScope(env, parentScope, shadowScope, options) {
+ if (!options) {
+ return;
}
- Logger['default'].info('Use `view`, `context`, and `get(<path>)` to debug this template.');
+ var didOverrideController = false;
- debugger;
+ if (parentScope && parentScope.overrideController) {
+ didOverrideController = true;
+ shadowScope.locals.controller = parentScope.locals.controller;
+ }
+
+ var view = options.view;
+ if (view && !(view instanceof Component['default'])) {
+ newStream(shadowScope.locals, 'view', view, null);
+
+ if (!didOverrideController) {
+ newStream(shadowScope.locals, 'controller', shadowScope.locals.view.getKey('controller'));
+ }
+
+ if (view.isView) {
+ newStream(shadowScope, 'self', shadowScope.locals.view.getKey('context'), null, true);
+ }
+ }
+
+ shadowScope.view = view;
+
+ if (view && options.attrs) {
+ shadowScope.component = view;
+ }
+
+ if ('attrs' in options) {
+ shadowScope.attrs = options.attrs;
+ }
+
+ return shadowScope;
}
+ function newStream(scope, key, newValue, renderNode, isSelf) {
+ var stream = new ProxyStream['default'](newValue, isSelf ? '' : key);
+ if (renderNode) {
+ subscribe['default'](renderNode, scope, stream);
+ }
+ scope[key] = stream;
+ }
+
});
-enifed('ember-htmlbars/helpers/each', ['exports', 'ember-metal/core', 'ember-views/views/each'], function (exports, Ember, EachView) {
+enifed('ember-htmlbars/hooks/classify', ['exports', 'ember-htmlbars/utils/is-component'], function (exports, isComponent) {
'use strict';
- exports.eachHelper = eachHelper;
+
+ exports['default'] = classify;
/**
@module ember
@submodule ember-htmlbars
*/
- function eachHelper(params, hash, options, env) {
- var view = env.data.view;
- var helperName = 'each';
- var path = params[0] || view.getStream('');
- Ember['default'].assert("If you pass more than one argument to the each helper, " + "it must be in the form {{#each foo in bar}}", params.length <= 1);
+ function classify(env, scope, path) {
+ if (isComponent['default'](env, scope, path)) {
+ return "component";
+ }
- var blockParams = options.template && options.template.blockParams;
+ return null;
+ }
- if (blockParams) {
- hash.keyword = true;
- hash.blockParams = blockParams;
- }
+});
+enifed('ember-htmlbars/hooks/cleanup-render-node', ['exports'], function (exports) {
- Ember['default'].deprecate("Using the context switching form of {{each}} is deprecated. " + "Please use the block param form (`{{#each bar as |foo|}}`) instead.", hash.keyword === true || typeof hash.keyword === 'string', { url: 'http://emberjs.com/guides/deprecations/#toc_more-consistent-handlebars-scope' });
+ 'use strict';
- hash.dataSource = path;
- options.helperName = options.helperName || helperName;
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
- return env.helpers.collection.helperFunction.call(this, [EachView['default']], hash, options, env);
+ exports['default'] = cleanupRenderNode;
+
+ function cleanupRenderNode(renderNode) {
+ if (renderNode.cleanup) {
+ renderNode.cleanup();
+ }
}
- exports.EachView = EachView['default'];
+});
+enifed('ember-htmlbars/hooks/component', ['exports', 'ember-htmlbars/node-managers/component-node-manager'], function (exports, ComponentNodeManager) {
+ 'use strict';
+
+
+
+ exports['default'] = componentHook;
+ function componentHook(renderNode, env, scope, _tagName, params, attrs, templates, visitor) {
+ var state = renderNode.state;
+
+ // Determine if this is an initial render or a re-render
+ if (state.manager) {
+ state.manager.rerender(env, attrs, visitor);
+ return;
+ }
+
+ var tagName = _tagName;
+ var isAngleBracket = false;
+
+ if (tagName.charAt(0) === "<") {
+ tagName = tagName.slice(1, -1);
+ isAngleBracket = true;
+ }
+
+ var read = env.hooks.getValue;
+ var parentView = read(env.view);
+
+ var manager = ComponentNodeManager['default'].create(renderNode, env, {
+ tagName: tagName,
+ params: params,
+ attrs: attrs,
+ parentView: parentView,
+ templates: templates,
+ isAngleBracket: isAngleBracket,
+ parentScope: scope
+ });
+
+ state.manager = manager;
+
+ manager.render(env, visitor);
+ }
+
});
-enifed('ember-htmlbars/helpers/if_unless', ['exports', 'ember-metal/core', 'ember-metal/streams/conditional', 'ember-views/streams/should_display', 'ember-metal/property_get', 'ember-metal/streams/utils', 'ember-views/views/bound_if_view', 'ember-htmlbars/templates/empty'], function (exports, Ember, conditional, shouldDisplay, property_get, utils, BoundIfView, emptyTemplate) {
+enifed('ember-htmlbars/hooks/concat', ['exports', 'ember-metal/streams/utils'], function (exports, utils) {
'use strict';
- exports.ifHelper = ifHelper;
- exports.unlessHelper = unlessHelper;
+
+ exports['default'] = concat;
/**
@module ember
@submodule ember-htmlbars
*/
- function ifHelper(params, hash, options, env) {
- var helperName = options.helperName || 'if';
- return appendConditional(false, helperName, params, hash, options, env);
+ function concat(env, parts) {
+ return utils.concat(parts, "");
}
+});
+enifed('ember-htmlbars/hooks/create-fresh-scope', ['exports'], function (exports) {
+
+ 'use strict';
+
+ exports['default'] = createFreshScope;
+
+ function createFreshScope() {
+ return {
+ self: null,
+ blocks: {},
+ component: null,
+ view: null,
+ attrs: null,
+ locals: {},
+ localPresent: {}
+ };
+ }
+
+});
+enifed('ember-htmlbars/hooks/destroy-render-node', ['exports'], function (exports) {
+
+ 'use strict';
+
/**
- @method unless
- @for Ember.Handlebars.helpers
+ @module ember
+ @submodule ember-htmlbars
*/
- function unlessHelper(params, hash, options, env) {
- var helperName = options.helperName || 'unless';
- return appendConditional(true, helperName, params, hash, options, env);
- }
- function assertInlineIfNotEnabled() {
- Ember['default'].assert("To use the inline forms of the `if` and `unless` helpers you must " + "enable the `ember-htmlbars-inline-if-helper` feature flag.");
- }
+ exports['default'] = destroyRenderNode;
- function appendConditional(inverted, helperName, params, hash, options, env) {
- var view = env.data.view;
+ function destroyRenderNode(renderNode) {
+ if (renderNode.emberView) {
+ renderNode.emberView.destroy();
+ }
- if (options.isBlock) {
- return appendBlockConditional(view, inverted, helperName, params, hash, options, env);
- } else {
-
- return appendInlineConditional(view, inverted, helperName, params, hash, options, env);
- }
+ var streamUnsubscribers = renderNode.streamUnsubscribers;
+ if (streamUnsubscribers) {
+ for (var i = 0, l = streamUnsubscribers.length; i < l; i++) {
+ streamUnsubscribers[i]();
+ }
+ }
}
- function appendBlockConditional(view, inverted, helperName, params, hash, options, env) {
- Ember['default'].assert("The block form of the `if` and `unless` helpers expect exactly one " + "argument, e.g. `{{#if newMessages}} You have new messages. {{/if}}.`", params.length === 1);
+});
+enifed('ember-htmlbars/hooks/did-cleanup-tree', ['exports'], function (exports) {
- var condition = shouldDisplay['default'](params[0]);
- var truthyTemplate = (inverted ? options.inverse : options.template) || emptyTemplate['default'];
- var falsyTemplate = (inverted ? options.template : options.inverse) || emptyTemplate['default'];
+ 'use strict';
- if (utils.isStream(condition)) {
- view.appendChild(BoundIfView['default'], {
- _morph: options.morph,
- _context: property_get.get(view, 'context'),
- conditionStream: condition,
- truthyTemplate: truthyTemplate,
- falsyTemplate: falsyTemplate,
- helperName: helperName
- });
- } else {
- var template = condition ? truthyTemplate : falsyTemplate;
- if (template) {
- return template.render(view, env, options.morph.contextualElement);
- }
+ exports['default'] = didCleanupTree;
+
+ function didCleanupTree(env) {
+ var view;
+ if (view = env.view) {
+ view.ownerView.isDestroyingSubtree = false;
}
}
- function appendInlineConditional(view, inverted, helperName, params) {
- Ember['default'].assert("The inline form of the `if` and `unless` helpers expect two or " + "three arguments, e.g. `{{if trialExpired 'Expired' expiryDate}}` " + "or `{{unless isFirstLogin 'Welcome back!'}}`.", params.length === 2 || params.length === 3);
+});
+enifed('ember-htmlbars/hooks/did-render-node', ['exports'], function (exports) {
- return conditional['default'](shouldDisplay['default'](params[0]), inverted ? params[2] : params[1], inverted ? params[1] : params[2]);
+ 'use strict';
+
+ exports['default'] = didRenderNode;
+
+ function didRenderNode(morph, env) {
+ env.renderedNodes[morph.guid] = true;
}
});
-enifed('ember-htmlbars/helpers/input', ['exports', 'ember-views/views/checkbox', 'ember-views/views/text_field', 'ember-metal/streams/utils', 'ember-metal/core'], function (exports, Checkbox, TextField, utils, Ember) {
+enifed('ember-htmlbars/hooks/element', ['exports', 'ember-htmlbars/system/lookup-helper', 'htmlbars-runtime/hooks'], function (exports, lookup_helper, hooks) {
'use strict';
- exports.inputHelper = inputHelper;
- function inputHelper(params, hash, options, env) {
- Ember['default'].assert('You can only pass attributes to the `input` helper, not arguments', params.length === 0);
- var onEvent = hash.on;
- var inputType;
+ exports['default'] = emberElement;
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
- inputType = utils.read(hash.type);
+ var fakeElement;
- if (inputType === 'checkbox') {
- delete hash.type;
+ function updateElementAttributesFromString(element, string) {
+ if (!fakeElement) {
+ fakeElement = document.createElement("div");
+ }
- Ember['default'].assert("{{input type='checkbox'}} does not support setting `value=someBooleanValue`;" + " you must use `checked=someBooleanValue` instead.", !hash.hasOwnProperty('value'));
+ fakeElement.innerHTML = "<" + element.tagName + " " + string + "><" + "/" + element.tagName + ">";
- env.helpers.view.helperFunction.call(this, [Checkbox['default']], hash, options, env);
+ var attrs = fakeElement.firstChild.attributes;
+ for (var i = 0, l = attrs.length; i < l; i++) {
+ var attr = attrs[i];
+ if (attr.specified) {
+ element.setAttribute(attr.name, attr.value);
+ }
+ }
+ }
+ function emberElement(morph, env, scope, path, params, hash, visitor) {
+ if (hooks.handleRedirect(morph, env, scope, path, params, hash, null, null, visitor)) {
+ return;
+ }
+
+ var result;
+ var helper = lookup_helper.findHelper(path, scope.self, env);
+ if (helper) {
+ result = env.hooks.invokeHelper(null, env, scope, null, params, hash, helper, { element: morph.element }).value;
} else {
- delete hash.on;
+ result = env.hooks.get(env, scope, path);
+ }
- hash.onEvent = onEvent || 'enter';
- env.helpers.view.helperFunction.call(this, [TextField['default']], hash, options, env);
+ var value = env.hooks.getValue(result);
+ if (value) {
+ Ember.deprecate("Returning a string of attributes from a helper inside an element is deprecated.");
+ updateElementAttributesFromString(morph.element, value);
}
}
});
-enifed('ember-htmlbars/helpers/loc', ['exports', 'ember-metal/core', 'ember-runtime/system/string', 'ember-metal/streams/utils'], function (exports, Ember, string, utils) {
+enifed('ember-htmlbars/hooks/get-cell-or-value', ['exports', 'ember-metal/streams/utils', 'ember-htmlbars/keywords/mut'], function (exports, utils, mut) {
'use strict';
- exports.locHelper = locHelper;
- function locHelper(params, hash, options, env) {
- Ember['default'].assert('You cannot pass bindings to `loc` helper', (function ifParamsContainBindings() {
- for (var i = 0, l = params.length; i < l; i++) {
- if (utils.isStream(params[i])) {
- return false;
- }
- }
- return true;
- })());
- return string.loc.apply(env.data.view, params);
+ exports['default'] = getCellOrValue;
+ function getCellOrValue(ref) {
+ if (ref && ref[mut.MUTABLE_REFERENCE]) {
+ // reify the mutable reference into a mutable cell
+ return ref.cell();
+ }
+
+ // get the value out of the reference
+ return utils.read(ref);
}
});
-enifed('ember-htmlbars/helpers/log', ['exports', 'ember-metal/logger', 'ember-metal/streams/utils'], function (exports, Logger, utils) {
+enifed('ember-htmlbars/hooks/get-child', ['exports', 'ember-metal/streams/utils'], function (exports, utils) {
'use strict';
- exports.logHelper = logHelper;
- function logHelper(params, hash, options, env) {
- var logger = Logger['default'].log;
- var values = [];
- for (var i = 0; i < params.length; i++) {
- values.push(utils.read(params[i]));
+ exports['default'] = getChild;
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
+
+ function getChild(parent, key) {
+ if (utils.isStream(parent)) {
+ return parent.getKey(key);
}
- logger.apply(logger, values);
+ // This should only happen when we are looking at an `attrs` hash
+ // That might change if it is possible to pass object literals
+ // through the templating system.
+ return parent[key];
}
});
-enifed('ember-htmlbars/helpers/partial', ['exports', 'ember-metal/property_get', 'ember-metal/streams/utils', 'ember-views/views/bound_partial_view', 'ember-views/system/lookup_partial'], function (exports, property_get, utils, BoundPartialView, lookupPartial) {
+enifed('ember-htmlbars/hooks/get-root', ['exports', 'ember-metal/core', 'ember-metal/path_cache', 'ember-metal/streams/proxy-stream'], function (exports, Ember, path_cache, ProxyStream) {
'use strict';
- exports.partialHelper = partialHelper;
- function partialHelper(params, hash, options, env) {
- var view = env.data.view;
- var templateName = params[0];
- if (utils.isStream(templateName)) {
- view.appendChild(BoundPartialView['default'], {
- _morph: options.morph,
- _context: property_get.get(view, 'context'),
- templateNameStream: templateName,
- helperName: options.helperName || 'partial'
- });
+ exports['default'] = getRoot;
+
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
+
+ function getRoot(scope, key) {
+ if (key === "this") {
+ return [scope.self];
+ } else if (key === "hasBlock") {
+ return [!!scope.blocks["default"]];
+ } else if (key === "hasBlockParams") {
+ return [!!(scope.blocks["default"] && scope.blocks["default"].arity)];
+ } else if (path_cache.isGlobal(key) && Ember['default'].lookup[key]) {
+ return [getGlobal(key)];
+ } else if (scope.locals[key]) {
+ return [scope.locals[key]];
} else {
- var template = lookupPartial['default'](view, templateName);
- return template.render(view, env, options.morph.contextualElement);
+ return [getKey(scope, key)];
}
}
+ function getKey(scope, key) {
+ if (key === "attrs" && scope.attrs) {
+ return scope.attrs;
+ }
+
+ var self = scope.self || scope.locals.view;
+
+ if (scope.attrs && key in scope.attrs) {
+ // TODO: attrs
+ // Ember.deprecate("You accessed the `" + key + "` attribute directly. Please use `attrs." + key + "` instead.");
+ return scope.attrs[key];
+ } else if (self) {
+ return self.getKey(key);
+ }
+ }
+
+ function getGlobal(name) {
+ Ember['default'].deprecate("Global lookup of " + name + " from a Handlebars template is deprecated.");
+
+ // This stream should be memoized, but this path is deprecated and
+ // will be removed soon so it's not worth the trouble.
+ return new ProxyStream['default'](Ember['default'].lookup[name], name);
+ }
+
});
-enifed('ember-htmlbars/helpers/template', ['exports', 'ember-metal/core'], function (exports, Ember) {
+enifed('ember-htmlbars/hooks/get-value', ['exports', 'ember-metal/streams/utils', 'ember-views/compat/attrs-proxy'], function (exports, utils, attrs_proxy) {
'use strict';
- exports.templateHelper = templateHelper;
- function templateHelper(params, hash, options, env) {
- Ember['default'].deprecate("The `template` helper has been deprecated in favor of the `partial` helper." + " Please use `partial` instead, which will work the same way.");
- options.helperName = options.helperName || 'template';
+ exports['default'] = getValue;
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
- return env.helpers.partial.helperFunction.call(this, params, hash, options, env);
+ function getValue(ref) {
+ var value = utils.read(ref);
+
+ if (value && value[attrs_proxy.MUTABLE_CELL]) {
+ return value.value;
+ }
+
+ return value;
}
});
-enifed('ember-htmlbars/helpers/text_area', ['exports', 'ember-metal/core', 'ember-views/views/text_area'], function (exports, Ember, TextArea) {
+enifed('ember-htmlbars/hooks/has-helper', ['exports', 'ember-htmlbars/system/lookup-helper'], function (exports, lookup_helper) {
'use strict';
- exports.textareaHelper = textareaHelper;
- function textareaHelper(params, hash, options, env) {
- Ember['default'].assert('You can only pass attributes to the `textarea` helper, not arguments', params.length === 0);
- return env.helpers.view.helperFunction.call(this, [TextArea['default']], hash, options, env);
+ exports['default'] = hasHelperHook;
+ function hasHelperHook(env, scope, helperName) {
+ return !!lookup_helper.findHelper(helperName, scope.self, env);
}
});
-enifed('ember-htmlbars/helpers/unbound', ['exports', 'ember-metal/error', 'ember-metal/mixin', 'ember-metal/streams/utils', 'ember-htmlbars/system/lookup-helper'], function (exports, EmberError, mixin, utils, lookupHelper) {
+enifed('ember-htmlbars/hooks/invoke-helper', ['exports', 'ember-metal/core', 'ember-htmlbars/hooks/get-value'], function (exports, Ember, getValue) {
'use strict';
- exports.unboundHelper = unboundHelper;
- function unboundHelper(params, hash, options, env) {
- Ember.assert("The `unbound` helper expects at least one argument, " + "e.g. `{{unbound user.name}}`.", params.length > 0);
- if (params.length === 1) {
- return utils.read(params[0]);
- } else {
- options.helperName = options.helperName || 'unbound';
+ exports['default'] = invokeHelper;
- var view = env.data.view;
- var helperName = params[0]._label;
- var helper = lookupHelper['default'](helperName, view, env);
+ function invokeHelper(morph, env, scope, visitor, _params, _hash, helper, templates, context) {
+ var params, hash;
- if (!helper) {
- throw new EmberError['default']('HTMLBars error: Could not find component or helper named ' + helperName + '.');
- }
+ if (typeof helper === 'function') {
+ params = getArrayValues(_params);
+ hash = getHashValues(_hash);
+ return { value: helper.call(context, params, hash, templates) };
+ } else if (helper.isLegacyViewHelper) {
+ Ember['default'].assert('You can only pass attributes (such as name=value) not bare ' + 'values to a helper for a View found in \'' + helper.viewClass + '\'', _params.length === 0);
- return helper.helperFunction.call(this, readParams(params), readHash(hash, view), options, env);
+ env.hooks.keyword('view', morph, env, scope, [helper.viewClass], _hash, templates.template.raw, null, visitor);
+ return { handled: true };
+ } else if (helper && helper.helperFunction) {
+ var helperFunc = helper.helperFunction;
+ return { value: helperFunc.call({}, _params, _hash, templates, env, scope) };
}
}
- function readParams(params) {
- var l = params.length;
- var unboundParams = new Array(l - 1);
-
- for (var i = 1; i < l; i++) {
- unboundParams[i - 1] = utils.read(params[i]);
+ // We don't want to leak mutable cells into helpers, which
+ // are pure functions that can only work with values.
+ function getArrayValues(params) {
+ var out = [];
+ for (var i = 0, l = params.length; i < l; i++) {
+ out.push(getValue['default'](params[i]));
}
- return unboundParams;
+ return out;
}
- function readHash(hash, view) {
- var unboundHash = {};
-
+ function getHashValues(hash) {
+ var out = {};
for (var prop in hash) {
- if (mixin.IS_BINDING.test(prop)) {
- var value = hash[prop];
- if (typeof value === 'string') {
- value = view.getStream(value);
- }
-
- unboundHash[prop.slice(0, -7)] = utils.read(value);
- } else {
- unboundHash[prop] = utils.read(hash[prop]);
- }
+ out[prop] = getValue['default'](hash[prop]);
}
- return unboundHash;
+ return out;
}
});
-enifed('ember-htmlbars/helpers/view', ['exports', 'ember-metal/core', 'ember-metal/streams/utils', 'ember-views/streams/utils', 'ember-views/views/view', 'ember-htmlbars/system/merge-view-bindings', 'ember-htmlbars/system/append-templated-view'], function (exports, Ember, utils, streams__utils, View, mergeViewBindings, appendTemplatedView) {
+enifed('ember-htmlbars/hooks/link-render-node', ['exports', 'ember-htmlbars/utils/subscribe', 'ember-runtime/utils', 'ember-metal/streams/utils', 'ember-htmlbars/system/lookup-helper'], function (exports, subscribe, utils, streams__utils, lookup_helper) {
'use strict';
- exports.viewHelper = viewHelper;
- function viewHelper(params, hash, options, env) {
- Ember['default'].assert("The `view` helper expects zero or one arguments.", params.length <= 2);
- var view = env.data.view;
- var container = view.container || utils.read(view._keywords.view).container;
- var viewClassOrInstance;
- if (params.length === 0) {
- if (container) {
- viewClassOrInstance = container.lookupFactory('view:toplevel');
- } else {
- viewClassOrInstance = View['default'];
- }
+ exports['default'] = linkRenderNode;
+
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
+
+ function linkRenderNode(renderNode, env, scope, path, params, hash) {
+ if (renderNode.streamUnsubscribers) {
+ return true;
+ }
+
+ var keyword = env.hooks.keywords[path];
+ var helper;
+ if (keyword && keyword.link) {
+ keyword.link(renderNode.state, params, hash);
} else {
- viewClassOrInstance = streams__utils.readViewFactory(params[0], container);
+ switch (path) {
+ case "unbound":
+ return true;
+ case "if":
+ params[0] = shouldDisplay(params[0]);break;
+ case "each":
+ params[0] = eachParam(params[0]);break;
+ default:
+ helper = lookup_helper.findHelper(path, scope.view, env);
+
+ if (helper && helper.isHandlebarsCompat && params[0]) {
+ params[0] = processHandlebarsCompatDepKeys(params[0], helper._dependentKeys);
+ }
+ }
}
- var props = {
- helperName: options.helperName || 'view'
- };
+ if (params && params.length) {
+ for (var i = 0; i < params.length; i++) {
+ subscribe['default'](renderNode, env, scope, params[i]);
+ }
+ }
- if (options.template) {
- props.template = options.template;
+ if (hash) {
+ for (var key in hash) {
+ subscribe['default'](renderNode, env, scope, hash[key]);
+ }
}
- mergeViewBindings['default'](view, props, hash);
- appendTemplatedView['default'](view, options.morph, viewClassOrInstance, props);
+ // The params and hash can be reused; they don't need to be
+ // recomputed on subsequent re-renders because they are
+ // streams.
+ return true;
}
-});
-enifed('ember-htmlbars/helpers/with', ['exports', 'ember-metal/core', 'ember-views/views/with_view'], function (exports, Ember, WithView) {
+ function eachParam(list) {
+ var listChange = getKey(list, "[]");
- 'use strict';
+ var stream = streams__utils.chain(list, function () {
+ streams__utils.read(listChange);
+ return streams__utils.read(list);
+ }, "each");
- exports.withHelper = withHelper;
+ stream.addDependency(listChange);
+ return stream;
+ }
- function withHelper(params, hash, options, env) {
- Ember['default'].assert("{{#with}} must be called with an argument. For example, `{{#with foo as |bar|}}{{/with}}`", params.length === 1);
+ function shouldDisplay(predicate) {
+ var length = getKey(predicate, "length");
+ var isTruthy = getKey(predicate, "isTruthy");
- Ember['default'].assert("The {{#with}} helper must be called with a block", !!options.template);
+ var stream = streams__utils.chain(predicate, function () {
+ var predicateVal = streams__utils.read(predicate);
+ var lengthVal = streams__utils.read(length);
+ var isTruthyVal = streams__utils.read(isTruthy);
- var view = env.data.view;
- var preserveContext;
+ if (utils.isArray(predicateVal)) {
+ return lengthVal > 0;
+ }
- if (options.template.blockParams) {
- preserveContext = true;
+ if (typeof isTruthyVal === "boolean") {
+ return isTruthyVal;
+ }
+
+ return !!predicateVal;
+ }, "ShouldDisplay");
+
+ streams__utils.addDependency(stream, length);
+ streams__utils.addDependency(stream, isTruthy);
+
+ return stream;
+ }
+
+ function getKey(obj, key) {
+ if (streams__utils.isStream(obj)) {
+ return obj.getKey(key);
} else {
- Ember['default'].deprecate("Using the context switching form of `{{with}}` is deprecated. " + "Please use the block param form (`{{#with bar as |foo|}}`) instead.", false, { url: 'http://emberjs.com/guides/deprecations/#toc_more-consistent-handlebars-scope' });
- preserveContext = false;
+ return obj && obj[key];
}
+ }
- view.appendChild(WithView['default'], {
- _morph: options.morph,
- withValue: params[0],
- preserveContext: preserveContext,
- previousContext: view.get('context'),
- controllerName: hash.controller,
- mainTemplate: options.template,
- inverseTemplate: options.inverse,
- helperName: options.helperName || 'with'
- });
+ function processHandlebarsCompatDepKeys(base, additionalKeys) {
+ if (!streams__utils.isStream(base) || additionalKeys.length === 0) {
+ return base;
+ }
+
+ var depKeyStreams = [];
+
+ var stream = streams__utils.chain(base, function () {
+ streams__utils.readArray(depKeyStreams);
+
+ return streams__utils.read(base);
+ }, "HandlebarsCompatHelper");
+
+ for (var i = 0, l = additionalKeys.length; i < l; i++) {
+ var depKeyStream = base.get(additionalKeys[i]);
+
+ depKeyStreams.push(depKeyStream);
+ stream.addDependency(depKeyStream);
+ }
+
+ return stream;
}
});
-enifed('ember-htmlbars/helpers/yield', ['exports', 'ember-metal/core', 'ember-metal/property_get'], function (exports, Ember, property_get) {
+enifed('ember-htmlbars/hooks/lookup-helper', ['exports', 'ember-htmlbars/system/lookup-helper'], function (exports, lookupHelper) {
'use strict';
- exports.yieldHelper = yieldHelper;
- function yieldHelper(params, hash, options, env) {
- var view = env.data.view;
- var layoutView = view;
- // Yea gods
- while (layoutView && !property_get.get(layoutView, 'layout')) {
- if (layoutView._contextView) {
- layoutView = layoutView._contextView;
- } else {
- layoutView = layoutView._parentView;
+ exports['default'] = lookupHelperHook;
+ function lookupHelperHook(env, scope, helperName) {
+ return lookupHelper['default'](helperName, scope.self, env);
+ }
+
+});
+enifed('ember-htmlbars/hooks/subexpr', ['exports', 'ember-htmlbars/system/lookup-helper', 'ember-metal/merge', 'ember-metal/streams/stream', 'ember-metal/platform/create', 'ember-metal/streams/utils'], function (exports, lookupHelper, merge, Stream, create, utils) {
+
+ 'use strict';
+
+
+
+ exports['default'] = subexpr;
+
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
+
+ function subexpr(env, scope, helperName, params, hash) {
+ // TODO: Keywords and helper invocation should be integrated into
+ // the subexpr hook upstream in HTMLBars.
+ var keyword = env.hooks.keywords[helperName];
+ if (keyword) {
+ return keyword(null, env, scope, params, hash, null, null);
+ }
+
+ var helper = lookupHelper['default'](helperName, scope.self, env);
+ var invoker = function (params, hash) {
+ return env.hooks.invokeHelper(null, env, scope, null, params, hash, helper, { template: {}, inverse: {} }, undefined).value;
+ };
+
+ //Ember.assert("A helper named '"+helperName+"' could not be found", typeof helper === 'function');
+
+ var label = labelForSubexpr(params, hash, helperName);
+ return new SubexprStream(params, hash, invoker, label);
+ }
+
+ function labelForSubexpr(params, hash, helperName) {
+ return function () {
+ var paramsLabels = labelsForParams(params);
+ var hashLabels = labelsForHash(hash);
+ var label = "(" + helperName;
+ if (paramsLabels) {
+ label += " " + paramsLabels;
}
+ if (hashLabels) {
+ label += " " + hashLabels;
+ }
+ return "" + label + ")";
+ };
+ }
+
+ function labelsForParams(params) {
+ return utils.labelsFor(params).join(" ");
+ }
+
+ function labelsForHash(hash) {
+ var out = [];
+
+ for (var prop in hash) {
+ out.push("" + prop + "=" + utils.labelFor(hash[prop]));
}
- Ember['default'].assert("You called yield in a template that was not a layout", !!layoutView);
+ return out.join(" ");
+ }
- return layoutView._yield(view, env, options.morph, params);
+ function SubexprStream(params, hash, helper, label) {
+ this.init(label);
+ this.params = params;
+ this.hash = hash;
+ this.helper = helper;
+
+ for (var i = 0, l = params.length; i < l; i++) {
+ this.addDependency(params[i]);
+ }
+
+ for (var key in hash) {
+ this.addDependency(hash[key]);
+ }
}
+ SubexprStream.prototype = create['default'](Stream['default'].prototype);
+
+ merge['default'](SubexprStream.prototype, {
+ compute: function () {
+ return this.helper(utils.readArray(this.params), utils.readHash(this.hash));
+ }
+ });
+
});
-enifed('ember-htmlbars/hooks/attribute', ['exports', 'ember-views/attr_nodes/attr_node', 'ember-metal/error', 'ember-metal/streams/utils', 'morph-attr/sanitize-attribute-value'], function (exports, AttrNode, EmberError, utils, sanitizeAttributeValue) {
+enifed('ember-htmlbars/hooks/update-self', ['exports', 'ember-metal/property_get', 'ember-htmlbars/utils/update-scope'], function (exports, property_get, updateScope) {
'use strict';
- exports['default'] = attribute;
+ exports['default'] = updateSelf;
/**
@module ember
@submodule ember-htmlbars
*/
- var boundAttributesEnabled = false;
+ function updateSelf(env, scope, _self) {
+ var self = _self;
-
- boundAttributesEnabled = true;
-
- function attribute(env, morph, element, attrName, attrValue) {
- if (boundAttributesEnabled) {
- var attrNode = new AttrNode['default'](attrName, attrValue);
- attrNode._morph = morph;
- env.data.view.appendChild(attrNode);
- } else {
- if (utils.isStream(attrValue)) {
- throw new EmberError['default']('Bound attributes are not yet supported in Ember.js');
- } else {
- var sanitizedValue = sanitizeAttributeValue['default'](env.dom, element, attrName, attrValue);
- env.dom.setProperty(element, attrName, sanitizedValue);
- }
+ if (self && self.hasBoundController) {
+ var controller = self.controller;
+
+ self = self.self;
+
+ updateScope['default'](scope.locals, "controller", controller || self);
}
+
+ Ember.assert("BUG: scope.attrs and self.isView should not both be true", !(scope.attrs && self.isView));
+
+ if (self && self.isView) {
+ scope.view = self;
+ updateScope['default'](scope.locals, "view", self, null);
+ updateScope['default'](scope, "self", property_get.get(self, "context"), null, true);
+ return;
+ }
+
+ updateScope['default'](scope, "self", self, null);
}
});
-enifed('ember-htmlbars/hooks/block', ['exports', 'ember-views/views/simple_bound_view', 'ember-metal/streams/utils', 'ember-htmlbars/system/lookup-helper'], function (exports, simple_bound_view, utils, lookupHelper) {
+enifed('ember-htmlbars/hooks/will-cleanup-tree', ['exports'], function (exports) {
'use strict';
+ exports['default'] = willCleanupTree;
+ function willCleanupTree(env, morph, destroySelf) {
+ var view = morph.emberView;
+ if (destroySelf && view && view.parentView) {
+ view.parentView.removeChild(view);
+ }
- exports['default'] = block;
+ if (view = env.view) {
+ view.ownerView.isDestroyingSubtree = true;
+ }
+ }
+
+});
+enifed('ember-htmlbars/keywords', ['exports', 'htmlbars-runtime', 'ember-metal/platform/create'], function (exports, htmlbars_runtime, o_create) {
+
+ 'use strict';
+
+ exports.registerKeyword = registerKeyword;
+
/**
@module ember
@submodule ember-htmlbars
*/
- function block(env, morph, view, path, params, hash, template, inverse) {
- var helper = lookupHelper['default'](path, view, env);
+ /**
+ @private
+ @method _registerHelper
+ @for Ember.HTMLBars
+ @param {String} name
+ @param {Object|Function} helperFunc the helper function to add
+ */
+ var keywords = o_create['default'](htmlbars_runtime.hooks.keywords);
+ function registerKeyword(name, keyword) {
+ keywords[name] = keyword;
+ }
- Ember.assert("A helper named `" + path + "` could not be found", helper);
+ exports['default'] = keywords;
- var options = {
- morph: morph,
- template: template,
- inverse: inverse,
- isBlock: true
- };
- var result = helper.helperFunction.call(undefined, params, hash, options, env);
+});
+enifed('ember-htmlbars/keywords/collection', ['exports', 'ember-views/streams/utils', 'ember-views/views/collection_view', 'ember-htmlbars/node-managers/view-node-manager', 'ember-metal/keys', 'ember-metal/merge'], function (exports, utils, CollectionView, ViewNodeManager, objectKeys, merge) {
- if (utils.isStream(result)) {
- simple_bound_view.appendSimpleBoundView(view, morph, result);
+ 'use strict';
+
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
+
+ exports['default'] = {
+ setupState: function (state, env, scope, params, hash) {
+ var read = env.hooks.getValue;
+
+ return merge.assign({}, state, {
+ parentView: read(scope.locals.view),
+ viewClassOrInstance: getView(read(params[0]), env.container)
+ });
+ },
+
+ rerender: function (morph, env, scope, params, hash, template, inverse, visitor) {
+ // If the hash is empty, the component cannot have extracted a part
+ // of a mutable param and used it in its layout, because there are
+ // no params at all.
+ if (objectKeys['default'](hash).length) {
+ return morph.state.manager.rerender(env, hash, visitor, true);
+ }
+ },
+
+ render: function (node, env, scope, params, hash, template, inverse, visitor) {
+ var state = node.state;
+ var parentView = state.parentView;
+
+ var options = { component: node.state.viewClassOrInstance, layout: null };
+ if (template) {
+ options.createOptions = {
+ _itemViewTemplate: template && { raw: template },
+ _itemViewInverse: inverse && { raw: inverse }
+ };
+ }
+
+ if (hash.itemView) {
+ hash.itemViewClass = hash.itemView;
+ }
+
+ if (hash.emptyView) {
+ hash.emptyViewClass = hash.emptyView;
+ }
+
+ var nodeManager = ViewNodeManager['default'].create(node, env, hash, options, parentView, null, scope, template);
+ state.manager = nodeManager;
+
+ nodeManager.render(env, hash, visitor);
+ }
+ };
+
+ function getView(viewPath, container) {
+ var viewClassOrInstance;
+
+ if (!viewPath) {
+ viewClassOrInstance = CollectionView['default'];
} else {
- morph.setContent(result);
+ viewClassOrInstance = utils.readViewFactory(viewPath, container);
}
+
+ return viewClassOrInstance;
}
});
-enifed('ember-htmlbars/hooks/component', ['exports', 'ember-metal/core', 'ember-htmlbars/system/lookup-helper'], function (exports, Ember, lookupHelper) {
+enifed('ember-htmlbars/keywords/component', ['exports', 'ember-metal/merge'], function (exports, merge) {
'use strict';
+ exports['default'] = {
+ setupState: function (lastState, env, scope, params, hash) {
+ var componentPath = env.hooks.getValue(params[0]);
+ return merge.assign({}, lastState, { componentPath: componentPath, isComponentHelper: true });
+ },
+ render: function (morph) {
+ for (var _len = arguments.length, rest = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
+ rest[_key - 1] = arguments[_key];
+ }
- exports['default'] = component;
+ // Force the component hook to treat this as a first-time render,
+ // because normal components (`<foo-bar>`) cannot change at runtime,
+ // but the `{{component}}` helper can.
+ morph.state.manager = null;
+
+ render.apply(undefined, [morph].concat(rest));
+ },
+
+ rerender: render
+ };
+
+ function render(morph, env, scope, params, hash, template, inverse, visitor) {
+ var componentPath = morph.state.componentPath;
+
+ // If the value passed to the {{component}} helper is undefined or null,
+ // don't create a new ComponentNode.
+ if (componentPath === undefined || componentPath === null) {
+ return;
+ }
+
+ env.hooks.component(morph, env, scope, componentPath, params, hash, { "default": template, inverse: inverse }, visitor);
+ }
+
+});
+enifed('ember-htmlbars/keywords/customized_outlet', ['exports', 'ember-htmlbars/node-managers/view-node-manager', 'ember-views/streams/utils', 'ember-metal/streams/utils'], function (exports, ViewNodeManager, utils, streams__utils) {
+
+ 'use strict';
+
/**
@module ember
@submodule ember-htmlbars
*/
- function component(env, morph, view, tagName, attrs, template) {
- var helper = lookupHelper['default'](tagName, view, env);
+ exports['default'] = {
+ setupState: function (state, env, scope, params, hash) {
+ Ember.assert("Using a quoteless view parameter with {{outlet}} is not supported", !hash.view || !streams__utils.isStream(hash.view));
+ var read = env.hooks.getValue;
+ var viewClass = read(hash.viewClass) || utils.readViewFactory(read(hash.view), env.container);
+ return { viewClass: viewClass };
+ },
+ render: function (renderNode, env, scope, params, hash, template, inverse, visitor) {
+ var state = renderNode.state;
+ var parentView = env.view;
- Ember['default'].assert('You specified `' + tagName + '` in your template, but a component for `' + tagName + '` could not be found.', !!helper);
+ var options = {
+ component: state.viewClass
+ };
+ var nodeManager = ViewNodeManager['default'].create(renderNode, env, hash, options, parentView, null, null, null);
+ state.manager = nodeManager;
+ nodeManager.render(env, hash, visitor);
+ }
+ };
- return helper.helperFunction.call(undefined, [], attrs, { morph: morph, template: template }, env);
- }
-
});
-enifed('ember-htmlbars/hooks/concat', ['exports', 'ember-metal/streams/utils'], function (exports, utils) {
+enifed('ember-htmlbars/keywords/debugger', ['exports', 'ember-metal/logger'], function (exports, Logger) {
'use strict';
- exports['default'] = concat;
/**
+ Execute the `debugger` statement in the current template's context.
+ ```handlebars
+ {{debugger}}
+ ```
+ When using the debugger helper you will have access to a `get` function. This
+ function retrieves values available in the context of the template.
+ For example, if you're wondering why a value `{{foo}}` isn't rendering as
+ expected within a template, you could place a `{{debugger}}` statement and,
+ when the `debugger;` breakpoint is hit, you can attempt to retrieve this value:
+ ```
+ > get('foo')
+ ```
+ `get` is also aware of keywords. So in this situation
+ ```handlebars
+ {{#each items as |item|}}
+ {{debugger}}
+ {{/each}}
+ ```
+ you'll be able to get values from the current item:
+ ```
+ > get('item.name')
+ ```
+ You can also access the context of the view to make sure it is the object that
+ you expect:
+ ```
+ > context
+ ```
+ @method debugger
+ @for Ember.Handlebars.helpers
+ @param {String} property
+ */
+ exports['default'] = debuggerKeyword;
+ /*jshint debug:true*/
+
+ /**
@module ember
@submodule ember-htmlbars
*/
+ function debuggerKeyword(morph, env, scope) {
+ /* jshint unused: false, debug: true */
- function concat(env, parts) {
- return utils.concat(parts, '');
+ var view = env.hooks.getValue(scope.locals.view);
+ var context = env.hooks.getValue(scope.self);
+
+ function get(path) {
+ return env.hooks.getValue(env.hooks.get(env, scope, path));
+ }
+
+ Logger['default'].info("Use `view`, `context`, and `get(<path>)` to debug this template.");
+
+ debugger;
+
+ return true;
}
});
-enifed('ember-htmlbars/hooks/content', ['exports', 'ember-views/views/simple_bound_view', 'ember-metal/streams/utils', 'ember-htmlbars/system/lookup-helper'], function (exports, simple_bound_view, utils, lookupHelper) {
+enifed('ember-htmlbars/keywords/each', ['exports', 'ember-htmlbars/hooks/get-value', 'ember-runtime/controllers/array_controller'], function (exports, getValue, ArrayController) {
'use strict';
- exports['default'] = content;
+ exports['default'] = each;
/**
@module ember
@submodule ember-htmlbars
*/
- function content(env, morph, view, path) {
- var helper = lookupHelper['default'](path, view, env);
- var result;
+ function each(morph, env, scope, params, hash, template, inverse, visitor) {
+ var firstParam = params[0] && getValue['default'](params[0]);
- if (helper) {
- var options = {
- morph: morph,
- isInline: true
- };
- result = helper.helperFunction.call(undefined, [], {}, options, env);
+ if (firstParam && firstParam instanceof ArrayController['default']) {
+ env.hooks.block(morph, env, scope, "-legacy-each-with-controller", params, hash, template, inverse, visitor);
+ return true;
+ }
+
+ return false;
+ }
+
+});
+enifed('ember-htmlbars/keywords/input', ['exports', 'ember-metal/core', 'ember-metal/merge'], function (exports, Ember, merge) {
+
+ 'use strict';
+
+ exports['default'] = {
+ setupState: function (lastState, env, scope, params, hash) {
+ var type = env.hooks.getValue(hash.type);
+ var componentName = componentNameMap[type] || defaultComponentName;
+
+ Ember['default'].assert("{{input type='checkbox'}} does not support setting `value=someBooleanValue`;" + " you must use `checked=someBooleanValue` instead.", !(type === "checkbox" && hash.hasOwnProperty("value")));
+
+ return merge.assign({}, lastState, { componentName: componentName });
+ },
+
+ render: function (morph, env, scope, params, hash, template, inverse, visitor) {
+ env.hooks.component(morph, env, scope, morph.state.componentName, params, hash, { "default": template, inverse: inverse }, visitor);
+ },
+
+ rerender: function () {
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
+ args[_key] = arguments[_key];
+ }
+
+ this.render.apply(this, args);
+ }
+ };
+
+ var defaultComponentName = "-text-field";
+
+ var componentNameMap = {
+ "checkbox": "-checkbox"
+ };
+
+});
+enifed('ember-htmlbars/keywords/legacy-yield', ['exports', 'ember-metal/streams/proxy-stream'], function (exports, ProxyStream) {
+
+ 'use strict';
+
+
+
+ exports['default'] = legacyYield;
+ function legacyYield(morph, env, _scope, params, hash, template, inverse, visitor) {
+ var scope = _scope;
+
+ if (scope.blocks["default"].arity === 0) {
+ // Typically, the `controller` local is persists through lexical scope.
+ // However, in this case, the `{{legacy-yield}}` in the legacy each view
+ // needs to override the controller local for the template it is yielding.
+ // This megahaxx allows us to override the controller, and most importantly,
+ // prevents the downstream scope from attempting to bind the `controller` local.
+ if (hash.controller) {
+ scope = env.hooks.createChildScope(scope);
+ scope.locals.controller = new ProxyStream['default'](hash.controller, "controller");
+ scope.overrideController = true;
+ }
+ scope.blocks["default"](env, [], params[0], morph, scope, visitor);
} else {
- result = view.getStream(path);
+ scope.blocks["default"](env, params, undefined, morph, scope, visitor);
}
- if (utils.isStream(result)) {
- simple_bound_view.appendSimpleBoundView(view, morph, result);
+ return true;
+ }
+
+});
+enifed('ember-htmlbars/keywords/mut', ['exports', 'ember-metal/platform/create', 'ember-metal/merge', 'ember-metal/utils', 'ember-metal/streams/proxy-stream', 'ember-metal/streams/utils', 'ember-metal/streams/stream', 'ember-views/compat/attrs-proxy', 'ember-routing-htmlbars/keywords/closure-action'], function (exports, create, merge, utils, ProxyStream, streams__utils, Stream, attrs_proxy, closure_action) {
+
+ 'use strict';
+
+ exports.privateMut = privateMut;
+
+ var _merge;
+
+ exports['default'] = mut;
+
+ var MUTABLE_REFERENCE = utils.symbol("MUTABLE_REFERENCE");function mut(morph, env, scope, originalParams, hash, template, inverse) {
+ // If `morph` is `null` the keyword is being invoked as a subexpression.
+ if (morph === null) {
+ var valueStream = originalParams[0];
+ return mutParam(env.hooks.getValue, valueStream);
+ }
+
+ return true;
+ }
+
+ function privateMut(morph, env, scope, originalParams, hash, template, inverse) {
+ // If `morph` is `null` the keyword is being invoked as a subexpression.
+ if (morph === null) {
+ var valueStream = originalParams[0];
+ return mutParam(env.hooks.getValue, valueStream, true);
+ }
+
+ return true;
+ }
+
+ function mutParam(read, stream, internal) {
+ if (internal) {
+ if (!streams__utils.isStream(stream)) {
+ (function () {
+ var literal = stream;
+ stream = new Stream['default'](function () {
+ return literal;
+ }, "(literal " + literal + ")");
+ stream.setValue = function (newValue) {
+ literal = newValue;
+ stream.notify();
+ };
+ })();
+ }
} else {
- morph.setContent(result);
+ Ember.assert("You can only pass a path to mut", streams__utils.isStream(stream));
}
+
+ if (stream[MUTABLE_REFERENCE]) {
+ return stream;
+ }
+
+ return new MutStream(stream);
}
+ function MutStream(stream) {
+ this.init("(mut " + stream.label + ")");
+ this.path = stream.path;
+ this.sourceDep = this.addMutableDependency(stream);
+ this[MUTABLE_REFERENCE] = true;
+ }
+
+ MutStream.prototype = create['default'](ProxyStream['default'].prototype);
+
+ merge['default'](MutStream.prototype, (_merge = {}, _merge.cell = function () {
+ var source = this;
+ var value = source.value();
+
+ if (value && value[closure_action.ACTION]) {
+ return value;
+ }
+
+ var val = {
+ value: value,
+ update: function (val) {
+ source.setValue(val);
+ }
+ };
+
+ val[attrs_proxy.MUTABLE_CELL] = true;
+ return val;
+ }, _merge[closure_action.INVOKE] = function (val) {
+ this.setValue(val);
+ }, _merge));
+
+ exports.MUTABLE_REFERENCE = MUTABLE_REFERENCE;
+
});
-enifed('ember-htmlbars/hooks/element', ['exports', 'ember-metal/core', 'ember-metal/streams/utils', 'ember-htmlbars/system/lookup-helper'], function (exports, Ember, utils, lookupHelper) {
+enifed('ember-htmlbars/keywords/outlet', ['exports', 'htmlbars-runtime/hooks'], function (exports, hooks) {
'use strict';
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
+ exports['default'] = function (morph, env, scope, params, hash, template, inverse, visitor) {
+ if (hash.hasOwnProperty('view') || hash.hasOwnProperty('viewClass')) {
+ Ember.deprecate('Passing `view` or `viewClass` to {{outlet}} is deprecated.');
+ hooks.keyword('@customized_outlet', morph, env, scope, params, hash, template, inverse, visitor);
+ } else {
+ hooks.keyword('@real_outlet', morph, env, scope, params, hash, template, inverse, visitor);
+ }
+ return true;
+ }
- exports['default'] = element;
+});
+enifed('ember-htmlbars/keywords/partial', ['exports', 'ember-views/system/lookup_partial', 'htmlbars-runtime'], function (exports, lookupPartial, htmlbars_runtime) {
+
+ 'use strict';
+
/**
@module ember
@submodule ember-htmlbars
*/
- var fakeElement;
+ exports['default'] = {
+ setupState: function (state, env, scope, params, hash) {
+ return { partialName: env.hooks.getValue(params[0]) };
+ },
- function updateElementAttributesFromString(dom, element, string) {
- if (!fakeElement) {
- fakeElement = document.createElement('div');
+ render: function (renderNode, env, scope, params, hash, template, inverse, visitor) {
+ var state = renderNode.state;
+ if (!state.partialName) {
+ return true;
+ }
+ var found = lookupPartial['default'](env, state.partialName);
+ if (!found) {
+ return true;
+ }
+
+ htmlbars_runtime.internal.hostBlock(renderNode, env, scope, found.raw, null, null, visitor, function (options) {
+ options.templates.template.yield();
+ });
}
+ };
- fakeElement.innerHTML = '<' + element.tagName + ' ' + string + '><' + '/' + element.tagName + '>';
+});
+enifed('ember-htmlbars/keywords/readonly', ['exports', 'ember-htmlbars/keywords/mut'], function (exports, mut) {
- var attrs = fakeElement.firstChild.attributes;
- for (var i = 0, l = attrs.length; i < l; i++) {
- var attr = attrs[i];
- if (attr.specified) {
- dom.setAttribute(element, attr.name, attr.value);
+ 'use strict';
+
+
+
+ exports['default'] = readonly;
+ function readonly(morph, env, scope, originalParams, hash, template, inverse) {
+ // If `morph` is `null` the keyword is being invoked as a subexpression.
+ if (morph === null) {
+ var stream = originalParams[0];
+ if (stream && stream[mut.MUTABLE_REFERENCE]) {
+ return stream.sourceDep.dependee;
}
+ return stream;
}
+
+ return true;
}
- function element(env, domElement, view, path, params, hash) {
- //jshint ignore:line
- var helper = lookupHelper['default'](path, view, env);
- var valueOrLazyValue;
- if (helper) {
+});
+enifed('ember-htmlbars/keywords/real_outlet', ['exports', 'ember-metal/property_get', 'ember-htmlbars/node-managers/view-node-manager', 'ember-htmlbars/templates/top-level-view'], function (exports, property_get, ViewNodeManager, topLevelViewTemplate) {
+
+ 'use strict';
+
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
+
+ topLevelViewTemplate['default'].meta.revision = "Ember@1.13.0-beta.1";
+
+ exports['default'] = {
+ willRender: function (renderNode, env) {
+ env.view.ownerView._outlets.push(renderNode);
+ },
+
+ setupState: function (state, env, scope, params, hash) {
+ var outletState = env.outletState;
+ var read = env.hooks.getValue;
+ var outletName = read(params[0]) || "main";
+ var selectedOutletState = outletState[outletName];
+
+ var toRender = selectedOutletState && selectedOutletState.render;
+ if (toRender && !toRender.template && !toRender.ViewClass) {
+ toRender.template = topLevelViewTemplate['default'];
+ }
+
+ return { outletState: selectedOutletState, hasParentOutlet: env.hasParentOutlet };
+ },
+
+ childEnv: function (state) {
+ return { outletState: state.outletState && state.outletState.outlets, hasParentOutlet: true };
+ },
+
+ isStable: function (lastState, nextState) {
+ return isStable(lastState.outletState, nextState.outletState);
+ },
+
+ isEmpty: function (state) {
+ return isEmpty(state.outletState);
+ },
+
+ render: function (renderNode, env, scope, params, hash, template, inverse, visitor) {
+ var state = renderNode.state;
+ var parentView = env.view;
+ var outletState = state.outletState;
+ var toRender = outletState.render;
+ var namespace = env.container.lookup("application:main");
+ var LOG_VIEW_LOOKUPS = property_get.get(namespace, "LOG_VIEW_LOOKUPS");
+
+ var ViewClass = outletState.render.ViewClass;
+
+ if (!state.hasParentOutlet && !ViewClass) {
+ ViewClass = env.container.lookupFactory("view:toplevel");
+ }
+
var options = {
- element: domElement
+ component: ViewClass,
+ self: toRender.controller,
+ createOptions: {
+ controller: toRender.controller
+ }
};
- valueOrLazyValue = helper.helperFunction.call(undefined, params, hash, options, env);
- } else {
- valueOrLazyValue = view.getStream(path);
+
+ template = template || toRender.template && toRender.template.raw;
+
+ if (LOG_VIEW_LOOKUPS && ViewClass) {
+ Ember.Logger.info("Rendering " + toRender.name + " with " + ViewClass, { fullName: "view:" + toRender.name });
+ }
+
+ var nodeManager = ViewNodeManager['default'].create(renderNode, env, {}, options, parentView, null, null, template);
+ state.manager = nodeManager;
+
+ nodeManager.render(env, hash, visitor);
}
+ };
- var value = utils.read(valueOrLazyValue);
- if (value) {
- Ember['default'].deprecate('Returning a string of attributes from a helper inside an element is deprecated.');
- updateElementAttributesFromString(env.dom, domElement, value);
+ function isEmpty(outletState) {
+ return !outletState || !outletState.render.ViewClass && !outletState.render.template;
+ }
+
+ function isStable(a, b) {
+ if (!a && !b) {
+ return true;
}
+ if (!a || !b) {
+ return false;
+ }
+ a = a.render;
+ b = b.render;
+ for (var key in a) {
+ if (a.hasOwnProperty(key)) {
+ // name is only here for logging & debugging. If two different
+ // names result in otherwise identical states, they're still
+ // identical.
+ if (a[key] !== b[key] && key !== "name") {
+ return false;
+ }
+ }
+ }
+ return true;
}
});
-enifed('ember-htmlbars/hooks/get', ['exports'], function (exports) {
+enifed('ember-htmlbars/keywords/template', ['exports', 'ember-metal/core'], function (exports, Ember) {
'use strict';
+ exports['default'] = templateKeyword;
+ var deprecation = "The `template` helper has been deprecated in favor of the `partial` helper.";function templateKeyword(morph, env, scope, params, hash, template, inverse, visitor) {
+ Ember['default'].deprecate(deprecation);
+ env.hooks.keyword("partial", morph, env, scope, params, hash, template, inverse, visitor);
+ return true;
+ }
+ exports.deprecation = deprecation;
- exports['default'] = get;
+});
+enifed('ember-htmlbars/keywords/textarea', ['exports'], function (exports) {
+
+ 'use strict';
+
/**
@module ember
@submodule ember-htmlbars
*/
- function get(env, view, path) {
- return view.getStream(path);
+
+ exports['default'] = textarea;
+
+ function textarea(morph, env, scope, originalParams, hash, template, inverse, visitor) {
+ env.hooks.component(morph, env, scope, '-text-area', originalParams, hash, { "default": template, inverse: inverse }, visitor);
+ return true;
}
});
-enifed('ember-htmlbars/hooks/inline', ['exports', 'ember-views/views/simple_bound_view', 'ember-metal/streams/utils', 'ember-htmlbars/system/lookup-helper'], function (exports, simple_bound_view, utils, lookupHelper) {
+enifed('ember-htmlbars/keywords/unbound', ['exports', 'ember-metal/merge', 'ember-metal/platform/create', 'ember-metal/streams/stream', 'ember-metal/streams/utils'], function (exports, merge, create, Stream, utils) {
'use strict';
-
-
- exports['default'] = inline;
/**
@module ember
@submodule ember-htmlbars
*/
- function inline(env, morph, view, path, params, hash) {
- var helper = lookupHelper['default'](path, view, env);
+ exports['default'] = unbound;
- Ember.assert("A helper named '" + path + "' could not be found", helper);
+ function unbound(morph, env, scope, originalParams, hash, template, inverse) {
+ // Since we already got the params as a set of streams, we need to extract the key from
+ // the first param instead of (incorrectly) trying to read from it. If this was a call
+ // to `{{unbound foo.bar}}`, then we pass along the original stream to `hooks.range`.
+ var params = originalParams.slice();
+ var valueStream = params.shift();
- var result = helper.helperFunction.call(undefined, params, hash, { morph: morph }, env);
+ // If `morph` is `null` the keyword is being invoked as a subexpression.
+ if (morph === null) {
+ if (originalParams.length > 1) {
+ valueStream = env.hooks.subexpr(env, scope, valueStream.key, params, hash);
+ }
- if (utils.isStream(result)) {
- simple_bound_view.appendSimpleBoundView(view, morph, result);
+ return new VolatileStream(valueStream);
+ }
+
+ if (params.length === 0) {
+ env.hooks.range(morph, env, scope, null, valueStream);
+ } else if (template === null) {
+ env.hooks.inline(morph, env, scope, valueStream.key, params, hash);
} else {
- morph.setContent(result);
+ env.hooks.block(morph, env, scope, valueStream.key, params, hash, template, inverse);
}
+
+ return true;
}
-});
-enifed('ember-htmlbars/hooks/set', ['exports'], function (exports) {
+ function VolatileStream(source) {
+ this.init("(volatile " + source.label + ")");
+ this.source = source;
- 'use strict';
+ this.addDependency(source);
+ }
+ VolatileStream.prototype = create['default'](Stream['default'].prototype);
+ merge['default'](VolatileStream.prototype, {
+ value: function () {
+ return utils.read(this.source);
+ },
- exports['default'] = set;
+ notify: function () {}
+ });
+
+});
+enifed('ember-htmlbars/keywords/view', ['exports', 'ember-views/streams/utils', 'ember-views/views/view', 'ember-htmlbars/node-managers/view-node-manager', 'ember-metal/keys'], function (exports, utils, EmberView, ViewNodeManager, objectKeys) {
+
+ 'use strict';
+
/**
@module ember
@submodule ember-htmlbars
*/
- function set(env, view, name, value) {
- view._keywords[name] = value;
+
+ exports['default'] = {
+ setupState: function (state, env, scope, params, hash) {
+ var read = env.hooks.getValue;
+ var targetObject = read(scope.self);
+ var viewClassOrInstance = state.viewClassOrInstance;
+ if (!viewClassOrInstance) {
+ viewClassOrInstance = getView(read(params[0]), env.container);
+ }
+
+ // if parentView exists, use its controller (the default
+ // behavior), otherwise use `scope.self` as the controller
+ var controller = scope.view ? null : read(scope.self);
+
+ return {
+ manager: state.manager,
+ parentView: scope.view,
+ controller: controller,
+ targetObject: targetObject,
+ viewClassOrInstance: viewClassOrInstance
+ };
+ },
+
+ rerender: function (morph, env, scope, params, hash, template, inverse, visitor) {
+ // If the hash is empty, the component cannot have extracted a part
+ // of a mutable param and used it in its layout, because there are
+ // no params at all.
+ if (objectKeys['default'](hash).length) {
+ return morph.state.manager.rerender(env, hash, visitor, true);
+ }
+ },
+
+ render: function (node, env, scope, params, hash, template, inverse, visitor) {
+ if (hash.tag) {
+ hash = swapKey(hash, "tag", "tagName");
+ }
+
+ if (hash.classNameBindings) {
+ hash.classNameBindings = hash.classNameBindings.split(" ");
+ }
+
+ var state = node.state;
+ var parentView = state.parentView;
+
+ var options = {
+ component: node.state.viewClassOrInstance,
+ layout: null
+ };
+
+ options.createOptions = {};
+ if (node.state.controller) {
+ // Use `_controller` to avoid stomping on a CP
+ // that exists in the target view/component
+ options.createOptions._controller = node.state.controller;
+ }
+
+ if (node.state.targetObject) {
+ // Use `_targetObject` to avoid stomping on a CP
+ // that exists in the target view/component
+ options.createOptions._targetObject = node.state.targetObject;
+ }
+
+ var nodeManager = ViewNodeManager['default'].create(node, env, hash, options, parentView, null, scope, template);
+ state.manager = nodeManager;
+
+ nodeManager.render(env, hash, visitor);
+ }
+ };
+
+ function getView(viewPath, container) {
+ var viewClassOrInstance;
+
+ if (!viewPath) {
+ if (container) {
+ viewClassOrInstance = container.lookupFactory("view:toplevel");
+ } else {
+ viewClassOrInstance = EmberView['default'];
+ }
+ } else {
+ viewClassOrInstance = utils.readViewFactory(viewPath, container);
+ }
+
+ return viewClassOrInstance;
}
+ function swapKey(hash, original, update) {
+ var newHash = {};
+
+ for (var prop in hash) {
+ if (prop === original) {
+ newHash[update] = hash[prop];
+ } else {
+ newHash[prop] = hash[prop];
+ }
+ }
+
+ return newHash;
+ }
+
});
-enifed('ember-htmlbars/hooks/subexpr', ['exports', 'ember-htmlbars/system/lookup-helper'], function (exports, lookupHelper) {
+enifed('ember-htmlbars/keywords/with', ['exports', 'htmlbars-runtime', 'ember-metal/property_get'], function (exports, htmlbars_runtime, property_get) {
'use strict';
+ exports['default'] = {
+ setupState: function (state, env, scope, params, hash) {
+ var controller = hash.controller;
+ if (controller) {
+ if (!state.controller) {
+ var context = params[0];
+ var controllerFactory = env.container.lookupFactory("controller:" + controller);
+ var parentController = scope.view ? property_get.get(scope.view, "context") : null;
- exports['default'] = subexpr;
- /**
- @module ember
- @submodule ember-htmlbars
- */
+ var controllerInstance = controllerFactory.create({
+ model: env.hooks.getValue(context),
+ parentController: parentController,
+ target: parentController
+ });
- function subexpr(env, view, path, params, hash) {
- var helper = lookupHelper['default'](path, view, env);
+ params[0] = controllerInstance;
+ return { controller: controllerInstance };
+ }
- Ember.assert("A helper named '" + path + "' could not be found", helper);
+ return state;
+ }
- var options = {
- isInline: true
- };
- return helper.helperFunction.call(undefined, params, hash, options, env);
+ return { controller: null };
+ },
+
+ isStable: function () {
+ return true;
+ },
+
+ isEmpty: function (state) {
+ return false;
+ },
+
+ render: function (morph, env, scope, params, hash, template, inverse, visitor) {
+ if (morph.state.controller) {
+ morph.addDestruction(morph.state.controller);
+ hash.controller = morph.state.controller;
+ }
+
+ Ember.assert("{{#with foo}} must be called with a single argument or the use the " + "{{#with foo as bar}} syntax", params.length === 1);
+
+ Ember.assert("The {{#with}} helper must be called with a block", !!template);
+
+ if (template && template.arity === 0) {
+ Ember.deprecate("Using the context switching form of `{{with}}` is deprecated. " + "Please use the block param form (`{{#with bar as |foo|}}`) instead.", false, { url: "http://emberjs.com/guides/deprecations/#toc_more-consistent-handlebars-scope" });
+ }
+
+ htmlbars_runtime.internal.continueBlock(morph, env, scope, "with", params, hash, template, inverse, visitor);
+ },
+
+ rerender: function (morph, env, scope, params, hash, template, inverse, visitor) {
+ htmlbars_runtime.internal.continueBlock(morph, env, scope, "with", params, hash, template, inverse, visitor);
+ }
+ };
+
+});
+enifed('ember-htmlbars/morphs/attr-morph', ['exports', 'ember-metal/core', 'dom-helper', 'ember-metal/platform/create'], function (exports, Ember, DOMHelper, o_create) {
+
+ 'use strict';
+
+ var HTMLBarsAttrMorph = DOMHelper['default'].prototype.AttrMorphClass;
+
+ var styleWarning = "" + "Binding style attributes may introduce cross-site scripting vulnerabilities; " + "please ensure that values being bound are properly escaped. For more information, " + "including how to disable this warning, see " + "http://emberjs.com/deprecations/v1.x/#toc_binding-style-attributes.";
+
+ function EmberAttrMorph(element, attrName, domHelper, namespace) {
+ HTMLBarsAttrMorph.call(this, element, attrName, domHelper, namespace);
}
+ var proto = EmberAttrMorph.prototype = o_create['default'](HTMLBarsAttrMorph.prototype);
+ proto.HTMLBarsAttrMorph$setContent = HTMLBarsAttrMorph.prototype.setContent;
+
+ proto._deprecateEscapedStyle = function EmberAttrMorph_deprecateEscapedStyle(value) {
+ Ember['default'].warn(styleWarning, (function (name, value, escaped) {
+ // SafeString
+ if (value && value.toHTML) {
+ return true;
+ }
+
+ if (name !== "style") {
+ return true;
+ }
+
+ return !escaped;
+ })(this.attrName, value, this.escaped));
+ };
+
+ proto.setContent = function EmberAttrMorph_setContent(value) {
+ this._deprecateEscapedStyle(value);
+ this.HTMLBarsAttrMorph$setContent(value);
+ };
+
+ exports['default'] = EmberAttrMorph;
+
+ exports.styleWarning = styleWarning;
+
});
+enifed('ember-htmlbars/morphs/morph', ['exports', 'dom-helper', 'ember-metal/platform/create'], function (exports, dom_helper, o_create) {
+
+ 'use strict';
+
+ var HTMLBarsMorph = dom_helper['default'].prototype.MorphClass;
+ var guid = 1;
+
+ function EmberMorph(DOMHelper, contextualElement) {
+ this.HTMLBarsMorph$constructor(DOMHelper, contextualElement);
+
+ this.emberView = null;
+ this.emberToDestroy = null;
+ this.streamUnsubscribers = null;
+ this.guid = guid++;
+
+ // A component can become dirty either because one of its
+ // attributes changed, or because it was re-rendered. If any part
+ // of the component's template changes through observation, it has
+ // re-rendered from the perpsective of the programming model. This
+ // flag is set to true whenever a component becomes dirty because
+ // one of its attributes changed, which also triggers the attribute
+ // update flag (didUpdateAttrs).
+ this.shouldReceiveAttrs = false;
+ }
+
+ var proto = EmberMorph.prototype = o_create['default'](HTMLBarsMorph.prototype);
+ proto.HTMLBarsMorph$constructor = HTMLBarsMorph;
+ proto.HTMLBarsMorph$clear = HTMLBarsMorph.prototype.clear;
+
+ proto.addDestruction = function (toDestroy) {
+ this.emberToDestroy = this.emberToDestroy || [];
+ this.emberToDestroy.push(toDestroy);
+ };
+
+ proto.cleanup = function () {
+ var view;
+
+ if (view = this.emberView) {
+ if (!view.ownerView.isDestroyingSubtree) {
+ view.ownerView.isDestroyingSubtree = true;
+ if (view.parentView) {
+ view.parentView.removeChild(view);
+ }
+ }
+ }
+
+ var toDestroy = this.emberToDestroy;
+ if (toDestroy) {
+ for (var i = 0, l = toDestroy.length; i < l; i++) {
+ toDestroy[i].destroy();
+ }
+
+ this.emberToDestroy = null;
+ }
+ };
+
+ proto.didRender = function (env, scope) {
+ env.renderedNodes[this.guid] = true;
+ };
+
+ exports['default'] = EmberMorph;
+
+});
+enifed('ember-htmlbars/node-managers/component-node-manager', ['exports', 'ember-metal/core', 'ember-metal/merge', 'ember-views/system/build-component-template', 'ember-htmlbars/utils/lookup-component', 'ember-htmlbars/hooks/get-cell-or-value', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/set_properties', 'ember-views/compat/attrs-proxy', 'htmlbars-util/safe-string', 'ember-htmlbars/system/instrumentation-support', 'ember-views/views/component', 'ember-htmlbars/hooks/get-value'], function (exports, Ember, merge, buildComponentTemplate, lookupComponent, getCellOrValue, property_get, property_set, setProperties, attrs_proxy, SafeString, instrumentation_support, EmberComponent, getValue) {
+
+ 'use strict';
+
+ exports.handleLegacyRender = handleLegacyRender;
+ exports.createComponent = createComponent;
+
+ function ComponentNodeManager(component, isAngleBracket, scope, renderNode, attrs, block, expectElement) {
+ this.component = component;
+ this.isAngleBracket = isAngleBracket;
+ this.scope = scope;
+ this.renderNode = renderNode;
+ this.attrs = attrs;
+ this.block = block;
+ this.expectElement = expectElement;
+ }
+
+ exports['default'] = ComponentNodeManager;
+
+ ComponentNodeManager.create = function (renderNode, env, options) {
+ var tagName = options.tagName;
+ var params = options.params;
+ var attrs = options.attrs;
+ var parentView = options.parentView;
+ var parentScope = options.parentScope;
+ var isAngleBracket = options.isAngleBracket;
+ var templates = options.templates;
+
+ attrs = attrs || {};
+
+ // Try to find the Component class and/or template for this component name in
+ // the container.
+
+ var _lookupComponent = lookupComponent['default'](env.container, tagName);
+
+ var component = _lookupComponent.component;
+ var layout = _lookupComponent.layout;
+
+ Ember['default'].assert("HTMLBars error: Could not find component named \"" + tagName + "\" (no component or template with that name was found)", function () {
+ return component || layout;
+ });
+
+ component = component || EmberComponent['default'];
+
+ var createOptions = { parentView: parentView };
+
+ configureTagName(attrs, tagName, component, isAngleBracket, createOptions);
+
+ // Map passed attributes (e.g. <my-component id="foo">) to component
+ // properties ({ id: "foo" }).
+ configureCreateOptions(attrs, createOptions);
+
+ // If there is a controller on the scope, pluck it off and save it on the
+ // component. This allows the component to target actions sent via
+ // `sendAction` correctly.
+ if (parentScope.locals.controller) {
+ createOptions._controller = getValue['default'](parentScope.locals.controller);
+ }
+
+ // Instantiate the component
+ component = createComponent(component, isAngleBracket, createOptions, renderNode, env, attrs);
+
+ // If the component specifies its template via the `layout` or `template`
+ // properties instead of using the template looked up in the container, get
+ // them now that we have the component instance.
+ var result = extractComponentTemplates(component, templates);
+ layout = result.layout || layout;
+ templates = result.templates || templates;
+
+ extractPositionalParams(renderNode, component, params, attrs);
+
+ var results = buildComponentTemplate['default']({ layout: layout, component: component, isAngleBracket: isAngleBracket }, attrs, { templates: templates, scope: parentScope });
+
+ return new ComponentNodeManager(component, isAngleBracket, parentScope, renderNode, attrs, results.block, results.createdElement);
+ };
+
+ function extractPositionalParams(renderNode, component, params, attrs) {
+ if (component.positionalParams) {
+ // if the component is rendered via {{component}} helper, the first
+ // element of `params` is the name of the component, so we need to
+ // skip that when the positional parameters are constructed
+ var paramsStartIndex = renderNode.state.isComponentHelper ? 1 : 0;
+ var pp = component.positionalParams;
+ for (var i = 0; i < pp.length; i++) {
+ attrs[pp[i]] = params[paramsStartIndex + i];
+ }
+ }
+ }
+
+ function extractComponentTemplates(component, _templates) {
+ // Even though we looked up a layout from the container earlier, the
+ // component may specify a `layout` property that overrides that.
+ // The component may also provide a `template` property we should
+ // respect (though this behavior is deprecated).
+ var componentLayout = property_get.get(component, "layout");
+ var componentTemplate = property_get.get(component, "template");
+ var layout = undefined,
+ templates = undefined;
+
+ if (componentLayout) {
+ layout = componentLayout;
+ templates = extractLegacyTemplate(_templates, componentTemplate);
+ } else if (componentTemplate) {
+ // If the component has a `template` but no `layout`, use the template
+ // as the layout.
+ layout = componentTemplate;
+ templates = _templates;
+ Ember['default'].deprecate("Using deprecated `template` property on a Component.");
+ }
+
+ return { layout: layout, templates: templates };
+ }
+
+ // 2.0TODO: Remove legacy behavior
+ function extractLegacyTemplate(_templates, componentTemplate) {
+ var templates = undefined;
+
+ // There is no block template provided but the component has a
+ // `template` property.
+ if ((!templates || !templates["default"]) && componentTemplate) {
+ Ember['default'].deprecate("Using deprecated `template` property on a Component.");
+ templates = { "default": componentTemplate.raw };
+ } else {
+ templates = _templates;
+ }
+
+ return templates;
+ }
+
+ function configureTagName(attrs, tagName, component, isAngleBracket, createOptions) {
+ if (isAngleBracket) {
+ createOptions.tagName = tagName;
+ } else if (attrs.tagName) {
+ createOptions.tagName = getValue['default'](attrs.tagName);
+ }
+ }
+
+ function configureCreateOptions(attrs, createOptions) {
+ // Some attrs are special and need to be set as properties on the component
+ // instance. Make sure we use getValue() to get them from `attrs` since
+ // they are still streams.
+ if (attrs.id) {
+ createOptions.elementId = getValue['default'](attrs.id);
+ }
+ if (attrs._defaultTagName) {
+ createOptions._defaultTagName = getValue['default'](attrs._defaultTagName);
+ }
+ if (attrs.viewName) {
+ createOptions.viewName = getValue['default'](attrs.viewName);
+ }
+ }
+
+ ComponentNodeManager.prototype.render = function (_env, visitor) {
+ var component = this.component;
+ var attrs = this.attrs;
+
+ return instrumentation_support.instrument(component, function () {
+ var env = _env;
+
+ env = merge.assign({ view: component }, env);
+
+ var snapshot = takeSnapshot(attrs);
+ env.renderer.componentInitAttrs(this.component, snapshot);
+ env.renderer.componentWillRender(component);
+ env.renderedViews.push(component.elementId);
+
+ if (this.block) {
+ this.block(env, [], undefined, this.renderNode, this.scope, visitor);
+ }
+
+ var element = this.expectElement && this.renderNode.firstNode;
+
+ handleLegacyRender(component, element);
+ env.renderer.didCreateElement(component, element);
+ env.renderer.willInsertElement(component, element); // 2.0TODO remove legacy hook
+
+ env.lifecycleHooks.push({ type: "didInsertElement", view: component });
+ }, this);
+ };
+ function handleLegacyRender(component, element) {
+ if (!component.render) {
+ return;
+ }
+
+ Ember['default'].assert("Legacy render functions are not supported with angle-bracket components", !component._isAngleBracket);
+
+ var content, node, lastChildIndex;
+ var buffer = [];
+ var renderNode = component._renderNode;
+ component.render(buffer);
+ content = buffer.join("");
+ if (element) {
+ lastChildIndex = renderNode.childNodes.length - 1;
+ node = renderNode.childNodes[lastChildIndex];
+ } else {
+ node = renderNode;
+ }
+ node.setContent(new SafeString['default'](content));
+ }
+
+ ComponentNodeManager.prototype.rerender = function (_env, attrs, visitor) {
+ var component = this.component;
+
+ return instrumentation_support.instrument(component, function () {
+ var env = _env;
+
+ env = merge.assign({ view: component }, env);
+
+ var snapshot = takeSnapshot(attrs);
+
+ if (component._renderNode.shouldReceiveAttrs) {
+ env.renderer.componentUpdateAttrs(component, component.attrs, snapshot);
+
+ if (!component._isAngleBracket) {
+ setProperties['default'](component, mergeBindings({}, shadowedAttrs(component, snapshot)));
+ }
+
+ component._renderNode.shouldReceiveAttrs = false;
+ }
+
+ // Notify component that it has become dirty and is about to change.
+ env.renderer.componentWillUpdate(component, snapshot);
+ env.renderer.componentWillRender(component);
+
+ env.renderedViews.push(component.elementId);
+
+ if (this.block) {
+ this.block(env, [], undefined, this.renderNode, this.scope, visitor);
+ }
+
+ env.lifecycleHooks.push({ type: "didUpdate", view: component });
+
+ return env;
+ }, this);
+ };
+ function createComponent(_component, isAngleBracket, _props, renderNode, env) {
+ var attrs = arguments[5] === undefined ? {} : arguments[5];
+
+ var props = merge.assign({}, _props);
+
+ if (!isAngleBracket) {
+ var hasSuppliedController = ("controller" in attrs); // 2.0TODO remove
+ Ember['default'].deprecate("controller= is deprecated", !hasSuppliedController);
+
+ var snapshot = takeSnapshot(attrs);
+ props.attrs = snapshot;
+
+ var proto = _component.proto();
+ mergeBindings(props, shadowedAttrs(proto, snapshot));
+ } else {
+ props._isAngleBracket = true;
+ }
+
+ var component = _component.create(props);
+
+ // for the fallback case
+ component.container = component.container || env.container;
+
+ if (props.parentView) {
+ props.parentView.appendChild(component);
+
+ if (props.viewName) {
+ property_set.set(props.parentView, props.viewName, component);
+ }
+ }
+
+ component._renderNode = renderNode;
+ renderNode.emberView = component;
+ return component;
+ }
+
+ function shadowedAttrs(target, attrs) {
+ var shadowed = {};
+
+ // For backwards compatibility, set the component property
+ // if it has an attr with that name. Undefined attributes
+ // are handled on demand via the `unknownProperty` hook.
+ for (var attr in attrs) {
+ if (attr in target) {
+ // TODO: Should we issue a deprecation here?
+ //Ember.deprecate(deprecation(attr));
+ shadowed[attr] = attrs[attr];
+ }
+ }
+
+ return shadowed;
+ }
+
+ function takeSnapshot(attrs) {
+ var hash = {};
+
+ for (var prop in attrs) {
+ hash[prop] = getCellOrValue['default'](attrs[prop]);
+ }
+
+ return hash;
+ }
+
+ function mergeBindings(target, attrs) {
+ for (var prop in attrs) {
+ if (!attrs.hasOwnProperty(prop)) {
+ continue;
+ }
+ // when `attrs` is an actual value being set in the
+ // attrs hash (`{{foo-bar attrs="blah"}}`) we cannot
+ // set `"blah"` to the root of the target because
+ // that would replace all attrs with `attrs.attrs`
+ if (prop === "attrs") {
+ Ember['default'].warn("Invoking a component with a hash attribute named `attrs` is not supported. Please refactor usage of " + target + " to avoid passing `attrs` as a hash parameter.");
+ continue;
+ }
+ var value = attrs[prop];
+
+ if (value && value[attrs_proxy.MUTABLE_CELL]) {
+ target[prop] = value.value;
+ } else {
+ target[prop] = value;
+ }
+ }
+
+ return target;
+ }
+
+});
+enifed('ember-htmlbars/node-managers/view-node-manager', ['exports', 'ember-metal/merge', 'ember-metal/core', 'ember-views/system/build-component-template', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/set_properties', 'ember-views/views/view', 'ember-views/compat/attrs-proxy', 'ember-htmlbars/hooks/get-cell-or-value', 'ember-htmlbars/system/instrumentation-support', 'ember-htmlbars/node-managers/component-node-manager', 'ember-htmlbars/hooks/get-value'], function (exports, merge, Ember, buildComponentTemplate, property_get, property_set, setProperties, View, attrs_proxy, getCellOrValue, instrumentation_support, component_node_manager, getValue) {
+
+ 'use strict';
+
+ exports.createOrUpdateComponent = createOrUpdateComponent;
+
+ function ViewNodeManager(component, scope, renderNode, block, expectElement) {
+ this.component = component;
+ this.scope = scope;
+ this.renderNode = renderNode;
+ this.block = block;
+ this.expectElement = expectElement;
+ }
+
+ exports['default'] = ViewNodeManager;
+
+ ViewNodeManager.create = function (renderNode, env, attrs, found, parentView, path, contentScope, contentTemplate) {
+ Ember['default'].assert("HTMLBars error: Could not find component named \"" + path + "\" (no component or template with that name was found)", function () {
+ if (path) {
+ return found.component || found.layout;
+ } else {
+ return found.component || found.layout || contentTemplate;
+ }
+ });
+
+ var component;
+ var componentInfo = { layout: found.layout };
+
+ if (found.component) {
+ var options = { parentView: parentView };
+
+ if (attrs && attrs.id) {
+ options.elementId = getValue['default'](attrs.id);
+ }
+ if (attrs && attrs.tagName) {
+ options.tagName = getValue['default'](attrs.tagName);
+ }
+ if (attrs && attrs._defaultTagName) {
+ options._defaultTagName = getValue['default'](attrs._defaultTagName);
+ }
+ if (attrs && attrs.viewName) {
+ options.viewName = getValue['default'](attrs.viewName);
+ }
+
+ if (found.component.create && contentScope && contentScope.self) {
+ options._context = getValue['default'](contentScope.self);
+ }
+
+ if (found.self) {
+ options._context = getValue['default'](found.self);
+ }
+
+ component = componentInfo.component = createOrUpdateComponent(found.component, options, found.createOptions, renderNode, env, attrs);
+
+ var layout = property_get.get(component, "layout");
+ if (layout) {
+ componentInfo.layout = layout;
+ if (!contentTemplate) {
+ var template = property_get.get(component, "template");
+ if (template) {
+ Ember['default'].deprecate("Using deprecated `template` property on a " + (component.isView ? "View" : "Component") + ".");
+ contentTemplate = template.raw;
+ }
+ }
+ } else {
+ componentInfo.layout = property_get.get(component, "template") || componentInfo.layout;
+ }
+
+ renderNode.emberView = component;
+ }
+
+ Ember['default'].assert("BUG: ViewNodeManager.create can take a scope or a self, but not both", !(contentScope && found.self));
+
+ var results = buildComponentTemplate['default'](componentInfo, attrs, {
+ templates: { "default": contentTemplate },
+ scope: contentScope,
+ self: found.self
+ });
+
+ return new ViewNodeManager(component, contentScope, renderNode, results.block, results.createdElement);
+ };
+
+ ViewNodeManager.prototype.render = function (env, attrs, visitor) {
+ var component = this.component;
+
+ return instrumentation_support.instrument(component, function () {
+
+ var newEnv = env;
+ if (component) {
+ newEnv = merge['default']({}, env);
+ newEnv.view = component;
+ }
+
+ if (component) {
+ var snapshot = takeSnapshot(attrs);
+ env.renderer.setAttrs(this.component, snapshot);
+ env.renderer.willCreateElement(component);
+ env.renderer.willRender(component);
+ env.renderedViews.push(component.elementId);
+ }
+
+ if (this.block) {
+ this.block(newEnv, [], undefined, this.renderNode, this.scope, visitor);
+ }
+
+ if (component) {
+ var element = this.expectElement && this.renderNode.firstNode;
+ component_node_manager.handleLegacyRender(component, element);
+
+ env.renderer.didCreateElement(component, element); // 2.0TODO: Remove legacy hooks.
+ env.renderer.willInsertElement(component, element);
+ env.lifecycleHooks.push({ type: "didInsertElement", view: component });
+ }
+ }, this);
+ };
+
+ ViewNodeManager.prototype.rerender = function (env, attrs, visitor) {
+ var component = this.component;
+
+ return instrumentation_support.instrument(component, function () {
+ var newEnv = env;
+ if (component) {
+ newEnv = merge['default']({}, env);
+ newEnv.view = component;
+
+ var snapshot = takeSnapshot(attrs);
+
+ // Notify component that it has become dirty and is about to change.
+ env.renderer.willUpdate(component, snapshot);
+
+ if (component._renderNode.shouldReceiveAttrs) {
+ env.renderer.updateAttrs(component, snapshot);
+ setProperties['default'](component, mergeBindings({}, shadowedAttrs(component, snapshot)));
+ component._renderNode.shouldReceiveAttrs = false;
+ }
+
+ env.renderer.willRender(component);
+
+ env.renderedViews.push(component.elementId);
+ }
+ if (this.block) {
+ this.block(newEnv, [], undefined, this.renderNode, this.scope, visitor);
+ }
+
+ if (component) {
+ env.lifecycleHooks.push({ type: "didUpdate", view: component });
+ }
+
+ return newEnv;
+ }, this);
+ };
+ function createOrUpdateComponent(component, options, createOptions, renderNode, env) {
+ var attrs = arguments[5] === undefined ? {} : arguments[5];
+
+ var snapshot = takeSnapshot(attrs);
+ var props = merge['default']({}, options);
+ var defaultController = View['default'].proto().controller;
+ var hasSuppliedController = "controller" in attrs || "controller" in props;
+
+ props.attrs = snapshot;
+ if (component.create) {
+ var proto = component.proto();
+
+ if (createOptions) {
+ merge['default'](props, createOptions);
+ }
+
+ mergeBindings(props, shadowedAttrs(proto, snapshot));
+ props.container = options.parentView ? options.parentView.container : env.container;
+
+ if (proto.controller !== defaultController || hasSuppliedController) {
+ delete props._context;
+ }
+
+ component = component.create(props);
+ } else {
+ mergeBindings(props, shadowedAttrs(component, snapshot));
+ setProperties['default'](component, props);
+ }
+
+ if (options.parentView) {
+ options.parentView.appendChild(component);
+
+ if (options.viewName) {
+ property_set.set(options.parentView, options.viewName, component);
+ }
+ }
+
+ component._renderNode = renderNode;
+ renderNode.emberView = component;
+ return component;
+ }
+
+ function shadowedAttrs(target, attrs) {
+ var shadowed = {};
+
+ // For backwards compatibility, set the component property
+ // if it has an attr with that name. Undefined attributes
+ // are handled on demand via the `unknownProperty` hook.
+ for (var attr in attrs) {
+ if (attr in target) {
+ // TODO: Should we issue a deprecation here?
+ //Ember.deprecate(deprecation(attr));
+ shadowed[attr] = attrs[attr];
+ }
+ }
+
+ return shadowed;
+ }
+
+ function takeSnapshot(attrs) {
+ var hash = {};
+
+ for (var prop in attrs) {
+ hash[prop] = getCellOrValue['default'](attrs[prop]);
+ }
+
+ return hash;
+ }
+
+ function mergeBindings(target, attrs) {
+ for (var prop in attrs) {
+ if (!attrs.hasOwnProperty(prop)) {
+ continue;
+ }
+ // when `attrs` is an actual value being set in the
+ // attrs hash (`{{foo-bar attrs="blah"}}`) we cannot
+ // set `"blah"` to the root of the target because
+ // that would replace all attrs with `attrs.attrs`
+ if (prop === "attrs") {
+ Ember['default'].warn("Invoking a component with a hash attribute named `attrs` is not supported. Please refactor usage of " + target + " to avoid passing `attrs` as a hash parameter.");
+ continue;
+ }
+ var value = attrs[prop];
+
+ if (value && value[attrs_proxy.MUTABLE_CELL]) {
+ target[prop] = value.value;
+ } else {
+ target[prop] = value;
+ }
+ }
+
+ return target;
+ }
+
+});
enifed('ember-htmlbars/system/append-templated-view', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-views/views/view'], function (exports, Ember, property_get, View) {
'use strict';
@@ -6981,21 +9082,21 @@
viewProto = viewClassOrInstance;
} else {
viewProto = viewClassOrInstance.proto();
}
- Ember['default'].assert("You cannot provide a template block if you also specified a templateName", !props.template || !property_get.get(props, 'templateName') && !property_get.get(viewProto, 'templateName'));
+ Ember['default'].assert("You cannot provide a template block if you also specified a templateName", !props.template || !property_get.get(props, "templateName") && !property_get.get(viewProto, "templateName"));
// We only want to override the `_context` computed property if there is
// no specified controller. See View#_context for more information.
var noControllerInProto = !viewProto.controller;
if (viewProto.controller && viewProto.controller.isDescriptor) {
noControllerInProto = true;
}
if (noControllerInProto && !viewProto.controllerBinding && !props.controller && !props.controllerBinding) {
- props._context = property_get.get(parentView, 'context'); // TODO: is this right?!
+ props._context = property_get.get(parentView, "context"); // TODO: is this right?!
}
props._morph = morph;
return parentView.appendChild(viewClassOrInstance, props);
@@ -7012,26 +9113,34 @@
@module ember
@submodule ember-htmlbars
*/
function bootstrap(ctx) {
- var selectors = 'script[type="text/x-handlebars"], script[type="text/x-raw-handlebars"]';
+ var selectors = "script[type=\"text/x-handlebars\"], script[type=\"text/x-raw-handlebars\"]";
jQuery['default'](selectors, ctx).each(function () {
// Get a reference to the script tag
var script = jQuery['default'](this);
- var compile = script.attr('type') === 'text/x-raw-handlebars' ? jQuery['default'].proxy(Handlebars.compile, Handlebars) : htmlbarsCompile['default'];
// Get the name of the script, used by Ember.View's templateName property.
// First look for data-template-name attribute, then fall back to its
// id if no name is found.
- var templateName = script.attr('data-template-name') || script.attr('id') || 'application';
- var template = compile(script.html());
+ var templateName = script.attr("data-template-name") || script.attr("id") || "application";
+ var template, compile;
+ if (script.attr("type") === "text/x-raw-handlebars") {
+ compile = jQuery['default'].proxy(Handlebars.compile, Handlebars);
+ template = compile(script.html());
+ } else {
+ template = htmlbarsCompile['default'](script.html(), {
+ moduleName: templateName
+ });
+ }
+
// Check if template of same name already exists
if (Ember['default'].TEMPLATES[templateName] !== undefined) {
- throw new EmberError['default']('Template named "' + templateName + '" already exists.');
+ throw new EmberError['default']("Template named \"" + templateName + "\" already exists.");
}
// For templates which have a name, we save them and then remove them from the DOM
Ember['default'].TEMPLATES[templateName] = template;
@@ -7043,11 +9152,11 @@
function _bootstrap() {
bootstrap(jQuery['default'](document));
}
function registerComponentLookup(registry) {
- registry.register('component-lookup:main', ComponentLookup['default']);
+ registry.register("component-lookup:main", ComponentLookup['default']);
}
/*
We tie this to application.load to ensure that we've at least
attempted to bootstrap at the point that the application is loaded.
@@ -7057,26 +9166,41 @@
There's no harm to running this twice, since we remove the templates
from the DOM after processing.
*/
- lazy_load.onLoad('Ember.Application', function (Application) {
+ lazy_load.onLoad("Ember.Application", function (Application) {
Application.initializer({
- name: 'domTemplates',
+ name: "domTemplates",
initialize: environment['default'].hasDOM ? _bootstrap : function () {}
});
Application.initializer({
- name: 'registerComponentLookup',
- after: 'domTemplates',
+ name: "registerComponentLookup",
+ after: "domTemplates",
initialize: registerComponentLookup
});
});
exports['default'] = bootstrap;
});
+enifed('ember-htmlbars/system/dom-helper', ['exports', 'dom-helper', 'ember-htmlbars/morphs/morph', 'ember-htmlbars/morphs/attr-morph', 'ember-metal/platform/create'], function (exports, DOMHelper, EmberMorph, EmberAttrMorph, o_create) {
+
+ 'use strict';
+
+ function EmberDOMHelper(_document) {
+ DOMHelper['default'].call(this, _document);
+ }
+
+ var proto = EmberDOMHelper.prototype = o_create['default'](DOMHelper['default'].prototype);
+ proto.MorphClass = EmberMorph['default'];
+ proto.AttrMorphClass = EmberAttrMorph['default'];
+
+ exports['default'] = EmberDOMHelper;
+
+});
enifed('ember-htmlbars/system/helper', ['exports'], function (exports) {
'use strict';
/**
@@ -7096,40 +9220,103 @@
}
exports['default'] = Helper;
});
+enifed('ember-htmlbars/system/instrumentation-support', ['exports', 'ember-metal/instrumentation'], function (exports, instrumentation) {
+
+ 'use strict';
+
+ exports.instrument = instrument;
+
+ /**
+ * Provides instrumentation for node managers.
+ *
+ * Wrap your node manager's render and re-render methods
+ * with this function.
+ *
+ * @param {Object} component Component or View instance (optional)
+ * @param {Function} callback The function to instrument
+ * @param {Object} context The context to call the function with
+ * @return {Object} Return value from the invoked callback
+ */
+ function instrument(component, callback, context) {
+ var instrumentName, val, details, end;
+ // Only instrument if there's at least one subscriber.
+ if (instrumentation.subscribers.length) {
+ if (component) {
+ instrumentName = component.instrumentName;
+ } else {
+ instrumentName = 'node';
+ }
+ details = {};
+ if (component) {
+ component.instrumentDetails(details);
+ }
+ end = instrumentation._instrumentStart('render.' + instrumentName, function viewInstrumentDetails() {
+ return details;
+ });
+ val = callback.call(context);
+ if (end) {
+ end();
+ }
+ return val;
+ } else {
+ return callback.call(context);
+ }
+ }
+
+});
enifed('ember-htmlbars/system/lookup-helper', ['exports', 'ember-metal/core', 'ember-metal/cache', 'ember-htmlbars/system/make-view-helper', 'ember-htmlbars/compat/helper'], function (exports, Ember, Cache, makeViewHelper, HandlebarsCompatibleHelper) {
'use strict';
+ exports.findHelper = findHelper;
+
+ /**
+ Used to lookup/resolve handlebars helpers. The lookup order is:
+
+ * Look for a registered helper
+ * If a dash exists in the name:
+ * Look for a helper registed in the container
+ * Use Ember.ComponentLookup to find an Ember.Component that resolves
+ to the given name
+
+ @private
+ @method resolveHelper
+ @param {Container} container
+ @param {String} name the name of the helper to lookup
+ @return {Handlebars Helper}
+ */
exports['default'] = lookupHelper;
/**
@module ember
@submodule ember-htmlbars
*/
var ISNT_HELPER_CACHE = new Cache['default'](1000, function (key) {
- return key.indexOf('-') === -1;
- });
-
- function lookupHelper(name, view, env) {
+ return key.indexOf("-") === -1;
+ });function findHelper(name, view, env) {
var helper = env.helpers[name];
if (helper) {
return helper;
}
- var container = view.container;
+ var container = env.container;
if (!container || ISNT_HELPER_CACHE.get(name)) {
return;
}
- var helperName = 'helper:' + name;
+ if (name in env.hooks.keywords) {
+ return;
+ }
+
+ var helperName = "helper:" + name;
helper = container.lookup(helperName);
if (!helper) {
- var componentLookup = container.lookup('component-lookup:main');
+ var componentLookup = container.lookup("component-lookup:main");
Ember['default'].assert("Could not find 'component-lookup:main' on the provided container," + " which is necessary for performing component lookups", componentLookup);
var Component = componentLookup.lookupFactory(name, container);
if (Component) {
helper = makeViewHelper['default'](Component);
@@ -7144,477 +9331,742 @@
}
return helper;
}
- exports.ISNT_HELPER_CACHE = ISNT_HELPER_CACHE;
+ function lookupHelper(name, view, env) {
+ var helper = findHelper(name, view, env);
-});
-enifed('ember-htmlbars/system/make-view-helper', ['exports', 'ember-metal/core', 'ember-htmlbars/system/helper'], function (exports, Ember, Helper) {
+ Ember['default'].assert("A helper named '" + name + "' could not be found", !!helper);
- 'use strict';
-
-
- exports['default'] = makeViewHelper;
- /**
- @module ember
- @submodule ember-htmlbars
- */
-
- function makeViewHelper(ViewClass) {
- function helperFunc(params, hash, options, env) {
- Ember['default'].assert("You can only pass attributes (such as name=value) not bare " + "values to a helper for a View found in '" + ViewClass.toString() + "'", params.length === 0);
-
- return env.helpers.view.helperFunction.call(this, [ViewClass], hash, options, env);
- }
-
- return new Helper['default'](helperFunc);
+ return helper;
}
+ exports.ISNT_HELPER_CACHE = ISNT_HELPER_CACHE;
+
});
-enifed('ember-htmlbars/system/make_bound_helper', ['exports', 'ember-metal/core', 'ember-htmlbars/system/helper', 'ember-metal/streams/stream', 'ember-metal/streams/utils'], function (exports, Ember, Helper, Stream, utils) {
+enifed('ember-htmlbars/system/make-view-helper', ['exports'], function (exports) {
'use strict';
-
- exports['default'] = makeBoundHelper;
/**
@module ember
@submodule ember-htmlbars
*/
- function makeBoundHelper(fn) {
- function helperFunc(params, hash, options, env) {
- var view = env.data.view;
- var numParams = params.length;
- var param, prop;
+ /**
+ Returns a helper function that renders the provided ViewClass.
- Ember['default'].assert("makeBoundHelper generated helpers do not support use with blocks", !options.template);
+ Used internally by Ember.Handlebars.helper and other methods
+ involving helper/component registration.
- function valueFn() {
- return fn.call(view, utils.readArray(params), utils.readHash(hash), options, env);
- }
+ @private
+ @method makeViewHelper
+ @param {Function} ViewClass view class constructor
+ @since 1.2.0
+ */
+ exports['default'] = makeViewHelper;
- // If none of the hash parameters are bound, act as an unbound helper.
- // This prevents views from being unnecessarily created
- var hasStream = utils.scanArray(params) || utils.scanHash(hash);
- if (hasStream) {
- var lazyValue = new Stream['default'](valueFn);
-
- for (var i = 0; i < numParams; i++) {
- param = params[i];
- utils.subscribe(param, lazyValue.notify, lazyValue);
- }
-
- for (prop in hash) {
- param = hash[prop];
- utils.subscribe(param, lazyValue.notify, lazyValue);
- }
-
- return lazyValue;
- } else {
- return valueFn();
- }
- }
-
- return new Helper['default'](helperFunc);
+ function makeViewHelper(ViewClass) {
+ return {
+ isLegacyViewHelper: true,
+ isHTMLBars: true,
+ viewClass: ViewClass
+ };
}
});
-enifed('ember-htmlbars/system/merge-view-bindings', ['exports', 'ember-metal/core', 'ember-metal/mixin', 'ember-metal/streams/simple', 'ember-metal/streams/utils', 'ember-views/streams/class_name_binding'], function (exports, Ember, mixin, SimpleStream, utils, class_name_binding) {
+enifed('ember-htmlbars/system/make_bound_helper', ['exports', 'ember-htmlbars/system/helper', 'ember-metal/streams/utils'], function (exports, Helper, utils) {
'use strict';
- exports['default'] = mergeViewBindings;
+ /**
+ Create a bound helper. Accepts a function that receives the ordered and hash parameters
+ from the template. If a bound property was provided in the template it will be resolved to its
+ value and any changes to the bound property cause the helper function to be re-run with the updated
+ values.
- var a_push = Array.prototype.push;
- function mergeViewBindings(view, props, hash) {
- mergeGenericViewBindings(view, props, hash);
- mergeDOMViewBindings(view, props, hash);
- return props;
- }
+ * `params` - An array of resolved ordered parameters.
+ * `hash` - An object containing the hash parameters.
- function mergeGenericViewBindings(view, props, hash) {
- for (var key in hash) {
- if (key === 'id' || key === 'tag' || key === 'class' || key === 'classBinding' || key === 'classNameBindings' || key === 'attributeBindings') {
- continue;
- }
+ For example:
- var value = hash[key];
+ * With an unquoted ordered parameter:
- if (mixin.IS_BINDING.test(key)) {
- if (typeof value === 'string') {
- Ember['default'].deprecate("You're attempting to render a view by passing " + key + " " + "to a view helper, but this syntax is deprecated. You should use `" + key.slice(0, -7) + "=someValue` instead.");
+ ```javascript
+ {{x-capitalize foo}}
+ ```
- props[key] = view._getBindingForStream(value);
- } else if (utils.isStream(value)) {
- Ember['default'].deprecate("You're attempting to render a view by passing " + key + " " + "to a view helper without a quoted value, but this syntax is " + "ambiguous. You should either surround " + key + "'s value in " + "quotes or remove `Binding` from " + key + ".");
+ Assuming `foo` was set to `"bar"`, the bound helper would receive `["bar"]` as its first argument, and
+ an empty hash as its second.
- props[key] = view._getBindingForStream(value);
- } else {
- props[key] = value;
- }
- } else {
- if (utils.isStream(value)) {
- props[key + 'Binding'] = view._getBindingForStream(value);
- } else {
- props[key] = value;
- }
- }
- }
- }
+ * With a quoted ordered parameter:
- function mergeDOMViewBindings(view, props, hash) {
- Ember['default'].assert("Setting 'attributeBindings' via template helpers is not allowed. " + "Please subclass Ember.View and set it there instead.", !hash.attributeBindings);
+ ```javascript
+ {{x-capitalize "foo"}}
+ ```
- if (hash.id) {
- props.id = props.elementId = utils.read(hash.id);
- }
+ The bound helper would receive `["foo"]` as its first argument, and an empty hash as its second.
- if (hash.tag) {
- props.tagName = utils.read(hash.tag);
- }
+ * With an unquoted hash parameter:
- var classBindings = [];
+ ```javascript
+ {{x-repeat "foo" count=repeatCount}}
+ ```
- if (hash['class']) {
- if (typeof hash['class'] === 'string') {
- props.classNames = hash['class'].split(' ');
- } else if (hash['class']._label) {
- // label exists for via property paths in the template
- // but not for streams with nested sub-expressions
- classBindings.push(hash['class']._label);
- } else {
- // this stream did not have a label which means that
- // it is not a simple property path type stream (likely
- // the result of a sub-expression)
- classBindings.push(hash['class']);
- }
- }
+ Assuming that `repeatCount` resolved to 2, the bound helper would receive `["foo"]` as its first argument,
+ and { count: 2 } as its second.
- if (hash.classBinding) {
- a_push.apply(classBindings, hash.classBinding.split(' '));
- }
+ @private
+ @method makeBoundHelper
+ @for Ember.HTMLBars
+ @param {Function} function
+ @since 1.10.0
+ */
+ exports['default'] = makeBoundHelper;
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
- if (hash.classNameBindings) {
- a_push.apply(classBindings, hash.classNameBindings.split(' '));
- }
-
- if (classBindings.length > 0) {
- props.classNameBindings = classBindings;
-
- for (var i = 0; i < classBindings.length; i++) {
- var initialValue = classBindings[i];
- var classBinding;
-
- if (utils.isStream(initialValue)) {
- classBinding = initialValue;
- } else {
- classBinding = class_name_binding.streamifyClassNameBinding(view, initialValue);
- }
-
- if (utils.isStream(classBinding)) {
- classBindings[i] = classBinding;
- } else {
- classBindings[i] = new SimpleStream['default'](classBinding);
- }
- }
- }
+ function makeBoundHelper(fn) {
+ return new Helper['default'](function (params, hash, templates) {
+ Ember.assert("makeBoundHelper generated helpers do not support use with blocks", !templates.template.meta);
+ return fn(utils.readArray(params), utils.readHash(hash));
+ });
}
});
-enifed('ember-htmlbars/system/render-view', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-htmlbars/env'], function (exports, Ember, property_get, defaultEnv) {
+enifed('ember-htmlbars/system/render-view', ['exports', 'ember-htmlbars/env', 'ember-htmlbars/node-managers/view-node-manager'], function (exports, defaultEnv, view_node_manager) {
'use strict';
+ exports.renderHTMLBarsBlock = renderHTMLBarsBlock;
-
- exports['default'] = renderView;
-
- function renderView(view, buffer, template) {
- if (!template) {
- return;
- }
-
- var output;
-
- if (template.isHTMLBars) {
- Ember['default'].assert('template must be an object. Did you mean to call Ember.Handlebars.compile("...") or specify templateName instead?', typeof template === 'object');
- output = renderHTMLBarsTemplate(view, buffer, template);
- } else {
- Ember['default'].assert('template must be a function. Did you mean to call Ember.Handlebars.compile("...") or specify templateName instead?', typeof template === 'function');
- output = renderLegacyTemplate(view, buffer, template);
- }
-
- if (output !== undefined) {
- buffer.push(output);
- }
- }
-
- function renderHTMLBarsTemplate(view, buffer, template) {
- Ember['default'].assert('The template being rendered by `' + view + '` was compiled with `' + template.revision + '` which does not match `Ember@1.12.2` (this revision).', template.revision === 'Ember@1.12.2');
-
- var contextualElement = buffer.innerContextualElement();
- var args = view._blockArguments;
+ // This function only gets called once per render of a "root view" (`appendTo`). Otherwise,
+ // HTMLBars propagates the existing env and renders templates for a given render node.
+ function renderHTMLBarsBlock(view, block, renderNode) {
var env = {
- view: this,
+ lifecycleHooks: [],
+ renderedViews: [],
+ renderedNodes: {},
+ view: view,
+ outletState: view.outletState,
+ container: view.container,
+ renderer: view.renderer,
dom: view.renderer._dom,
hooks: defaultEnv['default'].hooks,
helpers: defaultEnv['default'].helpers,
- useFragmentCache: defaultEnv['default'].useFragmentCache,
- data: {
- view: view,
- buffer: buffer
- }
+ useFragmentCache: defaultEnv['default'].useFragmentCache
};
- return template.render(view, env, contextualElement, args);
- }
+ view.env = env;
+ view_node_manager.createOrUpdateComponent(view, {}, null, renderNode, env);
+ var nodeManager = new view_node_manager['default'](view, null, renderNode, block, view.tagName !== "");
- function renderLegacyTemplate(view, buffer, template) {
- var context = property_get.get(view, 'context');
- var options = {
- data: {
- view: view,
- buffer: buffer
- }
- };
-
- return template(context, options);
+ nodeManager.render(env, {});
}
});
enifed('ember-htmlbars/templates/component', ['exports', 'ember-template-compiler/system/template'], function (exports, template) {
'use strict';
exports['default'] = template['default']((function () {
return {
- isHTMLBars: true,
- revision: "Ember@1.12.2",
- blockParams: 0,
+ meta: {},
+ arity: 0,
cachedFragment: null,
hasRendered: false,
- build: function build(dom) {
+ buildFragment: function buildFragment(dom) {
var el0 = dom.createDocumentFragment();
var el1 = dom.createComment("");
dom.appendChild(el0, el1);
return el0;
},
- render: function render(context, env, contextualElement) {
- var dom = env.dom;
- var hooks = env.hooks,
- content = hooks.content;
- dom.detectNamespace(contextualElement);
- var fragment;
- if (env.useFragmentCache && dom.canClone) {
- if (this.cachedFragment === null) {
- fragment = this.build(dom);
- if (this.hasRendered) {
- this.cachedFragment = fragment;
- } else {
- this.hasRendered = true;
- }
- }
- if (this.cachedFragment) {
- fragment = dom.cloneNode(this.cachedFragment, true);
- }
- } else {
- fragment = this.build(dom);
- }
- var morph0 = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["content", "yield"]],
+ locals: [],
+ templates: []
+ };
+ })());
+
+});
+enifed('ember-htmlbars/templates/container-view', ['exports', 'ember-template-compiler/system/template'], function (exports, template) {
+
+ 'use strict';
+
+ exports['default'] = template['default']((function () {
+ var child0 = (function () {
+ return {
+ meta: {},
+ arity: 1,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["inline", "view", [["get", "childView"]], []]],
+ locals: ["childView"],
+ templates: []
+ };
+ })();
+ var child1 = (function () {
+ var child0 = (function () {
+ return {
+ meta: {},
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["inline", "view", [["get", "view._emptyView"]], ["_defaultTagName", ["get", "view._emptyViewTagName"]]]],
+ locals: [],
+ templates: []
+ };
+ })();
+ return {
+ meta: {},
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["block", "if", [["get", "view._emptyView"]], [], 0, null]],
+ locals: [],
+ templates: [child0]
+ };
+ })();
+ return {
+ meta: {},
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
dom.insertBoundary(fragment, 0);
- content(env, morph0, context, "yield");
- return fragment;
- }
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["block", "each", [["get", "view.childViews"]], ["key", "elementId"], 0, 1]],
+ locals: [],
+ templates: [child0, child1]
};
})());
});
enifed('ember-htmlbars/templates/empty', ['exports', 'ember-template-compiler/system/template'], function (exports, template) {
'use strict';
exports['default'] = template['default']((function () {
return {
- isHTMLBars: true,
- revision: "Ember@1.12.2",
- blockParams: 0,
+ meta: {},
+ arity: 0,
cachedFragment: null,
hasRendered: false,
- build: function build(dom) {
+ buildFragment: function buildFragment(dom) {
var el0 = dom.createDocumentFragment();
return el0;
},
- render: function render(context, env, contextualElement) {
- var dom = env.dom;
- dom.detectNamespace(contextualElement);
- var fragment;
- if (env.useFragmentCache && dom.canClone) {
- if (this.cachedFragment === null) {
- fragment = this.build(dom);
- if (this.hasRendered) {
- this.cachedFragment = fragment;
- } else {
- this.hasRendered = true;
- }
- }
- if (this.cachedFragment) {
- fragment = dom.cloneNode(this.cachedFragment, true);
- }
- } else {
- fragment = this.build(dom);
- }
- return fragment;
- }
+ buildRenderNodes: function buildRenderNodes() {
+ return [];
+ },
+ statements: [],
+ locals: [],
+ templates: []
};
})());
});
-enifed('ember-htmlbars/templates/link-to-escaped', ['exports', 'ember-template-compiler/system/template'], function (exports, template) {
+enifed('ember-htmlbars/templates/legacy-each', ['exports', 'ember-template-compiler/system/template'], function (exports, template) {
'use strict';
exports['default'] = template['default']((function () {
+ var child0 = (function () {
+ var child0 = (function () {
+ var child0 = (function () {
+ return {
+ meta: {},
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["inline", "legacy-yield", [["get", "item"]], []]],
+ locals: [],
+ templates: []
+ };
+ })();
+ return {
+ meta: {},
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["block", "view", [["get", "attrs.itemViewClass"]], ["controller", ["get", "item"], "tagName", ["get", "view._itemTagName"]], 0, null]],
+ locals: [],
+ templates: [child0]
+ };
+ })();
+ var child1 = (function () {
+ return {
+ meta: {},
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["inline", "legacy-yield", [["get", "item"]], ["controller", ["get", "item"]]]],
+ locals: [],
+ templates: []
+ };
+ })();
+ return {
+ meta: {},
+ arity: 1,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["block", "if", [["get", "attrs.itemViewClass"]], [], 0, 1]],
+ locals: ["item"],
+ templates: [child0, child1]
+ };
+ })();
+ var child1 = (function () {
+ var child0 = (function () {
+ return {
+ meta: {},
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["inline", "view", [["get", "attrs.emptyViewClass"]], ["tagName", ["get", "view._itemTagName"]]]],
+ locals: [],
+ templates: []
+ };
+ })();
+ return {
+ meta: {},
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["block", "if", [["get", "attrs.emptyViewClass"]], [], 0, null]],
+ locals: [],
+ templates: [child0]
+ };
+ })();
return {
- isHTMLBars: true,
- revision: "Ember@1.12.2",
- blockParams: 0,
+ meta: {},
+ arity: 0,
cachedFragment: null,
hasRendered: false,
- build: function build(dom) {
+ buildFragment: function buildFragment(dom) {
var el0 = dom.createDocumentFragment();
var el1 = dom.createComment("");
dom.appendChild(el0, el1);
return el0;
},
- render: function render(context, env, contextualElement) {
- var dom = env.dom;
- var hooks = env.hooks,
- content = hooks.content;
- dom.detectNamespace(contextualElement);
- var fragment;
- if (env.useFragmentCache && dom.canClone) {
- if (this.cachedFragment === null) {
- fragment = this.build(dom);
- if (this.hasRendered) {
- this.cachedFragment = fragment;
- } else {
- this.hasRendered = true;
- }
- }
- if (this.cachedFragment) {
- fragment = dom.cloneNode(this.cachedFragment, true);
- }
- } else {
- fragment = this.build(dom);
- }
- var morph0 = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["block", "each", [["get", "view._arrangedContent"]], [], 0, 1]],
+ locals: [],
+ templates: [child0, child1]
+ };
+ })());
+
+});
+enifed('ember-htmlbars/templates/link-to-escaped', ['exports', 'ember-template-compiler/system/template'], function (exports, template) {
+
+ 'use strict';
+
+ exports['default'] = template['default']((function () {
+ return {
+ meta: {},
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
dom.insertBoundary(fragment, 0);
- content(env, morph0, context, "linkTitle");
- return fragment;
- }
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["content", "linkTitle"]],
+ locals: [],
+ templates: []
};
})());
});
enifed('ember-htmlbars/templates/link-to-unescaped', ['exports', 'ember-template-compiler/system/template'], function (exports, template) {
'use strict';
exports['default'] = template['default']((function () {
return {
- isHTMLBars: true,
- revision: "Ember@1.12.2",
- blockParams: 0,
+ meta: {},
+ arity: 0,
cachedFragment: null,
hasRendered: false,
- build: function build(dom) {
+ buildFragment: function buildFragment(dom) {
var el0 = dom.createDocumentFragment();
var el1 = dom.createComment("");
dom.appendChild(el0, el1);
return el0;
},
- render: function render(context, env, contextualElement) {
- var dom = env.dom;
- var hooks = env.hooks,
- content = hooks.content;
- dom.detectNamespace(contextualElement);
- var fragment;
- if (env.useFragmentCache && dom.canClone) {
- if (this.cachedFragment === null) {
- fragment = this.build(dom);
- if (this.hasRendered) {
- this.cachedFragment = fragment;
- } else {
- this.hasRendered = true;
- }
- }
- if (this.cachedFragment) {
- fragment = dom.cloneNode(this.cachedFragment, true);
- }
- } else {
- fragment = this.build(dom);
- }
- var morph0 = dom.createUnsafeMorphAt(fragment, 0, 0, contextualElement);
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createUnsafeMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["content", "linkTitle"]],
+ locals: [],
+ templates: []
+ };
+ })());
+
+});
+enifed('ember-htmlbars/templates/link-to', ['exports', 'ember-template-compiler/system/template'], function (exports, template) {
+
+ 'use strict';
+
+ exports['default'] = template['default']((function () {
+ var child0 = (function () {
+ var child0 = (function () {
+ return {
+ meta: {},
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["content", "linkTitle"]],
+ locals: [],
+ templates: []
+ };
+ })();
+ var child1 = (function () {
+ return {
+ meta: {},
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createUnsafeMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["content", "linkTitle"]],
+ locals: [],
+ templates: []
+ };
+ })();
+ return {
+ meta: {},
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["block", "if", [["get", "attrs.escaped"]], [], 0, 1]],
+ locals: [],
+ templates: [child0, child1]
+ };
+ })();
+ var child1 = (function () {
+ return {
+ meta: {},
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["content", "yield"]],
+ locals: [],
+ templates: []
+ };
+ })();
+ return {
+ meta: {},
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
dom.insertBoundary(fragment, 0);
- content(env, morph0, context, "linkTitle");
- return fragment;
- }
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["block", "if", [["get", "linkTitle"]], [], 0, 1]],
+ locals: [],
+ templates: [child0, child1]
};
})());
});
-enifed('ember-htmlbars/templates/select-option', ['exports', 'ember-template-compiler/system/template'], function (exports, template) {
+enifed('ember-htmlbars/templates/select-optgroup', ['exports', 'ember-template-compiler/system/template'], function (exports, template) {
'use strict';
exports['default'] = template['default']((function () {
+ var child0 = (function () {
+ return {
+ meta: {},
+ arity: 1,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["inline", "view", [["get", "attrs.optionView"]], ["content", ["get", "item"], "selection", ["get", "attrs.selection"], "parentValue", ["get", "attrs.value"], "multiple", ["get", "attrs.multiple"], "optionLabelPath", ["get", "attrs.optionLabelPath"], "optionValuePath", ["get", "attrs.optionValuePath"]]]],
+ locals: ["item"],
+ templates: []
+ };
+ })();
return {
- isHTMLBars: true,
- revision: "Ember@1.12.2",
- blockParams: 0,
+ meta: {},
+ arity: 0,
cachedFragment: null,
hasRendered: false,
- build: function build(dom) {
+ buildFragment: function buildFragment(dom) {
var el0 = dom.createDocumentFragment();
var el1 = dom.createComment("");
dom.appendChild(el0, el1);
return el0;
},
- render: function render(context, env, contextualElement) {
- var dom = env.dom;
- var hooks = env.hooks,
- content = hooks.content;
- dom.detectNamespace(contextualElement);
- var fragment;
- if (env.useFragmentCache && dom.canClone) {
- if (this.cachedFragment === null) {
- fragment = this.build(dom);
- if (this.hasRendered) {
- this.cachedFragment = fragment;
- } else {
- this.hasRendered = true;
- }
- }
- if (this.cachedFragment) {
- fragment = dom.cloneNode(this.cachedFragment, true);
- }
- } else {
- fragment = this.build(dom);
- }
- var morph0 = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["block", "each", [["get", "attrs.content"]], [], 0, null]],
+ locals: [],
+ templates: [child0]
+ };
+ })());
+
+});
+enifed('ember-htmlbars/templates/select-option', ['exports', 'ember-template-compiler/system/template'], function (exports, template) {
+
+ 'use strict';
+
+ exports['default'] = template['default']((function () {
+ return {
+ meta: {},
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
dom.insertBoundary(fragment, 0);
- content(env, morph0, context, "view.label");
- return fragment;
- }
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["content", "view.label"]],
+ locals: [],
+ templates: []
};
})());
});
enifed('ember-htmlbars/templates/select', ['exports', 'ember-template-compiler/system/template'], function (exports, template) {
@@ -7622,272 +10074,244 @@
'use strict';
exports['default'] = template['default']((function () {
var child0 = (function () {
return {
- isHTMLBars: true,
- revision: "Ember@1.12.2",
- blockParams: 0,
+ meta: {},
+ arity: 0,
cachedFragment: null,
hasRendered: false,
- build: function build(dom) {
+ buildFragment: function buildFragment(dom) {
var el0 = dom.createDocumentFragment();
var el1 = dom.createElement("option");
dom.setAttribute(el1, "value", "");
var el2 = dom.createComment("");
dom.appendChild(el1, el2);
dom.appendChild(el0, el1);
return el0;
},
- render: function render(context, env, contextualElement) {
- var dom = env.dom;
- var hooks = env.hooks,
- content = hooks.content;
- dom.detectNamespace(contextualElement);
- var fragment;
- if (env.useFragmentCache && dom.canClone) {
- if (this.cachedFragment === null) {
- fragment = this.build(dom);
- if (this.hasRendered) {
- this.cachedFragment = fragment;
- } else {
- this.hasRendered = true;
- }
- }
- if (this.cachedFragment) {
- fragment = dom.cloneNode(this.cachedFragment, true);
- }
- } else {
- fragment = this.build(dom);
- }
- var morph0 = dom.createMorphAt(dom.childAt(fragment, [0]), 0, 0);
- content(env, morph0, context, "view.prompt");
- return fragment;
- }
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(dom.childAt(fragment, [0]), 0, 0);
+ return morphs;
+ },
+ statements: [["content", "view.prompt"]],
+ locals: [],
+ templates: []
};
})();
var child1 = (function () {
var child0 = (function () {
return {
- isHTMLBars: true,
- revision: "Ember@1.12.2",
- blockParams: 0,
+ meta: {},
+ arity: 1,
cachedFragment: null,
hasRendered: false,
- build: function build(dom) {
+ buildFragment: function buildFragment(dom) {
var el0 = dom.createDocumentFragment();
var el1 = dom.createComment("");
dom.appendChild(el0, el1);
return el0;
},
- render: function render(context, env, contextualElement) {
- var dom = env.dom;
- var hooks = env.hooks,
- get = hooks.get,
- inline = hooks.inline;
- dom.detectNamespace(contextualElement);
- var fragment;
- if (env.useFragmentCache && dom.canClone) {
- if (this.cachedFragment === null) {
- fragment = this.build(dom);
- if (this.hasRendered) {
- this.cachedFragment = fragment;
- } else {
- this.hasRendered = true;
- }
- }
- if (this.cachedFragment) {
- fragment = dom.cloneNode(this.cachedFragment, true);
- }
- } else {
- fragment = this.build(dom);
- }
- var morph0 = dom.createMorphAt(fragment, 0, 0, contextualElement);
- dom.insertBoundary(fragment, null);
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
dom.insertBoundary(fragment, 0);
- inline(env, morph0, context, "view", [get(env, context, "view.groupView")], { "content": get(env, context, "group.content"), "label": get(env, context, "group.label") });
- return fragment;
- }
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["inline", "view", [["get", "view.groupView"]], ["content", ["get", "group.content"], "label", ["get", "group.label"], "selection", ["get", "view.selection"], "multiple", ["get", "view.multiple"], "optionLabelPath", ["get", "view.optionLabelPath"], "optionValuePath", ["get", "view.optionValuePath"], "optionView", ["get", "view.optionView"]]]],
+ locals: ["group"],
+ templates: []
};
})();
return {
- isHTMLBars: true,
- revision: "Ember@1.12.2",
- blockParams: 0,
+ meta: {},
+ arity: 0,
cachedFragment: null,
hasRendered: false,
- build: function build(dom) {
+ buildFragment: function buildFragment(dom) {
var el0 = dom.createDocumentFragment();
var el1 = dom.createComment("");
dom.appendChild(el0, el1);
return el0;
},
- render: function render(context, env, contextualElement) {
- var dom = env.dom;
- var hooks = env.hooks,
- get = hooks.get,
- block = hooks.block;
- dom.detectNamespace(contextualElement);
- var fragment;
- if (env.useFragmentCache && dom.canClone) {
- if (this.cachedFragment === null) {
- fragment = this.build(dom);
- if (this.hasRendered) {
- this.cachedFragment = fragment;
- } else {
- this.hasRendered = true;
- }
- }
- if (this.cachedFragment) {
- fragment = dom.cloneNode(this.cachedFragment, true);
- }
- } else {
- fragment = this.build(dom);
- }
- var morph0 = dom.createMorphAt(fragment, 0, 0, contextualElement);
- dom.insertBoundary(fragment, null);
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
dom.insertBoundary(fragment, 0);
- block(env, morph0, context, "each", [get(env, context, "view.groupedContent")], { "keyword": "group" }, child0, null);
- return fragment;
- }
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["block", "each", [["get", "view.groupedContent"]], [], 0, null]],
+ locals: [],
+ templates: [child0]
};
})();
var child2 = (function () {
var child0 = (function () {
return {
- isHTMLBars: true,
- revision: "Ember@1.12.2",
- blockParams: 0,
+ meta: {},
+ arity: 1,
cachedFragment: null,
hasRendered: false,
- build: function build(dom) {
+ buildFragment: function buildFragment(dom) {
var el0 = dom.createDocumentFragment();
var el1 = dom.createComment("");
dom.appendChild(el0, el1);
return el0;
},
- render: function render(context, env, contextualElement) {
- var dom = env.dom;
- var hooks = env.hooks,
- get = hooks.get,
- inline = hooks.inline;
- dom.detectNamespace(contextualElement);
- var fragment;
- if (env.useFragmentCache && dom.canClone) {
- if (this.cachedFragment === null) {
- fragment = this.build(dom);
- if (this.hasRendered) {
- this.cachedFragment = fragment;
- } else {
- this.hasRendered = true;
- }
- }
- if (this.cachedFragment) {
- fragment = dom.cloneNode(this.cachedFragment, true);
- }
- } else {
- fragment = this.build(dom);
- }
- var morph0 = dom.createMorphAt(fragment, 0, 0, contextualElement);
- dom.insertBoundary(fragment, null);
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
dom.insertBoundary(fragment, 0);
- inline(env, morph0, context, "view", [get(env, context, "view.optionView")], { "content": get(env, context, "item") });
- return fragment;
- }
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["inline", "view", [["get", "view.optionView"]], ["content", ["get", "item"], "selection", ["get", "view.selection"], "parentValue", ["get", "view.value"], "multiple", ["get", "view.multiple"], "optionLabelPath", ["get", "view.optionLabelPath"], "optionValuePath", ["get", "view.optionValuePath"]]]],
+ locals: ["item"],
+ templates: []
};
})();
return {
- isHTMLBars: true,
- revision: "Ember@1.12.2",
- blockParams: 0,
+ meta: {},
+ arity: 0,
cachedFragment: null,
hasRendered: false,
- build: function build(dom) {
+ buildFragment: function buildFragment(dom) {
var el0 = dom.createDocumentFragment();
var el1 = dom.createComment("");
dom.appendChild(el0, el1);
return el0;
},
- render: function render(context, env, contextualElement) {
- var dom = env.dom;
- var hooks = env.hooks,
- get = hooks.get,
- block = hooks.block;
- dom.detectNamespace(contextualElement);
- var fragment;
- if (env.useFragmentCache && dom.canClone) {
- if (this.cachedFragment === null) {
- fragment = this.build(dom);
- if (this.hasRendered) {
- this.cachedFragment = fragment;
- } else {
- this.hasRendered = true;
- }
- }
- if (this.cachedFragment) {
- fragment = dom.cloneNode(this.cachedFragment, true);
- }
- } else {
- fragment = this.build(dom);
- }
- var morph0 = dom.createMorphAt(fragment, 0, 0, contextualElement);
- dom.insertBoundary(fragment, null);
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
dom.insertBoundary(fragment, 0);
- block(env, morph0, context, "each", [get(env, context, "view.content")], { "keyword": "item" }, child0, null);
- return fragment;
- }
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["block", "each", [["get", "view.content"]], [], 0, null]],
+ locals: [],
+ templates: [child0]
};
})();
return {
- isHTMLBars: true,
- revision: "Ember@1.12.2",
- blockParams: 0,
+ meta: {},
+ arity: 0,
cachedFragment: null,
hasRendered: false,
- build: function build(dom) {
+ buildFragment: function buildFragment(dom) {
var el0 = dom.createDocumentFragment();
var el1 = dom.createComment("");
dom.appendChild(el0, el1);
var el1 = dom.createComment("");
dom.appendChild(el0, el1);
var el1 = dom.createTextNode("\n");
dom.appendChild(el0, el1);
return el0;
},
- render: function render(context, env, contextualElement) {
- var dom = env.dom;
- var hooks = env.hooks,
- get = hooks.get,
- block = hooks.block;
- dom.detectNamespace(contextualElement);
- var fragment;
- if (env.useFragmentCache && dom.canClone) {
- if (this.cachedFragment === null) {
- fragment = this.build(dom);
- if (this.hasRendered) {
- this.cachedFragment = fragment;
- } else {
- this.hasRendered = true;
- }
- }
- if (this.cachedFragment) {
- fragment = dom.cloneNode(this.cachedFragment, true);
- }
- } else {
- fragment = this.build(dom);
- }
- var morph0 = dom.createMorphAt(fragment, 0, 0, contextualElement);
- var morph1 = dom.createMorphAt(fragment, 1, 1, contextualElement);
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(2);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ morphs[1] = dom.createMorphAt(fragment, 1, 1, contextualElement);
dom.insertBoundary(fragment, 0);
- block(env, morph0, context, "if", [get(env, context, "view.prompt")], {}, child0, null);
- block(env, morph1, context, "if", [get(env, context, "view.optionGroupPath")], {}, child1, child2);
- return fragment;
- }
+ return morphs;
+ },
+ statements: [["block", "if", [["get", "view.prompt"]], [], 0, null], ["block", "if", [["get", "view.optionGroupPath"]], [], 1, 2]],
+ locals: [],
+ templates: [child0, child1, child2]
};
})());
});
+enifed('ember-htmlbars/templates/top-level-view', ['exports', 'ember-template-compiler/system/template'], function (exports, template) {
+
+ 'use strict';
+
+ exports['default'] = template['default']((function () {
+ return {
+ meta: {},
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ var el1 = dom.createComment("");
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
+ var morphs = new Array(1);
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
+ dom.insertBoundary(fragment, 0);
+ dom.insertBoundary(fragment, null);
+ return morphs;
+ },
+ statements: [["content", "outlet"]],
+ locals: [],
+ templates: []
+ };
+ })());
+
+});
+enifed('ember-htmlbars/utils/is-component', ['exports'], function (exports) {
+
+ 'use strict';
+
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
+
+ /*
+ Given a path name, returns whether or not a component with that
+ name was found in the container.
+ */
+ exports['default'] = isComponent;
+
+ function isComponent(env, scope, path) {
+ var container = env.container;
+ if (!container) {
+ return false;
+ }
+
+ return container._registry.has('component:' + path) || container._registry.has('template:components/' + path);
+ }
+
+});
+enifed('ember-htmlbars/utils/lookup-component', ['exports'], function (exports) {
+
+ 'use strict';
+
+ exports['default'] = lookupComponent;
+
+ function lookupComponent(container, tagName) {
+ var componentLookup = container.lookup('component-lookup:main');
+
+ return {
+ component: componentLookup.componentFor(tagName, container),
+ layout: componentLookup.layoutFor(tagName, container)
+ };
+ }
+
+});
+enifed('ember-htmlbars/utils/normalize-self', ['exports'], function (exports) {
+
+ 'use strict';
+
+ exports['default'] = normalizeSelf;
+
+ function normalizeSelf(self) {
+ if (self === undefined) {
+ return null;
+ } else {
+ return self;
+ }
+ }
+
+});
enifed('ember-htmlbars/utils/string', ['exports', 'htmlbars-util', 'ember-runtime/system/string'], function (exports, htmlbars_util, EmberStringUtils) {
'use strict';
exports.htmlSafe = htmlSafe;
@@ -7901,12 +10325,12 @@
function htmlSafe(str) {
if (str === null || str === undefined) {
return "";
}
- if (typeof str !== 'string') {
- str = '' + str;
+ if (typeof str !== "string") {
+ str = "" + str;
}
return new htmlbars_util.SafeString(str);
}
EmberStringUtils['default'].htmlSafe = htmlSafe;
@@ -7929,325 +10353,334 @@
exports.SafeString = htmlbars_util.SafeString;
exports.escapeExpression = htmlbars_util.escapeExpression;
});
-enifed('ember-metal-views', ['exports', 'ember-metal-views/renderer'], function (exports, Renderer) {
+enifed('ember-htmlbars/utils/subscribe', ['exports', 'ember-metal/streams/utils'], function (exports, utils) {
- 'use strict';
+ 'use strict';
- exports.Renderer = Renderer['default'];
+ exports['default'] = subscribe;
+ function subscribe(node, env, scope, stream) {
+ if (!utils.isStream(stream)) {
+ return;
+ }
+ var component = scope.component;
+ var unsubscribers = node.streamUnsubscribers = node.streamUnsubscribers || [];
+ unsubscribers.push(stream.subscribe(function () {
+ node.isDirty = true;
+
+ // Whenever a render node directly inside a component becomes
+ // dirty, we want to invoke the willRenderElement and
+ // didRenderElement lifecycle hooks. From the perspective of the
+ // programming model, whenever anything in the DOM changes, a
+ // "re-render" has occured.
+ if (component && component._renderNode) {
+ component._renderNode.isDirty = true;
+ }
+
+ if (node.state.manager) {
+ node.shouldReceiveAttrs = true;
+ }
+
+ node.ownerNode.emberView.scheduleRevalidate(node, utils.labelFor(stream));
+ }));
+ }
+
});
-enifed('ember-metal-views/renderer', ['exports', 'dom-helper', 'ember-metal/environment'], function (exports, DOMHelper, environment) {
+enifed('ember-htmlbars/utils/update-scope', ['exports', 'ember-metal/streams/proxy-stream', 'ember-htmlbars/utils/subscribe'], function (exports, ProxyStream, subscribe) {
'use strict';
- var domHelper = environment['default'].hasDOM ? new DOMHelper['default']() : null;
- function Renderer(_helper, _destinedForDOM) {
- this._uuid = 0;
- // These sizes and values are somewhat arbitrary (but sensible)
- // pre-allocation defaults.
- this._views = new Array(2000);
- this._queue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
- this._parents = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
- this._elements = new Array(17);
- this._inserts = {};
- this._dom = _helper || domHelper;
- this._destinedForDOM = _destinedForDOM === undefined ? true : _destinedForDOM;
+ exports['default'] = updateScope;
+ function updateScope(scope, key, newValue, renderNode, isSelf) {
+ var existing = scope[key];
+
+ if (existing) {
+ existing.setSource(newValue);
+ } else {
+ var stream = new ProxyStream['default'](newValue, isSelf ? null : key);
+ if (renderNode) {
+ subscribe['default'](renderNode, scope, stream);
+ }
+ scope[key] = stream;
+ }
}
- function Renderer_renderTree(_view, _parentView, _refMorph) {
- var views = this._views;
- views[0] = _view;
- var index = 0;
- var total = 1;
- var levelBase = _parentView ? _parentView._level + 1 : 0;
+});
+enifed('ember-metal-views', ['exports', 'ember-metal-views/renderer'], function (exports, Renderer) {
- var root = _parentView == null ? _view : _parentView._root;
+ 'use strict';
- // if root view has a _morph assigned
- var willInsert = !!root._morph;
- var queue = this._queue;
- queue[0] = 0;
- var length = 1;
- var parentIndex = -1;
- var parents = this._parents;
- var parent = _parentView || null;
- var elements = this._elements;
- var element = null;
- var contextualElement = null;
- var level = 0;
+ exports.Renderer = Renderer['default'];
- var view = _view;
- var children, i, child;
- while (length) {
- elements[level] = element;
- if (!view._morph) {
- // ensure props we add are in same order
- view._morph = null;
- }
- view._root = root;
- this.uuid(view);
- view._level = levelBase + level;
- if (view._elementCreated) {
- this.remove(view, false, true);
- }
+});
+enifed('ember-metal-views/renderer', ['exports', 'ember-metal/run_loop', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-views/system/build-component-template', 'ember-metal/enumerable_utils'], function (exports, run, property_get, property_set, buildComponentTemplate, enumerable_utils) {
- this.willCreateElement(view);
+ 'use strict';
- contextualElement = view._morph && view._morph.contextualElement;
- if (!contextualElement && parent && parent._childViewsMorph) {
- contextualElement = parent._childViewsMorph.contextualElement;
- }
- if (!contextualElement && view._didCreateElementWithoutMorph) {
- // This code path is used by view.createElement(), which has two purposes:
- //
- // 1. Legacy usage of `createElement()`. Nobody really knows what the point
- // of that is. This usage may be removed in Ember 2.0.
- // 2. FastBoot, which creates an element and has no DOM to insert it into.
- //
- // For FastBoot purposes, rendering the DOM without a contextual element
- // should work fine, because it essentially re-emits the original markup
- // as a String, which will then be parsed again by the browser, which will
- // apply the appropriate parsing rules.
- contextualElement = typeof document !== 'undefined' ? document.body : null;
- }
- element = this.createElement(view, contextualElement);
+ function Renderer(_helper) {
+ this._dom = _helper;
+ }
- parents[level++] = parentIndex;
- parentIndex = index;
- parent = view;
+ Renderer.prototype.prerenderTopLevelView = function Renderer_prerenderTopLevelView(view, renderNode) {
+ if (view._state === "inDOM") {
+ throw new Error("You cannot insert a View that has already been rendered");
+ }
+ view.ownerView = renderNode.emberView = view;
+ view._renderNode = renderNode;
- // enqueue for end
- queue[length++] = index;
- // enqueue children
- children = this.childViews(view);
- if (children) {
- for (i = children.length - 1; i >= 0; i--) {
- child = children[i];
- index = total++;
- views[index] = child;
- queue[length++] = index;
- view = child;
- }
- }
+ var layout = property_get.get(view, "layout");
+ var template = property_get.get(view, "template");
- index = queue[--length];
- view = views[index];
+ var componentInfo = { component: view, layout: layout };
- while (parentIndex === index) {
- level--;
- view._elementCreated = true;
- this.didCreateElement(view);
- if (willInsert) {
- this.willInsertElement(view);
- }
+ var block = buildComponentTemplate['default'](componentInfo, {}, {
+ self: view,
+ templates: template ? { "default": template.raw } : undefined
+ }).block;
- if (level === 0) {
- length--;
- break;
- }
+ view.renderBlock(block, renderNode);
+ view.lastResult = renderNode.lastResult;
+ this.clearRenderedViews(view.env);
+ };
- parentIndex = parents[level];
- parent = parentIndex === -1 ? _parentView : views[parentIndex];
- this.insertElement(view, parent, element, null);
- index = queue[--length];
- view = views[index];
- element = elements[level];
- elements[level] = null;
+ Renderer.prototype.renderTopLevelView = function Renderer_renderTopLevelView(view, renderNode) {
+ // Check to see if insertion has been canceled
+ if (view._willInsert) {
+ view._willInsert = false;
+ this.prerenderTopLevelView(view, renderNode);
+ this.dispatchLifecycleHooks(view.env);
+ }
+ };
+
+ Renderer.prototype.revalidateTopLevelView = function Renderer_revalidateTopLevelView(view) {
+ // This guard prevents revalidation on an already-destroyed view.
+ if (view._renderNode.lastResult) {
+ view._renderNode.lastResult.revalidate(view.env);
+ // supports createElement, which operates without moving the view into
+ // the inDOM state.
+ if (view._state === "inDOM") {
+ this.dispatchLifecycleHooks(view.env);
}
+ this.clearRenderedViews(view.env);
}
+ };
- this.insertElement(view, _parentView, element, _refMorph);
+ Renderer.prototype.dispatchLifecycleHooks = function Renderer_dispatchLifecycleHooks(env) {
+ var ownerView = env.view;
- for (i = total - 1; i >= 0; i--) {
- if (willInsert) {
- views[i]._elementInserted = true;
- this.didInsertElement(views[i]);
+ var lifecycleHooks = env.lifecycleHooks;
+ var i, hook;
+
+ for (i = 0; i < lifecycleHooks.length; i++) {
+ hook = lifecycleHooks[i];
+ ownerView._dispatching = hook.type;
+
+ switch (hook.type) {
+ case "didInsertElement":
+ this.didInsertElement(hook.view);break;
+ case "didUpdate":
+ this.didUpdate(hook.view);break;
}
- views[i] = null;
+
+ this.didRender(hook.view);
}
- return element;
- }
-
- Renderer.prototype.uuid = function Renderer_uuid(view) {
- if (view._uuid === undefined) {
- view._uuid = ++this._uuid;
- view._renderer = this;
- } // else assert(view._renderer === this)
- return view._uuid;
+ ownerView._dispatching = null;
+ env.lifecycleHooks.length = 0;
};
- Renderer.prototype.scheduleInsert = function Renderer_scheduleInsert(view, morph) {
- if (view._morph || view._elementCreated) {
- throw new Error("You cannot insert a View that has already been rendered");
+ Renderer.prototype.ensureViewNotRendering = function Renderer_ensureViewNotRendering(view) {
+ var env = view.ownerView.env;
+ if (env && enumerable_utils.indexOf(env.renderedViews, view.elementId) !== -1) {
+ throw new Error("Something you did caused a view to re-render after it rendered but before it was inserted into the DOM.");
}
- Ember.assert("You cannot insert a View without a morph", morph);
- view._morph = morph;
- var viewId = this.uuid(view);
- this._inserts[viewId] = this.scheduleRender(this, function scheduledRenderTree() {
- this._inserts[viewId] = null;
- this.renderTree(view);
- });
};
+ Renderer.prototype.clearRenderedViews = function Renderer_clearRenderedViews(env) {
+ env.renderedNodes = {};
+ env.renderedViews.length = 0;
+ };
+
+ // This entry point is called from top-level `view.appendTo`
Renderer.prototype.appendTo = function Renderer_appendTo(view, target) {
var morph = this._dom.appendMorph(target);
- this.scheduleInsert(view, morph);
+ morph.ownerNode = morph;
+ view._willInsert = true;
+ run['default'].schedule("render", this, this.renderTopLevelView, view, morph);
};
- Renderer.prototype.appendAttrTo = function Renderer_appendAttrTo(view, target, attrName) {
- var morph = this._dom.createAttrMorph(target, attrName);
- this.scheduleInsert(view, morph);
+ Renderer.prototype.replaceIn = function Renderer_replaceIn(view, target) {
+ var morph = this._dom.replaceContentWithMorph(target);
+ morph.ownerNode = morph;
+ view._willInsert = true;
+ run['default'].scheduleOnce("render", this, this.renderTopLevelView, view, morph);
};
- Renderer.prototype.replaceIn = function Renderer_replaceIn(view, target) {
- var morph;
- if (target.firstChild) {
- morph = this._dom.createMorph(target, target.firstChild, target.lastChild);
- } else {
- morph = this._dom.appendMorph(target);
- }
- this.scheduleInsert(view, morph);
+ Renderer.prototype.createElement = function Renderer_createElement(view) {
+ var morph = this._dom.createFragmentMorph();
+ morph.ownerNode = morph;
+ this.prerenderTopLevelView(view, morph);
};
- function Renderer_remove(_view, shouldDestroy, reset) {
- var viewId = this.uuid(_view);
+ // inBuffer
+ Renderer.prototype.willCreateElement = function () {};
- if (this._inserts[viewId]) {
- this.cancelRender(this._inserts[viewId]);
- this._inserts[viewId] = undefined;
+ Renderer.prototype.didCreateElement = function (view, element) {
+ if (element) {
+ view.element = element;
}
- if (!_view._elementCreated) {
- return;
+ if (view._transitionTo) {
+ view._transitionTo("hasElement");
}
+ }; // hasElement
- var removeQueue = [];
- var destroyQueue = [];
- var morph = _view._morph;
- var idx, len, view, queue, childViews, i, l;
-
- removeQueue.push(_view);
-
- for (idx = 0; idx < removeQueue.length; idx++) {
- view = removeQueue[idx];
-
- if (!shouldDestroy && view._childViewsMorph) {
- queue = removeQueue;
- } else {
- queue = destroyQueue;
- }
-
- this.beforeRemove(removeQueue[idx]);
-
- childViews = this.childViews(view);
- if (childViews) {
- for (i = 0, l = childViews.length; i < l; i++) {
- queue.push(childViews[i]);
- }
- }
+ Renderer.prototype.willInsertElement = function (view) {
+ if (view.trigger) {
+ view.trigger("willInsertElement");
}
+ }; // will place into DOM
- for (idx = 0; idx < destroyQueue.length; idx++) {
- view = destroyQueue[idx];
+ Renderer.prototype.setAttrs = function (view, attrs) {
+ property_set.set(view, "attrs", attrs);
+ }; // set attrs the first time
- this.beforeRemove(destroyQueue[idx]);
+ Renderer.prototype.componentInitAttrs = function (component, attrs) {
+ property_set.set(component, "attrs", attrs);
+ component.trigger("didInitAttrs", { attrs: attrs });
+ component.trigger("didReceiveAttrs", { newAttrs: attrs });
+ }; // set attrs the first time
- childViews = this.childViews(view);
- if (childViews) {
- for (i = 0, l = childViews.length; i < l; i++) {
- destroyQueue.push(childViews[i]);
- }
- }
+ Renderer.prototype.didInsertElement = function (view) {
+ if (view._transitionTo) {
+ view._transitionTo("inDOM");
}
- // destroy DOM from root insertion
- if (morph && !reset) {
- morph.destroy();
+ if (view.trigger) {
+ view.trigger("didInsertElement");
}
+ }; // inDOM // placed into DOM
- for (idx = 0, len = removeQueue.length; idx < len; idx++) {
- this.afterRemove(removeQueue[idx], false);
+ Renderer.prototype.didUpdate = function (view) {
+ if (view.trigger) {
+ view.trigger("didUpdate");
}
+ };
- for (idx = 0, len = destroyQueue.length; idx < len; idx++) {
- this.afterRemove(destroyQueue[idx], true);
+ Renderer.prototype.didRender = function (view) {
+ if (view.trigger) {
+ view.trigger("didRender");
}
+ };
- if (reset) {
- _view._morph = morph;
+ Renderer.prototype.updateAttrs = function (view, attrs) {
+ if (view.willReceiveAttrs) {
+ view.willReceiveAttrs(attrs);
}
- }
- function Renderer_insertElement(view, parentView, element, refMorph) {
- if (element === null || element === undefined) {
- return;
- }
+ this.setAttrs(view, attrs);
+ }; // setting new attrs
- if (view._morph) {
- view._morph.setContent(element);
- } else if (parentView) {
- view._morph = parentView._childViewsMorph.insertContentBeforeMorph(element, refMorph);
+ Renderer.prototype.componentUpdateAttrs = function (component, oldAttrs, newAttrs) {
+ property_set.set(component, "attrs", newAttrs);
+
+ component.trigger("didUpdateAttrs", { oldAttrs: oldAttrs, newAttrs: newAttrs });
+ component.trigger("didReceiveAttrs", { oldAttrs: oldAttrs, newAttrs: newAttrs });
+ };
+
+ Renderer.prototype.willUpdate = function (view, attrs) {
+ if (view.willUpdate) {
+ view.willUpdate(attrs);
}
- }
+ };
- function Renderer_beforeRemove(view) {
- if (view._elementCreated) {
- this.willDestroyElement(view);
+ Renderer.prototype.componentWillUpdate = function (component) {
+ component.trigger("willUpdate");
+ };
+
+ Renderer.prototype.willRender = function (view) {
+ if (view.willRender) {
+ view.willRender();
}
- if (view._elementInserted) {
- this.willRemoveElement(view);
- }
- }
+ };
- function Renderer_afterRemove(view, shouldDestroy) {
- view._elementInserted = false;
- view._morph = null;
- view._childViewsMorph = null;
- if (view._elementCreated) {
- view._elementCreated = false;
+ Renderer.prototype.componentWillRender = function (component) {
+ component.trigger("willRender");
+ };
+
+ Renderer.prototype.remove = function (view, shouldDestroy) {
+ this.willDestroyElement(view);
+
+ view._willRemoveElement = true;
+ run['default'].schedule("render", this, this.renderElementRemoval, view);
+ };
+
+ Renderer.prototype.renderElementRemoval = function Renderer_renderElementRemoval(view) {
+ // Use the _willRemoveElement flag to avoid mulitple removal attempts in
+ // case many have been scheduled. This should be more performant than using
+ // `scheduleOnce`.
+ if (view._willRemoveElement) {
+ view._willRemoveElement = false;
+
+ if (view._renderNode) {
+ view._renderNode.clear();
+ }
this.didDestroyElement(view);
}
- if (shouldDestroy) {
- this.destroyView(view);
+ };
+
+ Renderer.prototype.willRemoveElement = function () {};
+
+ Renderer.prototype.willDestroyElement = function (view) {
+ if (view._willDestroyElement) {
+ view._willDestroyElement();
}
- }
+ if (view.trigger) {
+ view.trigger("willDestroyElement");
+ view.trigger("willClearRender");
+ }
- Renderer.prototype.remove = Renderer_remove;
- Renderer.prototype.removeAndDestroy = function (view) {
- this.remove(view, true);
+ view._transitionTo("destroying", false);
+
+ var childViews = view.childViews;
+ if (childViews) {
+ for (var i = 0; i < childViews.length; i++) {
+ this.willDestroyElement(childViews[i]);
+ }
+ }
};
- Renderer.prototype.renderTree = Renderer_renderTree;
- Renderer.prototype.insertElement = Renderer_insertElement;
- Renderer.prototype.beforeRemove = Renderer_beforeRemove;
- Renderer.prototype.afterRemove = Renderer_afterRemove;
+ Renderer.prototype.didDestroyElement = function (view) {
+ view.element = null;
- /// HOOKS
- var noop = function () {};
+ // Views that are being destroyed should never go back to the preRender state.
+ // However if we're just destroying an element on a view (as is the case when
+ // using View#remove) then the view should go to a preRender state so that
+ // it can be rendered again later.
+ if (view._state !== "destroying") {
+ view._transitionTo("preRender");
+ }
- Renderer.prototype.willCreateElement = noop; // inBuffer
- Renderer.prototype.createElement = noop; // renderToBuffer or createElement
- Renderer.prototype.didCreateElement = noop; // hasElement
- Renderer.prototype.willInsertElement = noop; // will place into DOM
- Renderer.prototype.didInsertElement = noop; // inDOM // placed into DOM
- Renderer.prototype.willRemoveElement = noop; // removed from DOM willDestroyElement currently paired with didInsertElement
- Renderer.prototype.willDestroyElement = noop; // willClearRender (currently balanced with render) this is now paired with createElement
- Renderer.prototype.didDestroyElement = noop; // element destroyed so view.destroy shouldn't try to remove it removedFromDOM
- Renderer.prototype.destroyView = noop;
- Renderer.prototype.childViews = noop;
+ var childViews = view.childViews;
+ if (childViews) {
+ for (var i = 0; i < childViews.length; i++) {
+ this.didDestroyElement(childViews[i]);
+ }
+ }
+ }; // element destroyed so view.destroy shouldn't try to remove it removedFromDOM
exports['default'] = Renderer;
+ /*view*/ /*view*/
});
enifed('ember-metal', ['exports', 'ember-metal/core', 'ember-metal/merge', 'ember-metal/instrumentation', 'ember-metal/utils', 'ember-metal/error', 'ember-metal/enumerable_utils', 'ember-metal/cache', 'ember-metal/platform/define_property', 'ember-metal/platform/create', 'ember-metal/array', 'ember-metal/logger', 'ember-metal/property_get', 'ember-metal/events', 'ember-metal/observer_set', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/property_set', 'ember-metal/map', 'ember-metal/get_properties', 'ember-metal/set_properties', 'ember-metal/watch_key', 'ember-metal/chains', 'ember-metal/watch_path', 'ember-metal/watching', 'ember-metal/expand_properties', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/computed_macros', 'ember-metal/observer', 'ember-metal/mixin', 'ember-metal/binding', 'ember-metal/run_loop', 'ember-metal/libraries', 'ember-metal/is_none', 'ember-metal/is_empty', 'ember-metal/is_blank', 'ember-metal/is_present', 'ember-metal/keys', 'backburner', 'ember-metal/streams/utils', 'ember-metal/streams/stream'], function (exports, Ember, merge, instrumentation, utils, EmberError, EnumerableUtils, Cache, define_property, create, array, Logger, property_get, events, ObserverSet, property_events, properties, property_set, map, getProperties, setProperties, watch_key, chains, watch_path, watching, expandProperties, computed, alias, computed_macros, observer, mixin, binding, run, Libraries, isNone, isEmpty, isBlank, isPresent, keys, Backburner, streams__utils, Stream) {
'use strict';
@@ -8278,11 +10711,14 @@
computed.computed.defaultTo = computed_macros.defaultTo;
computed.computed.deprecatingAlias = computed_macros.deprecatingAlias;
computed.computed.and = computed_macros.and;
computed.computed.or = computed_macros.or;
computed.computed.any = computed_macros.any;
- computed.computed.collect = computed_macros.collect;var EmberInstrumentation = Ember['default'].Instrumentation = {};
+ computed.computed.collect = computed_macros.collect; // END IMPORTS
+
+ // BEGIN EXPORTS
+ var EmberInstrumentation = Ember['default'].Instrumentation = {};
EmberInstrumentation.instrument = instrumentation.instrument;
EmberInstrumentation.subscribe = instrumentation.subscribe;
EmberInstrumentation.unsubscribe = instrumentation.unsubscribe;
EmberInstrumentation.reset = instrumentation.reset;
@@ -8314,13 +10750,11 @@
Ember['default'].meta = utils.meta;
Ember['default'].getMeta = utils.getMeta;
Ember['default'].setMeta = utils.setMeta;
Ember['default'].metaPath = utils.metaPath;
Ember['default'].inspect = utils.inspect;
- Ember['default'].typeOf = utils.typeOf;
Ember['default'].tryCatchFinally = utils.deprecatedTryCatchFinally;
- Ember['default'].isArray = utils.isArray;
Ember['default'].makeArray = utils.makeArray;
Ember['default'].canInvoke = utils.canInvoke;
Ember['default'].tryInvoke = utils.tryInvoke;
Ember['default'].tryFinally = utils.deprecatedTryFinally;
Ember['default'].wrap = utils.wrap;
@@ -8425,11 +10859,11 @@
* @private
*/
Ember['default'].Backburner = Backburner['default'];
Ember['default'].libraries = new Libraries['default']();
- Ember['default'].libraries.registerCoreLibrary('Ember', Ember['default'].VERSION);
+ Ember['default'].libraries.registerCoreLibrary("Ember", Ember['default'].VERSION);
Ember['default'].isNone = isNone['default'];
Ember['default'].isEmpty = isEmpty['default'];
Ember['default'].isBlank = isBlank['default'];
Ember['default'].isPresent = isPresent['default'];
@@ -8460,12 +10894,12 @@
Ember['default'].onerror = null;
// END EXPORTS
// do this for side-effects of updating Ember.assert, warn, etc when
// ember-debug is present
- if (Ember['default'].__loader.registry['ember-debug']) {
- requireModule('ember-debug');
+ if (Ember['default'].__loader.registry["ember-debug"]) {
+ requireModule("ember-debug");
}
exports['default'] = Ember['default'];
});
@@ -8556,11 +10990,11 @@
// Testing this is not ideal, but we want to use native functions
// if available, but not to use versions created by libraries like Prototype
var isNativeFunc = function (func) {
// This should probably work in all browsers likely to have ES5 array methods
- return func && Function.prototype.toString.call(func).indexOf('[native code]') > -1;
+ return func && Function.prototype.toString.call(func).indexOf("[native code]") > -1;
};
var defineNativeShim = function (nativeFunc, shim) {
if (isNativeFunc(nativeFunc)) {
return nativeFunc;
@@ -8688,10 +11122,154 @@
exports.bind = bind;
exports.oneWay = oneWay;
exports.Binding = Binding;
+ /**
+ An `Ember.Binding` connects the properties of two objects so that whenever
+ the value of one property changes, the other property will be changed also.
+
+ ## Automatic Creation of Bindings with `/^*Binding/`-named Properties
+
+ You do not usually create Binding objects directly but instead describe
+ bindings in your class or object definition using automatic binding
+ detection.
+
+ Properties ending in a `Binding` suffix will be converted to `Ember.Binding`
+ instances. The value of this property should be a string representing a path
+ to another object or a custom binding instance created using Binding helpers
+ (see "One Way Bindings"):
+
+ ```
+ valueBinding: "MyApp.someController.title"
+ ```
+
+ This will create a binding from `MyApp.someController.title` to the `value`
+ property of your object instance automatically. Now the two values will be
+ kept in sync.
+
+ ## One Way Bindings
+
+ One especially useful binding customization you can use is the `oneWay()`
+ helper. This helper tells Ember that you are only interested in
+ receiving changes on the object you are binding from. For example, if you
+ are binding to a preference and you want to be notified if the preference
+ has changed, but your object will not be changing the preference itself, you
+ could do:
+
+ ```
+ bigTitlesBinding: Ember.Binding.oneWay("MyApp.preferencesController.bigTitles")
+ ```
+
+ This way if the value of `MyApp.preferencesController.bigTitles` changes the
+ `bigTitles` property of your object will change also. However, if you
+ change the value of your `bigTitles` property, it will not update the
+ `preferencesController`.
+
+ One way bindings are almost twice as fast to setup and twice as fast to
+ execute because the binding only has to worry about changes to one side.
+
+ You should consider using one way bindings anytime you have an object that
+ may be created frequently and you do not intend to change a property; only
+ to monitor it for changes (such as in the example above).
+
+ ## Adding Bindings Manually
+
+ All of the examples above show you how to configure a custom binding, but the
+ result of these customizations will be a binding template, not a fully active
+ Binding instance. The binding will actually become active only when you
+ instantiate the object the binding belongs to. It is useful however, to
+ understand what actually happens when the binding is activated.
+
+ For a binding to function it must have at least a `from` property and a `to`
+ property. The `from` property path points to the object/key that you want to
+ bind from while the `to` path points to the object/key you want to bind to.
+
+ When you define a custom binding, you are usually describing the property
+ you want to bind from (such as `MyApp.someController.value` in the examples
+ above). When your object is created, it will automatically assign the value
+ you want to bind `to` based on the name of your binding key. In the
+ examples above, during init, Ember objects will effectively call
+ something like this on your binding:
+
+ ```javascript
+ binding = Ember.Binding.from("valueBinding").to("value");
+ ```
+
+ This creates a new binding instance based on the template you provide, and
+ sets the to path to the `value` property of the new object. Now that the
+ binding is fully configured with a `from` and a `to`, it simply needs to be
+ connected to become active. This is done through the `connect()` method:
+
+ ```javascript
+ binding.connect(this);
+ ```
+
+ Note that when you connect a binding you pass the object you want it to be
+ connected to. This object will be used as the root for both the from and
+ to side of the binding when inspecting relative paths. This allows the
+ binding to be automatically inherited by subclassed objects as well.
+
+ This also allows you to bind between objects using the paths you declare in
+ `from` and `to`:
+
+ ```javascript
+ // Example 1
+ binding = Ember.Binding.from("App.someObject.value").to("value");
+ binding.connect(this);
+
+ // Example 2
+ binding = Ember.Binding.from("parentView.value").to("App.someObject.value");
+ binding.connect(this);
+ ```
+
+ Now that the binding is connected, it will observe both the from and to side
+ and relay changes.
+
+ If you ever needed to do so (you almost never will, but it is useful to
+ understand this anyway), you could manually create an active binding by
+ using the `Ember.bind()` helper method. (This is the same method used by
+ to setup your bindings on objects):
+
+ ```javascript
+ Ember.bind(MyApp.anotherObject, "value", "MyApp.someController.value");
+ ```
+
+ Both of these code fragments have the same effect as doing the most friendly
+ form of binding creation like so:
+
+ ```javascript
+ MyApp.anotherObject = Ember.Object.create({
+ valueBinding: "MyApp.someController.value",
+
+ // OTHER CODE FOR THIS OBJECT...
+ });
+ ```
+
+ Ember's built in binding creation method makes it easy to automatically
+ create bindings for you. You should always use the highest-level APIs
+ available, even if you understand how it works underneath.
+
+ @class Binding
+ @namespace Ember
+ @since Ember 0.9
+ */
+ // Ember.Binding = Binding; ES6TODO: where to put this?
+
+ /**
+ Global helper method to create a new binding. Just pass the root object
+ along with a `to` and `from` path to create and connect the binding.
+
+ @method bind
+ @for Ember
+ @param {Object} obj The root object of the transform.
+ @param {String} to The path to the 'to' side of the binding.
+ Must be relative to obj.
+ @param {String} from The path to the 'from' side of the binding.
+ Must be relative to obj or a global path.
+ @return {Ember.Binding} binding instance
+ */
Ember['default'].LOG_BINDINGS = false || !!Ember['default'].ENV.LOG_BINDINGS;
/**
Returns true if the provided path is global (e.g., `MyApp.fooController.bar`)
instead of local (`foo.bar.baz`).
@@ -8790,11 +11368,11 @@
/**
@method toString
@return {String} string representation of binding
*/
toString: function () {
- var oneWay = this._oneWay ? '[oneWay]' : '';
+ var oneWay = this._oneWay ? "[oneWay]" : "";
return "Ember.Binding<" + utils.guidFor(this) + ">(" + this._from + " -> " + this._to + ")" + oneWay;
},
// ..........................................................
// CONNECT AND SYNC
@@ -8807,11 +11385,11 @@
@method connect
@param {Object} obj The root object for this binding.
@return {Ember.Binding} `this`
*/
connect: function (obj) {
- Ember['default'].assert('Must pass a valid object to Ember.Binding.connect()', !!obj);
+ Ember['default'].assert("Must pass a valid object to Ember.Binding.connect()", !!obj);
var fromPath = this._from;
var toPath = this._to;
property_set.trySet(obj, toPath, getWithGlobals(obj, fromPath));
@@ -8834,11 +11412,11 @@
@method disconnect
@param {Object} obj The root object you passed when connecting the binding.
@return {Ember.Binding} `this`
*/
disconnect: function (obj) {
- Ember['default'].assert('Must pass a valid object to Ember.Binding.disconnect()', !!obj);
+ Ember['default'].assert("Must pass a valid object to Ember.Binding.disconnect()", !!obj);
var twoWay = !this._oneWay;
// remove an observer on the object so we're no longer notified of
// changes that should update bindings.
@@ -8857,31 +11435,31 @@
// PRIVATE
//
/* called when the from side changes */
fromDidChange: function (target) {
- this._scheduleSync(target, 'fwd');
+ this._scheduleSync(target, "fwd");
},
/* called when the to side changes */
toDidChange: function (target) {
- this._scheduleSync(target, 'back');
+ this._scheduleSync(target, "back");
},
_scheduleSync: function (obj, dir) {
var existingDir = this._direction;
// if we haven't scheduled the binding yet, schedule it
if (existingDir === undefined) {
- run['default'].schedule('sync', this, this._sync, obj);
+ run['default'].schedule("sync", this, this._sync, obj);
this._direction = dir;
}
// If both a 'back' and 'fwd' sync have been scheduled on the same object,
// default to a 'fwd' sync so that it remains deterministic.
- if (existingDir === 'back' && dir === 'fwd') {
- this._direction = 'fwd';
+ if (existingDir === "back" && dir === "fwd") {
+ this._direction = "fwd";
}
},
_sync: function (obj) {
var log = Ember['default'].LOG_BINDINGS;
@@ -8899,32 +11477,32 @@
var toPath = this._to;
this._direction = undefined;
// if we're synchronizing from the remote object...
- if (direction === 'fwd') {
+ if (direction === "fwd") {
var fromValue = getWithGlobals(obj, this._from);
if (log) {
- Ember['default'].Logger.log(' ', this.toString(), '->', fromValue, obj);
+ Ember['default'].Logger.log(" ", this.toString(), "->", fromValue, obj);
}
if (this._oneWay) {
property_set.trySet(obj, toPath, fromValue);
} else {
observer._suspendObserver(obj, toPath, this, this.toDidChange, function () {
property_set.trySet(obj, toPath, fromValue);
});
}
// if we're synchronizing *to* the remote object
- } else if (direction === 'back') {
- var toValue = property_get.get(obj, this._to);
- if (log) {
- Ember['default'].Logger.log(' ', this.toString(), '<-', toValue, obj);
- }
- observer._suspendObserver(obj, fromPath, this, this.fromDidChange, function () {
- property_set.trySet(path_cache.isGlobal(fromPath) ? Ember['default'].lookup : obj, fromPath, toValue);
- });
+ } else if (direction === "back") {
+ var toValue = property_get.get(obj, this._to);
+ if (log) {
+ Ember['default'].Logger.log(" ", this.toString(), "<-", toValue, obj);
}
+ observer._suspendObserver(obj, fromPath, this, this.fromDidChange, function () {
+ property_set.trySet(path_cache.isGlobal(fromPath) ? Ember['default'].lookup : obj, fromPath, toValue);
+ });
+ }
}
};
function mixinProperties(to, from) {
@@ -8975,170 +11553,14 @@
var C = this;
return new C(undefined, from).oneWay(flag);
}
});
- /**
- An `Ember.Binding` connects the properties of two objects so that whenever
- the value of one property changes, the other property will be changed also.
-
- ## Automatic Creation of Bindings with `/^*Binding/`-named Properties
-
- You do not usually create Binding objects directly but instead describe
- bindings in your class or object definition using automatic binding
- detection.
-
- Properties ending in a `Binding` suffix will be converted to `Ember.Binding`
- instances. The value of this property should be a string representing a path
- to another object or a custom binding instance created using Binding helpers
- (see "One Way Bindings"):
-
- ```
- valueBinding: "MyApp.someController.title"
- ```
-
- This will create a binding from `MyApp.someController.title` to the `value`
- property of your object instance automatically. Now the two values will be
- kept in sync.
-
- ## One Way Bindings
-
- One especially useful binding customization you can use is the `oneWay()`
- helper. This helper tells Ember that you are only interested in
- receiving changes on the object you are binding from. For example, if you
- are binding to a preference and you want to be notified if the preference
- has changed, but your object will not be changing the preference itself, you
- could do:
-
- ```
- bigTitlesBinding: Ember.Binding.oneWay("MyApp.preferencesController.bigTitles")
- ```
-
- This way if the value of `MyApp.preferencesController.bigTitles` changes the
- `bigTitles` property of your object will change also. However, if you
- change the value of your `bigTitles` property, it will not update the
- `preferencesController`.
-
- One way bindings are almost twice as fast to setup and twice as fast to
- execute because the binding only has to worry about changes to one side.
-
- You should consider using one way bindings anytime you have an object that
- may be created frequently and you do not intend to change a property; only
- to monitor it for changes (such as in the example above).
-
- ## Adding Bindings Manually
-
- All of the examples above show you how to configure a custom binding, but the
- result of these customizations will be a binding template, not a fully active
- Binding instance. The binding will actually become active only when you
- instantiate the object the binding belongs to. It is useful however, to
- understand what actually happens when the binding is activated.
-
- For a binding to function it must have at least a `from` property and a `to`
- property. The `from` property path points to the object/key that you want to
- bind from while the `to` path points to the object/key you want to bind to.
-
- When you define a custom binding, you are usually describing the property
- you want to bind from (such as `MyApp.someController.value` in the examples
- above). When your object is created, it will automatically assign the value
- you want to bind `to` based on the name of your binding key. In the
- examples above, during init, Ember objects will effectively call
- something like this on your binding:
-
- ```javascript
- binding = Ember.Binding.from("valueBinding").to("value");
- ```
-
- This creates a new binding instance based on the template you provide, and
- sets the to path to the `value` property of the new object. Now that the
- binding is fully configured with a `from` and a `to`, it simply needs to be
- connected to become active. This is done through the `connect()` method:
-
- ```javascript
- binding.connect(this);
- ```
-
- Note that when you connect a binding you pass the object you want it to be
- connected to. This object will be used as the root for both the from and
- to side of the binding when inspecting relative paths. This allows the
- binding to be automatically inherited by subclassed objects as well.
-
- This also allows you to bind between objects using the paths you declare in
- `from` and `to`:
-
- ```javascript
- // Example 1
- binding = Ember.Binding.from("App.someObject.value").to("value");
- binding.connect(this);
-
- // Example 2
- binding = Ember.Binding.from("parentView.value").to("App.someObject.value");
- binding.connect(this);
- ```
-
- Now that the binding is connected, it will observe both the from and to side
- and relay changes.
-
- If you ever needed to do so (you almost never will, but it is useful to
- understand this anyway), you could manually create an active binding by
- using the `Ember.bind()` helper method. (This is the same method used by
- to setup your bindings on objects):
-
- ```javascript
- Ember.bind(MyApp.anotherObject, "value", "MyApp.someController.value");
- ```
-
- Both of these code fragments have the same effect as doing the most friendly
- form of binding creation like so:
-
- ```javascript
- MyApp.anotherObject = Ember.Object.create({
- valueBinding: "MyApp.someController.value",
-
- // OTHER CODE FOR THIS OBJECT...
- });
- ```
-
- Ember's built in binding creation method makes it easy to automatically
- create bindings for you. You should always use the highest-level APIs
- available, even if you understand how it works underneath.
-
- @class Binding
- @namespace Ember
- @since Ember 0.9
- */
- // Ember.Binding = Binding; ES6TODO: where to put this?
-
- /**
- Global helper method to create a new binding. Just pass the root object
- along with a `to` and `from` path to create and connect the binding.
-
- @method bind
- @for Ember
- @param {Object} obj The root object of the transform.
- @param {String} to The path to the 'to' side of the binding.
- Must be relative to obj.
- @param {String} from The path to the 'from' side of the binding.
- Must be relative to obj or a global path.
- @return {Ember.Binding} binding instance
- */
-
function bind(obj, to, from) {
return new Binding(to, from).connect(obj);
}
- /**
- @method oneWay
- @for Ember
- @param {Object} obj The root object of the transform.
- @param {String} to The path to the 'to' side of the binding.
- Must be relative to obj.
- @param {String} from The path to the 'from' side of the binding.
- Must be relative to obj or a global path.
- @return {Ember.Binding} binding instance
- */
-
function oneWay(obj, to, from) {
return new Binding(to, from).oneWay().connect(obj);
}
exports.isGlobalPath = path_cache.isGlobal;
@@ -9208,27 +11630,25 @@
exports.flushPendingChains = flushPendingChains;
exports.finishChains = finishChains;
exports.removeChainWatcher = removeChainWatcher;
exports.ChainNode = ChainNode;
+ // attempts to add the pendingQueue chains again. If some of them end up
+ // back in the queue and reschedule is true, schedules a timeout to try
+ // again.
var warn = Ember['default'].warn;
var FIRST_KEY = /^([^\.]+)/;
function firstKey(path) {
return path.match(FIRST_KEY)[0];
}
function isObject(obj) {
- return obj && typeof obj === 'object';
+ return obj && typeof obj === "object";
}
var pendingQueue = [];
-
- // attempts to add the pendingQueue chains again. If some of them end up
- // back in the queue and reschedule is true, schedules a timeout to try
- // again.
-
function flushPendingChains() {
if (pendingQueue.length === 0) {
return;
}
@@ -9237,22 +11657,22 @@
array.forEach.call(queue, function (q) {
q[0].add(q[1]);
});
- warn('Watching an undefined global, Ember expects watched globals to be' + ' setup by the time the run loop is flushed, check for typos', pendingQueue.length === 0);
+ warn("Watching an undefined global, Ember expects watched globals to be" + " setup by the time the run loop is flushed, check for typos", pendingQueue.length === 0);
}
function addChainWatcher(obj, keyName, node) {
if (!isObject(obj)) {
return;
}
var m = utils.meta(obj);
var nodes = m.chainWatchers;
- if (!m.hasOwnProperty('chainWatchers')) {
+ if (!m.hasOwnProperty("chainWatchers")) {
// FIXME?!
nodes = m.chainWatchers = {};
}
if (!nodes[keyName]) {
@@ -9265,14 +11685,14 @@
function removeChainWatcher(obj, keyName, node) {
if (!isObject(obj)) {
return;
}
- var m = obj['__ember_meta__'];
- if (m && !m.hasOwnProperty('chainWatchers')) {
+ var m = obj["__ember_meta__"];
+ if (m && !m.hasOwnProperty("chainWatchers")) {
return;
- }
+ } // nothing to do
var nodes = m && m.chainWatchers;
if (nodes && nodes[keyName]) {
nodes = nodes[keyName];
@@ -9313,21 +11733,21 @@
// Special-case: the EachProxy relies on immediate evaluation to
// establish its observers.
//
// TODO: Replace this with an efficient callback that the EachProxy
// can implement.
- if (this._parent && this._parent._key === '@each') {
+ if (this._parent && this._parent._key === "@each") {
this.value();
}
}
function lazyGet(obj, key) {
if (!obj) {
return;
}
- var meta = obj['__ember_meta__'];
+ var meta = obj["__ember_meta__"];
// check if object meant only to be a prototype
if (meta && meta.proto === obj) {
return;
}
@@ -9335,11 +11755,11 @@
return property_get.get(obj, key);
}
// if a CP only return cached value
var possibleDesc = obj[key];
- var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
+ var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined;
if (desc && desc._cacheable) {
if (meta.cache && key in meta.cache) {
return meta.cache[key];
} else {
return;
@@ -9402,20 +11822,20 @@
path = path.slice(key.length + 1);
// global path, but object does not exist yet.
// put into a queue and try to connect later.
} else if (!tuple[0]) {
- pendingQueue.push([this, path]);
- tuple.length = 0;
- return;
+ pendingQueue.push([this, path]);
+ tuple.length = 0;
+ return;
- // global path, and object already exists
- } else {
- src = tuple[0];
- key = path.slice(0, 0 - (tuple[1].length + 1));
- path = tuple[1];
- }
+ // global path, and object already exists
+ } else {
+ src = tuple[0];
+ key = path.slice(0, 0 - (tuple[1].length + 1));
+ path = tuple[1];
+ }
tuple.length = 0;
this.chain(key, path, src);
},
@@ -9503,38 +11923,38 @@
}
},
chainWillChange: function (chain, path, depth, events) {
if (this._key) {
- path = this._key + '.' + path;
+ path = this._key + "." + path;
}
if (this._parent) {
this._parent.chainWillChange(this, path, depth + 1, events);
} else {
if (depth > 1) {
events.push(this.value(), path);
}
- path = 'this.' + path;
+ path = "this." + path;
if (this._paths[path] > 0) {
events.push(this.value(), path);
}
}
},
chainDidChange: function (chain, path, depth, events) {
if (this._key) {
- path = this._key + '.' + path;
+ path = this._key + "." + path;
}
if (this._parent) {
this._parent.chainDidChange(this, path, depth + 1, events);
} else {
if (depth > 1) {
events.push(this.value(), path);
}
- path = 'this.' + path;
+ path = "this." + path;
if (this._paths[path] > 0) {
events.push(this.value(), path);
}
}
},
@@ -9550,11 +11970,11 @@
}
this._value = undefined;
// Special-case: the EachProxy relies on immediate evaluation to
// establish its observers.
- if (this._parent && this._parent._key === '@each') {
+ if (this._parent && this._parent._key === "@each") {
this.value();
}
}
// then notify chains...
@@ -9577,14 +11997,13 @@
if (this._parent) {
this._parent.chainDidChange(this, this._key, 1, events);
}
}
};
-
function finishChains(obj) {
// We only create meta if we really have to
- var m = obj['__ember_meta__'];
+ var m = obj["__ember_meta__"];
var chains, chainWatchers, chainNodes;
if (m) {
// finish any current chains node watchers that reference obj
chainWatchers = m.chainWatchers;
@@ -9729,14 +12148,14 @@
this._dependentKeys = undefined;
this._suspended = undefined;
this._meta = undefined;
- Ember.deprecate("Passing opts.cacheable to the CP constructor is deprecated. Invoke `volatile()` on the CP instead.", !opts || !opts.hasOwnProperty('cacheable'));
+ Ember.deprecate("Passing opts.cacheable to the CP constructor is deprecated. Invoke `volatile()` on the CP instead.", !opts || !opts.hasOwnProperty("cacheable"));
this._cacheable = opts && opts.cacheable !== undefined ? opts.cacheable : true; // TODO: Set always to `true` once this deprecation is gone.
this._dependentKeys = opts && opts.dependentKeys;
- Ember.deprecate("Passing opts.readOnly to the CP constructor is deprecated. All CPs are writable by default. You can invoke `readOnly()` on the CP to change this.", !opts || !opts.hasOwnProperty('readOnly'));
+ Ember.deprecate("Passing opts.readOnly to the CP constructor is deprecated. All CPs are writable by default. You can invoke `readOnly()` on the CP to change this.", !opts || !opts.hasOwnProperty("readOnly"));
this._readOnly = opts && (opts.readOnly !== undefined || !!opts.readOnly) || false; // TODO: Set always to `false` once this deprecation is gone.
}
ComputedProperty.prototype = new properties.Descriptor();
@@ -9757,11 +12176,11 @@
@return {Ember.ComputedProperty} this
@chainable
@deprecated All computed properties are cacheble by default. Use `volatile()` instead to opt-out to caching.
*/
ComputedPropertyPrototype.cacheable = function (aFlag) {
- Ember.deprecate('ComputedProperty.cacheable() is deprecated. All computed properties are cacheable by default.');
+ Ember.deprecate("ComputedProperty.cacheable() is deprecated. All computed properties are cacheable by default.");
this._cacheable = aFlag !== false;
return this;
};
/**
@@ -9804,14 +12223,13 @@
@method readOnly
@return {Ember.ComputedProperty} this
@chainable
*/
ComputedPropertyPrototype.readOnly = function (readOnly) {
- Ember.deprecate('Passing arguments to ComputedProperty.readOnly() is deprecated.', arguments.length === 0);
+ Ember.deprecate("Passing arguments to ComputedProperty.readOnly() is deprecated.", arguments.length === 0);
this._readOnly = readOnly === undefined || !!readOnly; // Force to true once this deprecation is gone
Ember.assert("Computed properties that define a setter using the new syntax cannot be read-only", !(this._readOnly && this._setter && this._setter !== this._getter));
-
return this;
};
/**
Sets the dependent keys on this computed property. Pass any number of
@@ -10177,12 +12595,10 @@
}
var cp = new ComputedProperty(func);
// jscs:disable
- // Empty block on purpose
-
if (args) {
cp.property.apply(cp, args);
}
return cp;
@@ -10200,11 +12616,11 @@
@param {String} key the name of the property whose cached value you want
to return
@return {Object} the cached value
*/
function cacheFor(obj, key) {
- var meta = obj['__ember_meta__'];
+ var meta = obj["__ember_meta__"];
var cache = meta && meta.cache;
var ret = cache && cache[key];
if (ret === UNDEFINED) {
return undefined;
@@ -10251,32 +12667,10 @@
exports.oneWay = oneWay;
exports.readOnly = readOnly;
exports.defaultTo = defaultTo;
exports.deprecatingAlias = deprecatingAlias;
- function getProperties(self, propertyNames) {
- var ret = {};
- for (var i = 0; i < propertyNames.length; i++) {
- ret[propertyNames[i]] = property_get.get(self, propertyNames[i]);
- }
- return ret;
- }
-
- function generateComputedWithProperties(macro) {
- return function () {
- for (var _len = arguments.length, properties = Array(_len), _key = 0; _key < _len; _key++) {
- properties[_key] = arguments[_key];
- }
-
- var computedFunc = computed.computed(function () {
- return macro.apply(this, [getProperties(this, properties)]);
- });
-
- return computedFunc.property.apply(computedFunc, properties);
- };
- }
-
/**
A computed property that returns true if the value of the dependent
property is null, an empty string, empty array, or empty function.
Example
@@ -10300,347 +12694,93 @@
@for Ember.computed
@param {String} dependentKey
@return {Ember.ComputedProperty} computed property which negate
the original value for property
*/
+ function getProperties(self, propertyNames) {
+ var ret = {};
+ for (var i = 0; i < propertyNames.length; i++) {
+ ret[propertyNames[i]] = property_get.get(self, propertyNames[i]);
+ }
+ return ret;
+ }
+ function generateComputedWithProperties(macro) {
+ return function () {
+ for (var _len = arguments.length, properties = Array(_len), _key = 0; _key < _len; _key++) {
+ properties[_key] = arguments[_key];
+ }
+
+ var computedFunc = computed.computed(function () {
+ return macro.apply(this, [getProperties(this, properties)]);
+ });
+
+ return computedFunc.property.apply(computedFunc, properties);
+ };
+ }
function empty(dependentKey) {
- return computed.computed(dependentKey + '.length', function () {
+ return computed.computed(dependentKey + ".length", function () {
return isEmpty['default'](property_get.get(this, dependentKey));
});
}
- /**
- A computed property that returns true if the value of the dependent
- property is NOT null, an empty string, empty array, or empty function.
-
- Example
-
- ```javascript
- var Hamster = Ember.Object.extend({
- hasStuff: Ember.computed.notEmpty('backpack')
- });
-
- var hamster = Hamster.create({ backpack: ['Food', 'Sleeping Bag', 'Tent'] });
-
- hamster.get('hasStuff'); // true
- hamster.get('backpack').clear(); // []
- hamster.get('hasStuff'); // false
- ```
-
- @method notEmpty
- @for Ember.computed
- @param {String} dependentKey
- @return {Ember.ComputedProperty} computed property which returns true if
- original value for property is not empty.
- */
-
function notEmpty(dependentKey) {
- return computed.computed(dependentKey + '.length', function () {
+ return computed.computed(dependentKey + ".length", function () {
return !isEmpty['default'](property_get.get(this, dependentKey));
});
}
- /**
- A computed property that returns true if the value of the dependent
- property is null or undefined. This avoids errors from JSLint complaining
- about use of ==, which can be technically confusing.
-
- Example
-
- ```javascript
- var Hamster = Ember.Object.extend({
- isHungry: Ember.computed.none('food')
- });
-
- var hamster = Hamster.create();
-
- hamster.get('isHungry'); // true
- hamster.set('food', 'Banana');
- hamster.get('isHungry'); // false
- hamster.set('food', null);
- hamster.get('isHungry'); // true
- ```
-
- @method none
- @for Ember.computed
- @param {String} dependentKey
- @return {Ember.ComputedProperty} computed property which
- returns true if original value for property is null or undefined.
- */
-
function none(dependentKey) {
return computed.computed(dependentKey, function () {
return isNone['default'](property_get.get(this, dependentKey));
});
}
- /**
- A computed property that returns the inverse boolean value
- of the original value for the dependent property.
-
- Example
-
- ```javascript
- var User = Ember.Object.extend({
- isAnonymous: Ember.computed.not('loggedIn')
- });
-
- var user = User.create({loggedIn: false});
-
- user.get('isAnonymous'); // true
- user.set('loggedIn', true);
- user.get('isAnonymous'); // false
- ```
-
- @method not
- @for Ember.computed
- @param {String} dependentKey
- @return {Ember.ComputedProperty} computed property which returns
- inverse of the original value for property
- */
-
function not(dependentKey) {
return computed.computed(dependentKey, function () {
return !property_get.get(this, dependentKey);
});
}
- /**
- A computed property that converts the provided dependent property
- into a boolean value.
-
- ```javascript
- var Hamster = Ember.Object.extend({
- hasBananas: Ember.computed.bool('numBananas')
- });
-
- var hamster = Hamster.create();
-
- hamster.get('hasBananas'); // false
- hamster.set('numBananas', 0);
- hamster.get('hasBananas'); // false
- hamster.set('numBananas', 1);
- hamster.get('hasBananas'); // true
- hamster.set('numBananas', null);
- hamster.get('hasBananas'); // false
- ```
-
- @method bool
- @for Ember.computed
- @param {String} dependentKey
- @return {Ember.ComputedProperty} computed property which converts
- to boolean the original value for property
- */
-
function bool(dependentKey) {
return computed.computed(dependentKey, function () {
return !!property_get.get(this, dependentKey);
});
}
- /**
- A computed property which matches the original value for the
- dependent property against a given RegExp, returning `true`
- if they values matches the RegExp and `false` if it does not.
-
- Example
-
- ```javascript
- var User = Ember.Object.extend({
- hasValidEmail: Ember.computed.match('email', /^.+@.+\..+$/)
- });
-
- var user = User.create({loggedIn: false});
-
- user.get('hasValidEmail'); // false
- user.set('email', '');
- user.get('hasValidEmail'); // false
- user.set('email', 'ember_hamster@example.com');
- user.get('hasValidEmail'); // true
- ```
-
- @method match
- @for Ember.computed
- @param {String} dependentKey
- @param {RegExp} regexp
- @return {Ember.ComputedProperty} computed property which match
- the original value for property against a given RegExp
- */
-
function match(dependentKey, regexp) {
return computed.computed(dependentKey, function () {
var value = property_get.get(this, dependentKey);
- return typeof value === 'string' ? regexp.test(value) : false;
+ return typeof value === "string" ? regexp.test(value) : false;
});
}
- /**
- A computed property that returns true if the provided dependent property
- is equal to the given value.
-
- Example
-
- ```javascript
- var Hamster = Ember.Object.extend({
- napTime: Ember.computed.equal('state', 'sleepy')
- });
-
- var hamster = Hamster.create();
-
- hamster.get('napTime'); // false
- hamster.set('state', 'sleepy');
- hamster.get('napTime'); // true
- hamster.set('state', 'hungry');
- hamster.get('napTime'); // false
- ```
-
- @method equal
- @for Ember.computed
- @param {String} dependentKey
- @param {String|Number|Object} value
- @return {Ember.ComputedProperty} computed property which returns true if
- the original value for property is equal to the given value.
- */
-
function equal(dependentKey, value) {
return computed.computed(dependentKey, function () {
return property_get.get(this, dependentKey) === value;
});
}
- /**
- A computed property that returns true if the provided dependent property
- is greater than the provided value.
-
- Example
-
- ```javascript
- var Hamster = Ember.Object.extend({
- hasTooManyBananas: Ember.computed.gt('numBananas', 10)
- });
-
- var hamster = Hamster.create();
-
- hamster.get('hasTooManyBananas'); // false
- hamster.set('numBananas', 3);
- hamster.get('hasTooManyBananas'); // false
- hamster.set('numBananas', 11);
- hamster.get('hasTooManyBananas'); // true
- ```
-
- @method gt
- @for Ember.computed
- @param {String} dependentKey
- @param {Number} value
- @return {Ember.ComputedProperty} computed property which returns true if
- the original value for property is greater than given value.
- */
-
function gt(dependentKey, value) {
return computed.computed(dependentKey, function () {
return property_get.get(this, dependentKey) > value;
});
}
- /**
- A computed property that returns true if the provided dependent property
- is greater than or equal to the provided value.
-
- Example
-
- ```javascript
- var Hamster = Ember.Object.extend({
- hasTooManyBananas: Ember.computed.gte('numBananas', 10)
- });
-
- var hamster = Hamster.create();
-
- hamster.get('hasTooManyBananas'); // false
- hamster.set('numBananas', 3);
- hamster.get('hasTooManyBananas'); // false
- hamster.set('numBananas', 10);
- hamster.get('hasTooManyBananas'); // true
- ```
-
- @method gte
- @for Ember.computed
- @param {String} dependentKey
- @param {Number} value
- @return {Ember.ComputedProperty} computed property which returns true if
- the original value for property is greater or equal then given value.
- */
-
function gte(dependentKey, value) {
return computed.computed(dependentKey, function () {
return property_get.get(this, dependentKey) >= value;
});
}
- /**
- A computed property that returns true if the provided dependent property
- is less than the provided value.
-
- Example
-
- ```javascript
- var Hamster = Ember.Object.extend({
- needsMoreBananas: Ember.computed.lt('numBananas', 3)
- });
-
- var hamster = Hamster.create();
-
- hamster.get('needsMoreBananas'); // true
- hamster.set('numBananas', 3);
- hamster.get('needsMoreBananas'); // false
- hamster.set('numBananas', 2);
- hamster.get('needsMoreBananas'); // true
- ```
-
- @method lt
- @for Ember.computed
- @param {String} dependentKey
- @param {Number} value
- @return {Ember.ComputedProperty} computed property which returns true if
- the original value for property is less then given value.
- */
-
function lt(dependentKey, value) {
return computed.computed(dependentKey, function () {
return property_get.get(this, dependentKey) < value;
});
}
- /**
- A computed property that returns true if the provided dependent property
- is less than or equal to the provided value.
-
- Example
-
- ```javascript
- var Hamster = Ember.Object.extend({
- needsMoreBananas: Ember.computed.lte('numBananas', 3)
- });
-
- var hamster = Hamster.create();
-
- hamster.get('needsMoreBananas'); // true
- hamster.set('numBananas', 5);
- hamster.get('needsMoreBananas'); // false
- hamster.set('numBananas', 3);
- hamster.get('needsMoreBananas'); // true
- ```
-
- @method lte
- @for Ember.computed
- @param {String} dependentKey
- @param {Number} value
- @return {Ember.ComputedProperty} computed property which returns true if
- the original value for property is less or equal than given value.
- */
-
function lte(dependentKey, value) {
return computed.computed(dependentKey, function () {
return property_get.get(this, dependentKey) <= value;
});
}
@@ -10712,122 +12852,32 @@
res.push(properties[key]);
}
}
}
return res;
- });
-
- function oneWay(dependentKey) {
+ });function oneWay(dependentKey) {
return alias['default'](dependentKey).oneWay();
}
- /**
- This is a more semantically meaningful alias of `computed.oneWay`,
- whose name is somewhat ambiguous as to which direction the data flows.
-
- @method reads
- @for Ember.computed
- @param {String} dependentKey
- @return {Ember.ComputedProperty} computed property which creates a
- one way computed property to the original value for property.
- */
-
- /**
- Where `computed.oneWay` provides oneWay bindings, `computed.readOnly` provides
- a readOnly one way binding. Very often when using `computed.oneWay` one does
- not also want changes to propagate back up, as they will replace the value.
-
- This prevents the reverse flow, and also throws an exception when it occurs.
-
- Example
-
- ```javascript
- var User = Ember.Object.extend({
- firstName: null,
- lastName: null,
- nickName: Ember.computed.readOnly('firstName')
- });
-
- var teddy = User.create({
- firstName: 'Teddy',
- lastName: 'Zeenny'
- });
-
- teddy.get('nickName'); // 'Teddy'
- teddy.set('nickName', 'TeddyBear'); // throws Exception
- // throw new Ember.Error('Cannot Set: nickName on: <User:ember27288>' );`
- teddy.get('firstName'); // 'Teddy'
- ```
-
- @method readOnly
- @for Ember.computed
- @param {String} dependentKey
- @return {Ember.ComputedProperty} computed property which creates a
- one way computed property to the original value for property.
- @since 1.5.0
- */
-
function readOnly(dependentKey) {
return alias['default'](dependentKey).readOnly();
}
- /**
- A computed property that acts like a standard getter and setter,
- but returns the value at the provided `defaultPath` if the
- property itself has not been set to a value
-
- Example
-
- ```javascript
- var Hamster = Ember.Object.extend({
- wishList: Ember.computed.defaultTo('favoriteFood')
- });
-
- var hamster = Hamster.create({ favoriteFood: 'Banana' });
-
- hamster.get('wishList'); // 'Banana'
- hamster.set('wishList', 'More Unit Tests');
- hamster.get('wishList'); // 'More Unit Tests'
- hamster.get('favoriteFood'); // 'Banana'
- ```
-
- @method defaultTo
- @for Ember.computed
- @param {String} defaultPath
- @return {Ember.ComputedProperty} computed property which acts like
- a standard getter and setter, but defaults to the value from `defaultPath`.
- @deprecated Use `Ember.computed.oneWay` or custom CP with default instead.
- */
-
function defaultTo(defaultPath) {
return computed.computed({
get: function (key) {
- Ember['default'].deprecate('Usage of Ember.computed.defaultTo is deprecated, use `Ember.computed.oneWay` instead.');
+ Ember['default'].deprecate("Usage of Ember.computed.defaultTo is deprecated, use `Ember.computed.oneWay` instead.");
return property_get.get(this, defaultPath);
},
set: function (key, newValue, cachedValue) {
- Ember['default'].deprecate('Usage of Ember.computed.defaultTo is deprecated, use `Ember.computed.oneWay` instead.');
+ Ember['default'].deprecate("Usage of Ember.computed.defaultTo is deprecated, use `Ember.computed.oneWay` instead.");
return newValue != null ? newValue : property_get.get(this, defaultPath);
}
});
}
- /**
- Creates a new property that is an alias for another property
- on an object. Calls to `get` or `set` this property behave as
- though they were called on the original property, but also
- print a deprecation warning.
-
- @method deprecatingAlias
- @for Ember.computed
- @param {String} dependentKey
- @return {Ember.ComputedProperty} computed property which creates an
- alias with a deprecation to the original value for property.
- @since 1.7.0
- */
-
function deprecatingAlias(dependentKey) {
return computed.computed(dependentKey, {
get: function (key) {
Ember['default'].deprecate("Usage of `" + key + "` is deprecated, use `" + dependentKey + "` instead.");
return property_get.get(this, dependentKey);
@@ -10874,11 +12924,11 @@
The core Runtime framework is based on the jQuery API with a number of
performance optimizations.
@class Ember
@static
- @version 1.12.2
+ @version 1.13.0-beta.1
*/
if ('undefined' === typeof Ember) {
// Create core object. Make it act like an instance of Ember.Namespace so that
// objects assigned to it are given a sane string representation.
@@ -10903,14 +12953,14 @@
};
/**
@property VERSION
@type String
- @default '1.12.2'
+ @default '1.13.0-beta.1'
@static
*/
- Ember.VERSION = '1.12.2';
+ Ember.VERSION = '1.13.0-beta.1';
/**
Standard environmental variables. You can define these in a global `EmberENV`
variable before loading Ember to control various configuration settings.
@@ -10947,11 +12997,11 @@
@class FEATURES
@namespace Ember
@static
@since 1.1.0
*/
- Ember.FEATURES = {"features-stripped-test":false,"ember-routing-named-substates":true,"mandatory-setter":true,"ember-htmlbars-component-generation":false,"ember-htmlbars-component-helper":true,"ember-htmlbars-inline-if-helper":true,"ember-htmlbars-attribute-syntax":true,"ember-routing-transitioning-classes":true,"new-computed-syntax":true,"ember-testing-checkbox-helpers":false,"ember-metal-stream":false,"ember-application-instance-initializers":true,"ember-application-initializer-context":true,"ember-router-willtransition":true,"ember-application-visit":false,"ember-views-component-block-info":false,"ember-routing-core-outlet":false,"ember-libraries-isregistered":false}; //jshint ignore:line
+ Ember.FEATURES = {"features-stripped-test":false,"ember-routing-named-substates":true,"mandatory-setter":true,"ember-htmlbars-component-generation":true,"ember-htmlbars-component-helper":true,"ember-htmlbars-inline-if-helper":true,"ember-htmlbars-attribute-syntax":true,"ember-routing-transitioning-classes":true,"new-computed-syntax":true,"ember-testing-checkbox-helpers":false,"ember-metal-stream":false,"ember-application-instance-initializers":true,"ember-application-initializer-context":true,"ember-router-willtransition":true,"ember-application-visit":false,"ember-views-component-block-info":true,"ember-routing-core-outlet":false,"ember-libraries-isregistered":false,"ember-routing-htmlbars-improved-actions":true}; //jshint ignore:line
if (Ember.ENV.FEATURES) {
for (var feature in Ember.ENV.FEATURES) {
if (Ember.ENV.FEATURES.hasOwnProperty(feature)) {
Ember.FEATURES[feature] = Ember.ENV.FEATURES[feature];
@@ -11085,11 +13135,30 @@
exports.addDependentKeys = addDependentKeys;
exports.removeDependentKeys = removeDependentKeys;
- "REMOVE_USE_STRICT: true";function keysForDep(depsMeta, depKey) {
+ "REMOVE_USE_STRICT: true"; /**
+ @module ember-metal
+ */
+
+ // ..........................................................
+ // DEPENDENT KEYS
+ //
+
+ // data structure:
+ // meta.deps = {
+ // 'depKey': {
+ // 'keyName': count,
+ // }
+ // }
+
+ /*
+ This function returns a map of unique dependencies for a
+ given object and key.
+ */
+ function keysForDep(depsMeta, depKey) {
var keys = depsMeta[depKey];
if (!keys) {
// if there are no dependencies yet for a the given key
// create a new empty list of dependencies for the key
keys = depsMeta[depKey] = {};
@@ -11100,13 +13169,12 @@
}
return keys;
}
function metaForDeps(meta) {
- return keysForDep(meta, 'deps');
+ return keysForDep(meta, "deps");
}
-
function addDependentKeys(desc, obj, keyName, meta) {
// the descriptor has a list of dependent keys, so
// add all of its dependent keys.
var depsMeta, idx, len, depKey, keys;
var depKeys = desc._dependentKeys;
@@ -11154,10 +13222,22 @@
'use strict';
exports.deprecateProperty = deprecateProperty;
+ /**
+ Used internally to allow changing properties in a backwards compatible way, and print a helpful
+ deprecation warning.
+
+ @method deprecateProperty
+ @param {Object} object The object to add the deprecated property to.
+ @param {String} deprecatedKey The property to add (and print deprecation warnings upon accessing).
+ @param {String} newKey The property that will be aliased.
+ @private
+ @since 1.7.0
+ */
+
function deprecateProperty(object, deprecatedKey, newKey) {
function deprecate() {
Ember['default'].deprecate("Usage of `" + deprecatedKey + "` is deprecated, use `" + newKey + "` instead.");
}
@@ -11181,10 +13261,16 @@
enifed('ember-metal/dictionary', ['exports', 'ember-metal/platform/create'], function (exports, create) {
'use strict';
+
+ // the delete is meant to hint at runtimes that this object should remain in
+ // dictionary mode. This is clearly a runtime specific hack, but currently it
+ // appears worthwhile in some usecases. Please note, these deletes do increase
+ // the cost of creation dramatically over a plain Object.create. And as this
+ // only makes sense for long-lived dictionaries that aren't instantiated often.
exports['default'] = makeDictionary;
function makeDictionary(parent) {
var dict = create['default'](parent);
dict['_dict'] = null;
delete dict['_dict'];
@@ -11205,12 +13291,10 @@
exports.removeObject = removeObject;
exports._replace = _replace;
exports.replace = replace;
exports.intersection = intersection;
- var splice = Array.prototype.splice;
-
/**
* Defines some convenience methods for working with Enumerables.
* `Ember.EnumerableUtils` uses `Ember.ArrayPolyfills` when necessary.
*
* @class EnumerableUtils
@@ -11227,117 +13311,40 @@
* @param {Function} callback The callback to execute
* @param {Object} thisArg Value to use as this when executing *callback*
*
* @return {Array} An array of mapped values.
*/
-
+ var splice = Array.prototype.splice;
function map(obj, callback, thisArg) {
return obj.map ? obj.map(callback, thisArg) : ember_metal__array.map.call(obj, callback, thisArg);
}
- /**
- * Calls the forEach function on the passed object with a specified callback. This
- * uses `Ember.ArrayPolyfill`'s-forEach method when necessary.
- *
- * @method forEach
- * @param {Object} obj The object to call forEach on
- * @param {Function} callback The callback to execute
- * @param {Object} thisArg Value to use as this when executing *callback*
- *
- */
-
function forEach(obj, callback, thisArg) {
return obj.forEach ? obj.forEach(callback, thisArg) : ember_metal__array.forEach.call(obj, callback, thisArg);
}
- /**
- * Calls the filter function on the passed object with a specified callback. This
- * uses `Ember.ArrayPolyfill`'s-filter method when necessary.
- *
- * @method filter
- * @param {Object} obj The object to call filter on
- * @param {Function} callback The callback to execute
- * @param {Object} thisArg Value to use as this when executing *callback*
- *
- * @return {Array} An array containing the filtered values
- * @since 1.4.0
- */
-
function filter(obj, callback, thisArg) {
return obj.filter ? obj.filter(callback, thisArg) : ember_metal__array.filter.call(obj, callback, thisArg);
}
- /**
- * Calls the indexOf function on the passed object with a specified callback. This
- * uses `Ember.ArrayPolyfill`'s-indexOf method when necessary.
- *
- * @method indexOf
- * @param {Object} obj The object to call indexOn on
- * @param {Function} callback The callback to execute
- * @param {Object} index The index to start searching from
- *
- */
-
function indexOf(obj, element, index) {
return obj.indexOf ? obj.indexOf(element, index) : ember_metal__array.indexOf.call(obj, element, index);
}
- /**
- * Returns an array of indexes of the first occurrences of the passed elements
- * on the passed object.
- *
- * ```javascript
- * var array = [1, 2, 3, 4, 5];
- * Ember.EnumerableUtils.indexesOf(array, [2, 5]); // [1, 4]
- *
- * var fubar = "Fubarr";
- * Ember.EnumerableUtils.indexesOf(fubar, ['b', 'r']); // [2, 4]
- * ```
- *
- * @method indexesOf
- * @param {Object} obj The object to check for element indexes
- * @param {Array} elements The elements to search for on *obj*
- *
- * @return {Array} An array of indexes.
- *
- */
-
function indexesOf(obj, elements) {
return elements === undefined ? [] : map(elements, function (item) {
return indexOf(obj, item);
});
}
- /**
- * Adds an object to an array. If the array already includes the object this
- * method has no effect.
- *
- * @method addObject
- * @param {Array} array The array the passed item should be added to
- * @param {Object} item The item to add to the passed array
- *
- * @return 'undefined'
- */
-
function addObject(array, item) {
var index = indexOf(array, item);
if (index === -1) {
array.push(item);
}
}
- /**
- * Removes an object from an array. If the array does not contain the passed
- * object this method has no effect.
- *
- * @method removeObject
- * @param {Array} array The array to remove the item from.
- * @param {Object} item The item to remove from the passed array.
- *
- * @return 'undefined'
- */
-
function removeObject(array, item) {
var index = indexOf(array, item);
if (index !== -1) {
array.splice(index, 1);
}
@@ -11367,68 +13374,18 @@
ret = ret.concat(splice.apply(array, chunk));
}
return ret;
}
- /**
- * Replaces objects in an array with the passed objects.
- *
- * ```javascript
- * var array = [1,2,3];
- * Ember.EnumerableUtils.replace(array, 1, 2, [4, 5]); // [1, 4, 5]
- *
- * var array = [1,2,3];
- * Ember.EnumerableUtils.replace(array, 1, 1, [4, 5]); // [1, 4, 5, 3]
- *
- * var array = [1,2,3];
- * Ember.EnumerableUtils.replace(array, 10, 1, [4, 5]); // [1, 2, 3, 4, 5]
- * ```
- *
- * @method replace
- * @param {Array} array The array the objects should be inserted into.
- * @param {Number} idx Starting index in the array to replace. If *idx* >=
- * length, then append to the end of the array.
- * @param {Number} amt Number of elements that should be removed from the array,
- * starting at *idx*
- * @param {Array} objects An array of zero or more objects that should be
- * inserted into the array at *idx*
- *
- * @return {Array} The modified array.
- */
-
function replace(array, idx, amt, objects) {
if (array.replace) {
return array.replace(idx, amt, objects);
} else {
return _replace(array, idx, amt, objects);
}
}
- /**
- * Calculates the intersection of two arrays. This method returns a new array
- * filled with the records that the two passed arrays share with each other.
- * If there is no intersection, an empty array will be returned.
- *
- * ```javascript
- * var array1 = [1, 2, 3, 4, 5];
- * var array2 = [1, 3, 5, 6, 7];
- *
- * Ember.EnumerableUtils.intersection(array1, array2); // [1, 3, 5]
- *
- * var array1 = [1, 2, 3];
- * var array2 = [4, 5, 6];
- *
- * Ember.EnumerableUtils.intersection(array1, array2); // []
- * ```
- *
- * @method intersection
- * @param {Array} array1 The first array
- * @param {Array} array2 The second array
- *
- * @return {Array} The intersection of the two passed arrays.
- */
-
function intersection(array1, array2) {
var result = [];
forEach(array1, function (element) {
if (indexOf(array2, element) >= 0) {
result.push(element);
@@ -11468,22 +13425,24 @@
if (hasDOM) {
environment = {
hasDOM: true,
isChrome: !!window.chrome && !window.opera,
+ isFirefox: typeof InstallTrigger !== 'undefined',
location: window.location,
history: window.history,
userAgent: window.navigator.userAgent,
global: window
};
} else {
environment = {
hasDOM: false,
isChrome: false,
+ isFirefox: false,
location: null,
history: null,
- userAgent: "Lynx (textmode)",
+ userAgent: 'Lynx (textmode)',
global: null
};
}
exports['default'] = environment;
@@ -11539,11 +13498,12 @@
exports.hasListeners = hasListeners;
exports.listenersFor = listenersFor;
exports.on = on;
exports.removeListener = removeListener;
- "REMOVE_USE_STRICT: true";var ONCE = 1;
+ "REMOVE_USE_STRICT: true"; /* listener flags */
+ var ONCE = 1;
var SUSPENDED = 2;
/*
The event system uses a series of nested hashes to store listeners on an
object. When a listener is registered, or when an event arrives, these
@@ -11601,13 +13561,12 @@
actions.__source__ = obj;
}
return actions;
}
-
function accumulateListeners(obj, eventName, otherActions) {
- var meta = obj['__ember_meta__'];
+ var meta = obj["__ember_meta__"];
var actions = meta && meta.listeners && meta.listeners[eventName];
if (!actions) {
return;
}
@@ -11627,26 +13586,14 @@
}
return newActions;
}
- /**
- Add an event listener
-
- @method addListener
- @for Ember
- @param obj
- @param {String} eventName
- @param {Object|Function} target A target object or a function
- @param {Function|String} method A function or the name of a function to be called on `target`
- @param {Boolean} once A flag whether a function should only be called once
- */
-
function addListener(obj, eventName, target, method, once) {
Ember['default'].assert("You must pass at least an object and event name to Ember.addListener", !!obj && !!eventName);
- if (!method && 'function' === typeof target) {
+ if (!method && "function" === typeof target) {
method = target;
target = null;
}
var actions = actionsFor(obj, eventName);
@@ -11661,11 +13608,11 @@
return;
}
actions.push(target, method, flags);
- if ('function' === typeof obj.didAddListener) {
+ if ("function" === typeof obj.didAddListener) {
obj.didAddListener(eventName, target, method);
}
}
/**
@@ -11681,11 +13628,11 @@
@param {Function|String} method A function or the name of a function to be called on `target`
*/
function removeListener(obj, eventName, target, method) {
Ember['default'].assert("You must pass at least an object and event name to Ember.removeListener", !!obj && !!eventName);
- if (!method && 'function' === typeof target) {
+ if (!method && "function" === typeof target) {
method = target;
target = null;
}
function _removeListener(target, method) {
@@ -11697,51 +13644,31 @@
return;
}
actions.splice(actionIndex, 3);
- if ('function' === typeof obj.didRemoveListener) {
+ if ("function" === typeof obj.didRemoveListener) {
obj.didRemoveListener(eventName, target, method);
}
}
if (method) {
_removeListener(target, method);
} else {
- var meta = obj['__ember_meta__'];
+ var meta = obj["__ember_meta__"];
var actions = meta && meta.listeners && meta.listeners[eventName];
if (!actions) {
return;
}
for (var i = actions.length - 3; i >= 0; i -= 3) {
_removeListener(actions[i], actions[i + 1]);
}
}
}
-
- /**
- Suspend listener during callback.
-
- This should only be used by the target of the event listener
- when it is taking an action that would cause the event, e.g.
- an object might suspend its property change listener while it is
- setting that property.
-
- @method suspendListener
- @for Ember
-
- @private
- @param obj
- @param {String} eventName
- @param {Object|Function} target A target object or a function
- @param {Function|String} method A function or the name of a function to be called on `target`
- @param {Function} callback
- */
-
function suspendListener(obj, eventName, target, method, callback) {
- if (!method && 'function' === typeof target) {
+ if (!method && "function" === typeof target) {
method = target;
target = null;
}
var actions = actionsFor(obj, eventName);
@@ -11761,26 +13688,12 @@
}
return utils.tryFinally(tryable, finalizer);
}
- /**
- Suspends multiple listeners during a callback.
-
- @method suspendListeners
- @for Ember
-
- @private
- @param obj
- @param {Array} eventNames Array of event names
- @param {Object|Function} target A target object or a function
- @param {Function|String} method A function or the name of a function to be called on `target`
- @param {Function} callback
- */
-
function suspendListeners(obj, eventNames, target, method, callback) {
- if (!method && 'function' === typeof target) {
+ if (!method && "function" === typeof target) {
method = target;
target = null;
}
var suspendedActions = [];
@@ -11811,56 +13724,32 @@
}
return utils.tryFinally(tryable, finalizer);
}
- /**
- Return a list of currently watched events
-
- @private
- @method watchedEvents
- @for Ember
- @param obj
- */
-
function watchedEvents(obj) {
- var listeners = obj['__ember_meta__'].listeners;
+ var listeners = obj["__ember_meta__"].listeners;
var ret = [];
if (listeners) {
for (var eventName in listeners) {
- if (eventName !== '__source__' && listeners[eventName]) {
+ if (eventName !== "__source__" && listeners[eventName]) {
ret.push(eventName);
}
}
}
return ret;
}
- /**
- Send an event. The execution of suspended listeners
- is skipped, and once listeners are removed. A listener without
- a target is executed on the passed object. If an array of actions
- is not passed, the actions stored on the passed object are invoked.
-
- @method sendEvent
- @for Ember
- @param obj
- @param {String} eventName
- @param {Array} params Optional parameters for each listener.
- @param {Array} actions Optional array of actions (listeners).
- @return true
- */
-
function sendEvent(obj, eventName, params, actions) {
// first give object a chance to handle it
- if (obj !== Ember['default'] && 'function' === typeof obj.sendEvent) {
+ if (obj !== Ember['default'] && "function" === typeof obj.sendEvent) {
obj.sendEvent(eventName, params);
}
if (!actions) {
- var meta = obj['__ember_meta__'];
+ var meta = obj["__ember_meta__"];
actions = meta && meta.listeners && meta.listeners[eventName];
}
if (!actions) {
return;
@@ -11882,11 +13771,11 @@
removeListener(obj, eventName, target, method);
}
if (!target) {
target = obj;
}
- if ('string' === typeof method) {
+ if ("string" === typeof method) {
if (params) {
utils.applyStr(target, method, params);
} else {
target[method]();
}
@@ -11899,36 +13788,20 @@
}
}
return true;
}
- /**
- @private
- @method hasListeners
- @for Ember
- @param obj
- @param {String} eventName
- */
-
function hasListeners(obj, eventName) {
- var meta = obj['__ember_meta__'];
+ var meta = obj["__ember_meta__"];
var actions = meta && meta.listeners && meta.listeners[eventName];
return !!(actions && actions.length);
}
- /**
- @private
- @method listenersFor
- @for Ember
- @param obj
- @param {String} eventName
- */
-
function listenersFor(obj, eventName) {
var ret = [];
- var meta = obj['__ember_meta__'];
+ var meta = obj["__ember_meta__"];
var actions = meta && meta.listeners && meta.listeners[eventName];
if (!actions) {
return ret;
}
@@ -11940,34 +13813,10 @@
}
return ret;
}
- /**
- Define a property as a function that should be executed when
- a specified event or events are triggered.
-
-
- ``` javascript
- var Job = Ember.Object.extend({
- logCompleted: Ember.on('completed', function() {
- console.log('Job completed!');
- })
- });
-
- var job = Job.create();
-
- Ember.sendEvent(job, 'completed'); // Logs 'Job completed!'
- ```
-
- @method on
- @for Ember
- @param {String} eventNames*
- @param {Function} func
- @return func
- */
-
function on() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
@@ -11976,19 +13825,16 @@
func.__ember_listens__ = events;
return func;
}
});
-enifed('ember-metal/expand_properties', ['exports', 'ember-metal/error', 'ember-metal/enumerable_utils', 'ember-metal/utils'], function (exports, EmberError, enumerable_utils, utils) {
+enifed('ember-metal/expand_properties', ['exports', 'ember-metal/error', 'ember-metal/array'], function (exports, EmberError, array) {
'use strict';
- exports['default'] = expandProperties;
- var SPLIT_REGEX = /\{|\}/;
-
/**
Expands `pattern`, invoking `callback` for each expansion.
The only pattern supported is brace-expansion, anything else will be passed
once to `callback` directly.
@@ -12011,38 +13857,41 @@
@private
@param {String} pattern The property pattern to expand.
@param {Function} callback The callback to invoke. It is invoked once per
expansion, and is passed the expansion.
*/
+ exports['default'] = expandProperties;
+
+ var SPLIT_REGEX = /\{|\}/;
function expandProperties(pattern, callback) {
if (pattern.indexOf(' ') > -1) {
throw new EmberError['default']('Brace expanded properties cannot contain spaces, e.g. \'user.{firstName, lastName}\' should be \'user.{firstName,lastName}\'');
}
- if ('string' === utils.typeOf(pattern)) {
+ if ('string' === typeof pattern) {
var parts = pattern.split(SPLIT_REGEX);
var properties = [parts];
- enumerable_utils.forEach(parts, function (part, index) {
+ array.forEach.call(parts, function (part, index) {
if (part.indexOf(',') >= 0) {
properties = duplicateAndReplace(properties, part.split(','), index);
}
});
- enumerable_utils.forEach(properties, function (property) {
+ array.forEach.call(properties, function (property) {
callback(property.join(''));
});
} else {
callback(pattern);
}
}
function duplicateAndReplace(properties, currentParts, index) {
var all = [];
- enumerable_utils.forEach(properties, function (property) {
- enumerable_utils.forEach(currentParts, function (part) {
+ array.forEach.call(properties, function (property) {
+ array.forEach.call(currentParts, function (part) {
var current = property.slice(0);
current[index] = part;
all.push(current);
});
});
@@ -12054,17 +13903,40 @@
enifed('ember-metal/get_properties', ['exports', 'ember-metal/property_get', 'ember-metal/utils'], function (exports, property_get, utils) {
'use strict';
+
+ /**
+ To get multiple properties at once, call `Ember.getProperties`
+ with an object followed by a list of strings or an array:
+
+ ```javascript
+ Ember.getProperties(record, 'firstName', 'lastName', 'zipCode');
+ // { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
+ ```
+
+ is equivalent to:
+
+ ```javascript
+ Ember.getProperties(record, ['firstName', 'lastName', 'zipCode']);
+ // { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
+ ```
+
+ @method getProperties
+ @for Ember
+ @param {Object} obj
+ @param {String...|Array} list of keys to get
+ @return {Object}
+ */
exports['default'] = getProperties;
function getProperties(obj) {
var ret = {};
var propertyNames = arguments;
var i = 1;
- if (arguments.length === 2 && utils.typeOf(arguments[1]) === 'array') {
+ if (arguments.length === 2 && utils.isArray(arguments[1])) {
i = 0;
propertyNames = arguments[1];
}
for (var len = propertyNames.length; i < len; i++) {
ret[propertyNames[i]] = property_get.get(obj, propertyNames[i]);
@@ -12085,15 +13957,15 @@
AliasedPropertyPrototype.oneWay.call(this);
}
function injectedPropertyGet(keyName) {
var possibleDesc = this[keyName];
- var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
+ var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined;
Ember['default'].assert("Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.", this.container);
- return this.container.lookup(desc.type + ':' + (desc.name || keyName));
+ return this.container.lookup(desc.type + ":" + (desc.name || keyName));
}
InjectedProperty.prototype = create['default'](properties.Descriptor.prototype);
var InjectedPropertyPrototype = InjectedProperty.prototype;
@@ -12118,10 +13990,21 @@
exports._instrumentStart = _instrumentStart;
exports.subscribe = subscribe;
exports.unsubscribe = unsubscribe;
exports.reset = reset;
+ /**
+ Notifies event's subscribers, calls `before` and `after` hooks.
+
+ @method instrument
+ @namespace Ember.Instrumentation
+
+ @param {String} [name] Namespaced event name.
+ @param {Object} payload
+ @param {Function} callback Function that you're instrumenting.
+ @param {Object} binding Context that instrument function is called with.
+ */
var subscribers = [];
var cache = {};
var populateListeners = function (name) {
var listeners = [];
@@ -12137,32 +14020,19 @@
cache[name] = listeners;
return listeners;
};
var time = (function () {
- var perf = 'undefined' !== typeof window ? window.performance || {} : {};
+ var perf = "undefined" !== typeof window ? window.performance || {} : {};
var fn = perf.now || perf.mozNow || perf.webkitNow || perf.msNow || perf.oNow;
// fn.bind will be available in all the browsers that support the advanced window.performance... ;-)
return fn ? fn.bind(perf) : function () {
return +new Date();
};
})();
-
- /**
- Notifies event's subscribers, calls `before` and `after` hooks.
-
- @method instrument
- @namespace Ember.Instrumentation
-
- @param {String} [name] Namespaced event name.
- @param {Object} payload
- @param {Function} callback Function that you're instrumenting.
- @param {Object} binding Context that instrument function is called with.
- */
-
function instrument(name, _payload, callback, binding) {
- if (arguments.length <= 3 && typeof _payload === 'function') {
+ if (arguments.length <= 3 && typeof _payload === "function") {
binding = callback;
callback = _payload;
_payload = undefined;
}
if (subscribers.length === 0) {
@@ -12183,12 +14053,10 @@
} else {
return callback.call(binding);
}
}
- // private for now
-
function _instrumentStart(name, _payload) {
var listeners = cache[name];
if (!listeners) {
listeners = populateListeners(name);
@@ -12228,22 +14096,10 @@
console.timeEnd(timeName);
}
};
}
- /**
- Subscribes to a particular event or instrumented block of code.
-
- @method subscribe
- @namespace Ember.Instrumentation
-
- @param {String} [pattern] Namespaced event name.
- @param {Object} [object] Before and After hooks.
-
- @return {Subscriber}
- */
-
function subscribe(pattern, object) {
var paths = pattern.split(".");
var path;
var regex = [];
@@ -12269,19 +14125,10 @@
cache = {};
return subscriber;
}
- /**
- Unsubscribes from a particular event or instrumented block of code.
-
- @method unsubscribe
- @namespace Ember.Instrumentation
-
- @param {Object} [subscriber]
- */
-
function unsubscribe(subscriber) {
var index;
for (var i = 0, l = subscribers.length; i < l; i++) {
if (subscribers[i] === subscriber) {
@@ -12291,17 +14138,10 @@
subscribers.splice(index, 1);
cache = {};
}
- /**
- Resets `Ember.Instrumentation` by flushing list of subscribers.
-
- @method reset
- @namespace Ember.Instrumentation
- */
-
function reset() {
subscribers.length = 0;
cache = {};
}
@@ -12311,10 +14151,34 @@
enifed('ember-metal/is_blank', ['exports', 'ember-metal/is_empty'], function (exports, isEmpty) {
'use strict';
+
+ /**
+ A value is blank if it is empty or a whitespace string.
+
+ ```javascript
+ Ember.isBlank(); // true
+ Ember.isBlank(null); // true
+ Ember.isBlank(undefined); // true
+ Ember.isBlank(''); // true
+ Ember.isBlank([]); // true
+ Ember.isBlank('\n\t'); // true
+ Ember.isBlank(' '); // true
+ Ember.isBlank({}); // false
+ Ember.isBlank('\n\t Hello'); // false
+ Ember.isBlank('Hello world'); // false
+ Ember.isBlank([1,2,3]); // false
+ ```
+
+ @method isBlank
+ @for Ember
+ @param {Object} obj Value to test
+ @return {Boolean}
+ @since 1.5.0
+ */
exports['default'] = isBlank;
function isBlank(obj) {
return isEmpty['default'](obj) || typeof obj === 'string' && obj.match(/\S/) === null;
}
@@ -12392,10 +14256,34 @@
enifed('ember-metal/is_present', ['exports', 'ember-metal/is_blank'], function (exports, isBlank) {
'use strict';
+
+ /**
+ A value is present if it not `isBlank`.
+
+ ```javascript
+ Ember.isPresent(); // false
+ Ember.isPresent(null); // false
+ Ember.isPresent(undefined); // false
+ Ember.isPresent(''); // false
+ Ember.isPresent([]); // false
+ Ember.isPresent('\n\t'); // false
+ Ember.isPresent(' '); // false
+ Ember.isPresent({}); // true
+ Ember.isPresent('\n\t Hello'); // true
+ Ember.isPresent('Hello world'); // true
+ Ember.isPresent([1,2,3]); // true
+ ```
+
+ @method isPresent
+ @for Ember
+ @param {Object} obj Value to test
+ @return {Boolean}
+ @since 1.8.0
+ */
exports['default'] = isPresent;
function isPresent(obj) {
return !isBlank['default'](obj);
}
@@ -12493,11 +14381,11 @@
this._registry.splice(index, 1);
}
},
each: function (callback) {
- Ember['default'].deprecate('Using Ember.libraries.each() is deprecated. Access to a list of registered libraries is currently a private API. If you are not knowingly accessing this method, your out-of-date Ember Inspector may be doing so.');
+ Ember['default'].deprecate("Using Ember.libraries.each() is deprecated. Access to a list of registered libraries is currently a private API. If you are not knowingly accessing this method, your out-of-date Ember Inspector may be doing so.");
enumerable_utils.forEach(this._registry, function (lib) {
callback(lib.name, lib.version);
});
}
};
@@ -12516,31 +14404,31 @@
function consoleMethod(name) {
var consoleObj, logToConsole;
if (Ember['default'].imports.console) {
consoleObj = Ember['default'].imports.console;
- } else if (typeof console !== 'undefined') {
+ } else if (typeof console !== "undefined") {
consoleObj = console;
}
- var method = typeof consoleObj === 'object' ? consoleObj[name] : null;
+ var method = typeof consoleObj === "object" ? consoleObj[name] : null;
if (method) {
// Older IE doesn't support bind, but Chrome needs it
- if (typeof method.bind === 'function') {
+ if (typeof method.bind === "function") {
logToConsole = method.bind(consoleObj);
- logToConsole.displayName = 'console.' + name;
+ logToConsole.displayName = "console." + name;
return logToConsole;
- } else if (typeof method.apply === 'function') {
+ } else if (typeof method.apply === "function") {
logToConsole = function () {
method.apply(consoleObj, arguments);
};
- logToConsole.displayName = 'console.' + name;
+ logToConsole.displayName = "console." + name;
return logToConsole;
} else {
return function () {
- var message = Array.prototype.join.call(arguments, ', ');
+ var message = Array.prototype.join.call(arguments, ", ");
method(message);
};
}
}
}
@@ -12576,11 +14464,11 @@
```
@method log
@for Ember.Logger
@param {*} arguments
*/
- log: consoleMethod('log') || K,
+ log: consoleMethod("log") || K,
/**
Prints the arguments to the console with a warning icon.
You can pass as many arguments as you want and they will be joined together with a space.
```javascript
@@ -12589,11 +14477,11 @@
```
@method warn
@for Ember.Logger
@param {*} arguments
*/
- warn: consoleMethod('warn') || K,
+ warn: consoleMethod("warn") || K,
/**
Prints the arguments to the console with an error icon, red text and a stack trace.
You can pass as many arguments as you want and they will be joined together with a space.
```javascript
@@ -12602,11 +14490,11 @@
```
@method error
@for Ember.Logger
@param {*} arguments
*/
- error: consoleMethod('error') || K,
+ error: consoleMethod("error") || K,
/**
Logs the arguments to the console.
You can pass as many arguments as you want and they will be joined together with a space.
```javascript
@@ -12616,11 +14504,11 @@
```
@method info
@for Ember.Logger
@param {*} arguments
*/
- info: consoleMethod('info') || K,
+ info: consoleMethod("info") || K,
/**
Logs the arguments to the console in blue text.
You can pass as many arguments as you want and they will be joined together with a space.
```javascript
@@ -12630,11 +14518,11 @@
```
@method debug
@for Ember.Logger
@param {*} arguments
*/
- debug: consoleMethod('debug') || consoleMethod('info') || K,
+ debug: consoleMethod("debug") || consoleMethod("info") || K,
/**
If the value passed into `Ember.Logger.assert` is not truthy it will throw an error with a stack trace.
```javascript
Ember.Logger.assert(true); // undefined
@@ -12642,11 +14530,11 @@
```
@method assert
@for Ember.Logger
@param {Boolean} bool Value to test
*/
- assert: consoleMethod('assert') || assertPolyfill
+ assert: consoleMethod("assert") || assertPolyfill
};
});
enifed('ember-metal/map', ['exports', 'ember-metal/utils', 'ember-metal/array', 'ember-metal/platform/create', 'ember-metal/deprecate_property'], function (exports, utils, array, create, deprecate_property) {
@@ -12677,11 +14565,11 @@
Map is mocked out to look like an Ember object, so you can do
`Ember.Map.create()` for symmetry with other Ember classes.
*/
function missingFunction(fn) {
- throw new TypeError(Object.prototype.toString.call(fn) + " is not a function");
+ throw new TypeError("" + Object.prototype.toString.call(fn) + " is not a function");
}
function missingNew(name) {
throw new TypeError("Constructor " + name + " requires 'new'");
}
@@ -12775,11 +14663,11 @@
@param obj
@param _guid (optional and for internal use only)
@return {Boolean}
*/
remove: function (obj, _guid) {
- Ember.deprecate('Calling `OrderedSet.prototype.remove` has been deprecated, please use `OrderedSet.prototype.delete` instead.', this._silenceRemoveDeprecation);
+ Ember.deprecate("Calling `OrderedSet.prototype.remove` has been deprecated, please use `OrderedSet.prototype.delete` instead.", this._silenceRemoveDeprecation);
return this["delete"](obj, _guid);
},
/**
@@ -12835,11 +14723,11 @@
@method forEach
@param {Function} fn
@param self
*/
forEach: function (fn /*, ...thisArg*/) {
- if (typeof fn !== 'function') {
+ if (typeof fn !== "function") {
missingFunction(fn);
}
if (this.size === 0) {
return;
@@ -12883,11 +14771,11 @@
return set;
}
};
- deprecate_property.deprecateProperty(OrderedSet.prototype, 'length', 'size');
+ deprecate_property.deprecateProperty(OrderedSet.prototype, "length", "size");
/**
A Map stores values indexed by keys. Unlike JavaScript's
default Objects, the keys of a Map can be any JavaScript
object.
@@ -12989,11 +14877,11 @@
@method remove
@param {*} key
@return {Boolean} true if an item was removed, false otherwise
*/
remove: function (key) {
- Ember.deprecate('Calling `Map.prototype.remove` has been deprecated, please use `Map.prototype.delete` instead.');
+ Ember.deprecate("Calling `Map.prototype.remove` has been deprecated, please use `Map.prototype.delete` instead.");
return this["delete"](key);
},
/**
@@ -13041,11 +14929,11 @@
@param {Function} callback
@param {*} self if passed, the `this` value inside the
callback. By default, `this` is the map.
*/
forEach: function (callback /*, ...thisArg*/) {
- if (typeof callback !== 'function') {
+ if (typeof callback !== "function") {
missingFunction(callback);
}
if (this.size === 0) {
return;
@@ -13085,11 +14973,11 @@
copy: function () {
return copyMap(this, new Map());
}
};
- deprecate_property.deprecateProperty(Map.prototype, 'length', 'size');
+ deprecate_property.deprecateProperty(Map.prototype, "length", "size");
/**
@class MapWithDefault
@namespace Ember
@extends Ember.Map
@@ -13159,12 +15047,30 @@
});
enifed('ember-metal/merge', ['exports', 'ember-metal/keys'], function (exports, keys) {
'use strict';
+ exports.assign = assign;
+ /**
+ Merge the contents of two objects together into the first object.
+
+ ```javascript
+ Ember.merge({first: 'Tom'}, {last: 'Dale'}); // {first: 'Tom', last: 'Dale'}
+ var a = {first: 'Yehuda'};
+ var b = {last: 'Katz'};
+ Ember.merge(a, b); // a == {first: 'Yehuda', last: 'Katz'}, b == {last: 'Katz'}
+ ```
+
+ @method merge
+ @for Ember
+ @param {Object} original The object to merge into
+ @param {Object} updates The object to copy properties from
+ @return {Object}
+ */
exports['default'] = merge;
+
function merge(original, updates) {
if (!updates || typeof updates !== 'object') {
return original;
}
@@ -13178,10 +15084,31 @@
}
return original;
}
+ function assign(original) {
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
+ args[_key - 1] = arguments[_key];
+ }
+
+ for (var i = 0, l = args.length; i < l; i++) {
+ var arg = args[i];
+ if (!arg) {
+ continue;
+ }
+
+ for (var prop in arg) {
+ if (arg.hasOwnProperty(prop)) {
+ original[prop] = arg[prop];
+ }
+ }
+ }
+
+ return original;
+ }
+
});
enifed('ember-metal/mixin', ['exports', 'ember-metal/core', 'ember-metal/merge', 'ember-metal/array', 'ember-metal/platform/create', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/utils', 'ember-metal/expand_properties', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/binding', 'ember-metal/observer', 'ember-metal/events', 'ember-metal/streams/utils'], function (exports, Ember, merge, array, o_create, property_get, property_set, utils, expandProperties, ember_metal__properties, computed, ember_metal__binding, ember_metal__observer, events, streams__utils) {
exports.mixin = mixin;
@@ -13190,10 +15117,17 @@
exports.observer = observer;
exports.immediateObserver = immediateObserver;
exports.beforeObserver = beforeObserver;
exports.Mixin = Mixin;
+ /**
+ @method mixin
+ @for Ember
+ @param obj
+ @param mixins*
+ @return obj
+ */
"REMOVE_USE_STRICT: true";var REQUIRED;
var a_slice = [].slice;
function superFunction() {
var func = this.__nextSuper;
@@ -13230,18 +15164,18 @@
function mixinsMeta(obj) {
var m = utils.meta(obj, true);
var ret = m.mixins;
if (!ret) {
ret = m.mixins = {};
- } else if (!m.hasOwnProperty('mixins')) {
+ } else if (!m.hasOwnProperty("mixins")) {
ret = m.mixins = o_create['default'](ret);
}
return ret;
}
function isMethod(obj) {
- return 'function' === typeof obj && obj.isMethod !== false && obj !== Boolean && obj !== Object && obj !== Number && obj !== Array && obj !== Date && obj !== String;
+ return "function" === typeof obj && obj.isMethod !== false && obj !== Boolean && obj !== Object && obj !== Number && obj !== Array && obj !== Date && obj !== String;
}
var CONTINUE = {};
function mixinProperties(mixinsMeta, mixin) {
@@ -13282,11 +15216,11 @@
// If we didn't find the original descriptor in a parent mixin, find
// it on the original object.
if (!superProperty) {
var possibleDesc = base[key];
- var superDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
+ var superDesc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined;
superProperty = superDesc;
}
if (superProperty === undefined || !(superProperty instanceof computed.ComputedProperty)) {
@@ -13309,11 +15243,11 @@
return property;
}
var sourceAvailable = (function () {
return this;
- }).toString().indexOf('return this;') > -1;
+ }).toString().indexOf("return this;") > -1;
function giveMethodSuper(obj, key, method, values, descs) {
var superMethod;
// Methods overwrite computed properties, and do not call super to them.
@@ -13325,20 +15259,20 @@
// If we didn't find the original value in a parent mixin, find it in
// the original object
superMethod = superMethod || obj[key];
// Only wrap the new method if the original method was a function
- if (superMethod === undefined || 'function' !== typeof superMethod) {
+ if (superMethod === undefined || "function" !== typeof superMethod) {
return method;
}
var hasSuper;
if (sourceAvailable) {
hasSuper = method.__hasSuper;
if (hasSuper === undefined) {
- hasSuper = method.toString().indexOf('_super') > -1;
+ hasSuper = method.toString().indexOf("_super") > -1;
method.__hasSuper = hasSuper;
}
}
if (sourceAvailable === false || hasSuper) {
@@ -13350,11 +15284,11 @@
function applyConcatenatedProperties(obj, key, value, values) {
var baseValue = values[key] || obj[key];
if (baseValue) {
- if ('function' === typeof baseValue.concat) {
+ if ("function" === typeof baseValue.concat) {
if (value === null || value === undefined) {
return baseValue;
} else {
return baseValue.concat(value);
}
@@ -13413,11 +15347,11 @@
}
descs[key] = value;
values[key] = undefined;
} else {
- if (concats && array.indexOf.call(concats, key) >= 0 || key === 'concatenatedProperties' || key === 'mergedProperties') {
+ if (concats && array.indexOf.call(concats, key) >= 0 || key === "concatenatedProperties" || key === "mergedProperties") {
value = applyConcatenatedProperties(base, key, value, values);
} else if (mergings && array.indexOf.call(mergings, key) >= 0) {
value = applyMergedProperties(base, key, value, values);
} else if (isMethod(value)) {
value = giveMethodSuper(base, key, value, values, descs);
@@ -13436,11 +15370,11 @@
delete values[keyName];
}
for (var i = 0, l = mixins.length; i < l; i++) {
currentMixin = mixins[i];
- Ember['default'].assert("Expected hash or Mixin instance, got " + Object.prototype.toString.call(currentMixin), typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]');
+ Ember['default'].assert("Expected hash or Mixin instance, got " + Object.prototype.toString.call(currentMixin), typeof currentMixin === "object" && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== "[object Array]");
props = mixinProperties(m, currentMixin);
if (props === CONTINUE) {
continue;
}
@@ -13448,23 +15382,23 @@
if (props) {
meta = utils.meta(base);
if (base.willMergeMixin) {
base.willMergeMixin(props);
}
- concats = concatenatedMixinProperties('concatenatedProperties', props, values, base);
- mergings = concatenatedMixinProperties('mergedProperties', props, values, base);
+ concats = concatenatedMixinProperties("concatenatedProperties", props, values, base);
+ mergings = concatenatedMixinProperties("mergedProperties", props, values, base);
for (key in props) {
if (!props.hasOwnProperty(key)) {
continue;
}
keys.push(key);
addNormalizedProperty(base, key, props[key], meta, descs, values, concats, mergings);
}
// manually copy toString() because some JS engines do not enumerate it
- if (props.hasOwnProperty('toString')) {
+ if (props.hasOwnProperty("toString")) {
base.toString = props.toString;
}
} else if (currentMixin.mixins) {
mergeMixins(currentMixin.mixins, m, descs, values, base, keys);
if (currentMixin._without) {
@@ -13479,11 +15413,11 @@
function detectBinding(obj, key, value, m) {
if (IS_BINDING.test(key)) {
var bindings = m.bindings;
if (!bindings) {
bindings = m.bindings = {};
- } else if (!m.hasOwnProperty('bindings')) {
+ } else if (!m.hasOwnProperty("bindings")) {
bindings = m.bindings = o_create['default'](m.bindings);
}
bindings[key] = value;
}
}
@@ -13551,11 +15485,11 @@
var value;
var possibleDesc;
if (descs[altKey] || values[altKey]) {
value = values[altKey];
desc = descs[altKey];
- } else if ((possibleDesc = obj[altKey]) && possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) {
+ } else if ((possibleDesc = obj[altKey]) && possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor) {
desc = possibleDesc;
value = undefined;
} else {
desc = undefined;
value = obj[altKey];
@@ -13575,20 +15509,20 @@
}
function replaceObserversAndListeners(obj, key, observerOrListener) {
var prev = obj[key];
- if ('function' === typeof prev) {
- updateObserversAndListeners(obj, key, prev, '__ember_observesBefore__', ember_metal__observer.removeBeforeObserver);
- updateObserversAndListeners(obj, key, prev, '__ember_observes__', ember_metal__observer.removeObserver);
- updateObserversAndListeners(obj, key, prev, '__ember_listens__', events.removeListener);
+ if ("function" === typeof prev) {
+ updateObserversAndListeners(obj, key, prev, "__ember_observesBefore__", ember_metal__observer.removeBeforeObserver);
+ updateObserversAndListeners(obj, key, prev, "__ember_observes__", ember_metal__observer.removeObserver);
+ updateObserversAndListeners(obj, key, prev, "__ember_listens__", events.removeListener);
}
- if ('function' === typeof observerOrListener) {
- updateObserversAndListeners(obj, key, observerOrListener, '__ember_observesBefore__', ember_metal__observer.addBeforeObserver);
- updateObserversAndListeners(obj, key, observerOrListener, '__ember_observes__', ember_metal__observer.addObserver);
- updateObserversAndListeners(obj, key, observerOrListener, '__ember_listens__', events.addListener);
+ if ("function" === typeof observerOrListener) {
+ updateObserversAndListeners(obj, key, observerOrListener, "__ember_observesBefore__", ember_metal__observer.addBeforeObserver);
+ updateObserversAndListeners(obj, key, observerOrListener, "__ember_observes__", ember_metal__observer.addObserver);
+ updateObserversAndListeners(obj, key, observerOrListener, "__ember_listens__", events.addListener);
}
}
function applyMixin(obj, mixins, partial) {
var descs = {};
@@ -13608,11 +15542,11 @@
// * Copying `toString` in broken browsers
mergeMixins(mixins, mixinsMeta(obj), descs, values, obj, keys);
for (var i = 0, l = keys.length; i < l; i++) {
key = keys[i];
- if (key === 'constructor' || !values.hasOwnProperty(key)) {
+ if (key === "constructor" || !values.hasOwnProperty(key)) {
continue;
}
desc = descs[key];
value = values[key];
@@ -13641,19 +15575,10 @@
finishPartial(obj, m);
}
return obj;
}
-
- /**
- @method mixin
- @for Ember
- @param obj
- @param mixins*
- @return obj
- */
-
function mixin(obj) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
@@ -13756,18 +15681,17 @@
@method create
@static
@param arguments*
*/
Mixin.create = function () {
- // ES6TODO: this relies on a global state?
- Ember['default'].anyUnprocessedMixins = true;
- var M = this;
-
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
+ // ES6TODO: this relies on a global state?
+ Ember['default'].anyUnprocessedMixins = true;
+ var M = this;
return new M(args, undefined);
};
var MixinPrototype = Mixin.prototype;
@@ -13790,11 +15714,11 @@
var mixins = this.mixins;
var idx;
for (idx = 0; idx < len; idx++) {
currentMixin = arguments[idx];
- Ember['default'].assert("Expected hash or Mixin instance, got " + Object.prototype.toString.call(currentMixin), typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]');
+ Ember['default'].assert("Expected hash or Mixin instance, got " + Object.prototype.toString.call(currentMixin), typeof currentMixin === "object" && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== "[object Array]");
if (currentMixin instanceof Mixin) {
mixins.push(currentMixin);
} else {
mixins.push(new Mixin(undefined, currentMixin));
@@ -13848,25 +15772,24 @@
return false;
}
if (obj instanceof Mixin) {
return _detect(obj, this, {});
}
- var m = obj['__ember_meta__'];
+ var m = obj["__ember_meta__"];
var mixins = m && m.mixins;
if (mixins) {
return !!mixins[utils.guidFor(this)];
}
return false;
};
MixinPrototype.without = function () {
- var ret = new Mixin([this]);
-
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
+ var ret = new Mixin([this]);
ret._without = args;
return ret;
};
function _keys(ret, mixin, seen) {
@@ -13903,11 +15826,11 @@
};
// returns the mixins currently applied to the specified object
// TODO: Make Ember.mixin
Mixin.mixins = function (obj) {
- var m = obj['__ember_meta__'];
+ var m = obj["__ember_meta__"];
var mixins = m && m.mixins;
var ret = [];
if (!mixins) {
return ret;
@@ -13925,86 +15848,27 @@
return ret;
};
REQUIRED = new ember_metal__properties.Descriptor();
REQUIRED.toString = function () {
- return '(Required Property)';
+ return "(Required Property)";
};
-
- /**
- Denotes a required property for a mixin
-
- @method required
- @for Ember
- */
-
function required() {
- Ember['default'].deprecate('Ember.required is deprecated as its behavior is inconsistent and unreliable.', false);
+ Ember['default'].deprecate("Ember.required is deprecated as its behavior is inconsistent and unreliable.", false);
return REQUIRED;
}
function Alias(methodName) {
this.isDescriptor = true;
this.methodName = methodName;
}
Alias.prototype = new ember_metal__properties.Descriptor();
-
- /**
- Makes a method available via an additional name.
-
- ```javascript
- App.Person = Ember.Object.extend({
- name: function() {
- return 'Tomhuda Katzdale';
- },
- moniker: Ember.aliasMethod('name')
- });
-
- var goodGuy = App.Person.create();
-
- goodGuy.name(); // 'Tomhuda Katzdale'
- goodGuy.moniker(); // 'Tomhuda Katzdale'
- ```
-
- @method aliasMethod
- @for Ember
- @param {String} methodName name of the method to alias
- */
-
function aliasMethod(methodName) {
return new Alias(methodName);
}
- // ..........................................................
- // OBSERVER HELPER
- //
-
- /**
- Specify a method that observes property changes.
-
- ```javascript
- Ember.Object.extend({
- valueObserver: Ember.observer('value', function() {
- // Executes whenever the "value" property changes
- })
- });
- ```
-
- In the future this method may become asynchronous. If you want to ensure
- synchronous behavior, use `immediateObserver`.
-
- Also available as `Function.prototype.observes` if prototype extensions are
- enabled.
-
- @method observer
- @for Ember
- @param {String} propertyNames*
- @param {Function} func
- @return func
- */
-
function observer() {
for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
@@ -14035,86 +15899,19 @@
func.__ember_observes__ = paths;
return func;
}
- /**
- Specify a method that observes property changes.
-
- ```javascript
- Ember.Object.extend({
- valueObserver: Ember.immediateObserver('value', function() {
- // Executes whenever the "value" property changes
- })
- });
- ```
-
- In the future, `Ember.observer` may become asynchronous. In this event,
- `Ember.immediateObserver` will maintain the synchronous behavior.
-
- Also available as `Function.prototype.observesImmediately` if prototype extensions are
- enabled.
-
- @method immediateObserver
- @for Ember
- @param {String} propertyNames*
- @param {Function} func
- @return func
- */
-
function immediateObserver() {
for (var i = 0, l = arguments.length; i < l; i++) {
var arg = arguments[i];
- Ember['default'].assert("Immediate observers must observe internal properties only, not properties on other objects.", typeof arg !== "string" || arg.indexOf('.') === -1);
+ Ember['default'].assert("Immediate observers must observe internal properties only, not properties on other objects.", typeof arg !== "string" || arg.indexOf(".") === -1);
}
return observer.apply(this, arguments);
}
- /**
- When observers fire, they are called with the arguments `obj`, `keyName`.
-
- Note, `@each.property` observer is called per each add or replace of an element
- and it's not called with a specific enumeration item.
-
- A `beforeObserver` fires before a property changes.
-
- A `beforeObserver` is an alternative form of `.observesBefore()`.
-
- ```javascript
- App.PersonView = Ember.View.extend({
- friends: [{ name: 'Tom' }, { name: 'Stefan' }, { name: 'Kris' }],
-
- valueWillChange: Ember.beforeObserver('content.value', function(obj, keyName) {
- this.changingFrom = obj.get(keyName);
- }),
-
- valueDidChange: Ember.observer('content.value', function(obj, keyName) {
- // only run if updating a value already in the DOM
- if (this.get('state') === 'inDOM') {
- var color = obj.get(keyName) > this.changingFrom ? 'green' : 'red';
- // logic
- }
- }),
-
- friendsDidChange: Ember.observer('friends.@each.name', function(obj, keyName) {
- // some logic
- // obj.get(keyName) returns friends array
- })
- });
- ```
-
- Also available as `Function.prototype.observesBefore` if prototype extensions are
- enabled.
-
- @method beforeObserver
- @for Ember
- @param {String} propertyNames*
- @param {Function} func
- @return func
- */
-
function beforeObserver() {
for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
args[_key5] = arguments[_key5];
}
@@ -14165,30 +15962,28 @@
exports._suspendBeforeObservers = _suspendBeforeObservers;
exports._suspendObservers = _suspendObservers;
exports.beforeObserversFor = beforeObserversFor;
exports.removeBeforeObserver = removeBeforeObserver;
- var AFTER_OBSERVERS = ':change';
- var BEFORE_OBSERVERS = ':before';
-
- function changeEvent(keyName) {
- return keyName + AFTER_OBSERVERS;
- }
-
- function beforeEvent(keyName) {
- return keyName + BEFORE_OBSERVERS;
- }
-
/**
@method addObserver
@for Ember
@param obj
@param {String} path
@param {Object|Function} targetOrMethod
@param {Function|String} [method]
*/
+ var AFTER_OBSERVERS = ":change";
+ var BEFORE_OBSERVERS = ":before";
+ function changeEvent(keyName) {
+ return keyName + AFTER_OBSERVERS;
+ }
+
+ function beforeEvent(keyName) {
+ return keyName + BEFORE_OBSERVERS;
+ }
function addObserver(obj, _path, target, method) {
ember_metal__events.addListener(obj, changeEvent(_path), target, method);
watching.watch(obj, _path);
return this;
@@ -14196,47 +15991,24 @@
function observersFor(obj, path) {
return ember_metal__events.listenersFor(obj, changeEvent(path));
}
- /**
- @method removeObserver
- @for Ember
- @param obj
- @param {String} path
- @param {Object|Function} target
- @param {Function|String} [method]
- */
-
function removeObserver(obj, path, target, method) {
watching.unwatch(obj, path);
ember_metal__events.removeListener(obj, changeEvent(path), target, method);
return this;
}
- /**
- @method addBeforeObserver
- @for Ember
- @param obj
- @param {String} path
- @param {Object|Function} target
- @param {Function|String} [method]
- */
-
function addBeforeObserver(obj, path, target, method) {
ember_metal__events.addListener(obj, beforeEvent(path), target, method);
watching.watch(obj, path);
return this;
}
- // Suspend observer during callback.
- //
- // This should only be used by the target of the observer
- // while it is setting the observed path.
-
function _suspendBeforeObserver(obj, path, target, method, callback) {
return ember_metal__events.suspendListener(obj, beforeEvent(path), target, method, callback);
}
function _suspendObserver(obj, path, target, method, callback) {
@@ -14255,19 +16027,10 @@
function beforeObserversFor(obj, path) {
return ember_metal__events.listenersFor(obj, beforeEvent(path));
}
- /**
- @method removeBeforeObserver
- @for Ember
- @param obj
- @param {String} path
- @param {Object|Function} target
- @param {Function|String} [method]
- */
-
function removeBeforeObserver(obj, path, target, method) {
watching.unwatch(obj, path);
ember_metal__events.removeListener(obj, beforeEvent(path), target, method);
return this;
@@ -14378,13 +16141,11 @@
isGlobalPathCache: isGlobalPathCache,
hasThisCache: hasThisCache,
firstDotIndexCache: firstDotIndexCache,
firstKeyCache: firstKeyCache,
tailPathCache: tailPathCache
- };
-
- function isGlobal(path) {
+ };function isGlobal(path) {
return isGlobalCache.get(path);
}
function isGlobalPath(path) {
return isGlobalPathCache.get(path);
@@ -14412,11 +16173,24 @@
enifed('ember-metal/platform/create', ['exports', 'ember-metal/platform/define_properties'], function (exports, defineProperties) {
- "REMOVE_USE_STRICT: true";var create;
+ 'REMOVE_USE_STRICT: true'; /**
+ @class platform
+ @namespace Ember
+ @static
+ */
+
+ /**
+ Identical to `Object.create()`. Implements if not available natively.
+
+ @since 1.8.0
+ @method create
+ @for Ember
+ */
+ var create;
// ES5 15.2.3.5
// http://es5.github.com/#x15.2.3.5
if (!(Object.create && !Object.create(null).hasOwnProperty)) {
/* jshint scripturl:true, proto:true */
// Contributed by Brandon Benvie, October, 2012
@@ -14425,11 +16199,11 @@
// the following produces false positives
// in Opera Mini => not a reliable check
// Object.prototype.__proto__ === null
if (supportsProto || typeof document === 'undefined') {
createEmpty = function () {
- return { "__proto__": null };
+ return { '__proto__': null };
};
} else {
// In old IE __proto__ can't be used to manually set `null`, nor does
// any other method exist to make an object that inherits from nothing,
// aside from Object.prototype itself. Instead, create a new global
@@ -14468,17 +16242,17 @@
function Type() {} // An empty constructor.
if (prototype === null) {
object = createEmpty();
} else {
- if (typeof prototype !== "object" && typeof prototype !== "function") {
+ if (typeof prototype !== 'object' && typeof prototype !== 'function') {
// In the native implementation `parent` can be `null`
// OR *any* `instanceof Object` (Object|Function|Array|RegExp|etc)
// Use `typeof` tho, b/c in old IE, DOM elements are not `instanceof Object`
// like they are in modern browsers. Using `Object.create` on DOM elements
// is...err...probably inappropriate, but the native version allows for it.
- throw new TypeError("Object prototype may only be an Object or null"); // same msg as Chrome
+ throw new TypeError('Object prototype may only be an Object or null'); // same msg as Chrome
}
Type.prototype = prototype;
object = new Type();
@@ -14629,14 +16403,14 @@
if (!canDefinePropertyOnDOM) {
defineProperty = function (obj, keyName, desc) {
var isNode;
- if (typeof Node === "object") {
+ if (typeof Node === 'object') {
isNode = obj instanceof Node;
} else {
- isNode = typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string";
+ isNode = typeof obj === 'object' && typeof obj.nodeType === 'number' && typeof obj.nodeName === 'string';
}
if (isNode) {
// TODO: Should we have a warning here?
return obj[keyName] = desc.value;
@@ -14671,86 +16445,44 @@
exports.Descriptor = Descriptor;
exports.MANDATORY_SETTER_FUNCTION = MANDATORY_SETTER_FUNCTION;
exports.DEFAULT_GETTER_FUNCTION = DEFAULT_GETTER_FUNCTION;
exports.defineProperty = defineProperty;
+ // ..........................................................
+ // DESCRIPTOR
+ //
+
+ /**
+ Objects of this type can implement an interface to respond to requests to
+ get and set. The default implementation handles simple properties.
+ */
function Descriptor() {
this.isDescriptor = true;
}
- // ..........................................................
- // DEFINING PROPERTIES API
- //
-
function MANDATORY_SETTER_FUNCTION(name) {
return function SETTER_FUNCTION(value) {
Ember['default'].assert("You must use Ember.set() to set the `" + name + "` property (of " + this + ") to `" + value + "`.", false);
};
}
function DEFAULT_GETTER_FUNCTION(name) {
return function GETTER_FUNCTION() {
- var meta = this['__ember_meta__'];
+ var meta = this["__ember_meta__"];
return meta && meta.values[name];
};
}
- /**
- NOTE: This is a low-level method used by other parts of the API. You almost
- never want to call this method directly. Instead you should use
- `Ember.mixin()` to define new properties.
-
- Defines a property on an object. This method works much like the ES5
- `Object.defineProperty()` method except that it can also accept computed
- properties and other special descriptors.
-
- Normally this method takes only three parameters. However if you pass an
- instance of `Descriptor` as the third param then you can pass an
- optional value as the fourth parameter. This is often more efficient than
- creating new descriptor hashes for each property.
-
- ## Examples
-
- ```javascript
- // ES5 compatible mode
- Ember.defineProperty(contact, 'firstName', {
- writable: true,
- configurable: false,
- enumerable: true,
- value: 'Charles'
- });
-
- // define a simple property
- Ember.defineProperty(contact, 'lastName', undefined, 'Jolley');
-
- // define a computed property
- Ember.defineProperty(contact, 'fullName', Ember.computed(function() {
- return this.firstName+' '+this.lastName;
- }).property('firstName', 'lastName'));
- ```
-
- @private
- @method defineProperty
- @for Ember
- @param {Object} obj the object to define this property on. This may be a prototype.
- @param {String} keyName the name of the property
- @param {Descriptor} [desc] an instance of `Descriptor` (typically a
- computed property) or an ES5 descriptor.
- You must provide this or `data` but not both.
- @param {*} [data] something other than a descriptor, that will
- become the explicit value of this property.
- */
-
function defineProperty(obj, keyName, desc, data, meta) {
var possibleDesc, existingDesc, watching, value;
if (!meta) {
meta = utils.meta(obj);
}
var watchEntry = meta.watching[keyName];
possibleDesc = obj[keyName];
- existingDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
+ existingDesc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined;
watching = watchEntry !== undefined && watchEntry > 0;
if (existingDesc) {
existingDesc.teardown(obj, keyName);
@@ -14822,10 +16554,12 @@
exports.overrideChains = overrideChains;
exports.beginPropertyChanges = beginPropertyChanges;
exports.endPropertyChanges = endPropertyChanges;
exports.changeProperties = changeProperties;
+ var PROPERTY_DID_CHANGE = utils.symbol("PROPERTY_DID_CHANGE");
+
var beforeObserverSet = new ObserverSet['default']();
var observerSet = new ObserverSet['default']();
var deferred = 0;
// ..........................................................
@@ -14846,15 +16580,15 @@
@param {Object} obj The object with the property that will change
@param {String} keyName The property key (or path) that will change.
@return {void}
*/
function propertyWillChange(obj, keyName) {
- var m = obj['__ember_meta__'];
- var watching = m && m.watching[keyName] > 0 || keyName === 'length';
+ var m = obj["__ember_meta__"];
+ var watching = m && m.watching[keyName] > 0 || keyName === "length";
var proto = m && m.proto;
var possibleDesc = obj[keyName];
- var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
+ var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined;
if (!watching) {
return;
}
@@ -14885,26 +16619,30 @@
@param {Object} obj The object with the property that will change
@param {String} keyName The property key (or path) that will change.
@return {void}
*/
function propertyDidChange(obj, keyName) {
- var m = obj['__ember_meta__'];
- var watching = m && m.watching[keyName] > 0 || keyName === 'length';
+ var m = obj["__ember_meta__"];
+ var watching = m && m.watching[keyName] > 0 || keyName === "length";
var proto = m && m.proto;
var possibleDesc = obj[keyName];
- var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
+ var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined;
if (proto === obj) {
return;
}
// shouldn't this mean that we're watching this key?
if (desc && desc.didChange) {
desc.didChange(obj, keyName);
}
- if (!watching && keyName !== 'length') {
+ if (obj[PROPERTY_DID_CHANGE]) {
+ obj[PROPERTY_DID_CHANGE](keyName);
+ }
+
+ if (!watching && keyName !== "length") {
return;
}
if (m && m.deps && m.deps[keyName]) {
dependentKeysDidChange(obj, keyName, m);
@@ -14989,11 +16727,11 @@
if (deps) {
keys = keysOf(deps);
for (i = 0; i < keys.length; i++) {
key = keys[i];
possibleDesc = obj[key];
- desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
+ desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined;
if (desc && desc._suspended === obj) {
continue;
}
@@ -15001,11 +16739,11 @@
}
}
}
function chainsWillChange(obj, keyName, m) {
- if (!(m.hasOwnProperty('chainWatchers') && m.chainWatchers[keyName])) {
+ if (!(m.hasOwnProperty("chainWatchers") && m.chainWatchers[keyName])) {
return;
}
var nodes = m.chainWatchers[keyName];
var events = [];
@@ -15019,11 +16757,11 @@
propertyWillChange(events[i], events[i + 1]);
}
}
function chainsDidChange(obj, keyName, m, suppressEvents) {
- if (!(m && m.hasOwnProperty('chainWatchers') && m.chainWatchers[keyName])) {
+ if (!(m && m.hasOwnProperty("chainWatchers") && m.chainWatchers[keyName])) {
return;
}
var nodes = m.chainWatchers[keyName];
var events = suppressEvents ? null : [];
@@ -15090,11 +16828,11 @@
function notifyBeforeObservers(obj, keyName) {
if (obj.isDestroying) {
return;
}
- var eventName = keyName + ':before';
+ var eventName = keyName + ":before";
var listeners, added;
if (deferred) {
listeners = beforeObserverSet.add(obj, keyName, eventName);
added = ember_metal__events.accumulateListeners(obj, eventName, listeners);
ember_metal__events.sendEvent(obj, eventName, [obj, keyName], added);
@@ -15106,32 +16844,32 @@
function notifyObservers(obj, keyName) {
if (obj.isDestroying) {
return;
}
- var eventName = keyName + ':change';
+ var eventName = keyName + ":change";
var listeners;
if (deferred) {
listeners = observerSet.add(obj, keyName, eventName);
ember_metal__events.accumulateListeners(obj, eventName, listeners);
} else {
ember_metal__events.sendEvent(obj, eventName, [obj, keyName]);
}
}
+ exports.PROPERTY_DID_CHANGE = PROPERTY_DID_CHANGE;
+
});
-enifed('ember-metal/property_get', ['exports', 'ember-metal/core', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/platform/define_property', 'ember-metal/is_none'], function (exports, Ember, EmberError, path_cache, define_property, isNone) {
+enifed('ember-metal/property_get', ['exports', 'ember-metal/core', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/platform/define_property', 'ember-metal/utils'], function (exports, Ember, EmberError, path_cache, define_property, utils) {
'use strict';
exports.get = get;
exports.normalizeTuple = normalizeTuple;
exports._getPath = _getPath;
exports.getWithDefault = getWithDefault;
- var FIRST_KEY = /^([^\.]+)/;
-
// ..........................................................
// GET AND SET
//
// If we are on a platform that supports accessors we can use those.
// Otherwise simulate accessors by looking up the property directly on the
@@ -15159,32 +16897,41 @@
@for Ember
@param {Object} obj The object to retrieve from.
@param {String} keyName The property key to retrieve
@return {Object} the property value or `null`.
*/
+ var FIRST_KEY = /^([^\.]+)/;
- function get(obj, keyName) {
+ var INTERCEPT_GET = utils.symbol("INTERCEPT_GET");
+ var UNHANDLED_GET = utils.symbol("UNHANDLED_GET");function get(obj, keyName) {
// Helpers that operate with 'this' within an #each
- if (keyName === '') {
+ if (keyName === "") {
return obj;
}
- if (!keyName && 'string' === typeof obj) {
+ if (!keyName && "string" === typeof obj) {
keyName = obj;
obj = Ember['default'].lookup;
}
Ember['default'].assert("Cannot call get with " + keyName + " key.", !!keyName);
Ember['default'].assert("Cannot call get with '" + keyName + "' on an undefined object.", obj !== undefined);
- if (isNone['default'](obj)) {
+ if (!obj) {
return _getPath(obj, keyName);
}
- var meta = obj['__ember_meta__'];
+ if (obj && typeof obj[INTERCEPT_GET] === "function") {
+ var result = obj[INTERCEPT_GET](obj, keyName);
+ if (result !== UNHANDLED_GET) {
+ return result;
+ }
+ }
+
+ var meta = obj["__ember_meta__"];
var possibleDesc = obj[keyName];
- var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
+ var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined;
var ret;
if (desc === undefined && path_cache.isPath(keyName)) {
return _getPath(obj, keyName);
}
@@ -15197,39 +16944,25 @@
ret = meta.values[keyName];
} else {
ret = obj[keyName];
}
- if (ret === undefined && 'object' === typeof obj && !(keyName in obj) && 'function' === typeof obj.unknownProperty) {
+ if (ret === undefined && "object" === typeof obj && !(keyName in obj) && "function" === typeof obj.unknownProperty) {
return obj.unknownProperty(keyName);
}
return ret;
}
}
- /**
- Normalizes a target/path pair to reflect that actual target/path that should
- be observed, etc. This takes into account passing in global property
- paths (i.e. a path beginning with a capital letter not defined on the
- target).
-
- @private
- @method normalizeTuple
- @for Ember
- @param {Object} target The current target. May be `null`.
- @param {String} path A path on the target or a global property path.
- @return {Array} a temporary array with the normalized target/path pair.
- */
-
function normalizeTuple(target, path) {
var hasThis = path_cache.hasThis(path);
var isGlobal = !hasThis && path_cache.isGlobal(path);
var key;
if (!target && !isGlobal) {
- return [undefined, ''];
+ return [undefined, ""];
}
if (hasThis) {
path = path.slice(5);
}
@@ -15253,11 +16986,10 @@
function validateIsPath(path) {
if (!path || path.length === 0) {
throw new EmberError['default']("Object in path " + path + " could not be found or was destroyed.");
}
}
-
function _getPath(root, path) {
var hasThis, parts, tuple, idx, len;
// detect complicated paths and normalize them
hasThis = path_cache.hasThis(path);
@@ -15289,20 +17021,37 @@
return value;
}
exports['default'] = get;
+ exports.INTERCEPT_GET = INTERCEPT_GET;
+ exports.UNHANDLED_GET = UNHANDLED_GET;
+
});
-enifed('ember-metal/property_set', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/platform/define_property'], function (exports, Ember, property_get, property_events, properties, EmberError, path_cache, define_property) {
+enifed('ember-metal/property_set', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/platform/define_property', 'ember-metal/utils'], function (exports, Ember, property_get, property_events, properties, EmberError, path_cache, define_property, utils) {
'use strict';
exports.set = set;
exports.trySet = trySet;
- function set(obj, keyName, value, tolerant) {
- if (typeof obj === 'string') {
+ /**
+ Sets the value of a property on an object, respecting computed properties
+ and notifying observers and other listeners of the change. If the
+ property is not defined but the object implements the `setUnknownProperty`
+ method then that will be invoked as well.
+
+ @method set
+ @for Ember
+ @param {Object} obj The object to modify.
+ @param {String} keyName The property key to set
+ @param {Object} value The value to set
+ @return {Object} the passed value.
+ */
+ var INTERCEPT_SET = utils.symbol("INTERCEPT_SET");
+ var UNHANDLED_SET = utils.symbol("UNHANDLED_SET");function set(obj, keyName, value, tolerant) {
+ if (typeof obj === "string") {
Ember['default'].assert("Path '" + obj + "' must be global if no obj is given.", path_cache.isGlobalPath(obj));
value = keyName;
keyName = obj;
obj = Ember['default'].lookup;
}
@@ -15311,39 +17060,49 @@
if (obj === Ember['default'].lookup) {
return setPath(obj, keyName, value, tolerant);
}
+ // This path exists purely to implement backwards-compatible
+ // effects (specifically, setting a property on a view may
+ // invoke a mutator on `attrs`).
+ if (obj && typeof obj[INTERCEPT_SET] === "function") {
+ var result = obj[INTERCEPT_SET](obj, keyName, value, tolerant);
+ if (result !== UNHANDLED_SET) {
+ return result;
+ }
+ }
+
var meta, possibleDesc, desc;
if (obj) {
- meta = obj['__ember_meta__'];
+ meta = obj["__ember_meta__"];
possibleDesc = obj[keyName];
- desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
+ desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined;
}
var isUnknown, currentValue;
if ((!obj || desc === undefined) && path_cache.isPath(keyName)) {
return setPath(obj, keyName, value, tolerant);
}
Ember['default'].assert("You need to provide an object and key to `set`.", !!obj && keyName !== undefined);
- Ember['default'].assert('calling set on destroyed object', !obj.isDestroyed);
+ Ember['default'].assert("calling set on destroyed object", !obj.isDestroyed);
if (desc) {
desc.set(obj, keyName, value);
} else {
- if (obj !== null && value !== undefined && typeof obj === 'object' && obj[keyName] === value) {
+ if (obj !== null && value !== undefined && typeof obj === "object" && obj[keyName] === value) {
return value;
}
- isUnknown = 'object' === typeof obj && !(keyName in obj);
+ isUnknown = "object" === typeof obj && !(keyName in obj);
// setUnknownProperty is called if `obj` is an object,
// the property does not already exist, and the
// `setUnknownProperty` method exists on the object
- if (isUnknown && 'function' === typeof obj.setUnknownProperty) {
+ if (isUnknown && "function" === typeof obj.setUnknownProperty) {
obj.setUnknownProperty(keyName, value);
} else if (meta && meta.watching[keyName] > 0) {
if (meta.proto !== obj) {
if (define_property.hasPropertyAccessors) {
@@ -15358,72 +17117,63 @@
if (define_property.hasPropertyAccessors) {
if (currentValue === undefined && !(keyName in obj) || !Object.prototype.propertyIsEnumerable.call(obj, keyName)) {
properties.defineProperty(obj, keyName, null, value); // setup mandatory setter
} else {
- meta.values[keyName] = value;
- }
+ meta.values[keyName] = value;
+ }
} else {
obj[keyName] = value;
}
property_events.propertyDidChange(obj, keyName);
}
} else {
obj[keyName] = value;
+ if (obj[property_events.PROPERTY_DID_CHANGE]) {
+ obj[property_events.PROPERTY_DID_CHANGE](keyName);
+ }
}
}
return value;
}
function setPath(root, path, value, tolerant) {
var keyName;
// get the last part of the path
- keyName = path.slice(path.lastIndexOf('.') + 1);
+ keyName = path.slice(path.lastIndexOf(".") + 1);
// get the first part of the part
path = path === keyName ? keyName : path.slice(0, path.length - (keyName.length + 1));
// unless the path is this, look up the first part to
// get the root
- if (path !== 'this') {
+ if (path !== "this") {
root = property_get._getPath(root, path);
}
if (!keyName || keyName.length === 0) {
- throw new EmberError['default']('Property set failed: You passed an empty path');
+ throw new EmberError['default']("Property set failed: You passed an empty path");
}
if (!root) {
if (tolerant) {
return;
} else {
- throw new EmberError['default']('Property set failed: object in path "' + path + '" could not be found or was destroyed.');
+ throw new EmberError['default']("Property set failed: object in path \"" + path + "\" could not be found or was destroyed.");
}
}
return set(root, keyName, value);
}
-
- /**
- Error-tolerant form of `Ember.set`. Will not blow up if any part of the
- chain is `undefined`, `null`, or destroyed.
-
- This is primarily used when syncing bindings, which may try to update after
- an object has been destroyed.
-
- @method trySet
- @for Ember
- @param {Object} obj The object to modify.
- @param {String} path The property path to set
- @param {Object} value The value to set
- */
-
function trySet(root, path, value) {
return set(root, path, value, true);
}
+ exports.INTERCEPT_SET = INTERCEPT_SET;
+ exports.UNHANDLED_SET = UNHANDLED_SET;
+
});
enifed('ember-metal/run_loop', ['exports', 'ember-metal/core', 'ember-metal/utils', 'ember-metal/array', 'ember-metal/property_events', 'backburner'], function (exports, Ember, utils, array, property_events, Backburner) {
'use strict';
@@ -15675,11 +17425,11 @@
will be resolved on the target object at the time the scheduled item is
invoked allowing you to change the target function.
@param {Object} [arguments*] Optional arguments to be passed to the queued method.
@return {void}
*/
- run.schedule = function () /* queue, target, method */{
+ run.schedule = function () {
checkAutoRun();
backburner.schedule.apply(backburner, arguments);
};
// Used by global test teardown
@@ -15737,11 +17487,11 @@
target at the time the method is invoked.
@param {Object} [args*] Optional arguments to pass to the timeout.
@param {Number} wait Number of milliseconds to wait.
@return {*} Timer information for use in cancelling, see `run.cancel`.
*/
- run.later = function () /*target, method*/{
+ run.later = function () {
return backburner.later.apply(backburner, arguments);
};
/**
Schedule a function to run one time during the current RunLoop. This is equivalent
@@ -15754,16 +17504,15 @@
target at the time the method is invoked.
@param {Object} [args*] Optional arguments to pass to the timeout.
@return {Object} Timer information for use in cancelling, see `run.cancel`.
*/
run.once = function () {
- checkAutoRun();
-
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
+ checkAutoRun();
args.unshift('actions');
return backburner.scheduleOnce.apply(backburner, args);
};
/**
@@ -15815,11 +17564,11 @@
If you pass a string it will be resolved on the
target at the time the method is invoked.
@param {Object} [args*] Optional arguments to pass to the timeout.
@return {Object} Timer information for use in cancelling, see `run.cancel`.
*/
- run.scheduleOnce = function () /*queue, target, method*/{
+ run.scheduleOnce = function () {
checkAutoRun();
return backburner.scheduleOnce.apply(backburner, arguments);
};
/**
@@ -16075,17 +17824,39 @@
run._addQueue = function (name, after) {
if (array.indexOf.call(run.queues, name) === -1) {
run.queues.splice(array.indexOf.call(run.queues, after) + 1, 0, name);
}
};
+ /* queue, target, method */ /*target, method*/ /*queue, target, method*/
});
enifed('ember-metal/set_properties', ['exports', 'ember-metal/property_events', 'ember-metal/property_set', 'ember-metal/keys'], function (exports, property_events, property_set, keys) {
'use strict';
+
+ /**
+ Set a list of properties on an object. These properties are set inside
+ a single `beginPropertyChanges` and `endPropertyChanges` batch, so
+ observers will be buffered.
+
+ ```javascript
+ var anObject = Ember.Object.create();
+
+ anObject.setProperties({
+ firstName: 'Stanley',
+ lastName: 'Stuart',
+ age: 21
+ });
+ ```
+
+ @method setProperties
+ @param obj
+ @param {Object} properties
+ @return obj
+ */
exports['default'] = setProperties;
function setProperties(obj, properties) {
if (!properties || typeof properties !== "object") {
return obj;
}
@@ -16132,11 +17903,11 @@
this.alternate = alternate;
}
ConditionalStream.prototype = create['default'](Stream['default'].prototype);
- ConditionalStream.prototype.valueFn = function () {
+ ConditionalStream.prototype.compute = function () {
var oldTestResult = this.oldTestResult;
var newTestResult = !!utils.read(this.test);
if (newTestResult !== oldTestResult) {
switch (oldTestResult) {
@@ -16160,125 +17931,238 @@
return newTestResult ? utils.read(this.consequent) : utils.read(this.alternate);
};
});
-enifed('ember-metal/streams/simple', ['exports', 'ember-metal/merge', 'ember-metal/streams/stream', 'ember-metal/platform/create', 'ember-metal/streams/utils'], function (exports, merge, Stream, create, utils) {
+enifed('ember-metal/streams/dependency', ['exports', 'ember-metal/core', 'ember-metal/merge', 'ember-metal/streams/utils'], function (exports, Ember, merge, utils) {
'use strict';
- function SimpleStream(source) {
- this.init();
- this.source = source;
+ function Dependency(depender, dependee) {
+ Ember['default'].assert("Dependency error: Depender must be a stream", utils.isStream(depender));
- if (utils.isStream(source)) {
- source.subscribe(this._didChange, this);
- }
+ this.next = null;
+ this.prev = null;
+ this.depender = depender;
+ this.dependee = dependee;
+ this.unsubscription = null;
}
- SimpleStream.prototype = create['default'](Stream['default'].prototype);
+ merge['default'](Dependency.prototype, {
+ subscribe: function () {
+ Ember['default'].assert("Dependency error: Dependency tried to subscribe while already subscribed", !this.unsubscription);
- merge['default'](SimpleStream.prototype, {
- valueFn: function () {
- return utils.read(this.source);
+ this.unsubscription = utils.subscribe(this.dependee, this.depender.notify, this.depender);
},
- setValue: function (value) {
- var source = this.source;
-
- if (utils.isStream(source)) {
- source.setValue(value);
+ unsubscribe: function () {
+ if (this.unsubscription) {
+ this.unsubscription();
+ this.unsubscription = null;
}
},
- setSource: function (nextSource) {
- var prevSource = this.source;
- if (nextSource !== prevSource) {
- if (utils.isStream(prevSource)) {
- prevSource.unsubscribe(this._didChange, this);
- }
+ replace: function (dependee) {
+ if (this.dependee !== dependee) {
+ this.dependee = dependee;
- if (utils.isStream(nextSource)) {
- nextSource.subscribe(this._didChange, this);
+ if (this.unsubscription) {
+ this.unsubscribe();
+ this.subscribe();
}
+ }
+ },
- this.source = nextSource;
- this.notify();
+ getValue: function () {
+ return utils.read(this.dependee);
+ },
+
+ setValue: function (value) {
+ return utils.setValue(this.dependee, value);
+ }
+
+ // destroy() {
+ // var next = this.next;
+ // var prev = this.prev;
+
+ // if (prev) {
+ // prev.next = next;
+ // } else {
+ // this.depender.dependencyHead = next;
+ // }
+
+ // if (next) {
+ // next.prev = prev;
+ // } else {
+ // this.depender.dependencyTail = prev;
+ // }
+
+ // this.unsubscribe();
+ // }
+ });
+
+ exports['default'] = Dependency;
+
+});
+enifed('ember-metal/streams/key-stream', ['exports', 'ember-metal/core', 'ember-metal/merge', 'ember-metal/platform/create', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/observer', 'ember-metal/streams/stream', 'ember-metal/streams/utils'], function (exports, Ember, merge, create, property_get, property_set, observer, Stream, utils) {
+
+ 'use strict';
+
+ function KeyStream(source, key) {
+ Ember['default'].assert('KeyStream error: source must be a stream', utils.isStream(source)); // TODO: This isn't necessary.
+ Ember['default'].assert('KeyStream error: key must be a non-empty string', typeof key === 'string' && key.length > 0);
+ Ember['default'].assert('KeyStream error: key must not have a \'.\'', key.indexOf('.') === -1);
+
+ // used to get the original path for debugging and legacy purposes
+ var label = labelFor(source, key);
+
+ this.init(label);
+ this.path = label;
+ this.sourceDep = this.addMutableDependency(source);
+ this.observedObject = null;
+ this.key = key;
+ }
+
+ function labelFor(source, key) {
+ return source.label ? source.label + '.' + key : key;
+ }
+
+ KeyStream.prototype = create['default'](Stream['default'].prototype);
+
+ merge['default'](KeyStream.prototype, {
+ compute: function () {
+ var object = this.sourceDep.getValue();
+ if (object) {
+ return property_get.get(object, this.key);
}
},
- _didChange: function () {
+ setValue: function (value) {
+ var object = this.sourceDep.getValue();
+ if (object) {
+ property_set.set(object, this.key, value);
+ }
+ },
+
+ setSource: function (source) {
+ this.sourceDep.replace(source);
this.notify();
},
- _super$destroy: Stream['default'].prototype.destroy,
+ _super$revalidate: Stream['default'].prototype.revalidate,
- destroy: function () {
- if (this._super$destroy()) {
- if (utils.isStream(this.source)) {
- this.source.unsubscribe(this._didChange, this);
+ revalidate: function (value) {
+ this._super$revalidate(value);
+
+ var object = this.sourceDep.getValue();
+ if (object !== this.observedObject) {
+ this.deactivate();
+
+ if (object && typeof object === 'object') {
+ observer.addObserver(object, this.key, this, this.notify);
+ this.observedObject = object;
}
- this.source = undefined;
- return true;
}
+ },
+
+ _super$deactivate: Stream['default'].prototype.deactivate,
+
+ deactivate: function () {
+ this._super$deactivate();
+
+ if (this.observedObject) {
+ observer.removeObserver(this.observedObject, this.key, this, this.notify);
+ this.observedObject = null;
+ }
}
});
- exports['default'] = SimpleStream;
+ exports['default'] = KeyStream;
});
-enifed('ember-metal/streams/stream', ['exports', 'ember-metal/platform/create', 'ember-metal/path_cache'], function (exports, create, path_cache) {
+enifed('ember-metal/streams/proxy-stream', ['exports', 'ember-metal/merge', 'ember-metal/streams/stream', 'ember-metal/platform/create'], function (exports, merge, Stream, create) {
'use strict';
- function Subscriber(callback, context) {
- this.next = null;
- this.prev = null;
- this.callback = callback;
- this.context = context;
+ function ProxyStream(source, label) {
+ this.init(label);
+ this.sourceDep = this.addMutableDependency(source);
}
- Subscriber.prototype.removeFrom = function (stream) {
- var next = this.next;
- var prev = this.prev;
+ ProxyStream.prototype = create['default'](Stream['default'].prototype);
- if (prev) {
- prev.next = next;
- } else {
- stream.subscriberHead = next;
- }
+ merge['default'](ProxyStream.prototype, {
+ compute: function () {
+ return this.sourceDep.getValue();
+ },
- if (next) {
- next.prev = prev;
- } else {
- stream.subscriberTail = prev;
+ setValue: function (value) {
+ this.sourceDep.setValue(value);
+ },
+
+ setSource: function (source) {
+ this.sourceDep.replace(source);
+ this.notify();
}
- };
+ });
- /*
- @public
- @class Stream
- @namespace Ember.stream
- @constructor
- */
- function Stream(fn) {
- this.init();
- this.valueFn = fn;
+ exports['default'] = ProxyStream;
+
+});
+enifed('ember-metal/streams/stream', ['exports', 'ember-metal/core', 'ember-metal/platform/create', 'ember-metal/path_cache', 'ember-metal/observer', 'ember-metal/streams/utils', 'ember-metal/streams/subscriber', 'ember-metal/streams/dependency'], function (exports, Ember, create, path_cache, observer, utils, Subscriber, Dependency) {
+
+ 'use strict';
+
+ function Stream(fn, label) {
+ this.init(label);
+ this.compute = fn;
}
+ var KeyStream;
+ var ProxyMixin;
+
Stream.prototype = {
isStream: true,
- init: function () {
- this.state = 'dirty';
+ init: function (label) {
+ this.label = makeLabel(label);
+ this.isActive = false;
+ this.isDirty = true;
+ this.isDestroyed = false;
this.cache = undefined;
+ this.children = undefined;
this.subscriberHead = null;
this.subscriberTail = null;
- this.children = undefined;
- this._label = undefined;
+ this.dependencyHead = null;
+ this.dependencyTail = null;
+ this.observedProxy = null;
},
+ _makeChildStream: function (key) {
+ KeyStream = KeyStream || Ember['default'].__loader.require("ember-metal/streams/key-stream")["default"];
+ return new KeyStream(this, key);
+ },
+
+ removeChild: function (key) {
+ delete this.children[key];
+ },
+
+ getKey: function (key) {
+ if (this.children === undefined) {
+ this.children = create['default'](null);
+ }
+
+ var keyStream = this.children[key];
+
+ if (keyStream === undefined) {
+ keyStream = this._makeChildStream(key);
+ this.children[key] = keyStream;
+ }
+
+ return keyStream;
+ },
+
get: function (path) {
var firstKey = path_cache.getFirstKey(path);
var tailPath = path_cache.getTailPath(path);
if (this.children === undefined) {
@@ -16298,58 +18182,167 @@
return keyStream.get(tailPath);
}
},
value: function () {
- if (this.state === 'clean') {
- return this.cache;
- } else if (this.state === 'dirty') {
- this.state = 'clean';
- return this.cache = this.valueFn();
- }
// TODO: Ensure value is never called on a destroyed stream
// so that we can uncomment this assertion.
//
- // Ember.assert("Stream error: value was called in an invalid state: " + this.state);
+ // Ember.assert("Stream error: value was called after the stream was destroyed", !this.isDestroyed);
+
+ // TODO: Remove this block. This will require ensuring we are
+ // not treating streams as "volatile" anywhere.
+ if (!this.isActive) {
+ this.isDirty = true;
+ }
+
+ var willRevalidate = false;
+
+ if (!this.isActive && this.subscriberHead) {
+ this.activate();
+ willRevalidate = true;
+ }
+
+ if (this.isDirty) {
+ if (this.isActive) {
+ willRevalidate = true;
+ }
+
+ this.cache = this.compute();
+ this.isDirty = false;
+ }
+
+ if (willRevalidate) {
+ this.revalidate(this.cache);
+ }
+
+ return this.cache;
},
- valueFn: function () {
- throw new Error("Stream error: valueFn not implemented");
+ addMutableDependency: function (object) {
+ var dependency = new Dependency['default'](this, object);
+
+ if (this.isActive) {
+ dependency.subscribe();
+ }
+
+ if (this.dependencyHead === null) {
+ this.dependencyHead = this.dependencyTail = dependency;
+ } else {
+ var tail = this.dependencyTail;
+ tail.next = dependency;
+ dependency.prev = tail;
+ this.dependencyTail = dependency;
+ }
+
+ return dependency;
},
+ addDependency: function (object) {
+ if (utils.isStream(object)) {
+ this.addMutableDependency(object);
+ }
+ },
+
+ subscribeDependencies: function () {
+ var dependency = this.dependencyHead;
+ while (dependency) {
+ var next = dependency.next;
+ dependency.subscribe();
+ dependency = next;
+ }
+ },
+
+ unsubscribeDependencies: function () {
+ var dependency = this.dependencyHead;
+ while (dependency) {
+ var next = dependency.next;
+ dependency.unsubscribe();
+ dependency = next;
+ }
+ },
+
+ maybeDeactivate: function () {
+ if (!this.subscriberHead && this.isActive) {
+ this.isActive = false;
+ this.unsubscribeDependencies();
+ this.deactivate();
+ }
+ },
+
+ activate: function () {
+ this.isActive = true;
+ this.subscribeDependencies();
+ },
+
+ revalidate: function (value) {
+ if (value !== this.observedProxy) {
+ this.deactivate();
+
+ ProxyMixin = ProxyMixin || Ember['default'].__loader.require("ember-runtime/mixins/-proxy")["default"];
+
+ if (ProxyMixin.detect(value)) {
+ observer.addObserver(value, "content", this, this.notify);
+ this.observedProxy = value;
+ }
+ }
+ },
+
+ deactivate: function () {
+ if (this.observedProxy) {
+ observer.removeObserver(this.observedProxy, "content", this, this.notify);
+ this.observedProxy = null;
+ }
+ },
+
+ compute: function () {
+ throw new Error("Stream error: compute not implemented");
+ },
+
setValue: function () {
throw new Error("Stream error: setValue not implemented");
},
notify: function () {
this.notifyExcept();
},
notifyExcept: function (callbackToSkip, contextToSkip) {
- if (this.state === 'clean') {
- this.state = 'dirty';
- this._notifySubscribers(callbackToSkip, contextToSkip);
+ if (!this.isDirty) {
+ this.isDirty = true;
+ this.notifySubscribers(callbackToSkip, contextToSkip);
}
},
subscribe: function (callback, context) {
- var subscriber = new Subscriber(callback, context, this);
+ Ember['default'].assert("You tried to subscribe to a stream but the callback provided was not a function.", typeof callback === "function");
+
+ var subscriber = new Subscriber['default'](callback, context, this);
if (this.subscriberHead === null) {
this.subscriberHead = this.subscriberTail = subscriber;
} else {
var tail = this.subscriberTail;
tail.next = subscriber;
subscriber.prev = tail;
this.subscriberTail = subscriber;
}
var stream = this;
- return function () {
+ return function (prune) {
subscriber.removeFrom(stream);
+ if (prune) {
+ stream.prune();
+ }
};
},
+ prune: function () {
+ if (this.subscriberHead === null) {
+ this.destroy(true);
+ }
+ },
+
unsubscribe: function (callback, context) {
var subscriber = this.subscriberHead;
while (subscriber) {
var next = subscriber.next;
@@ -16358,11 +18351,11 @@
}
subscriber = next;
}
},
- _notifySubscribers: function (callbackToSkip, contextToSkip) {
+ notifySubscribers: function (callbackToSkip, contextToSkip) {
var subscriber = this.subscriberHead;
while (subscriber) {
var next = subscriber.next;
@@ -16381,115 +18374,83 @@
callback.call(context, this);
}
}
},
- destroy: function () {
- if (this.state !== 'destroyed') {
- this.state = 'destroyed';
+ destroy: function (prune) {
+ if (!this.isDestroyed) {
+ this.isDestroyed = true;
- var children = this.children;
- for (var key in children) {
- children[key].destroy();
- }
-
this.subscriberHead = this.subscriberTail = null;
+ this.maybeDeactivate();
- return true;
- }
- },
+ var dependencies = this.dependencies;
- isGlobal: function () {
- var stream = this;
- while (stream !== undefined) {
- if (stream._isRoot) {
- return stream._isGlobal;
+ if (dependencies) {
+ for (var i = 0, l = dependencies.length; i < l; i++) {
+ dependencies[i](prune);
+ }
}
- stream = stream.source;
+
+ this.dependencies = null;
+ return true;
}
}
};
+ Stream.wrap = function (value, Kind, param) {
+ if (utils.isStream(value)) {
+ return value;
+ } else {
+ return new Kind(value, param);
+ }
+ };
+
+ function makeLabel(label) {
+ if (label === undefined) {
+ return "(no label)";
+ } else {
+ return label;
+ }
+ }
+
exports['default'] = Stream;
});
-enifed('ember-metal/streams/stream_binding', ['exports', 'ember-metal/platform/create', 'ember-metal/merge', 'ember-metal/run_loop', 'ember-metal/streams/stream'], function (exports, create, merge, run, Stream) {
+enifed('ember-metal/streams/subscriber', ['exports', 'ember-metal/merge'], function (exports, merge) {
'use strict';
- function StreamBinding(stream) {
- Ember.assert("StreamBinding error: tried to bind to object that is not a stream", stream && stream.isStream);
-
- this.init();
- this.stream = stream;
- this.senderCallback = undefined;
- this.senderContext = undefined;
- this.senderValue = undefined;
-
- stream.subscribe(this._onNotify, this);
+ function Subscriber(callback, context) {
+ this.next = null;
+ this.prev = null;
+ this.callback = callback;
+ this.context = context;
}
- StreamBinding.prototype = create['default'](Stream['default'].prototype);
+ merge['default'](Subscriber.prototype, {
+ removeFrom: function (stream) {
+ var next = this.next;
+ var prev = this.prev;
- merge['default'](StreamBinding.prototype, {
- valueFn: function () {
- return this.stream.value();
- },
-
- _onNotify: function () {
- this._scheduleSync(undefined, undefined, this);
- },
-
- setValue: function (value, callback, context) {
- this._scheduleSync(value, callback, context);
- },
-
- _scheduleSync: function (value, callback, context) {
- if (this.senderCallback === undefined && this.senderContext === undefined) {
- this.senderCallback = callback;
- this.senderContext = context;
- this.senderValue = value;
- run['default'].schedule('sync', this, this._sync);
- } else if (this.senderContext !== this) {
- this.senderCallback = callback;
- this.senderContext = context;
- this.senderValue = value;
+ if (prev) {
+ prev.next = next;
+ } else {
+ stream.subscriberHead = next;
}
- },
- _sync: function () {
- if (this.state === 'destroyed') {
- return;
+ if (next) {
+ next.prev = prev;
+ } else {
+ stream.subscriberTail = prev;
}
- if (this.senderContext !== this) {
- this.stream.setValue(this.senderValue);
- }
-
- var senderCallback = this.senderCallback;
- var senderContext = this.senderContext;
- this.senderCallback = undefined;
- this.senderContext = undefined;
- this.senderValue = undefined;
-
- // Force StreamBindings to always notify
- this.state = 'clean';
-
- this.notifyExcept(senderCallback, senderContext);
- },
-
- _super$destroy: Stream['default'].prototype.destroy,
-
- destroy: function () {
- if (this._super$destroy()) {
- this.stream.unsubscribe(this._onNotify, this);
- return true;
- }
+ stream.maybeDeactivate();
}
});
- exports['default'] = StreamBinding;
+ exports['default'] = Subscriber;
});
enifed('ember-metal/streams/utils', ['exports', './stream'], function (exports, Stream) {
'use strict';
@@ -16501,127 +18462,70 @@
exports.readArray = readArray;
exports.readHash = readHash;
exports.scanArray = scanArray;
exports.scanHash = scanHash;
exports.concat = concat;
+ exports.labelsFor = labelsFor;
+ exports.labelsForObject = labelsForObject;
+ exports.labelFor = labelFor;
+ exports.or = or;
+ exports.addDependency = addDependency;
+ exports.zip = zip;
+ exports.zipHash = zipHash;
exports.chain = chain;
+ exports.setValue = setValue;
- function isStream(object) {
- return object && object.isStream;
- }
-
/*
- A method of subscribing to a stream which is safe for use with a non-stream
- object. If a non-stream object is passed, the function does nothing.
+ Check whether an object is a stream or not
@public
@for Ember.stream
- @function subscribe
- @param {Object|Stream} object object or stream to potentially subscribe to
- @param {Function} callback function to run when stream value changes
- @param {Object} [context] the callback will be executed with this context if it
- is provided
- */
+ @function isStream
+ @param {Object|Stream} object object to check whether it is a stream
+ @return {Boolean} `true` if the object is a stream, `false` otherwise
+ */
+ function isStream(object) {
+ return object && object.isStream;
+ }
function subscribe(object, callback, context) {
if (object && object.isStream) {
- object.subscribe(callback, context);
+ return object.subscribe(callback, context);
}
}
- /*
- A method of unsubscribing from a stream which is safe for use with a non-stream
- object. If a non-stream object is passed, the function does nothing.
-
- @public
- @for Ember.stream
- @function unsubscribe
- @param {Object|Stream} object object or stream to potentially unsubscribe from
- @param {Function} callback function originally passed to `subscribe()`
- @param {Object} [context] object originally passed to `subscribe()`
- */
-
function unsubscribe(object, callback, context) {
if (object && object.isStream) {
object.unsubscribe(callback, context);
}
}
- /*
- Retrieve the value of a stream, or in the case a non-stream object is passed,
- return the object itself.
-
- @public
- @for Ember.stream
- @function read
- @param {Object|Stream} object object to return the value of
- @return the stream's current value, or the non-stream object itself
- */
-
function read(object) {
if (object && object.isStream) {
return object.value();
} else {
return object;
}
}
- /*
- Map an array, replacing any streams with their values.
-
- @public
- @for Ember.stream
- @function readArray
- @param {Array} array The array to read values from
- @return {Array} a new array of the same length with the values of non-stream
- objects mapped from their original positions untouched, and
- the values of stream objects retaining their original position
- and replaced with the stream's current value.
- */
-
function readArray(array) {
var length = array.length;
var ret = new Array(length);
for (var i = 0; i < length; i++) {
ret[i] = read(array[i]);
}
return ret;
}
- /*
- Map a hash, replacing any stream property values with the current value of that
- stream.
-
- @public
- @for Ember.stream
- @function readHash
- @param {Object} object The hash to read keys and values from
- @return {Object} a new object with the same keys as the passed object. The
- property values in the new object are the original values in
- the case of non-stream objects, and the streams' current
- values in the case of stream objects.
- */
-
function readHash(object) {
var ret = {};
for (var key in object) {
ret[key] = read(object[key]);
}
return ret;
}
- /*
- Check whether an array contains any stream values
-
- @public
- @for Ember.stream
- @function scanArray
- @param {Array} array array given to a handlebars helper
- @return {Boolean} `true` if the array contains a stream/bound value, `false`
- otherwise
- */
-
function scanArray(array) {
var length = array.length;
var containsStream = false;
for (var i = 0; i < length; i++) {
@@ -16632,21 +18536,10 @@
}
return containsStream;
}
- /*
- Check whether a hash has any stream property values
-
- @public
- @for Ember.stream
- @function scanHash
- @param {Object} hash "hash" argument given to a handlebars helper
- @return {Boolean} `true` if the object contains a stream/bound value, `false`
- otherwise
- */
-
function scanHash(hash) {
var containsStream = false;
for (var prop in hash) {
if (isStream(hash[prop])) {
@@ -16656,120 +18549,197 @@
}
return containsStream;
}
- /*
- Join an array, with any streams replaced by their current values
-
- @public
- @for Ember.stream
- @function concat
- @param {Array} array An array containing zero or more stream objects and
- zero or more non-stream objects
- @param {String} separator string to be used to join array elements
- @return {String} String with array elements concatenated and joined by the
- provided separator, and any stream array members having been
- replaced by the current value of the stream
- */
-
function concat(array, separator) {
// TODO: Create subclass ConcatStream < Stream. Defer
// subscribing to streams until the value() is called.
var hasStream = scanArray(array);
if (hasStream) {
var i, l;
var stream = new Stream['default'](function () {
- return readArray(array).join(separator);
+ return concat(readArray(array), separator);
+ }, function () {
+ var labels = labelsFor(array);
+ return 'concat([' + labels.join(', ') + ']; separator=' + inspect(separator) + ')';
});
for (i = 0, l = array.length; i < l; i++) {
subscribe(array[i], stream.notify, stream);
}
+ // used by angle bracket components to detect an attribute was provided
+ // as a string literal
+ stream.isConcat = true;
return stream;
} else {
return array.join(separator);
}
}
- /*
- Generate a new stream by providing a source stream and a function that can
- be used to transform the stream's value. In the case of a non-stream object,
- returns the result of the function.
+ function labelsFor(streams) {
+ var labels = [];
- The value to transform would typically be available to the function you pass
- to `chain()` via scope. For example:
+ for (var i = 0, l = streams.length; i < l; i++) {
+ var stream = streams[i];
+ labels.push(labelFor(stream));
+ }
- ```javascript
- var source = ...; // stream returning a number
- // or a numeric (non-stream) object
- var result = chain(source, function() {
- var currentValue = read(source);
- return currentValue + 1;
- });
- ```
+ return labels;
+ }
- In the example, result is a stream if source is a stream, or a number of
- source was numeric.
+ function labelsForObject(streams) {
+ var labels = [];
- @public
- @for Ember.stream
- @function chain
- @param {Object|Stream} value A stream or non-stream object
- @param {Function} fn function to be run when the stream value changes, or to
- be run once in the case of a non-stream object
- @return {Object|Stream} In the case of a stream `value` parameter, a new
- stream that will be updated with the return value of
- the provided function `fn`. In the case of a
- non-stream object, the return value of the provided
- function `fn`.
- */
+ for (var prop in streams) {
+ labels.push('' + prop + ': ' + inspect(streams[prop]));
+ }
- function chain(value, fn) {
+ return labels.length ? '{ ' + labels.join(', ') + ' }' : '{}';
+ }
+
+ function labelFor(maybeStream) {
+ if (isStream(maybeStream)) {
+ var stream = maybeStream;
+ return typeof stream.label === 'function' ? stream.label() : stream.label;
+ } else {
+ return inspect(maybeStream);
+ }
+ }
+
+ function inspect(value) {
+ switch (typeof value) {
+ case 'string':
+ return '"' + value + '"';
+ case 'object':
+ return '{ ... }';
+ case 'function':
+ return 'function() { ... }';
+ default:
+ return String(value);
+ }
+ }
+ function or(first, second) {
+ var stream = new Stream['default'](function () {
+ return first.value() || second.value();
+ }, function () {
+ return '' + labelFor(first) + ' || ' + labelFor(second);
+ });
+
+ stream.addDependency(first);
+ stream.addDependency(second);
+
+ return stream;
+ }
+
+ function addDependency(stream, dependency) {
+ Ember.assert('Cannot add a stream as a dependency to a non-stream', isStream(stream) || !isStream(dependency));
+ if (isStream(stream)) {
+ stream.addDependency(dependency);
+ }
+ }
+
+ function zip(streams, callback, label) {
+ Ember.assert('Must call zip with a label', !!label);
+
+ var stream = new Stream['default'](function () {
+ var array = readArray(streams);
+ return callback ? callback(array) : array;
+ }, function () {
+ return '' + label + '(' + labelsFor(streams) + ')';
+ });
+
+ for (var i = 0, l = streams.length; i < l; i++) {
+ stream.addDependency(streams[i]);
+ }
+
+ return stream;
+ }
+
+ function zipHash(object, callback, label) {
+ Ember.assert('Must call zipHash with a label', !!label);
+
+ var stream = new Stream['default'](function () {
+ var hash = readHash(object);
+ return callback ? callback(hash) : hash;
+ }, function () {
+ return '' + label + '(' + labelsForObject(object) + ')';
+ });
+
+ for (var prop in object) {
+ stream.addDependency(object[prop]);
+ }
+
+ return stream;
+ }
+
+ function chain(value, fn, label) {
+ Ember.assert('Must call chain with a label', !!label);
if (isStream(value)) {
- var stream = new Stream['default'](fn);
- subscribe(value, stream.notify, stream);
+ var stream = new Stream['default'](fn, function () {
+ return '' + label + '(' + labelFor(value) + ')';
+ });
+ stream.addDependency(value);
return stream;
} else {
return fn();
}
}
+ function setValue(object, value) {
+ if (object && object.isStream) {
+ object.setValue(value);
+ }
+ }
+
});
-enifed('ember-metal/utils', ['exports', 'ember-metal/core', 'ember-metal/platform/create', 'ember-metal/platform/define_property', 'ember-metal/array'], function (exports, Ember, o_create, define_property, array) {
+enifed('ember-metal/symbol', function () {
+ 'use strict';
+
+});
+enifed('ember-metal/utils', ['exports', 'ember-metal/core', 'ember-metal/platform/create', 'ember-metal/platform/define_property'], function (exports, Ember, o_create, define_property) {
+
exports.uuid = uuid;
+ exports.symbol = symbol;
exports.generateGuid = generateGuid;
exports.guidFor = guidFor;
exports.getMeta = getMeta;
exports.setMeta = setMeta;
exports.metaPath = metaPath;
exports.wrap = wrap;
- exports.makeArray = makeArray;
exports.tryInvoke = tryInvoke;
+ exports.makeArray = makeArray;
exports.inspect = inspect;
exports.apply = apply;
exports.applyStr = applyStr;
exports.meta = meta;
- exports.typeOf = typeOf;
- exports.isArray = isArray;
exports.canInvoke = canInvoke;
- "REMOVE_USE_STRICT: true";var _uuid = 0;
-
/**
Generates a universally unique identifier. This method
is used internally by Ember for assisting with
the generation of GUID's and other unique identifiers
such as `bind-attr` data attributes.
@public
@return {Number} [description]
*/
+ "REMOVE_USE_STRICT: true"; /**
+ @module ember-metal
+ */
+ /**
+ Previously we used `Ember.$.uuid`, however `$.uuid` has been removed from
+ jQuery master. We'll just bootstrap our own uuid now.
+
+ @private
+ @return {Number} the uuid
+ */
+ var _uuid = 0;
function uuid() {
return ++_uuid;
}
/**
@@ -16778,11 +18748,11 @@
@property GUID_PREFIX
@for Ember
@type String
@final
*/
- var GUID_PREFIX = 'ember';
+ var GUID_PREFIX = "ember";
// Used for guid generation...
var numberCache = [];
var stringCache = {};
@@ -16833,11 +18803,18 @@
return key;
}
}
return str;
}
+ function symbol(debugName) {
+ // TODO: Investigate using platform symbols, but we do not
+ // want to require non-enumerability for this API, which
+ // would introduce a large cost.
+ return intern(debugName + " [id=" + GUID_KEY + Math.floor(Math.random() * new Date()) + "]");
+ }
+
/**
A unique key used to assign guids and other private metadata to objects.
If you inspect an object in your browser debugger you will often see these.
They can be safely ignored.
@@ -16848,11 +18825,11 @@
@property GUID_KEY
@for Ember
@type String
@final
*/
- var GUID_KEY = intern('__ember' + +new Date());
+ var GUID_KEY = intern("__ember" + +new Date());
var GUID_DESC = {
writable: true,
configurable: true,
enumerable: false,
@@ -16879,25 +18856,23 @@
enumerable: false,
value: null
};
var EMBER_META_PROPERTY = {
- name: '__ember_meta__',
+ name: "__ember_meta__",
descriptor: META_DESC
};
var GUID_KEY_PROPERTY = {
name: GUID_KEY,
descriptor: nullDescriptor
};
var NEXT_SUPER_PROPERTY = {
- name: '__nextSuper',
+ name: "__nextSuper",
descriptor: undefinedDescriptor
- };
-
- function generateGuid(obj, prefix) {
+ };function generateGuid(obj, prefix) {
if (!prefix) {
prefix = GUID_PREFIX;
}
var ret = prefix + uuid();
@@ -16914,25 +18889,10 @@
}
}
return ret;
}
- /**
- Returns a unique id for the object. If the object does not yet have a guid,
- one will be assigned to it. You can call this on any object,
- `Ember.Object`-based or not, but be aware that it will add a `_guid`
- property.
-
- You can also use this method on DOM Element objects.
-
- @private
- @method guidFor
- @for Ember
- @param {Object} obj any object, string, number, Element, or primitive
- @return {String} the unique guid for this instance.
- */
-
function guidFor(obj) {
// special cases where we don't want to add a key to object
if (obj === undefined) {
return "(undefined)";
@@ -16945,42 +18905,42 @@
var ret;
var type = typeof obj;
// Don't allow prototype changes to String etc. to change the guidFor
switch (type) {
- case 'number':
+ case "number":
ret = numberCache[obj];
if (!ret) {
- ret = numberCache[obj] = 'nu' + obj;
+ ret = numberCache[obj] = "nu" + obj;
}
return ret;
- case 'string':
+ case "string":
ret = stringCache[obj];
if (!ret) {
- ret = stringCache[obj] = 'st' + uuid();
+ ret = stringCache[obj] = "st" + uuid();
}
return ret;
- case 'boolean':
- return obj ? '(true)' : '(false)';
+ case "boolean":
+ return obj ? "(true)" : "(false)";
default:
if (obj[GUID_KEY]) {
return obj[GUID_KEY];
}
if (obj === Object) {
- return '(Object)';
+ return "(Object)";
}
if (obj === Array) {
- return '(Array)';
+ return "(Array)";
}
ret = GUID_PREFIX + uuid();
if (obj[GUID_KEY] === null) {
@@ -17067,11 +19027,11 @@
if (!ret) {
if (define_property.canDefineNonEnumerableProperties) {
if (obj.__defineNonEnumerable) {
obj.__defineNonEnumerable(EMBER_META_PROPERTY);
} else {
- define_property.defineProperty(obj, '__ember_meta__', META_DESC);
+ define_property.defineProperty(obj, "__ember_meta__", META_DESC);
}
}
ret = new Meta(obj);
@@ -17084,11 +19044,11 @@
obj.__ember_meta__ = ret;
} else if (ret.source !== obj) {
if (obj.__defineNonEnumerable) {
obj.__defineNonEnumerable(EMBER_META_PROPERTY);
} else {
- define_property.defineProperty(obj, '__ember_meta__', META_DESC);
+ define_property.defineProperty(obj, "__ember_meta__", META_DESC);
}
ret = o_create['default'](ret);
ret.watching = o_create['default'](ret.watching);
ret.cache = undefined;
@@ -17099,15 +19059,14 @@
if (define_property.hasPropertyAccessors) {
ret.values = o_create['default'](ret.values);
}
- obj['__ember_meta__'] = ret;
+ obj["__ember_meta__"] = ret;
}
return ret;
}
-
function getMeta(obj, property) {
var _meta = meta(obj, false);
return _meta[property];
}
@@ -17115,44 +19074,10 @@
var _meta = meta(obj, true);
_meta[property] = value;
return value;
}
- /**
- @deprecated
- @private
-
- In order to store defaults for a class, a prototype may need to create
- a default meta object, which will be inherited by any objects instantiated
- from the class's constructor.
-
- However, the properties of that meta object are only shallow-cloned,
- so if a property is a hash (like the event system's `listeners` hash),
- it will by default be shared across all instances of that class.
-
- This method allows extensions to deeply clone a series of nested hashes or
- other complex objects. For instance, the event system might pass
- `['listeners', 'foo:change', 'ember157']` to `prepareMetaPath`, which will
- walk down the keys provided.
-
- For each key, if the key does not exist, it is created. If it already
- exists and it was inherited from its constructor, the constructor's
- key is cloned.
-
- You can also pass false for `writable`, which will simply return
- undefined if `prepareMetaPath` discovers any part of the path that
- shared or undefined.
-
- @method metaPath
- @for Ember
- @param {Object} obj The object whose meta we are examining
- @param {Array} path An array of keys to walk down
- @param {Boolean} writable whether or not to create a new meta
- (or meta property) if one does not already exist or if it's
- shared with its constructor
- */
-
function metaPath(obj, path, writable) {
Ember['default'].deprecate("Ember.metaPath is deprecated and will be removed from future releases.");
var _meta = meta(obj, writable);
var keyName, value;
@@ -17177,23 +19102,10 @@
}
return value;
}
- /**
- Wraps the passed function so that `this._super` will point to the superFunc
- when the function is invoked. This is the primitive we use to implement
- calls to super.
-
- @private
- @method wrap
- @for Ember
- @param {Function} func The function to call
- @param {Function} superFunc The super function.
- @return {Function} wrapped function.
- */
-
function wrap(func, superFunc) {
function superWrapper() {
var ret;
var sup = this && this.__nextSuper;
var length = arguments.length;
@@ -17229,97 +19141,11 @@
superWrapper.__ember_listens__ = func.__ember_listens__;
return superWrapper;
}
- var EmberArray;
-
/**
- Returns true if the passed object is an array or Array-like.
-
- Ember Array Protocol:
-
- - the object has an objectAt property
- - the object is a native Array
- - the object is an Object, and has a length property
-
- Unlike `Ember.typeOf` this method returns true even if the passed object is
- not formally array but appears to be array-like (i.e. implements `Ember.Array`)
-
- ```javascript
- Ember.isArray(); // false
- Ember.isArray([]); // true
- Ember.isArray(Ember.ArrayProxy.create({ content: [] })); // true
- ```
-
- @method isArray
- @for Ember
- @param {Object} obj The object to test
- @return {Boolean} true if the passed object is an array or Array-like
- */
- // ES6TODO: Move up to runtime? This is only use in ember-metal by concatenatedProperties
- function isArray(obj) {
- var modulePath, type;
-
- if (typeof EmberArray === "undefined") {
- modulePath = 'ember-runtime/mixins/array';
- if (Ember['default'].__loader.registry[modulePath]) {
- EmberArray = Ember['default'].__loader.require(modulePath)['default'];
- }
- }
-
- if (!obj || obj.setInterval) {
- return false;
- }
- if (Array.isArray && Array.isArray(obj)) {
- return true;
- }
- if (EmberArray && EmberArray.detect(obj)) {
- return true;
- }
-
- type = typeOf(obj);
- if ('array' === type) {
- return true;
- }
- if (obj.length !== undefined && 'object' === type) {
- return true;
- }
- return false;
- }
-
- /**
- Forces the passed object to be part of an array. If the object is already
- an array or array-like, it will return the object. Otherwise, it will add the object to
- an array. If obj is `null` or `undefined`, it will return an empty array.
-
- ```javascript
- Ember.makeArray(); // []
- Ember.makeArray(null); // []
- Ember.makeArray(undefined); // []
- Ember.makeArray('lindsay'); // ['lindsay']
- Ember.makeArray([1, 2, 42]); // [1, 2, 42]
-
- var controller = Ember.ArrayProxy.create({ content: [] });
-
- Ember.makeArray(controller) === controller; // true
- ```
-
- @method makeArray
- @for Ember
- @param {Object} obj the object
- @return {Array}
- */
-
- function makeArray(obj) {
- if (obj === null || obj === undefined) {
- return [];
- }
- return isArray(obj) ? obj : [obj];
- }
-
- /**
Checks to see if the `methodName` exists on the `obj`.
```javascript
var foo = { bar: function() { return 'bar'; }, baz: null };
@@ -17333,33 +19159,12 @@
@param {Object} obj The object to check for the method
@param {String} methodName The method name to check for
@return {Boolean}
*/
function canInvoke(obj, methodName) {
- return !!(obj && typeof obj[methodName] === 'function');
+ return !!(obj && typeof obj[methodName] === "function");
}
-
- /**
- Checks to see if the `methodName` exists on the `obj`,
- and if it does, invokes it with the arguments passed.
-
- ```javascript
- var d = new Date('03/15/2013');
-
- Ember.tryInvoke(d, 'getTime'); // 1363320000000
- Ember.tryInvoke(d, 'setFullYear', [2014]); // 1394856000000
- Ember.tryInvoke(d, 'noSuchMethod', [2014]); // undefined
- ```
-
- @method tryInvoke
- @for Ember
- @param {Object} obj The object to check for the method
- @param {String} methodName The method name to check for
- @param {Array} [args] The arguments to pass to the method
- @return {*} the return value of the invoked method or undefined if it cannot be invoked
- */
-
function tryInvoke(obj, methodName, args) {
if (canInvoke(obj, methodName)) {
return args ? applyStr(obj, methodName, args) : applyStr(obj, methodName);
}
}
@@ -17369,11 +19174,11 @@
var count = 0;
try {
// jscs:disable
try {} finally {
count++;
- throw new Error('needsFinallyFixTest');
+ throw new Error("needsFinallyFixTest");
}
// jscs:enable
} catch (e) {}
return count !== 1;
@@ -17541,155 +19346,64 @@
// ........................................
// TYPING & ARRAY MESSAGING
//
- var TYPE_MAP = {};
- var t = "Boolean Number String Function Array Date RegExp Object".split(" ");
- array.forEach.call(t, function (name) {
- TYPE_MAP["[object " + name + "]"] = name.toLowerCase();
- });
-
var toString = Object.prototype.toString;
- var EmberObject;
-
- /**
- Returns a consistent type for the passed item.
-
- Use this instead of the built-in `typeof` to get the type of an item.
- It will return the same result across all browsers and includes a bit
- more detail. Here is what will be returned:
-
- | Return Value | Meaning |
- |---------------|------------------------------------------------------|
- | 'string' | String primitive or String object. |
- | 'number' | Number primitive or Number object. |
- | 'boolean' | Boolean primitive or Boolean object. |
- | 'null' | Null value |
- | 'undefined' | Undefined value |
- | 'function' | A function |
- | 'array' | An instance of Array |
- | 'regexp' | An instance of RegExp |
- | 'date' | An instance of Date |
- | 'class' | An Ember class (created using Ember.Object.extend()) |
- | 'instance' | An Ember object instance |
- | 'error' | An instance of the Error object |
- | 'object' | A JavaScript object not inheriting from Ember.Object |
-
- Examples:
-
- ```javascript
- Ember.typeOf(); // 'undefined'
- Ember.typeOf(null); // 'null'
- Ember.typeOf(undefined); // 'undefined'
- Ember.typeOf('michael'); // 'string'
- Ember.typeOf(new String('michael')); // 'string'
- Ember.typeOf(101); // 'number'
- Ember.typeOf(new Number(101)); // 'number'
- Ember.typeOf(true); // 'boolean'
- Ember.typeOf(new Boolean(true)); // 'boolean'
- Ember.typeOf(Ember.makeArray); // 'function'
- Ember.typeOf([1, 2, 90]); // 'array'
- Ember.typeOf(/abc/); // 'regexp'
- Ember.typeOf(new Date()); // 'date'
- Ember.typeOf(Ember.Object.extend()); // 'class'
- Ember.typeOf(Ember.Object.create()); // 'instance'
- Ember.typeOf(new Error('teamocil')); // 'error'
-
- // 'normal' JavaScript object
- Ember.typeOf({ a: 'b' }); // 'object'
- ```
-
- @method typeOf
- @for Ember
- @param {Object} item the item to check
- @return {String} the type
- */
- function typeOf(item) {
- var ret, modulePath;
-
- // ES6TODO: Depends on Ember.Object which is defined in runtime.
- if (typeof EmberObject === "undefined") {
- modulePath = 'ember-runtime/system/object';
- if (Ember['default'].__loader.registry[modulePath]) {
- EmberObject = Ember['default'].__loader.require(modulePath)['default'];
- }
+ var isArray = Array.isArray || function (value) {
+ return value !== null && value !== undefined && typeof value === "object" && typeof value.length === "number" && toString.call(value) === "[object Array]";
+ };
+ function makeArray(obj) {
+ if (obj === null || obj === undefined) {
+ return [];
}
-
- ret = item === null || item === undefined ? String(item) : TYPE_MAP[toString.call(item)] || 'object';
-
- if (ret === 'function') {
- if (EmberObject && EmberObject.detect(item)) {
- ret = 'class';
- }
- } else if (ret === 'object') {
- if (item instanceof Error) {
- ret = 'error';
- } else if (EmberObject && item instanceof EmberObject) {
- ret = 'instance';
- } else if (item instanceof Date) {
- ret = 'date';
- }
- }
-
- return ret;
+ return isArray(obj) ? obj : [obj];
}
- /**
- Convenience method to inspect an object. This method will attempt to
- convert the object into a useful string description.
-
- It is a pretty simple implementation. If you want something more robust,
- use something like JSDump: https://github.com/NV/jsDump
-
- @method inspect
- @for Ember
- @param {Object} obj The object you want to inspect.
- @return {String} A description of the object
- @since 1.4.0
- */
-
function inspect(obj) {
- var type = typeOf(obj);
- if (type === 'array') {
- return '[' + obj + ']';
+ if (obj === null) {
+ return "null";
}
- if (type !== 'object') {
- return obj + '';
+ if (obj === undefined) {
+ return "undefined";
}
+ if (isArray(obj)) {
+ return "[" + obj + "]";
+ }
+ // for non objects
+ if (typeof obj !== "object") {
+ return "" + obj;
+ }
+ // overridden toString
+ if (typeof obj.toString === "function" && obj.toString !== toString) {
+ return obj.toString();
+ }
+ // Object.prototype.toString === {}.toString
var v;
var ret = [];
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
v = obj[key];
- if (v === 'toString') {
+ if (v === "toString") {
continue;
} // ignore useless items
- if (typeOf(v) === 'function') {
+ if (typeof v === "function") {
v = "function() { ... }";
}
- if (v && typeof v.toString !== 'function') {
+ if (v && typeof v.toString !== "function") {
ret.push(key + ": " + toString.call(v));
} else {
ret.push(key + ": " + v);
}
}
}
return "{" + ret.join(", ") + "}";
}
- // The following functions are intentionally minified to keep the functions
- // below Chrome's function body size inlining limit of 600 chars.
- /**
- @param {Object} target
- @param {Function} method
- @param {Array} args
- */
-
function apply(t, m, a) {
var l = a && a.length;
if (!a || !l) {
return m.call(t);
}
@@ -17707,16 +19421,10 @@
default:
return m.apply(t, a);
}
}
- /**
- @param {Object} target
- @param {String} method
- @param {Array} args
- */
-
function applyStr(t, m, a) {
var l = a && a.length;
if (!a || !l) {
return t[m]();
}
@@ -17741,10 +19449,11 @@
exports.GUID_KEY_PROPERTY = GUID_KEY_PROPERTY;
exports.NEXT_SUPER_PROPERTY = NEXT_SUPER_PROPERTY;
exports.GUID_KEY = GUID_KEY;
exports.META_DESC = META_DESC;
exports.EMPTY_META = EMPTY_META;
+ exports.isArray = isArray;
exports.tryCatchFinally = tryCatchFinally;
exports.deprecatedTryCatchFinally = deprecatedTryCatchFinally;
exports.tryFinally = tryFinally;
exports.deprecatedTryFinally = deprecatedTryFinally;
@@ -17756,11 +19465,11 @@
exports.watchKey = watchKey;
exports.unwatchKey = unwatchKey;
function watchKey(obj, keyName, meta) {
// can't watch length on Array - it is special...
- if (keyName === 'length' && utils.typeOf(obj) === 'array') {
+ if (keyName === "length" && utils.isArray(obj)) {
return;
}
var m = meta || utils.meta(obj);
var watching = m.watching;
@@ -17768,16 +19477,16 @@
// activate watching first time
if (!watching[keyName]) {
watching[keyName] = 1;
var possibleDesc = obj[keyName];
- var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
+ var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined;
if (desc && desc.willWatch) {
desc.willWatch(obj, keyName);
}
- if ('function' === typeof obj.willWatchProperty) {
+ if ("function" === typeof obj.willWatchProperty) {
obj.willWatchProperty(keyName);
}
if (define_property.hasPropertyAccessors) {
@@ -17792,13 +19501,13 @@
var handleMandatorySetter = function handleMandatorySetter(m, obj, keyName) {
var descriptor = Object.getOwnPropertyDescriptor && Object.getOwnPropertyDescriptor(obj, keyName);
var configurable = descriptor ? descriptor.configurable : true;
var isWritable = descriptor ? descriptor.writable : true;
- var hasValue = descriptor ? 'value' in descriptor : true;
+ var hasValue = descriptor ? "value" in descriptor : true;
var possibleDesc = descriptor && descriptor.value;
- var isDescriptor = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor;
+ var isDescriptor = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor;
if (isDescriptor) {
return;
}
@@ -17815,26 +19524,25 @@
};
// This is super annoying, but required until
// https://github.com/babel/babel/issues/906 is resolved
- ; // jshint ignore:line
-
+ ;
function unwatchKey(obj, keyName, meta) {
var m = meta || utils.meta(obj);
var watching = m.watching;
if (watching[keyName] === 1) {
watching[keyName] = 0;
var possibleDesc = obj[keyName];
- var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
+ var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined;
if (desc && desc.didUnwatch) {
desc.didUnwatch(obj, keyName);
}
- if ('function' === typeof obj.didUnwatchProperty) {
+ if ("function" === typeof obj.didUnwatchProperty) {
obj.didUnwatchProperty(keyName);
}
if (!desc && define_property.hasPropertyAccessors && keyName in obj) {
@@ -17876,14 +19584,13 @@
} else if (ret.value() !== obj) {
ret = m.chains = ret.copy(obj);
}
return ret;
}
-
function watchPath(obj, keyPath, meta) {
// can't watch length on Array - it is special...
- if (keyPath === 'length' && utils.typeOf(obj) === 'array') {
+ if (keyPath === "length" && utils.isArray(obj)) {
return;
}
var m = meta || utils.meta(obj);
var watching = m.watching;
@@ -17919,11 +19626,11 @@
exports.destroy = destroy;
exports.watch = watch;
function watch(obj, _keyPath, m) {
// can't watch length on Array - it is special...
- if (_keyPath === 'length' && utils.typeOf(obj) === 'array') {
+ if (_keyPath === "length" && utils.isArray(obj)) {
return;
}
if (!path_cache.isPath(_keyPath)) {
watch_key.watchKey(obj, _keyPath, m);
@@ -17931,19 +19638,18 @@
watch_path.watchPath(obj, _keyPath, m);
}
}
function isWatching(obj, key) {
- var meta = obj['__ember_meta__'];
+ var meta = obj["__ember_meta__"];
return (meta && meta.watching[key]) > 0;
}
watch.flushPending = chains.flushPendingChains;
-
function unwatch(obj, _keyPath, m) {
// can't watch length on Array - it is special...
- if (_keyPath === 'length' && utils.typeOf(obj) === 'array') {
+ if (_keyPath === "length" && utils.isArray(obj)) {
return;
}
if (!path_cache.isPath(_keyPath)) {
watch_key.unwatchKey(obj, _keyPath, m);
@@ -17951,27 +19657,16 @@
watch_path.unwatchPath(obj, _keyPath, m);
}
}
var NODE_STACK = [];
-
- /**
- Tears down the meta on an object so that it can be garbage collected.
- Multiple calls will have no effect.
-
- @method destroy
- @for Ember
- @param {Object} obj the object to destroy
- @return {void}
- */
-
function destroy(obj) {
- var meta = obj['__ember_meta__'];
+ var meta = obj["__ember_meta__"];
var node, nodes, key, nodeObject;
if (meta) {
- obj['__ember_meta__'] = null;
+ obj["__ember_meta__"] = null;
// remove chainWatchers to remove circular references that would prevent GC
node = meta.chains;
if (node) {
NODE_STACK.push(node);
// process tree
@@ -17997,619 +19692,591 @@
}
}
}
});
-enifed('ember-routing-htmlbars', ['exports', 'ember-metal/core', 'ember-htmlbars/helpers', 'ember-routing-htmlbars/helpers/outlet', 'ember-routing-htmlbars/helpers/render', 'ember-routing-htmlbars/helpers/link-to', 'ember-routing-htmlbars/helpers/action', 'ember-routing-htmlbars/helpers/query-params'], function (exports, Ember, helpers, outlet, render, link_to, action, query_params) {
+enifed('ember-routing-htmlbars', ['exports', 'ember-metal/core', 'ember-metal/merge', 'ember-htmlbars/helpers', 'ember-htmlbars/keywords', 'ember-routing-htmlbars/helpers/query-params', 'ember-routing-htmlbars/keywords/action', 'ember-routing-htmlbars/keywords/element-action', 'ember-routing-htmlbars/keywords/link-to', 'ember-routing-htmlbars/keywords/render'], function (exports, Ember, merge, helpers, keywords, query_params, action, elementAction, linkTo, render) {
- 'use strict';
+ 'use strict';
- /**
- Ember Routing HTMLBars Helpers
+ /**
+ Ember Routing HTMLBars Helpers
- @module ember
- @submodule ember-routing-htmlbars
- @requires ember-routing
- */
+ @module ember
+ @submodule ember-routing-htmlbars
+ @requires ember-routing
+ */
- helpers.registerHelper('outlet', outlet.outletHelper);
- helpers.registerHelper('render', render.renderHelper);
- helpers.registerHelper('link-to', link_to.linkToHelper);
- helpers.registerHelper('linkTo', link_to.deprecatedLinkToHelper);
- helpers.registerHelper('action', action.actionHelper);
- helpers.registerHelper('query-params', query_params.queryParamsHelper);
+ helpers.registerHelper("query-params", query_params.queryParamsHelper);
- exports['default'] = Ember['default'];
+ keywords.registerKeyword("action", action['default']);
+ keywords.registerKeyword("@element_action", elementAction['default']);
+ keywords.registerKeyword("link-to", linkTo['default']);
+ keywords.registerKeyword("render", render['default']);
+ var deprecatedLinkTo = merge['default']({}, linkTo['default']);
+ merge['default'](deprecatedLinkTo, {
+ link: function (state, params, hash) {
+ linkTo['default'].link.call(this, state, params, hash);
+ Ember['default'].deprecate("The 'linkTo' view helper is deprecated in favor of 'link-to'");
+ }
+ });
+
+ keywords.registerKeyword("linkTo", deprecatedLinkTo);
+
+ exports['default'] = Ember['default'];
+
});
-enifed('ember-routing-htmlbars/helpers/action', ['exports', 'ember-metal/core', 'ember-metal/utils', 'ember-metal/run_loop', 'ember-views/streams/utils', 'ember-views/system/utils', 'ember-views/system/action_manager', 'ember-metal/streams/utils'], function (exports, Ember, utils, run, streams__utils, system__utils, ActionManager, ember_metal__streams__utils) {
+enifed('ember-routing-htmlbars/helpers/query-params', ['exports', 'ember-metal/core', 'ember-routing/system/query_params'], function (exports, Ember, QueryParams) {
'use strict';
- exports.actionHelper = actionHelper;
+ exports.queryParamsHelper = queryParamsHelper;
- function actionArgs(parameters, actionName) {
- var ret, i, l;
+ /**
+ This is a sub-expression to be used in conjunction with the link-to helper.
+ It will supply url query parameters to the target route.
- if (actionName === undefined) {
- ret = new Array(parameters.length);
- for (i = 0, l = parameters.length; i < l; i++) {
- ret[i] = streams__utils.readUnwrappedModel(parameters[i]);
- }
- } else {
- ret = new Array(parameters.length + 1);
- ret[0] = actionName;
- for (i = 0, l = parameters.length; i < l; i++) {
- ret[i + 1] = streams__utils.readUnwrappedModel(parameters[i]);
- }
- }
+ Example
- return ret;
- }
+ {{#link-to 'posts' (query-params direction="asc")}}Sort{{/link-to}}
- var ActionHelper = {};
+ @method query-params
+ @for Ember.Handlebars.helpers
+ @param {Object} hash takes a hash of query parameters
+ @return {String} HTML string
+ */
+ function queryParamsHelper(params, hash) {
+ Ember['default'].assert("The `query-params` helper only accepts hash parameters, e.g. (query-params queryParamPropertyName='foo') as opposed to just (query-params 'foo')", params.length === 0);
- // registeredActions is re-exported for compatibility with older plugins
- // that were using this undocumented API.
- ActionHelper.registeredActions = ActionManager['default'].registeredActions;
+ return QueryParams['default'].create({
+ values: hash
+ });
+ }
- var keys = ["alt", "shift", "meta", "ctrl"];
+});
+enifed('ember-routing-htmlbars/keywords/action', ['exports', 'htmlbars-runtime/hooks', 'ember-routing-htmlbars/keywords/closure-action'], function (exports, hooks, closureAction) {
- var POINTER_EVENT_TYPE_REGEX = /^click|mouse|touch/;
+ 'use strict';
- var isAllowedEvent = function (event, allowedKeys) {
- if (typeof allowedKeys === "undefined") {
- if (POINTER_EVENT_TYPE_REGEX.test(event.type)) {
- return system__utils.isSimpleClick(event);
- } else {
- allowedKeys = '';
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
+
+ exports['default'] = function (morph, env, scope, params, hash, template, inverse, visitor) {
+
+ if (morph) {
+ hooks.keyword("@element_action", morph, env, scope, params, hash, template, inverse, visitor);
+ return true;
}
- }
- if (allowedKeys.indexOf("any") >= 0) {
- return true;
- }
-
- for (var i = 0, l = keys.length; i < l; i++) {
- if (event[keys[i] + "Key"] && allowedKeys.indexOf(keys[i]) === -1) {
- return false;
+ return closureAction['default'](morph, env, scope, params, hash, template, inverse, visitor);
}
- }
- return true;
- };
+});
+enifed('ember-routing-htmlbars/keywords/closure-action', ['exports', 'ember-metal/streams/stream', 'ember-metal/array', 'ember-metal/streams/utils', 'ember-metal/keys', 'ember-metal/utils', 'ember-metal/property_get'], function (exports, Stream, array, utils, keys, ember_metal__utils, property_get) {
- ActionHelper.registerAction = function (actionNameOrStream, options, allowedKeys) {
- var actionId = utils.uuid();
- var eventName = options.eventName;
- var parameters = options.parameters;
+ 'use strict';
- ActionManager['default'].registeredActions[actionId] = {
- eventName: eventName,
- handler: function (event) {
- if (!isAllowedEvent(event, allowedKeys)) {
- return true;
- }
+ exports['default'] = closureAction;
- if (options.preventDefault !== false) {
- event.preventDefault();
- }
+ var INVOKE = ember_metal__utils.symbol("INVOKE");
+ var ACTION = ember_metal__utils.symbol("ACTION");function closureAction(morph, env, scope, params, hash, template, inverse, visitor) {
+ return new Stream['default'](function () {
+ var _this = this;
- if (options.bubbles === false) {
- event.stopPropagation();
- }
+ array.map.call(params, this.addDependency, this);
+ array.map.call(keys['default'](hash), function (item) {
+ _this.addDependency(item);
+ });
- var target = options.target.value();
+ var rawAction = params[0];
+ var actionArguments = utils.readArray(params.slice(1, params.length));
- var actionName;
-
- if (ember_metal__streams__utils.isStream(actionNameOrStream)) {
- actionName = actionNameOrStream.value();
-
- Ember['default'].assert("You specified a quoteless path to the {{action}} helper " + "which did not resolve to an action name (a string). " + "Perhaps you meant to use a quoted actionName? (e.g. {{action 'save'}}).", typeof actionName === 'string');
- } else {
- actionName = actionNameOrStream;
- }
-
- run['default'](function runRegisteredAction() {
- if (target.send) {
- target.send.apply(target, actionArgs(parameters, actionName));
+ var target, action, valuePath;
+ if (rawAction[INVOKE]) {
+ // on-change={{action (mut name)}}
+ target = rawAction;
+ action = rawAction[INVOKE];
+ } else {
+ // on-change={{action setName}}
+ // element-space actions look to "controller" then target. Here we only
+ // look to "target".
+ target = utils.read(scope.self);
+ action = utils.read(rawAction);
+ if (typeof action === "string") {
+ // on-change={{action 'setName'}}
+ if (hash.target) {
+ // on-change={{action 'setName' target=alternativeComponent}}
+ target = utils.read(hash.target);
+ }
+ if (target.actions) {
+ action = target.actions[action];
} else {
- Ember['default'].assert("The action '" + actionName + "' did not exist on " + target, typeof target[actionName] === 'function');
- target[actionName].apply(target, actionArgs(parameters));
+ action = target._actions[action];
}
- });
+ }
}
- };
- options.view.on('willClearRender', function () {
- delete ActionManager['default'].registeredActions[actionId];
+ if (hash.value) {
+ // <button on-keypress={{action (mut name) value="which"}}
+ // on-keypress is not even an Ember feature yet
+ valuePath = utils.read(hash.value);
+ }
+
+ return createClosureAction(target, action, valuePath, actionArguments);
});
+ }
- return actionId;
- };
+ function createClosureAction(target, action, valuePath, actionArguments) {
+ var closureAction;
- /**
- The `{{action}}` helper provides a useful shortcut for registering an HTML
- element within a template for a single DOM event and forwarding that
- interaction to the template's controller or specified `target` option.
-
- If the controller does not implement the specified action, the event is sent
- to the current route, and it bubbles up the route hierarchy from there.
-
- For more advanced event handling see [Ember.Component](/api/classes/Ember.Component.html)
-
-
- ### Use
- Given the following application Handlebars template on the page
-
- ```handlebars
- <div {{action 'anActionName'}}>
- click me
- </div>
- ```
-
- And application code
-
- ```javascript
- App.ApplicationController = Ember.Controller.extend({
- actions: {
- anActionName: function() {
+ if (actionArguments.length > 0) {
+ closureAction = function () {
+ var args = actionArguments;
+ if (arguments.length > 0) {
+ args = actionArguments.concat.apply(actionArguments, arguments);
}
- }
- });
- ```
+ if (valuePath && args.length > 0) {
+ args[0] = property_get.get(args[0], valuePath);
+ }
+ return action.apply(target, args);
+ };
+ } else {
+ closureAction = function () {
+ var args = arguments;
+ if (valuePath && args.length > 0) {
+ args = Array.prototype.slice.apply(args);
+ args[0] = property_get.get(args[0], valuePath);
+ }
+ return action.apply(target, args);
+ };
+ }
- Will result in the following rendered HTML
+ closureAction[ACTION] = true;
- ```html
- <div class="ember-view">
- <div data-ember-action="1">
- click me
- </div>
- </div>
- ```
+ return closureAction;
+ }
- Clicking "click me" will trigger the `anActionName` action of the
- `App.ApplicationController`. In this case, no additional parameters will be passed.
+ exports.INVOKE = INVOKE;
+ exports.ACTION = ACTION;
- If you provide additional parameters to the helper:
+});
+enifed('ember-routing-htmlbars/keywords/element-action', ['exports', 'ember-metal/core', 'ember-metal/utils', 'ember-metal/run_loop', 'ember-views/streams/utils', 'ember-views/system/utils', 'ember-views/system/action_manager'], function (exports, Ember, utils, run, streams__utils, system__utils, ActionManager) {
- ```handlebars
- <button {{action 'edit' post}}>Edit</button>
- ```
+ 'use strict';
- Those parameters will be passed along as arguments to the JavaScript
- function implementing the action.
+ function assert(message, test) {
+ // This only exists to prevent defeatureify from error when attempting
+ // to transform the same source twice (tldr; you can't nest stripped statements)
+ Ember['default'].assert(message, test);
+ }
- ### Event Propagation
+ exports['default'] = {
+ setupState: function (state, env, scope, params, hash) {
+ var getStream = env.hooks.get;
+ var read = env.hooks.getValue;
- Events triggered through the action helper will automatically have
- `.preventDefault()` called on them. You do not need to do so in your event
- handlers. If you need to allow event propagation (to handle file inputs for
- example) you can supply the `preventDefault=false` option to the `{{action}}` helper:
+ var actionName = read(params[0]);
- ```handlebars
- <div {{action "sayHello" preventDefault=false}}>
- <input type="file" />
- <input type="checkbox" />
- </div>
- ```
+
+ assert("You specified a quoteless path to the {{action}} helper " + "which did not resolve to an action name (a string). " + "Perhaps you meant to use a quoted actionName? (e.g. {{action 'save'}}).", typeof actionName === "string" || typeof actionName === "function");
+
+ var actionArgs = [];
+ for (var i = 1, l = params.length; i < l; i++) {
+ actionArgs.push(streams__utils.readUnwrappedModel(params[i]));
+ }
- To disable bubbling, pass `bubbles=false` to the helper:
+ var target;
+ if (hash.target) {
+ if (typeof hash.target === "string") {
+ target = read(getStream(env, scope, hash.target));
+ } else {
+ target = read(hash.target);
+ }
+ } else {
+ target = read(scope.locals.controller) || read(scope.self);
+ }
- ```handlebars
- <button {{action 'edit' post bubbles=false}}>Edit</button>
- ```
+ return { actionName: actionName, actionArgs: actionArgs, target: target };
+ },
- 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](/api/classes/Ember.View.html)
- 'Responding to Browser Events' for more information.
+ isStable: function (state, env, scope, params, hash) {
+ return true;
+ },
- ### Specifying DOM event type
+ render: function (node, env, scope, params, hash, template, inverse, visitor) {
+ var actionId = ActionHelper.registerAction({
+ node: node,
+ eventName: hash.on || "click",
+ bubbles: hash.bubbles,
+ preventDefault: hash.preventDefault,
+ withKeyCode: hash.withKeyCode,
+ allowedKeys: hash.allowedKeys
+ });
- By default the `{{action}}` helper registers for DOM `click` events. You can
- supply an `on` option to the helper to specify a different DOM event name:
+ node.cleanup = function () {
+ ActionHelper.unregisterAction(actionId);
+ };
- ```handlebars
- <div {{action "anActionName" on="doubleClick"}}>
- click me
- </div>
- ```
+ env.dom.setAttribute(node.element, "data-ember-action", actionId);
+ }
+ };
- See `Ember.View` 'Responding to Browser Events' for a list of
- acceptable DOM event names.
+ var ActionHelper = {};
- ### Specifying whitelisted modifier keys
+ ActionHelper.registeredActions = ActionManager['default'].registeredActions;
- By default the `{{action}}` helper will ignore click event with pressed modifier
- keys. You can supply an `allowedKeys` option to specify which keys should not be ignored.
+ ActionHelper.registerAction = function (_ref) {
+ var node = _ref.node;
+ var eventName = _ref.eventName;
+ var preventDefault = _ref.preventDefault;
+ var bubbles = _ref.bubbles;
+ var allowedKeys = _ref.allowedKeys;
- ```handlebars
- <div {{action "anActionName" allowedKeys="alt"}}>
- click me
- </div>
- ```
+ var actionId = utils.uuid();
- This way the `{{action}}` will fire when clicking with the alt key pressed down.
+ ActionManager['default'].registeredActions[actionId] = {
+ eventName: eventName,
+ handler: function (event) {
+ if (!isAllowedEvent(event, allowedKeys)) {
+ return true;
+ }
- Alternatively, supply "any" to the `allowedKeys` option to accept any combination of modifier keys.
+ if (preventDefault !== false) {
+ event.preventDefault();
+ }
- ```handlebars
- <div {{action "anActionName" allowedKeys="any"}}>
- click me with any key pressed
- </div>
- ```
+ if (bubbles === false) {
+ event.stopPropagation();
+ }
- ### Specifying a Target
+ var _node$state = node.state;
+ var target = _node$state.target;
+ var actionName = _node$state.actionName;
+ var actionArgs = _node$state.actionArgs;
- There are several possible target objects for `{{action}}` helpers:
+ run['default'](function runRegisteredAction() {
+
+ if (typeof actionName === "function") {
+ actionName.apply(target, actionArgs);
+ return;
+ }
+
+ if (target.send) {
+ target.send.apply(target, [actionName].concat(actionArgs));
+ } else {
+ Ember['default'].assert("The action '" + actionName + "' did not exist on " + target, typeof target[actionName] === "function");
- In a typical Ember application, where templates are managed through use of the
- `{{outlet}}` helper, actions will bubble to the current controller, then
- to the current route, and then up the route hierarchy.
-
- Alternatively, a `target` option can be provided to the helper to change
- which object will receive the method call. This option must be a path
- to an object, accessible in the current context:
-
- ```handlebars
- {{! the application template }}
- <div {{action "anActionName" target=view}}>
- click me
- </div>
- ```
-
- ```javascript
- App.ApplicationView = Ember.View.extend({
- actions: {
- anActionName: function() {}
+ target[actionName].apply(target, actionArgs);
+ }
+ });
}
- });
+ };
- ```
+ return actionId;
+ };
- ### Additional Parameters
+ ActionHelper.unregisterAction = function (actionId) {
+ delete ActionManager['default'].registeredActions[actionId];
+ };
- You may specify additional parameters to the `{{action}}` helper. These
- parameters are passed along as the arguments to the JavaScript function
- implementing the action.
+ var MODIFIERS = ["alt", "shift", "meta", "ctrl"];
+ var POINTER_EVENT_TYPE_REGEX = /^click|mouse|touch/;
- ```handlebars
- {{#each person in people}}
- <div {{action "edit" person}}>
- click me
- </div>
- {{/each}}
- ```
+ function isAllowedEvent(event, allowedKeys) {
+ if (typeof allowedKeys === "undefined") {
+ if (POINTER_EVENT_TYPE_REGEX.test(event.type)) {
+ return system__utils.isSimpleClick(event);
+ } else {
+ allowedKeys = "";
+ }
+ }
- Clicking "click me" will trigger the `edit` method on the current controller
- with the value of `person` as a parameter.
+ if (allowedKeys.indexOf("any") >= 0) {
+ return true;
+ }
- @method action
- @for Ember.Handlebars.helpers
- @param {String} actionName
- @param {Object} [context]*
- @param {Hash} options
- */
-
- function actionHelper(params, hash, options, env) {
- var view = env.data.view;
- var target;
- if (!hash.target) {
- target = view.getStream('controller');
- } else if (ember_metal__streams__utils.isStream(hash.target)) {
- target = hash.target;
- } else {
- target = view.getStream(hash.target);
+ for (var i = 0, l = MODIFIERS.length; i < l; i++) {
+ if (event[MODIFIERS[i] + "Key"] && allowedKeys.indexOf(MODIFIERS[i]) === -1) {
+ return false;
+ }
}
- // Ember.assert("You specified a quoteless path to the {{action}} helper which did not resolve to an action name (a string). Perhaps you meant to use a quoted actionName? (e.g. {{action 'save'}}).", !params[0].isStream);
- // Ember.deprecate("You specified a quoteless path to the {{action}} helper which did not resolve to an action name (a string). Perhaps you meant to use a quoted actionName? (e.g. {{action 'save'}}).", params[0].isStream);
-
- var actionOptions = {
- eventName: hash.on || "click",
- parameters: params.slice(1),
- view: view,
- bubbles: hash.bubbles,
- preventDefault: hash.preventDefault,
- target: target,
- withKeyCode: hash.withKeyCode
- };
-
- var actionId = ActionHelper.registerAction(params[0], actionOptions, hash.allowedKeys);
- env.dom.setAttribute(options.element, 'data-ember-action', actionId);
+ return true;
}
exports.ActionHelper = ActionHelper;
});
-enifed('ember-routing-htmlbars/helpers/link-to', ['exports', 'ember-metal/core', 'ember-routing-views/views/link', 'ember-metal/streams/utils', 'ember-runtime/mixins/controller', 'ember-htmlbars/templates/link-to-escaped', 'ember-htmlbars/templates/link-to-unescaped', 'ember-htmlbars'], function (exports, Ember, link, utils, ControllerMixin, inlineEscapedLinkTo, inlineUnescapedLinkTo) {
+enifed('ember-routing-htmlbars/keywords/link-to', ['exports', 'ember-metal/streams/utils', 'ember-metal/core', 'ember-metal/merge'], function (exports, utils, Ember, merge) {
'use strict';
- exports.deprecatedLinkToHelper = deprecatedLinkToHelper;
- exports.linkToHelper = linkToHelper;
-
/**
@module ember
@submodule ember-routing-htmlbars
*/
- function linkToHelper(params, hash, options, env) {
- var queryParamsObject;
- var view = env.data.view;
+ exports['default'] = {
+ link: function (state, params, hash) {
+ Ember['default'].assert("You must provide one or more parameters to the link-to helper.", params.length);
+ },
- Ember['default'].assert("You must provide one or more parameters to the link-to helper.", params.length);
+ render: function (morph, env, scope, params, hash, template, inverse, visitor) {
+ var attrs = merge['default']({}, utils.readHash(hash));
+ attrs.params = utils.readArray(params);
- var lastParam = params[params.length - 1];
+ // Used for deprecations (to tell the user what view the deprecated syntax
+ // was used in).
+ attrs.view = env.view;
- if (lastParam && lastParam.isQueryParams) {
- hash.queryParamsObject = queryParamsObject = params.pop();
- }
+ // TODO: Remove once `hasBlock` is working again
+ attrs.hasBlock = !!template;
- if (hash.disabledWhen) {
- hash.disabled = hash.disabledWhen;
- delete hash.disabledWhen;
- }
+ attrs.escaped = !morph.parseTextAsHTML;
- if (!options.template) {
- var linkTitle = params.shift();
- var parseTextAsHTML = options.morph.parseTextAsHTML;
+ env.hooks.component(morph, env, scope, "-link-to", params, attrs, { "default": template }, visitor);
+ },
- if (parseTextAsHTML) {
- hash.layout = inlineUnescapedLinkTo['default'];
- } else {
- hash.layout = inlineEscapedLinkTo['default'];
- }
-
- hash.linkTitle = linkTitle;
+ rerender: function (morph, env, scope, params, hash, template, inverse, visitor) {
+ this.render(morph, env, scope, params, hash, template, inverse, visitor);
}
+ };
- for (var i = 0; i < params.length; i++) {
- if (utils.isStream(params[i])) {
- var lazyValue = params[i];
-
- if (!lazyValue._isController) {
- while (ControllerMixin['default'].detect(lazyValue.value())) {
- Ember['default'].deprecate('Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated. Please update `' + view + '` to use `{{link-to "post" someController.model}}` instead.');
-
- lazyValue = lazyValue.get('model');
- }
- }
-
- params[i] = lazyValue;
- }
- }
-
- hash.params = params;
-
- options.helperName = options.helperName || 'link-to';
-
- return env.helpers.view.helperFunction.call(this, [link.LinkView], hash, options, env);
- }
-
/**
See [link-to](/api/classes/Ember.Handlebars.helpers.html#method_link-to)
@method linkTo
@for Ember.Handlebars.helpers
@deprecated
@param {String} routeName
@param {Object} [context]*
@return {String} HTML string
*/
- function deprecatedLinkToHelper(params, hash, options, env) {
- Ember['default'].deprecate("The 'linkTo' view helper is deprecated in favor of 'link-to'");
- return env.helpers['link-to'].helperFunction.call(this, params, hash, options, env);
- }
-
});
-enifed('ember-routing-htmlbars/helpers/outlet', ['exports', 'ember-metal/core'], function (exports, Ember) {
+enifed('ember-routing-htmlbars/keywords/render', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/error', 'ember-metal/platform/create', 'ember-metal/streams/utils', 'ember-runtime/system/string', 'ember-routing/system/generate_controller', 'ember-htmlbars/node-managers/view-node-manager'], function (exports, Ember, property_get, EmberError, create, utils, string, generateController, ViewNodeManager) {
'use strict';
- exports.outletHelper = outletHelper;
+ exports['default'] = {
+ willRender: function (renderNode, env) {
+ if (env.view.ownerView._outlets) {
+ // We make sure we will get dirtied when outlet state changes.
+ env.view.ownerView._outlets.push(renderNode);
+ }
+ },
- function outletHelper(params, hash, options, env) {
- var viewName;
- var viewClass;
- var viewFullName;
- var view = env.data.view;
+ setupState: function (prevState, env, scope, params, hash) {
+ var name = params[0];
- Ember['default'].assert("Using {{outlet}} with an unquoted name is not supported.", params.length === 0 || typeof params[0] === 'string');
+ Ember['default'].assert("The first argument of {{render}} must be quoted, e.g. {{render \"sidebar\"}}.", typeof name === "string");
- var property = params[0] || 'main';
+ return {
+ parentView: scope.view,
+ manager: prevState.manager,
+ controller: prevState.controller,
+ childOutletState: childOutletState(name, env)
+ };
+ },
- // provide controller override
- viewName = hash.view;
+ childEnv: function (state) {
+ return { outletState: state.childOutletState };
+ },
- if (viewName) {
- viewFullName = 'view:' + viewName;
- Ember['default'].assert("Using a quoteless view parameter with {{outlet}} is not supported." + " Please update to quoted usage '{{outlet ... view=\"" + viewName + "\"}}.", typeof hash.view === 'string');
- Ember['default'].assert("The view name you supplied '" + viewName + "' did not resolve to a view.", view.container._registry.has(viewFullName));
- }
+ isStable: function (lastState, nextState) {
+ return isStable(lastState.childOutletState, nextState.childOutletState);
+ },
- viewClass = viewName ? view.container.lookupFactory(viewFullName) : hash.viewClass || view.container.lookupFactory('view:-outlet');
- hash._outletName = property;
- options.helperName = options.helperName || 'outlet';
- return env.helpers.view.helperFunction.call(this, [viewClass], hash, options, env);
- }
+ isEmpty: function (state) {
+ return false;
+ },
-});
-enifed('ember-routing-htmlbars/helpers/query-params', ['exports', 'ember-metal/core', 'ember-routing/system/query_params'], function (exports, Ember, QueryParams) {
+ render: function (node, env, scope, params, hash, template, inverse, visitor) {
+ var state = node.state;
+ var name = params[0];
+ var context = params[1];
- 'use strict';
+ var container = env.container;
- exports.queryParamsHelper = queryParamsHelper;
+ // The render keyword presumes it can work without a router. This is really
+ // only to satisfy the test:
+ //
+ // {{view}} should not override class bindings defined on a child view"
+ //
+ var router = container.lookup("router:main");
- function queryParamsHelper(params, hash) {
- Ember['default'].assert("The `query-params` helper only accepts hash parameters, e.g. (query-params queryParamPropertyName='foo') as opposed to just (query-params 'foo')", params.length === 0);
+ Ember['default'].assert("The second argument of {{render}} must be a path, e.g. {{render \"post\" post}}.", params.length < 2 || utils.isStream(params[1]));
- return QueryParams['default'].create({
- values: hash
- });
- }
+ if (params.length === 1) {
+ // use the singleton controller
+ Ember['default'].assert("You can only use the {{render}} helper once without a model object as " + "its second argument, as in {{render \"post\" post}}.", !router || !router._lookupActiveComponentNode(name));
+ } else if (params.length !== 2) {
+ throw new EmberError['default']("You must pass a templateName to render");
+ }
-});
-enifed('ember-routing-htmlbars/helpers/render', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/error', 'ember-runtime/system/string', 'ember-routing/system/generate_controller', 'ember-metal/streams/utils', 'ember-htmlbars/system/merge-view-bindings', 'ember-htmlbars/system/append-templated-view', 'ember-metal/platform/create'], function (exports, Ember, property_get, EmberError, string, generateController, utils, mergeViewBindings, appendTemplatedView, create) {
+ // # legacy namespace
+ name = name.replace(/\//g, ".");
+ // \ legacy slash as namespace support
- 'use strict';
+ var templateName = "template:" + name;
+ Ember['default'].assert("You used `{{render '" + name + "'}}`, but '" + name + "' can not be " + "found as either a template or a view.", container._registry.has("view:" + name) || container._registry.has(templateName) || !!template);
- exports.renderHelper = renderHelper;
+ var view = container.lookup("view:" + name);
+ if (!view) {
+ view = container.lookup("view:default");
+ }
+ var viewHasTemplateSpecified = view && !!property_get.get(view, "template");
+ if (!template && !viewHasTemplateSpecified) {
+ template = container.lookup(templateName);
+ }
- function renderHelper(params, hash, options, env) {
- var currentView = env.data.view;
- var container, router, controller, view, initialContext;
+ if (view) {
+ view.ownerView = env.view.ownerView;
+ }
- var name = params[0];
- var context = params[1];
+ // provide controller override
+ var controllerName;
+ var controllerFullName;
- container = currentView._keywords.controller.value().container;
- router = container.lookup('router:main');
+ if (hash.controller) {
+ controllerName = hash.controller;
+ controllerFullName = "controller:" + controllerName;
+ delete hash.controller;
- Ember['default'].assert("The first argument of {{render}} must be quoted, e.g. {{render \"sidebar\"}}.", typeof name === 'string');
+ Ember['default'].assert("The controller name you supplied '" + controllerName + "' " + "did not resolve to a controller.", container._registry.has(controllerFullName));
+ } else {
+ controllerName = name;
+ controllerFullName = "controller:" + controllerName;
+ }
- Ember['default'].assert("The second argument of {{render}} must be a path, e.g. {{render \"post\" post}}.", params.length < 2 || utils.isStream(params[1]));
+ var parentController = utils.read(scope.locals.controller);
+ var controller;
- if (params.length === 1) {
- // use the singleton controller
- Ember['default'].assert("You can only use the {{render}} helper once without a model object as " + "its second argument, as in {{render \"post\" post}}.", !router || !router._lookupActiveView(name));
- } else if (params.length === 2) {
- // create a new controller
- initialContext = context.value();
- } else {
- throw new EmberError['default']("You must pass a templateName to render");
- }
+ // choose name
+ if (params.length > 1) {
+ var factory = container.lookupFactory(controllerFullName) || generateController.generateControllerFactory(container, controllerName);
- // # legacy namespace
- name = name.replace(/\//g, '.');
- // \ legacy slash as namespace support
+ controller = factory.create({
+ model: utils.read(context),
+ parentController: parentController,
+ target: parentController
+ });
- var templateName = 'template:' + name;
- Ember['default'].assert("You used `{{render '" + name + "'}}`, but '" + name + "' can not be " + "found as either a template or a view.", container._registry.has("view:" + name) || container._registry.has(templateName) || !!options.template);
+ node.addDestruction(controller);
+ } else {
+ controller = container.lookup(controllerFullName) || generateController['default'](container, controllerName);
- var template = options.template;
- view = container.lookup('view:' + name);
- if (!view) {
- view = container.lookup('view:default');
- }
- var viewHasTemplateSpecified = !!property_get.get(view, 'template');
- if (!viewHasTemplateSpecified) {
- template = template || container.lookup(templateName);
- }
+ controller.setProperties({
+ target: parentController,
+ parentController: parentController
+ });
+ }
- // provide controller override
- var controllerName;
- var controllerFullName;
+ if (view) {
+ view.set("controller", controller);
+ }
+ state.controller = controller;
- if (hash.controller) {
- controllerName = hash.controller;
- controllerFullName = 'controller:' + controllerName;
- delete hash.controller;
+ hash.viewName = string.camelize(name);
- Ember['default'].assert("The controller name you supplied '" + controllerName + "' " + "did not resolve to a controller.", container._registry.has(controllerFullName));
- } else {
- controllerName = name;
- controllerFullName = 'controller:' + controllerName;
- }
+ // var state = node.state;
+ // var parentView = scope.view;
+ if (template && template.raw) {
+ template = template.raw;
+ }
- var parentController = currentView._keywords.controller.value();
+ var options = {
+ layout: null,
+ self: controller
+ };
- // choose name
- if (params.length > 1) {
- var factory = container.lookupFactory(controllerFullName) || generateController.generateControllerFactory(container, controllerName, initialContext);
+ if (view) {
+ options.component = view;
+ }
- controller = factory.create({
- modelBinding: context, // TODO: Use a StreamBinding
- parentController: parentController,
- target: parentController
- });
+ var nodeManager = ViewNodeManager['default'].create(node, env, hash, options, state.parentView, null, null, template);
+ state.manager = nodeManager;
- view.one('willDestroyElement', function () {
- controller.destroy();
- });
- } else {
- controller = container.lookup(controllerFullName) || generateController['default'](container, controllerName);
+ if (router && params.length === 1) {
+ router._connectActiveComponentNode(name, nodeManager);
+ }
- controller.setProperties({
- target: parentController,
- parentController: parentController
- });
+ nodeManager.render(env, hash, visitor);
+ },
+
+ rerender: function (node, env, scope, params, hash, template, inverse, visitor) {
+ var model = utils.read(params[1]);
+ node.state.controller.set("model", model);
}
+ };
- hash.viewName = string.camelize(name);
+ function childOutletState(name, env) {
+ var topLevel = env.view.ownerView;
+ if (!topLevel || !topLevel.outletState) {
+ return;
+ }
- if (router && !initialContext) {
- router._connectActiveView(name, view);
+ var outletState = topLevel.outletState;
+ if (!outletState.main) {
+ return;
}
- var props = {
- template: template,
- controller: controller,
- helperName: 'render "' + name + '"'
- };
-
- impersonateAnOutlet(currentView, view, name);
- mergeViewBindings['default'](currentView, props, hash);
- appendTemplatedView['default'](currentView, options.morph, view, props);
+ var selectedOutletState = outletState.main.outlets["__ember_orphans__"];
+ if (!selectedOutletState) {
+ return;
+ }
+ var matched = selectedOutletState.outlets[name];
+ if (matched) {
+ var childState = create['default'](null);
+ childState[matched.render.outlet] = matched;
+ matched.wasUsed = true;
+ return childState;
+ }
}
- // Megahax to make outlets inside the render helper work, until we
- // can kill that behavior at 2.0.
- function impersonateAnOutlet(currentView, view, name) {
- view._childOutlets = Ember['default'].A();
- view._isOutlet = true;
- view._outletName = '__ember_orphans__';
- view._matchOutletName = name;
- view._parentOutlet = function () {
- var parent = this._parentView;
- while (parent && !parent._isOutlet) {
- parent = parent._parentView;
+ function isStable(a, b) {
+ if (!a && !b) {
+ return true;
+ }
+ if (!a || !b) {
+ return false;
+ }
+ for (var outletName in a) {
+ if (!isStableOutlet(a[outletName], b[outletName])) {
+ return false;
}
- return parent;
- };
- view.setOutletState = function (state) {
- var ownState;
- if (state && (ownState = state.outlets[this._matchOutletName])) {
- this._outletState = {
- render: { name: 'render helper stub' },
- outlets: create['default'](null)
- };
- this._outletState.outlets[ownState.render.outlet] = ownState;
- ownState.wasUsed = true;
- } else {
- this._outletState = null;
- }
- for (var i = 0; i < this._childOutlets.length; i++) {
- var child = this._childOutlets[i];
- child.setOutletState(this._outletState && this._outletState.outlets[child._outletName]);
- }
- };
+ }
+ return true;
+ }
- var pointer = currentView;
- var po;
- while (pointer && !pointer._isOutlet) {
- pointer = pointer._parentView;
+ function isStableOutlet(a, b) {
+ if (!a && !b) {
+ return true;
}
- while (pointer && (po = pointer._parentOutlet())) {
- pointer = po;
+ if (!a || !b) {
+ return false;
}
- if (pointer) {
- // we've found the toplevel outlet. Subscribe to its
- // __ember_orphan__ child outlet, which is our hack convention for
- // stashing outlet state that may target the render helper.
- pointer._childOutlets.push(view);
- if (pointer._outletState) {
- view.setOutletState(pointer._outletState.outlets[view._outletName]);
+ a = a.render;
+ b = b.render;
+ for (var key in a) {
+ if (a.hasOwnProperty(key)) {
+ // name is only here for logging & debugging. If two different
+ // names result in otherwise identical states, they're still
+ // identical.
+ if (a[key] !== b[key] && key !== "name") {
+ return false;
+ }
}
}
+ return true;
}
});
-enifed('ember-routing-views', ['exports', 'ember-metal/core', 'ember-routing-views/views/link', 'ember-routing-views/views/outlet'], function (exports, Ember, link, outlet) {
+enifed('ember-routing-views', ['exports', 'ember-metal/core', 'ember-routing-views/initializers/link-to-component', 'ember-routing-views/views/link', 'ember-routing-views/views/outlet'], function (exports, Ember, __dep1__, LinkView, outlet) {
'use strict';
/**
Ember Routing Views
@@ -18617,40 +20284,44 @@
@module ember
@submodule ember-routing-views
@requires ember-routing
*/
- Ember['default'].LinkView = link.LinkView;
+ Ember['default'].LinkView = LinkView['default'];
Ember['default'].OutletView = outlet.OutletView;
exports['default'] = Ember['default'];
});
-enifed('ember-routing-views/views/link', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/merge', 'ember-metal/run_loop', 'ember-metal/computed', 'ember-runtime/system/string', 'ember-metal/keys', 'ember-views/system/utils', 'ember-views/views/component', 'ember-routing/utils', 'ember-metal/streams/utils'], function (exports, Ember, property_get, merge, run, computed, string, keys, utils, EmberComponent, ember_routing__utils, streams__utils) {
+enifed('ember-routing-views/initializers/link-to-component', ['ember-runtime/system/lazy_load', 'ember-routing-views/views/link'], function (lazy_load, linkToComponent) {
'use strict';
+ lazy_load.onLoad("Ember.Application", function (Application) {
+ Application.initializer({
+ name: "link-to-component",
+ initialize: function (registry) {
+ registry.register("component:-link-to", linkToComponent['default']);
+ }
+ });
+ });
+
+});
+enifed('ember-routing-views/views/link', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/computed', 'ember-views/system/utils', 'ember-views/views/component', 'ember-runtime/inject', 'ember-runtime/mixins/controller', 'ember-htmlbars/templates/link-to'], function (exports, Ember, property_get, property_set, computed, utils, EmberComponent, inject, ControllerMixin, linkToTemplate) {
+
+ 'use strict';
+
/**
@module ember
@submodule ember-routing-views
*/
- var numberOfContextsAcceptedByHandler = function (handler, handlerInfos) {
- var req = 0;
- for (var i = 0, l = handlerInfos.length; i < l; i++) {
- req = req + handlerInfos[i].names.length;
- if (handlerInfos[i].handler === handler) {
- break;
- }
- }
+ linkToTemplate['default'].meta.revision = "Ember@1.13.0-beta.1";
- return req;
- };
-
- var linkViewClassNameBindings = ['active', 'loading', 'disabled'];
+ var linkViewClassNameBindings = ["active", "loading", "disabled"];
- linkViewClassNameBindings = ['active', 'loading', 'disabled', 'transitioningIn', 'transitioningOut'];
+ linkViewClassNameBindings = ["active", "loading", "disabled", "transitioningIn", "transitioningOut"];
/**
`Ember.LinkView` renders an element whose `click` event triggers a
transition of the application's instance of `Ember.Router` to
@@ -18663,24 +20334,26 @@
@class LinkView
@namespace Ember
@extends Ember.View
@see {Handlebars.helpers.link-to}
**/
- var LinkView = EmberComponent['default'].extend({
- tagName: 'a',
+ var LinkComponent = EmberComponent['default'].extend({
+ defaultLayout: linkToTemplate['default'],
+ tagName: "a",
+
/**
@deprecated Use current-when instead.
@property currentWhen
*/
currentWhen: null,
/**
Used to determine when this LinkView is active.
@property currentWhen
*/
- 'current-when': null,
+ "current-when": null,
/**
Sets the `title` attribute of the `LinkView`'s HTML element.
@property title
@default null
@@ -18714,29 +20387,29 @@
property is `true`.
@property activeClass
@type String
@default active
**/
- activeClass: 'active',
+ activeClass: "active",
/**
The CSS class to apply to `LinkView`'s element when its `loading`
property is `true`.
@property loadingClass
@type String
@default loading
**/
- loadingClass: 'loading',
+ loadingClass: "loading",
/**
The CSS class to apply to a `LinkView`'s element when its `disabled`
property is `true`.
@property disabledClass
@type String
@default disabled
**/
- disabledClass: 'disabled',
+ disabledClass: "disabled",
_isDisabled: false,
/**
Determines whether the `LinkView` will trigger routing via
the `replaceWith` routing strategy.
@@ -18750,13 +20423,13 @@
By default the `{{link-to}}` helper will bind to the `href` and
`title` attributes. It's discouraged that you override these defaults,
however you can push onto the array if needed.
@property attributeBindings
@type Array | String
- @default ['href', 'title', 'rel', 'tabindex', 'target']
+ @default ['title', 'rel', 'tabindex', 'target']
**/
- attributeBindings: ['href', 'title', 'rel', 'tabindex', 'target'],
+ attributeBindings: ["href", "title", "rel", "tabindex", "target"],
/**
By default the `{{link-to}}` helper will bind to the `active`, `loading`, and
`disabled` classes. It is discouraged to override these directly.
@property classNameBindings
@@ -18773,11 +20446,11 @@
click delay using some sort of custom `tap` event.
@property eventName
@type String
@default click
*/
- eventName: 'click',
+ eventName: "click",
// this is doc'ed here so it shows up in the events
// section of the API documentation, which is where
// people will likely go looking for it.
/**
@@ -18807,77 +20480,35 @@
@method init
*/
init: function () {
this._super.apply(this, arguments);
- Ember['default'].deprecate('Using currentWhen with {{link-to}} is deprecated in favor of `current-when`.', !this.currentWhen);
+ Ember['default'].deprecate("Using currentWhen with {{link-to}} is deprecated in favor of `current-when`.", !this.currentWhen);
// Map desired event name to invoke function
- var eventName = property_get.get(this, 'eventName');
+ var eventName = property_get.get(this, "eventName");
this.on(eventName, this, this._invoke);
},
- /**
- This method is invoked by observers installed during `init` that fire
- whenever the params change
- @private
- @method _paramsChanged
- @since 1.3.0
- */
- _paramsChanged: function () {
- this.notifyPropertyChange('resolvedParams');
- },
+ _routing: inject['default'].service("-routing"),
/**
- This is called to setup observers that will trigger a rerender.
- @private
- @method _setupPathObservers
- @since 1.3.0
- **/
- _setupPathObservers: function () {
- var params = this.params;
-
- var scheduledParamsChanged = this._wrapAsScheduled(this._paramsChanged);
-
- for (var i = 0; i < params.length; i++) {
- streams__utils.subscribe(params[i], scheduledParamsChanged, this);
- }
-
- var queryParamsObject = this.queryParamsObject;
- if (queryParamsObject) {
- var values = queryParamsObject.values;
- for (var k in values) {
- if (!values.hasOwnProperty(k)) {
- continue;
- }
-
- streams__utils.subscribe(values[k], scheduledParamsChanged, this);
- }
- }
- },
-
- afterRender: function () {
- this._super.apply(this, arguments);
- this._setupPathObservers();
- },
-
- /**
- Accessed as a classname binding to apply the `LinkView`'s `disabledClass`
+ Accessed as a classname binding to apply the `LinkView`'s `disabledClass`
CSS `class` to the element when the link is disabled.
When `true` interactions with the element will not trigger route changes.
@property disabled
*/
disabled: computed.computed({
get: function (key, value) {
return false;
},
set: function (key, value) {
if (value !== undefined) {
- this.set('_isDisabled', value);
+ this.set("_isDisabled", value);
}
- return value ? property_get.get(this, 'disabledClass') : false;
+ return value ? property_get.get(this, "disabledClass") : false;
}
}),
/**
Accessed as a classname binding to apply the `LinkView`'s `activeClass`
@@ -18887,495 +20518,319 @@
transitions into.
The `currentWhen` property can match against multiple routes by separating
route names using the ` ` (space) character.
@property active
**/
- active: computed.computed('loadedParams', function computeLinkViewActive() {
- var router = property_get.get(this, 'router');
- if (!router) {
- return;
- }
- return computeActive(this, router.currentState);
+ active: computed.computed("attrs.params", "_routing.currentState", function computeLinkViewActive() {
+ var currentState = property_get.get(this, "_routing.currentState");
+ return computeActive(this, currentState);
}),
- willBeActive: computed.computed('router.targetState', function () {
- var router = property_get.get(this, 'router');
- if (!router) {
+ willBeActive: computed.computed("_routing.targetState", function () {
+ var routing = property_get.get(this, "_routing");
+ var targetState = property_get.get(routing, "targetState");
+ if (property_get.get(routing, "currentState") === targetState) {
return;
}
- var targetState = router.targetState;
- if (router.currentState === targetState) {
- return;
- }
return !!computeActive(this, targetState);
}),
- transitioningIn: computed.computed('active', 'willBeActive', function () {
- var willBeActive = property_get.get(this, 'willBeActive');
- if (typeof willBeActive === 'undefined') {
+ transitioningIn: computed.computed("active", "willBeActive", function () {
+ var willBeActive = property_get.get(this, "willBeActive");
+ if (typeof willBeActive === "undefined") {
return false;
}
- return !property_get.get(this, 'active') && willBeActive && 'ember-transitioning-in';
+ return !property_get.get(this, "active") && willBeActive && "ember-transitioning-in";
}),
- transitioningOut: computed.computed('active', 'willBeActive', function () {
- var willBeActive = property_get.get(this, 'willBeActive');
- if (typeof willBeActive === 'undefined') {
+ transitioningOut: computed.computed("active", "willBeActive", function () {
+ var willBeActive = property_get.get(this, "willBeActive");
+ if (typeof willBeActive === "undefined") {
return false;
}
- return property_get.get(this, 'active') && !willBeActive && 'ember-transitioning-out';
+ return property_get.get(this, "active") && !willBeActive && "ember-transitioning-out";
}),
/**
- Accessed as a classname binding to apply the `LinkView`'s `loadingClass`
- CSS `class` to the element when the link is loading.
- A `LinkView` is considered loading when it has at least one
- parameter whose value is currently null or undefined. During
- this time, clicking the link will perform no transition and
- emit a warning that the link is still in a loading state.
- @property loading
- **/
- loading: computed.computed('loadedParams', function computeLinkViewLoading() {
- if (!property_get.get(this, 'loadedParams')) {
- return property_get.get(this, 'loadingClass');
- }
- }),
-
- /**
- Returns the application's main router from the container.
- @private
- @property router
- **/
- router: computed.computed(function () {
- var controller = property_get.get(this, 'controller');
- if (controller && controller.container) {
- return controller.container.lookup('router:main');
- }
- }),
-
- /**
Event handler that invokes the link, activating the associated route.
@private
@method _invoke
@param {Event} event
*/
_invoke: function (event) {
if (!utils.isSimpleClick(event)) {
return true;
}
- if (this.preventDefault !== false) {
- var targetAttribute = property_get.get(this, 'target');
- if (!targetAttribute || targetAttribute === '_self') {
+ if (this.attrs.preventDefault !== false) {
+ var targetAttribute = this.attrs.target;
+ if (!targetAttribute || targetAttribute === "_self") {
event.preventDefault();
}
}
- if (this.bubbles === false) {
+ if (this.attrs.bubbles === false) {
event.stopPropagation();
}
- if (property_get.get(this, '_isDisabled')) {
+ if (property_get.get(this, "_isDisabled")) {
return false;
}
- if (property_get.get(this, 'loading')) {
+ if (property_get.get(this, "loading")) {
Ember['default'].Logger.warn("This link-to is in an inactive loading state because at least one of its parameters presently has a null/undefined value, or the provided route name is invalid.");
return false;
}
- var targetAttribute2 = property_get.get(this, 'target');
- if (targetAttribute2 && targetAttribute2 !== '_self') {
+ var targetAttribute2 = this.attrs.target;
+ if (targetAttribute2 && targetAttribute2 !== "_self") {
return false;
}
- var router = property_get.get(this, 'router');
- var loadedParams = property_get.get(this, 'loadedParams');
-
- var transition = router._doTransition(loadedParams.targetRouteName, loadedParams.models, loadedParams.queryParams);
- if (property_get.get(this, 'replace')) {
- transition.method('replace');
- }
-
-
- return;
-
-
- // Schedule eager URL update, but after we've given the transition
- // a chance to synchronously redirect.
- // We need to always generate the URL instead of using the href because
- // the href will include any rootURL set, but the router expects a URL
- // without it! Note that we don't use the first level router because it
- // calls location.formatURL(), which also would add the rootURL!
- var args = ember_routing__utils.routeArgs(loadedParams.targetRouteName, loadedParams.models, transition.state.queryParams);
- var url = router.router.generate.apply(router.router, args);
-
- run['default'].scheduleOnce('routerTransitions', this, this._eagerUpdateUrl, transition, url);
+ property_get.get(this, "_routing").transitionTo(property_get.get(this, "targetRouteName"), property_get.get(this, "models"), property_get.get(this, "queryParams.values"), property_get.get(this, "attrs.replace"));
},
+ queryParams: null,
+
/**
- @private
- @method _eagerUpdateUrl
- @param transition
- @param href
- */
- _eagerUpdateUrl: function (transition, href) {
- if (!transition.isActive || !transition.urlMethod) {
- // transition was aborted, already ran to completion,
- // or it has a null url-updated method.
+ Sets the element's `href` attribute to the url for
+ the `LinkView`'s targeted route.
+ If the `LinkView`'s `tagName` is changed to a value other
+ than `a`, this property will be ignored.
+ @property href
+ **/
+ href: computed.computed("models", "targetRouteName", "_routing.currentState", function computeLinkViewHref() {
+ if (property_get.get(this, "tagName") !== "a") {
return;
}
- if (href.indexOf('#') === 0) {
- href = href.slice(1);
- }
+ var targetRouteName = property_get.get(this, "targetRouteName");
+ var models = property_get.get(this, "models");
- // Re-use the routerjs hooks set up by the Ember router.
- var routerjs = property_get.get(this, 'router.router');
- if (transition.urlMethod === 'update') {
- routerjs.updateURL(href);
- } else if (transition.urlMethod === 'replace') {
- routerjs.replaceURL(href);
+ if (property_get.get(this, "loading")) {
+ return property_get.get(this, "loadingHref");
}
- // Prevent later update url refire.
- transition.method(null);
- },
+ var routing = property_get.get(this, "_routing");
+ return routing.generateURL(targetRouteName, models, property_get.get(this, "queryParams.values"));
+ }),
+ loading: computed.computed("models", "targetRouteName", function () {
+ var targetRouteName = property_get.get(this, "targetRouteName");
+ var models = property_get.get(this, "models");
+
+ if (!modelsAreLoaded(models) || targetRouteName == null) {
+ return property_get.get(this, "loadingClass");
+ }
+ }),
+
/**
- Computed property that returns an array of the
- resolved parameters passed to the `link-to` helper,
- e.g.:
- ```hbs
- {{link-to a b '123' c}}
- ```
- will generate a `resolvedParams` of:
- ```js
- [aObject, bObject, '123', cObject]
- ```
- @private
- @property
- @return {Array}
- */
- resolvedParams: computed.computed('router.url', function () {
- var params = this.params;
- var targetRouteName;
- var models = [];
- var onlyQueryParamsSupplied = params.length === 0;
+ The default href value to use while a link-to is loading.
+ Only applies when tagName is 'a'
+ @property loadingHref
+ @type String
+ @default #
+ */
+ loadingHref: "#",
- if (onlyQueryParamsSupplied) {
- var appController = this.container.lookup('controller:application');
- targetRouteName = property_get.get(appController, 'currentRouteName');
- } else {
- targetRouteName = streams__utils.read(params[0]);
+ willRender: function () {
+ var queryParams;
- for (var i = 1; i < params.length; i++) {
- models.push(streams__utils.read(params[i]));
- }
- }
+ var attrs = this.attrs;
- var suppliedQueryParams = getResolvedQueryParams(this, targetRouteName);
+ // Do not mutate params in place
+ var params = attrs.params.slice();
- return {
- targetRouteName: targetRouteName,
- models: models,
- queryParams: suppliedQueryParams
- };
- }),
+ Ember['default'].assert("You must provide one or more parameters to the link-to helper.", params.length);
- /**
- Computed property that returns the current route name,
- dynamic segments, and query params. Returns falsy if
- for null/undefined params to indicate that the link view
- is still in a loading state.
- @private
- @property
- @return {Array} An array with the route name and any dynamic segments
- **/
- loadedParams: computed.computed('resolvedParams', function computeLinkViewRouteArgs() {
- var router = property_get.get(this, 'router');
- if (!router) {
- return;
+ var lastParam = params[params.length - 1];
+
+ if (lastParam && lastParam.isQueryParams) {
+ queryParams = params.pop();
+ } else {
+ queryParams = {};
}
- var resolvedParams = property_get.get(this, 'resolvedParams');
- var namedRoute = resolvedParams.targetRouteName;
+ if (attrs.disabledClass) {
+ this.set("disabledClass", attrs.disabledClass);
+ }
- if (!namedRoute) {
- return;
+ if (attrs.activeClass) {
+ this.set("activeClass", attrs.activeClass);
}
- Ember['default'].assert(string.fmt("The attempt to link-to route '%@' failed. " + "The router did not find '%@' in its possible routes: '%@'", [namedRoute, namedRoute, keys['default'](router.router.recognizer.names).join("', '")]), router.hasRoute(namedRoute));
-
- if (!paramsAreLoaded(resolvedParams.models)) {
- return;
+ if (attrs.disabledWhen) {
+ this.set("disabled", attrs.disabledWhen);
}
- return resolvedParams;
- }),
+ var currentWhen = attrs["current-when"];
- queryParamsObject: null,
+ if (attrs.currentWhen) {
+ Ember['default'].deprecate("Using currentWhen with {{link-to}} is deprecated in favor of `current-when`.", !attrs.currentWhen);
+ currentWhen = attrs.currentWhen;
+ }
- /**
- Sets the element's `href` attribute to the url for
- the `LinkView`'s targeted route.
- If the `LinkView`'s `tagName` is changed to a value other
- than `a`, this property will be ignored.
- @property href
- **/
- href: computed.computed('loadedParams', function computeLinkViewHref() {
- if (property_get.get(this, 'tagName') !== 'a') {
- return;
+ if (currentWhen) {
+ this.set("currentWhen", currentWhen);
}
- var router = property_get.get(this, 'router');
- var loadedParams = property_get.get(this, 'loadedParams');
+ // TODO: Change to built-in hasBlock once it's available
+ if (!attrs.hasBlock) {
+ this.set("linkTitle", params.shift());
+ }
- if (!loadedParams) {
- return property_get.get(this, 'loadingHref');
+ if (attrs.loadingClass) {
+ property_set.set(this, "loadingClass", attrs.loadingClass);
}
- var visibleQueryParams = {};
- merge['default'](visibleQueryParams, loadedParams.queryParams);
- router._prepareQueryParams(loadedParams.targetRouteName, loadedParams.models, visibleQueryParams);
+ for (var i = 0; i < params.length; i++) {
+ var value = params[i];
- var args = ember_routing__utils.routeArgs(loadedParams.targetRouteName, loadedParams.models, visibleQueryParams);
- var result = router.generate.apply(router, args);
- return result;
- }),
+ while (ControllerMixin['default'].detect(value)) {
+ Ember['default'].deprecate("Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated. Please update `" + attrs.view + "` to use `{{link-to \"post\" someController.model}}` instead.");
+ value = value.get("model");
+ }
- /**
- The default href value to use while a link-to is loading.
- Only applies when tagName is 'a'
- @property loadingHref
- @type String
- @default #
- */
- loadingHref: '#'
- });
+ params[i] = value;
+ }
- LinkView.toString = function () {
- return "LinkView";
- };
+ var targetRouteName = undefined;
+ var models = [];
+ var onlyQueryParamsSupplied = params.length === 0;
- function getResolvedQueryParams(linkView, targetRouteName) {
- var queryParamsObject = linkView.queryParamsObject;
- var resolvedQueryParams = {};
+ if (onlyQueryParamsSupplied) {
+ var appController = this.container.lookup("controller:application");
+ if (appController) {
+ targetRouteName = property_get.get(appController, "currentRouteName");
+ }
+ } else {
+ targetRouteName = params[0];
- if (!queryParamsObject) {
- return resolvedQueryParams;
- }
-
- var values = queryParamsObject.values;
- for (var key in values) {
- if (!values.hasOwnProperty(key)) {
- continue;
+ for (var i = 1; i < params.length; i++) {
+ models.push(params[i]);
+ }
}
- resolvedQueryParams[key] = streams__utils.read(values[key]);
- }
- return resolvedQueryParams;
- }
+ var resolvedQueryParams = getResolvedQueryParams(queryParams, targetRouteName);
- function paramsAreLoaded(params) {
- for (var i = 0, len = params.length; i < len; ++i) {
- var param = params[i];
- if (param === null || typeof param === 'undefined') {
- return false;
- }
+ this.set("targetRouteName", targetRouteName);
+ this.set("models", models);
+ this.set("queryParams", queryParams);
+ this.set("resolvedQueryParams", resolvedQueryParams);
}
- return true;
- }
+ });
- function computeActive(route, routerState) {
- if (property_get.get(route, 'loading')) {
+ LinkComponent.toString = function () {
+ return "LinkComponent";
+ };
+
+ function computeActive(view, routerState) {
+ if (property_get.get(view, "loading")) {
return false;
}
- var currentWhen = route['current-when'] || route.currentWhen;
+ var currentWhen = property_get.get(view, "currentWhen");
var isCurrentWhenSpecified = !!currentWhen;
- currentWhen = currentWhen || property_get.get(route, 'loadedParams').targetRouteName;
- currentWhen = currentWhen.split(' ');
+ currentWhen = currentWhen || property_get.get(view, "targetRouteName");
+ currentWhen = currentWhen.split(" ");
for (var i = 0, len = currentWhen.length; i < len; i++) {
- if (isActiveForRoute(route, currentWhen[i], isCurrentWhenSpecified, routerState)) {
- return property_get.get(route, 'activeClass');
+ if (isActiveForRoute(view, currentWhen[i], isCurrentWhenSpecified, routerState)) {
+ return property_get.get(view, "activeClass");
}
}
return false;
}
- function isActiveForRoute(route, routeName, isCurrentWhenSpecified, routerState) {
- var router = property_get.get(route, 'router');
- var loadedParams = property_get.get(route, 'loadedParams');
- var contexts = loadedParams.models;
+ function modelsAreLoaded(models) {
+ for (var i = 0, l = models.length; i < l; i++) {
+ if (models[i] == null) {
+ return false;
+ }
+ }
- var handlers = router.router.recognizer.handlersFor(routeName);
- var leafName = handlers[handlers.length - 1].handler;
- var maximumContexts = numberOfContextsAcceptedByHandler(routeName, handlers);
+ return true;
+ }
- // NOTE: any ugliness in the calculation of activeness is largely
- // due to the fact that we support automatic normalizing of
- // `resource` -> `resource.index`, even though there might be
- // dynamic segments / query params defined on `resource.index`
- // which complicates (and makes somewhat ambiguous) the calculation
- // of activeness for links that link to `resource` instead of
- // directly to `resource.index`.
+ function isActiveForRoute(view, routeName, isCurrentWhenSpecified, routerState) {
+ var service = property_get.get(view, "_routing");
+ return service.isActiveForRoute(property_get.get(view, "models"), property_get.get(view, "resolvedQueryParams"), routeName, routerState, isCurrentWhenSpecified);
+ }
- // if we don't have enough contexts revert back to full route name
- // this is because the leaf route will use one of the contexts
- if (contexts.length > maximumContexts) {
- routeName = leafName;
+ function getResolvedQueryParams(queryParamsObject, targetRouteName) {
+ var resolvedQueryParams = {};
+
+ if (!queryParamsObject) {
+ return resolvedQueryParams;
}
- return routerState.isActiveIntent(routeName, contexts, loadedParams.queryParams, !isCurrentWhenSpecified);
+ var values = queryParamsObject.values;
+ for (var key in values) {
+ if (!values.hasOwnProperty(key)) {
+ continue;
+ }
+ resolvedQueryParams[key] = values[key];
+ }
+
+ return resolvedQueryParams;
}
- exports.LinkView = LinkView;
+ exports['default'] = LinkComponent;
});
-enifed('ember-routing-views/views/outlet', ['exports', 'ember-views/views/container_view', 'ember-views/views/metamorph_view', 'ember-metal/property_get'], function (exports, ContainerView, metamorph_view, property_get) {
+enifed('ember-routing-views/views/outlet', ['exports', 'ember-views/views/view', 'ember-htmlbars/templates/top-level-view'], function (exports, View, topLevelViewTemplate) {
'use strict';
/**
@module ember
@submodule ember-routing-views
*/
- var CoreOutletView = ContainerView['default'].extend({
- init: function () {
- this._super();
- this._childOutlets = Ember.A();
- this._outletState = null;
- },
+ topLevelViewTemplate['default'].meta.revision = "Ember@1.13.0-beta.1";
- _isOutlet: true,
+ var CoreOutletView = View['default'].extend({
+ defaultTemplate: topLevelViewTemplate['default'],
- _parentOutlet: function () {
- var parent = this._parentView;
- while (parent && !parent._isOutlet) {
- parent = parent._parentView;
- }
- return parent;
- },
-
- _linkParent: Ember.on('init', 'parentViewDidChange', function () {
- var parent = this._parentOutlet();
- if (parent) {
- parent._childOutlets.push(this);
- if (parent._outletState) {
- this.setOutletState(parent._outletState.outlets[this._outletName]);
- }
- }
- }),
-
- willDestroy: function () {
- var parent = this._parentOutlet();
- if (parent) {
- parent._childOutlets.removeObject(this);
- }
+ init: function () {
this._super();
+ this._outlets = [];
},
- _diffState: function (state) {
- while (state && emptyRouteState(state)) {
- state = state.outlets.main;
- }
- var different = !sameRouteState(this._outletState, state);
- this._outletState = state;
- return different;
- },
-
setOutletState: function (state) {
- if (!this._diffState(state)) {
- var children = this._childOutlets;
- for (var i = 0; i < children.length; i++) {
- var child = children[i];
- child.setOutletState(this._outletState && this._outletState.outlets[child._outletName]);
- }
- } else {
- var view = this._buildView(this._outletState);
- var length = property_get.get(this, 'length');
- if (view) {
- this.replace(0, length, [view]);
- } else {
- this.replace(0, length, []);
- }
- }
- },
+ this.outletState = { main: state };
- _buildView: function (state) {
- if (!state) {
- return;
+ if (this.env) {
+ this.env.outletState = this.outletState;
}
- var LOG_VIEW_LOOKUPS = property_get.get(this, 'namespace.LOG_VIEW_LOOKUPS');
- var view;
- var render = state.render;
- var ViewClass = render.ViewClass;
- var isDefaultView = false;
+ if (this.lastResult) {
+ this.dirtyOutlets();
+ this._outlets = [];
- if (!ViewClass) {
- isDefaultView = true;
- ViewClass = this.container.lookupFactory(this._isTopLevel ? 'view:toplevel' : 'view:default');
+ this.scheduleRevalidate(null, null);
}
+ },
- view = ViewClass.create({
- _debugTemplateName: render.name,
- renderedName: render.name,
- controller: render.controller
- });
-
- if (!property_get.get(view, 'template')) {
- view.set('template', render.template);
+ dirtyOutlets: function () {
+ // Dirty any render nodes that correspond to outlets
+ for (var i = 0; i < this._outlets.length; i++) {
+ this._outlets[i].isDirty = true;
}
-
- if (LOG_VIEW_LOOKUPS) {
- Ember.Logger.info("Rendering " + render.name + " with " + (render.isDefaultView ? "default view " : "") + view, { fullName: 'view:' + render.name });
- }
-
- return view;
}
});
- function emptyRouteState(state) {
- return !state.render.ViewClass && !state.render.template;
- }
+ var OutletView = CoreOutletView.extend({ tagName: "" });
- function sameRouteState(a, b) {
- if (!a && !b) {
- return true;
- }
- if (!a || !b) {
- return false;
- }
- a = a.render;
- b = b.render;
- for (var key in a) {
- if (a.hasOwnProperty(key)) {
- // name is only here for logging & debugging. If two different
- // names result in otherwise identical states, they're still
- // identical.
- if (a[key] !== b[key] && key !== 'name') {
- return false;
- }
- }
- }
- return true;
- }
-
- var OutletView = CoreOutletView.extend(metamorph_view._Metamorph);
-
exports.CoreOutletView = CoreOutletView;
exports.OutletView = OutletView;
});
-enifed('ember-routing', ['exports', 'ember-metal/core', 'ember-routing/ext/run_loop', 'ember-routing/ext/controller', 'ember-routing/location/api', 'ember-routing/location/none_location', 'ember-routing/location/hash_location', 'ember-routing/location/history_location', 'ember-routing/location/auto_location', 'ember-routing/system/generate_controller', 'ember-routing/system/controller_for', 'ember-routing/system/dsl', 'ember-routing/system/router', 'ember-routing/system/route'], function (exports, Ember, __dep1__, __dep2__, EmberLocation, NoneLocation, HashLocation, HistoryLocation, AutoLocation, generateController, controllerFor, RouterDSL, Router, Route) {
+enifed('ember-routing', ['exports', 'ember-metal/core', 'ember-routing/ext/run_loop', 'ember-routing/ext/controller', 'ember-routing/location/api', 'ember-routing/location/none_location', 'ember-routing/location/hash_location', 'ember-routing/location/history_location', 'ember-routing/location/auto_location', 'ember-routing/system/generate_controller', 'ember-routing/system/controller_for', 'ember-routing/system/dsl', 'ember-routing/system/router', 'ember-routing/system/route', 'ember-routing/initializers/routing-service'], function (exports, Ember, __dep1__, __dep2__, EmberLocation, NoneLocation, HashLocation, HistoryLocation, AutoLocation, generateController, controllerFor, RouterDSL, Router, Route) {
'use strict';
/**
Ember Routing
@@ -19404,11 +20859,11 @@
enifed('ember-routing/ext/controller', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/computed', 'ember-metal/utils', 'ember-metal/merge', 'ember-runtime/mixins/controller'], function (exports, Ember, property_get, property_set, computed, utils, merge, ControllerMixin) {
'use strict';
ControllerMixin['default'].reopen({
- concatenatedProperties: ['queryParams', '_pCacheMeta'],
+ concatenatedProperties: ["queryParams"],
init: function () {
this._super.apply(this, arguments);
listenForQueryParamChanges(this);
},
@@ -19434,14 +20889,14 @@
@private
*/
_normalizedQueryParams: computed.computed(function () {
var m = utils.meta(this);
if (m.proto !== this) {
- return property_get.get(m.proto, '_normalizedQueryParams');
+ return property_get.get(m.proto, "_normalizedQueryParams");
}
- var queryParams = property_get.get(this, 'queryParams');
+ var queryParams = property_get.get(this, "queryParams");
if (queryParams._qpMap) {
return queryParams._qpMap;
}
var qpMap = queryParams._qpMap = {};
@@ -19458,25 +20913,25 @@
@private
*/
_cacheMeta: computed.computed(function () {
var m = utils.meta(this);
if (m.proto !== this) {
- return property_get.get(m.proto, '_cacheMeta');
+ return property_get.get(m.proto, "_cacheMeta");
}
var cacheMeta = {};
- var qpMap = property_get.get(this, '_normalizedQueryParams');
+ var qpMap = property_get.get(this, "_normalizedQueryParams");
for (var prop in qpMap) {
if (!qpMap.hasOwnProperty(prop)) {
continue;
}
var qp = qpMap[prop];
var scope = qp.scope;
var parts;
- if (scope === 'controller') {
+ if (scope === "controller") {
parts = [];
}
cacheMeta[prop] = {
parts: parts, // provided by route if 'model' scope
@@ -19493,11 +20948,11 @@
/**
@method _updateCacheParams
@private
*/
_updateCacheParams: function (params) {
- var cacheMeta = property_get.get(this, '_cacheMeta');
+ var cacheMeta = property_get.get(this, "_cacheMeta");
for (var prop in cacheMeta) {
if (!cacheMeta.hasOwnProperty(prop)) {
continue;
}
var propMeta = cacheMeta[prop];
@@ -19517,11 +20972,11 @@
@method _qpChanged
@private
*/
_qpChanged: function (controller, _prop) {
var prop = _prop.substr(0, _prop.length - 3);
- var cacheMeta = property_get.get(controller, '_cacheMeta');
+ var cacheMeta = property_get.get(controller, "_cacheMeta");
var propCache = cacheMeta[prop];
var cacheKey = controller._calculateCacheKey(propCache.prefix || "", propCache.parts, propCache.values);
var value = property_get.get(controller, prop);
// 1. Update model-dep cache
@@ -19547,11 +21002,11 @@
for (var i = 0, len = parts.length; i < len; ++i) {
var part = parts[i];
var value = property_get.get(values, part);
suffixes += "::" + part + ":" + value;
}
- return prefix + suffixes.replace(ALL_PERIODS_REGEX, '-');
+ return prefix + suffixes.replace(ALL_PERIODS_REGEX, "-");
},
/**
Transition the application into another route. The route may
be either a single route or route path:
@@ -19608,11 +21063,11 @@
@for Ember.ControllerMixin
@method transitionToRoute
*/
transitionToRoute: function () {
// target may be either another controller or a router
- var target = property_get.get(this, 'target');
+ var target = property_get.get(this, "target");
var method = target.transitionToRoute || target.transitionTo;
return method.apply(target, arguments);
},
/**
@@ -19669,11 +21124,11 @@
@for Ember.ControllerMixin
@method replaceRoute
*/
replaceRoute: function () {
// target may be either another controller or a router
- var target = property_get.get(this, 'target');
+ var target = property_get.get(this, "target");
var method = target.replaceRoute || target.replaceWith;
return method.apply(target, arguments);
},
/**
@@ -19690,11 +21145,11 @@
var ALL_PERIODS_REGEX = /\./g;
function accumulateQueryParamDescriptors(_desc, accum) {
var desc = _desc;
var tmp;
- if (utils.typeOf(desc) === 'string') {
+ if (typeof desc === "string") {
tmp = {};
tmp[desc] = { as: null };
desc = tmp;
}
@@ -19702,28 +21157,28 @@
if (!desc.hasOwnProperty(key)) {
return;
}
var singleDesc = desc[key];
- if (utils.typeOf(singleDesc) === 'string') {
+ if (typeof singleDesc === "string") {
singleDesc = { as: singleDesc };
}
- tmp = accum[key] || { as: null, scope: 'model' };
+ tmp = accum[key] || { as: null, scope: "model" };
merge['default'](tmp, singleDesc);
accum[key] = tmp;
}
}
function listenForQueryParamChanges(controller) {
- var qpMap = property_get.get(controller, '_normalizedQueryParams');
+ var qpMap = property_get.get(controller, "_normalizedQueryParams");
for (var prop in qpMap) {
if (!qpMap.hasOwnProperty(prop)) {
continue;
}
- controller.addObserver(prop + '.[]', controller, controller._qpChanged);
+ controller.addObserver(prop + ".[]", controller, controller._qpChanged);
}
}
exports['default'] = ControllerMixin['default'];
@@ -19733,10 +21188,27 @@
'use strict';
run['default']._addQueue('routerTransitions', 'actions');
});
+enifed('ember-routing/initializers/routing-service', ['ember-runtime/system/lazy_load', 'ember-routing/services/routing'], function (lazy_load, RoutingService) {
+
+ 'use strict';
+
+ lazy_load.onLoad("Ember.Application", function (Application) {
+ Application.initializer({
+ name: "routing-service",
+ initialize: function (registry) {
+ // Register the routing service...
+ registry.register("service:-routing", RoutingService['default']);
+ // Then inject the app router into it
+ registry.injection("service:-routing", "router", "router:main");
+ }
+ });
+ });
+
+});
enifed('ember-routing/location/api', ['exports', 'ember-metal/core', 'ember-metal/environment', 'ember-routing/location/util'], function (exports, Ember, environment, util) {
'use strict';
exports['default'] = {
@@ -19783,11 +21255,11 @@
@param {Object} implementation of the `location` API
@deprecated Register your custom location implementation with the
container directly.
*/
registerImplementation: function (name, implementation) {
- Ember['default'].deprecate('Using the Ember.Location.registerImplementation is no longer supported.' + ' Register your custom location implementation with the container instead.');
+ Ember['default'].deprecate("Using the Ember.Location.registerImplementation is no longer supported. Register your custom location implementation with the container instead.", false);
this.implementations[name] = implementation;
},
implementations: {},
@@ -19812,10 +21284,17 @@
'use strict';
exports.getHistoryPath = getHistoryPath;
exports.getHashPath = getHashPath;
+ /**
+ @private
+
+ Returns the current path as it should appear for HistoryLocation supported
+ browsers. This may very well differ from the real current path (e.g. if it
+ starts off as a hashed URL)
+ */
exports['default'] = EmberObject['default'].extend({
/**
@private
The browser's `location` object. This is typically equivalent to
`window.location`, but may be overridden for testing.
@@ -19868,21 +21347,21 @@
Will be pre-pended to path upon state change.
@since 1.5.1
@property rootURL
@default '/'
*/
- rootURL: '/',
+ rootURL: "/",
/**
Called by the router to instruct the location to do any feature detection
necessary. In the case of AutoLocation, we detect whether to use history
or hash concrete implementations.
*/
detect: function () {
var rootURL = this.rootURL;
- Ember['default'].assert('rootURL must end with a trailing forward slash e.g. "/app/"', rootURL.charAt(rootURL.length - 1) === '/');
+ Ember['default'].assert("rootURL must end with a trailing forward slash e.g. \"/app/\"", rootURL.charAt(rootURL.length - 1) === "/");
var implementation = detectImplementation({
location: this.location,
history: this.history,
userAgent: this.userAgent,
@@ -19890,47 +21369,44 @@
documentMode: this.documentMode,
global: this.global
});
if (implementation === false) {
- property_set.set(this, 'cancelRouterSetup', true);
- implementation = 'none';
+ property_set.set(this, "cancelRouterSetup", true);
+ implementation = "none";
}
- var concrete = this.container.lookup('location:' + implementation);
- property_set.set(concrete, 'rootURL', rootURL);
-
+ var concrete = this.container.lookup("location:" + implementation);
Ember['default'].assert("Could not find location '" + implementation + "'.", !!concrete);
- property_set.set(this, 'concreteImplementation', concrete);
+ property_set.set(this, "concreteImplementation", concrete);
},
- initState: delegateToConcreteImplementation('initState'),
- getURL: delegateToConcreteImplementation('getURL'),
- setURL: delegateToConcreteImplementation('setURL'),
- replaceURL: delegateToConcreteImplementation('replaceURL'),
- onUpdateURL: delegateToConcreteImplementation('onUpdateURL'),
- formatURL: delegateToConcreteImplementation('formatURL'),
+ initState: delegateToConcreteImplementation("initState"),
+ getURL: delegateToConcreteImplementation("getURL"),
+ setURL: delegateToConcreteImplementation("setURL"),
+ replaceURL: delegateToConcreteImplementation("replaceURL"),
+ onUpdateURL: delegateToConcreteImplementation("onUpdateURL"),
+ formatURL: delegateToConcreteImplementation("formatURL"),
willDestroy: function () {
- var concreteImplementation = property_get.get(this, 'concreteImplementation');
+ var concreteImplementation = property_get.get(this, "concreteImplementation");
if (concreteImplementation) {
concreteImplementation.destroy();
}
}
});
function delegateToConcreteImplementation(methodName) {
return function () {
- var concreteImplementation = property_get.get(this, 'concreteImplementation');
- Ember['default'].assert("AutoLocation's detect() method should be called before calling any other hooks.", !!concreteImplementation);
-
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
+ var concreteImplementation = property_get.get(this, "concreteImplementation");
+ Ember['default'].assert("AutoLocation's detect() method should be called before calling any other hooks.", !!concreteImplementation);
return utils.tryInvoke(concreteImplementation, methodName, args);
};
}
/**
@@ -19953,25 +21429,25 @@
var history = options.history;
var documentMode = options.documentMode;
var global = options.global;
var rootURL = options.rootURL;
- var implementation = 'none';
+ var implementation = "none";
var cancelRouterSetup = false;
var currentPath = util.getFullPath(location);
if (util.supportsHistory(userAgent, history)) {
var historyPath = getHistoryPath(rootURL, location);
// If the browser supports history and we have a history path, we can use
// the history location with no redirects.
if (currentPath === historyPath) {
- return 'history';
+ return "history";
} else {
- if (currentPath.substr(0, 2) === '/#') {
+ if (currentPath.substr(0, 2) === "/#") {
history.replaceState({ path: historyPath }, null, historyPath);
- implementation = 'history';
+ implementation = "history";
} else {
cancelRouterSetup = true;
util.replacePath(location, historyPath);
}
}
@@ -19979,12 +21455,12 @@
var hashPath = getHashPath(rootURL, location);
// Be sure we're using a hashed path, otherwise let's switch over it to so
// we start off clean and consistent. We'll count an index path with no
// hash as "good enough" as well.
- if (currentPath === hashPath || currentPath === '/' && hashPath === '/#/') {
- implementation = 'hash';
+ if (currentPath === hashPath || currentPath === "/" && hashPath === "/#/") {
+ implementation = "hash";
} else {
// Our URL isn't in the expected hash-supported format, so we want to
// cancel the router setup and replace the URL to start off clean
cancelRouterSetup = true;
util.replacePath(location, hashPath);
@@ -19995,76 +21471,58 @@
return false;
}
return implementation;
}
-
- /**
- @private
-
- Returns the current path as it should appear for HistoryLocation supported
- browsers. This may very well differ from the real current path (e.g. if it
- starts off as a hashed URL)
- */
-
function getHistoryPath(rootURL, location) {
var path = util.getPath(location);
var hash = util.getHash(location);
var query = util.getQuery(location);
var rootURLIndex = path.indexOf(rootURL);
var routeHash, hashParts;
- Ember['default'].assert('Path ' + path + ' does not start with the provided rootURL ' + rootURL, rootURLIndex === 0);
+ Ember['default'].assert("Path " + path + " does not start with the provided rootURL " + rootURL, rootURLIndex === 0);
// By convention, Ember.js routes using HashLocation are required to start
// with `#/`. Anything else should NOT be considered a route and should
// be passed straight through, without transformation.
- if (hash.substr(0, 2) === '#/') {
+ if (hash.substr(0, 2) === "#/") {
// There could be extra hash segments after the route
- hashParts = hash.substr(1).split('#');
+ hashParts = hash.substr(1).split("#");
// The first one is always the route url
routeHash = hashParts.shift();
// If the path already has a trailing slash, remove the one
// from the hashed route so we don't double up.
- if (path.slice(-1) === '/') {
+ if (path.slice(-1) === "/") {
routeHash = routeHash.substr(1);
}
// This is the "expected" final order
path = path + routeHash + query;
if (hashParts.length) {
- path += '#' + hashParts.join('#');
+ path += "#" + hashParts.join("#");
}
} else {
path = path + query + hash;
}
return path;
}
- /**
- @private
-
- Returns the current path as it should appear for HashLocation supported
- browsers. This may very well differ from the real current path.
-
- @method _getHashPath
- */
-
function getHashPath(rootURL, location) {
var path = rootURL;
var historyPath = getHistoryPath(rootURL, location);
var routePath = historyPath.substr(rootURL.length);
- if (routePath !== '') {
- if (routePath.charAt(0) !== '/') {
- routePath = '/' + routePath;
+ if (routePath !== "") {
+ if (routePath.charAt(0) !== "/") {
+ routePath = "/" + routePath;
}
- path += '#' + routePath;
+ path += "#" + routePath;
}
return path;
}
@@ -20072,14 +21530,14 @@
enifed('ember-routing/location/hash_location', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/run_loop', 'ember-metal/utils', 'ember-runtime/system/object', 'ember-routing/location/api'], function (exports, Ember, property_get, property_set, run, utils, EmberObject, EmberLocation) {
'use strict';
exports['default'] = EmberObject['default'].extend({
- implementation: 'hash',
+ implementation: "hash",
init: function () {
- property_set.set(this, 'location', property_get.get(this, '_location') || window.location);
+ property_set.set(this, "location", property_get.get(this, "_location") || window.location);
},
/**
@private
Returns normalized location.hash
@@ -20098,19 +21556,19 @@
*/
getURL: function () {
var originalPath = this.getHash().substr(1);
var outPath = originalPath;
- if (outPath.charAt(0) !== '/') {
- outPath = '/';
+ if (outPath.charAt(0) !== "/") {
+ outPath = "/";
// Only add the # if the path isn't empty.
// We do NOT want `/#` since the ampersand
// is only included (conventionally) when
// the location.hash has a value
if (originalPath) {
- outPath += '#' + originalPath;
+ outPath += "#" + originalPath;
}
}
return outPath;
},
@@ -20122,24 +21580,24 @@
@private
@method setURL
@param path {String}
*/
setURL: function (path) {
- property_get.get(this, 'location').hash = path;
- property_set.set(this, 'lastSetURL', path);
+ property_get.get(this, "location").hash = path;
+ property_set.set(this, "lastSetURL", path);
},
/**
Uses location.replace to update the url without a page reload
or history modification.
@private
@method replaceURL
@param path {String}
*/
replaceURL: function (path) {
- property_get.get(this, 'location').replace('#' + path);
- property_set.set(this, 'lastSetURL', path);
+ property_get.get(this, "location").replace("#" + path);
+ property_set.set(this, "lastSetURL", path);
},
/**
Register a callback to be invoked when the hash changes. These
callbacks will execute when the user presses the back or forward
@@ -20147,21 +21605,22 @@
@private
@method onUpdateURL
@param callback {Function}
*/
onUpdateURL: function (callback) {
- var self = this;
+ var _this = this;
+
var guid = utils.guidFor(this);
- Ember['default'].$(window).on('hashchange.ember-location-' + guid, function () {
+ Ember['default'].$(window).on("hashchange.ember-location-" + guid, function () {
run['default'](function () {
- var path = self.getURL();
- if (property_get.get(self, 'lastSetURL') === path) {
+ var path = _this.getURL();
+ if (property_get.get(_this, "lastSetURL") === path) {
return;
}
- property_set.set(self, 'lastSetURL', null);
+ property_set.set(_this, "lastSetURL", null);
callback(path);
});
});
},
@@ -20174,22 +21633,22 @@
@private
@method formatURL
@param url {String}
*/
formatURL: function (url) {
- return '#' + url;
+ return "#" + url;
},
/**
Cleans up the HashLocation event listener.
@private
@method willDestroy
*/
willDestroy: function () {
var guid = utils.guidFor(this);
- Ember['default'].$(window).off('hashchange.ember-location-' + guid);
+ Ember['default'].$(window).off("hashchange.ember-location-" + guid);
}
});
});
enifed('ember-routing/location/history_location', ['exports', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/utils', 'ember-runtime/system/object', 'ember-routing/location/api', 'ember-views/system/jquery'], function (exports, property_get, property_set, utils, EmberObject, EmberLocation, jQuery) {
@@ -20205,27 +21664,27 @@
@class HistoryLocation
@namespace Ember
@extends Ember.Object
*/
exports['default'] = EmberObject['default'].extend({
- implementation: 'history',
+ implementation: "history",
init: function () {
- property_set.set(this, 'location', property_get.get(this, 'location') || window.location);
- property_set.set(this, 'baseURL', jQuery['default']('base').attr('href') || '');
+ property_set.set(this, "location", property_get.get(this, "location") || window.location);
+ property_set.set(this, "baseURL", jQuery['default']("base").attr("href") || "");
},
/**
Used to set state on first call to setURL
@private
@method initState
*/
initState: function () {
- var history = property_get.get(this, 'history') || window.history;
- property_set.set(this, 'history', history);
+ var history = property_get.get(this, "history") || window.history;
+ property_set.set(this, "history", history);
- if (history && 'state' in history) {
+ if (history && "state" in history) {
this.supportsHistory = true;
}
this.replaceState(this.formatURL(this.getURL()));
},
@@ -20233,29 +21692,29 @@
/**
Will be pre-pended to path upon state change
@property rootURL
@default '/'
*/
- rootURL: '/',
+ rootURL: "/",
/**
Returns the current `location.pathname` without `rootURL` or `baseURL`
@private
@method getURL
@return url {String}
*/
getURL: function () {
- var rootURL = property_get.get(this, 'rootURL');
- var location = property_get.get(this, 'location');
+ var rootURL = property_get.get(this, "rootURL");
+ var location = property_get.get(this, "location");
var path = location.pathname;
- var baseURL = property_get.get(this, 'baseURL');
+ var baseURL = property_get.get(this, "baseURL");
- rootURL = rootURL.replace(/\/$/, '');
- baseURL = baseURL.replace(/\/$/, '');
+ rootURL = rootURL.replace(/\/$/, "");
+ baseURL = baseURL.replace(/\/$/, "");
- var url = path.replace(baseURL, '').replace(rootURL, '');
- var search = location.search || '';
+ var url = path.replace(baseURL, "").replace(rootURL, "");
+ var search = location.search || "";
url += search;
url += this.getHash();
return url;
@@ -20301,11 +21760,11 @@
@method getState
@return state {Object}
*/
getState: function () {
if (this.supportsHistory) {
- return property_get.get(this, 'history').state;
+ return property_get.get(this, "history").state;
}
return this._historyState;
},
@@ -20316,11 +21775,11 @@
@param path {String}
*/
pushState: function (path) {
var state = { path: path };
- property_get.get(this, 'history').pushState(state, null, path);
+ property_get.get(this, "history").pushState(state, null, path);
this._historyState = state;
// used for webkit workaround
this._previousURL = this.getURL();
@@ -20332,11 +21791,11 @@
@method replaceState
@param path {String}
*/
replaceState: function (path) {
var state = { path: path };
- property_get.get(this, 'history').replaceState(state, null, path);
+ property_get.get(this, "history").replaceState(state, null, path);
this._historyState = state;
// used for webkit workaround
this._previousURL = this.getURL();
@@ -20348,22 +21807,23 @@
@private
@method onUpdateURL
@param callback {Function}
*/
onUpdateURL: function (callback) {
+ var _this = this;
+
var guid = utils.guidFor(this);
- var self = this;
- jQuery['default'](window).on('popstate.ember-location-' + guid, function (e) {
+ jQuery['default'](window).on("popstate.ember-location-" + guid, function (e) {
// Ignore initial page load popstate event in Chrome
if (!popstateFired) {
popstateFired = true;
- if (self.getURL() === self._previousURL) {
+ if (_this.getURL() === _this._previousURL) {
return;
}
}
- callback(self.getURL());
+ callback(_this.getURL());
});
},
/**
Used when using `{{action}}` helper. The url is always appended to the rootURL.
@@ -20371,18 +21831,18 @@
@method formatURL
@param url {String}
@return formatted url {String}
*/
formatURL: function (url) {
- var rootURL = property_get.get(this, 'rootURL');
- var baseURL = property_get.get(this, 'baseURL');
+ var rootURL = property_get.get(this, "rootURL");
+ var baseURL = property_get.get(this, "baseURL");
- if (url !== '') {
- rootURL = rootURL.replace(/\/$/, '');
- baseURL = baseURL.replace(/\/$/, '');
+ if (url !== "") {
+ rootURL = rootURL.replace(/\/$/, "");
+ baseURL = baseURL.replace(/\/$/, "");
} else if (baseURL.match(/^\//) && rootURL.match(/^\//)) {
- baseURL = baseURL.replace(/\/$/, '');
+ baseURL = baseURL.replace(/\/$/, "");
}
return baseURL + rootURL + url;
},
@@ -20392,11 +21852,11 @@
@method willDestroy
*/
willDestroy: function () {
var guid = utils.guidFor(this);
- jQuery['default'](window).off('popstate.ember-location-' + guid);
+ jQuery['default'](window).off("popstate.ember-location-" + guid);
},
/**
@private
Returns normalized location.hash
@@ -20409,32 +21869,32 @@
enifed('ember-routing/location/none_location', ['exports', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-runtime/system/object'], function (exports, property_get, property_set, EmberObject) {
'use strict';
exports['default'] = EmberObject['default'].extend({
- implementation: 'none',
- path: '',
+ implementation: "none",
+ path: "",
/**
Returns the current path.
@private
@method getURL
@return {String} path
*/
getURL: function () {
- return property_get.get(this, 'path');
+ return property_get.get(this, "path");
},
/**
Set the path and remembers what was set. Using this method
to change the path will not invoke the `updateURL` callback.
@private
@method setURL
@param path {String}
*/
setURL: function (path) {
- property_set.set(this, 'path', path);
+ property_set.set(this, "path", path);
},
/**
Register a callback to be invoked when the path changes. These
callbacks will execute when the user presses the back or forward
@@ -20452,11 +21912,11 @@
@private
@method handleURL
@param callback {Function}
*/
handleURL: function (url) {
- property_set.set(this, 'path', url);
+ property_set.set(this, "path", url);
this.updateCallback(url);
},
/**
Given a URL, formats it to be placed into the page as part
@@ -20488,41 +21948,29 @@
exports.getOrigin = getOrigin;
exports.supportsHashChange = supportsHashChange;
exports.supportsHistory = supportsHistory;
exports.replacePath = replacePath;
+ /**
+ @private
+
+ Returns the current `location.pathname`, normalized for IE inconsistencies.
+ */
function getPath(location) {
var pathname = location.pathname;
// Various versions of IE/Opera don't always return a leading slash
if (pathname.charAt(0) !== '/') {
pathname = '/' + pathname;
}
return pathname;
}
- /**
- @private
-
- Returns the current `location.search`.
- */
-
function getQuery(location) {
return location.search;
}
- /**
- @private
-
- Returns the current `location.hash` by parsing location.href since browsers
- inconsistently URL-decode `location.hash`.
-
- Should be passed the browser's `location` object as the first argument.
-
- https://bugzilla.mozilla.org/show_bug.cgi?id=483304
- */
-
function getHash(location) {
var href = location.href;
var hashIndex = href.indexOf('#');
if (hashIndex === -1) {
@@ -20549,34 +21997,14 @@
}
return origin;
}
- /*
- `documentMode` only exist in Internet Explorer, and it's tested because IE8 running in
- IE7 compatibility mode claims to support `onhashchange` but actually does not.
-
- `global` is an object that may have an `onhashchange` property.
-
- @private
- @function supportsHashChange
- */
-
function supportsHashChange(documentMode, global) {
return 'onhashchange' in global && (documentMode === undefined || documentMode > 7);
}
- /*
- `userAgent` is a user agent string. We use user agent testing here, because
- the stock Android browser in Gingerbread has a buggy versions of this API,
- Before feature detecting, we blacklist a browser identifying as both Android 2
- and Mobile Safari, but not Chrome.
-
- @private
- @function supportsHistory
- */
-
function supportsHistory(userAgent, history) {
// Boosted from Modernizr: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js
// The stock browser on Android 2.2 & 2.3 returns positive on history support
// Unfortunately support is really buggy and there is no clean way to detect
// these bugs, so we fall back to a user agent sniff :(
@@ -20588,22 +22016,105 @@
}
return !!(history && 'pushState' in history);
}
- /**
- Replaces the current location, making sure we explicitly include the origin
- to prevent redirecting to a different origin.
-
- @private
- */
-
function replacePath(location, path) {
location.replace(getOrigin(location) + path);
}
});
+enifed('ember-routing/services/routing', ['exports', 'ember-runtime/system/service', 'ember-metal/property_get', 'ember-metal/computed_macros', 'ember-routing/utils', 'ember-metal/keys', 'ember-metal/merge'], function (exports, Service, property_get, computed_macros, utils, keys, merge) {
+
+ 'use strict';
+
+ /**
+ @module ember
+ @submodule ember-routing
+ */
+
+ var RoutingService = Service['default'].extend({
+ router: null,
+
+ targetState: computed_macros.readOnly("router.targetState"),
+ currentState: computed_macros.readOnly("router.currentState"),
+ currentRouteName: computed_macros.readOnly("router.currentRouteName"),
+
+ availableRoutes: function () {
+ return keys['default'](property_get.get(this, "router").router.recognizer.names);
+ },
+
+ hasRoute: function (routeName) {
+ return property_get.get(this, "router").hasRoute(routeName);
+ },
+
+ transitionTo: function (routeName, models, queryParams, shouldReplace) {
+ var router = property_get.get(this, "router");
+
+ var transition = router._doTransition(routeName, models, queryParams);
+
+ if (shouldReplace) {
+ transition.method("replace");
+ }
+ },
+
+ normalizeQueryParams: function (routeName, models, queryParams) {
+ property_get.get(this, "router")._prepareQueryParams(routeName, models, queryParams);
+ },
+
+ generateURL: function (routeName, models, queryParams) {
+ var router = property_get.get(this, "router");
+
+ var visibleQueryParams = {};
+ merge['default'](visibleQueryParams, queryParams);
+
+ this.normalizeQueryParams(routeName, models, visibleQueryParams);
+
+ var args = utils.routeArgs(routeName, models, visibleQueryParams);
+ return router.generate.apply(router, args);
+ },
+
+ isActiveForRoute: function (contexts, queryParams, routeName, routerState, isCurrentWhenSpecified) {
+ var router = property_get.get(this, "router");
+
+ var handlers = router.router.recognizer.handlersFor(routeName);
+ var leafName = handlers[handlers.length - 1].handler;
+ var maximumContexts = numberOfContextsAcceptedByHandler(routeName, handlers);
+
+ // NOTE: any ugliness in the calculation of activeness is largely
+ // due to the fact that we support automatic normalizing of
+ // `resource` -> `resource.index`, even though there might be
+ // dynamic segments / query params defined on `resource.index`
+ // which complicates (and makes somewhat ambiguous) the calculation
+ // of activeness for links that link to `resource` instead of
+ // directly to `resource.index`.
+
+ // if we don't have enough contexts revert back to full route name
+ // this is because the leaf route will use one of the contexts
+ if (contexts.length > maximumContexts) {
+ routeName = leafName;
+ }
+
+ return routerState.isActiveIntent(routeName, contexts, queryParams, !isCurrentWhenSpecified);
+ }
+ });
+
+ var numberOfContextsAcceptedByHandler = function (handler, handlerInfos) {
+ var req = 0;
+ for (var i = 0, l = handlerInfos.length; i < l; i++) {
+ req = req + handlerInfos[i].names.length;
+ if (handlerInfos[i].handler === handler) {
+ break;
+ }
+ }
+
+ return req;
+ };
+
+ exports['default'] = RoutingService;
+
+});
enifed('ember-routing/system/cache', ['exports', 'ember-runtime/system/object'], function (exports, EmberObject) {
'use strict';
exports['default'] = EmberObject['default'].extend({
@@ -20638,12 +22149,10 @@
});
enifed('ember-routing/system/controller_for', ['exports'], function (exports) {
'use strict';
-
- exports['default'] = controllerFor;
/**
@module ember
@submodule ember-routing
*/
@@ -20653,12 +22162,14 @@
@for Ember
@method controllerFor
@private
*/
+ exports['default'] = controllerFor;
+
function controllerFor(container, controllerName, lookupOptions) {
- return container.lookup('controller:' + controllerName, lookupOptions);
+ return container.lookup("controller:" + controllerName, lookupOptions);
}
});
enifed('ember-routing/system/dsl', ['exports', 'ember-metal/core', 'ember-metal/array'], function (exports, Ember, array) {
@@ -20671,63 +22182,64 @@
}
exports['default'] = DSL;
DSL.prototype = {
route: function (name, options, callback) {
- if (arguments.length === 2 && typeof options === 'function') {
+ var dummyErrorRoute = "/_unused_dummy_error_path_route_" + name + "/:error";
+ if (arguments.length === 2 && typeof options === "function") {
callback = options;
options = {};
}
if (arguments.length === 1) {
options = {};
}
- var type = options.resetNamespace === true ? 'resource' : 'route';
+ var type = options.resetNamespace === true ? "resource" : "route";
Ember['default'].assert("'" + name + "' cannot be used as a " + type + " name.", (function () {
if (options.overrideNameAssertion === true) {
return true;
}
- return array.indexOf.call(['array', 'basic', 'object', 'application'], name) === -1;
+ return array.indexOf.call(["array", "basic", "object", "application"], name) === -1;
})());
if (this.enableLoadingSubstates) {
- createRoute(this, name + '_loading', { resetNamespace: options.resetNamespace });
- createRoute(this, name + '_error', { path: "/_unused_dummy_error_path_route_" + name + "/:error" });
+ createRoute(this, "" + name + "_loading", { resetNamespace: options.resetNamespace });
+ createRoute(this, "" + name + "_error", { path: dummyErrorRoute });
}
if (callback) {
var fullName = getFullName(this, name, options.resetNamespace);
var dsl = new DSL(fullName, {
enableLoadingSubstates: this.enableLoadingSubstates
});
- createRoute(dsl, 'loading');
- createRoute(dsl, 'error', { path: "/_unused_dummy_error_path_route_" + name + "/:error" });
+ createRoute(dsl, "loading");
+ createRoute(dsl, "error", { path: dummyErrorRoute });
callback.call(dsl);
createRoute(this, name, options, dsl.generate());
} else {
createRoute(this, name, options);
}
},
push: function (url, name, callback) {
- var parts = name.split('.');
+ var parts = name.split(".");
if (url === "" || url === "/" || parts[parts.length - 1] === "index") {
this.explicitIndex = true;
}
this.matches.push([url, name, callback]);
},
resource: function (name, options, callback) {
- if (arguments.length === 2 && typeof options === 'function') {
+ if (arguments.length === 2 && typeof options === "function") {
callback = options;
options = {};
}
if (arguments.length === 1) {
@@ -20753,27 +22265,27 @@
};
}
};
function canNest(dsl) {
- return dsl.parent && dsl.parent !== 'application';
+ return dsl.parent && dsl.parent !== "application";
}
function getFullName(dsl, name, resetNamespace) {
if (canNest(dsl) && resetNamespace !== true) {
- return dsl.parent + "." + name;
+ return "" + dsl.parent + "." + name;
} else {
return name;
}
}
function createRoute(dsl, name, options, callback) {
options = options || {};
var fullName = getFullName(dsl, name, options.resetNamespace);
- if (typeof options.path !== 'string') {
+ if (typeof options.path !== "string") {
options.path = "/" + name;
}
dsl.push(options.path, fullName, callback);
}
@@ -20783,63 +22295,71 @@
callback.call(dsl);
return dsl;
};
});
-enifed('ember-routing/system/generate_controller', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/utils'], function (exports, Ember, property_get, utils) {
+enifed('ember-routing/system/generate_controller', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-runtime/utils'], function (exports, Ember, property_get, utils) {
'use strict';
exports.generateControllerFactory = generateControllerFactory;
+ /**
+ @module ember
+ @submodule ember-routing
+ */
+
+ /**
+ Generates a controller factory
+
+ The type of the generated controller factory is derived
+ from the context. If the context is an array an array controller
+ is generated, if an object, an object controller otherwise, a basic
+ controller is generated.
+
+ You can customize your generated controllers by defining
+ `App.ObjectController` or `App.ArrayController`.
+
+ @for Ember
+ @method generateControllerFactory
+ @private
+ */
+
exports['default'] = generateController;
function generateControllerFactory(container, controllerName, context) {
var Factory, fullName, factoryName, controllerType;
if (context && utils.isArray(context)) {
- controllerType = 'array';
+ controllerType = "array";
} else if (context) {
- controllerType = 'object';
+ controllerType = "object";
} else {
- controllerType = 'basic';
+ controllerType = "basic";
}
- factoryName = 'controller:' + controllerType;
+ factoryName = "controller:" + controllerType;
Factory = container.lookupFactory(factoryName).extend({
isGenerated: true,
toString: function () {
return "(generated " + controllerName + " controller)";
}
});
- fullName = 'controller:' + controllerName;
+ fullName = "controller:" + controllerName;
container._registry.register(fullName, Factory);
return Factory;
}
- /**
- Generates and instantiates a controller.
-
- The type of the generated controller factory is derived
- from the context. If the context is an array an array controller
- is generated, if an object, an object controller otherwise, a basic
- controller is generated.
-
- @for Ember
- @method generateController
- @private
- @since 1.3.0
- */
function generateController(container, controllerName, context) {
generateControllerFactory(container, controllerName, context);
- var fullName = 'controller:' + controllerName;
+ var fullName = "controller:" + controllerName;
var instance = container.lookup(fullName);
- if (property_get.get(instance, 'namespace.LOG_ACTIVE_GENERATION')) {
+ if (property_get.get(instance, "namespace.LOG_ACTIVE_GENERATION")) {
Ember['default'].Logger.info("generated -> " + fullName, { fullName: fullName });
}
return instance;
}
@@ -20853,11 +22373,11 @@
isQueryParams: true,
values: null
});
});
-enifed('ember-routing/system/route', ['exports', 'ember-metal/core', 'ember-metal/error', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/get_properties', 'ember-metal/enumerable_utils', 'ember-metal/is_none', 'ember-metal/computed', 'ember-metal/merge', 'ember-metal/utils', 'ember-metal/run_loop', 'ember-metal/keys', 'ember-runtime/copy', 'ember-runtime/system/string', 'ember-runtime/system/object', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/action_handler', 'ember-routing/system/generate_controller', 'ember-routing/utils'], function (exports, Ember, EmberError, property_get, property_set, getProperties, enumerable_utils, isNone, computed, merge, utils, run, keys, copy, string, EmberObject, Evented, ActionHandler, generateController, ember_routing__utils) {
+enifed('ember-routing/system/route', ['exports', 'ember-metal/core', 'ember-metal/error', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/get_properties', 'ember-metal/enumerable_utils', 'ember-metal/is_none', 'ember-metal/computed', 'ember-metal/merge', 'ember-runtime/utils', 'ember-metal/run_loop', 'ember-metal/keys', 'ember-runtime/copy', 'ember-runtime/system/string', 'ember-runtime/system/object', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/action_handler', 'ember-routing/system/generate_controller', 'ember-routing/utils'], function (exports, Ember, EmberError, property_get, property_set, getProperties, enumerable_utils, isNone, computed, merge, utils, run, keys, copy, string, EmberObject, Evented, ActionHandler, generateController, ember_routing__utils) {
'use strict';
var slice = Array.prototype.slice;
@@ -20923,24 +22443,25 @@
/**
@private
@property _qp
*/
_qp: computed.computed(function () {
+ var _this = this;
+
var controllerName = this.controllerName || this.routeName;
- var controllerClass = this.container.lookupFactory('controller:' + controllerName);
+ var controllerClass = this.container.lookupFactory("controller:" + controllerName);
if (!controllerClass) {
return defaultQPMeta;
}
var controllerProto = controllerClass.proto();
- var qpProps = property_get.get(controllerProto, '_normalizedQueryParams');
- var cacheMeta = property_get.get(controllerProto, '_cacheMeta');
+ var qpProps = property_get.get(controllerProto, "_normalizedQueryParams");
+ var cacheMeta = property_get.get(controllerProto, "_cacheMeta");
var qps = [];
var map = {};
- var self = this;
for (var propName in qpProps) {
if (!qpProps.hasOwnProperty(propName)) {
continue;
}
@@ -20952,11 +22473,11 @@
defaultValue = Ember['default'].A(defaultValue.slice());
}
var type = utils.typeOf(defaultValue);
var defaultValueSerialized = this.serializeQueryParam(defaultValue, urlKey, type);
- var fprop = controllerName + ':' + propName;
+ var fprop = "" + controllerName + ":" + propName;
var qp = {
def: defaultValue,
sdef: defaultValueSerialized,
type: type,
urlKey: urlKey,
@@ -20977,17 +22498,14 @@
return {
qps: qps,
map: map,
states: {
active: function (controller, prop) {
- return self._activeQPChanged(controller, map[prop]);
+ return _this._activeQPChanged(controller, map[prop]);
},
allowOverrides: function (controller, prop) {
- return self._updatingQPChanged(controller, map[prop]);
- },
- changingKeys: function (controller, prop) {
- return self._updateSerializedQPValue(controller, map[prop]);
+ return _this._updatingQPChanged(controller, map[prop]);
}
}
};
}),
@@ -21011,22 +22529,22 @@
if (!names.length) {
handlerInfo = dynamicParent;
names = handlerInfo && handlerInfo._names || [];
}
- var qps = property_get.get(this, '_qp.qps');
+ var qps = property_get.get(this, "_qp.qps");
var len = qps.length;
var namePaths = new Array(names.length);
for (var a = 0, nlen = names.length; a < nlen; ++a) {
- namePaths[a] = handlerInfo.name + '.' + names[a];
+ namePaths[a] = "" + handlerInfo.name + "." + names[a];
}
for (var i = 0; i < len; ++i) {
var qp = qps[i];
var cacheMeta = qp.cacheMeta;
- if (cacheMeta.scope === 'model') {
+ if (cacheMeta.scope === "model") {
cacheMeta.parts = namePaths;
}
cacheMeta.prefix = qp.ctrl;
}
},
@@ -21060,20 +22578,20 @@
router._qpUpdates = {};
}
router._qpUpdates[qp.urlKey] = true;
},
- mergedProperties: ['events', 'queryParams'],
+ mergedProperties: ["events", "queryParams"],
/**
Retrieves parameters, for current route using the state.params
variable and getQueryParamsFor, using the supplied routeName.
@method paramsFor
@param {String} name
*/
paramsFor: function (name) {
- var route = this.container.lookup('route:' + name);
+ var route = this.container.lookup("route:" + name);
if (!route) {
return {};
}
@@ -21105,14 +22623,14 @@
*/
serializeQueryParam: function (value, urlKey, defaultValueType) {
// urlKey isn't used here, but anyone overriding
// can use it to provide serialization specific
// to a certain query param.
- if (defaultValueType === 'array') {
+ if (defaultValueType === "array") {
return JSON.stringify(value);
}
- return '' + value;
+ return "" + value;
},
/**
Deserializes value of the query parameter based on defaultValueType
@method deserializeQueryParam
@@ -21125,15 +22643,15 @@
// can use it to provide deserialization specific
// to a certain query param.
// Use the defaultValueType of the default value (the initial value assigned to a
// controller query param property), to intelligently deserialize and cast.
- if (defaultValueType === 'boolean') {
- return value === 'true' ? true : false;
- } else if (defaultValueType === 'number') {
+ if (defaultValueType === "boolean") {
+ return value === "true" ? true : false;
+ } else if (defaultValueType === "number") {
return Number(value).valueOf();
- } else if (defaultValueType === 'array') {
+ } else if (defaultValueType === "array") {
return Ember['default'].A(JSON.parse(value));
}
return value;
},
@@ -21149,11 +22667,11 @@
/**
@private
@property _optionsForQueryParam
*/
_optionsForQueryParam: function (qp) {
- return property_get.get(this, 'queryParams.' + qp.urlKey) || property_get.get(this, 'queryParams.' + qp.prop) || {};
+ return property_get.get(this, "queryParams." + qp.urlKey) || property_get.get(this, "queryParams." + qp.prop) || {};
},
/**
A hook you can use to reset controller values either when the model
changes or the route is exiting.
@@ -21179,11 +22697,11 @@
@private
@method exit
*/
exit: function () {
this.deactivate();
- this.trigger('deactivate');
+ this.trigger("deactivate");
this.teardownViews();
},
/**
@private
@@ -21191,11 +22709,11 @@
@since 1.7.0
*/
_reset: function (isExiting, transition) {
var controller = this.controller;
- controller._qpDelegate = property_get.get(this, '_qp.states.inactive');
+ controller._qpDelegate = null;
this.resetController(controller, isExiting, transition);
},
/**
@@ -21203,11 +22721,11 @@
@method enter
*/
enter: function () {
this.connections = [];
this.activate();
- this.trigger('activate');
+ this.trigger("activate");
},
/**
The name of the view to use by default when rendering this routes template.
When rendering a template, the route will, by default, determine the
@@ -21445,25 +22963,25 @@
*/
_actions: {
queryParamsDidChange: function (changed, totalPresent, removed) {
- var qpMap = property_get.get(this, '_qp').map;
+ var qpMap = property_get.get(this, "_qp").map;
var totalChanged = keys['default'](changed).concat(keys['default'](removed));
for (var i = 0, len = totalChanged.length; i < len; ++i) {
var qp = qpMap[totalChanged[i]];
- if (qp && property_get.get(this._optionsForQueryParam(qp), 'refreshModel')) {
+ if (qp && property_get.get(this._optionsForQueryParam(qp), "refreshModel")) {
this.refresh();
}
}
return true;
},
finalizeQueryParamChange: function (params, finalParams, transition) {
- if (this.routeName !== 'application') {
+ if (this.routeName !== "application") {
return true;
}
// Transition object is absent for intermediate transitions.
if (!transition) {
@@ -21501,17 +23019,17 @@
svalue = qp.sdef;
value = copyDefaultValue(qp.def);
}
}
- controller._qpDelegate = property_get.get(this, '_qp.states.inactive');
+ controller._qpDelegate = null;
var thisQueryParamChanged = svalue !== qp.svalue;
if (thisQueryParamChanged) {
if (transition.queryParamsOnly && replaceUrl !== false) {
var options = route._optionsForQueryParam(qp);
- var replaceConfigValue = property_get.get(options, 'replace');
+ var replaceConfigValue = property_get.get(options, "replace");
if (replaceConfigValue) {
replaceUrl = true;
} else if (replaceConfigValue === false) {
// Explicit pushState wins over any other replaceStates.
replaceUrl = false;
@@ -21533,17 +23051,17 @@
});
}
}
if (replaceUrl) {
- transition.method('replace');
+ transition.method("replace");
}
enumerable_utils.forEach(qpMeta.qps, function (qp) {
- var routeQpMeta = property_get.get(qp.route, '_qp');
+ var routeQpMeta = property_get.get(qp.route, "_qp");
var finalizedController = qp.route.controller;
- finalizedController._qpDelegate = property_get.get(routeQpMeta, 'states.active');
+ finalizedController._qpDelegate = property_get.get(routeQpMeta, "states.active");
});
router._qpUpdates = null;
}
},
@@ -21798,17 +23316,21 @@
@method send
@param {String} name the name of the action to trigger
@param {...*} args
*/
send: function () {
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
+ args[_key] = arguments[_key];
+ }
+
if (this.router || !Ember['default'].testing) {
var _router;
- (_router = this.router).send.apply(_router, arguments);
+ (_router = this.router).send.apply(_router, args);
} else {
- var name = arguments[0];
- var args = slice.call(arguments, 1);
+ var name = args[0];
+ args = slice.call(args, 1);
var action = this._actions[name];
if (action) {
return this._actions[name].apply(this, args);
}
}
@@ -21833,15 +23355,14 @@
if (this.setupControllers) {
Ember['default'].deprecate("Ember.Route.setupControllers is deprecated. Please use Ember.Route.setupController(controller, model) instead.");
this.setupControllers(controller, context);
} else {
- var states = property_get.get(this, '_qp.states');
+ var states = property_get.get(this, "_qp.states");
if (transition) {
// Update the model dep values used to calculate cache keys.
ember_routing__utils.stashParamNames(this.router, transition.state.handlerInfos);
- controller._qpDelegate = states.changingKeys;
controller._updateCacheParams(transition.params);
}
controller._qpDelegate = states.allowOverrides;
if (transition) {
@@ -22042,14 +23563,14 @@
will be used as the model for this route.
*/
model: function (params, transition) {
var match, name, sawParams, value;
- var queryParams = property_get.get(this, '_qp.map');
+ var queryParams = property_get.get(this, "_qp.map");
for (var prop in params) {
- if (prop === 'queryParams' || queryParams && prop in queryParams) {
+ if (prop === "queryParams" || queryParams && prop in queryParams) {
continue;
}
if (match = prop.match(/^(.*)_id$/)) {
name = match[1];
@@ -22089,11 +23610,11 @@
@method findModel
@param {String} type the model type
@param {Object} value the value passed to find
*/
findModel: function () {
- var store = property_get.get(this, 'store');
+ var store = property_get.get(this, "store");
return store.find.apply(store, arguments);
},
/**
Store property provides a hook for data persistence libraries to inject themselves.
@@ -22105,23 +23626,23 @@
@param {Object} store
*/
store: computed.computed(function () {
var container = this.container;
var routeName = this.routeName;
- var namespace = property_get.get(this, 'router.namespace');
+ var namespace = property_get.get(this, "router.namespace");
return {
find: function (name, value) {
- var modelClass = container.lookupFactory('model:' + name);
+ var modelClass = container.lookupFactory("model:" + name);
- Ember['default'].assert("You used the dynamic segment " + name + "_id in your route " + routeName + ", but " + namespace + "." + string.classify(name) + " did not exist and you did not override your route's `model` " + "hook.", !!modelClass);
+ Ember['default'].assert("You used the dynamic segment " + name + "_id in your route " + routeName + ", but " + namespace + "." + string.classify(name) + " did not exist and you did not override your route's `model` hook.", !!modelClass);
if (!modelClass) {
return;
}
- Ember['default'].assert(string.classify(name) + ' has no method `find`.', typeof modelClass.find === 'function');
+ Ember['default'].assert("" + string.classify(name) + " has no method `find`.", typeof modelClass.find === "function");
return modelClass.find(value);
}
};
}),
@@ -22233,11 +23754,11 @@
@param {Controller} controller instance
@param {Object} model
*/
setupController: function (controller, context, transition) {
if (controller && context !== undefined) {
- property_set.set(controller, 'model', context);
+ property_set.set(controller, "model", context);
}
},
/**
Returns the controller for a particular route or name.
@@ -22255,23 +23776,23 @@
@param {String} name the name of the route or controller
@return {Ember.Controller}
*/
controllerFor: function (name, _skipAssert) {
var container = this.container;
- var route = container.lookup('route:' + name);
+ var route = container.lookup("route:" + name);
var controller;
if (route && route.controllerName) {
name = route.controllerName;
}
- controller = container.lookup('controller:' + name);
+ controller = container.lookup("controller:" + name);
// NOTE: We're specifically checking that skipAssert is true, because according
// to the old API the second parameter was model. We do not want people who
// passed a model to skip the assertion.
- Ember['default'].assert("The controller named '" + name + "' could not be found. Make sure " + "that this route exists and has already been entered at least " + "once. If you are accessing a controller not associated with a " + "route, make sure the controller class is explicitly defined.", controller || _skipAssert === true);
+ Ember['default'].assert("The controller named '" + name + "' could not be found. Make sure that this route exists and has already been entered at least once. If you are accessing a controller not associated with a route, make sure the controller class is explicitly defined.", controller || _skipAssert === true);
return controller;
},
/**
@@ -22323,11 +23844,11 @@
@method modelFor
@param {String} name the name of the route
@return {Object} the model object
*/
modelFor: function (name) {
- var route = this.container.lookup('route:' + name);
+ var route = this.container.lookup("route:" + name);
var transition = this.router ? this.router.router.activeTransition : null;
// If we are mid-transition, we want to try and look up
// resolved parent contexts on the current transitionEvent.
if (transition) {
@@ -22469,24 +23990,24 @@
Defaults to the return value of the Route's model hook
*/
render: function (_name, options) {
Ember['default'].assert("The name in the given arguments is undefined", arguments.length > 0 ? !isNone['default'](arguments[0]) : true);
- var namePassed = typeof _name === 'string' && !!_name;
+ var namePassed = typeof _name === "string" && !!_name;
var isDefaultRender = arguments.length === 0 || Ember['default'].isEmpty(arguments[0]);
var name;
- if (typeof _name === 'object' && !options) {
+ if (typeof _name === "object" && !options) {
name = this.routeName;
options = _name;
} else {
name = _name;
}
var renderOptions = buildRenderOptions(this, namePassed, isDefaultRender, name, options);
this.connections.push(renderOptions);
- run['default'].once(this.router, '_setOutlets');
+ run['default'].once(this.router, "_setOutlets");
},
/**
Disconnects a view that has been rendered into an outlet.
You may pass any or all of the following options to `disconnectOutlet`:
@@ -22529,12 +24050,12 @@
outletName = options;
} else {
outletName = options.outlet;
parentView = options.parentView;
}
- parentView = parentView && parentView.replace(/\//g, '.');
- outletName = outletName || 'main';
+ parentView = parentView && parentView.replace(/\//g, ".");
+ outletName = outletName || "main";
this._disconnectOutlet(outletName, parentView);
for (var i = 0; i < this.router.router.currentHandlerInfos.length; i++) {
// This non-local state munging is sadly necessary to maintain
// backward compatibility with our existing semantics, which allow
// any route to disconnectOutlet things originally rendered by any
@@ -22560,11 +24081,11 @@
this.connections[i] = {
into: connection.into,
outlet: connection.outlet,
name: connection.name
};
- run['default'].once(this.router, '_setOutlets');
+ run['default'].once(this.router, "_setOutlets");
}
}
},
willDestroy: function () {
@@ -22576,11 +24097,11 @@
@method teardownViews
*/
teardownViews: function () {
if (this.connections && this.connections.length > 0) {
this.connections = [];
- run['default'].once(this.router, '_setOutlets');
+ run['default'].once(this.router, "_setOutlets");
}
}
});
var defaultQPMeta = {
@@ -22613,49 +24134,50 @@
var controller = options && options.controller;
var templateName;
var viewName;
var ViewClass;
var template;
- var LOG_VIEW_LOOKUPS = property_get.get(route.router, 'namespace.LOG_VIEW_LOOKUPS');
- var into = options && options.into && options.into.replace(/\//g, '.');
- var outlet = options && options.outlet || 'main';
+ var LOG_VIEW_LOOKUPS = property_get.get(route.router, "namespace.LOG_VIEW_LOOKUPS");
+ var into = options && options.into && options.into.replace(/\//g, ".");
+ var outlet = options && options.outlet || "main";
if (name) {
- name = name.replace(/\//g, '.');
+ name = name.replace(/\//g, ".");
templateName = name;
} else {
name = route.routeName;
templateName = route.templateName || name;
}
if (!controller) {
if (namePassed) {
- controller = route.container.lookup('controller:' + name) || route.controllerName || route.routeName;
+ controller = route.container.lookup("controller:" + name) || route.controllerName || route.routeName;
} else {
- controller = route.controllerName || route.container.lookup('controller:' + name);
+ controller = route.controllerName || route.container.lookup("controller:" + name);
}
}
- if (typeof controller === 'string') {
+ if (typeof controller === "string") {
var controllerName = controller;
- controller = route.container.lookup('controller:' + controllerName);
+ controller = route.container.lookup("controller:" + controllerName);
if (!controller) {
throw new EmberError['default']("You passed `controller: '" + controllerName + "'` into the `render` method, but no such controller could be found.");
}
}
if (options && options.model) {
- controller.set('model', options.model);
+ controller.set("model", options.model);
}
viewName = options && options.view || namePassed && name || route.viewName || name;
- ViewClass = route.container.lookupFactory('view:' + viewName);
- template = route.container.lookup('template:' + templateName);
+ ViewClass = route.container.lookupFactory("view:" + viewName);
+ template = route.container.lookup("template:" + templateName);
if (!ViewClass && !template) {
Ember['default'].assert("Could not find \"" + name + "\" template or view.", isDefaultRender);
if (LOG_VIEW_LOOKUPS) {
- Ember['default'].Logger.info("Could not find \"" + name + "\" template or view. Nothing will be rendered", { fullName: 'template:' + name });
+ var fullName = "template:" + name;
+ Ember['default'].Logger.info("Could not find \"" + name + "\" template or view. Nothing will be rendered", { fullName: fullName });
}
}
var parent;
if (into && (parent = parentRoute(route)) && into === parentRoute(route).routeName) {
@@ -22698,11 +24220,11 @@
var fullQueryParams = getFullQueryParams(route.router, state);
var params = state.queryParamsFor[name] = {};
// Copy over all the query params for this route/controller into params hash.
- var qpMeta = property_get.get(route, '_qp');
+ var qpMeta = property_get.get(route, "_qp");
var qps = qpMeta.qps;
for (var i = 0, len = qps.length; i < len; ++i) {
// Put deserialized qp on params hash.
var qp = qps[i];
@@ -22753,19 +24275,19 @@
* `none`
@property location
@default 'hash'
@see {Ember.Location}
*/
- location: 'hash',
+ location: "hash",
/**
Represents the URL of the root of the application, often '/'. This prefix is
assumed on all routes defined on this router.
@property rootURL
@default '/'
*/
- rootURL: '/',
+ rootURL: "/",
_initRouterJs: function (moduleBasedResolver) {
var router = this.router = new Router['default']();
router.triggerEvent = triggerEvent;
@@ -22776,20 +24298,20 @@
var dsl = new EmberRouterDSL['default'](null, {
enableLoadingSubstates: !!moduleBasedResolver
});
function generateDSL() {
- this.resource('application', { path: "/", overrideNameAssertion: true }, function () {
+ this.resource("application", { path: "/", overrideNameAssertion: true }, function () {
for (var i = 0; i < dslCallbacks.length; i++) {
dslCallbacks[i].call(this);
}
});
}
generateDSL.call(dsl);
- if (property_get.get(this, 'namespace.LOG_TRANSITIONS_INTERNAL')) {
+ if (property_get.get(this, "namespace.LOG_TRANSITIONS_INTERNAL")) {
router.log = Ember['default'].Logger.debug;
}
router.map(dsl.generate());
},
@@ -22804,11 +24326,11 @@
Represents the current URL.
@method url
@return {String} The current URL.
*/
url: computed.computed(function () {
- return property_get.get(this, 'location').getURL();
+ return property_get.get(this, "location").getURL();
}),
/**
Initializes the current router instance and sets up the change handling
event listeners used by the instances `location` implementation.
@@ -22816,41 +24338,42 @@
If no value is found `/` will be used.
@method startRouting
@private
*/
startRouting: function (moduleBasedResolver) {
- var initialURL = property_get.get(this, 'initialURL');
+ var initialURL = property_get.get(this, "initialURL");
if (this.setupRouter(moduleBasedResolver)) {
if (typeof initialURL === "undefined") {
- initialURL = property_get.get(this, 'location').getURL();
+ initialURL = property_get.get(this, "location").getURL();
}
var initialTransition = this.handleURL(initialURL);
if (initialTransition && initialTransition.error) {
throw initialTransition.error;
}
}
},
setupRouter: function (moduleBasedResolver) {
+ var _this = this;
+
this._initRouterJs(moduleBasedResolver);
this._setupLocation();
var router = this.router;
- var location = property_get.get(this, 'location');
- var self = this;
+ var location = property_get.get(this, "location");
// Allow the Location class to cancel the router setup while it refreshes
// the page
- if (property_get.get(location, 'cancelRouterSetup')) {
+ if (property_get.get(location, "cancelRouterSetup")) {
return false;
}
this._setupRouter(router, location);
location.onUpdateURL(function (url) {
- self.handleURL(url);
+ _this.handleURL(url);
});
return true;
},
@@ -22865,18 +24388,18 @@
didTransition: function (infos) {
updatePaths(this);
this._cancelSlowTransitionTimer();
- this.notifyPropertyChange('url');
- this.set('currentState', this.targetState);
+ this.notifyPropertyChange("url");
+ this.set("currentState", this.targetState);
// Put this in the runloop so url will be accurate. Seems
// less surprising than didTransition being out of sync.
- run['default'].once(this, this.trigger, 'didTransition');
+ run['default'].once(this, this.trigger, "didTransition");
- if (property_get.get(this, 'namespace').LOG_TRANSITIONS) {
+ if (property_get.get(this, "namespace").LOG_TRANSITIONS) {
Ember['default'].Logger.log("Transitioned into '" + EmberRouter._routePath(infos) + "'");
}
},
_setOutlets: function () {
@@ -22894,23 +24417,23 @@
var connections = route.connections;
var ownState;
for (var j = 0; j < connections.length; j++) {
var appended = appendLiveRoute(liveRoutes, defaultParentState, connections[j]);
liveRoutes = appended.liveRoutes;
- if (appended.ownState.render.name === route.routeName || appended.ownState.render.outlet === 'main') {
+ if (appended.ownState.render.name === route.routeName || appended.ownState.render.outlet === "main") {
ownState = appended.ownState;
}
}
if (connections.length === 0) {
ownState = representEmptyRoute(liveRoutes, defaultParentState, route);
}
defaultParentState = ownState;
}
if (!this._toplevelView) {
- var OutletView = this.container.lookupFactory('view:-outlet');
- this._toplevelView = OutletView.create({ _isTopLevel: true });
- var instance = this.container.lookup('-application-instance:main');
+ var OutletView = this.container.lookupFactory("view:-outlet");
+ this._toplevelView = OutletView.create();
+ var instance = this.container.lookup("-application-instance:main");
instance.didCreateRootView(this._toplevelView);
}
this._toplevelView.setOutletState(liveRoutes);
},
@@ -22921,43 +24444,42 @@
@method willTransition
@private
@since 1.11.0
*/
willTransition: function (oldInfos, newInfos, transition) {
- run['default'].once(this, this.trigger, 'willTransition', transition);
+ run['default'].once(this, this.trigger, "willTransition", transition);
- if (property_get.get(this, 'namespace').LOG_TRANSITIONS) {
- Ember['default'].Logger.log("Preparing to transition from '" + EmberRouter._routePath(oldInfos) + "' to '" + EmberRouter._routePath(newInfos) + "'");
+ if (property_get.get(this, "namespace").LOG_TRANSITIONS) {
+ Ember['default'].Logger.log("Preparing to transition from '" + EmberRouter._routePath(oldInfos) + "' to ' " + EmberRouter._routePath(newInfos) + "'");
}
},
handleURL: function (url) {
// Until we have an ember-idiomatic way of accessing #hashes, we need to
// remove it because router.js doesn't know how to handle it.
url = url.split(/#(.+)?/)[0];
- return this._doURLTransition('handleURL', url);
+ return this._doURLTransition("handleURL", url);
},
_doURLTransition: function (routerJsMethod, url) {
- var transition = this.router[routerJsMethod](url || '/');
+ var transition = this.router[routerJsMethod](url || "/");
didBeginTransition(transition, this);
return transition;
},
transitionTo: function () {
- var queryParams;
-
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
+ var queryParams;
if (resemblesURL(args[0])) {
- return this._doURLTransition('transitionTo', args[0]);
+ return this._doURLTransition("transitionTo", args[0]);
}
var possibleQueryParams = args[args.length - 1];
- if (possibleQueryParams && possibleQueryParams.hasOwnProperty('queryParams')) {
+ if (possibleQueryParams && possibleQueryParams.hasOwnProperty("queryParams")) {
queryParams = args.pop().queryParams;
} else {
queryParams = {};
}
@@ -22971,17 +24493,17 @@
(_router = this.router).intermediateTransitionTo.apply(_router, arguments);
updatePaths(this);
var infos = this.router.currentHandlerInfos;
- if (property_get.get(this, 'namespace').LOG_TRANSITIONS) {
+ if (property_get.get(this, "namespace").LOG_TRANSITIONS) {
Ember['default'].Logger.log("Intermediate-transitioned into '" + EmberRouter._routePath(infos) + "'");
}
},
replaceWith: function () {
- return this.transitionTo.apply(this, arguments).method('replace');
+ return this.transitionTo.apply(this, arguments).method("replace");
},
generate: function () {
var _router2;
@@ -23052,77 +24574,74 @@
}
this._super.apply(this, arguments);
this.reset();
},
- _lookupActiveView: function (templateName) {
- var active = this._activeViews[templateName];
- return active && active[0];
+ _lookupActiveComponentNode: function (templateName) {
+ return this._activeViews[templateName];
},
- _connectActiveView: function (templateName, view) {
- var existing = this._activeViews[templateName];
+ _connectActiveComponentNode: function (templateName, componentNode) {
+ Ember['default'].assert("cannot connect an activeView that already exists", !this._activeViews[templateName]);
- if (existing) {
- existing[0].off('willDestroyElement', this, existing[1]);
- }
-
+ var _activeViews = this._activeViews;
function disconnectActiveView() {
- delete this._activeViews[templateName];
+ delete _activeViews[templateName];
}
- this._activeViews[templateName] = [view, disconnectActiveView];
- view.one('willDestroyElement', this, disconnectActiveView);
+ this._activeViews[templateName] = componentNode;
+ componentNode.renderNode.addDestruction({ destroy: disconnectActiveView });
},
_setupLocation: function () {
- var location = property_get.get(this, 'location');
- var rootURL = property_get.get(this, 'rootURL');
+ var location = property_get.get(this, "location");
+ var rootURL = property_get.get(this, "rootURL");
- if ('string' === typeof location && this.container) {
- var resolvedLocation = this.container.lookup('location:' + location);
+ if ("string" === typeof location && this.container) {
+ var resolvedLocation = this.container.lookup("location:" + location);
- if ('undefined' !== typeof resolvedLocation) {
- location = property_set.set(this, 'location', resolvedLocation);
+ if ("undefined" !== typeof resolvedLocation) {
+ location = property_set.set(this, "location", resolvedLocation);
} else {
// Allow for deprecated registration of custom location API's
var options = {
implementation: location
};
- location = property_set.set(this, 'location', EmberLocation['default'].create(options));
+ location = property_set.set(this, "location", EmberLocation['default'].create(options));
}
}
- if (location !== null && typeof location === 'object') {
+ if (location !== null && typeof location === "object") {
if (rootURL) {
- property_set.set(location, 'rootURL', rootURL);
+ property_set.set(location, "rootURL", rootURL);
}
// Allow the location to do any feature detection, such as AutoLocation
// detecting history support. This gives it a chance to set its
// `cancelRouterSetup` property which aborts routing.
- if (typeof location.detect === 'function') {
+ if (typeof location.detect === "function") {
location.detect();
}
// ensure that initState is called AFTER the rootURL is set on
// the location instance
- if (typeof location.initState === 'function') {
+ if (typeof location.initState === "function") {
location.initState();
}
}
},
_getHandlerFunction: function () {
+ var _this2 = this;
+
var seen = create['default'](null);
var container = this.container;
- var DefaultRoute = container.lookupFactory('route:basic');
- var self = this;
+ var DefaultRoute = container.lookupFactory("route:basic");
return function (name) {
- var routeName = 'route:' + name;
+ var routeName = "route:" + name;
var handler = container.lookup(routeName);
if (seen[name]) {
return handler;
}
@@ -23131,11 +24650,11 @@
if (!handler) {
container._registry.register(routeName, DefaultRoute.extend());
handler = container.lookup(routeName);
- if (property_get.get(self, 'namespace.LOG_ACTIVE_GENERATION')) {
+ if (property_get.get(_this2, "namespace.LOG_ACTIVE_GENERATION")) {
Ember['default'].Logger.info("generated -> " + routeName, { fullName: routeName });
}
}
handler.routeName = name;
@@ -23262,11 +24781,11 @@
var recogHandlerInfos = routerjs.recognizer.handlersFor(leafRouteName);
for (var i = 0, len = recogHandlerInfos.length; i < len; ++i) {
var recogHandler = recogHandlerInfos[i];
var route = routerjs.getHandler(recogHandler.handler);
- var qpMeta = property_get.get(route, '_qp');
+ var qpMeta = property_get.get(route, "_qp");
if (!qpMeta) {
continue;
}
@@ -23304,11 +24823,11 @@
utils.stashParamNames(this, handlerInfos);
for (var i = 0, len = handlerInfos.length; i < len; ++i) {
var route = handlerInfos[i].handler;
- var qpMeta = property_get.get(route, '_qp');
+ var qpMeta = property_get.get(route, "_qp");
for (var j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) {
var qp = qpMeta.qps[j];
var presentProp = qp.prop in queryParams && qp.prop || qp.fprop in queryParams && qp.fprop;
@@ -23317,22 +24836,22 @@
queryParams[qp.fprop] = queryParams[presentProp];
delete queryParams[presentProp];
}
} else {
var controllerProto = qp.cProto;
- var cacheMeta = property_get.get(controllerProto, '_cacheMeta');
+ var cacheMeta = property_get.get(controllerProto, "_cacheMeta");
var cacheKey = controllerProto._calculateCacheKey(qp.ctrl, cacheMeta[qp.prop].parts, state.params);
queryParams[qp.fprop] = appCache.lookup(cacheKey, qp.prop, qp.def);
}
}
}
},
_scheduleLoadingEvent: function (transition, originRoute) {
this._cancelSlowTransitionTimer();
- this._slowTransitionTimer = run['default'].scheduleOnce('routerTransitions', this, '_handleSlowTransition', transition, originRoute);
+ this._slowTransitionTimer = run['default'].scheduleOnce("routerTransitions", this, "_handleSlowTransition", transition, originRoute);
},
currentState: null,
targetState: null,
@@ -23341,17 +24860,17 @@
// Don't fire an event if we've since moved on from
// the transition that put us in a loading state.
return;
}
- this.set('targetState', RouterState['default'].create({
+ this.set("targetState", RouterState['default'].create({
emberRouter: this,
routerJs: this.router,
routerJsState: this.router.activeTransition.state
}));
- transition.trigger(true, 'loading', transition, originRoute);
+ transition.trigger(true, "loading", transition, originRoute);
},
_cancelSlowTransitionTimer: function () {
if (this._slowTransitionTimer) {
run['default'].cancel(this._slowTransitionTimer);
@@ -23403,35 +24922,35 @@
error: function (error, transition, originRoute) {
// Attempt to find an appropriate error substate to enter.
var router = originRoute.router;
var tryTopLevel = forEachRouteAbove(originRoute, transition, function (route, childRoute) {
- var childErrorRouteName = findChildRouteName(route, childRoute, 'error');
+ var childErrorRouteName = findChildRouteName(route, childRoute, "error");
if (childErrorRouteName) {
router.intermediateTransitionTo(childErrorRouteName, error);
return;
}
return true;
});
if (tryTopLevel) {
// Check for top-level error state to enter.
- if (routeHasBeenDefined(originRoute.router, 'application_error')) {
- router.intermediateTransitionTo('application_error', error);
+ if (routeHasBeenDefined(originRoute.router, "application_error")) {
+ router.intermediateTransitionTo("application_error", error);
return;
}
}
- logError(error, 'Error while processing route: ' + transition.targetName);
+ logError(error, "Error while processing route: " + transition.targetName);
},
loading: function (transition, originRoute) {
// Attempt to find an appropriate loading substate to enter.
var router = originRoute.router;
var tryTopLevel = forEachRouteAbove(originRoute, transition, function (route, childRoute) {
- var childLoadingRouteName = findChildRouteName(route, childRoute, 'loading');
+ var childLoadingRouteName = findChildRouteName(route, childRoute, "loading");
if (childLoadingRouteName) {
router.intermediateTransitionTo(childLoadingRouteName);
return;
}
@@ -23442,22 +24961,22 @@
}
});
if (tryTopLevel) {
// Check for top-level loading state to enter.
- if (routeHasBeenDefined(originRoute.router, 'application_loading')) {
- router.intermediateTransitionTo('application_loading');
+ if (routeHasBeenDefined(originRoute.router, "application_loading")) {
+ router.intermediateTransitionTo("application_loading");
return;
}
}
}
};
function logError(_error, initialMessage) {
var errorArgs = [];
var error;
- if (_error && typeof _error === 'object' && typeof _error.errorThrown === 'object') {
+ if (_error && typeof _error === "object" && typeof _error.errorThrown === "object") {
error = _error.errorThrown;
} else {
error = _error;
}
@@ -23482,16 +25001,16 @@
}
function findChildRouteName(parentRoute, originatingChildRoute, name) {
var router = parentRoute.router;
var childName;
- var targetChildRouteName = originatingChildRoute.routeName.split('.').pop();
- var namespace = parentRoute.routeName === 'application' ? '' : parentRoute.routeName + '.';
+ var targetChildRouteName = originatingChildRoute.routeName.split(".").pop();
+ var namespace = parentRoute.routeName === "application" ? "" : parentRoute.routeName + ".";
// First, try a named loading state, e.g. 'foo_loading'
- childName = namespace + targetChildRouteName + '_' + name;
+ childName = namespace + targetChildRouteName + "_" + name;
if (routeHasBeenDefined(router, childName)) {
return childName;
}
@@ -23502,11 +25021,11 @@
}
}
function routeHasBeenDefined(router, name) {
var container = router.container;
- return router.hasRoute(name) && (container._registry.has('template:' + name) || container._registry.has('route:' + name));
+ return router.hasRoute(name) && (container._registry.has("template:" + name) || container._registry.has("route:" + name));
}
function triggerEvent(handlerInfos, ignoreFailure, args) {
var name = args.shift();
@@ -23558,11 +25077,11 @@
}
return state;
}
function updatePaths(router) {
- var appController = router.container.lookup('controller:application');
+ var appController = router.container.lookup("controller:application");
if (!appController) {
// appController might not exist when top-level loading/error
// substates have been entered since ApplicationRoute hasn't
// actually been entered at that point.
@@ -23570,21 +25089,23 @@
}
var infos = router.router.currentHandlerInfos;
var path = EmberRouter._routePath(infos);
- if (!('currentPath' in appController)) {
- properties.defineProperty(appController, 'currentPath');
+ if (!("currentPath" in appController)) {
+ properties.defineProperty(appController, "currentPath");
}
- property_set.set(appController, 'currentPath', path);
+ property_set.set(appController, "currentPath", path);
+ property_set.set(router, "currentPath", path);
- if (!('currentRouteName' in appController)) {
- properties.defineProperty(appController, 'currentRouteName');
+ if (!("currentRouteName" in appController)) {
+ properties.defineProperty(appController, "currentRouteName");
}
- property_set.set(appController, 'currentRouteName', infos[infos.length - 1].name);
+ property_set.set(appController, "currentRouteName", infos[infos.length - 1].name);
+ property_set.set(router, "currentRouteName", infos[infos.length - 1].name);
}
EmberRouter.reopenClass({
router: null,
@@ -23657,27 +25178,27 @@
routerJs: router.router,
routerJsState: transition.state
});
if (!router.currentState) {
- router.set('currentState', routerState);
+ router.set("currentState", routerState);
}
- router.set('targetState', routerState);
+ router.set("targetState", routerState);
transition.then(null, function (error) {
if (!error || !error.name) {
return;
}
Ember['default'].assert("The URL '" + error.message + "' did not match any routes in your application", error.name !== "UnrecognizedURLError");
return error;
- }, 'Ember: Process errors from Router');
+ }, "Ember: Process errors from Router");
}
function resemblesURL(str) {
- return typeof str === 'string' && (str === '' || str.charAt(0) === '/');
+ return typeof str === "string" && (str === "" || str.charAt(0) === "/");
}
function forEachQueryParam(router, targetRouteName, queryParams, callback) {
var qpCache = router._queryParamsFor(targetRouteName);
@@ -23745,17 +25266,17 @@
function appendOrphan(liveRoutes, into, myState) {
if (!liveRoutes.outlets.__ember_orphans__) {
liveRoutes.outlets.__ember_orphans__ = {
render: {
- name: '__ember_orphans__'
+ name: "__ember_orphans__"
},
outlets: create['default'](null)
};
}
liveRoutes.outlets.__ember_orphans__.outlets[into] = myState;
- Ember['default'].run.schedule('afterRender', function () {
+ Ember['default'].run.schedule("afterRender", function () {
// `wasUsed` gets set by the render helper. See the function
// `impersonateAnOutlet`.
Ember['default'].assert("You attempted to render into '" + into + "' but it was not found", liveRoutes.outlets.__ember_orphans__.outlets[into].wasUsed);
});
}
@@ -23773,11 +25294,11 @@
// just so other routes can target it and inherit its place
// in the outlet hierarchy.
defaultParentState.outlets.main = {
render: {
name: route.routeName,
- outlet: 'main'
+ outlet: "main"
},
outlets: {}
};
return defaultParentState;
}
@@ -23831,21 +25352,21 @@
}
exports['default'] = RouterState;
});
-enifed('ember-routing/utils', ['exports', 'ember-metal/utils'], function (exports, utils) {
+enifed('ember-routing/utils', ['exports'], function (exports) {
'use strict';
exports.routeArgs = routeArgs;
exports.getActiveTargetName = getActiveTargetName;
exports.stashParamNames = stashParamNames;
function routeArgs(targetRouteName, models, queryParams) {
var args = [];
- if (utils.typeOf(targetRouteName) === 'string') {
+ if (typeof targetRouteName === 'string') {
args.push('' + targetRouteName);
}
args.push.apply(args, models);
args.push({ queryParams: queryParams });
return args;
@@ -23885,11 +25406,11 @@
handlerInfos._namesStashed = true;
}
});
-enifed('ember-runtime', ['exports', 'ember-metal', 'ember-runtime/core', 'ember-runtime/compare', 'ember-runtime/copy', 'ember-runtime/inject', 'ember-runtime/system/namespace', 'ember-runtime/system/object', 'ember-runtime/system/tracked_array', 'ember-runtime/system/subarray', 'ember-runtime/system/container', 'ember-runtime/system/array_proxy', 'ember-runtime/system/object_proxy', 'ember-runtime/system/core_object', 'ember-runtime/system/native_array', 'ember-runtime/system/set', 'ember-runtime/system/string', 'ember-runtime/system/deferred', 'ember-runtime/system/lazy_load', 'ember-runtime/mixins/array', 'ember-runtime/mixins/comparable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/freezable', 'ember-runtime/mixins/-proxy', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/deferred', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/target_action_support', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/promise_proxy', 'ember-runtime/mixins/sortable', 'ember-runtime/computed/array_computed', 'ember-runtime/computed/reduce_computed', 'ember-runtime/computed/reduce_computed_macros', 'ember-runtime/controllers/array_controller', 'ember-runtime/controllers/object_controller', 'ember-runtime/controllers/controller', 'ember-runtime/mixins/controller', 'ember-runtime/system/service', 'ember-runtime/ext/rsvp', 'ember-runtime/ext/string', 'ember-runtime/ext/function'], function (exports, Ember, core, compare, copy, inject, Namespace, EmberObject, TrackedArray, SubArray, container, ArrayProxy, ObjectProxy, CoreObject, NativeArray, Set, EmberStringUtils, Deferred, lazy_load, EmberArray, Comparable, Copyable, Enumerable, freezable, _ProxyMixin, Observable, ActionHandler, DeferredMixin, MutableEnumerable, MutableArray, TargetActionSupport, Evented, PromiseProxyMixin, SortableMixin, array_computed, reduce_computed, reduce_computed_macros, ArrayController, ObjectController, Controller, ControllerMixin, Service, RSVP) {
+enifed('ember-runtime', ['exports', 'ember-metal', 'ember-runtime/core', 'ember-runtime/compare', 'ember-runtime/copy', 'ember-runtime/inject', 'ember-runtime/system/namespace', 'ember-runtime/system/object', 'ember-runtime/system/tracked_array', 'ember-runtime/system/subarray', 'ember-runtime/system/container', 'ember-runtime/system/array_proxy', 'ember-runtime/system/object_proxy', 'ember-runtime/system/core_object', 'ember-runtime/system/native_array', 'ember-runtime/system/set', 'ember-runtime/system/string', 'ember-runtime/system/deferred', 'ember-runtime/system/lazy_load', 'ember-runtime/mixins/array', 'ember-runtime/mixins/comparable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/freezable', 'ember-runtime/mixins/-proxy', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/deferred', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/target_action_support', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/promise_proxy', 'ember-runtime/mixins/sortable', 'ember-runtime/computed/array_computed', 'ember-runtime/computed/reduce_computed', 'ember-runtime/computed/reduce_computed_macros', 'ember-runtime/controllers/array_controller', 'ember-runtime/controllers/object_controller', 'ember-runtime/controllers/controller', 'ember-runtime/mixins/controller', 'ember-runtime/system/service', 'ember-runtime/ext/rsvp', 'ember-runtime/ext/string', 'ember-runtime/ext/function', 'ember-runtime/utils'], function (exports, Ember, core, compare, copy, inject, Namespace, EmberObject, TrackedArray, SubArray, container, ArrayProxy, ObjectProxy, CoreObject, NativeArray, Set, EmberStringUtils, Deferred, lazy_load, EmberArray, Comparable, Copyable, Enumerable, freezable, _ProxyMixin, Observable, ActionHandler, DeferredMixin, MutableEnumerable, MutableArray, TargetActionSupport, Evented, PromiseProxyMixin, SortableMixin, array_computed, reduce_computed, reduce_computed_macros, ArrayController, ObjectController, Controller, ControllerMixin, Service, RSVP, __dep42__, __dep43__, utils) {
'use strict';
/**
Ember Runtime
@@ -23931,10 +25452,13 @@
Ember['default'].arrayComputed = array_computed.arrayComputed;
Ember['default'].ArrayComputedProperty = array_computed.ArrayComputedProperty;
Ember['default'].reduceComputed = reduce_computed.reduceComputed;
Ember['default'].ReduceComputedProperty = reduce_computed.ReduceComputedProperty;
+ Ember['default'].typeOf = utils.typeOf;
+ Ember['default'].isArray = utils.isArray;
+
// ES6TODO: this seems a less than ideal way/place to add properties to Ember.computed
var EmComputed = Ember['default'].computed;
EmComputed.sum = reduce_computed_macros.sum;
EmComputed.min = reduce_computed_macros.min;
@@ -23984,38 +25508,16 @@
// END EXPORTS
exports['default'] = Ember['default'];
});
-enifed('ember-runtime/compare', ['exports', 'ember-metal/utils', 'ember-runtime/mixins/comparable'], function (exports, utils, Comparable) {
+enifed('ember-runtime/compare', ['exports', 'ember-runtime/utils', 'ember-runtime/mixins/comparable'], function (exports, utils, Comparable) {
'use strict';
- exports['default'] = compare;
- var TYPE_ORDER = {
- 'undefined': 0,
- 'null': 1,
- 'boolean': 2,
- 'number': 3,
- 'string': 4,
- 'array': 5,
- 'object': 6,
- 'instance': 7,
- 'function': 8,
- 'class': 9,
- 'date': 10
- };
- //
- // the spaceship operator
- //
- function spaceship(a, b) {
- var diff = a - b;
- return (diff > 0) - (diff < 0);
- }
-
/**
This will compare two javascript values of possibly different types.
It will tell you which one is greater than the other by returning:
- -1 if the first is smaller than the second,
@@ -24035,10 +25537,32 @@
@for Ember
@param {Object} v First value to compare
@param {Object} w Second value to compare
@return {Number} -1 if v < w, 0 if v = w and 1 if v > w.
*/
+ exports['default'] = compare;
+ var TYPE_ORDER = {
+ 'undefined': 0,
+ 'null': 1,
+ 'boolean': 2,
+ 'number': 3,
+ 'string': 4,
+ 'array': 5,
+ 'object': 6,
+ 'instance': 7,
+ 'function': 8,
+ 'class': 9,
+ 'date': 10
+ };
+
+ //
+ // the spaceship operator
+ //
+ function spaceship(a, b) {
+ var diff = a - b;
+ return (diff > 0) - (diff < 0);
+ }
function compare(v, w) {
if (v === w) {
return 0;
}
@@ -24292,10 +25816,195 @@
'use strict';
exports.reduceComputed = reduceComputed;
exports.ReduceComputedProperty = ReduceComputedProperty;
+ /**
+ Creates a computed property which operates on dependent arrays and
+ is updated with "one at a time" semantics. When items are added or
+ removed from the dependent array(s) a reduce computed only operates
+ on the change instead of re-evaluating the entire array.
+
+ If there are more than one arguments the first arguments are
+ considered to be dependent property keys. The last argument is
+ required to be an options object. The options object can have the
+ following four properties:
+
+ `initialValue` - A value or function that will be used as the initial
+ value for the computed. If this property is a function the result of calling
+ the function will be used as the initial value. This property is required.
+
+ `initialize` - An optional initialize function. Typically this will be used
+ to set up state on the instanceMeta object.
+
+ `removedItem` - A function that is called each time an element is removed
+ from the array.
+
+ `addedItem` - A function that is called each time an element is added to
+ the array.
+
+
+ The `initialize` function has the following signature:
+
+ ```javascript
+ function(initialValue, changeMeta, instanceMeta)
+ ```
+
+ `initialValue` - The value of the `initialValue` property from the
+ options object.
+
+ `changeMeta` - An object which contains meta information about the
+ computed. It contains the following properties:
+
+ - `property` the computed property
+ - `propertyName` the name of the property on the object
+
+ `instanceMeta` - An object that can be used to store meta
+ information needed for calculating your computed. For example a
+ unique computed might use this to store the number of times a given
+ element is found in the dependent array.
+
+
+ The `removedItem` and `addedItem` functions both have the following signature:
+
+ ```javascript
+ function(accumulatedValue, item, changeMeta, instanceMeta)
+ ```
+
+ `accumulatedValue` - The value returned from the last time
+ `removedItem` or `addedItem` was called or `initialValue`.
+
+ `item` - the element added or removed from the array
+
+ `changeMeta` - An object which contains meta information about the
+ change. It contains the following properties:
+
+ - `property` the computed property
+ - `propertyName` the name of the property on the object
+ - `index` the index of the added or removed item
+ - `item` the added or removed item: this is exactly the same as
+ the second arg
+ - `arrayChanged` the array that triggered the change. Can be
+ useful when depending on multiple arrays.
+
+ For property changes triggered on an item property change (when
+ depKey is something like `someArray.@each.someProperty`),
+ `changeMeta` will also contain the following property:
+
+ - `previousValues` an object whose keys are the properties that changed on
+ the item, and whose values are the item's previous values.
+
+ `previousValues` is important Ember coalesces item property changes via
+ Ember.run.once. This means that by the time removedItem gets called, item has
+ the new values, but you may need the previous value (eg for sorting &
+ filtering).
+
+ `instanceMeta` - An object that can be used to store meta
+ information needed for calculating your computed. For example a
+ unique computed might use this to store the number of times a given
+ element is found in the dependent array.
+
+ The `removedItem` and `addedItem` functions should return the accumulated
+ value. It is acceptable to not return anything (ie return undefined)
+ to invalidate the computation. This is generally not a good idea for
+ arrayComputed but it's used in eg max and min.
+
+ Note that observers will be fired if either of these functions return a value
+ that differs from the accumulated value. When returning an object that
+ mutates in response to array changes, for example an array that maps
+ everything from some other array (see `Ember.computed.map`), it is usually
+ important that the *same* array be returned to avoid accidentally triggering observers.
+
+ Example
+
+ ```javascript
+ Ember.computed.max = function(dependentKey) {
+ return Ember.reduceComputed(dependentKey, {
+ initialValue: -Infinity,
+
+ addedItem: function(accumulatedValue, item, changeMeta, instanceMeta) {
+ return Math.max(accumulatedValue, item);
+ },
+
+ removedItem: function(accumulatedValue, item, changeMeta, instanceMeta) {
+ if (item < accumulatedValue) {
+ return accumulatedValue;
+ }
+ }
+ });
+ };
+ ```
+
+ Dependent keys may refer to `@this` to observe changes to the object itself,
+ which must be array-like, rather than a property of the object. This is
+ mostly useful for array proxies, to ensure objects are retrieved via
+ `objectAtContent`. This is how you could sort items by properties defined on an item controller.
+
+ Example
+
+ ```javascript
+ App.PeopleController = Ember.ArrayController.extend({
+ itemController: 'person',
+
+ sortedPeople: Ember.computed.sort('@this.@each.reversedName', function(personA, personB) {
+ // `reversedName` isn't defined on Person, but we have access to it via
+ // the item controller App.PersonController. If we'd used
+ // `content.@each.reversedName` above, we would be getting the objects
+ // directly and not have access to `reversedName`.
+ //
+ var reversedNameA = get(personA, 'reversedName');
+ var reversedNameB = get(personB, 'reversedName');
+
+ return Ember.compare(reversedNameA, reversedNameB);
+ })
+ });
+
+ App.PersonController = Ember.ObjectController.extend({
+ reversedName: function() {
+ return reverse(get(this, 'name'));
+ }.property('name')
+ });
+ ```
+
+ Dependent keys whose values are not arrays are treated as regular
+ dependencies: when they change, the computed property is completely
+ recalculated. It is sometimes useful to have dependent arrays with similar
+ semantics. Dependent keys which end in `.[]` do not use "one at a time"
+ semantics. When an item is added or removed from such a dependency, the
+ computed property is completely recomputed.
+
+ When the computed property is completely recomputed, the `accumulatedValue`
+ is discarded, it starts with `initialValue` again, and each item is passed
+ to `addedItem` in turn.
+
+ Example
+
+ ```javascript
+ Ember.Object.extend({
+ // When `string` is changed, `computed` is completely recomputed.
+ string: 'a string',
+
+ // When an item is added to `array`, `addedItem` is called.
+ array: [],
+
+ // When an item is added to `anotherArray`, `computed` is completely
+ // recomputed.
+ anotherArray: [],
+
+ computed: Ember.reduceComputed('string', 'array', 'anotherArray.[]', {
+ addedItem: addedItemCallback,
+ removedItem: removedItemCallback
+ })
+ });
+ ```
+
+ @method reduceComputed
+ @for Ember
+ @param {String} [dependentKeys*]
+ @param {Object} options
+ @return {Ember.ComputedProperty}
+ */
var cacheSet = computed.cacheFor.set;
var cacheGet = computed.cacheFor.get;
var cacheRemove = computed.cacheFor.remove;
var a_slice = [].slice;
// Here we explicitly don't allow `@each.foo`; it would require some special
@@ -24929,197 +26638,10 @@
propertyArgsToArray.push(propertyArgs[guid]);
}
return computed.ComputedProperty.prototype.property.apply(this, propertyArgsToArray);
};
-
- /**
- Creates a computed property which operates on dependent arrays and
- is updated with "one at a time" semantics. When items are added or
- removed from the dependent array(s) a reduce computed only operates
- on the change instead of re-evaluating the entire array.
-
- If there are more than one arguments the first arguments are
- considered to be dependent property keys. The last argument is
- required to be an options object. The options object can have the
- following four properties:
-
- `initialValue` - A value or function that will be used as the initial
- value for the computed. If this property is a function the result of calling
- the function will be used as the initial value. This property is required.
-
- `initialize` - An optional initialize function. Typically this will be used
- to set up state on the instanceMeta object.
-
- `removedItem` - A function that is called each time an element is removed
- from the array.
-
- `addedItem` - A function that is called each time an element is added to
- the array.
-
-
- The `initialize` function has the following signature:
-
- ```javascript
- function(initialValue, changeMeta, instanceMeta)
- ```
-
- `initialValue` - The value of the `initialValue` property from the
- options object.
-
- `changeMeta` - An object which contains meta information about the
- computed. It contains the following properties:
-
- - `property` the computed property
- - `propertyName` the name of the property on the object
-
- `instanceMeta` - An object that can be used to store meta
- information needed for calculating your computed. For example a
- unique computed might use this to store the number of times a given
- element is found in the dependent array.
-
-
- The `removedItem` and `addedItem` functions both have the following signature:
-
- ```javascript
- function(accumulatedValue, item, changeMeta, instanceMeta)
- ```
-
- `accumulatedValue` - The value returned from the last time
- `removedItem` or `addedItem` was called or `initialValue`.
-
- `item` - the element added or removed from the array
-
- `changeMeta` - An object which contains meta information about the
- change. It contains the following properties:
-
- - `property` the computed property
- - `propertyName` the name of the property on the object
- - `index` the index of the added or removed item
- - `item` the added or removed item: this is exactly the same as
- the second arg
- - `arrayChanged` the array that triggered the change. Can be
- useful when depending on multiple arrays.
-
- For property changes triggered on an item property change (when
- depKey is something like `someArray.@each.someProperty`),
- `changeMeta` will also contain the following property:
-
- - `previousValues` an object whose keys are the properties that changed on
- the item, and whose values are the item's previous values.
-
- `previousValues` is important Ember coalesces item property changes via
- Ember.run.once. This means that by the time removedItem gets called, item has
- the new values, but you may need the previous value (eg for sorting &
- filtering).
-
- `instanceMeta` - An object that can be used to store meta
- information needed for calculating your computed. For example a
- unique computed might use this to store the number of times a given
- element is found in the dependent array.
-
- The `removedItem` and `addedItem` functions should return the accumulated
- value. It is acceptable to not return anything (ie return undefined)
- to invalidate the computation. This is generally not a good idea for
- arrayComputed but it's used in eg max and min.
-
- Note that observers will be fired if either of these functions return a value
- that differs from the accumulated value. When returning an object that
- mutates in response to array changes, for example an array that maps
- everything from some other array (see `Ember.computed.map`), it is usually
- important that the *same* array be returned to avoid accidentally triggering observers.
-
- Example
-
- ```javascript
- Ember.computed.max = function(dependentKey) {
- return Ember.reduceComputed(dependentKey, {
- initialValue: -Infinity,
-
- addedItem: function(accumulatedValue, item, changeMeta, instanceMeta) {
- return Math.max(accumulatedValue, item);
- },
-
- removedItem: function(accumulatedValue, item, changeMeta, instanceMeta) {
- if (item < accumulatedValue) {
- return accumulatedValue;
- }
- }
- });
- };
- ```
-
- Dependent keys may refer to `@this` to observe changes to the object itself,
- which must be array-like, rather than a property of the object. This is
- mostly useful for array proxies, to ensure objects are retrieved via
- `objectAtContent`. This is how you could sort items by properties defined on an item controller.
-
- Example
-
- ```javascript
- App.PeopleController = Ember.ArrayController.extend({
- itemController: 'person',
-
- sortedPeople: Ember.computed.sort('@this.@each.reversedName', function(personA, personB) {
- // `reversedName` isn't defined on Person, but we have access to it via
- // the item controller App.PersonController. If we'd used
- // `content.@each.reversedName` above, we would be getting the objects
- // directly and not have access to `reversedName`.
- //
- var reversedNameA = get(personA, 'reversedName');
- var reversedNameB = get(personB, 'reversedName');
-
- return Ember.compare(reversedNameA, reversedNameB);
- })
- });
-
- App.PersonController = Ember.ObjectController.extend({
- reversedName: function() {
- return reverse(get(this, 'name'));
- }.property('name')
- });
- ```
-
- Dependent keys whose values are not arrays are treated as regular
- dependencies: when they change, the computed property is completely
- recalculated. It is sometimes useful to have dependent arrays with similar
- semantics. Dependent keys which end in `.[]` do not use "one at a time"
- semantics. When an item is added or removed from such a dependency, the
- computed property is completely recomputed.
-
- When the computed property is completely recomputed, the `accumulatedValue`
- is discarded, it starts with `initialValue` again, and each item is passed
- to `addedItem` in turn.
-
- Example
-
- ```javascript
- Ember.Object.extend({
- // When `string` is changed, `computed` is completely recomputed.
- string: 'a string',
-
- // When an item is added to `array`, `addedItem` is called.
- array: [],
-
- // When an item is added to `anotherArray`, `computed` is completely
- // recomputed.
- anotherArray: [],
-
- computed: Ember.reduceComputed('string', 'array', 'anotherArray.[]', {
- addedItem: addedItemCallback,
- removedItem: removedItemCallback
- })
- });
- ```
-
- @method reduceComputed
- @for Ember
- @param {String} [dependentKeys*]
- @param {Object} options
- @return {Ember.ComputedProperty}
- */
-
function reduceComputed(options) {
var args;
if (arguments.length > 1) {
args = a_slice.call(arguments, 0, -1);
@@ -25158,12 +26680,10 @@
exports.uniq = uniq;
exports.intersect = intersect;
exports.setDiff = setDiff;
exports.sort = sort;
- var a_slice = [].slice;
-
/**
A computed property that returns the sum of the value
in the dependent array.
@method sum
@@ -25171,10 +26691,11 @@
@param {String} dependentKey
@return {Ember.ComputedProperty} computes the sum of all values in the dependentKey's array
@since 1.4.0
*/
+ var a_slice = [].slice;
function sum(dependentKey) {
return reduce_computed.reduceComputed(dependentKey, {
initialValue: 0,
addedItem: function (accumulatedValue, item, changeMeta, instanceMeta) {
@@ -25185,44 +26706,10 @@
return accumulatedValue - item;
}
});
}
- /**
- A computed property that calculates the maximum value in the
- dependent array. This will return `-Infinity` when the dependent
- array is empty.
-
- ```javascript
- var Person = Ember.Object.extend({
- childAges: Ember.computed.mapBy('children', 'age'),
- maxChildAge: Ember.computed.max('childAges')
- });
-
- var lordByron = Person.create({ children: [] });
-
- lordByron.get('maxChildAge'); // -Infinity
- lordByron.get('children').pushObject({
- name: 'Augusta Ada Byron', age: 7
- });
- lordByron.get('maxChildAge'); // 7
- lordByron.get('children').pushObjects([{
- name: 'Allegra Byron',
- age: 5
- }, {
- name: 'Elizabeth Medora Leigh',
- age: 8
- }]);
- lordByron.get('maxChildAge'); // 8
- ```
-
- @method max
- @for Ember.computed
- @param {String} dependentKey
- @return {Ember.ComputedProperty} computes the largest value in the dependentKey's array
- */
-
function max(dependentKey) {
return reduce_computed.reduceComputed(dependentKey, {
initialValue: -Infinity,
addedItem: function (accumulatedValue, item, changeMeta, instanceMeta) {
@@ -25235,44 +26722,10 @@
}
}
});
}
- /**
- A computed property that calculates the minimum value in the
- dependent array. This will return `Infinity` when the dependent
- array is empty.
-
- ```javascript
- var Person = Ember.Object.extend({
- childAges: Ember.computed.mapBy('children', 'age'),
- minChildAge: Ember.computed.min('childAges')
- });
-
- var lordByron = Person.create({ children: [] });
-
- lordByron.get('minChildAge'); // Infinity
- lordByron.get('children').pushObject({
- name: 'Augusta Ada Byron', age: 7
- });
- lordByron.get('minChildAge'); // 7
- lordByron.get('children').pushObjects([{
- name: 'Allegra Byron',
- age: 5
- }, {
- name: 'Elizabeth Medora Leigh',
- age: 8
- }]);
- lordByron.get('minChildAge'); // 5
- ```
-
- @method min
- @for Ember.computed
- @param {String} dependentKey
- @return {Ember.ComputedProperty} computes the smallest value in the dependentKey's array
- */
-
function min(dependentKey) {
return reduce_computed.reduceComputed(dependentKey, {
initialValue: Infinity,
addedItem: function (accumulatedValue, item, changeMeta, instanceMeta) {
@@ -25285,44 +26738,10 @@
}
}
});
}
- /**
- Returns an array mapped via the callback
-
- The callback method you provide should have the following signature.
- `item` is the current item in the iteration.
- `index` is the integer index of the current item in the iteration.
-
- ```javascript
- function(item, index);
- ```
-
- Example
-
- ```javascript
- var Hamster = Ember.Object.extend({
- excitingChores: Ember.computed.map('chores', function(chore, index) {
- return chore.toUpperCase() + '!';
- })
- });
-
- var hamster = Hamster.create({
- chores: ['clean', 'write more unit tests']
- });
-
- hamster.get('excitingChores'); // ['CLEAN!', 'WRITE MORE UNIT TESTS!']
- ```
-
- @method map
- @for Ember.computed
- @param {String} dependentKey
- @param {Function} callback
- @return {Ember.ComputedProperty} an array mapped via the callback
- */
-
function map(dependentKey, callback) {
var options = {
addedItem: function (array, item, changeMeta, instanceMeta) {
var mapped = callback.call(this, item, changeMeta.index);
array.insertAt(changeMeta.index, mapped);
@@ -25335,40 +26754,10 @@
};
return array_computed.arrayComputed(dependentKey, options);
}
- /**
- Returns an array mapped to the specified key.
-
- ```javascript
- var Person = Ember.Object.extend({
- childAges: Ember.computed.mapBy('children', 'age')
- });
-
- var lordByron = Person.create({ children: [] });
-
- lordByron.get('childAges'); // []
- lordByron.get('children').pushObject({ name: 'Augusta Ada Byron', age: 7 });
- lordByron.get('childAges'); // [7]
- lordByron.get('children').pushObjects([{
- name: 'Allegra Byron',
- age: 5
- }, {
- name: 'Elizabeth Medora Leigh',
- age: 8
- }]);
- lordByron.get('childAges'); // [7, 5, 8]
- ```
-
- @method mapBy
- @for Ember.computed
- @param {String} dependentKey
- @param {String} propertyKey
- @return {Ember.ComputedProperty} an array mapped to the specified key
- */
-
function mapBy(dependentKey, propertyKey) {
var callback = function (item) {
return property_get.get(item, propertyKey);
};
return map(dependentKey + '.@each.' + propertyKey, callback);
@@ -25379,13 +26768,11 @@
@for Ember.computed
@deprecated Use `Ember.computed.mapBy` instead
@param dependentKey
@param propertyKey
*/
- var mapProperty = mapBy;
-
- function filter(dependentKey, callback) {
+ var mapProperty = mapBy;function filter(dependentKey, callback) {
var options = {
initialize: function (array, changeMeta, instanceMeta) {
instanceMeta.filteredArrayIndexes = new SubArray['default']();
},
@@ -25412,37 +26799,10 @@
};
return array_computed.arrayComputed(dependentKey, options);
}
- /**
- Filters the array by the property and value
-
- ```javascript
- var Hamster = Ember.Object.extend({
- remainingChores: Ember.computed.filterBy('chores', 'done', false)
- });
-
- var hamster = Hamster.create({
- chores: [
- { name: 'cook', done: true },
- { name: 'clean', done: true },
- { name: 'write more unit tests', done: false }
- ]
- });
-
- hamster.get('remainingChores'); // [{ name: 'write more unit tests', done: false }]
- ```
-
- @method filterBy
- @for Ember.computed
- @param {String} dependentKey
- @param {String} propertyKey
- @param {*} value
- @return {Ember.ComputedProperty} the filtered array
- */
-
function filterBy(dependentKey, propertyKey, value) {
var callback;
if (arguments.length === 2) {
callback = function (item) {
@@ -25463,13 +26823,11 @@
@param dependentKey
@param propertyKey
@param value
@deprecated Use `Ember.computed.filterBy` instead
*/
- var filterProperty = filterBy;
-
- function uniq() {
+ var filterProperty = filterBy;function uniq() {
var args = a_slice.call(arguments);
args.push({
initialize: function (array, changeMeta, instanceMeta) {
instanceMeta.itemCounts = {};
@@ -25509,13 +26867,11 @@
@for Ember.computed
@param {String} propertyKey*
@return {Ember.ComputedProperty} computes a new array with all the
unique elements from the dependent array
*/
- var union = uniq;
-
- function intersect() {
+ var union = uniq;function intersect() {
var args = a_slice.call(arguments);
args.push({
initialize: function (array, changeMeta, instanceMeta) {
instanceMeta.itemCounts = {};
@@ -25568,42 +26924,10 @@
});
return array_computed.arrayComputed.apply(null, args);
}
- /**
- A computed property which returns a new array with all the
- properties from the first dependent array that are not in the second
- dependent array.
-
- Example
-
- ```javascript
- var Hamster = Ember.Object.extend({
- likes: ['banana', 'grape', 'kale'],
- wants: Ember.computed.setDiff('likes', 'fruits')
- });
-
- var hamster = Hamster.create({
- fruits: [
- 'grape',
- 'kale',
- ]
- });
-
- hamster.get('wants'); // ['banana']
- ```
-
- @method setDiff
- @for Ember.computed
- @param {String} setAProperty
- @param {String} setBProperty
- @return {Ember.ComputedProperty} computes a new array with all the
- items from the first dependent array that are not in the second
- dependent array
- */
-
function setDiff(setAProperty, setBProperty) {
if (arguments.length !== 2) {
throw new EmberError['default']('setDiff requires exactly two dependent arrays.');
}
@@ -25677,76 +27001,10 @@
return this.binarySearch(array, item, low, mid);
}
return mid;
}
-
- /**
- A computed property which returns a new array with all the
- properties from the first dependent array sorted based on a property
- or sort function.
-
- The callback method you provide should have the following signature:
-
- ```javascript
- function(itemA, itemB);
- ```
-
- - `itemA` the first item to compare.
- - `itemB` the second item to compare.
-
- This function should return negative number (e.g. `-1`) when `itemA` should come before
- `itemB`. It should return positive number (e.g. `1`) when `itemA` should come after
- `itemB`. If the `itemA` and `itemB` are equal this function should return `0`.
-
- Therefore, if this function is comparing some numeric values, simple `itemA - itemB` or
- `itemA.get( 'foo' ) - itemB.get( 'foo' )` can be used instead of series of `if`.
-
- Example
-
- ```javascript
- var ToDoList = Ember.Object.extend({
- // using standard ascending sort
- todosSorting: ['name'],
- sortedTodos: Ember.computed.sort('todos', 'todosSorting'),
-
- // using descending sort
- todosSortingDesc: ['name:desc'],
- sortedTodosDesc: Ember.computed.sort('todos', 'todosSortingDesc'),
-
- // using a custom sort function
- priorityTodos: Ember.computed.sort('todos', function(a, b){
- if (a.priority > b.priority) {
- return 1;
- } else if (a.priority < b.priority) {
- return -1;
- }
-
- return 0;
- })
- });
-
- var todoList = ToDoList.create({todos: [
- { name: 'Unit Test', priority: 2 },
- { name: 'Documentation', priority: 3 },
- { name: 'Release', priority: 1 }
- ]});
-
- todoList.get('sortedTodos'); // [{ name:'Documentation', priority:3 }, { name:'Release', priority:1 }, { name:'Unit Test', priority:2 }]
- todoList.get('sortedTodosDesc'); // [{ name:'Unit Test', priority:2 }, { name:'Release', priority:1 }, { name:'Documentation', priority:3 }]
- todoList.get('priorityTodos'); // [{ name:'Release', priority:1 }, { name:'Unit Test', priority:2 }, { name:'Documentation', priority:3 }]
- ```
-
- @method sort
- @for Ember.computed
- @param {String} dependentKey
- @param {String or Function} sortDefinition a dependent key to an
- array of sort properties (add `:desc` to the arrays sort properties to sort descending) or a function to use when sorting
- @return {Ember.ComputedProperty} computes a new sorted array based
- on the sort property array or callback function
- */
-
function sort(itemsKey, sortDefinition) {
Ember['default'].assert('Ember.computed.sort requires two arguments: an array key to sort and ' + 'either a sort properties key or sort function', arguments.length === 2);
if (typeof sortDefinition === 'function') {
return customSort(itemsKey, sortDefinition);
@@ -26092,11 +27350,11 @@
'use strict';
var Controller = EmberObject['default'].extend(Mixin['default']);
function controllerInjectionHelper(factory) {
- Ember['default'].assert("Defining an injected controller property on a " + "non-controller is not allowed.", Mixin['default'].detect(factory.PrototypeMixin));
+ Ember['default'].assert('Defining an injected controller property on a ' + 'non-controller is not allowed.', Mixin['default'].detect(factory.PrototypeMixin));
}
/**
Creates a property that lazily looks up another controller in the container.
Can only be used when defining another controller.
@@ -26151,10 +27409,26 @@
enifed('ember-runtime/copy', ['exports', 'ember-metal/enumerable_utils', 'ember-metal/utils', 'ember-runtime/system/object', 'ember-runtime/mixins/copyable'], function (exports, enumerable_utils, utils, EmberObject, Copyable) {
'use strict';
+
+ /**
+ Creates a clone of the passed object. This function can take just about
+ any type of object and create a clone of it, including primitive values
+ (which are not actually cloned because they are immutable).
+
+ If the passed object implements the `copy()` method, then this function
+ will simply call that method and return the result. Please see
+ `Ember.Copyable` for further details.
+
+ @method copy
+ @for Ember
+ @param {Object} obj The object to clone
+ @param {Boolean} deep If true, a deep copy of the object is made
+ @return {Object} The cloned object
+ */
exports['default'] = copy;
function _copy(obj, deep, seen, copies) {
var ret, loc, key;
// primitive data types are immutable, just return them.
@@ -26169,11 +27443,11 @@
Ember.assert('Cannot clone an Ember.Object that does not implement Ember.Copyable', !(obj instanceof EmberObject['default']) || Copyable['default'] && Copyable['default'].detect(obj));
// IMPORTANT: this specific test will detect a native array only. Any other
// object will need to implement Copyable.
- if (utils.typeOf(obj) === 'array') {
+ if (utils.isArray(obj)) {
ret = obj.slice();
if (deep) {
loc = ret.length;
@@ -26209,26 +27483,10 @@
copies.push(ret);
}
return ret;
}
-
- /**
- Creates a clone of the passed object. This function can take just about
- any type of object and create a clone of it, including primitive values
- (which are not actually cloned because they are immutable).
-
- If the passed object implements the `copy()` method, then this function
- will simply call that method and return the result. Please see
- `Ember.Copyable` for further details.
-
- @method copy
- @for Ember
- @param {Object} obj The object to clone
- @param {Boolean} deep If true, a deep copy of the object is made
- @return {Object} The cloned object
- */
function copy(obj, deep) {
// fast paths
if ('object' !== typeof obj || obj === null) {
return obj; // can't copy primitives
}
@@ -26245,10 +27503,33 @@
'use strict';
exports.isEqual = isEqual;
+ /**
+ @module ember
+ @submodule ember-runtime
+ */
+
+ /**
+ 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
+ respect that method.
+
+ ```javascript
+ Ember.isEqual('hello', 'hello'); // true
+ Ember.isEqual(1, 2); // false
+ Ember.isEqual([4, 2], [4, 2]); // false
+ ```
+
+ @method isEqual
+ @for Ember
+ @param {Object} a first object to compare
+ @param {Object} b second object to compare
+ @return {Boolean}
+ */
function isEqual(a, b) {
if (a && typeof a.isEqual === 'function') {
return a.isEqual(b);
}
@@ -26486,11 +27767,10 @@
RSVP.Promise.prototype.fail = function (callback, label) {
Ember['default'].deprecate('RSVP.Promise.fail has been renamed as RSVP.Promise.catch');
return this['catch'](callback, label);
};
-
function onerrorDefault(e) {
var error;
if (e && e.errorThrown) {
// jqXHR provides this
@@ -26630,17 +27910,10 @@
'use strict';
exports.createInjectionHelper = createInjectionHelper;
exports.validatePropertyInjections = validatePropertyInjections;
- function inject() {
- Ember['default'].assert("Injected properties must be created through helpers, see `" + keys['default'](inject).join("`, `") + "`");
- }
-
- // Dictionary of injection validations by type, added to by `createInjectionHelper`
- var typeValidators = {};
-
/**
This method allows other Ember modules to register injection helpers for a
given container type. Helpers are exported to the `inject` namespace as the
container type itself.
@@ -26649,30 +27922,24 @@
@since 1.10.0
@for Ember
@param {String} type The container type the helper will inject
@param {Function} validator A validation callback that is executed at mixin-time
*/
+ function inject() {
+ Ember['default'].assert("Injected properties must be created through helpers, see `" + keys['default'](inject).join("`, `") + "`");
+ }
+ // Dictionary of injection validations by type, added to by `createInjectionHelper`
+ var typeValidators = {};
function createInjectionHelper(type, validator) {
typeValidators[type] = validator;
inject[type] = function (name) {
return new InjectedProperty['default'](type, name);
};
}
- /**
- Validation function that runs per-type validation functions once for each
- injected type encountered.
-
- @private
- @method validatePropertyInjections
- @since 1.10.0
- @for Ember
- @param {Object} factory The factory object
- */
-
function validatePropertyInjections(factory) {
var proto = factory.proto();
var types = [];
var key, desc, validator, i, l;
@@ -26685,11 +27952,11 @@
if (types.length) {
for (i = 0, l = types.length; i < l; i++) {
validator = typeValidators[types[i]];
- if (typeof validator === 'function') {
+ if (typeof validator === "function") {
validator(factory);
}
}
}
@@ -26737,34 +28004,34 @@
@property content
@type Ember.Object
@default null
*/
content: null,
- _contentDidChange: mixin.observer('content', function () {
- Ember['default'].assert("Can't set Proxy's content to itself", property_get.get(this, 'content') !== this);
+ _contentDidChange: mixin.observer("content", function () {
+ Ember['default'].assert("Can't set Proxy's content to itself", property_get.get(this, "content") !== this);
}),
- isTruthy: computed.computed.bool('content'),
+ isTruthy: computed.computed.bool("content"),
_debugContainerKey: null,
willWatchProperty: function (key) {
- var contentKey = 'content.' + key;
+ var contentKey = "content." + key;
observer.addBeforeObserver(this, contentKey, null, contentPropertyWillChange);
observer.addObserver(this, contentKey, null, contentPropertyDidChange);
},
didUnwatchProperty: function (key) {
- var contentKey = 'content.' + key;
+ var contentKey = "content." + key;
observer.removeBeforeObserver(this, contentKey, null, contentPropertyWillChange);
observer.removeObserver(this, contentKey, null, contentPropertyDidChange);
},
unknownProperty: function (key) {
- var content = property_get.get(this, 'content');
+ var content = property_get.get(this, "content");
if (content) {
- Ember['default'].deprecate(string.fmt('You attempted to access `%@` from `%@`, but object proxying is deprecated. ' + 'Please use `model.%@` instead.', [key, this, key]), !this.isController, { url: 'http://emberjs.com/guides/deprecations/#toc_objectcontroller' });
+ Ember['default'].deprecate(string.fmt("You attempted to access `%@` from `%@`, but object proxying is deprecated. " + "Please use `model.%@` instead.", [key, this, key]), !this.isController);
return property_get.get(content, key);
}
},
setUnknownProperty: function (key, value) {
@@ -26774,30 +28041,30 @@
// rather than delegate
properties.defineProperty(this, key, null, value);
return value;
}
- var content = property_get.get(this, 'content');
+ var content = property_get.get(this, "content");
Ember['default'].assert(string.fmt("Cannot delegate set('%@', %@) to the 'content' property of" + " object proxy %@: its 'content' is undefined.", [key, value, this]), content);
- Ember['default'].deprecate(string.fmt('You attempted to set `%@` from `%@`, but object proxying is deprecated. ' + 'Please use `model.%@` instead.', [key, this, key]), !this.isController, { url: 'http://emberjs.com/guides/deprecations/#toc_objectcontroller' });
+ Ember['default'].deprecate(string.fmt("You attempted to set `%@` from `%@`, but object proxying is deprecated. " + "Please use `model.%@` instead.", [key, this, key]), !this.isController);
return property_set.set(content, key, value);
}
});
});
-enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal/merge', 'ember-metal/mixin', 'ember-metal/property_get', 'ember-metal/utils'], function (exports, merge, mixin, property_get, utils) {
+enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal/merge', 'ember-metal/mixin', 'ember-metal/property_get'], function (exports, merge, mixin, property_get) {
'use strict';
/**
@module ember
@submodule ember-runtime
*/
var ActionHandler = mixin.Mixin.create({
- mergedProperties: ['_actions'],
+ mergedProperties: ["_actions"],
/**
The collection of functions, keyed by name, available on this
`ActionHandler` as action targets.
These functions will be invoked when a matching `{{action}}` is triggered
@@ -26906,17 +28173,17 @@
*/
willMergeMixin: function (props) {
var hashName;
if (!props._actions) {
- Ember.assert("'actions' should not be a function", typeof props.actions !== 'function');
+ Ember.assert("'actions' should not be a function", typeof props.actions !== "function");
- if (utils.typeOf(props.actions) === 'object') {
- hashName = 'actions';
- } else if (utils.typeOf(props.events) === 'object') {
- Ember.deprecate('Action handlers contained in an `events` object are deprecated in favor' + ' of putting them in an `actions` object');
- hashName = 'events';
+ if (!!props.actions && typeof props.actions === "object") {
+ hashName = "actions";
+ } else if (!!props.events && typeof props.events === "object") {
+ Ember.deprecate("Action handlers contained in an `events` object are deprecated in favor" + " of putting them in an `actions` object", false);
+ hashName = "events";
}
if (hashName) {
props._actions = merge['default'](props._actions || {}, props[hashName]);
}
@@ -26962,15 +28229,13 @@
if (!shouldBubble) {
return;
}
}
- if (target = property_get.get(this, 'target')) {
- var _target;
-
- Ember.assert("The `target` for " + this + " (" + target + ") does not have a `send` method", typeof target.send === 'function');
- (_target = target).send.apply(_target, arguments);
+ if (target = property_get.get(this, "target")) {
+ Ember.assert("The `target` for " + this + " (" + target + ") does not have a `send` method", typeof target.send === "function");
+ target.send.apply(target, arguments);
}
}
});
exports['default'] = ActionHandler;
@@ -27516,11 +28781,11 @@
model: null,
/**
@private
*/
- content: alias['default']('model')
+ content: alias['default']("model")
});
});
enifed('ember-runtime/mixins/controller_content_model_alias_deprecation', ['exports', 'ember-metal/core', 'ember-metal/mixin'], function (exports, Ember, mixin) {
@@ -27546,11 +28811,11 @@
if (props.content && !modelSpecified) {
props.model = props.content;
delete props['content'];
- Ember['default'].deprecate('Do not specify `content` on a Controller, use `model` instead.');
+ Ember['default'].deprecate('Do not specify `content` on a Controller, use `model` instead.', false);
}
}
});
});
@@ -27585,11 +28850,11 @@
@method frozenCopy
@return {Object} copy of receiver or receiver
*/
frozenCopy: function () {
if (freezable.Freezable && freezable.Freezable.detect(this)) {
- return property_get.get(this, 'isFrozen') ? this : this.copy().freeze();
+ return property_get.get(this, "isFrozen") ? this : this.copy().freeze();
} else {
throw new EmberError['default'](string.fmt("%@ does not support freezing", [this]));
}
}
});
@@ -27608,11 +28873,11 @@
*/
then: function (resolve, reject, label) {
var deferred, promise, entity;
entity = this;
- deferred = property_get.get(this, '_deferred');
+ deferred = property_get.get(this, "_deferred");
promise = deferred.promise;
function fulfillmentHandler(fulfillment) {
if (fulfillment === promise) {
return resolve(entity);
@@ -27629,11 +28894,11 @@
@method resolve
*/
resolve: function (value) {
var deferred, promise;
- deferred = property_get.get(this, '_deferred');
+ deferred = property_get.get(this, "_deferred");
promise = deferred.promise;
if (value === this) {
deferred.resolve(promise);
} else {
@@ -27644,17 +28909,17 @@
/**
Reject a Deferred object and call any `failCallbacks` with the given args.
@method reject
*/
reject: function (value) {
- property_get.get(this, '_deferred').reject(value);
+ property_get.get(this, "_deferred").reject(value);
},
_deferred: computed.computed(function () {
- Ember['default'].deprecate('Usage of Ember.DeferredMixin or Ember.Deferred is deprecated.', this._suppressDeferredDeprecation, { url: 'http://emberjs.com/guides/deprecations/#toc_ember-deferredmixin-and-ember-deferred' });
+ Ember['default'].deprecate("Usage of Ember.DeferredMixin or Ember.Deferred is deprecated.", this._suppressDeferredDeprecation, { url: "http://emberjs.com/guides/deprecations/#toc_deprecate-ember-deferredmixin-and-ember-deferred" });
- return RSVP['default'].defer('Ember: DeferredMixin - ' + this);
+ return RSVP['default'].defer("Ember: DeferredMixin - " + this);
})
});
});
enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/mixin', 'ember-metal/enumerable_utils', 'ember-metal/computed', 'ember-metal/property_events', 'ember-metal/events', 'ember-runtime/compare'], function (exports, Ember, property_get, property_set, mixin, enumerable_utils, computed, property_events, events, compare) {
@@ -28830,15 +30095,15 @@
no longer allow any properties to be edited.
@method freeze
@return {Object} receiver
*/
freeze: function () {
- if (property_get.get(this, 'isFrozen')) {
+ if (property_get.get(this, "isFrozen")) {
return this;
}
- property_set.set(this, 'isFrozen', true);
+ property_set.set(this, "isFrozen", true);
return this;
}
});
@@ -28857,11 +30122,31 @@
// ..........................................................
// HELPERS
//
var OUT_OF_RANGE_EXCEPTION = "Index out of range";
- var EMPTY = [];exports['default'] = mixin.Mixin.create(EmberArray['default'], MutableEnumerable['default'], {
+ var EMPTY = []; /**
+ This mixin defines the API for modifying array-like objects. These methods
+ can be applied only to a collection that keeps its items in an ordered set.
+ It builds upon the Array mixin and adds methods to modify the array.
+ Concrete implementations of this class include ArrayProxy and ArrayController.
+
+ It is important to use the methods in this class to modify arrays so that
+ changes are observable. This allows the binding system in Ember to function
+ correctly.
+
+
+ Note that an Array can change even if it does not implement this mixin.
+ For example, one might implement a SparseArray that cannot be directly
+ modified, but if its underlying enumerable changes, it will change also.
+
+ @class MutableArray
+ @namespace Ember
+ @uses Ember.Array
+ @uses Ember.MutableEnumerable
+ */
+ exports['default'] = mixin.Mixin.create(EmberArray['default'], MutableEnumerable['default'], {
/**
__Required.__ You must implement this method to apply this mixin.
This is one of the primitives you must implement to support `Ember.Array`.
You should replace amt objects started at idx with the objects in the
@@ -28887,11 +30172,11 @@
```
@method clear
@return {Ember.Array} An empty Array.
*/
clear: function () {
- var len = property_get.get(this, 'length');
+ var len = property_get.get(this, "length");
if (len === 0) {
return this;
}
this.replace(0, len, EMPTY);
@@ -28910,11 +30195,11 @@
@param {Number} idx index of insert the object at.
@param {Object} object object to insert
@return {Ember.Array} receiver
*/
insertAt: function (idx, object) {
- if (idx > property_get.get(this, 'length')) {
+ if (idx > property_get.get(this, "length")) {
throw new EmberError['default'](OUT_OF_RANGE_EXCEPTION);
}
this.replace(idx, 0, [object]);
return this;
@@ -28935,13 +30220,13 @@
@param {Number} start index, start of range
@param {Number} len length of passing range
@return {Ember.Array} receiver
*/
removeAt: function (start, len) {
- if ('number' === typeof start) {
+ if ("number" === typeof start) {
- if (start < 0 || start >= property_get.get(this, 'length')) {
+ if (start < 0 || start >= property_get.get(this, "length")) {
throw new EmberError['default'](OUT_OF_RANGE_EXCEPTION);
}
// fast case
if (len === undefined) {
@@ -28965,11 +30250,11 @@
@method pushObject
@param {*} obj object to push
@return object same object passed as a param
*/
pushObject: function (obj) {
- this.insertAt(property_get.get(this, 'length'), obj);
+ this.insertAt(property_get.get(this, "length"), obj);
return obj;
},
/**
Add the objects in the passed numerable to the end of the array. Defers
@@ -28984,11 +30269,11 @@
*/
pushObjects: function (objects) {
if (!(Enumerable['default'].detect(objects) || utils.isArray(objects))) {
throw new TypeError("Must pass Ember.Enumerable to Ember.MutableArray#pushObjects");
}
- this.replace(property_get.get(this, 'length'), 0, objects);
+ this.replace(property_get.get(this, "length"), 0, objects);
return this;
},
/**
Pop object from array or nil if none are left. Works just like `pop()` but
@@ -29000,11 +30285,11 @@
```
@method popObject
@return object
*/
popObject: function () {
- var len = property_get.get(this, 'length');
+ var len = property_get.get(this, "length");
if (len === 0) {
return null;
}
var ret = this.objectAt(len - 1);
@@ -29022,11 +30307,11 @@
```
@method shiftObject
@return object
*/
shiftObject: function () {
- if (property_get.get(this, 'length') === 0) {
+ if (property_get.get(this, "length") === 0) {
return null;
}
var ret = this.objectAt(0);
this.removeAt(0);
@@ -29072,11 +30357,11 @@
KVO-compliant.
@method reverseObjects
@return {Ember.Array} receiver
*/
reverseObjects: function () {
- var len = property_get.get(this, 'length');
+ var len = property_get.get(this, "length");
if (len === 0) {
return this;
}
var objects = this.toArray().reverse();
@@ -29100,11 +30385,11 @@
setObjects: function (objects) {
if (objects.length === 0) {
return this.clear();
}
- var len = property_get.get(this, 'length');
+ var len = property_get.get(this, "length");
this.replace(0, len, objects);
return this;
},
// ..........................................................
@@ -29122,11 +30407,11 @@
@method removeObject
@param {*} obj object to remove
@return {Ember.Array} receiver
*/
removeObject: function (obj) {
- var loc = property_get.get(this, 'length') || 0;
+ var loc = property_get.get(this, "length") || 0;
while (--loc >= 0) {
var curObject = this.objectAt(loc);
if (curObject === obj) {
this.removeAt(loc);
@@ -29430,11 +30715,11 @@
this.propertyDidChange(keyName);
return this;
},
addBeforeObserver: function (key, target, method) {
- Ember['default'].deprecate('Before observers are deprecated and will be removed in a future release. If you want to keep track of previous values you have to implement it yourself.', false, { url: 'http://emberjs.com/guides/deprecations/#toc_deprecate-beforeobservers' });
+ Ember['default'].deprecate("Before observers are deprecated and will be removed in a future release. If you want to keep track of previous values you have to implement it yourself.", false, { url: "http://emberjs.com/guides/deprecations/#toc_deprecate-beforeobservers" });
observer.addBeforeObserver(this, key, target, method);
},
/**
Adds an observer on a property.
@@ -29497,11 +30782,11 @@
@method hasObserverFor
@param {String} key Key to check
@return {Boolean}
*/
hasObserverFor: function (key) {
- return events.hasListeners(this, key + ':change');
+ return events.hasListeners(this, key + ":change");
},
/**
Retrieves the value of a property, or a default value in the case that the
property returns `undefined`.
@@ -29702,18 +30987,18 @@
/**
Once the proxied promise has settled this will become `false`.
@property isPending
@default true
*/
- isPending: not('isSettled').readOnly(),
+ isPending: not("isSettled").readOnly(),
/**
Once the proxied promise has settled this will become `true`.
@property isSettled
@default false
*/
- isSettled: or('isRejected', 'isFulfilled').readOnly(),
+ isSettled: or("isRejected", "isFulfilled").readOnly(),
/**
Will become `true` if the proxied promise is rejected.
@property isRejected
@default false
@@ -29753,37 +31038,37 @@
See RSVP.Promise.then.
@method then
@param {Function} callback
@return {RSVP.Promise}
*/
- then: promiseAlias('then'),
+ then: promiseAlias("then"),
/**
An alias to the proxied promise's `catch`.
See RSVP.Promise.catch.
@method catch
@param {Function} callback
@return {RSVP.Promise}
@since 1.3.0
*/
- 'catch': promiseAlias('catch'),
+ "catch": promiseAlias("catch"),
/**
An alias to the proxied promise's `finally`.
See RSVP.Promise.finally.
@method finally
@param {Function} callback
@return {RSVP.Promise}
@since 1.3.0
*/
- 'finally': promiseAlias('finally')
+ "finally": promiseAlias("finally")
});
function promiseAlias(name) {
return function () {
- var promise = property_get.get(this, 'promise');
+ var promise = property_get.get(this, "promise");
return promise[name].apply(promise, arguments);
};
}
});
@@ -29835,13 +31120,13 @@
*/
sortFunction: compare['default'],
orderBy: function (item1, item2) {
var result = 0;
- var sortProperties = property_get.get(this, 'sortProperties');
- var sortAscending = property_get.get(this, 'sortAscending');
- var sortFunction = property_get.get(this, 'sortFunction');
+ var sortProperties = property_get.get(this, "sortProperties");
+ var sortAscending = property_get.get(this, "sortAscending");
+ var sortFunction = property_get.get(this, "sortFunction");
Ember['default'].assert("you need to define `sortProperties`", !!sortProperties);
enumerable_utils.forEach(sortProperties, function (propertyName) {
if (result === 0) {
@@ -29854,138 +31139,138 @@
return result;
},
destroy: function () {
- var content = property_get.get(this, 'content');
- var sortProperties = property_get.get(this, 'sortProperties');
+ var content = property_get.get(this, "content");
+ var sortProperties = property_get.get(this, "sortProperties");
if (content && sortProperties) {
enumerable_utils.forEach(content, function (item) {
enumerable_utils.forEach(sortProperties, function (sortProperty) {
- observer.removeObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');
+ observer.removeObserver(item, sortProperty, this, "contentItemSortPropertyDidChange");
}, this);
}, this);
}
return this._super.apply(this, arguments);
},
- isSorted: computed_macros.notEmpty('sortProperties'),
+ isSorted: computed_macros.notEmpty("sortProperties"),
/**
Overrides the default `arrangedContent` from `ArrayProxy` in order to sort by `sortFunction`.
Also sets up observers for each `sortProperty` on each item in the content Array.
@property arrangedContent
*/
- arrangedContent: computed.computed('content', 'sortProperties.@each', {
+ arrangedContent: computed.computed("content", "sortProperties.@each", {
get: function (key) {
- var content = property_get.get(this, 'content');
- var isSorted = property_get.get(this, 'isSorted');
- var sortProperties = property_get.get(this, 'sortProperties');
+ var content = property_get.get(this, "content");
+ var isSorted = property_get.get(this, "isSorted");
+ var sortProperties = property_get.get(this, "sortProperties");
var self = this;
if (content && isSorted) {
content = content.slice();
content.sort(function (item1, item2) {
return self.orderBy(item1, item2);
});
enumerable_utils.forEach(content, function (item) {
enumerable_utils.forEach(sortProperties, function (sortProperty) {
- observer.addObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');
+ observer.addObserver(item, sortProperty, this, "contentItemSortPropertyDidChange");
}, this);
}, this);
return Ember['default'].A(content);
}
return content;
}
}),
- _contentWillChange: mixin.beforeObserver('content', function () {
- var content = property_get.get(this, 'content');
- var sortProperties = property_get.get(this, 'sortProperties');
+ _contentWillChange: mixin.beforeObserver("content", function () {
+ var content = property_get.get(this, "content");
+ var sortProperties = property_get.get(this, "sortProperties");
if (content && sortProperties) {
enumerable_utils.forEach(content, function (item) {
enumerable_utils.forEach(sortProperties, function (sortProperty) {
- observer.removeObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');
+ observer.removeObserver(item, sortProperty, this, "contentItemSortPropertyDidChange");
}, this);
}, this);
}
this._super.apply(this, arguments);
}),
- sortPropertiesWillChange: mixin.beforeObserver('sortProperties', function () {
+ sortPropertiesWillChange: mixin.beforeObserver("sortProperties", function () {
this._lastSortAscending = undefined;
}),
- sortPropertiesDidChange: mixin.observer('sortProperties', function () {
+ sortPropertiesDidChange: mixin.observer("sortProperties", function () {
this._lastSortAscending = undefined;
}),
- sortAscendingWillChange: mixin.beforeObserver('sortAscending', function () {
- this._lastSortAscending = property_get.get(this, 'sortAscending');
+ sortAscendingWillChange: mixin.beforeObserver("sortAscending", function () {
+ this._lastSortAscending = property_get.get(this, "sortAscending");
}),
- sortAscendingDidChange: mixin.observer('sortAscending', function () {
- if (this._lastSortAscending !== undefined && property_get.get(this, 'sortAscending') !== this._lastSortAscending) {
- var arrangedContent = property_get.get(this, 'arrangedContent');
+ sortAscendingDidChange: mixin.observer("sortAscending", function () {
+ if (this._lastSortAscending !== undefined && property_get.get(this, "sortAscending") !== this._lastSortAscending) {
+ var arrangedContent = property_get.get(this, "arrangedContent");
arrangedContent.reverseObjects();
}
}),
contentArrayWillChange: function (array, idx, removedCount, addedCount) {
- var isSorted = property_get.get(this, 'isSorted');
+ var isSorted = property_get.get(this, "isSorted");
if (isSorted) {
- var arrangedContent = property_get.get(this, 'arrangedContent');
+ var arrangedContent = property_get.get(this, "arrangedContent");
var removedObjects = array.slice(idx, idx + removedCount);
- var sortProperties = property_get.get(this, 'sortProperties');
+ var sortProperties = property_get.get(this, "sortProperties");
enumerable_utils.forEach(removedObjects, function (item) {
arrangedContent.removeObject(item);
enumerable_utils.forEach(sortProperties, function (sortProperty) {
- observer.removeObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');
+ observer.removeObserver(item, sortProperty, this, "contentItemSortPropertyDidChange");
}, this);
}, this);
}
return this._super(array, idx, removedCount, addedCount);
},
contentArrayDidChange: function (array, idx, removedCount, addedCount) {
- var isSorted = property_get.get(this, 'isSorted');
- var sortProperties = property_get.get(this, 'sortProperties');
+ var isSorted = property_get.get(this, "isSorted");
+ var sortProperties = property_get.get(this, "sortProperties");
if (isSorted) {
var addedObjects = array.slice(idx, idx + addedCount);
enumerable_utils.forEach(addedObjects, function (item) {
this.insertItemSorted(item);
enumerable_utils.forEach(sortProperties, function (sortProperty) {
- observer.addObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');
+ observer.addObserver(item, sortProperty, this, "contentItemSortPropertyDidChange");
}, this);
}, this);
}
return this._super(array, idx, removedCount, addedCount);
},
insertItemSorted: function (item) {
- var arrangedContent = property_get.get(this, 'arrangedContent');
- var length = property_get.get(arrangedContent, 'length');
+ var arrangedContent = property_get.get(this, "arrangedContent");
+ var length = property_get.get(arrangedContent, "length");
var idx = this._binarySearch(item, 0, length);
arrangedContent.insertAt(idx, item);
},
contentItemSortPropertyDidChange: function (item) {
- var arrangedContent = property_get.get(this, 'arrangedContent');
+ var arrangedContent = property_get.get(this, "arrangedContent");
var oldIndex = arrangedContent.indexOf(item);
var leftItem = arrangedContent.objectAt(oldIndex - 1);
var rightItem = arrangedContent.objectAt(oldIndex + 1);
var leftResult = leftItem && this.orderBy(item, leftItem);
var rightResult = rightItem && this.orderBy(item, rightItem);
@@ -30001,11 +31286,11 @@
if (low === high) {
return low;
}
- arrangedContent = property_get.get(this, 'arrangedContent');
+ arrangedContent = property_get.get(this, "arrangedContent");
mid = low + Math.floor((high - low) / 2);
midItem = arrangedContent.objectAt(mid);
res = this.orderBy(midItem, item);
@@ -30019,11 +31304,11 @@
return mid;
}
});
});
-enifed('ember-runtime/mixins/target_action_support', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/utils', 'ember-metal/mixin', 'ember-metal/computed'], function (exports, Ember, property_get, utils, mixin, computed) {
+enifed('ember-runtime/mixins/target_action_support', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/mixin', 'ember-metal/computed'], function (exports, Ember, property_get, mixin, computed) {
'use strict';
/**
@module ember
@@ -30032,38 +31317,42 @@
var TargetActionSupport = mixin.Mixin.create({
target: null,
action: null,
actionContext: null,
- targetObject: computed.computed(function () {
- var target = property_get.get(this, 'target');
+ targetObject: computed.computed("target", function () {
+ if (this._targetObject) {
+ return this._targetObject;
+ }
- if (utils.typeOf(target) === "string") {
+ var target = property_get.get(this, "target");
+
+ if (typeof target === "string") {
var value = property_get.get(this, target);
if (value === undefined) {
value = property_get.get(Ember['default'].lookup, target);
}
return value;
} else {
return target;
}
- }).property('target'),
+ }),
actionContextObject: computed.computed(function () {
- var actionContext = property_get.get(this, 'actionContext');
+ var actionContext = property_get.get(this, "actionContext");
- if (utils.typeOf(actionContext) === "string") {
+ if (typeof actionContext === "string") {
var value = property_get.get(this, actionContext);
if (value === undefined) {
value = property_get.get(Ember['default'].lookup, actionContext);
}
return value;
} else {
return actionContext;
}
- }).property('actionContext'),
+ }).property("actionContext"),
/**
Send an `action` with an `actionContext` to a `target`. The action, actionContext
and target will be retrieved from properties of the object. For example:
```javascript
@@ -30109,12 +31398,12 @@
@param opts {Hash} (optional, with the optional keys action, target and/or actionContext)
@return {Boolean} true if the action was sent successfully and did not return false
*/
triggerAction: function (opts) {
opts = opts || {};
- var action = opts.action || property_get.get(this, 'action');
- var target = opts.target || property_get.get(this, 'targetObject');
+ var action = opts.action || property_get.get(this, "action");
+ var target = opts.target || property_get.get(this, "targetObject");
var actionContext = opts.actionContext;
function args(options, actionName) {
var ret = [];
if (actionName) {
@@ -30122,21 +31411,21 @@
}
return ret.concat(options);
}
- if (typeof actionContext === 'undefined') {
- actionContext = property_get.get(this, 'actionContextObject') || this;
+ if (typeof actionContext === "undefined") {
+ actionContext = property_get.get(this, "actionContextObject") || this;
}
if (target && action) {
var ret;
if (target.send) {
ret = target.send.apply(target, args(actionContext, action));
} else {
- Ember['default'].assert("The action '" + action + "' did not exist on " + target, typeof target[action] === 'function');
+ Ember['default'].assert("The action '" + action + "' did not exist on " + target, typeof target[action] === "function");
ret = target[action].apply(target, args(actionContext));
}
if (ret !== false) {
ret = true;
@@ -30157,11 +31446,11 @@
'use strict';
exports['default'] = Namespace['default'].extend();
});
-enifed('ember-runtime/system/array_proxy', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/utils', 'ember-metal/computed', 'ember-metal/mixin', 'ember-metal/property_events', 'ember-metal/error', 'ember-runtime/system/object', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/enumerable', 'ember-runtime/system/string', 'ember-metal/alias'], function (exports, Ember, property_get, utils, computed, mixin, property_events, EmberError, EmberObject, MutableArray, Enumerable, string, alias) {
+enifed('ember-runtime/system/array_proxy', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-runtime/utils', 'ember-metal/computed', 'ember-metal/mixin', 'ember-metal/property_events', 'ember-metal/error', 'ember-runtime/system/object', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/enumerable', 'ember-runtime/system/string', 'ember-metal/alias'], function (exports, Ember, property_get, utils, computed, mixin, property_events, EmberError, EmberObject, MutableArray, Enumerable, string, alias) {
'use strict';
var OUT_OF_RANGE_EXCEPTION = "Index out of range";
var EMPTY = [];
@@ -30222,11 +31511,11 @@
The array that the proxy pretends to be. In the default `ArrayProxy`
implementation, this and `content` are the same. Subclasses of `ArrayProxy`
can override this property to provide things like sorting and filtering.
@property arrangedContent
*/
- arrangedContent: alias['default']('content'),
+ arrangedContent: alias['default']("content"),
/**
Should actually retrieve the object at the specified index from the
content. You can override this method in subclasses to transform the
content item to something new.
@@ -30234,11 +31523,11 @@
@method objectAtContent
@param {Number} idx The index to retrieve.
@return {Object} the value or undefined if none found
*/
objectAtContent: function (idx) {
- return property_get.get(this, 'arrangedContent').objectAt(idx);
+ return property_get.get(this, "arrangedContent").objectAt(idx);
},
/**
Should actually replace the specified objects on the content array.
You can override this method in subclasses to transform the content item
@@ -30250,30 +31539,30 @@
@param {Array} objects Optional array of objects to insert or null if no
objects.
@return {void}
*/
replaceContent: function (idx, amt, objects) {
- property_get.get(this, 'content').replace(idx, amt, objects);
+ property_get.get(this, "content").replace(idx, amt, objects);
},
/**
Invoked when the content property is about to change. Notifies observers that the
entire array content will change.
@private
@method _contentWillChange
*/
- _contentWillChange: mixin.beforeObserver('content', function () {
+ _contentWillChange: mixin.beforeObserver("content", function () {
this._teardownContent();
}),
_teardownContent: function () {
- var content = property_get.get(this, 'content');
+ var content = property_get.get(this, "content");
if (content) {
content.removeArrayObserver(this, {
- willChange: 'contentArrayWillChange',
- didChange: 'contentArrayDidChange'
+ willChange: "contentArrayWillChange",
+ didChange: "contentArrayDidChange"
});
}
},
/**
@@ -30299,133 +31588,133 @@
Invoked when the content property changes. Notifies observers that the
entire array content has changed.
@private
@method _contentDidChange
*/
- _contentDidChange: mixin.observer('content', function () {
- var content = property_get.get(this, 'content');
+ _contentDidChange: mixin.observer("content", function () {
+ var content = property_get.get(this, "content");
Ember['default'].assert("Can't set ArrayProxy's content to itself", content !== this);
this._setupContent();
}),
_setupContent: function () {
- var content = property_get.get(this, 'content');
+ var content = property_get.get(this, "content");
if (content) {
- Ember['default'].assert(string.fmt('ArrayProxy expects an Array or ' + 'Ember.ArrayProxy, but you passed %@', [typeof content]), utils.isArray(content) || content.isDestroyed);
+ Ember['default'].assert(string.fmt("ArrayProxy expects an Array or " + "Ember.ArrayProxy, but you passed %@", [typeof content]), utils.isArray(content) || content.isDestroyed);
content.addArrayObserver(this, {
- willChange: 'contentArrayWillChange',
- didChange: 'contentArrayDidChange'
+ willChange: "contentArrayWillChange",
+ didChange: "contentArrayDidChange"
});
}
},
- _arrangedContentWillChange: mixin.beforeObserver('arrangedContent', function () {
- var arrangedContent = property_get.get(this, 'arrangedContent');
- var len = arrangedContent ? property_get.get(arrangedContent, 'length') : 0;
+ _arrangedContentWillChange: mixin.beforeObserver("arrangedContent", function () {
+ var arrangedContent = property_get.get(this, "arrangedContent");
+ var len = arrangedContent ? property_get.get(arrangedContent, "length") : 0;
this.arrangedContentArrayWillChange(this, 0, len, undefined);
this.arrangedContentWillChange(this);
this._teardownArrangedContent(arrangedContent);
}),
- _arrangedContentDidChange: mixin.observer('arrangedContent', function () {
- var arrangedContent = property_get.get(this, 'arrangedContent');
- var len = arrangedContent ? property_get.get(arrangedContent, 'length') : 0;
+ _arrangedContentDidChange: mixin.observer("arrangedContent", function () {
+ var arrangedContent = property_get.get(this, "arrangedContent");
+ var len = arrangedContent ? property_get.get(arrangedContent, "length") : 0;
Ember['default'].assert("Can't set ArrayProxy's content to itself", arrangedContent !== this);
this._setupArrangedContent();
this.arrangedContentDidChange(this);
this.arrangedContentArrayDidChange(this, 0, undefined, len);
}),
_setupArrangedContent: function () {
- var arrangedContent = property_get.get(this, 'arrangedContent');
+ var arrangedContent = property_get.get(this, "arrangedContent");
if (arrangedContent) {
- Ember['default'].assert(string.fmt('ArrayProxy expects an Array or ' + 'Ember.ArrayProxy, but you passed %@', [typeof arrangedContent]), utils.isArray(arrangedContent) || arrangedContent.isDestroyed);
+ Ember['default'].assert(string.fmt("ArrayProxy expects an Array or " + "Ember.ArrayProxy, but you passed %@", [typeof arrangedContent]), utils.isArray(arrangedContent) || arrangedContent.isDestroyed);
arrangedContent.addArrayObserver(this, {
- willChange: 'arrangedContentArrayWillChange',
- didChange: 'arrangedContentArrayDidChange'
+ willChange: "arrangedContentArrayWillChange",
+ didChange: "arrangedContentArrayDidChange"
});
}
},
_teardownArrangedContent: function () {
- var arrangedContent = property_get.get(this, 'arrangedContent');
+ var arrangedContent = property_get.get(this, "arrangedContent");
if (arrangedContent) {
arrangedContent.removeArrayObserver(this, {
- willChange: 'arrangedContentArrayWillChange',
- didChange: 'arrangedContentArrayDidChange'
+ willChange: "arrangedContentArrayWillChange",
+ didChange: "arrangedContentArrayDidChange"
});
}
},
arrangedContentWillChange: K,
arrangedContentDidChange: K,
objectAt: function (idx) {
- return property_get.get(this, 'content') && this.objectAtContent(idx);
+ return property_get.get(this, "content") && this.objectAtContent(idx);
},
length: computed.computed(function () {
- var arrangedContent = property_get.get(this, 'arrangedContent');
- return arrangedContent ? property_get.get(arrangedContent, 'length') : 0;
+ var arrangedContent = property_get.get(this, "arrangedContent");
+ return arrangedContent ? property_get.get(arrangedContent, "length") : 0;
// No dependencies since Enumerable notifies length of change
}),
_replace: function (idx, amt, objects) {
- var content = property_get.get(this, 'content');
- Ember['default'].assert('The content property of ' + this.constructor + ' should be set before modifying it', content);
+ var content = property_get.get(this, "content");
+ Ember['default'].assert("The content property of " + this.constructor + " should be set before modifying it", content);
if (content) {
this.replaceContent(idx, amt, objects);
}
return this;
},
replace: function () {
- if (property_get.get(this, 'arrangedContent') === property_get.get(this, 'content')) {
+ if (property_get.get(this, "arrangedContent") === property_get.get(this, "content")) {
this._replace.apply(this, arguments);
} else {
throw new EmberError['default']("Using replace on an arranged ArrayProxy is not allowed.");
}
},
_insertAt: function (idx, object) {
- if (idx > property_get.get(this, 'content.length')) {
+ if (idx > property_get.get(this, "content.length")) {
throw new EmberError['default'](OUT_OF_RANGE_EXCEPTION);
}
this._replace(idx, 0, [object]);
return this;
},
insertAt: function (idx, object) {
- if (property_get.get(this, 'arrangedContent') === property_get.get(this, 'content')) {
+ if (property_get.get(this, "arrangedContent") === property_get.get(this, "content")) {
return this._insertAt(idx, object);
} else {
throw new EmberError['default']("Using insertAt on an arranged ArrayProxy is not allowed.");
}
},
removeAt: function (start, len) {
- if ('number' === typeof start) {
- var content = property_get.get(this, 'content');
- var arrangedContent = property_get.get(this, 'arrangedContent');
+ if ("number" === typeof start) {
+ var content = property_get.get(this, "content");
+ var arrangedContent = property_get.get(this, "arrangedContent");
var indices = [];
var i;
- if (start < 0 || start >= property_get.get(this, 'length')) {
+ if (start < 0 || start >= property_get.get(this, "length")) {
throw new EmberError['default'](OUT_OF_RANGE_EXCEPTION);
}
if (len === undefined) {
len = 1;
@@ -30451,28 +31740,28 @@
return this;
},
pushObject: function (obj) {
- this._insertAt(property_get.get(this, 'content.length'), obj);
+ this._insertAt(property_get.get(this, "content.length"), obj);
return obj;
},
pushObjects: function (objects) {
if (!(Enumerable['default'].detect(objects) || utils.isArray(objects))) {
throw new TypeError("Must pass Ember.Enumerable to Ember.MutableArray#pushObjects");
}
- this._replace(property_get.get(this, 'length'), 0, objects);
+ this._replace(property_get.get(this, "length"), 0, objects);
return this;
},
setObjects: function (objects) {
if (objects.length === 0) {
return this.clear();
}
- var len = property_get.get(this, 'length');
+ var len = property_get.get(this, "length");
this._replace(0, len, objects);
return this;
},
unshiftObject: function (obj) {
@@ -30577,11 +31866,11 @@
for (var i = 0, l = props.length; i < l; i++) {
var properties = props[i];
Ember['default'].assert("Ember.Object.create no longer supports mixing in other definitions, use createWithMixins instead.", !(properties instanceof mixin.Mixin));
- if (typeof properties !== 'object' && properties !== undefined) {
+ if (typeof properties !== "object" && properties !== undefined) {
throw new EmberError['default']("Ember.Object.create only accepts objects.");
}
if (!properties) {
continue;
@@ -30595,28 +31884,28 @@
if (mixin.IS_BINDING.test(keyName)) {
var bindings = m.bindings;
if (!bindings) {
bindings = m.bindings = {};
- } else if (!m.hasOwnProperty('bindings')) {
+ } else if (!m.hasOwnProperty("bindings")) {
bindings = m.bindings = o_create['default'](m.bindings);
}
bindings[keyName] = value;
}
var possibleDesc = this[keyName];
- var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
+ var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined;
Ember['default'].assert("Ember.Object.create no longer supports defining computed properties. Define computed properties using extend() or reopen() before calling create().", !(value instanceof computed.ComputedProperty));
- Ember['default'].assert("Ember.Object.create no longer supports defining methods that call _super.", !(typeof value === 'function' && value.toString().indexOf('._super') !== -1));
- Ember['default'].assert("`actions` must be provided at extend time, not at create " + "time, when Ember.ActionHandler is used (i.e. views, " + "controllers & routes).", !(keyName === 'actions' && ActionHandler['default'].detect(this)));
+ Ember['default'].assert("Ember.Object.create no longer supports defining methods that call _super.", !(typeof value === "function" && value.toString().indexOf("._super") !== -1));
+ Ember['default'].assert("`actions` must be provided at extend time, not at create " + "time, when Ember.ActionHandler is used (i.e. views, " + "controllers & routes).", !(keyName === "actions" && ActionHandler['default'].detect(this)));
if (concatenatedProperties && concatenatedProperties.length > 0 && enumerable_utils.indexOf(concatenatedProperties, keyName) >= 0) {
var baseValue = this[keyName];
if (baseValue) {
- if ('function' === typeof baseValue.concat) {
+ if ("function" === typeof baseValue.concat) {
value = baseValue.concat(value);
} else {
value = utils.makeArray(baseValue).concat(value);
}
} else {
@@ -30631,19 +31920,19 @@
}
if (desc) {
desc.set(this, keyName, value);
} else {
- if (typeof this.setUnknownProperty === 'function' && !(keyName in this)) {
+ if (typeof this.setUnknownProperty === "function" && !(keyName in this)) {
this.setUnknownProperty(keyName, value);
} else {
if (define_property.hasPropertyAccessors) {
ember_metal__properties.defineProperty(this, keyName, null, value); // setup mandatory setter
} else {
- this[keyName] = value;
- }
+ this[keyName] = value;
+ }
}
}
}
}
}
@@ -30666,11 +31955,11 @@
this.init.apply(this, args);
}
m.proto = proto;
chains.finishChains(this);
- events.sendEvent(this, 'init');
+ events.sendEvent(this, "init");
};
Class.toString = mixin.Mixin.prototype.toString;
Class.willReopen = function () {
if (wasApplied) {
@@ -30837,12 +32126,12 @@
if (this.isDestroying) {
return;
}
this.isDestroying = true;
- schedule('actions', this, this.willDestroy);
- schedule('destroy', this, this._scheduledDestroy);
+ schedule("actions", this, this.willDestroy);
+ schedule("destroy", this, this._scheduledDestroy);
return this;
},
/**
Override to implement teardown.
@@ -30901,13 +32190,13 @@
```
@method toString
@return {String} string representation
*/
toString: function () {
- var hasToStringExtension = typeof this.toStringExtension === 'function';
- var extension = hasToStringExtension ? ":" + this.toStringExtension() : '';
- var ret = '<' + this.constructor.toString() + ':' + utils.guidFor(this) + extension + '>';
+ var hasToStringExtension = typeof this.toStringExtension === "function";
+ var extension = hasToStringExtension ? ":" + this.toStringExtension() : "";
+ var ret = "<" + this.constructor.toString() + ":" + utils.guidFor(this) + extension + ">";
this.toString = makeToString(ret);
return ret;
}
});
@@ -31024,16 +32313,15 @@
@method createWithMixins
@static
@param [arguments]*
*/
createWithMixins: function () {
- var C = this;
-
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
+ var C = this;
if (args.length > 0) {
this._initMixins(args);
}
return new C();
},
@@ -31066,16 +32354,15 @@
@method create
@static
@param [arguments]*
*/
create: function () {
- var C = this;
-
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
+ var C = this;
if (args.length > 0) {
this._initProperties(args);
}
return new C();
},
@@ -31157,11 +32444,11 @@
applyMixin(this, arguments, false);
return this;
},
detect: function (obj) {
- if ('function' !== typeof obj) {
+ if ("function" !== typeof obj) {
return false;
}
while (obj) {
if (obj === this) {
return true;
@@ -31198,11 +32485,11 @@
@param key {String} property name
*/
metaForProperty: function (key) {
var proto = this.proto();
var possibleDesc = proto[key];
- var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
+ var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined;
Ember['default'].assert("metaForProperty() could not find a computed property with key '" + key + "'.", !!desc && desc instanceof computed.ComputedProperty);
return desc._meta || {};
},
@@ -31235,11 +32522,11 @@
*/
eachComputedProperty: function (callback, binding) {
var property, name;
var empty = {};
- var properties = property_get.get(this, '_computedProperties');
+ var properties = property_get.get(this, "_computedProperties");
for (var i = 0, length = properties.length; i < length; i++) {
property = properties[i];
name = property.name;
callback.call(binding || this, property.name, property.meta || empty);
@@ -31273,11 +32560,11 @@
var key, desc;
for (key in proto) {
desc = proto[key];
if (desc instanceof InjectedProperty['default']) {
- injections[key] = desc.type + ':' + (desc.name || key);
+ injections[key] = desc.type + ":" + (desc.name || key);
}
}
return injections;
};
@@ -31312,11 +32599,11 @@
'use strict';
var Deferred = EmberObject['default'].extend(DeferredMixin['default'], {
init: function () {
- Ember['default'].deprecate('Usage of Ember.Deferred is deprecated.', false, { url: 'http://emberjs.com/guides/deprecations/#toc_deprecate-ember-deferredmixin-and-ember-deferred' });
+ Ember['default'].deprecate("Usage of Ember.Deferred is deprecated.", false, { url: "http://emberjs.com/guides/deprecations/#toc_deprecate-ember-deferredmixin-and-ember-deferred" });
this._super.apply(this, arguments);
}
});
Deferred.reopenClass({
@@ -31328,11 +32615,11 @@
});
exports['default'] = Deferred;
});
-enifed('ember-runtime/system/each_proxy', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/utils', 'ember-metal/enumerable_utils', 'ember-metal/array', 'ember-runtime/mixins/array', 'ember-runtime/system/object', 'ember-metal/computed', 'ember-metal/observer', 'ember-metal/events', 'ember-metal/properties', 'ember-metal/property_events'], function (exports, Ember, property_get, utils, enumerable_utils, array, EmberArray, EmberObject, computed, observer, events, properties, property_events) {
+enifed('ember-runtime/system/each_proxy', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/utils', 'ember-runtime/utils', 'ember-metal/enumerable_utils', 'ember-metal/array', 'ember-runtime/mixins/array', 'ember-runtime/system/object', 'ember-metal/computed', 'ember-metal/observer', 'ember-metal/events', 'ember-metal/properties', 'ember-metal/property_events'], function (exports, Ember, property_get, utils, ember_runtime__utils, enumerable_utils, array, EmberArray, EmberObject, computed, observer, events, properties, property_events) {
'use strict';
/**
@module ember
@@ -31353,11 +32640,11 @@
return item && property_get.get(item, this._keyName);
},
length: computed.computed(function () {
var content = this._content;
- return content ? property_get.get(content, 'length') : 0;
+ return content ? property_get.get(content, "length") : 0;
})
});
var IS_OBSERVER = /^.+:(before|change)$/;
@@ -31370,13 +32657,13 @@
}
while (--loc >= idx) {
var item = content.objectAt(loc);
if (item) {
- Ember['default'].assert('When using @each to observe the array ' + content + ', the array must return an object', utils.typeOf(item) === 'instance' || utils.typeOf(item) === 'object');
- observer.addBeforeObserver(item, keyName, proxy, 'contentKeyWillChange');
- observer.addObserver(item, keyName, proxy, 'contentKeyDidChange');
+ Ember['default'].assert("When using @each to observe the array " + content + ", the array must return an object", ember_runtime__utils.typeOf(item) === "instance" || ember_runtime__utils.typeOf(item) === "object");
+ observer.addBeforeObserver(item, keyName, proxy, "contentKeyWillChange");
+ observer.addObserver(item, keyName, proxy, "contentKeyDidChange");
// keep track of the index each item was found at so we can map
// it back when the obj changes.
guid = utils.guidFor(item);
if (!objects[guid]) {
@@ -31397,12 +32684,12 @@
var indices, guid;
while (--loc >= idx) {
var item = content.objectAt(loc);
if (item) {
- observer.removeBeforeObserver(item, keyName, proxy, 'contentKeyWillChange');
- observer.removeObserver(item, keyName, proxy, 'contentKeyDidChange');
+ observer.removeBeforeObserver(item, keyName, proxy, "contentKeyWillChange");
+ observer.removeObserver(item, keyName, proxy, "contentKeyDidChange");
guid = utils.guidFor(item);
indices = objects[guid];
indices[array.indexOf.call(indices, loc)] = null;
}
@@ -31463,11 +32750,11 @@
}
property_events.propertyWillChange(this, key);
}
- property_events.propertyWillChange(this._content, '@each');
+ property_events.propertyWillChange(this._content, "@each");
property_events.endPropertyChanges(this);
},
arrayDidChange: function (content, idx, removedCnt, addedCnt) {
var keys = this._keys;
@@ -31485,11 +32772,11 @@
}
property_events.propertyDidChange(this, key);
}
- property_events.propertyDidChange(this._content, '@each');
+ property_events.propertyDidChange(this._content, "@each");
}, this);
},
// ..........................................................
// LISTEN FOR NEW OBSERVERS AND OTHER EVENT LISTENERS
@@ -31518,11 +32805,11 @@
}
if (!keys[keyName]) {
keys[keyName] = 1;
var content = this._content;
- var len = property_get.get(content, 'length');
+ var len = property_get.get(content, "length");
addObserverForContentKey(content, keyName, this, 0, len);
} else {
keys[keyName]++;
}
@@ -31530,11 +32817,11 @@
stopObservingContentKey: function (keyName) {
var keys = this._keys;
if (keys && keys[keyName] > 0 && --keys[keyName] <= 0) {
var content = this._content;
- var len = property_get.get(content, 'length');
+ var len = property_get.get(content, "length");
removeObserverForContentKey(content, keyName, this, 0, len);
}
},
@@ -31556,13 +32843,10 @@
'use strict';
exports.onLoad = onLoad;
exports.runLoadHooks = runLoadHooks;
- var loadHooks = Ember['default'].ENV.EMBER_LOAD_HOOKS || {};
- var loaded = {};
-
/**
Detects when a specific package of Ember (e.g. 'Ember.Handlebars')
has fully loaded and is available for extension.
The provided `callback` will be called with the `name` passed
@@ -31577,11 +32861,12 @@
@method onLoad
@for Ember
@param name {String} name of hook
@param callback {Function} callback to be called
*/
-
+ var loadHooks = Ember['default'].ENV.EMBER_LOAD_HOOKS || {};
+ var loaded = {};
function onLoad(name, callback) {
var object;
loadHooks[name] = loadHooks[name] || Ember['default'].A();
loadHooks[name].pushObject(callback);
@@ -31589,24 +32874,14 @@
if (object = loaded[name]) {
callback(object);
}
}
- /**
- Called when an Ember.js package (e.g Ember.Handlebars) has finished
- loading. Triggers any callbacks registered for this event.
-
- @method runLoadHooks
- @for Ember
- @param name {String} name of hook
- @param object {Object} object to pass to callbacks
- */
-
function runLoadHooks(name, object) {
loaded[name] = object;
- if (typeof window === 'object' && typeof window.dispatchEvent === 'function' && typeof CustomEvent === "function") {
+ if (typeof window === "object" && typeof window.dispatchEvent === "function" && typeof CustomEvent === "function") {
var event = new CustomEvent(name, { detail: object, name: name });
window.dispatchEvent(event);
}
if (loadHooks[name]) {
@@ -31634,11 +32909,11 @@
Namespace.NAMESPACES.push(this);
Namespace.PROCESSED = false;
},
toString: function () {
- var name = property_get.get(this, 'name') || property_get.get(this, 'modulePrefix');
+ var name = property_get.get(this, "name") || property_get.get(this, "modulePrefix");
if (name) {
return name;
}
findNamespaces();
@@ -31681,11 +32956,11 @@
var hasOwnProp = ({}).hasOwnProperty;
function processNamespace(paths, root, seen) {
var idx = paths.length;
- NAMESPACES_BY_ID[paths.join('.')] = root;
+ NAMESPACES_BY_ID[paths.join(".")] = root;
// Loop over all of the keys in the namespace, looking for classes
for (var key in root) {
if (!hasOwnProp.call(root, key)) {
continue;
@@ -31701,24 +32976,24 @@
// If we have found an unprocessed class
if (obj && obj.toString === classToString) {
// Replace the class' `toString` with the dot-separated path
// and set its `NAME_KEY`
- obj.toString = makeToString(paths.join('.'));
- obj[NAME_KEY] = paths.join('.');
+ obj.toString = makeToString(paths.join("."));
+ obj[NAME_KEY] = paths.join(".");
// Support nested namespaces
} else if (obj && obj.isNamespace) {
- // Skip aliased namespaces
- if (seen[utils.guidFor(obj)]) {
- continue;
- }
- seen[utils.guidFor(obj)] = true;
-
- // Process the child namespace
- processNamespace(paths, obj, seen);
+ // Skip aliased namespaces
+ if (seen[utils.guidFor(obj)]) {
+ continue;
}
+ seen[utils.guidFor(obj)] = true;
+
+ // Process the child namespace
+ processNamespace(paths, obj, seen);
+ }
}
paths.length = idx; // cut out last item
}
@@ -31726,13 +33001,11 @@
function tryIsNamespace(lookup, prop) {
try {
var obj = lookup[prop];
return obj && obj.isNamespace && obj;
- } catch (e) {
- // continue
- }
+ } catch (e) {}
}
function findNamespaces() {
var lookup = Ember['default'].lookup;
var obj;
@@ -31759,11 +33032,11 @@
obj[NAME_KEY] = prop;
}
}
}
- var NAME_KEY = Ember['default'].NAME_KEY = utils.GUID_KEY + '_name';
+ var NAME_KEY = Ember['default'].NAME_KEY = utils.GUID_KEY + "_name";
function superClassString(mixin) {
var superclass = mixin.superclass;
if (superclass) {
if (superclass[NAME_KEY]) {
@@ -31830,10 +33103,12 @@
ember_metal__mixin.Mixin.prototype.toString = classToString; // ES6TODO: altering imported objects. SBB.
exports['default'] = Namespace;
+ // continue
+
});
enifed('ember-runtime/system/native_array', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/enumerable_utils', 'ember-metal/mixin', 'ember-metal/array', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/freezable', 'ember-runtime/copy'], function (exports, Ember, property_get, enumerable_utils, mixin, array, EmberArray, MutableArray, Observable, Copyable, freezable, copy) {
'use strict';
@@ -31845,13 +33120,13 @@
var NativeArray = mixin.Mixin.create(MutableArray['default'], Observable['default'], Copyable['default'], {
// because length is a built-in property we need to know to just get the
// original property.
get: function (key) {
- if (key === 'length') {
+ if (key === "length") {
return this.length;
- } else if ('number' === typeof key) {
+ } else if ("number" === typeof key) {
return this[key];
} else {
return this._super(key);
}
},
@@ -31868,11 +33143,11 @@
}
// if we replaced exactly the same number of items, then pass only the
// replaced range. Otherwise, pass the full remaining array length
// since everything has shifted
- var len = objects ? property_get.get(objects, 'length') : 0;
+ var len = objects ? property_get.get(objects, "length") : 0;
this.arrayContentWillChange(idx, amt, len);
if (len === 0) {
this.splice(idx, amt);
} else {
@@ -31907,11 +33182,11 @@
return this.slice();
}
});
// Remove any methods implemented natively so we don't override them
- var ignore = ['length'];
+ var ignore = ["length"];
enumerable_utils.forEach(NativeArray.keys(), function (methodName) {
if (Array.prototype[methodName]) {
ignore.push(methodName);
}
});
@@ -32067,31 +33342,31 @@
clear: function () {
if (this.isFrozen) {
throw new EmberError['default'](freezable.FROZEN_ERROR);
}
- var len = property_get.get(this, 'length');
+ var len = property_get.get(this, "length");
if (len === 0) {
return this;
}
var guid;
this.enumerableContentWillChange(len, 0);
- property_events.propertyWillChange(this, 'firstObject');
- property_events.propertyWillChange(this, 'lastObject');
+ property_events.propertyWillChange(this, "firstObject");
+ property_events.propertyWillChange(this, "lastObject");
for (var i = 0; i < len; i++) {
guid = utils.guidFor(this[i]);
delete this[guid];
delete this[i];
}
- property_set.set(this, 'length', 0);
+ property_set.set(this, "length", 0);
- property_events.propertyDidChange(this, 'firstObject');
- property_events.propertyDidChange(this, 'lastObject');
+ property_events.propertyDidChange(this, "firstObject");
+ property_events.propertyDidChange(this, "lastObject");
this.enumerableContentDidChange(len, 0);
return this;
},
@@ -32112,12 +33387,12 @@
// fail fast
if (!Enumerable['default'].detect(obj)) {
return false;
}
- var loc = property_get.get(this, 'length');
- if (property_get.get(obj, 'length') !== loc) {
+ var loc = property_get.get(this, "length");
+ if (property_get.get(obj, "length") !== loc) {
return false;
}
while (--loc >= 0) {
if (!obj.contains(this[loc])) {
@@ -32143,11 +33418,11 @@
```
@method add
@param {Object} obj The object to add.
@return {Ember.Set} The set itself.
*/
- add: mixin.aliasMethod('addObject'),
+ add: mixin.aliasMethod("addObject"),
/**
Removes the object from the set if it is found. If you pass a `null` value
or an object that is already not in the set, this method will have no
effect. This is an alias for `Ember.MutableEnumerable.removeObject()`.
@@ -32159,11 +33434,11 @@
```
@method remove
@param {Object} obj The object to remove
@return {Ember.Set} The set itself.
*/
- remove: mixin.aliasMethod('removeObject'),
+ remove: mixin.aliasMethod("removeObject"),
/**
Removes the last element from the set and returns it, or `null` if it's empty.
```javascript
var colors = new Ember.Set(["green", "blue"]);
@@ -32173,11 +33448,11 @@
```
@method pop
@return {Object} The removed object from the set or null.
*/
pop: function () {
- if (property_get.get(this, 'isFrozen')) {
+ if (property_get.get(this, "isFrozen")) {
throw new EmberError['default'](freezable.FROZEN_ERROR);
}
var obj = this.length > 0 ? this[this.length - 1] : null;
this.remove(obj);
@@ -32195,11 +33470,11 @@
colors.push("blue"); // ["red", "green", "blue"]
```
@method push
@return {Ember.Set} The set itself.
*/
- push: mixin.aliasMethod('addObject'),
+ push: mixin.aliasMethod("addObject"),
/**
Removes the last element from the set and returns it, or `null` if it's empty.
This is an alias for `Ember.Set.pop()`.
```javascript
@@ -32209,11 +33484,11 @@
colors.shift(); // null
```
@method shift
@return {Object} The removed object from the set or null.
*/
- shift: mixin.aliasMethod('pop'),
+ shift: mixin.aliasMethod("pop"),
/**
Inserts the given object on to the end of the set. It returns
the set itself.
This is an alias of `Ember.Set.push()`
@@ -32224,11 +33499,11 @@
colors.unshift("blue"); // ["red", "green", "blue"]
```
@method unshift
@return {Ember.Set} The set itself.
*/
- unshift: mixin.aliasMethod('push'),
+ unshift: mixin.aliasMethod("push"),
/**
Adds each object in the passed enumerable to the set.
This is an alias of `Ember.MutableEnumerable.addObjects()`
```javascript
@@ -32237,11 +33512,11 @@
```
@method addEach
@param {Ember.Enumerable} objects the objects to add.
@return {Ember.Set} The set itself.
*/
- addEach: mixin.aliasMethod('addObjects'),
+ addEach: mixin.aliasMethod("addObjects"),
/**
Removes each object in the passed enumerable to the set.
This is an alias of `Ember.MutableEnumerable.removeObjects()`
```javascript
@@ -32250,18 +33525,18 @@
```
@method removeEach
@param {Ember.Enumerable} objects the objects to remove.
@return {Ember.Set} The set itself.
*/
- removeEach: mixin.aliasMethod('removeObjects'),
+ removeEach: mixin.aliasMethod("removeObjects"),
// ..........................................................
// PRIVATE ENUMERABLE SUPPORT
//
init: function (items) {
- Ember['default'].deprecate('Ember.Set is deprecated and will be removed in a future release.');
+ Ember['default'].deprecate("Ember.Set is deprecated and will be removed in a future release.");
this._super.apply(this, arguments);
if (items) {
this.addObjects(items);
}
@@ -32282,69 +33557,69 @@
return this.length > 0 ? this[this.length - 1] : undefined;
}),
// implements Ember.MutableEnumerable
addObject: function (obj) {
- if (property_get.get(this, 'isFrozen')) {
+ if (property_get.get(this, "isFrozen")) {
throw new EmberError['default'](freezable.FROZEN_ERROR);
}
if (isNone['default'](obj)) {
return this; // nothing to do
}
var guid = utils.guidFor(obj);
var idx = this[guid];
- var len = property_get.get(this, 'length');
+ var len = property_get.get(this, "length");
var added;
if (idx >= 0 && idx < len && this[idx] === obj) {
return this; // added
}
added = [obj];
this.enumerableContentWillChange(null, added);
- property_events.propertyWillChange(this, 'lastObject');
+ property_events.propertyWillChange(this, "lastObject");
- len = property_get.get(this, 'length');
+ len = property_get.get(this, "length");
this[guid] = len;
this[len] = obj;
- property_set.set(this, 'length', len + 1);
+ property_set.set(this, "length", len + 1);
- property_events.propertyDidChange(this, 'lastObject');
+ property_events.propertyDidChange(this, "lastObject");
this.enumerableContentDidChange(null, added);
return this;
},
// implements Ember.MutableEnumerable
removeObject: function (obj) {
- if (property_get.get(this, 'isFrozen')) {
+ if (property_get.get(this, "isFrozen")) {
throw new EmberError['default'](freezable.FROZEN_ERROR);
}
if (isNone['default'](obj)) {
return this; // nothing to do
}
var guid = utils.guidFor(obj);
var idx = this[guid];
- var len = property_get.get(this, 'length');
+ var len = property_get.get(this, "length");
var isFirst = idx === 0;
var isLast = idx === len - 1;
var last, removed;
if (idx >= 0 && idx < len && this[idx] === obj) {
removed = [obj];
this.enumerableContentWillChange(removed, null);
if (isFirst) {
- property_events.propertyWillChange(this, 'firstObject');
+ property_events.propertyWillChange(this, "firstObject");
}
if (isLast) {
- property_events.propertyWillChange(this, 'lastObject');
+ property_events.propertyWillChange(this, "lastObject");
}
// swap items - basically move the item to the end so it can be removed
if (idx < len - 1) {
last = this[len - 1];
@@ -32352,17 +33627,17 @@
this[utils.guidFor(last)] = idx;
}
delete this[guid];
delete this[len - 1];
- property_set.set(this, 'length', len - 1);
+ property_set.set(this, "length", len - 1);
if (isFirst) {
- property_events.propertyDidChange(this, 'firstObject');
+ property_events.propertyDidChange(this, "firstObject");
}
if (isLast) {
- property_events.propertyDidChange(this, 'lastObject');
+ property_events.propertyDidChange(this, "lastObject");
}
this.enumerableContentDidChange(removed, null);
}
return this;
@@ -32374,13 +33649,13 @@
},
copy: function () {
var C = this.constructor;
var ret = new C();
- var loc = property_get.get(this, 'length');
+ var loc = property_get.get(this, "length");
- property_set.set(ret, 'length', loc);
+ property_set.set(ret, "length", loc);
while (--loc >= 0) {
ret[loc] = this[loc];
ret[utils.guidFor(this[loc])] = loc;
}
return ret;
@@ -32392,16 +33667,16 @@
var idx;
for (idx = 0; idx < len; idx++) {
array[idx] = this[idx];
}
- return string.fmt("Ember.Set<%@>", [array.join(',')]);
+ return string.fmt("Ember.Set<%@>", [array.join(",")]);
}
});
});
-enifed('ember-runtime/system/string', ['exports', 'ember-metal/core', 'ember-metal/utils', 'ember-metal/cache'], function (exports, Ember, utils, Cache) {
+enifed('ember-runtime/system/string', ['exports', 'ember-metal/core', 'ember-metal/utils', 'ember-runtime/utils', 'ember-metal/cache'], function (exports, Ember, utils, ember_runtime__utils, Cache) {
'use strict';
exports.fmt = fmt;
exports.loc = loc;
@@ -32418,16 +33693,16 @@
@submodule ember-runtime
*/
var STRING_DASHERIZE_REGEXP = /[ _]/g;
var STRING_DASHERIZE_CACHE = new Cache['default'](1000, function (key) {
- return decamelize(key).replace(STRING_DASHERIZE_REGEXP, '-');
+ return decamelize(key).replace(STRING_DASHERIZE_REGEXP, "-");
});
var CAMELIZE_CACHE = new Cache['default'](1000, function (key) {
return key.replace(STRING_CAMELIZE_REGEXP, function (match, separator, chr) {
- return chr ? chr.toUpperCase() : '';
+ return chr ? chr.toUpperCase() : "";
}).replace(/^([A-Z])/, function (match, separator, chr) {
return match.toLowerCase();
});
});
@@ -32442,30 +33717,30 @@
return out.join(".");
});
var UNDERSCORE_CACHE = new Cache['default'](1000, function (str) {
- return str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase();
+ return str.replace(STRING_UNDERSCORE_REGEXP_1, "$1_$2").replace(STRING_UNDERSCORE_REGEXP_2, "_").toLowerCase();
});
var CAPITALIZE_CACHE = new Cache['default'](1000, function (str) {
return str.charAt(0).toUpperCase() + str.substr(1);
});
var DECAMELIZE_CACHE = new Cache['default'](1000, function (str) {
- return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase();
+ return str.replace(STRING_DECAMELIZE_REGEXP, "$1_$2").toLowerCase();
});
var STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
var STRING_CAMELIZE_REGEXP = /(\-|_|\.|\s)+(.)?/g;
var STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g;
var STRING_UNDERSCORE_REGEXP_2 = /\-|\s+/g;
function fmt(str, formats) {
var cachedFormats = formats;
- if (!utils.isArray(cachedFormats) || arguments.length > 2) {
+ if (!ember_runtime__utils.isArray(cachedFormats) || arguments.length > 2) {
cachedFormats = new Array(arguments.length - 1);
for (var i = 1, l = arguments.length; i < l; i++) {
cachedFormats[i - 1] = arguments[i];
}
@@ -32474,16 +33749,16 @@
// first, replace any ORDERED replacements.
var idx = 0; // the current index for non-numerical replacements
return str.replace(/%@([0-9]+)?/g, function (s, argIndex) {
argIndex = argIndex ? parseInt(argIndex, 10) - 1 : idx++;
s = cachedFormats[argIndex];
- return s === null ? '(null)' : s === undefined ? '' : utils.inspect(s);
+ return s === null ? "(null)" : s === undefined ? "" : utils.inspect(s);
});
}
function loc(str, formats) {
- if (!utils.isArray(formats) || arguments.length > 2) {
+ if (!ember_runtime__utils.isArray(formats) || arguments.length > 2) {
formats = Array.prototype.slice.call(arguments, 1);
}
str = Ember['default'].STRINGS[str] || str;
return fmt(str, formats);
@@ -32687,12 +33962,12 @@
});
enifed('ember-runtime/system/subarray', ['exports', 'ember-metal/error', 'ember-metal/enumerable_utils'], function (exports, EmberError, EnumerableUtils) {
'use strict';
- var RETAIN = 'r';
- var FILTER = 'f';
+ var RETAIN = "r";
+ var FILTER = "f";
function Operation(type, count) {
this.type = type;
this.count = count;
}
@@ -32860,13 +34135,13 @@
});
enifed('ember-runtime/system/tracked_array', ['exports', 'ember-metal/property_get', 'ember-metal/enumerable_utils'], function (exports, property_get, enumerable_utils) {
'use strict';
- var RETAIN = 'r';
- var INSERT = 'i';
- var DELETE = 'd';
+ var RETAIN = "r";
+ var INSERT = "i";
+ var DELETE = "d";
exports['default'] = TrackedArray;
/**
An `Ember.TrackedArray` tracks array operations. It's useful when you want to
@@ -32881,11 +34156,11 @@
function TrackedArray(items) {
if (arguments.length < 1) {
items = [];
}
- var length = property_get.get(items, 'length');
+ var length = property_get.get(items, "length");
if (length) {
this._operations = [new ArrayOperation(RETAIN, length, items)];
} else {
this._operations = [];
@@ -32903,11 +34178,11 @@
@method addItems
@param index
@param newItems
*/
addItems: function (index, newItems) {
- var count = property_get.get(newItems, 'length');
+ var count = property_get.get(newItems, "length");
if (count < 1) {
return;
}
var match = this._findArrayOperation(index);
@@ -33184,16 +34459,115 @@
this.split = split;
this.rangeStart = rangeStart;
}
});
-enifed('ember-template-compiler', ['exports', 'ember-metal/core', 'ember-template-compiler/system/precompile', 'ember-template-compiler/system/compile', 'ember-template-compiler/system/template', 'ember-template-compiler/plugins', 'ember-template-compiler/plugins/transform-each-in-to-hash', 'ember-template-compiler/plugins/transform-with-as-to-hash', 'ember-template-compiler/compat'], function (exports, _Ember, precompile, compile, template, plugins, TransformEachInToHash, TransformWithAsToHash) {
+enifed('ember-runtime/utils', ['exports', 'ember-runtime/mixins/array', 'ember-runtime/system/object', 'ember-metal/utils'], function (exports, EmberArray, EmberObject, utils) {
+ 'use strict';
+
+ exports.isArray = isArray;
+ exports.typeOf = typeOf;
+
+ /**
+ Returns true if the passed object is an array or Array-like.
+
+ Ember Array Protocol:
+
+ - the object has an objectAt property
+ - the object is a native Array
+ - the object is an Object, and has a length property
+
+ Unlike `Ember.typeOf` this method returns true even if the passed object is
+ not formally array but appears to be array-like (i.e. implements `Ember.Array`)
+
+ ```javascript
+ Ember.isArray(); // false
+ Ember.isArray([]); // true
+ Ember.isArray(Ember.ArrayProxy.create({ content: [] })); // true
+ ```
+
+ @method isArray
+ @for Ember
+ @param {Object} obj The object to test
+ @return {Boolean} true if the passed object is an array or Array-like
+ */
+ var TYPE_MAP = {
+ '[object Boolean]': 'boolean',
+ '[object Number]': 'number',
+ '[object String]': 'string',
+ '[object Function]': 'function',
+ '[object Array]': 'array',
+ '[object Date]': 'date',
+ '[object RegExp]': 'regexp',
+ '[object Object]': 'object'
+ };
+
+ var toString = Object.prototype.toString;
+ function isArray(obj) {
+ if (!obj || obj.setInterval) {
+ return false;
+ }
+ if (utils.isArray(obj)) {
+ return true;
+ }
+ if (EmberArray['default'].detect(obj)) {
+ return true;
+ }
+
+ var type = typeOf(obj);
+ if ('array' === type) {
+ return true;
+ }
+ if (obj.length !== undefined && 'object' === type) {
+ return true;
+ }
+ return false;
+ }
+
+ function typeOf(item) {
+ if (item === null) {
+ return 'null';
+ }
+ if (item === undefined) {
+ return 'undefined';
+ }
+ var ret = TYPE_MAP[toString.call(item)] || 'object';
+
+ if (ret === 'function') {
+ if (EmberObject['default'].detect(item)) {
+ ret = 'class';
+ }
+ } else if (ret === 'object') {
+ if (item instanceof Error) {
+ ret = 'error';
+ } else if (item instanceof EmberObject['default']) {
+ ret = 'instance';
+ } else if (item instanceof Date) {
+ ret = 'date';
+ }
+ }
+
+ return ret;
+ }
+
+});
+enifed('ember-template-compiler', ['exports', 'ember-metal/core', 'ember-template-compiler/system/precompile', 'ember-template-compiler/system/compile', 'ember-template-compiler/system/template', 'ember-template-compiler/plugins', 'ember-template-compiler/plugins/transform-each-in-to-block-params', 'ember-template-compiler/plugins/transform-with-as-to-hash', 'ember-template-compiler/plugins/transform-bind-attr-to-attributes', 'ember-template-compiler/plugins/transform-each-into-collection', 'ember-template-compiler/plugins/transform-single-arg-each', 'ember-template-compiler/plugins/transform-old-binding-syntax', 'ember-template-compiler/plugins/transform-old-class-binding-syntax', 'ember-template-compiler/plugins/transform-item-class', 'ember-template-compiler/plugins/transform-component-attrs-into-mut', 'ember-template-compiler/plugins/transform-component-curly-to-readonly', 'ember-template-compiler/plugins/transform-angle-bracket-components', 'ember-template-compiler/compat'], function (exports, _Ember, precompile, compile, template, plugins, TransformEachInToBlockParams, TransformWithAsToHash, TransformBindAttrToAttributes, TransformEachIntoCollection, TransformSingleArgEach, TransformOldBindingSyntax, TransformOldClassBindingSyntax, TransformItemClass, TransformComponentAttrsIntoMut, TransformComponentCurlyToReadonly, TransformAngleBracketComponents) {
+
'use strict';
- plugins.registerPlugin('ast', TransformWithAsToHash['default']);
- plugins.registerPlugin('ast', TransformEachInToHash['default']);
+ plugins.registerPlugin("ast", TransformWithAsToHash['default']);
+ plugins.registerPlugin("ast", TransformEachInToBlockParams['default']);
+ plugins.registerPlugin("ast", TransformBindAttrToAttributes['default']);
+ plugins.registerPlugin("ast", TransformSingleArgEach['default']);
+ plugins.registerPlugin("ast", TransformEachIntoCollection['default']);
+ plugins.registerPlugin("ast", TransformOldBindingSyntax['default']);
+ plugins.registerPlugin("ast", TransformOldClassBindingSyntax['default']);
+ plugins.registerPlugin("ast", TransformItemClass['default']);
+ plugins.registerPlugin("ast", TransformComponentAttrsIntoMut['default']);
+ plugins.registerPlugin("ast", TransformComponentCurlyToReadonly['default']);
+ plugins.registerPlugin("ast", TransformAngleBracketComponents['default']);
exports._Ember = _Ember['default'];
exports.precompile = precompile['default'];
exports.compile = compile['default'];
exports.template = template['default'];
@@ -33244,21 +34618,19 @@
'use strict';
exports.registerPlugin = registerPlugin;
- var plugins = {
- ast: []
- };
-
/**
Adds an AST plugin to be used by Ember.HTMLBars.compile.
@private
@method registerASTPlugin
*/
-
+ var plugins = {
+ ast: []
+ };
function registerPlugin(type, Plugin) {
if (!plugins[type]) {
throw new Error('Attempting to register "' + Plugin + '" as "' + type + '" which is not a valid HTMLBars plugin type.');
}
@@ -33266,10 +34638,375 @@
}
exports['default'] = plugins;
});
+enifed('ember-template-compiler/plugins/transform-angle-bracket-components', ['exports'], function (exports) {
+
+ 'use strict';
+
+ function TransformAngleBracketComponents() {
+ // set later within HTMLBars to the syntax package
+ this.syntax = null;
+ }
+
+ /**
+ @private
+ @method transform
+ @param {AST} The AST to be transformed.
+ */
+ TransformAngleBracketComponents.prototype.transform = function TransformBindAttrToAttributes_transform(ast) {
+ var walker = new this.syntax.Walker();
+
+ walker.visit(ast, function (node) {
+ if (!validate(node)) {
+ return;
+ }
+
+ node.tag = '<' + node.tag + '>';
+ });
+
+ return ast;
+ };
+
+ function validate(node) {
+ return node.type === 'ComponentNode';
+ }
+
+ exports['default'] = TransformAngleBracketComponents;
+
+});
+enifed('ember-template-compiler/plugins/transform-bind-attr-to-attributes', ['exports', 'ember-metal/core', 'ember-template-compiler/system/string'], function (exports, Ember, string) {
+
+ 'use strict';
+
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
+
+ function TransformBindAttrToAttributes() {
+ // set later within HTMLBars to the syntax package
+ this.syntax = null;
+ }
+
+ /**
+ @private
+ @method transform
+ @param {AST} The AST to be transformed.
+ */
+ TransformBindAttrToAttributes.prototype.transform = function TransformBindAttrToAttributes_transform(ast) {
+ var plugin = this;
+ var walker = new this.syntax.Walker();
+
+ walker.visit(ast, function (node) {
+ if (node.type === "ElementNode") {
+ for (var i = 0; i < node.modifiers.length; i++) {
+ var modifier = node.modifiers[i];
+
+ if (isBindAttrModifier(modifier)) {
+ node.modifiers.splice(i--, 1);
+ plugin.assignAttrs(node, modifier.hash);
+ }
+ }
+ }
+ });
+
+ return ast;
+ };
+
+ TransformBindAttrToAttributes.prototype.assignAttrs = function assignAttrs(element, hash) {
+ var pairs = hash.pairs;
+
+ for (var i = 0; i < pairs.length; i++) {
+ var name = pairs[i].key;
+ var value = pairs[i].value;
+
+ assertAttrNameIsUnused(element, name);
+
+ var attr = this.syntax.builders.attr(name, this.transformValue(name, value));
+ element.attributes.push(attr);
+ }
+ };
+
+ TransformBindAttrToAttributes.prototype.transformValue = function transformValue(name, value) {
+ var b = this.syntax.builders;
+
+ if (name === "class") {
+ switch (value.type) {
+ case "StringLiteral":
+ return this.parseClasses(value.value);
+ case "PathExpression":
+ return this.parseClasses(value.original);
+ case "SubExpression":
+ return b.mustache(value.path, value.params, value.hash);
+ default:
+ Ember['default'].assert("Unsupported attribute value type: " + value.type);
+ }
+ } else {
+ switch (value.type) {
+ case "StringLiteral":
+ return b.mustache(b.path(value.value));
+ case "PathExpression":
+ return b.mustache(value);
+ case "SubExpression":
+ return b.mustache(value.path, value.params, value.hash);
+ default:
+ Ember['default'].assert("Unsupported attribute value type: " + value.type);
+ }
+ }
+ };
+
+ TransformBindAttrToAttributes.prototype.parseClasses = function parseClasses(value) {
+ var b = this.syntax.builders;
+
+ var concat = b.concat();
+ var classes = value.split(" ");
+
+ for (var i = 0; i < classes.length; i++) {
+ if (i > 0) {
+ concat.parts.push(b.string(" "));
+ }
+
+ var concatPart = this.parseClass(classes[i]);
+ concat.parts.push(concatPart);
+ }
+
+ return concat;
+ };
+
+ TransformBindAttrToAttributes.prototype.parseClass = function parseClass(value) {
+ var b = this.syntax.builders;
+
+ var parts = value.split(":");
+
+ switch (parts.length) {
+ case 1:
+ // Before: {{bind-attr class="view.fooBar ..."}}
+ // After: class="{{-bind-attr-class view.fooBar "foo-bar"}} ..."
+ return b.sexpr(b.path("-bind-attr-class"), [b.path(parts[0]), b.string(dasherizeLastKey(parts[0]))]);
+ case 2:
+ if (parts[0] === "") {
+ // Before: {{bind-attr class=":foo ..."}}
+ // After: class="foo ..."
+ return b.string(parts[1]);
+ } else {
+ // Before: {{bind-attr class="some.path:foo ..."}}
+ // After: class="{{if some.path "foo" ""}} ..."
+ return b.sexpr(b.path("if"), [b.path(parts[0]), b.string(parts[1]), b.string("")]);
+ }
+ break;
+ case 3:
+ // Before: {{bind-attr class="some.path:foo:bar ..."}}
+ // After: class="{{if some.path "foo" "bar"}} ..."
+ return b.sexpr(b.path("if"), [b.path(parts[0]), b.string(parts[1]), b.string(parts[2])]);
+ default:
+ Ember['default'].assert("Unsupported bind-attr class syntax: `" + value + "`");
+ }
+ };
+
+ function isBindAttrModifier(modifier) {
+ var name = modifier.path.original;
+
+ if (name === "bind-attr" || name === "bindAttr") {
+ Ember['default'].deprecate("The `" + name + "` helper is deprecated in favor of " + "HTMLBars-style bound attributes");
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function assertAttrNameIsUnused(element, name) {
+ for (var i = 0; i < element.attributes.length; i++) {
+ var attr = element.attributes[i];
+
+ if (attr.name === name) {
+ if (name === "class") {
+ Ember['default'].assert("You cannot set `class` manually and via `{{bind-attr}}` helper " + "on the same element. Please use `{{bind-attr}}`'s `:static-class` " + "syntax instead.");
+ } else {
+ Ember['default'].assert("You cannot set `" + name + "` manually and via `{{bind-attr}}` " + "helper on the same element.");
+ }
+ }
+ }
+ }
+
+ function dasherizeLastKey(path) {
+ var parts = path.split(".");
+ return string.dasherize(parts[parts.length - 1]);
+ }
+
+ exports['default'] = TransformBindAttrToAttributes;
+
+});
+enifed('ember-template-compiler/plugins/transform-component-attrs-into-mut', ['exports'], function (exports) {
+
+ 'use strict';
+
+ function TransformComponentAttrsIntoMut() {
+ // set later within HTMLBars to the syntax package
+ this.syntax = null;
+ }
+
+ /**
+ @private
+ @method transform
+ @param {AST} The AST to be transformed.
+ */
+ TransformComponentAttrsIntoMut.prototype.transform = function TransformBindAttrToAttributes_transform(ast) {
+ var b = this.syntax.builders;
+ var walker = new this.syntax.Walker();
+
+ walker.visit(ast, function (node) {
+ if (!validate(node)) {
+ return;
+ }
+
+ each(node.hash.pairs, function (pair) {
+ var value = pair.value;
+
+ if (value.type === 'PathExpression') {
+ pair.value = b.sexpr(b.path('@mut'), [pair.value]);
+ }
+ });
+ });
+
+ return ast;
+ };
+
+ function validate(node) {
+ return node.type === 'BlockStatement' || node.type === 'MustacheStatement';
+ }
+
+ function each(list, callback) {
+ for (var i = 0, l = list.length; i < l; i++) {
+ callback(list[i]);
+ }
+ }
+
+ exports['default'] = TransformComponentAttrsIntoMut;
+
+});
+enifed('ember-template-compiler/plugins/transform-component-curly-to-readonly', ['exports'], function (exports) {
+
+ 'use strict';
+
+ function TransformComponentCurlyToReadonly() {
+ // set later within HTMLBars to the syntax package
+ this.syntax = null;
+ }
+
+ /**
+ @private
+ @method transform
+ @param {AST} The AST to be transformed.
+ */
+ TransformComponentCurlyToReadonly.prototype.transform = function TransformComponetnCurlyToReadonly_transform(ast) {
+ var b = this.syntax.builders;
+ var walker = new this.syntax.Walker();
+
+ walker.visit(ast, function (node) {
+ if (!validate(node)) {
+ return;
+ }
+
+ each(node.attributes, function (attr) {
+ if (attr.value.type !== 'MustacheStatement') {
+ return;
+ }
+ if (attr.value.params.length || attr.value.hash.pairs.length) {
+ return;
+ }
+
+ attr.value = b.mustache(b.path('readonly'), [attr.value.path], null, !attr.value.escape);
+ });
+ });
+
+ return ast;
+ };
+
+ function validate(node) {
+ return node.type === 'ComponentNode';
+ }
+
+ function each(list, callback) {
+ for (var i = 0, l = list.length; i < l; i++) {
+ callback(list[i]);
+ }
+ }
+
+ exports['default'] = TransformComponentCurlyToReadonly;
+
+});
+enifed('ember-template-compiler/plugins/transform-each-in-to-block-params', ['exports'], function (exports) {
+
+ 'use strict';
+
+ /**
+ @module ember
+ @submodule ember-htmlbars
+ */
+
+ /**
+ An HTMLBars AST transformation that replaces all instances of
+
+ ```handlebars
+ {{#each item in items}}
+ {{/each}}
+ ```
+
+ with
+
+ ```handlebars
+ {{#each items as |item|}}
+ {{/each}}
+ ```
+
+ @class TransformEachInToBlockParams
+ @private
+ */
+ function TransformEachInToBlockParams() {
+ // set later within HTMLBars to the syntax package
+ this.syntax = null;
+ }
+
+ /**
+ @private
+ @method transform
+ @param {AST} The AST to be transformed.
+ */
+ TransformEachInToBlockParams.prototype.transform = function TransformEachInToBlockParams_transform(ast) {
+ var b = this.syntax.builders;
+ var walker = new this.syntax.Walker();
+
+ walker.visit(ast, function (node) {
+ if (validate(node)) {
+
+ var removedParams = node.params.splice(0, 2);
+ var keyword = removedParams[0].original;
+
+ if (node.type === 'BlockStatement') {
+ if (node.program.blockParams.length) {
+ throw new Error('You cannot use keyword (`{{each foo in bar}}`) and block params (`{{each bar as |foo|}}`) at the same time.');
+ }
+
+ node.program.blockParams = [keyword];
+ } else {
+ node.hash.pairs.push(b.pair('keyword', b.string(keyword)));
+ }
+ }
+ });
+
+ return ast;
+ };
+
+ function validate(node) {
+ return (node.type === 'BlockStatement' || node.type === 'MustacheStatement') && node.path.original === 'each' && node.params.length === 3 && node.params[1].type === 'PathExpression' && node.params[1].original === 'in';
+ }
+
+ exports['default'] = TransformEachInToBlockParams;
+
+});
enifed('ember-template-compiler/plugins/transform-each-in-to-hash', ['exports'], function (exports) {
'use strict';
/**
@@ -33338,10 +35075,411 @@
};
exports['default'] = TransformEachInToHash;
});
+enifed('ember-template-compiler/plugins/transform-each-into-collection', ['exports', 'ember-metal/core'], function (exports, Ember) {
+
+ 'use strict';
+
+
+
+ exports['default'] = TransformEachIntoCollection;
+
+ function TransformEachIntoCollection(options) {
+ this.options = options;
+ this.syntax = null;
+ }
+
+ TransformEachIntoCollection.prototype.transform = function TransformEachIntoCollection_transform(ast) {
+ var options = this.options;
+ var b = this.syntax.builders;
+ var walker = new this.syntax.Walker();
+
+ walker.visit(ast, function (node) {
+ var legacyHashKey = validate(node);
+ if (!legacyHashKey) {
+ return;
+ }
+
+ var _ref = legacyHashKey.loc.start || {};
+
+ var column = _ref.column;
+ var line = _ref.line;
+
+ var moduleInfo = '';
+ if (options.moduleName) {
+ moduleInfo += '\'' + options.moduleName + '\' ';
+ }
+
+ if (line && column) {
+ moduleInfo += '@L' + line + ':C' + column;
+ }
+
+ Ember['default'].deprecate('Using \'' + legacyHashKey.key + '\' with \'{{each}}\' ' + moduleInfo + ' is deprecated. Please refactor to a component.');
+
+ var list = node.params.shift();
+ node.path = b.path('collection');
+
+ node.params.unshift(b.string('-legacy-each'));
+
+ var pair = b.pair('content', list);
+ pair.loc = list.loc;
+
+ node.hash.pairs.push(pair);
+
+ //pair = b.pair('dataSource', list);
+ //node.hash.pairs.push(pair);
+ });
+
+ return ast;
+ };
+
+ function validate(node) {
+ if ((node.type === 'BlockStatement' || node.type === 'MustacheStatement') && node.path.original === 'each') {
+
+ return any(node.hash.pairs, function (pair) {
+ var key = pair.key;
+ return key === 'itemController' || key === 'itemView' || key === 'itemViewClass' || key === 'tagName' || key === 'emptyView' || key === 'emptyViewClass';
+ });
+ }
+
+ return false;
+ }
+
+ function any(list, predicate) {
+ for (var i = 0, l = list.length; i < l; i++) {
+ if (predicate(list[i])) {
+ return list[i];
+ }
+ }
+
+ return false;
+ }
+
+});
+enifed('ember-template-compiler/plugins/transform-item-class', ['exports'], function (exports) {
+
+ 'use strict';
+
+ exports['default'] = TransformItemClass;
+
+ function TransformItemClass() {
+ this.syntax = null;
+ }
+
+ TransformItemClass.prototype.transform = function TransformItemClass_transform(ast) {
+ var b = this.syntax.builders;
+ var walker = new this.syntax.Walker();
+
+ walker.visit(ast, function (node) {
+ if (!validate(node)) {
+ return;
+ }
+
+ each(node.hash.pairs, function (pair) {
+ var key = pair.key;
+ var value = pair.value;
+
+ if (key !== 'itemClass') {
+ return;
+ }
+ if (value.type === 'StringLiteral') {
+ return;
+ }
+
+ var propName = value.original;
+ var params = [value];
+ var sexprParams = [b.string(propName), b.path(propName)];
+
+ params.push(b.sexpr(b.string('-normalize-class'), sexprParams));
+ var sexpr = b.sexpr(b.string('if'), params);
+
+ pair.value = sexpr;
+ });
+ });
+
+ return ast;
+ };
+
+ function validate(node) {
+ return (node.type === 'BlockStatement' || node.type === 'MustacheStatement') && node.path.original === 'collection';
+ }
+
+ function each(list, callback) {
+ for (var i = 0, l = list.length; i < l; i++) {
+ callback(list[i]);
+ }
+ }
+
+});
+enifed('ember-template-compiler/plugins/transform-old-binding-syntax', ['exports', 'ember-metal/core'], function (exports, Ember) {
+
+ 'use strict';
+
+
+
+ exports['default'] = TransformOldBindingSyntax;
+
+ function TransformOldBindingSyntax() {
+ this.syntax = null;
+ }
+
+ TransformOldBindingSyntax.prototype.transform = function TransformOldBindingSyntax_transform(ast) {
+ var b = this.syntax.builders;
+ var walker = new this.syntax.Walker();
+
+ walker.visit(ast, function (node) {
+ if (!validate(node)) {
+ return;
+ }
+
+ each(node.hash.pairs, function (pair) {
+ var key = pair.key;
+ var value = pair.value;
+
+ var sourceInformation = '';
+
+ if (pair.loc) {
+ var _pair$loc = pair.loc;
+ var start = _pair$loc.start;
+ var source = _pair$loc.source;
+
+ sourceInformation = '@ ' + start.line + ':' + start.column + ' in ' + (source || '(inline)');
+ }
+
+ if (key === 'classBinding') {
+ return;
+ }
+
+ Ember['default'].assert('Setting \'attributeBindings\' via template helpers is not allowed ' + sourceInformation, key !== 'attributeBindings');
+
+ if (key.substr(-7) === 'Binding') {
+ var newKey = key.slice(0, -7);
+
+ Ember['default'].deprecate('You\'re using legacy binding syntax: ' + key + '=' + exprToString(value) + ' ' + sourceInformation + '. Please replace with ' + newKey + '=' + value.original);
+
+ pair.key = newKey;
+ if (value.type === 'StringLiteral') {
+ pair.value = b.path(value.original);
+ }
+ }
+ });
+ });
+
+ return ast;
+ };
+
+ function validate(node) {
+ return node.type === 'BlockStatement' || node.type === 'MustacheStatement';
+ }
+
+ function each(list, callback) {
+ for (var i = 0, l = list.length; i < l; i++) {
+ callback(list[i]);
+ }
+ }
+
+ function exprToString(expr) {
+ switch (expr.type) {
+ case 'StringLiteral':
+ return '"' + expr.original + '"';
+ case 'PathExpression':
+ return expr.original;
+ }
+ }
+
+});
+enifed('ember-template-compiler/plugins/transform-old-class-binding-syntax', ['exports', 'ember-metal/core'], function (exports, Ember) {
+
+ 'use strict';
+
+
+
+ exports['default'] = TransformOldClassBindingSyntax;
+
+ function TransformOldClassBindingSyntax() {
+ this.syntax = null;
+ }
+
+ TransformOldClassBindingSyntax.prototype.transform = function TransformOldClassBindingSyntax_transform(ast) {
+ var b = this.syntax.builders;
+ var walker = new this.syntax.Walker();
+
+ walker.visit(ast, function (node) {
+ if (!validate(node)) {
+ return;
+ }
+
+ var allOfTheMicrosyntaxes = [];
+ var allOfTheMicrosyntaxIndexes = [];
+ var classPair = undefined;
+
+ each(node.hash.pairs, function (pair, index) {
+ var key = pair.key;
+
+ if (key === 'classBinding' || key === 'classNameBindings') {
+ allOfTheMicrosyntaxIndexes.push(index);
+ allOfTheMicrosyntaxes.push(pair);
+ } else if (key === 'class') {
+ classPair = pair;
+ }
+ });
+
+ if (allOfTheMicrosyntaxes.length === 0) {
+ return;
+ }
+
+ var classValue = [];
+
+ if (classPair) {
+ classValue.push(classPair.value);
+ } else {
+ classPair = b.pair('class', null);
+ node.hash.pairs.push(classPair);
+ }
+
+ each(allOfTheMicrosyntaxIndexes, function (index) {
+ node.hash.pairs.splice(index, 1);
+ });
+
+ each(allOfTheMicrosyntaxes, function (_ref) {
+ var value = _ref.value;
+ var loc = _ref.loc;
+
+ var sexprs = [];
+
+ var sourceInformation = '';
+ if (loc) {
+ var start = loc.start;
+ var source = loc.source;
+
+ sourceInformation = '@ ' + start.line + ':' + start.column + ' in ' + (source || '(inline)');
+ }
+
+ // TODO: Parse the microsyntax and offer the correct information
+ Ember['default'].deprecate('You\'re using legacy class binding syntax: classBinding=' + exprToString(value) + ' ' + sourceInformation + '. Please replace with class=""');
+
+ if (value.type === 'StringLiteral') {
+ var microsyntax = parseMicrosyntax(value.original);
+
+ buildSexprs(microsyntax, sexprs, b);
+
+ classValue.push.apply(classValue, sexprs);
+ }
+ });
+
+ var hash = b.hash([b.pair('separator', b.string(' '))]);
+ classPair.value = b.sexpr(b.string('-concat'), classValue, hash);
+ });
+
+ return ast;
+ };
+
+ function buildSexprs(microsyntax, sexprs, b) {
+ for (var i = 0, l = microsyntax.length; i < l; i++) {
+ var _microsyntax$i = microsyntax[i];
+ var propName = _microsyntax$i[0];
+ var activeClass = _microsyntax$i[1];
+ var inactiveClass = _microsyntax$i[2];
+
+ var sexpr = undefined;
+
+ // :my-class-name microsyntax for static values
+ if (propName === '') {
+ sexpr = b.string(activeClass);
+ } else {
+ var params = [b.path(propName)];
+
+ if (activeClass) {
+ params.push(b.string(activeClass));
+ } else {
+ var sexprParams = [b.string(propName), b.path(propName)];
+
+ var hash = b.hash();
+ if (activeClass !== undefined) {
+ hash.pairs.push(b.pair('activeClass', b.string(activeClass)));
+ }
+
+ if (inactiveClass !== undefined) {
+ hash.pairs.push(b.pair('inactiveClass', b.string(inactiveClass)));
+ }
+
+ params.push(b.sexpr(b.string('-normalize-class'), sexprParams, hash));
+ }
+
+ if (inactiveClass) {
+ params.push(b.string(inactiveClass));
+ }
+
+ sexpr = b.sexpr(b.string('if'), params);
+ }
+
+ sexprs.push(sexpr);
+ }
+ }
+
+ function validate(node) {
+ return node.type === 'BlockStatement' || node.type === 'MustacheStatement';
+ }
+
+ function each(list, callback) {
+ for (var i = 0, l = list.length; i < l; i++) {
+ callback(list[i], i);
+ }
+ }
+
+ function parseMicrosyntax(string) {
+ var segments = string.split(' ');
+
+ for (var i = 0, l = segments.length; i < l; i++) {
+ segments[i] = segments[i].split(':');
+ }
+
+ return segments;
+ }
+
+ function exprToString(expr) {
+ switch (expr.type) {
+ case 'StringLiteral':
+ return '"' + expr.original + '"';
+ case 'PathExpression':
+ return expr.original;
+ }
+ }
+
+});
+enifed('ember-template-compiler/plugins/transform-single-arg-each', ['exports'], function (exports) {
+
+ 'use strict';
+
+ exports['default'] = TransformSingleArgEach;
+
+ function TransformSingleArgEach() {
+ this.syntax = null;
+ }
+
+ TransformSingleArgEach.prototype.transform = function TransformSingleArgEach_transform(ast) {
+ var b = this.syntax.builders;
+ var walker = new this.syntax.Walker();
+
+ walker.visit(ast, function (node) {
+ if (!validate(node)) {
+ return;
+ }
+
+ node.params.push(b.path('this'));
+ });
+
+ return ast;
+ };
+
+ function validate(node) {
+ return (node.type === 'BlockStatement' || node.type === 'MustacheStatement') && node.path.original === 'each' && node.params.length === 0;
+ }
+
+});
enifed('ember-template-compiler/plugins/transform-with-as-to-hash', ['exports'], function (exports) {
'use strict';
/**
@@ -33368,11 +35506,11 @@
@class TransformWithAsToHash
*/
function TransformWithAsToHash(options) {
// set later within HTMLBars to the syntax package
this.syntax = null;
- this.options = options;
+ this.options = options || {};
}
/**
@private
@method transform
@@ -33385,43 +35523,53 @@
walker.visit(ast, function (node) {
if (pluginContext.validate(node)) {
if (node.program && node.program.blockParams.length) {
- throw new Error('You cannot use keyword (`{{with foo as bar}}`) and block params (`{{with foo as |bar|}}`) at the same time.');
+ throw new Error("You cannot use keyword (`{{with foo as bar}}`) and block params (`{{with foo as |bar|}}`) at the same time.");
}
Ember.deprecate("Using {{with}} without block syntax is deprecated. " + "Please use standard block form (`{{#with foo as |bar|}}`) " + (moduleName ? " in `" + moduleName + "` " : "") + "instead.", false, { url: "http://emberjs.com/deprecations/v1.x/#toc_code-as-code-sytnax-for-code-with-code" });
- var removedParams = node.sexpr.params.splice(1, 2);
+ var removedParams = node.params.splice(1, 2);
var keyword = removedParams[1].original;
node.program.blockParams = [keyword];
}
});
return ast;
};
TransformWithAsToHash.prototype.validate = function TransformWithAsToHash_validate(node) {
- return node.type === 'BlockStatement' && node.sexpr.path.original === 'with' && node.sexpr.params.length === 3 && node.sexpr.params[1].type === 'PathExpression' && node.sexpr.params[1].original === 'as';
+ return node.type === "BlockStatement" && node.path.original === "with" && node.params.length === 3 && node.params[1].type === "PathExpression" && node.params[1].original === "as";
};
exports['default'] = TransformWithAsToHash;
});
enifed('ember-template-compiler/system/compile', ['exports', 'ember-template-compiler/system/compile_options', 'ember-template-compiler/system/template'], function (exports, compileOptions, template) {
'use strict';
- var compile;exports['default'] = function (templateString, options) {
- if (!compile && Ember.__loader.registry['htmlbars-compiler/compiler']) {
- compile = requireModule('htmlbars-compiler/compiler').compile;
+ var compile; /**
+ Uses HTMLBars `compile` function to process a string into a compiled template.
+
+ This is not present in production builds.
+
+ @private
+ @method compile
+ @param {String} templateString This is the string to be compiled by HTMLBars.
+ @param {Object} options This is an options hash to augment the compiler options.
+ */
+ exports['default'] = function (templateString, options) {
+ if (!compile && Ember.__loader.registry["htmlbars-compiler/compiler"]) {
+ compile = requireModule("htmlbars-compiler/compiler").compile;
}
if (!compile) {
- throw new Error('Cannot call `compile` without the template compiler loaded. Please load `ember-template-compiler.js` prior to calling `compile`.');
+ throw new Error("Cannot call `compile` without the template compiler loaded. Please load `ember-template-compiler.js` prior to calling `compile`.");
}
var templateSpec = compile(templateString, compileOptions['default'](options));
return template['default'](templateSpec);
@@ -33438,22 +35586,32 @@
*/
exports['default'] = function (_options) {
var disableComponentGeneration = true;
+ disableComponentGeneration = false;
+
+
var options = _options || {};
// When calling `Ember.Handlebars.compile()` a second argument of `true`
// had a special meaning (long since lost), this just gaurds against
// `options` being true, and causing an error during compilation.
if (options === true) {
options = {};
}
- options.revision = 'Ember@1.12.2';
options.disableComponentGeneration = disableComponentGeneration;
options.plugins = plugins['default'];
+ options.buildMeta = function buildMeta(program) {
+ return {
+ revision: "Ember@1.13.0-beta.1",
+ loc: program.loc,
+ moduleName: options.moduleName
+ };
+ };
+
return options;
}
});
enifed('ember-template-compiler/system/precompile', ['exports', 'ember-template-compiler/system/compile_options'], function (exports, compileOptions) {
@@ -33488,34 +35646,43 @@
return compileSpec(templateString, compileOptions['default'](options));
}
});
-enifed('ember-template-compiler/system/template', ['exports'], function (exports) {
+enifed('ember-template-compiler/system/string', ['exports'], function (exports) {
'use strict';
- /**
- @module ember
- @submodule ember-template-compiler
- */
+ exports.decamelize = decamelize;
+ exports.dasherize = dasherize;
+ var STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
+ var STRING_DASHERIZE_REGEXP = /[ _]/g;
+ function decamelize(str) {
+ return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase();
+ }
+
+ function dasherize(str) {
+ return decamelize(str).replace(STRING_DASHERIZE_REGEXP, '-');
+ }
+
+});
+enifed('ember-template-compiler/system/template', ['exports', 'htmlbars-runtime/hooks'], function (exports, hooks) {
+
+ 'use strict';
+
exports['default'] = function (templateSpec) {
+ if (!templateSpec.render) {
+ templateSpec = hooks.wrap(templateSpec);
+ }
+
templateSpec.isTop = true;
templateSpec.isMethod = false;
return templateSpec;
}
- /**
- Augments the default precompiled output of an HTMLBars template with
- additional information needed by Ember.
- @private
- @method template
- @param {Function} templateSpec This is the compiled HTMLBars template spec.
- */
-
});
enifed('ember-testing', ['ember-metal/core', 'ember-testing/initializers', 'ember-testing/support', 'ember-testing/setup_for_testing', 'ember-testing/test', 'ember-testing/adapters/adapter', 'ember-testing/adapters/qunit', 'ember-testing/helpers'], function (Ember, __dep1__, __dep2__, setupForTesting, Test, Adapter, QUnitAdapter) {
'use strict';
@@ -33607,99 +35774,97 @@
var helper = Test['default'].registerHelper;
var asyncHelper = Test['default'].registerAsyncHelper;
function currentRouteName(app) {
- var appController = app.__container__.lookup('controller:application');
+ var appController = app.__container__.lookup("controller:application");
- return property_get.get(appController, 'currentRouteName');
+ return property_get.get(appController, "currentRouteName");
}
function currentPath(app) {
- var appController = app.__container__.lookup('controller:application');
+ var appController = app.__container__.lookup("controller:application");
- return property_get.get(appController, 'currentPath');
+ return property_get.get(appController, "currentPath");
}
function currentURL(app) {
- var router = app.__container__.lookup('router:main');
+ var router = app.__container__.lookup("router:main");
- return property_get.get(router, 'location').getURL();
+ return property_get.get(router, "location").getURL();
}
function pauseTest() {
Test['default'].adapter.asyncStart();
- return new Ember['default'].RSVP.Promise(function () {}, 'TestAdapter paused promise');
+ return new Ember['default'].RSVP.Promise(function () {}, "TestAdapter paused promise");
}
function focus(el) {
- if (el && el.is(':input, [contenteditable=true]')) {
- var type = el.prop('type');
- if (type !== 'checkbox' && type !== 'radio' && type !== 'hidden') {
+ if (el && el.is(":input, [contenteditable=true]")) {
+ var type = el.prop("type");
+ if (type !== "checkbox" && type !== "radio" && type !== "hidden") {
run['default'](el, function () {
// Firefox does not trigger the `focusin` event if the window
// does not have focus. If the document doesn't have focus just
// use trigger('focusin') instead.
if (!document.hasFocus || document.hasFocus()) {
this.focus();
} else {
- this.trigger('focusin');
+ this.trigger("focusin");
}
});
}
}
}
function visit(app, url) {
- var router = app.__container__.lookup('router:main');
- app.boot().then(function () {
- router.location.setURL(url);
- });
+ var router = app.__container__.lookup("router:main");
if (app._readinessDeferrals > 0) {
- router['initialURL'] = url;
- run['default'](app, 'advanceReadiness');
- delete router['initialURL'];
+ router["initialURL"] = url;
+ run['default'](app, "advanceReadiness");
+ delete router["initialURL"];
} else {
- run['default'](app.__deprecatedInstance__, 'handleURL', url);
+ router.location.setURL(url);
+ run['default'](app.__deprecatedInstance__, "handleURL", url);
}
return app.testHelpers.wait();
}
function click(app, selector, context) {
var $el = app.testHelpers.findWithAssert(selector, context);
- run['default']($el, 'mousedown');
+ run['default']($el, "mousedown");
focus($el);
- run['default']($el, 'mouseup');
- run['default']($el, 'click');
+ run['default']($el, "mouseup");
+ run['default']($el, "click");
return app.testHelpers.wait();
}
function check(app, selector, context) {
var $el = app.testHelpers.findWithAssert(selector, context);
- var type = $el.prop('type');
+ var type = $el.prop("type");
- Ember['default'].assert('To check \'' + selector + '\', the input must be a checkbox', type === 'checkbox');
+ Ember['default'].assert("To check '" + selector + "', the input must be a checkbox", type === "checkbox");
- if (!$el.prop('checked')) {
+ if (!$el.prop("checked")) {
app.testHelpers.click(selector, context);
}
return app.testHelpers.wait();
}
function uncheck(app, selector, context) {
var $el = app.testHelpers.findWithAssert(selector, context);
- var type = $el.prop('type');
+ var type = $el.prop("type");
- Ember['default'].assert('To uncheck \'' + selector + '\', the input must be a checkbox', type === 'checkbox');
+ Ember['default'].assert("To uncheck '" + selector + "', the input must be a checkbox", type === "checkbox");
- if ($el.prop('checked')) {
+ if ($el.prop("checked")) {
app.testHelpers.click(selector, context);
}
return app.testHelpers.wait();
}
@@ -33737,19 +35902,19 @@
var $el = app.testHelpers.findWithAssert(selector, context);
var event = jQuery['default'].Event(type, options);
- run['default']($el, 'trigger', event);
+ run['default']($el, "trigger", event);
return app.testHelpers.wait();
}
function keyEvent(app, selector, contextOrType, typeOrKeyCode, keyCode) {
var context, type;
- if (typeof keyCode === 'undefined') {
+ if (typeof keyCode === "undefined") {
context = null;
keyCode = typeOrKeyCode;
type = contextOrType;
} else {
context = contextOrType;
@@ -33759,11 +35924,11 @@
return app.testHelpers.triggerEvent(selector, context, type, { keyCode: keyCode, which: keyCode });
}
function fillIn(app, selector, contextOrText, text) {
var $el, context;
- if (typeof text === 'undefined') {
+ if (typeof text === "undefined") {
text = contextOrText;
} else {
context = contextOrText;
}
$el = app.testHelpers.findWithAssert(selector, context);
@@ -33782,11 +35947,11 @@
return $el;
}
function find(app, selector, context) {
var $el;
- context = context || property_get.get(app, 'rootElement');
+ context = context || property_get.get(app, "rootElement");
$el = app.$(selector, context);
return $el;
}
@@ -33796,11 +35961,11 @@
function wait(app, value) {
return new RSVP['default'].Promise(function (resolve) {
// Every 10ms, poll for the async thing to have finished
var watcher = setInterval(function () {
- var router = app.__container__.lookup('router:main');
+ var router = app.__container__.lookup("router:main");
// 1. If the router is loading, keep polling
var routerIsLoading = router.router && !!router.router.activeTransition;
if (routerIsLoading) {
return;
@@ -33846,11 +36011,11 @@
*
* @method visit
* @param {String} url the name of the route
* @return {RSVP.Promise}
*/
- asyncHelper('visit', visit);
+ asyncHelper("visit", visit);
/**
* Clicks an element and triggers any actions triggered by the element's `click`
* event.
*
@@ -33864,11 +36029,11 @@
*
* @method click
* @param {String} selector jQuery selector for finding element on the DOM
* @return {RSVP.Promise}
*/
- asyncHelper('click', click);
+ asyncHelper("click", click);
/**
* Simulates a key event, e.g. `keypress`, `keydown`, `keyup` with the desired keyCode
*
* Example:
@@ -33884,11 +36049,11 @@
* @param {String} type the type of key event, e.g. `keypress`, `keydown`, `keyup`
* @param {Number} keyCode the keyCode of the simulated key event
* @return {RSVP.Promise}
* @since 1.5.0
*/
- asyncHelper('keyEvent', keyEvent);
+ asyncHelper("keyEvent", keyEvent);
/**
* Fills in an input element with some text.
*
* Example:
@@ -33903,11 +36068,11 @@
* @param {String} selector jQuery selector finding an input element on the DOM
* to fill text with
* @param {String} text text to place inside the input element
* @return {RSVP.Promise}
*/
- asyncHelper('fillIn', fillIn);
+ asyncHelper("fillIn", fillIn);
/**
* Finds an element in the context of the app's container element. A simple alias
* for `app.$(selector)`.
*
@@ -33919,11 +36084,11 @@
*
* @method find
* @param {String} selector jQuery string selector for element lookup
* @return {Object} jQuery object representing the results of the query
*/
- helper('find', find);
+ helper("find", find);
/**
* Like `find`, but throws an error if the element selector returns no results.
*
* Example:
@@ -33936,11 +36101,11 @@
* @param {String} selector jQuery selector string for finding an element within
* the DOM
* @return {Object} jQuery object representing the results of the query
* @throws {Error} throws error if jQuery object returned has a length of 0
*/
- helper('findWithAssert', findWithAssert);
+ helper("findWithAssert", findWithAssert);
/**
Causes the run loop to process any pending events. This is used to ensure that
any async operations from other helpers (or your assertions) have been processed.
@@ -33961,12 +36126,12 @@
@method wait
@param {Object} value The value to be returned.
@return {RSVP.Promise}
*/
- asyncHelper('wait', wait);
- asyncHelper('andThen', andThen);
+ asyncHelper("wait", wait);
+ asyncHelper("andThen", andThen);
/**
Returns the currently active route name.
Example:
@@ -33981,11 +36146,11 @@
@method currentRouteName
@return {Object} The name of the currently active route.
@since 1.5.0
*/
- helper('currentRouteName', currentRouteName);
+ helper("currentRouteName", currentRouteName);
/**
Returns the current path.
Example:
@@ -34000,11 +36165,11 @@
@method currentPath
@return {Object} The currently active path.
@since 1.5.0
*/
- helper('currentPath', currentPath);
+ helper("currentPath", currentPath);
/**
Returns the current URL.
Example:
@@ -34019,11 +36184,11 @@
@method currentURL
@return {Object} The currently active URL.
@since 1.5.0
*/
- helper('currentURL', currentURL);
+ helper("currentURL", currentURL);
/**
Pauses the current test - this is useful for debugging while testing or for test-driving.
It allows you to inspect the state of your application at any point.
@@ -34038,11 +36203,11 @@
@since 1.9.0
@method pauseTest
@return {Object} A promise that will never resolve
*/
- helper('pauseTest', pauseTest);
+ helper("pauseTest", pauseTest);
/**
Triggers the given DOM event on the element identified by the provided selector.
Example:
@@ -34064,11 +36229,11 @@
@param {String} type The event type to be triggered.
@param {Object} [options] The options to be passed to jQuery.Event.
@return {RSVP.Promise}
@since 1.5.0
*/
- asyncHelper('triggerEvent', triggerEvent);
+ asyncHelper("triggerEvent", triggerEvent);
});
enifed('ember-testing/initializers', ['ember-runtime/system/lazy_load'], function (lazy_load) {
'use strict';
@@ -34093,10 +36258,22 @@
enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal/core', 'ember-testing/adapters/qunit', 'ember-views/system/jquery'], function (exports, Ember, QUnitAdapter, jQuery) {
'use strict';
+
+ /**
+ Sets Ember up for testing. This is useful to perform
+ basic setup steps in order to unit test.
+
+ Use `App.setupForTesting` to perform integration tests (full
+ application testing).
+
+ @method setupForTesting
+ @namespace Ember
+ @since 1.5.0
+ */
exports['default'] = setupForTesting;
var Test, requests;
function incrementAjaxPendingRequests(_, xhr) {
requests.push(xhr);
@@ -34109,25 +36286,13 @@
requests.splice(i, 1);
}
}
Test.pendingAjaxRequests = requests.length;
}
-
- /**
- Sets Ember up for testing. This is useful to perform
- basic setup steps in order to unit test.
-
- Use `App.setupForTesting` to perform integration tests (full
- application testing).
-
- @method setupForTesting
- @namespace Ember
- @since 1.5.0
- */
function setupForTesting() {
if (!Test) {
- Test = requireModule('ember-testing/test')['default'];
+ Test = requireModule("ember-testing/test")["default"];
}
Ember['default'].testing = true;
// if adapter is not manually set default to QUnit
@@ -34136,14 +36301,14 @@
}
requests = [];
Test.pendingAjaxRequests = requests.length;
- jQuery['default'](document).off('ajaxSend', incrementAjaxPendingRequests);
- jQuery['default'](document).off('ajaxComplete', decrementAjaxPendingRequests);
- jQuery['default'](document).on('ajaxSend', incrementAjaxPendingRequests);
- jQuery['default'](document).on('ajaxComplete', decrementAjaxPendingRequests);
+ jQuery['default'](document).off("ajaxSend", incrementAjaxPendingRequests);
+ jQuery['default'](document).off("ajaxComplete", decrementAjaxPendingRequests);
+ jQuery['default'](document).on("ajaxSend", incrementAjaxPendingRequests);
+ jQuery['default'](document).on("ajaxComplete", decrementAjaxPendingRequests);
}
});
enifed('ember-testing/support', ['ember-metal/core', 'ember-views/system/jquery', 'ember-metal/environment'], function (Ember, jQuery, environment) {
@@ -34158,11 +36323,11 @@
@private
@method testCheckboxClick
*/
function testCheckboxClick(handler) {
- $('<input type="checkbox">').css({ position: 'absolute', left: '-1000px', top: '-1000px' }).appendTo('body').on('click', handler).trigger('click').remove();
+ $("<input type=\"checkbox\">").css({ position: "absolute", left: "-1000px", top: "-1000px" }).appendTo("body").on("click", handler).trigger("click").remove();
}
if (environment['default'].hasDOM) {
$(function () {
/*
@@ -34524,11 +36689,11 @@
setupForTesting['default']();
this.testing = true;
this.Router.reopen({
- location: 'none'
+ location: "none"
});
},
/**
This will be used as the container to inject the test helpers into. By
@@ -34665,11 +36830,11 @@
}
exports['default'] = Test;
});
-enifed('ember-views', ['exports', 'ember-runtime', 'ember-views/system/jquery', 'ember-views/system/utils', 'ember-views/system/render_buffer', 'ember-views/system/renderer', 'dom-helper', 'ember-views/system/ext', 'ember-views/views/states', 'ember-views/views/core_view', 'ember-views/views/view', 'ember-views/views/container_view', 'ember-views/views/collection_view', 'ember-views/views/component', 'ember-views/system/event_dispatcher', 'ember-views/mixins/view_target_action_support', 'ember-views/component_lookup', 'ember-views/views/checkbox', 'ember-views/mixins/text_support', 'ember-views/views/text_field', 'ember-views/views/text_area', 'ember-views/views/simple_bound_view', 'ember-views/views/metamorph_view', 'ember-views/views/select'], function (exports, Ember, jQuery, utils, RenderBuffer, Renderer, DOMHelper, __dep6__, states, core_view, View, ContainerView, CollectionView, Component, EventDispatcher, ViewTargetActionSupport, ComponentLookup, Checkbox, TextSupport, TextField, TextArea, SimpleBoundView, _MetamorphView, select) {
+enifed('ember-views', ['exports', 'ember-runtime', 'ember-views/system/jquery', 'ember-views/system/utils', 'ember-views/compat/render_buffer', 'ember-views/system/ext', 'ember-views/views/states', 'ember-metal-views/renderer', 'ember-views/views/core_view', 'ember-views/views/view', 'ember-views/views/container_view', 'ember-views/views/collection_view', 'ember-views/views/component', 'ember-views/system/event_dispatcher', 'ember-views/mixins/view_target_action_support', 'ember-views/component_lookup', 'ember-views/views/checkbox', 'ember-views/mixins/text_support', 'ember-views/views/text_field', 'ember-views/views/text_area', 'ember-views/views/select', 'ember-views/initializers/components', 'ember-views/compat/metamorph_view', 'ember-views/views/legacy_each_view'], function (exports, Ember, jQuery, utils, RenderBuffer, __dep4__, states, Renderer, core_view, View, ContainerView, CollectionView, Component, EventDispatcher, ViewTargetActionSupport, ComponentLookup, Checkbox, TextSupport, TextField, TextArea, select, __dep20__, metamorph_view, LegacyEachView) {
'use strict';
/**
Ember Views
@@ -34693,345 +36858,818 @@
Ember['default'].CoreView = core_view.DeprecatedCoreView;
Ember['default'].View = View['default'];
Ember['default'].View.states = states.states;
Ember['default'].View.cloneStates = states.cloneStates;
- Ember['default'].View.DOMHelper = DOMHelper['default'];
Ember['default'].View._Renderer = Renderer['default'];
Ember['default'].Checkbox = Checkbox['default'];
Ember['default'].TextField = TextField['default'];
Ember['default'].TextArea = TextArea['default'];
- Ember['default']._SimpleBoundView = SimpleBoundView['default'];
- Ember['default']._MetamorphView = _MetamorphView['default'];
- Ember['default']._Metamorph = _MetamorphView._Metamorph;
Ember['default'].Select = select.Select;
Ember['default'].SelectOption = select.SelectOption;
Ember['default'].SelectOptgroup = select.SelectOptgroup;
Ember['default'].TextSupport = TextSupport['default'];
Ember['default'].ComponentLookup = ComponentLookup['default'];
Ember['default'].ContainerView = ContainerView['default'];
Ember['default'].CollectionView = CollectionView['default'];
Ember['default'].Component = Component['default'];
Ember['default'].EventDispatcher = EventDispatcher['default'];
+
+ // Deprecated:
+ Ember['default']._Metamorph = metamorph_view._Metamorph;
+ Ember['default']._MetamorphView = metamorph_view['default'];
+ Ember['default']._LegacyEachView = LegacyEachView['default'];
+
// END EXPORTS
exports['default'] = Ember['default'];
});
-enifed('ember-views/attr_nodes/attr_node', ['exports', 'ember-metal/core', 'ember-metal/streams/utils', 'ember-metal/run_loop'], function (exports, Ember, utils, run) {
+enifed('ember-views/compat/attrs-proxy', ['exports', 'ember-metal/property_get', 'ember-metal/mixin', 'ember-metal/events', 'ember-metal/utils', 'ember-metal/keys', 'ember-metal/property_events', 'ember-metal/observer'], function (exports, property_get, mixin, events, utils, objectKeys, property_events, observer) {
'use strict';
- exports['default'] = AttrNode;
+ exports.deprecation = deprecation;
- /**
- @module ember
- @submodule ember-htmlbars
- */
+ function deprecation(key) {
+ return "You tried to look up an attribute directly on the component. This is deprecated. Use attrs." + key + " instead.";
+ }
- function AttrNode(attrName, attrValue) {
- this.init(attrName, attrValue);
+ var MUTABLE_CELL = utils.symbol("MUTABLE_CELL");
+
+ function isCell(val) {
+ return val && val[MUTABLE_CELL];
}
- var styleWarning = 'Binding style attributes may introduce cross-site scripting vulnerabilities; ' + 'please ensure that values being bound are properly escaped. For more information, ' + 'including how to disable this warning, see ' + 'http://emberjs.com/deprecations/v1.x/#toc_binding-style-attributes.';
+ function attrsWillChange(view, attrsKey) {
+ var key = attrsKey.slice(6);
+ view.currentState.legacyAttrWillChange(view, key);
+ }
- AttrNode.prototype.init = function init(attrName, simpleAttrValue) {
- this.isAttrNode = true;
- this.isView = true;
+ function attrsDidChange(view, attrsKey) {
+ var key = attrsKey.slice(6);
+ view.currentState.legacyAttrDidChange(view, key);
+ }
- this.tagName = '';
- this.isVirtual = true;
+ var AttrsProxyMixin = {
+ attrs: null,
- this.attrName = attrName;
- this.attrValue = simpleAttrValue;
- this.isDirty = true;
- this.isDestroying = false;
- this.lastValue = null;
- this.hasRenderedInitially = false;
+ getAttr: function (key) {
+ var attrs = this.attrs;
+ if (!attrs) {
+ return;
+ }
+ return this.getAttrFor(attrs, key);
+ },
- utils.subscribe(this.attrValue, this.rerender, this);
- };
+ getAttrFor: function (attrs, key) {
+ var val = attrs[key];
+ return isCell(val) ? val.value : val;
+ },
- AttrNode.prototype.renderIfDirty = function renderIfDirty() {
- if (this.isDirty && !this.isDestroying) {
- var value = utils.read(this.attrValue);
- if (value !== this.lastValue) {
- this._renderer.renderTree(this, this._parentView);
- } else {
- this.isDirty = false;
+ setAttr: function (key, value) {
+ var attrs = this.attrs;
+ var val = attrs[key];
+
+ if (!isCell(val)) {
+ throw new Error("You can't update attrs." + key + ", because it's not mutable");
}
- }
- };
- AttrNode.prototype.render = function render(buffer) {
- this.isDirty = false;
- if (this.isDestroying) {
- return;
- }
+ val.update(value);
+ },
- var value = utils.read(this.attrValue);
+ willWatchProperty: function (key) {
+ if (this._isAngleBracket || key === "attrs") {
+ return;
+ }
- if (this.attrName === 'value' && (value === null || value === undefined)) {
- value = '';
- }
+ var attrsKey = "attrs." + key;
+ observer.addBeforeObserver(this, attrsKey, null, attrsWillChange);
+ observer.addObserver(this, attrsKey, null, attrsDidChange);
+ },
- if (value === undefined) {
- value = null;
- }
+ didUnwatchProperty: function (key) {
+ if (this._isAngleBracket || key === "attrs") {
+ return;
+ }
- // If user is typing in a value we don't want to rerender and loose cursor position.
- if (this.hasRenderedInitially && this.attrName === 'value' && this._morph.element.value === value) {
- this.lastValue = value;
- return;
- }
+ var attrsKey = "attrs." + key;
+ observer.removeBeforeObserver(this, attrsKey, null, attrsWillChange);
+ observer.removeObserver(this, attrsKey, null, attrsDidChange);
+ },
- if (this.lastValue !== null || value !== null) {
- this._deprecateEscapedStyle(value);
- this._morph.setContent(value);
- this.lastValue = value;
- this.hasRenderedInitially = true;
- }
- };
+ legacyDidReceiveAttrs: events.on("didReceiveAttrs", function () {
+ if (this._isAngleBracket) {
+ return;
+ }
- AttrNode.prototype._deprecateEscapedStyle = function AttrNode_deprecateEscapedStyle(value) {
- Ember['default'].warn(styleWarning, (function (name, value, escaped) {
- // SafeString
- if (value && value.toHTML) {
- return true;
+ var keys = objectKeys['default'](this.attrs);
+
+ for (var i = 0, l = keys.length; i < l; i++) {
+ // Only issue the deprecation if it wasn't already issued when
+ // setting attributes initially.
+ if (!(keys[i] in this)) {
+ this.notifyPropertyChange(keys[i]);
+ }
}
+ }),
- if (name !== 'style') {
- return true;
+ unknownProperty: function (key) {
+ if (this._isAngleBracket) {
+ return;
}
- return !escaped;
- })(this.attrName, value, this._morph.escaped));
- };
+ var attrs = property_get.get(this, "attrs");
- AttrNode.prototype.rerender = function AttrNode_render() {
- this.isDirty = true;
- run['default'].schedule('render', this, this.renderIfDirty);
- };
+ if (attrs && key in attrs) {
+ // do not deprecate accessing `this[key]` at this time.
+ // add this back when we have a proper migration path
+ // Ember.deprecate(deprecation(key));
+ var possibleCell = property_get.get(attrs, key);
- AttrNode.prototype.destroy = function AttrNode_destroy() {
- this.isDestroying = true;
- this.isDirty = false;
+ if (possibleCell && possibleCell[MUTABLE_CELL]) {
+ return possibleCell.value;
+ }
- utils.unsubscribe(this.attrValue, this.rerender, this);
+ return possibleCell;
+ }
+ }
- if (!this.removedFromDOM && this._renderer) {
- this._renderer.remove(this, true);
+ //setUnknownProperty(key) {
+
+ //}
+ };
+
+ AttrsProxyMixin[property_events.PROPERTY_DID_CHANGE] = function (key) {
+ if (this._isAngleBracket) {
+ return;
}
+
+ if (this.currentState) {
+ this.currentState.legacyPropertyDidChange(this, key);
+ }
};
- AttrNode.prototype.propertyDidChange = function render() {};
+ exports['default'] = mixin.Mixin.create(AttrsProxyMixin);
- AttrNode.prototype._notifyBecameHidden = function render() {};
+ exports.MUTABLE_CELL = MUTABLE_CELL;
- AttrNode.prototype._notifyBecameVisible = function render() {};
+});
+enifed('ember-views/compat/metamorph_view', ['exports', 'ember-metal/core', 'ember-views/views/view', 'ember-metal/mixin'], function (exports, Ember, View, mixin) {
- exports.styleWarning = styleWarning;
+ 'use strict';
+ /*jshint newcap:false*/
+ var _Metamorph = mixin.Mixin.create({
+ tagName: "",
+ __metamorphType: "Ember._Metamorph",
+
+ instrumentName: "metamorph",
+
+ init: function () {
+ this._super.apply(this, arguments);
+ Ember['default'].deprecate("Supplying a tagName to Metamorph views is unreliable and is deprecated." + " You may be setting the tagName on a Handlebars helper that creates a Metamorph.", !this.tagName);
+
+ Ember['default'].deprecate("Using " + this.__metamorphType + " is deprecated.");
+ }
+ });
+
+ exports['default'] = View['default'].extend(_Metamorph, {
+ __metamorphType: "Ember._MetamorphView"
+ });
+
+ exports._Metamorph = _Metamorph;
+
});
-enifed('ember-views/attr_nodes/legacy_bind', ['exports', './attr_node', 'ember-runtime/system/string', 'ember-metal/utils', 'ember-metal/streams/utils', 'ember-metal/platform/create'], function (exports, AttrNode, string, utils, streams__utils, o_create) {
+enifed('ember-views/compat/render_buffer', ['exports', 'ember-views/system/jquery', 'ember-metal/core', 'ember-metal/platform/create', 'dom-helper/prop', 'ember-views/system/platform'], function (exports, jQuery, Ember, o_create, dom_helper__prop, platform) {
'use strict';
- /**
- @module ember
- @submodule ember-htmlbars
- */
+ exports.renderComponentWithBuffer = renderComponentWithBuffer;
- function LegacyBindAttrNode(attrName, attrValue) {
- this.init(attrName, attrValue);
+ var omittedStartTagChildren;
+ var omittedStartTagChildTest = /(?:<script)*.*?<([\w:]+)/i;
+
+ function detectOmittedStartTag(dom, string, contextualElement) {
+ omittedStartTagChildren = omittedStartTagChildren || {
+ tr: dom.createElement("tbody"),
+ col: dom.createElement("colgroup")
+ };
+
+ // Omitted start tags are only inside table tags.
+ if (contextualElement.tagName === "TABLE") {
+ var omittedStartTagChildMatch = omittedStartTagChildTest.exec(string);
+ if (omittedStartTagChildMatch) {
+ // It is already asserted that the contextual element is a table
+ // and not the proper start tag. Just look up the start tag.
+ return omittedStartTagChildren[omittedStartTagChildMatch[1].toLowerCase()];
+ }
+ }
}
- LegacyBindAttrNode.prototype = o_create['default'](AttrNode['default'].prototype);
+ function ClassSet() {
+ this.seen = o_create['default'](null);
+ this.list = [];
+ }
- LegacyBindAttrNode.prototype.render = function render(buffer) {
- this.isDirty = false;
- if (this.isDestroying) {
- return;
+ ClassSet.prototype = {
+ add: function (string) {
+ if (this.seen[string] === true) {
+ return;
+ }
+ this.seen[string] = true;
+
+ this.list.push(string);
}
- var value = streams__utils.read(this.attrValue);
+ };
- if (value === undefined) {
- value = null;
+ var BAD_TAG_NAME_TEST_REGEXP = /[^a-zA-Z0-9\-]/;
+ var BAD_TAG_NAME_REPLACE_REGEXP = /[^a-zA-Z0-9\-]/g;
+
+ function stripTagName(tagName) {
+ if (!tagName) {
+ return tagName;
}
- if ((this.attrName === 'value' || this.attrName === 'src') && value === null) {
- value = '';
+ if (!BAD_TAG_NAME_TEST_REGEXP.test(tagName)) {
+ return tagName;
}
- Ember.assert(string.fmt("Attributes must be numbers, strings or booleans, not %@", [value]), value === null || value === undefined || utils.typeOf(value) === 'number' || utils.typeOf(value) === 'string' || utils.typeOf(value) === 'boolean' || !!(value && value.toHTML));
+ return tagName.replace(BAD_TAG_NAME_REPLACE_REGEXP, "");
+ }
- if (this.lastValue !== null || value !== null) {
- this._deprecateEscapedStyle(value);
- this._morph.setContent(value);
- this.lastValue = value;
+ var BAD_CHARS_REGEXP = /&(?!\w+;)|[<>"'`]/g;
+ var POSSIBLE_CHARS_REGEXP = /[&<>"'`]/;
+
+ function escapeAttribute(value) {
+ // Stolen shamelessly from Handlebars
+
+ var escape = {
+ "<": "<",
+ ">": ">",
+ "\"": """,
+ "'": "'",
+ "`": "`"
+ };
+
+ var escapeChar = function (chr) {
+ return escape[chr] || "&";
+ };
+
+ var string = value.toString();
+
+ if (!POSSIBLE_CHARS_REGEXP.test(string)) {
+ return string;
}
+ return string.replace(BAD_CHARS_REGEXP, escapeChar);
+ }
+ function renderComponentWithBuffer(component, contextualElement, dom) {
+ var buffer = [];
+ component.render(buffer);
+ var element = dom.parseHTML(buffer.join(""), contextualElement);
+ return element;
+ }
+
+ /**
+ `Ember.RenderBuffer` gathers information regarding the view and generates the
+ final representation. `Ember.RenderBuffer` will generate HTML which can be pushed
+ to the DOM.
+
+ ```javascript
+ var buffer = new Ember.RenderBuffer('div', contextualElement);
+ ```
+
+ @method renderBuffer
+ @namespace Ember
+ @param {String} tagName tag name (such as 'div' or 'p') used for the buffer
+ */
+
+ var RenderBuffer = function (domHelper) {
+ this.buffer = null;
+ this.childViews = [];
+ this.attrNodes = [];
+
+ Ember['default'].assert("RenderBuffer requires a DOM helper to be passed to its constructor.", !!domHelper);
+
+ this.dom = domHelper;
};
- exports['default'] = LegacyBindAttrNode;
+ RenderBuffer.prototype = {
-});
-enifed('ember-views/component_lookup', ['exports', 'ember-runtime/system/object'], function (exports, EmberObject) {
+ reset: function (tagName, contextualElement) {
+ this.tagName = tagName;
+ this.buffer = null;
+ this._element = null;
+ this._outerContextualElement = contextualElement;
+ this.elementClasses = null;
+ this.elementId = null;
+ this.elementAttributes = null;
+ this.elementProperties = null;
+ this.elementTag = null;
+ this.elementStyle = null;
+ this.childViews.length = 0;
+ this.attrNodes.length = 0;
+ },
- 'use strict';
+ // The root view's element
+ _element: null,
- exports['default'] = EmberObject['default'].extend({
- lookupFactory: function (name, container) {
+ // The root view's contextualElement
+ _outerContextualElement: null,
- container = container || this.container;
+ /**
+ An internal set used to de-dupe class names when `addClass()` is
+ used. After each call to `addClass()`, the `classes` property
+ will be updated.
+ @private
+ @property elementClasses
+ @type Array
+ @default null
+ */
+ elementClasses: null,
- var fullName = 'component:' + name;
- var templateFullName = 'template:components/' + name;
- var templateRegistered = container && container._registry.has(templateFullName);
+ /**
+ Array of class names which will be applied in the class attribute.
+ You can use `setClasses()` to set this property directly. If you
+ use `addClass()`, it will be maintained for you.
+ @property classes
+ @type Array
+ @default null
+ */
+ classes: null,
- if (templateRegistered) {
- container._registry.injection(fullName, 'layout', templateFullName);
- }
+ /**
+ The id in of the element, to be applied in the id attribute.
+ You should not set this property yourself, rather, you should use
+ the `id()` method of `Ember.RenderBuffer`.
+ @property elementId
+ @type String
+ @default null
+ */
+ elementId: null,
- var Component = container.lookupFactory(fullName);
+ /**
+ A hash keyed on the name of the attribute and whose value will be
+ applied to that attribute. For example, if you wanted to apply a
+ `data-view="Foo.bar"` property to an element, you would set the
+ elementAttributes hash to `{'data-view':'Foo.bar'}`.
+ You should not maintain this hash yourself, rather, you should use
+ the `attr()` method of `Ember.RenderBuffer`.
+ @property elementAttributes
+ @type Hash
+ @default {}
+ */
+ elementAttributes: null,
- // Only treat as a component if either the component
- // or a template has been registered.
- if (templateRegistered || Component) {
- if (!Component) {
- container._registry.register(fullName, Ember.Component);
- Component = container.lookupFactory(fullName);
+ /**
+ A hash keyed on the name of the properties and whose value will be
+ applied to that property. For example, if you wanted to apply a
+ `checked=true` property to an element, you would set the
+ elementProperties hash to `{'checked':true}`.
+ You should not maintain this hash yourself, rather, you should use
+ the `prop()` method of `Ember.RenderBuffer`.
+ @property elementProperties
+ @type Hash
+ @default {}
+ */
+ elementProperties: null,
+
+ /**
+ The tagname of the element an instance of `Ember.RenderBuffer` represents.
+ Usually, this gets set as the first parameter to `Ember.RenderBuffer`. For
+ example, if you wanted to create a `p` tag, then you would call
+ ```javascript
+ Ember.RenderBuffer('p', contextualElement)
+ ```
+ @property elementTag
+ @type String
+ @default null
+ */
+ elementTag: null,
+
+ /**
+ A hash keyed on the name of the style attribute and whose value will
+ be applied to that attribute. For example, if you wanted to apply a
+ `background-color:black;` style to an element, you would set the
+ elementStyle hash to `{'background-color':'black'}`.
+ You should not maintain this hash yourself, rather, you should use
+ the `style()` method of `Ember.RenderBuffer`.
+ @property elementStyle
+ @type Hash
+ @default {}
+ */
+ elementStyle: null,
+
+ pushChildView: function (view) {
+ var index = this.childViews.length;
+ this.childViews[index] = view;
+ this.push("<script id='morph-" + index + "' type='text/x-placeholder'></script>");
+ },
+
+ pushAttrNode: function (node) {
+ var index = this.attrNodes.length;
+ this.attrNodes[index] = node;
+ },
+
+ hydrateMorphs: function (contextualElement) {
+ var childViews = this.childViews;
+ var el = this._element;
+ for (var i = 0, l = childViews.length; i < l; i++) {
+ var childView = childViews[i];
+ var ref = el.querySelector("#morph-" + i);
+
+ Ember['default'].assert("An error occurred while setting up template bindings. Please check " + (childView && childView.parentView && childView._parentView._debugTemplateName ? "\"" + childView._parentView._debugTemplateName + "\" template " : "") + "for invalid markup or bindings within HTML comments.", ref);
+
+ var parent = ref.parentNode;
+
+ childView._morph = this.dom.insertMorphBefore(parent, ref, parent.nodeType === 1 ? parent : contextualElement);
+ parent.removeChild(ref);
+ }
+ },
+
+ /**
+ Adds a string of HTML to the `RenderBuffer`.
+ @method push
+ @param {String} string HTML to push into the buffer
+ @chainable
+ */
+ push: function (content) {
+ if (typeof content === "string") {
+ if (this.buffer === null) {
+ this.buffer = "";
}
- return Component;
+ Ember['default'].assert("A string cannot be pushed into the buffer after a fragment", !this.buffer.nodeType);
+ this.buffer += content;
+ } else {
+ Ember['default'].assert("A fragment cannot be pushed into a buffer that contains content", !this.buffer);
+ this.buffer = content;
}
- }
- });
+ return this;
+ },
-});
-enifed('ember-views/mixins/attribute_bindings_support', ['exports', 'ember-metal/mixin', 'ember-views/attr_nodes/attr_node', 'ember-metal/properties', 'ember-views/system/platform', 'ember-metal/streams/utils', 'ember-metal/property_set'], function (exports, mixin, AttrNode, properties, platform, utils, property_set) {
+ /**
+ Adds a class to the buffer, which will be rendered to the class attribute.
+ @method addClass
+ @param {String} className Class name to add to the buffer
+ @chainable
+ */
+ addClass: function (className) {
+ // lazily create elementClasses
+ this.elementClasses = this.elementClasses || new ClassSet();
+ this.elementClasses.add(className);
+ this.classes = this.elementClasses.list;
- 'use strict';
+ return this;
+ },
- /**
- @module ember
- @submodule ember-views
- */
- var EMPTY_ARRAY = [];
+ setClasses: function (classNames) {
+ this.elementClasses = null;
+ var len = classNames.length;
+ var i;
+ for (i = 0; i < len; i++) {
+ this.addClass(classNames[i]);
+ }
+ },
- /**
- @class AttributeBindingsSupport
- @namespace Ember
- */
- var AttributeBindingsSupport = mixin.Mixin.create({
- concatenatedProperties: ['attributeBindings'],
+ /**
+ Sets the elementID to be used for the element.
+ @method id
+ @param {String} id
+ @chainable
+ */
+ id: function (id) {
+ this.elementId = id;
+ return this;
+ },
+ // duck type attribute functionality like jQuery so a render buffer
+ // can be used like a jQuery object in attribute binding scenarios.
+
/**
- A list of properties of the view to apply as attributes. If the property is
- a string value, the value of that string will be applied as the attribute.
- ```javascript
- // Applies the type attribute to the element
- // with the value "button", like <div type="button">
- Ember.View.extend({
- attributeBindings: ['type'],
- type: 'button'
- });
- ```
- If the value of the property is a Boolean, the name of that property is
- added as an attribute.
- ```javascript
- // Renders something like <div enabled="enabled">
- Ember.View.extend({
- attributeBindings: ['enabled'],
- enabled: true
- });
- ```
- @property attributeBindings
+ Adds an attribute which will be rendered to the element.
+ @method attr
+ @param {String} name The name of the attribute
+ @param {String} value The value to add to the attribute
+ @chainable
+ @return {Ember.RenderBuffer|String} this or the current attribute value
*/
- attributeBindings: EMPTY_ARRAY,
+ attr: function (name, value) {
+ var attributes = this.elementAttributes = this.elementAttributes || {};
- _attrNodes: EMPTY_ARRAY,
+ if (arguments.length === 1) {
+ return attributes[name];
+ } else {
+ attributes[name] = value;
+ }
- _unspecifiedAttributeBindings: null,
+ return this;
+ },
/**
- Iterates through the view's attribute bindings, sets up observers for each,
- then applies the current value of the attributes to the passed render buffer.
- @method _applyAttributeBindings
- @param {Ember.RenderBuffer} buffer
- @param {Array} attributeBindings
- @private
+ Remove an attribute from the list of attributes to render.
+ @method removeAttr
+ @param {String} name The name of the attribute
+ @chainable
*/
- _applyAttributeBindings: function (buffer) {
- var attributeBindings = this.attributeBindings;
+ removeAttr: function (name) {
+ var attributes = this.elementAttributes;
+ if (attributes) {
+ delete attributes[name];
+ }
- if (!attributeBindings || !attributeBindings.length) {
- return;
+ return this;
+ },
+
+ /**
+ Adds a property which will be rendered to the element.
+ @method prop
+ @param {String} name The name of the property
+ @param {String} value The value to add to the property
+ @chainable
+ @return {Ember.RenderBuffer|String} this or the current property value
+ */
+ prop: function (name, value) {
+ var properties = this.elementProperties = this.elementProperties || {};
+
+ if (arguments.length === 1) {
+ return properties[name];
+ } else {
+ properties[name] = value;
}
- var unspecifiedAttributeBindings = this._unspecifiedAttributeBindings = this._unspecifiedAttributeBindings || {};
+ return this;
+ },
- var binding, colonIndex, property, attrName, attrNode, attrValue;
- var i, l;
- for (i = 0, l = attributeBindings.length; i < l; i++) {
- binding = attributeBindings[i];
- colonIndex = binding.indexOf(':');
- if (colonIndex === -1) {
- property = binding;
- attrName = binding;
- } else {
- property = binding.substring(0, colonIndex);
- attrName = binding.substring(colonIndex + 1);
+ /**
+ Remove an property from the list of properties to render.
+ @method removeProp
+ @param {String} name The name of the property
+ @chainable
+ */
+ removeProp: function (name) {
+ var properties = this.elementProperties;
+ if (properties) {
+ delete properties[name];
+ }
+
+ return this;
+ },
+
+ /**
+ Adds a style to the style attribute which will be rendered to the element.
+ @method style
+ @param {String} name Name of the style
+ @param {String} value
+ @chainable
+ */
+ style: function (name, value) {
+ this.elementStyle = this.elementStyle || {};
+
+ this.elementStyle[name] = value;
+ return this;
+ },
+
+ generateElement: function () {
+ var tagName = this.tagName;
+ var id = this.elementId;
+ var classes = this.classes;
+ var attrs = this.elementAttributes;
+ var props = this.elementProperties;
+ var style = this.elementStyle;
+ var styleBuffer = "";
+ var attr, prop, tagString;
+
+ if (!platform.canSetNameOnInputs && attrs && attrs.name) {
+ // IE allows passing a tag to createElement. See note on `canSetNameOnInputs` above as well.
+ tagString = "<" + stripTagName(tagName) + " name=\"" + escapeAttribute(attrs.name) + "\">";
+ } else {
+ tagString = tagName;
+ }
+
+ var element = this.dom.createElement(tagString, this.outerContextualElement());
+
+ if (id) {
+ this.dom.setAttribute(element, "id", id);
+ this.elementId = null;
+ }
+ if (classes) {
+ this.dom.setAttribute(element, "class", classes.join(" "));
+ this.classes = null;
+ this.elementClasses = null;
+ }
+
+ if (style) {
+ for (prop in style) {
+ styleBuffer += prop + ":" + style[prop] + ";";
}
- Ember.assert('You cannot use class as an attributeBinding, use classNameBindings instead.', attrName !== 'class');
+ this.dom.setAttribute(element, "style", styleBuffer);
- if (property in this) {
- attrValue = this.getStream('view.' + property);
- attrNode = new AttrNode['default'](attrName, attrValue);
- this.appendAttr(attrNode);
- if (!platform.canSetNameOnInputs && attrName === 'name') {
- buffer.attr('name', utils.read(attrValue));
- }
- } else {
- unspecifiedAttributeBindings[property] = attrName;
+ this.elementStyle = null;
+ }
+
+ if (attrs) {
+ for (attr in attrs) {
+ this.dom.setAttribute(element, attr, attrs[attr]);
}
+
+ this.elementAttributes = null;
}
- // Lazily setup setUnknownProperty after attributeBindings are initially applied
- this.setUnknownProperty = this._setUnknownProperty;
+ if (props) {
+ for (prop in props) {
+ var normalizedCase = dom_helper__prop.normalizeProperty(element, prop.toLowerCase()) || prop;
+
+ this.dom.setPropertyStrict(element, normalizedCase, props[prop]);
+ }
+
+ this.elementProperties = null;
+ }
+
+ return this._element = element;
},
/**
- We're using setUnknownProperty as a hook to setup attributeBinding observers for
- properties that aren't defined on a view at initialization time.
- Note: setUnknownProperty will only be called once for each property.
- @method setUnknownProperty
- @param key
- @param value
- @private
+ @method element
+ @return {DOMElement} The element corresponding to the generated HTML
+ of this buffer
*/
- setUnknownProperty: null, // Gets defined after initialization by _applyAttributeBindings
+ element: function () {
- _setUnknownProperty: function (key, value) {
- var attrName = this._unspecifiedAttributeBindings && this._unspecifiedAttributeBindings[key];
+ if (this._element && this.attrNodes.length > 0) {
+ var i, l, attrMorph, attrNode;
+ for (i = 0, l = this.attrNodes.length; i < l; i++) {
+ attrNode = this.attrNodes[i];
+ attrMorph = this.dom.createAttrMorph(this._element, attrNode.attrName);
+ attrNode._morph = attrMorph;
+ }
+ }
- properties.defineProperty(this, key);
+ var content = this.innerContent();
+ // No content means a text node buffer, with the content
+ // in _element. Ember._BoundView is an example.
+ if (content === null) {
+ return this._element;
+ }
- if (attrName) {
- var attrValue = this.getStream('view.' + key);
- var attrNode = new AttrNode['default'](attrName, attrValue);
- this.appendAttr(attrNode);
+ var contextualElement = this.innerContextualElement(content);
+ this.dom.detectNamespace(contextualElement);
+
+ if (!this._element) {
+ this._element = this.dom.createDocumentFragment();
}
- return property_set.set(this, key, value);
+
+ if (content.nodeType) {
+ this._element.appendChild(content);
+ } else {
+ var frag = this.dom.parseHTML(content, contextualElement);
+ this._element.appendChild(frag);
+ }
+
+ // This should only happen with legacy string buffers
+ if (this.childViews.length > 0) {
+ this.hydrateMorphs(contextualElement);
+ }
+
+ return this._element;
+ },
+
+ /**
+ Generates the HTML content for this buffer.
+ @method string
+ @return {String} The generated HTML
+ */
+ string: function () {
+ if (this._element) {
+ // Firefox versions < 11 do not have support for element.outerHTML.
+ var thisElement = this.element();
+ var outerHTML = thisElement.outerHTML;
+ if (typeof outerHTML === "undefined") {
+ return jQuery['default']("<div/>").append(thisElement).html();
+ }
+ return outerHTML;
+ } else {
+ return this.innerString();
+ }
+ },
+
+ outerContextualElement: function () {
+ if (this._outerContextualElement === undefined) {
+ Ember['default'].deprecate("The render buffer expects an outer contextualElement to exist." + " This ensures DOM that requires context is correctly generated (tr, SVG tags)." + " Defaulting to document.body, but this will be removed in the future");
+ this.outerContextualElement = document.body;
+ }
+ return this._outerContextualElement;
+ },
+
+ innerContextualElement: function (html) {
+ var innerContextualElement;
+ if (this._element && this._element.nodeType === 1) {
+ innerContextualElement = this._element;
+ } else {
+ innerContextualElement = this.outerContextualElement();
+ }
+
+ var omittedStartTag;
+ if (html) {
+ omittedStartTag = detectOmittedStartTag(this.dom, html, innerContextualElement);
+ }
+ return omittedStartTag || innerContextualElement;
+ },
+
+ innerString: function () {
+ var content = this.innerContent();
+ if (content && !content.nodeType) {
+ return content;
+ }
+ },
+
+ innerContent: function () {
+ return this.buffer;
}
+ };
+
+ exports['default'] = RenderBuffer;
+
+});
+enifed('ember-views/component_lookup', ['exports', 'ember-metal/core', 'ember-runtime/system/object', 'ember-htmlbars/system/lookup-helper'], function (exports, Ember, EmberObject, lookup_helper) {
+
+ 'use strict';
+
+ exports['default'] = EmberObject['default'].extend({
+ invalidName: function (name) {
+ var invalidName = lookup_helper.ISNT_HELPER_CACHE.get(name);
+
+ if (invalidName) {
+ Ember['default'].assert("You canot use '" + name + "' as a component name. Component names must contain a hyphen.");
+ }
+ },
+
+ lookupFactory: function (name, container) {
+
+ container = container || this.container;
+
+ var fullName = "component:" + name;
+ var templateFullName = "template:components/" + name;
+ var templateRegistered = container && container._registry.has(templateFullName);
+
+ if (templateRegistered) {
+ container._registry.injection(fullName, "layout", templateFullName);
+ }
+
+ var Component = container.lookupFactory(fullName);
+
+ // Only treat as a component if either the component
+ // or a template has been registered.
+ if (templateRegistered || Component) {
+ if (!Component) {
+ container._registry.register(fullName, Ember['default'].Component);
+ Component = container.lookupFactory(fullName);
+ }
+ return Component;
+ }
+ },
+
+ componentFor: function (name, container) {
+ if (this.invalidName(name)) {
+ return;
+ }
+
+ var fullName = "component:" + name;
+ return container.lookupFactory(fullName);
+ },
+
+ layoutFor: function (name, container) {
+ if (this.invalidName(name)) {
+ return;
+ }
+
+ var templateFullName = "template:components/" + name;
+ return container.lookup(templateFullName);
+ }
});
- exports['default'] = AttributeBindingsSupport;
+});
+enifed('ember-views/initializers/components', ['ember-runtime/system/lazy_load', 'ember-views/views/text_field', 'ember-views/views/text_area', 'ember-views/views/checkbox', 'ember-views/views/legacy_each_view'], function (lazy_load, TextField, TextArea, Checkbox, LegacyEachView) {
+ 'use strict';
+
+ lazy_load.onLoad("Ember.Application", function (Application) {
+ Application.initializer({
+ name: "ember-views-components",
+ initialize: function (registry) {
+ registry.register("component:-text-field", TextField['default']);
+ registry.register("component:-text-area", TextArea['default']);
+ registry.register("component:-checkbox", Checkbox['default']);
+ registry.register("view:-legacy-each", LegacyEachView['default']);
+ }
+ });
+ });
+
});
-enifed('ember-views/mixins/class_names_support', ['exports', 'ember-metal/core', 'ember-metal/mixin', 'ember-runtime/system/native_array', 'ember-metal/enumerable_utils', 'ember-metal/streams/utils', 'ember-views/streams/class_name_binding', 'ember-metal/utils'], function (exports, Ember, mixin, native_array, enumerable_utils, utils, class_name_binding, ember_metal__utils) {
+enifed('ember-views/mixins/class_names_support', ['exports', 'ember-metal/core', 'ember-metal/mixin', 'ember-runtime/system/native_array', 'ember-metal/utils'], function (exports, Ember, mixin, native_array, utils) {
'use strict';
/**
@module ember
@@ -35042,19 +37680,19 @@
/**
@class ClassNamesSupport
@namespace Ember
*/
var ClassNamesSupport = mixin.Mixin.create({
- concatenatedProperties: ['classNames', 'classNameBindings'],
+ concatenatedProperties: ["classNames", "classNameBindings"],
init: function () {
this._super.apply(this, arguments);
- Ember['default'].assert("Only arrays are allowed for 'classNameBindings'", ember_metal__utils.typeOf(this.classNameBindings) === 'array');
+ Ember['default'].assert("Only arrays are allowed for 'classNameBindings'", utils.isArray(this.classNameBindings));
this.classNameBindings = native_array.A(this.classNameBindings.slice());
- Ember['default'].assert("Only arrays of static class strings are allowed for 'classNames'. For dynamic classes, use 'classNameBindings'.", ember_metal__utils.typeOf(this.classNames) === 'array');
+ Ember['default'].assert("Only arrays of static class strings are allowed for 'classNames'. For dynamic classes, use 'classNameBindings'.", utils.isArray(this.classNames));
this.classNames = native_array.A(this.classNames.slice());
},
/**
Standard CSS class names to apply to the view's outer element. This
@@ -35062,11 +37700,11 @@
superclasses as well.
@property classNames
@type Array
@default ['ember-view']
*/
- classNames: ['ember-view'],
+ classNames: ["ember-view"],
/**
A list of properties of the view to apply as class names. If the property
is a string value, the value of that string will be applied as a class
name.
@@ -35098,97 +37736,11 @@
This list of properties is inherited from the view's superclasses as well.
@property classNameBindings
@type Array
@default []
*/
- classNameBindings: EMPTY_ARRAY,
-
- /**
- Iterates over the view's `classNameBindings` array, inserts the value
- of the specified property into the `classNames` array, then creates an
- observer to update the view's element if the bound property ever changes
- in the future.
- @method _applyClassNameBindings
- @private
- */
- _applyClassNameBindings: function () {
- var classBindings = this.classNameBindings;
-
- if (!classBindings || !classBindings.length) {
- return;
- }
-
- var classNames = this.classNames;
- var elem, newClass, dasherizedClass;
-
- // Loop through all of the configured bindings. These will be either
- // property names ('isUrgent') or property paths relative to the view
- // ('content.isUrgent')
- enumerable_utils.forEach(classBindings, function (binding) {
-
- var boundBinding;
- if (utils.isStream(binding)) {
- boundBinding = binding;
- } else {
- boundBinding = class_name_binding.streamifyClassNameBinding(this, binding, '_view.');
- }
-
- // Variable in which the old class value is saved. The observer function
- // closes over this variable, so it knows which string to remove when
- // the property changes.
- var oldClass;
-
- // Set up an observer on the context. If the property changes, toggle the
- // class name.
- var observer = this._wrapAsScheduled(function () {
- // Get the current value of the property
- elem = this.$();
- newClass = utils.read(boundBinding);
-
- // If we had previously added a class to the element, remove it.
- if (oldClass) {
- elem.removeClass(oldClass);
- // Also remove from classNames so that if the view gets rerendered,
- // the class doesn't get added back to the DOM.
- classNames.removeObject(oldClass);
- }
-
- // If necessary, add a new class. Make sure we keep track of it so
- // it can be removed in the future.
- if (newClass) {
- elem.addClass(newClass);
- oldClass = newClass;
- } else {
- oldClass = null;
- }
- });
-
- // Get the class name for the property at its current value
- dasherizedClass = utils.read(boundBinding);
-
- if (dasherizedClass) {
- // Ensure that it gets into the classNames array
- // so it is displayed when we render.
- enumerable_utils.addObject(classNames, dasherizedClass);
-
- // Save a reference to the class name so we can remove it
- // if the observer fires. Remember that this variable has
- // been closed over by the observer.
- oldClass = dasherizedClass;
- }
-
- utils.subscribe(boundBinding, observer, this);
- // Remove className so when the view is rerendered,
- // the className is added based on binding reevaluation
- this.one('willClearRender', function () {
- if (oldClass) {
- classNames.removeObject(oldClass);
- oldClass = null;
- }
- });
- }, this);
- }
+ classNameBindings: EMPTY_ARRAY
});
exports['default'] = ClassNamesSupport;
});
@@ -35253,18 +37805,18 @@
@property instrumentDisplay
@type String
*/
instrumentDisplay: computed.computed(function () {
if (this.helperName) {
- return '{{' + this.helperName + '}}';
+ return "{{" + this.helperName + "}}";
}
}),
- instrumentName: 'view',
+ instrumentName: "view",
instrumentDetails: function (hash) {
- hash.template = property_get.get(this, 'templateName');
+ hash.template = property_get.get(this, "templateName");
this._super(hash);
}
});
exports['default'] = InstrumentationSupport;
@@ -35281,12 +37833,22 @@
var LegacyViewSupport = mixin.Mixin.create({
beforeRender: function (buffer) {},
afterRender: function (buffer) {},
+ walkChildViews: function (callback) {
+ var childViews = this.childViews.slice();
+
+ while (childViews.length) {
+ var view = childViews.pop();
+ callback(view);
+ childViews.push.apply(childViews, view.childViews);
+ }
+ },
+
mutateChildViews: function (callback) {
- var childViews = this._childViews;
+ var childViews = property_get.get(this, "childViews");
var idx = childViews.length;
var view;
while (--idx >= 0) {
view = childViews[idx];
@@ -35322,17 +37884,17 @@
@deprecated
*/
nearestChildOf: function (klass) {
Ember['default'].deprecate("nearestChildOf has been deprecated.");
- var view = property_get.get(this, 'parentView');
+ var view = property_get.get(this, "parentView");
while (view) {
- if (property_get.get(view, 'parentView') instanceof klass) {
+ if (property_get.get(view, "parentView") instanceof klass) {
return view;
}
- view = property_get.get(view, 'parentView');
+ view = property_get.get(view, "parentView");
}
},
/**
Return the nearest ancestor that is an instance of the provided
@@ -35342,17 +37904,17 @@
@return Ember.View
@deprecated
*/
nearestInstanceOf: function (klass) {
Ember['default'].deprecate("nearestInstanceOf is deprecated and will be removed from future releases. Use nearestOfType.");
- var view = property_get.get(this, 'parentView');
+ var view = property_get.get(this, "parentView");
while (view) {
if (view instanceof klass) {
return view;
}
- view = property_get.get(view, 'parentView');
+ view = property_get.get(view, "parentView");
}
}
});
exports['default'] = LegacyViewSupport;
@@ -35386,35 +37948,29 @@
exports['default'] = mixin.Mixin.create({
_states: states,
normalizedValue: function () {
var value = this.lazyValue.value();
- var valueNormalizer = property_get.get(this, 'valueNormalizerFunc');
+ var valueNormalizer = property_get.get(this, "valueNormalizerFunc");
return valueNormalizer ? valueNormalizer(value) : value;
},
rerenderIfNeeded: function () {
this.currentState.rerenderIfNeeded(this);
}
});
});
-enifed('ember-views/mixins/template_rendering_support', ['exports', 'ember-metal/mixin', 'ember-metal/property_get'], function (exports, mixin, property_get) {
+enifed('ember-views/mixins/template_rendering_support', ['exports', 'ember-metal/mixin'], function (exports, mixin) {
'use strict';
/**
@module ember
@submodule ember-views
*/
var _renderView;
- function renderView(view, buffer, template) {
- if (_renderView === undefined) {
- _renderView = eriuqer('ember-htmlbars/system/render-view')['default'];
- }
- _renderView(view, buffer, template);
- }
/**
@class TemplateRenderingSupport
@namespace Ember
*/
@@ -35427,16 +37983,17 @@
property and invoke it with the value of `context`. The value of
`context` will be the view's controller unless you override it.
@method render
@param {Ember.RenderBuffer} buffer The render buffer
*/
- render: function (buffer) {
- // If this view has a layout, it is the responsibility of the
- // the layout to render the view's template. Otherwise, render the template
- // directly.
- var template = property_get.get(this, 'layout') || property_get.get(this, 'template');
- renderView(this, buffer, template);
+
+ renderBlock: function (block, renderNode) {
+ if (_renderView === undefined) {
+ _renderView = eriuqer("ember-htmlbars/system/render-view");
+ }
+
+ return _renderView.renderHTMLBarsBlock(this, block, renderNode);
}
});
exports['default'] = TemplateRenderingSupport;
@@ -35451,11 +38008,11 @@
*/
var TextSupport = mixin.Mixin.create(TargetActionSupport['default'], {
value: "",
- attributeBindings: ['autocapitalize', 'autocorrect', 'autofocus', 'disabled', 'form', 'maxlength', 'placeholder', 'readonly', 'required', 'selectionDirection', 'spellcheck', 'tabindex', 'title'],
+ attributeBindings: ["autocapitalize", "autocorrect", "autofocus", "disabled", "form", "maxlength", "placeholder", "readonly", "required", "selectionDirection", "spellcheck", "tabindex", "title"],
placeholder: null,
disabled: false,
maxlength: null,
init: function () {
@@ -35483,11 +38040,11 @@
* `keyPress`: the user pressed a key
@property onEvent
@type String
@default enter
*/
- onEvent: 'enter',
+ onEvent: "enter",
/**
Whether the `keyUp` event that triggers an `action` to be sent continues
propagating to other views.
By default, when the user presses the return key on their keyboard and
@@ -35510,11 +38067,13 @@
return this[method](event);
}
},
_elementValueDidChange: function () {
- property_set.set(this, 'value', this.$().val());
+ // Using readDOMAttr will ensure that HTMLBars knows the last
+ // value.
+ property_set.set(this, "value", this.readDOMAttr("value"));
},
change: function (event) {
this._elementValueDidChange(event);
},
@@ -35529,12 +38088,12 @@
reference the example near the top of this file.
@method insertNewline
@param {Event} event
*/
insertNewline: function (event) {
- sendAction('enter', this, event);
- sendAction('insert-newline', this, event);
+ sendAction("enter", this, event);
+ sendAction("insert-newline", this, event);
},
/**
Allows you to specify a controller action to invoke when the escape button
is pressed. To use this method, give your field an `escape-press`
@@ -35544,11 +38103,11 @@
the example near the top of this file.
@method cancel
@param {Event} event
*/
cancel: function (event) {
- sendAction('escape-press', this, event);
+ sendAction("escape-press", this, event);
},
/**
Allows you to specify a controller action to invoke when a field receives
focus. To use this method, give your field a `focus-in` attribute. The value
@@ -35558,11 +38117,11 @@
example near the top of this file.
@method focusIn
@param {Event} event
*/
focusIn: function (event) {
- sendAction('focus-in', this, event);
+ sendAction("focus-in", this, event);
},
/**
Allows you to specify a controller action to invoke when a field loses
focus. To use this method, give your field a `focus-out` attribute. The value
@@ -35573,11 +38132,11 @@
@method focusOut
@param {Event} event
*/
focusOut: function (event) {
this._elementValueDidChange(event);
- sendAction('focus-out', this, event);
+ sendAction("focus-out", this, event);
},
/**
Allows you to specify a controller action to invoke when a key is pressed.
To use this method, give your field a `key-press` attribute. The value of
@@ -35587,11 +38146,11 @@
example near the top of this file.
@method keyPress
@param {Event} event
*/
keyPress: function (event) {
- sendAction('key-press', this, event);
+ sendAction("key-press", this, event);
},
/**
Allows you to specify a controller action to invoke when a key-up event is
fired. To use this method, give your field a `key-up` attribute. The value
@@ -35603,11 +38162,11 @@
@param {Event} event
*/
keyUp: function (event) {
this.interpretKeyEvents(event);
- this.sendAction('key-up', property_get.get(this, 'value'), event);
+ this.sendAction("key-up", property_get.get(this, "value"), event);
},
/**
Allows you to specify a controller action to invoke when a key-down event is
fired. To use this method, give your field a `key-down` attribute. The value
@@ -35617,76 +38176,54 @@
example near the top of this file.
@method keyDown
@param {Event} event
*/
keyDown: function (event) {
- this.sendAction('key-down', property_get.get(this, 'value'), event);
+ this.sendAction("key-down", property_get.get(this, "value"), event);
}
});
TextSupport.KEY_EVENTS = {
- 13: 'insertNewline',
- 27: 'cancel'
+ 13: "insertNewline",
+ 27: "cancel"
};
// In principle, this shouldn't be necessary, but the legacy
// sendAction semantics for TextField are different from
// the component semantics so this method normalizes them.
function sendAction(eventName, view, event) {
- var action = property_get.get(view, eventName);
- var on = property_get.get(view, 'onEvent');
- var value = property_get.get(view, 'value');
+ var action = property_get.get(view, "attrs." + eventName) || property_get.get(view, eventName);
+ var on = property_get.get(view, "onEvent");
+ var value = property_get.get(view, "value");
// back-compat support for keyPress as an event name even though
// it's also a method name that consumes the event (and therefore
// incompatible with sendAction semantics).
- if (on === eventName || on === 'keyPress' && eventName === 'key-press') {
- view.sendAction('action', value);
+ if (on === eventName || on === "keyPress" && eventName === "key-press") {
+ view.sendAction("action", value);
}
view.sendAction(eventName, value);
if (action || on === eventName) {
- if (!property_get.get(view, 'bubbles')) {
+ if (!property_get.get(view, "bubbles")) {
event.stopPropagation();
}
}
}
exports['default'] = TextSupport;
});
-enifed('ember-views/mixins/view_child_views_support', ['exports', 'ember-metal/core', 'ember-metal/mixin', 'ember-metal/computed', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/set_properties', 'ember-metal/error', 'ember-metal/enumerable_utils', 'ember-runtime/system/native_array'], function (exports, Ember, mixin, computed, property_get, property_set, setProperties, EmberError, enumerable_utils, native_array) {
+enifed('ember-views/mixins/view_child_views_support', ['exports', 'ember-metal/core', 'ember-metal/mixin', 'ember-metal/enumerable_utils', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/set_properties'], function (exports, Ember, mixin, enumerable_utils, property_get, property_set, setProperties) {
'use strict';
/**
@module ember
@submodule ember-views
*/
- var childViewsProperty = computed.computed(function () {
- var childViews = this._childViews;
- var ret = native_array.A();
-
- enumerable_utils.forEach(childViews, function (view) {
- var currentChildViews;
- if (view.isVirtual) {
- if (currentChildViews = property_get.get(view, 'childViews')) {
- ret.pushObjects(currentChildViews);
- }
- } else {
- ret.push(view);
- }
- });
-
- ret.replace = function (idx, removedCount, addedViews) {
- throw new EmberError['default']("childViews is immutable");
- };
-
- return ret;
- });
-
var EMPTY_ARRAY = [];
var ViewChildViewsSupport = mixin.Mixin.create({
/**
Array of child views. You should never edit this array directly.
@@ -35694,23 +38231,28 @@
@property childViews
@type Array
@default []
@private
*/
- childViews: childViewsProperty,
+ childViews: EMPTY_ARRAY,
- _childViews: EMPTY_ARRAY,
-
init: function () {
+ this._super.apply(this, arguments);
+
// setup child views. be sure to clone the child views array first
- this._childViews = this._childViews.slice();
+ // 2.0TODO: Remove Ember.A() here
+ this.childViews = Ember['default'].A(this.childViews.slice());
+ this.ownerView = this;
+ },
- this._super.apply(this, arguments);
+ appendChild: function (view) {
+ this.linkChild(view);
+ this.childViews.push(view);
},
- appendChild: function (view, options) {
- return this.currentState.appendChild(this, view, options);
+ destroyChild: function (view) {
+ view.destroy();
},
/**
Removes the child view from the parent view.
@method removeChild
@@ -35724,19 +38266,17 @@
if (this.isDestroying) {
return;
}
// update parent node
- property_set.set(view, '_parentView', null);
+ this.unlinkChild(view);
// remove view from childViews array.
- var childViews = this._childViews;
+ var childViews = property_get.get(this, "childViews");
enumerable_utils.removeObject(childViews, view);
- this.propertyDidChange('childViews'); // HUH?! what happened to will change?
-
return this;
},
/**
Instantiates a view to be added to the childViews array during view
@@ -35752,62 +38292,71 @@
createChildView: function (maybeViewClass, _attrs) {
if (!maybeViewClass) {
throw new TypeError("createChildViews first argument must exist");
}
- if (maybeViewClass.isView && maybeViewClass._parentView === this && maybeViewClass.container === this.container) {
+ if (maybeViewClass.isView && maybeViewClass.parentView === this && maybeViewClass.container === this.container) {
return maybeViewClass;
}
var attrs = _attrs || {};
var view;
- attrs._parentView = this;
attrs.renderer = this.renderer;
if (maybeViewClass.isViewClass) {
attrs.container = this.container;
view = maybeViewClass.create(attrs);
- // don't set the property on a virtual view, as they are invisible to
- // consumers of the view API
if (view.viewName) {
- property_set.set(property_get.get(this, 'concreteView'), view.viewName, view);
+ property_set.set(this, view.viewName, view);
}
- } else if ('string' === typeof maybeViewClass) {
- var fullName = 'view:' + maybeViewClass;
+ } else if ("string" === typeof maybeViewClass) {
+ var fullName = "view:" + maybeViewClass;
var ViewKlass = this.container.lookupFactory(fullName);
Ember['default'].assert("Could not find view: '" + fullName + "'", !!ViewKlass);
view = ViewKlass.create(attrs);
} else {
view = maybeViewClass;
- Ember['default'].assert('You must pass instance or subclass of View', view.isView);
+ Ember['default'].assert("You must pass instance or subclass of View", view.isView);
attrs.container = this.container;
setProperties['default'](view, attrs);
}
+ this.linkChild(view);
+
return view;
+ },
+
+ linkChild: function (instance) {
+ instance.container = this.container;
+ property_set.set(instance, "parentView", this);
+ instance.trigger("parentViewDidChange");
+ instance.ownerView = this.ownerView;
+ },
+
+ unlinkChild: function (instance) {
+ property_set.set(instance, "parentView", null);
+ instance.trigger("parentViewDidChange");
}
});
exports['default'] = ViewChildViewsSupport;
- exports.childViewsProperty = childViewsProperty;
-
});
-enifed('ember-views/mixins/view_context_support', ['exports', 'ember-metal/mixin', 'ember-metal/computed', 'ember-metal/property_get', 'ember-metal/property_set'], function (exports, mixin, computed, property_get, property_set) {
+enifed('ember-views/mixins/view_context_support', ['exports', 'ember-metal/mixin', 'ember-metal/computed', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-views/mixins/legacy_view_support', 'ember-metal/events'], function (exports, mixin, computed, property_get, property_set, LegacyViewSupport, events) {
'use strict';
/**
@module ember
@submodule ember-views
*/
- var ViewContextSupport = mixin.Mixin.create({
+ var ViewContextSupport = mixin.Mixin.create(LegacyViewSupport['default'], {
/**
The object from which templates should access properties.
This object will be passed to the template function each time the render
method is called, but it is up to the individual function to decide what
to do with it.
@@ -35815,14 +38364,14 @@
@property context
@type Object
*/
context: computed.computed({
get: function () {
- return property_get.get(this, '_context');
+ return property_get.get(this, "_context");
},
set: function (key, value) {
- property_set.set(this, '_context', value);
+ property_set.set(this, "_context", value);
return value;
}
})["volatile"](),
/**
@@ -35841,17 +38390,17 @@
*/
_context: computed.computed({
get: function () {
var parentView, controller;
- if (controller = property_get.get(this, 'controller')) {
+ if (controller = property_get.get(this, "controller")) {
return controller;
}
- parentView = this._parentView;
+ parentView = this.parentView;
if (parentView) {
- return property_get.get(parentView, '_context');
+ return property_get.get(parentView, "_context");
}
return null;
},
set: function (key, value) {
return value;
@@ -35870,64 +38419,32 @@
get: function () {
if (this._controller) {
return this._controller;
}
- return this._parentView ? property_get.get(this._parentView, 'controller') : null;
+ return this.parentView ? property_get.get(this.parentView, "controller") : null;
},
set: function (_, value) {
this._controller = value;
return value;
}
+ }),
+
+ _legacyControllerDidChange: mixin.observer("controller", function () {
+ this.walkChildViews(function (view) {
+ return view.notifyPropertyChange("controller");
+ });
+ }),
+
+ _notifyControllerChange: events.on("parentViewDidChange", function () {
+ this.notifyPropertyChange("controller");
})
});
exports['default'] = ViewContextSupport;
});
-enifed('ember-views/mixins/view_keyword_support', ['exports', 'ember-metal/mixin', 'ember-metal/platform/create', 'ember-views/streams/key_stream'], function (exports, mixin, create, KeyStream) {
-
- 'use strict';
-
- var ViewKeywordSupport = mixin.Mixin.create({
- init: function () {
- this._super.apply(this, arguments);
-
- if (!this._keywords) {
- this._keywords = create['default'](null);
- }
- this._keywords._view = this;
- this._keywords.view = undefined;
- this._keywords.controller = new KeyStream['default'](this, 'controller');
- this._setupKeywords();
- },
-
- _setupKeywords: function () {
- var keywords = this._keywords;
- var contextView = this._contextView || this._parentView;
-
- if (contextView) {
- var parentKeywords = contextView._keywords;
-
- keywords.view = this.isVirtual ? parentKeywords.view : this;
-
- for (var name in parentKeywords) {
- if (keywords[name]) {
- continue;
- }
-
- keywords[name] = parentKeywords[name];
- }
- } else {
- keywords.view = this.isVirtual ? null : this;
- }
- }
- });
-
- exports['default'] = ViewKeywordSupport;
-
-});
enifed('ember-views/mixins/view_state_support', ['exports', 'ember-metal/core', 'ember-metal/mixin'], function (exports, Ember, mixin) {
'use strict';
var ViewStateSupport = mixin.Mixin.create({
@@ -35951,117 +38468,23 @@
});
exports['default'] = ViewStateSupport;
});
-enifed('ember-views/mixins/view_stream_support', ['exports', 'ember-metal/mixin', 'ember-metal/streams/stream_binding', 'ember-views/streams/key_stream', 'ember-views/streams/context_stream', 'ember-metal/platform/create', 'ember-metal/streams/utils'], function (exports, mixin, StreamBinding, KeyStream, ContextStream, create, utils) {
-
- 'use strict';
-
- var ViewStreamSupport = mixin.Mixin.create({
- init: function () {
- this._baseContext = undefined;
- this._contextStream = undefined;
- this._streamBindings = undefined;
- this._super.apply(this, arguments);
- },
-
- getStream: function (path) {
- var stream = this._getContextStream().get(path);
-
- stream._label = path;
-
- return stream;
- },
-
- _willDestroyElement: function () {
- if (this._streamBindings) {
- this._destroyStreamBindings();
- }
- if (this._contextStream) {
- this._destroyContextStream();
- }
- },
-
- _getBindingForStream: function (pathOrStream) {
- if (this._streamBindings === undefined) {
- this._streamBindings = create['default'](null);
- }
-
- var path = pathOrStream;
- if (utils.isStream(pathOrStream)) {
- path = pathOrStream._label;
-
- if (!path) {
- // if no _label is present on the provided stream
- // it is likely a subexpr and cannot be set (so it
- // does not need a StreamBinding)
- return pathOrStream;
- }
- }
-
- if (this._streamBindings[path] !== undefined) {
- return this._streamBindings[path];
- } else {
- var stream = this._getContextStream().get(path);
- var streamBinding = new StreamBinding['default'](stream);
-
- streamBinding._label = path;
-
- return this._streamBindings[path] = streamBinding;
- }
- },
-
- _destroyStreamBindings: function () {
- var streamBindings = this._streamBindings;
- for (var path in streamBindings) {
- streamBindings[path].destroy();
- }
- this._streamBindings = undefined;
- },
-
- _getContextStream: function () {
- if (this._contextStream === undefined) {
- this._baseContext = new KeyStream['default'](this, 'context');
- this._contextStream = new ContextStream['default'](this);
- }
-
- return this._contextStream;
- },
-
- _destroyContextStream: function () {
- this._baseContext.destroy();
- this._baseContext = undefined;
- this._contextStream.destroy();
- this._contextStream = undefined;
- },
-
- _unsubscribeFromStreamBindings: function () {
- for (var key in this._streamBindingSubscriptions) {
- var streamBinding = this[key + 'Binding'];
- var callback = this._streamBindingSubscriptions[key];
- streamBinding.unsubscribe(callback);
- }
- }
- });
-
- exports['default'] = ViewStreamSupport;
-
-});
enifed('ember-views/mixins/view_target_action_support', ['exports', 'ember-metal/mixin', 'ember-runtime/mixins/target_action_support', 'ember-metal/alias'], function (exports, mixin, TargetActionSupport, alias) {
'use strict';
exports['default'] = mixin.Mixin.create(TargetActionSupport['default'], {
/**
@property target
*/
- target: alias['default']('controller'),
+ target: alias['default']("controller"),
/**
@property actionContext
*/
- actionContext: alias['default']('context')
+ actionContext: alias['default']("context")
});
});
enifed('ember-views/mixins/visibility_support', ['exports', 'ember-metal/mixin', 'ember-metal/property_get', 'ember-metal/run_loop'], function (exports, mixin, property_get, run) {
@@ -36095,20 +38518,20 @@
When the view's `isVisible` property changes, toggle the visibility
element of the actual DOM element.
@method _isVisibleDidChange
@private
*/
- _isVisibleDidChange: mixin.observer('isVisible', function () {
- if (this._isVisible === property_get.get(this, 'isVisible')) {
+ _isVisibleDidChange: mixin.observer("isVisible", function () {
+ if (this._isVisible === property_get.get(this, "isVisible")) {
return;
}
- run['default'].scheduleOnce('render', this, this._toggleVisibility);
+ run['default'].scheduleOnce("render", this, this._toggleVisibility);
}),
_toggleVisibility: function () {
var $el = this.$();
- var isVisible = property_get.get(this, 'isVisible');
+ var isVisible = property_get.get(this, "isVisible");
if (this._isVisible === isVisible) {
return;
}
@@ -36132,41 +38555,41 @@
this._notifyBecameHidden();
}
},
_notifyBecameVisible: function () {
- this.trigger('becameVisible');
+ this.trigger("becameVisible");
this.forEachChildView(function (view) {
- var isVisible = property_get.get(view, 'isVisible');
+ var isVisible = property_get.get(view, "isVisible");
if (isVisible || isVisible === null) {
view._notifyBecameVisible();
}
});
},
_notifyBecameHidden: function () {
- this.trigger('becameHidden');
+ this.trigger("becameHidden");
this.forEachChildView(function (view) {
- var isVisible = property_get.get(view, 'isVisible');
+ var isVisible = property_get.get(view, "isVisible");
if (isVisible || isVisible === null) {
view._notifyBecameHidden();
}
});
},
_isAncestorHidden: function () {
- var parent = property_get.get(this, 'parentView');
+ var parent = property_get.get(this, "parentView");
while (parent) {
- if (property_get.get(parent, 'isVisible') === false) {
+ if (property_get.get(parent, "isVisible") === false) {
return true;
}
- parent = property_get.get(parent, 'parentView');
+ parent = property_get.get(parent, "parentView");
}
return false;
}
});
@@ -36180,12 +38603,31 @@
exports.parsePropertyPath = parsePropertyPath;
exports.classStringForValue = classStringForValue;
exports.streamifyClassNameBinding = streamifyClassNameBinding;
+ /**
+ Parse a path and return an object which holds the parsed properties.
+
+ For example a path like "content.isEnabled:enabled:disabled" will return the
+ following object:
+
+ ```javascript
+ {
+ path: "content.isEnabled",
+ className: "enabled",
+ falsyClassName: "disabled",
+ classNames: ":enabled:disabled"
+ }
+ ```
+
+ @method parsePropertyPath
+ @static
+ @private
+ */
function parsePropertyPath(path) {
- var split = path.split(':');
+ var split = path.split(":");
var propertyPath = split[0];
var classNames = "";
var className, falsyClassName;
// check if the property is defined as prop:class or prop:trueClass:falseClass
@@ -36193,52 +38635,27 @@
className = split[1];
if (split.length === 3) {
falsyClassName = split[2];
}
- classNames = ':' + className;
+ classNames = ":" + className;
if (falsyClassName) {
classNames += ":" + falsyClassName;
}
}
return {
path: propertyPath,
classNames: classNames,
- className: className === '' ? undefined : className,
+ className: className === "" ? undefined : className,
falsyClassName: falsyClassName
};
}
- /**
- Get the class name for a given value, based on the path, optional
- `className` and optional `falsyClassName`.
-
- - if a `className` or `falsyClassName` has been specified:
- - if the value is truthy and `className` has been specified,
- `className` is returned
- - if the value is falsy and `falsyClassName` has been specified,
- `falsyClassName` is returned
- - otherwise `null` is returned
- - if the value is `true`, the dasherized last part of the supplied path
- is returned
- - if the value is not `false`, `undefined` or `null`, the `value`
- is returned
- - if none of the above rules apply, `null` is returned
-
- @method classStringForValue
- @param path
- @param val
- @param className
- @param falsyClassName
- @static
- @private
- */
-
function classStringForValue(path, val, className, falsyClassName) {
if (ember_metal__utils.isArray(val)) {
- val = property_get.get(val, 'length') !== 0;
+ val = property_get.get(val, "length") !== 0;
}
// When using the colon syntax, evaluate the truthiness or falsiness
// of the value to determine which className to return
if (className || falsyClassName) {
@@ -36251,256 +38668,113 @@
}
// If value is a Boolean and true, return the dasherized property
// name.
} else if (val === true) {
- // Normalize property path to be suitable for use
- // as a class name. For exaple, content.foo.barBaz
- // becomes bar-baz.
- var parts = path.split('.');
- return string.dasherize(parts[parts.length - 1]);
+ // Normalize property path to be suitable for use
+ // as a class name. For exaple, content.foo.barBaz
+ // becomes bar-baz.
+ var parts = path.split(".");
+ return string.dasherize(parts[parts.length - 1]);
- // If the value is not false, undefined, or null, return the current
- // value of the property.
- } else if (val !== false && val != null) {
- return val;
+ // If the value is not false, undefined, or null, return the current
+ // value of the property.
+ } else if (val !== false && val != null) {
+ return val;
- // Nothing to display. Return null so that the old class is removed
- // but no new class is added.
- } else {
- return null;
- }
+ // Nothing to display. Return null so that the old class is removed
+ // but no new class is added.
+ } else {
+ return null;
+ }
}
function streamifyClassNameBinding(view, classNameBinding, prefix) {
- prefix = prefix || '';
- Ember.assert("classNameBindings must not have spaces in them. Multiple class name bindings can be provided as elements of an array, e.g. ['foo', ':bar']", classNameBinding.indexOf(' ') === -1);
+ prefix = prefix || "";
+ Ember.assert("classNameBindings must not have spaces in them. Multiple class name bindings can be provided as elements of an array, e.g. ['foo', ':bar']", classNameBinding.indexOf(" ") === -1);
var parsedPath = parsePropertyPath(classNameBinding);
- if (parsedPath.path === '') {
+ if (parsedPath.path === "") {
return classStringForValue(parsedPath.path, true, parsedPath.className, parsedPath.falsyClassName);
} else {
var pathValue = view.getStream(prefix + parsedPath.path);
return utils.chain(pathValue, function () {
return classStringForValue(parsedPath.path, utils.read(pathValue), parsedPath.className, parsedPath.falsyClassName);
});
}
}
});
-enifed('ember-views/streams/context_stream', ['exports', 'ember-metal/core', 'ember-metal/merge', 'ember-metal/platform/create', 'ember-metal/path_cache', 'ember-metal/streams/stream', 'ember-metal/streams/simple'], function (exports, Ember, merge, create, path_cache, Stream, SimpleStream) {
+enifed('ember-views/streams/should_display', ['exports', 'ember-metal/platform/create', 'ember-metal/merge', 'ember-metal/property_get', 'ember-runtime/utils', 'ember-metal/streams/stream', 'ember-metal/streams/utils'], function (exports, create, merge, property_get, utils, Stream, streams__utils) {
'use strict';
- function ContextStream(view) {
- Ember['default'].assert("ContextStream error: the argument is not a view", view && view.isView);
- this.init();
- this.view = view;
- }
- ContextStream.prototype = create['default'](Stream['default'].prototype);
-
- merge['default'](ContextStream.prototype, {
- value: function () {},
-
- _makeChildStream: function (key, _fullPath) {
- var stream;
-
- if (key === '' || key === 'this') {
- stream = this.view._baseContext;
- } else if (path_cache.isGlobal(key) && Ember['default'].lookup[key]) {
- Ember['default'].deprecate("Global lookup of " + _fullPath + " from a Handlebars template is deprecated.");
- stream = new SimpleStream['default'](Ember['default'].lookup[key]);
- stream._isGlobal = true;
- } else if (key in this.view._keywords) {
- stream = new SimpleStream['default'](this.view._keywords[key]);
- } else {
- stream = new SimpleStream['default'](this.view._baseContext.get(key));
- }
-
- stream._isRoot = true;
-
- if (key === 'controller') {
- stream._isController = true;
- }
-
- return stream;
- }
- });
-
- exports['default'] = ContextStream;
-
-});
-enifed('ember-views/streams/key_stream', ['exports', 'ember-metal/core', 'ember-metal/merge', 'ember-metal/platform/create', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/observer', 'ember-metal/streams/stream', 'ember-metal/streams/utils'], function (exports, Ember, merge, create, property_get, property_set, observer, Stream, utils) {
-
- 'use strict';
-
- function KeyStream(source, key) {
- Ember['default'].assert("KeyStream error: key must be a non-empty string", typeof key === 'string' && key.length > 0);
- Ember['default'].assert("KeyStream error: key must not have a '.'", key.indexOf('.') === -1);
-
- this.init();
- this.source = source;
- this.obj = undefined;
- this.key = key;
-
- if (utils.isStream(source)) {
- source.subscribe(this._didChange, this);
- }
- }
-
- KeyStream.prototype = create['default'](Stream['default'].prototype);
-
- merge['default'](KeyStream.prototype, {
- valueFn: function () {
- var prevObj = this.obj;
- var nextObj = utils.read(this.source);
-
- if (nextObj !== prevObj) {
- if (prevObj && typeof prevObj === 'object') {
- observer.removeObserver(prevObj, this.key, this, this._didChange);
- }
-
- if (nextObj && typeof nextObj === 'object') {
- observer.addObserver(nextObj, this.key, this, this._didChange);
- }
-
- this.obj = nextObj;
- }
-
- if (nextObj) {
- return property_get.get(nextObj, this.key);
- }
- },
-
- setValue: function (value) {
- if (this.obj) {
- property_set.set(this.obj, this.key, value);
- }
- },
-
- setSource: function (nextSource) {
- Ember['default'].assert("KeyStream error: source must be an object", typeof nextSource === 'object');
-
- var prevSource = this.source;
-
- if (nextSource !== prevSource) {
- if (utils.isStream(prevSource)) {
- prevSource.unsubscribe(this._didChange, this);
- }
-
- if (utils.isStream(nextSource)) {
- nextSource.subscribe(this._didChange, this);
- }
-
- this.source = nextSource;
- this.notify();
- }
- },
-
- _didChange: function () {
- this.notify();
- },
-
- _super$destroy: Stream['default'].prototype.destroy,
-
- destroy: function () {
- if (this._super$destroy()) {
- if (utils.isStream(this.source)) {
- this.source.unsubscribe(this._didChange, this);
- }
-
- if (this.obj && typeof this.obj === 'object') {
- observer.removeObserver(this.obj, this.key, this, this._didChange);
- }
-
- this.source = undefined;
- this.obj = undefined;
- return true;
- }
- }
- });
-
- exports['default'] = KeyStream;
-
- // The transpiler does not resolve cycles, so we export
- // the `_makeChildStream` method onto `Stream` here.
-
- Stream['default'].prototype._makeChildStream = function (key) {
- return new KeyStream(this, key);
- };
-
-});
-enifed('ember-views/streams/should_display', ['exports', 'ember-metal/streams/stream', 'ember-metal/streams/utils', 'ember-metal/platform/create', 'ember-metal/property_get', 'ember-metal/utils'], function (exports, Stream, utils, create, property_get, ember_metal__utils) {
-
- 'use strict';
-
-
-
exports['default'] = shouldDisplay;
function shouldDisplay(predicate) {
- if (utils.isStream(predicate)) {
+ if (streams__utils.isStream(predicate)) {
return new ShouldDisplayStream(predicate);
}
- var truthy = predicate && property_get.get(predicate, 'isTruthy');
- if (typeof truthy === 'boolean') {
+ var truthy = predicate && property_get.get(predicate, "isTruthy");
+ if (typeof truthy === "boolean") {
return truthy;
}
- if (ember_metal__utils.isArray(predicate)) {
- return property_get.get(predicate, 'length') !== 0;
+ if (utils.isArray(predicate)) {
+ return property_get.get(predicate, "length") !== 0;
} else {
return !!predicate;
}
}
- function ShouldDisplayStream(predicateStream) {
+ function ShouldDisplayStream(predicate) {
+ Ember.assert("ShouldDisplayStream error: predicate must be a stream", streams__utils.isStream(predicate));
+
+ var isTruthy = predicate.get("isTruthy");
+
this.init();
- this.oldPredicate = undefined;
- this.predicateStream = predicateStream;
- this.isTruthyStream = predicateStream.get('isTruthy');
- this.lengthStream = undefined;
- utils.subscribe(this.predicateStream, this.notify, this);
- utils.subscribe(this.isTruthyStream, this.notify, this);
+ this.predicate = predicate;
+ this.isTruthy = isTruthy;
+ this.lengthDep = null;
+
+ this.addDependency(predicate);
+ this.addDependency(isTruthy);
}
ShouldDisplayStream.prototype = create['default'](Stream['default'].prototype);
- ShouldDisplayStream.prototype.valueFn = function () {
- var oldPredicate = this.oldPredicate;
- var newPredicate = utils.read(this.predicateStream);
- var newIsArray = ember_metal__utils.isArray(newPredicate);
+ merge['default'](ShouldDisplayStream.prototype, {
+ compute: function () {
+ var truthy = streams__utils.read(this.isTruthy);
- if (newPredicate !== oldPredicate) {
+ if (typeof truthy === "boolean") {
+ return truthy;
+ }
- if (this.lengthStream && !newIsArray) {
- utils.unsubscribe(this.lengthStream, this.notify, this);
- this.lengthStream = undefined;
+ if (this.lengthDep) {
+ return this.lengthDep.getValue() !== 0;
+ } else {
+ return !!streams__utils.read(this.predicate);
}
+ },
- if (!this.lengthStream && newIsArray) {
- this.lengthStream = this.predicateStream.get('length');
- utils.subscribe(this.lengthStream, this.notify, this);
+ revalidate: function () {
+ if (utils.isArray(streams__utils.read(this.predicate))) {
+ if (!this.lengthDep) {
+ this.lengthDep = this.addMutableDependency(this.predicate.get("length"));
+ }
+ } else {
+ if (this.lengthDep) {
+ this.lengthDep.destroy();
+ this.lengthDep = null;
+ }
}
- this.oldPredicate = newPredicate;
}
+ });
- var truthy = utils.read(this.isTruthyStream);
- if (typeof truthy === 'boolean') {
- return truthy;
- }
-
- if (this.lengthStream) {
- var length = utils.read(this.lengthStream);
- return length !== 0;
- }
-
- return !!newPredicate;
- };
-
});
enifed('ember-views/streams/utils', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/path_cache', 'ember-runtime/system/string', 'ember-metal/streams/utils', 'ember-views/views/view', 'ember-runtime/mixins/controller'], function (exports, Ember, property_get, path_cache, string, utils, View, ControllerMixin) {
'use strict';
@@ -36510,17 +38784,17 @@
function readViewFactory(object, container) {
var value = utils.read(object);
var viewClass;
- if (typeof value === 'string') {
+ if (typeof value === "string") {
if (path_cache.isGlobal(value)) {
viewClass = property_get.get(null, value);
- Ember['default'].deprecate('Resolved the view "' + value + '" on the global context. Pass a view name to be looked up on the container instead, such as {{view "select"}}.', !viewClass, { url: 'http://emberjs.com/guides/deprecations/#toc_global-lookup-of-views' });
+ Ember['default'].deprecate("Resolved the view \"" + value + "\" on the global context. Pass a view name to be looked up on the container instead, such as {{view \"select\"}}.", !viewClass, { url: "http://emberjs.com/guides/deprecations/#toc_global-lookup-of-views" });
} else {
Ember['default'].assert("View requires a container to resolve views not passed in through the context", !!container);
- viewClass = container.lookupFactory('view:' + value);
+ viewClass = container.lookupFactory("view:" + value);
}
} else {
viewClass = value;
}
@@ -36529,24 +38803,24 @@
return viewClass;
}
function readComponentFactory(nameOrStream, container) {
var name = utils.read(nameOrStream);
- var componentLookup = container.lookup('component-lookup:main');
+ var componentLookup = container.lookup("component-lookup:main");
Ember['default'].assert("Could not find 'component-lookup:main' on the provided container," + " which is necessary for performing component lookups", componentLookup);
return componentLookup.lookupFactory(name, container);
}
function readUnwrappedModel(object) {
if (utils.isStream(object)) {
var result = object.value();
// If the path is exactly `controller` then we don't unwrap it.
- if (!object._isController) {
+ if (object.label !== "controller") {
while (ControllerMixin['default'].detect(result)) {
- result = property_get.get(result, 'model');
+ result = property_get.get(result, "model");
}
}
return result;
} else {
@@ -36576,14 +38850,289 @@
ActionManager.registeredActions = {};
exports['default'] = ActionManager;
});
-enifed('ember-views/system/event_dispatcher', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/is_none', 'ember-metal/run_loop', 'ember-metal/utils', 'ember-runtime/system/string', 'ember-runtime/system/object', 'ember-views/system/jquery', 'ember-views/system/action_manager', 'ember-views/views/view', 'ember-metal/merge'], function (exports, Ember, property_get, property_set, isNone, run, utils, string, EmberObject, jQuery, ActionManager, View, merge) {
+enifed('ember-views/system/build-component-template', ['exports', 'htmlbars-runtime', 'ember-htmlbars/hooks/get-value', 'ember-metal/property_get', 'ember-metal/path_cache'], function (exports, htmlbars_runtime, getValue, property_get, path_cache) {
'use strict';
+
+
+ exports['default'] = buildComponentTemplate;
+
+ function buildComponentTemplate(_ref, attrs, content) {
+ var component = _ref.component;
+ var layout = _ref.layout;
+ var isAngleBracket = _ref.isAngleBracket;
+
+ var blockToRender, tagName, meta;
+
+ if (component === undefined) {
+ component = null;
+ }
+
+ if (layout && layout.raw) {
+ var yieldTo = createContentBlocks(content.templates, content.scope, content.self, component);
+ blockToRender = createLayoutBlock(layout.raw, yieldTo, content.self, component, attrs);
+ meta = layout.raw.meta;
+ } else if (content.templates && content.templates["default"]) {
+ blockToRender = createContentBlock(content.templates["default"], content.scope, content.self, component);
+ meta = content.templates["default"].meta;
+ }
+
+ if (component) {
+ tagName = tagNameFor(component);
+
+ // If this is not a tagless component, we need to create the wrapping
+ // element. We use `manualElement` to create a template that represents
+ // the wrapping element and yields to the previous block.
+ if (tagName !== "") {
+ var attributes = normalizeComponentAttributes(component, isAngleBracket, attrs);
+ var elementTemplate = htmlbars_runtime.internal.manualElement(tagName, attributes);
+ elementTemplate.meta = meta;
+
+ blockToRender = createElementBlock(elementTemplate, blockToRender, component);
+ } else {
+ validateTaglessComponent(component);
+ }
+ }
+
+ // tagName is one of:
+ // * `undefined` if no component is present
+ // * the falsy value "" if set explicitly on the component
+ // * an actual tagName set explicitly on the component
+ return { createdElement: !!tagName, block: blockToRender };
+ }
+
+ function blockFor(template, options) {
+ Ember.assert("BUG: Must pass a template to blockFor", !!template);
+ return htmlbars_runtime.internal.blockFor(htmlbars_runtime.render, template, options);
+ }
+
+ function createContentBlock(template, scope, self, component) {
+ Ember.assert("BUG: buildComponentTemplate can take a scope or a self, but not both", !(scope && self));
+
+ return blockFor(template, {
+ scope: scope,
+ self: self,
+ options: { view: component }
+ });
+ }
+
+ function createContentBlocks(templates, scope, self, component) {
+ if (!templates) {
+ return;
+ }
+ var output = {};
+ for (var name in templates) {
+ if (templates.hasOwnProperty(name)) {
+ var template = templates[name];
+ if (template) {
+ output[name] = createContentBlock(templates[name], scope, self, component);
+ }
+ }
+ }
+ return output;
+ }
+
+ function createLayoutBlock(template, yieldTo, self, component, attrs) {
+ return blockFor(template, {
+ yieldTo: yieldTo,
+
+ // If we have an old-style Controller with a template it will be
+ // passed as our `self` argument, and it should be the context for
+ // the template. Otherwise, we must have a real Component and it
+ // should be its own template context.
+ self: self || component,
+
+ options: { view: component, attrs: attrs }
+ });
+ }
+
+ function createElementBlock(template, yieldTo, component) {
+ return blockFor(template, {
+ yieldTo: yieldTo,
+ self: component,
+ options: { view: component }
+ });
+ }
+
+ function tagNameFor(view) {
+ var tagName = view.tagName;
+
+ if (tagName !== null && typeof tagName === "object" && tagName.isDescriptor) {
+ tagName = property_get.get(view, "tagName");
+ Ember.deprecate("In the future using a computed property to define tagName will not be permitted. That value will be respected, but changing it will not update the element.", !tagName);
+ }
+
+ if (tagName === null || tagName === undefined) {
+ tagName = view._defaultTagName || "div";
+ }
+
+ return tagName;
+ }
+
+ // Takes a component and builds a normalized set of attribute
+ // bindings consumable by HTMLBars' `attribute` hook.
+ function normalizeComponentAttributes(component, isAngleBracket, attrs) {
+ var normalized = {};
+ var attributeBindings = component.attributeBindings;
+ var i, l;
+
+ if (attributeBindings) {
+ for (i = 0, l = attributeBindings.length; i < l; i++) {
+ var attr = attributeBindings[i];
+ var colonIndex = attr.indexOf(":");
+
+ var attrName, expression;
+ if (colonIndex !== -1) {
+ var attrProperty = attr.substring(0, colonIndex);
+ attrName = attr.substring(colonIndex + 1);
+ expression = ["get", "view." + attrProperty];
+ } else if (attrs[attr]) {
+ // TODO: For compatibility with 1.x, we probably need to `set`
+ // the component's attribute here if it is a CP, but we also
+ // probably want to suspend observers and allow the
+ // willUpdateAttrs logic to trigger observers at the correct time.
+ attrName = attr;
+ expression = ["value", attrs[attr]];
+ } else {
+ attrName = attr;
+ expression = ["get", "view." + attr];
+ }
+
+ Ember.assert("You cannot use class as an attributeBinding, use classNameBindings instead.", attrName !== "class");
+
+ normalized[attrName] = expression;
+ }
+ }
+
+ if (isAngleBracket) {
+ for (var prop in attrs) {
+ var val = attrs[prop];
+ if (!val) {
+ continue;
+ }
+
+ if (typeof val === "string" || val.isConcat) {
+ normalized[prop] = ["value", val];
+ }
+ }
+ }
+
+ if (attrs.id && getValue['default'](attrs.id)) {
+ // Do not allow binding to the `id`
+ normalized.id = getValue['default'](attrs.id);
+ component.elementId = normalized.id;
+ } else {
+ normalized.id = component.elementId;
+ }
+
+ if (attrs.tagName) {
+ component.tagName = attrs.tagName;
+ }
+
+ var normalizedClass = normalizeClass(component, attrs);
+
+ if (normalizedClass) {
+ normalized["class"] = normalizedClass;
+ }
+
+ if (component.isVisible === false) {
+ var hiddenStyle = ["value", "display: none;"];
+ var existingStyle = normalized.style;
+
+ if (existingStyle) {
+ normalized.style = ["subexpr", "-concat", [existingStyle, hiddenStyle], ["separator", " "]];
+ } else {
+ normalized.style = hiddenStyle;
+ }
+ }
+
+ return normalized;
+ }
+
+ function normalizeClass(component, attrs) {
+ var i, l;
+ var normalizedClass = [];
+ var classNames = property_get.get(component, "classNames");
+ var classNameBindings = property_get.get(component, "classNameBindings");
+
+ if (attrs["class"]) {
+ if (typeof attrs["class"] === "string") {
+ normalizedClass.push(attrs["class"]);
+ } else {
+ normalizedClass.push(["subexpr", "-normalize-class", [["value", attrs["class"].path], ["value", attrs["class"]]], []]);
+ }
+ }
+
+ if (attrs.classBinding) {
+ normalizeClasses(attrs.classBinding.split(" "), normalizedClass);
+ }
+
+ if (attrs.classNames) {
+ normalizedClass.push(["value", attrs.classNames]);
+ }
+
+ if (classNames) {
+ for (i = 0, l = classNames.length; i < l; i++) {
+ normalizedClass.push(classNames[i]);
+ }
+ }
+
+ if (classNameBindings) {
+ normalizeClasses(classNameBindings, normalizedClass);
+ }
+
+ if (normalizeClass.length) {
+ return ["subexpr", "-join-classes", normalizedClass, []];
+ }
+ }
+
+ function normalizeClasses(classes, output) {
+ var i, l;
+
+ for (i = 0, l = classes.length; i < l; i++) {
+ var className = classes[i];
+ Ember.assert("classNameBindings must not have spaces in them. Multiple class name bindings can be provided as elements of an array, e.g. ['foo', ':bar']", className.indexOf(" ") === -1);
+
+ var _className$split = className.split(":");
+
+ var propName = _className$split[0];
+ var activeClass = _className$split[1];
+ var inactiveClass = _className$split[2];
+
+ // Legacy :class microsyntax for static class names
+ if (propName === "") {
+ output.push(activeClass);
+ return;
+ }
+
+ // 2.0TODO: Remove deprecated global path
+ var prop = path_cache.isGlobal(propName) ? propName : "view." + propName;
+
+ output.push(["subexpr", "-normalize-class", [
+ // params
+ ["value", propName], ["get", prop]], [
+ // hash
+ "activeClass", activeClass, "inactiveClass", inactiveClass]]);
+ }
+ }
+
+ function validateTaglessComponent(component) {
+ Ember.assert("You cannot use `classNameBindings` on a tag-less component: " + component.toString(), function () {
+ var classNameBindings = component.classNameBindings;
+ return !classNameBindings || classNameBindings.length === 0;
+ });
+ }
+
+});
+enifed('ember-views/system/event_dispatcher', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/is_none', 'ember-metal/run_loop', 'ember-runtime/system/string', 'ember-runtime/system/object', 'ember-views/system/jquery', 'ember-views/system/action_manager', 'ember-views/views/view', 'ember-metal/merge'], function (exports, Ember, property_get, property_set, isNone, run, string, EmberObject, jQuery, ActionManager, View, merge) {
+
+ 'use strict';
+
/**
@module ember
@submodule ember-views
*/
exports['default'] = EmberObject['default'].extend({
@@ -36596,37 +39145,37 @@
This set will be modified by `setup` to also include any events added at that time.
@property events
@type Object
*/
events: {
- touchstart: 'touchStart',
- touchmove: 'touchMove',
- touchend: 'touchEnd',
- touchcancel: 'touchCancel',
- keydown: 'keyDown',
- keyup: 'keyUp',
- keypress: 'keyPress',
- mousedown: 'mouseDown',
- mouseup: 'mouseUp',
- contextmenu: 'contextMenu',
- click: 'click',
- dblclick: 'doubleClick',
- mousemove: 'mouseMove',
- focusin: 'focusIn',
- focusout: 'focusOut',
- mouseenter: 'mouseEnter',
- mouseleave: 'mouseLeave',
- submit: 'submit',
- input: 'input',
- change: 'change',
- dragstart: 'dragStart',
- drag: 'drag',
- dragenter: 'dragEnter',
- dragleave: 'dragLeave',
- dragover: 'dragOver',
- drop: 'drop',
- dragend: 'dragEnd'
+ touchstart: "touchStart",
+ touchmove: "touchMove",
+ touchend: "touchEnd",
+ touchcancel: "touchCancel",
+ keydown: "keyDown",
+ keyup: "keyUp",
+ keypress: "keyPress",
+ mousedown: "mouseDown",
+ mouseup: "mouseUp",
+ contextmenu: "contextMenu",
+ click: "click",
+ dblclick: "doubleClick",
+ mousemove: "mouseMove",
+ focusin: "focusIn",
+ focusout: "focusOut",
+ mouseenter: "mouseEnter",
+ mouseleave: "mouseLeave",
+ submit: "submit",
+ input: "input",
+ change: "change",
+ dragstart: "dragStart",
+ drag: "drag",
+ dragenter: "dragEnter",
+ dragleave: "dragLeave",
+ dragover: "dragOver",
+ drop: "drop",
+ dragend: "dragEnd"
},
/**
The root DOM element to which event listeners should be attached. Event
listeners will be attached to the document unless this is overridden.
@@ -36636,11 +39185,11 @@
@private
@property rootElement
@type DOMElement
@default 'body'
*/
- rootElement: 'body',
+ rootElement: "body",
/**
It enables events to be dispatched to the view's `eventManager.` When present,
this object takes precedence over handling of events on the view itself.
Note that most Ember applications do not use this feature. If your app also
@@ -36676,27 +39225,27 @@
@method setup
@param addedEvents {Hash}
*/
setup: function (addedEvents, rootElement) {
var event;
- var events = property_get.get(this, 'events');
+ var events = property_get.get(this, "events");
merge['default'](events, addedEvents || {});
if (!isNone['default'](rootElement)) {
- property_set.set(this, 'rootElement', rootElement);
+ property_set.set(this, "rootElement", rootElement);
}
- rootElement = jQuery['default'](property_get.get(this, 'rootElement'));
+ rootElement = jQuery['default'](property_get.get(this, "rootElement"));
- Ember['default'].assert(string.fmt('You cannot use the same root element (%@) multiple times in an Ember.Application', [rootElement.selector || rootElement[0].tagName]), !rootElement.is('.ember-application'));
- Ember['default'].assert('You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application', !rootElement.closest('.ember-application').length);
- Ember['default'].assert('You cannot make a new Ember.Application using a root element that is an ancestor of an existing Ember.Application', !rootElement.find('.ember-application').length);
+ Ember['default'].assert(string.fmt("You cannot use the same root element (%@) multiple times in an Ember.Application", [rootElement.selector || rootElement[0].tagName]), !rootElement.is(".ember-application"));
+ Ember['default'].assert("You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application", !rootElement.closest(".ember-application").length);
+ Ember['default'].assert("You cannot make a new Ember.Application using a root element that is an ancestor of an existing Ember.Application", !rootElement.find(".ember-application").length);
- rootElement.addClass('ember-application');
+ rootElement.addClass("ember-application");
- Ember['default'].assert('Unable to add "ember-application" class to rootElement. Make sure you set rootElement to the body or an element in the body.', rootElement.is('.ember-application'));
+ Ember['default'].assert("Unable to add \"ember-application\" class to rootElement. Make sure you set rootElement to the body or an element in the body.", rootElement.is(".ember-application"));
for (event in events) {
if (events.hasOwnProperty(event)) {
this.setupHandler(rootElement, event, events[event]);
}
@@ -36716,11 +39265,11 @@
@param {String} eventName the name of the method to call on the view
*/
setupHandler: function (rootElement, event, eventName) {
var self = this;
- rootElement.on(event + '.ember', '.ember-view', function (evt, triggeringManager) {
+ rootElement.on(event + ".ember", ".ember-view", function (evt, triggeringManager) {
var view = View['default'].views[this.id];
var result = true;
var manager = self.canDispatchToEventManager ? self._findNearestEventManager(view, eventName) : null;
@@ -36731,12 +39280,12 @@
}
return result;
});
- rootElement.on(event + '.ember', '[data-ember-action]', function (evt) {
- var actionId = jQuery['default'](evt.currentTarget).attr('data-ember-action');
+ rootElement.on(event + ".ember", "[data-ember-action]", function (evt) {
+ var actionId = jQuery['default'](evt.currentTarget).attr("data-ember-action");
var action = ActionManager['default'].registeredActions[actionId];
// We have to check for action here since in some cases, jQuery will trigger
// an event on `removeChild` (i.e. focusout) after we've already torn down the
// action handlers for the view.
@@ -36748,26 +39297,26 @@
_findNearestEventManager: function (view, eventName) {
var manager = null;
while (view) {
- manager = property_get.get(view, 'eventManager');
+ manager = property_get.get(view, "eventManager");
if (manager && manager[eventName]) {
break;
}
- view = property_get.get(view, 'parentView');
+ view = property_get.get(view, "parentView");
}
return manager;
},
_dispatchEvent: function (object, evt, eventName, view) {
var result = true;
var handler = object[eventName];
- if (utils.typeOf(handler) === 'function') {
+ if (typeof handler === "function") {
result = run['default'](object, handler, evt, view);
// Do not preventDefault in eventManagers.
evt.stopPropagation();
} else {
result = this._bubbleEvent(view, evt, eventName);
@@ -36779,17 +39328,17 @@
_bubbleEvent: function (view, evt, eventName) {
return run['default'].join(view, view.handleEvent, eventName, evt);
},
destroy: function () {
- var rootElement = property_get.get(this, 'rootElement');
- jQuery['default'](rootElement).off('.ember', '**').removeClass('ember-application');
+ var rootElement = property_get.get(this, "rootElement");
+ jQuery['default'](rootElement).off(".ember", "**").removeClass("ember-application");
return this._super.apply(this, arguments);
},
toString: function () {
- return '(EventDispatcher)';
+ return "(EventDispatcher)";
}
});
});
enifed('ember-views/system/ext', ['ember-metal/run_loop'], function (run) {
@@ -36816,11 +39365,11 @@
jQuery = Ember['default'].imports && Ember['default'].imports.jQuery || mainContext && mainContext.jQuery; //jshint ignore:line
if (!jQuery && typeof eriuqer === 'function') {
jQuery = eriuqer('jquery');
}
- Ember['default'].assert("Ember Views require jQuery between 1.7 and 2.1", jQuery && (jQuery().jquery.match(/^((1\.(7|8|9|10|11))|(2\.(0|1)))(\.\d+)?(pre|rc\d?)?/) || Ember['default'].ENV.FORCE_JQUERY));
+ Ember['default'].assert('Ember Views require jQuery between 1.7 and 2.1', jQuery && (jQuery().jquery.match(/^((1\.(7|8|9|10|11))|(2\.(0|1)))(\.\d+)?(pre|rc\d?)?/) || Ember['default'].ENV.FORCE_JQUERY));
/**
@module ember
@submodule ember-views
*/
@@ -36839,34 +39388,49 @@
}
exports['default'] = jQuery;
});
-enifed('ember-views/system/lookup_partial', ['exports', 'ember-metal/core'], function (exports, Ember) {
+enifed('ember-views/system/lookup_partial', ['exports', 'ember-metal/core', 'ember-metal/error'], function (exports, Ember, EmberError) {
'use strict';
exports['default'] = lookupPartial;
- function lookupPartial(view, templateName) {
+
+ function lookupPartial(env, templateName) {
+ if (templateName == null) {
+ return;
+ }
+
var nameParts = templateName.split("/");
var lastPart = nameParts[nameParts.length - 1];
nameParts[nameParts.length - 1] = "_" + lastPart;
- var underscoredName = nameParts.join('/');
- var template = view.templateForName(underscoredName);
- if (!template) {
- template = view.templateForName(templateName);
- }
+ var underscoredName = nameParts.join("/");
+ var template = templateFor(env, underscoredName, templateName);
- Ember['default'].assert('Unable to find partial with name "' + templateName + '"', !!template);
+ Ember['default'].assert("Unable to find partial with name \"" + templateName + "\"", !!template);
return template;
}
+ function templateFor(env, underscored, name) {
+ if (!name) {
+ return;
+ }
+ Ember['default'].assert("templateNames are not allowed to contain periods: " + name, name.indexOf(".") === -1);
+
+ if (!env.container) {
+ throw new EmberError['default']("Container was not found when looking up a views template. " + "This is most likely due to manually instantiating an Ember.View. " + "See: http://git.io/EKPpnA");
+ }
+
+ return env.container.lookup("template:" + underscored) || env.container.lookup("template:" + name);
+ }
+
});
enifed('ember-views/system/platform', ['exports', 'ember-metal/environment'], function (exports, environment) {
'use strict';
@@ -36881,711 +39445,23 @@
})();
exports.canSetNameOnInputs = canSetNameOnInputs;
});
-enifed('ember-views/system/render_buffer', ['exports', 'ember-views/system/jquery', 'ember-metal/core', 'ember-metal/platform/create', 'dom-helper/prop', 'ember-views/system/platform'], function (exports, jQuery, Ember, o_create, dom_helper__prop, platform) {
-
- 'use strict';
-
- /**
- @module ember
- @submodule ember-views
- */
-
- var omittedStartTagChildren;
- var omittedStartTagChildTest = /(?:<script)*.*?<([\w:]+)/i;
-
- function detectOmittedStartTag(dom, string, contextualElement) {
- omittedStartTagChildren = omittedStartTagChildren || {
- tr: dom.createElement('tbody'),
- col: dom.createElement('colgroup')
- };
-
- // Omitted start tags are only inside table tags.
- if (contextualElement.tagName === 'TABLE') {
- var omittedStartTagChildMatch = omittedStartTagChildTest.exec(string);
- if (omittedStartTagChildMatch) {
- // It is already asserted that the contextual element is a table
- // and not the proper start tag. Just look up the start tag.
- return omittedStartTagChildren[omittedStartTagChildMatch[1].toLowerCase()];
- }
- }
- }
-
- function ClassSet() {
- this.seen = o_create['default'](null);
- this.list = [];
- }
-
- ClassSet.prototype = {
- add: function (string) {
- if (this.seen[string] === true) {
- return;
- }
- this.seen[string] = true;
-
- this.list.push(string);
- }
- };
-
- var BAD_TAG_NAME_TEST_REGEXP = /[^a-zA-Z0-9\-]/;
- var BAD_TAG_NAME_REPLACE_REGEXP = /[^a-zA-Z0-9\-]/g;
-
- function stripTagName(tagName) {
- if (!tagName) {
- return tagName;
- }
-
- if (!BAD_TAG_NAME_TEST_REGEXP.test(tagName)) {
- return tagName;
- }
-
- return tagName.replace(BAD_TAG_NAME_REPLACE_REGEXP, '');
- }
-
- var BAD_CHARS_REGEXP = /&(?!\w+;)|[<>"'`]/g;
- var POSSIBLE_CHARS_REGEXP = /[&<>"'`]/;
-
- function escapeAttribute(value) {
- // Stolen shamelessly from Handlebars
-
- var escape = {
- "<": "<",
- ">": ">",
- '"': """,
- "'": "'",
- "`": "`"
- };
-
- var escapeChar = function (chr) {
- return escape[chr] || "&";
- };
-
- var string = value.toString();
-
- if (!POSSIBLE_CHARS_REGEXP.test(string)) {
- return string;
- }
- return string.replace(BAD_CHARS_REGEXP, escapeChar);
- }
-
- /**
- `Ember.RenderBuffer` gathers information regarding the view and generates the
- final representation. `Ember.RenderBuffer` will generate HTML which can be pushed
- to the DOM.
-
- ```javascript
- var buffer = new Ember.RenderBuffer('div', contextualElement);
- ```
-
- @method renderBuffer
- @namespace Ember
- @param {String} tagName tag name (such as 'div' or 'p') used for the buffer
- */
-
- var RenderBuffer = function (domHelper) {
- this.buffer = null;
- this.childViews = [];
- this.attrNodes = [];
-
- Ember['default'].assert("RenderBuffer requires a DOM helper to be passed to its constructor.", !!domHelper);
-
- this.dom = domHelper;
- };
-
- RenderBuffer.prototype = {
-
- reset: function (tagName, contextualElement) {
- this.tagName = tagName;
- this.buffer = null;
- this._element = null;
- this._outerContextualElement = contextualElement;
- this.elementClasses = null;
- this.elementId = null;
- this.elementAttributes = null;
- this.elementProperties = null;
- this.elementTag = null;
- this.elementStyle = null;
- this.childViews.length = 0;
- this.attrNodes.length = 0;
- },
-
- // The root view's element
- _element: null,
-
- // The root view's contextualElement
- _outerContextualElement: null,
-
- /**
- An internal set used to de-dupe class names when `addClass()` is
- used. After each call to `addClass()`, the `classes` property
- will be updated.
- @private
- @property elementClasses
- @type Array
- @default null
- */
- elementClasses: null,
-
- /**
- Array of class names which will be applied in the class attribute.
- You can use `setClasses()` to set this property directly. If you
- use `addClass()`, it will be maintained for you.
- @property classes
- @type Array
- @default null
- */
- classes: null,
-
- /**
- The id in of the element, to be applied in the id attribute.
- You should not set this property yourself, rather, you should use
- the `id()` method of `Ember.RenderBuffer`.
- @property elementId
- @type String
- @default null
- */
- elementId: null,
-
- /**
- A hash keyed on the name of the attribute and whose value will be
- applied to that attribute. For example, if you wanted to apply a
- `data-view="Foo.bar"` property to an element, you would set the
- elementAttributes hash to `{'data-view':'Foo.bar'}`.
- You should not maintain this hash yourself, rather, you should use
- the `attr()` method of `Ember.RenderBuffer`.
- @property elementAttributes
- @type Hash
- @default {}
- */
- elementAttributes: null,
-
- /**
- A hash keyed on the name of the properties and whose value will be
- applied to that property. For example, if you wanted to apply a
- `checked=true` property to an element, you would set the
- elementProperties hash to `{'checked':true}`.
- You should not maintain this hash yourself, rather, you should use
- the `prop()` method of `Ember.RenderBuffer`.
- @property elementProperties
- @type Hash
- @default {}
- */
- elementProperties: null,
-
- /**
- The tagname of the element an instance of `Ember.RenderBuffer` represents.
- Usually, this gets set as the first parameter to `Ember.RenderBuffer`. For
- example, if you wanted to create a `p` tag, then you would call
- ```javascript
- Ember.RenderBuffer('p', contextualElement)
- ```
- @property elementTag
- @type String
- @default null
- */
- elementTag: null,
-
- /**
- A hash keyed on the name of the style attribute and whose value will
- be applied to that attribute. For example, if you wanted to apply a
- `background-color:black;` style to an element, you would set the
- elementStyle hash to `{'background-color':'black'}`.
- You should not maintain this hash yourself, rather, you should use
- the `style()` method of `Ember.RenderBuffer`.
- @property elementStyle
- @type Hash
- @default {}
- */
- elementStyle: null,
-
- pushChildView: function (view) {
- var index = this.childViews.length;
- this.childViews[index] = view;
- this.push("<script id='morph-" + index + "' type='text/x-placeholder'>\x3C/script>");
- },
-
- pushAttrNode: function (node) {
- var index = this.attrNodes.length;
- this.attrNodes[index] = node;
- },
-
- hydrateMorphs: function (contextualElement) {
- var childViews = this.childViews;
- var el = this._element;
- for (var i = 0, l = childViews.length; i < l; i++) {
- var childView = childViews[i];
- var ref = el.querySelector('#morph-' + i);
-
- Ember['default'].assert('An error occurred while setting up template bindings. Please check ' + (childView && childView._parentView && childView._parentView._debugTemplateName ? '"' + childView._parentView._debugTemplateName + '" template ' : '') + 'for invalid markup or bindings within HTML comments.', ref);
-
- var parent = ref.parentNode;
-
- childView._morph = this.dom.insertMorphBefore(parent, ref, parent.nodeType === 1 ? parent : contextualElement);
- parent.removeChild(ref);
- }
- },
-
- /**
- Adds a string of HTML to the `RenderBuffer`.
- @method push
- @param {String} string HTML to push into the buffer
- @chainable
- */
- push: function (content) {
- if (typeof content === 'string') {
- if (this.buffer === null) {
- this.buffer = '';
- }
- Ember['default'].assert("A string cannot be pushed into the buffer after a fragment", !this.buffer.nodeType);
- this.buffer += content;
- } else {
- Ember['default'].assert("A fragment cannot be pushed into a buffer that contains content", !this.buffer);
- this.buffer = content;
- }
- return this;
- },
-
- /**
- Adds a class to the buffer, which will be rendered to the class attribute.
- @method addClass
- @param {String} className Class name to add to the buffer
- @chainable
- */
- addClass: function (className) {
- // lazily create elementClasses
- this.elementClasses = this.elementClasses || new ClassSet();
- this.elementClasses.add(className);
- this.classes = this.elementClasses.list;
-
- return this;
- },
-
- setClasses: function (classNames) {
- this.elementClasses = null;
- var len = classNames.length;
- var i;
- for (i = 0; i < len; i++) {
- this.addClass(classNames[i]);
- }
- },
-
- /**
- Sets the elementID to be used for the element.
- @method id
- @param {String} id
- @chainable
- */
- id: function (id) {
- this.elementId = id;
- return this;
- },
-
- // duck type attribute functionality like jQuery so a render buffer
- // can be used like a jQuery object in attribute binding scenarios.
-
- /**
- Adds an attribute which will be rendered to the element.
- @method attr
- @param {String} name The name of the attribute
- @param {String} value The value to add to the attribute
- @chainable
- @return {Ember.RenderBuffer|String} this or the current attribute value
- */
- attr: function (name, value) {
- var attributes = this.elementAttributes = this.elementAttributes || {};
-
- if (arguments.length === 1) {
- return attributes[name];
- } else {
- attributes[name] = value;
- }
-
- return this;
- },
-
- /**
- Remove an attribute from the list of attributes to render.
- @method removeAttr
- @param {String} name The name of the attribute
- @chainable
- */
- removeAttr: function (name) {
- var attributes = this.elementAttributes;
- if (attributes) {
- delete attributes[name];
- }
-
- return this;
- },
-
- /**
- Adds a property which will be rendered to the element.
- @method prop
- @param {String} name The name of the property
- @param {String} value The value to add to the property
- @chainable
- @return {Ember.RenderBuffer|String} this or the current property value
- */
- prop: function (name, value) {
- var properties = this.elementProperties = this.elementProperties || {};
-
- if (arguments.length === 1) {
- return properties[name];
- } else {
- properties[name] = value;
- }
-
- return this;
- },
-
- /**
- Remove an property from the list of properties to render.
- @method removeProp
- @param {String} name The name of the property
- @chainable
- */
- removeProp: function (name) {
- var properties = this.elementProperties;
- if (properties) {
- delete properties[name];
- }
-
- return this;
- },
-
- /**
- Adds a style to the style attribute which will be rendered to the element.
- @method style
- @param {String} name Name of the style
- @param {String} value
- @chainable
- */
- style: function (name, value) {
- this.elementStyle = this.elementStyle || {};
-
- this.elementStyle[name] = value;
- return this;
- },
-
- generateElement: function () {
- var tagName = this.tagName;
- var id = this.elementId;
- var classes = this.classes;
- var attrs = this.elementAttributes;
- var props = this.elementProperties;
- var style = this.elementStyle;
- var styleBuffer = '';
- var attr, prop, tagString;
-
- if (!platform.canSetNameOnInputs && attrs && attrs.name) {
- // IE allows passing a tag to createElement. See note on `canSetNameOnInputs` above as well.
- tagString = '<' + stripTagName(tagName) + ' name="' + escapeAttribute(attrs.name) + '">';
- } else {
- tagString = tagName;
- }
-
- var element = this.dom.createElement(tagString, this.outerContextualElement());
-
- if (id) {
- this.dom.setAttribute(element, 'id', id);
- this.elementId = null;
- }
- if (classes) {
- this.dom.setAttribute(element, 'class', classes.join(' '));
- this.classes = null;
- this.elementClasses = null;
- }
-
- if (style) {
- for (prop in style) {
- styleBuffer += prop + ':' + style[prop] + ';';
- }
-
- this.dom.setAttribute(element, 'style', styleBuffer);
-
- this.elementStyle = null;
- }
-
- if (attrs) {
- for (attr in attrs) {
- this.dom.setAttribute(element, attr, attrs[attr]);
- }
-
- this.elementAttributes = null;
- }
-
- if (props) {
- for (prop in props) {
- var normalizedCase = dom_helper__prop.normalizeProperty(element, prop.toLowerCase()) || prop;
-
- this.dom.setPropertyStrict(element, normalizedCase, props[prop]);
- }
-
- this.elementProperties = null;
- }
-
- this._element = element;
- },
-
- /**
- @method element
- @return {DOMElement} The element corresponding to the generated HTML
- of this buffer
- */
- element: function () {
-
- if (this._element && this.attrNodes.length > 0) {
- var i, l, attrMorph, attrNode;
- for (i = 0, l = this.attrNodes.length; i < l; i++) {
- attrNode = this.attrNodes[i];
- attrMorph = this.dom.createAttrMorph(this._element, attrNode.attrName);
- attrNode._morph = attrMorph;
- }
- }
-
- var content = this.innerContent();
- // No content means a text node buffer, with the content
- // in _element. Ember._BoundView is an example.
- if (content === null) {
- return this._element;
- }
-
- var contextualElement = this.innerContextualElement(content);
- this.dom.detectNamespace(contextualElement);
-
- if (!this._element) {
- this._element = this.dom.createDocumentFragment();
- }
-
- if (content.nodeType) {
- this._element.appendChild(content);
- } else {
- var frag = this.dom.parseHTML(content, contextualElement);
- this._element.appendChild(frag);
- }
-
- // This should only happen with legacy string buffers
- if (this.childViews.length > 0) {
- this.hydrateMorphs(contextualElement);
- }
-
- return this._element;
- },
-
- /**
- Generates the HTML content for this buffer.
- @method string
- @return {String} The generated HTML
- */
- string: function () {
- if (this._element) {
- // Firefox versions < 11 do not have support for element.outerHTML.
- var thisElement = this.element();
- var outerHTML = thisElement.outerHTML;
- if (typeof outerHTML === 'undefined') {
- return jQuery['default']('<div/>').append(thisElement).html();
- }
- return outerHTML;
- } else {
- return this.innerString();
- }
- },
-
- outerContextualElement: function () {
- if (this._outerContextualElement === undefined) {
- Ember['default'].deprecate("The render buffer expects an outer contextualElement to exist." + " This ensures DOM that requires context is correctly generated (tr, SVG tags)." + " Defaulting to document.body, but this will be removed in the future");
- this.outerContextualElement = document.body;
- }
- return this._outerContextualElement;
- },
-
- innerContextualElement: function (html) {
- var innerContextualElement;
- if (this._element && this._element.nodeType === 1) {
- innerContextualElement = this._element;
- } else {
- innerContextualElement = this.outerContextualElement();
- }
-
- var omittedStartTag;
- if (html) {
- omittedStartTag = detectOmittedStartTag(this.dom, html, innerContextualElement);
- }
- return omittedStartTag || innerContextualElement;
- },
-
- innerString: function () {
- var content = this.innerContent();
- if (content && !content.nodeType) {
- return content;
- }
- },
-
- innerContent: function () {
- return this.buffer;
- }
- };
-
- exports['default'] = RenderBuffer;
-
-});
-enifed('ember-views/system/renderer', ['exports', 'ember-metal/core', 'ember-metal-views/renderer', 'ember-metal/platform/create', 'ember-views/system/render_buffer', 'ember-metal/run_loop', 'ember-metal/property_get', 'ember-metal/instrumentation'], function (exports, Ember, Renderer, create, RenderBuffer, run, property_get, instrumentation) {
-
- 'use strict';
-
- function EmberRenderer(domHelper, _destinedForDOM) {
- this._super$constructor(domHelper, _destinedForDOM);
- this.buffer = new RenderBuffer['default'](domHelper);
- }
-
- EmberRenderer.prototype = create['default'](Renderer['default'].prototype);
- EmberRenderer.prototype.constructor = EmberRenderer;
- EmberRenderer.prototype._super$constructor = Renderer['default'];
-
- EmberRenderer.prototype.scheduleRender = function EmberRenderer_scheduleRender(ctx, fn) {
- return run['default'].scheduleOnce('render', ctx, fn);
- };
-
- EmberRenderer.prototype.cancelRender = function EmberRenderer_cancelRender(id) {
- run['default'].cancel(id);
- };
-
- EmberRenderer.prototype.createElement = function EmberRenderer_createElement(view, contextualElement) {
- // If this is the top-most view, start a new buffer. Otherwise,
- // create a new buffer relative to the original using the
- // provided buffer operation (for example, `insertAfter` will
- // insert a new buffer after the "parent buffer").
- var tagName = view.tagName;
- if (tagName !== null && typeof tagName === 'object' && tagName.isDescriptor) {
- tagName = property_get.get(view, 'tagName');
- Ember['default'].deprecate('In the future using a computed property to define tagName will not be permitted. That value will be respected, but changing it will not update the element.', !tagName);
- }
- var classNameBindings = view.classNameBindings;
- var taglessViewWithClassBindings = tagName === '' && classNameBindings && classNameBindings.length > 0;
-
- if (tagName === null || tagName === undefined) {
- tagName = 'div';
- }
-
- Ember['default'].assert('You cannot use `classNameBindings` on a tag-less view: ' + view.toString(), !taglessViewWithClassBindings);
-
- var buffer = view.buffer = this.buffer;
- buffer.reset(tagName, contextualElement);
-
- if (view.beforeRender) {
- view.beforeRender(buffer);
- }
-
- if (tagName !== '') {
- if (view.applyAttributesToBuffer) {
- view.applyAttributesToBuffer(buffer);
- }
- buffer.generateElement();
- }
-
- if (view.render) {
- view.render(buffer);
- }
-
- if (view.afterRender) {
- view.afterRender(buffer);
- }
-
- var element = buffer.element();
-
- view.buffer = null;
- if (element && element.nodeType === 1) {
- view.element = element;
- }
- return element;
- };
-
- EmberRenderer.prototype.destroyView = function destroyView(view) {
- view.removedFromDOM = true;
- view.destroy();
- };
-
- EmberRenderer.prototype.childViews = function childViews(view) {
- if (view._attrNodes && view._childViews) {
- return view._attrNodes.concat(view._childViews);
- }
- return view._attrNodes || view._childViews;
- };
-
- Renderer['default'].prototype.willCreateElement = function (view) {
- if (instrumentation.subscribers.length && view.instrumentDetails) {
- view._instrumentEnd = instrumentation._instrumentStart('render.' + view.instrumentName, function viewInstrumentDetails() {
- var details = {};
- view.instrumentDetails(details);
- return details;
- });
- }
- if (view._transitionTo) {
- view._transitionTo('inBuffer');
- }
- }; // inBuffer
- Renderer['default'].prototype.didCreateElement = function (view) {
- if (view._transitionTo) {
- view._transitionTo('hasElement');
- }
- if (view._instrumentEnd) {
- view._instrumentEnd();
- }
- }; // hasElement
- Renderer['default'].prototype.willInsertElement = function (view) {
- if (this._destinedForDOM) {
- if (view.trigger) {
- view.trigger('willInsertElement');
- }
- }
- }; // will place into DOM
- Renderer['default'].prototype.didInsertElement = function (view) {
- if (view._transitionTo) {
- view._transitionTo('inDOM');
- }
-
- if (this._destinedForDOM) {
- if (view.trigger) {
- view.trigger('didInsertElement');
- }
- }
- }; // inDOM // placed into DOM
-
- Renderer['default'].prototype.willRemoveElement = function (view) {};
-
- Renderer['default'].prototype.willDestroyElement = function (view) {
- if (this._destinedForDOM) {
- if (view._willDestroyElement) {
- view._willDestroyElement();
- }
- if (view.trigger) {
- view.trigger('willDestroyElement');
- view.trigger('willClearRender');
- }
- }
- };
-
- Renderer['default'].prototype.didDestroyElement = function (view) {
- view.element = null;
- if (view._transitionTo) {
- view._transitionTo('preRender');
- }
- }; // element destroyed so view.destroy shouldn't try to remove it removedFromDOM
-
- exports['default'] = EmberRenderer;
-
-});
enifed('ember-views/system/utils', ['exports'], function (exports) {
'use strict';
exports.isSimpleClick = isSimpleClick;
exports.getViewClientRects = getViewClientRects;
exports.getViewBoundingClientRect = getViewBoundingClientRect;
+ /**
+ @module ember
+ @submodule ember-views
+ */
+
function isSimpleClick(event) {
var modifier = event.shiftKey || event.metaKey || event.altKey || event.ctrlKey;
var secondaryClick = event.which > 1; // IE9 may return undefined
return !modifier && !secondaryClick;
@@ -37596,208 +39472,63 @@
@method getViewRange
@param {Ember.View} view
*/
function getViewRange(view) {
var range = document.createRange();
- range.setStartBefore(view._morph.firstNode);
- range.setEndAfter(view._morph.lastNode);
+ range.setStartBefore(view._renderNode.firstNode);
+ range.setEndAfter(view._renderNode.lastNode);
return range;
}
-
- /**
- `getViewClientRects` provides information about the position of the border
- box edges of a view relative to the viewport.
-
- It is only intended to be used by development tools like the Ember Inspector
- and may not work on older browsers.
-
- @private
- @method getViewClientRects
- @param {Ember.View} view
- */
-
function getViewClientRects(view) {
var range = getViewRange(view);
return range.getClientRects();
}
- /**
- `getViewBoundingClientRect` provides information about the position of the
- bounding border box edges of a view relative to the viewport.
-
- It is only intended to be used by development tools like the Ember Inpsector
- and may not work on older browsers.
-
- @private
- @method getViewBoundingClientRect
- @param {Ember.View} view
- */
-
function getViewBoundingClientRect(view) {
var range = getViewRange(view);
return range.getBoundingClientRect();
}
});
-enifed('ember-views/views/bound_component_view', ['exports', 'ember-views/views/metamorph_view', 'ember-metal/streams/utils', 'ember-views/streams/utils', 'ember-htmlbars/system/merge-view-bindings', 'ember-metal/error', 'ember-views/views/container_view', 'ember-views/views/view'], function (exports, metamorph_view, utils, streams__utils, mergeViewBindings, EmberError, ContainerView, View) {
-
- 'use strict';
-
- /**
- @module ember
- @submodule ember-views
- */
-
- exports['default'] = ContainerView['default'].extend(metamorph_view._Metamorph, {
- init: function () {
- this._super.apply(this, arguments);
- this.componentNameStream = this._boundComponentOptions.componentNameStream;
-
- utils.subscribe(this.componentNameStream, this._updateBoundChildComponent, this);
- this._updateBoundChildComponent();
- },
- willDestroy: function () {
- utils.unsubscribe(this.componentNameStream, this._updateBoundChildComponent, this);
- this._super.apply(this, arguments);
- },
- _updateBoundChildComponent: function () {
- this.replace(0, 1, [this._createNewComponent()]);
- },
- _createNewComponent: function () {
- var componentName = utils.read(this.componentNameStream);
- if (!componentName) {
- return this.createChildView(View['default']);
- }
-
- var componentClass = streams__utils.readComponentFactory(componentName, this.container);
- if (!componentClass) {
- throw new EmberError['default']('HTMLBars error: Could not find component named "' + utils.read(this._boundComponentOptions.componentNameStream) + '".');
- }
- var hash = this._boundComponentOptions;
- var hashForComponent = {};
-
- var prop;
- for (prop in hash) {
- if (prop === '_boundComponentOptions' || prop === 'componentNameStream') {
- continue;
- }
- hashForComponent[prop] = hash[prop];
- }
-
- var props = {};
- mergeViewBindings['default'](this, props, hashForComponent);
- return this.createChildView(componentClass, props);
- }
- });
-
-});
-enifed('ember-views/views/bound_if_view', ['exports', 'ember-metal/run_loop', 'ember-views/views/metamorph_view', 'ember-views/mixins/normalized_rerender_if_needed', 'ember-htmlbars/system/render-view'], function (exports, run, _MetamorphView, NormalizedRerenderIfNeededSupport, renderView) {
-
- 'use strict';
-
- exports['default'] = _MetamorphView['default'].extend(NormalizedRerenderIfNeededSupport['default'], {
- init: function () {
- this._super.apply(this, arguments);
-
- var self = this;
-
- this.conditionStream.subscribe(this._wrapAsScheduled(function () {
- run['default'].scheduleOnce('render', self, 'rerenderIfNeeded');
- }));
- },
-
- normalizedValue: function () {
- return this.conditionStream.value();
- },
-
- render: function (buffer) {
- var result = this.conditionStream.value();
- this._lastNormalizedValue = result;
-
- var template = result ? this.truthyTemplate : this.falsyTemplate;
- renderView['default'](this, buffer, template);
- }
- });
-
-});
-enifed('ember-views/views/bound_partial_view', ['exports', 'ember-views/views/metamorph_view', 'ember-views/mixins/normalized_rerender_if_needed', 'ember-views/system/lookup_partial', 'ember-metal/run_loop', 'ember-htmlbars/system/render-view', 'ember-htmlbars/templates/empty'], function (exports, _MetamorphView, NormalizedRerenderIfNeededSupport, lookupPartial, run, renderView, emptyTemplate) {
-
- 'use strict';
-
- /**
- @module ember
- @submodule ember-views
- */
-
- exports['default'] = _MetamorphView['default'].extend(NormalizedRerenderIfNeededSupport['default'], {
- init: function () {
- this._super.apply(this, arguments);
-
- var self = this;
-
- this.templateNameStream.subscribe(this._wrapAsScheduled(function () {
- run['default'].scheduleOnce('render', self, 'rerenderIfNeeded');
- }));
- },
-
- normalizedValue: function () {
- return this.templateNameStream.value();
- },
-
- render: function (buffer) {
- var templateName = this.normalizedValue();
- this._lastNormalizedValue = templateName;
-
- var template;
- if (templateName) {
- template = lookupPartial['default'](this, templateName);
- }
-
- renderView['default'](this, buffer, template || emptyTemplate['default']);
- }
- });
-
-});
enifed('ember-views/views/checkbox', ['exports', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-views/views/view'], function (exports, property_get, property_set, View) {
'use strict';
exports['default'] = View['default'].extend({
- instrumentDisplay: '{{input type="checkbox"}}',
+ instrumentDisplay: "{{input type=\"checkbox\"}}",
- classNames: ['ember-checkbox'],
+ classNames: ["ember-checkbox"],
- tagName: 'input',
+ tagName: "input",
- attributeBindings: ['type', 'checked', 'indeterminate', 'disabled', 'tabindex', 'name', 'autofocus', 'required', 'form'],
+ attributeBindings: ["type", "checked", "indeterminate", "disabled", "tabindex", "name", "autofocus", "required", "form"],
- type: 'checkbox',
+ type: "checkbox",
checked: false,
disabled: false,
indeterminate: false,
init: function () {
this._super.apply(this, arguments);
- this.on('change', this, this._updateElementValue);
+ this.on("change", this, this._updateElementValue);
},
didInsertElement: function () {
this._super.apply(this, arguments);
- property_get.get(this, 'element').indeterminate = !!property_get.get(this, 'indeterminate');
+ property_get.get(this, "element").indeterminate = !!property_get.get(this, "indeterminate");
},
_updateElementValue: function () {
- property_set.set(this, 'checked', this.$().prop('checked'));
+ property_set.set(this, "checked", this.$().prop("checked"));
}
});
});
-enifed('ember-views/views/collection_view', ['exports', 'ember-metal/core', 'ember-metal/binding', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-runtime/system/string', 'ember-views/views/container_view', 'ember-views/views/core_view', 'ember-views/views/view', 'ember-metal/mixin', 'ember-views/streams/utils', 'ember-runtime/mixins/array'], function (exports, Ember, binding, property_get, property_set, string, ContainerView, CoreView, View, mixin, utils, EmberArray) {
+enifed('ember-views/views/collection_view', ['exports', 'ember-metal/core', 'ember-views/views/container_view', 'ember-views/views/view', 'ember-runtime/mixins/array', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-runtime/system/string', 'ember-metal/computed', 'ember-metal/mixin', 'ember-views/streams/utils'], function (exports, Ember, ContainerView, View, EmberArray, property_get, property_set, string, computed, mixin, utils) {
'use strict';
-
/**
@module ember
@submodule ember-views
*/
@@ -37849,17 +39580,17 @@
Invoked when the content property is about to change. Notifies observers that the
entire array content will change.
@private
@method _contentWillChange
*/
- _contentWillChange: mixin.beforeObserver('content', function () {
- var content = this.get('content');
+ _contentWillChange: mixin.beforeObserver("content", function () {
+ var content = this.get("content");
if (content) {
content.removeArrayObserver(this);
}
- var len = content ? property_get.get(content, 'length') : 0;
+ var len = content ? property_get.get(content, "length") : 0;
this.arrayWillChange(content, 0, len);
}),
/**
Check to make sure that the content has changed, and if so,
@@ -37867,19 +39598,19 @@
asynchronously, to allow the element to be created before
bindings have synchronized and vice versa.
@private
@method _contentDidChange
*/
- _contentDidChange: mixin.observer('content', function () {
- var content = property_get.get(this, 'content');
+ _contentDidChange: mixin.observer("content", function () {
+ var content = property_get.get(this, "content");
if (content) {
this._assertArrayLike(content);
content.addArrayObserver(this);
}
- var len = content ? property_get.get(content, 'length') : 0;
+ var len = content ? property_get.get(content, "length") : 0;
this.arrayDidChange(content, 0, null, len);
}),
/**
Ensure that the content implements Ember.Array
@@ -37897,11 +39628,11 @@
destroy: function () {
if (!this._super.apply(this, arguments)) {
return;
}
- var content = property_get.get(this, 'content');
+ var content = property_get.get(this, "content");
if (content) {
content.removeArrayObserver(this);
}
if (this._createdEmptyView) {
@@ -37920,27 +39651,11 @@
@param {Array} content the managed collection of objects
@param {Number} start the index at which the changes will occur
@param {Number} removed number of object to be removed from content
*/
arrayWillChange: function (content, start, removedCount) {
- // If the contents were empty before and this template collection has an
- // empty view remove it now.
- var emptyView = property_get.get(this, 'emptyView');
- if (emptyView && emptyView instanceof View['default']) {
- emptyView.removeFromParent();
- }
-
- // Loop through child views that correspond with the removed items.
- // Note that we loop from the end of the array to the beginning because
- // we are mutating it as we go.
- var childViews = this._childViews;
- var childView, idx;
-
- for (idx = start + removedCount - 1; idx >= start; idx--) {
- childView = childViews[idx];
- childView.destroy();
- }
+ this.replace(start, removedCount, []);
},
/**
Called when a mutation to the underlying content array occurs.
This method will replay that mutation against the views that compose the
@@ -37952,69 +39667,40 @@
@param {Number} removed number of object removed from content
@param {Number} added number of object added to content
*/
arrayDidChange: function (content, start, removed, added) {
var addedViews = [];
- var view, item, idx, len, itemViewClass, emptyView, itemViewProps;
+ var view, item, idx, len, itemViewClass, itemViewProps;
- len = content ? property_get.get(content, 'length') : 0;
+ len = content ? property_get.get(content, "length") : 0;
if (len) {
itemViewProps = this._itemViewProps || {};
- itemViewClass = property_get.get(this, 'itemViewClass');
+ itemViewClass = this.getAttr("itemViewClass") || property_get.get(this, "itemViewClass");
itemViewClass = utils.readViewFactory(itemViewClass, this.container);
for (idx = start; idx < start + added; idx++) {
item = content.objectAt(idx);
- itemViewProps._context = this.keyword ? this.get('context') : item;
+ itemViewProps._context = this.keyword ? this.get("context") : item;
itemViewProps.content = item;
itemViewProps.contentIndex = idx;
view = this.createChildView(itemViewClass, itemViewProps);
- if (this.blockParams > 0) {
- view._blockArguments = [item];
- }
- if (this.blockParams > 1) {
- view._blockArguments.push(view.getStream('_view.contentIndex'));
- }
+
+ if (this.blockParams > 0) {
+ view._blockArguments = [item];
+ }
+
addedViews.push(view);
}
this.replace(start, 0, addedViews);
- if (this.blockParams > 1) {
- var childViews = this._childViews;
- for (idx = start + added; idx < len; idx++) {
- view = childViews[idx];
- property_set.set(view, 'contentIndex', idx);
- }
- }
- } else {
- emptyView = property_get.get(this, 'emptyView');
-
- if (!emptyView) {
- return;
- }
-
- if ('string' === typeof emptyView && binding.isGlobalPath(emptyView)) {
- emptyView = property_get.get(emptyView) || emptyView;
- }
-
- emptyView = this.createChildView(emptyView);
-
- addedViews.push(emptyView);
- property_set.set(this, 'emptyView', emptyView);
-
- if (CoreView['default'].detect(emptyView)) {
- this._createdEmptyView = emptyView;
- }
-
- this.replace(start, 0, addedViews);
- }
+ }
},
/**
Instantiates a view to be added to the childViews array during view
initialization. You generally will not call this method directly unless
@@ -38029,19 +39715,70 @@
@return {Ember.View} new instance
*/
createChildView: function (_view, attrs) {
var view = this._super(_view, attrs);
- var itemTagName = property_get.get(view, 'tagName');
+ var itemTagName = property_get.get(view, "tagName");
if (itemTagName === null || itemTagName === undefined) {
- itemTagName = CollectionView.CONTAINER_MAP[property_get.get(this, 'tagName')];
- property_set.set(view, 'tagName', itemTagName);
+ itemTagName = CollectionView.CONTAINER_MAP[property_get.get(this, "tagName")];
+ property_set.set(view, "tagName", itemTagName);
}
return view;
- }
+ },
+
+ willRender: function () {
+ var attrs = this.attrs;
+ var itemProps = buildItemViewProps(this._itemViewTemplate, attrs);
+ this._itemViewProps = itemProps;
+ var childViews = property_get.get(this, "childViews");
+
+ for (var i = 0, l = childViews.length; i < l; i++) {
+ childViews[i].setProperties(itemProps);
+ }
+
+ if ("content" in attrs) {
+ property_set.set(this, "content", this.getAttr("content"));
+ }
+
+ if ("emptyView" in attrs) {
+ property_set.set(this, "emptyView", this.getAttr("emptyView"));
+ }
+ },
+
+ _emptyView: computed.computed("emptyView", "attrs.emptyViewClass", "emptyViewClass", function () {
+ var emptyView = property_get.get(this, "emptyView");
+ var attrsEmptyViewClass = this.getAttr("emptyViewClass");
+ var emptyViewClass = property_get.get(this, "emptyViewClass");
+ var inverse = property_get.get(this, "_itemViewInverse");
+ var actualEmpty = emptyView || attrsEmptyViewClass;
+
+ // Somehow, our previous semantics differed depending on whether the
+ // `emptyViewClass` was provided on the JavaScript class or via the
+ // Handlebars template.
+ // In Glimmer, we disambiguate between the two by checking first (and
+ // preferring) the attrs-supplied class.
+ // If not present, we fall back to the class's `emptyViewClass`, but only
+ // if an inverse has been provided via an `{{else}}`.
+ if (inverse && actualEmpty) {
+ if (actualEmpty.extend) {
+ return actualEmpty.extend({ template: inverse });
+ } else {
+ property_set.set(actualEmpty, "template", inverse);
+ }
+ } else if (inverse && emptyViewClass) {
+ return emptyViewClass.extend({ template: inverse });
+ }
+
+ return actualEmpty;
+ }),
+
+ _emptyViewTagName: computed.computed("tagName", function () {
+ var tagName = property_get.get(this, "tagName");
+ return CollectionView.CONTAINER_MAP[tagName] || "div";
+ })
});
/**
A map of parent tags to their default child tags. You can add
additional parent tags if you want collection views that use
@@ -38051,24 +39788,60 @@
@type Hash
@static
@final
*/
CollectionView.CONTAINER_MAP = {
- ul: 'li',
- ol: 'li',
- table: 'tr',
- thead: 'tr',
- tbody: 'tr',
- tfoot: 'tr',
- tr: 'td',
- select: 'option'
+ ul: "li",
+ ol: "li",
+ table: "tr",
+ thead: "tr",
+ tbody: "tr",
+ tfoot: "tr",
+ tr: "td",
+ select: "option"
};
+ var CONTAINER_MAP = CollectionView.CONTAINER_MAP;
+
+ function buildItemViewProps(template, attrs) {
+ var props = {};
+
+ // Go through options passed to the {{collection}} helper and extract options
+ // that configure item views instead of the collection itself.
+ for (var prop in attrs) {
+ if (prop === "itemViewClass" || prop === "itemController" || prop === "itemClassBinding") {
+ continue;
+ }
+ if (attrs.hasOwnProperty(prop)) {
+ var match = prop.match(/^item(.)(.*)$/);
+ if (match) {
+ var childProp = match[1].toLowerCase() + match[2];
+
+ if (childProp === "class" || childProp === "classNames") {
+ props.classNames = [attrs[prop]];
+ } else {
+ props[childProp] = attrs[prop];
+ }
+
+ delete attrs[prop];
+ }
+ }
+ }
+
+ if (template) {
+ props.template = template;
+ }
+
+ return props;
+ }
+
exports['default'] = CollectionView;
+ exports.CONTAINER_MAP = CONTAINER_MAP;
+
});
-enifed('ember-views/views/component', ['exports', 'ember-metal/core', 'ember-views/mixins/component_template_deprecation', 'ember-runtime/mixins/target_action_support', 'ember-views/views/view', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/is_none', 'ember-metal/computed', 'ember-metal/computed_macros', 'ember-htmlbars/templates/component'], function (exports, Ember, ComponentTemplateDeprecation, TargetActionSupport, View, property_get, property_set, isNone, computed, computed_macros, defaultComponentLayout) {
+enifed('ember-views/views/component', ['exports', 'ember-metal/core', 'ember-views/mixins/component_template_deprecation', 'ember-runtime/mixins/target_action_support', 'ember-views/views/view', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/is_none', 'ember-metal/computed'], function (exports, Ember, ComponentTemplateDeprecation, TargetActionSupport, View, property_get, property_set, isNone, computed) {
'use strict';
var Component = View['default'].extend(TargetActionSupport['default'], ComponentTemplateDeprecation['default'], {
/*
@@ -38076,26 +39849,23 @@
think that it should set the components `context` to that of the parent view.
*/
controller: null,
context: null,
- instrumentName: 'component',
+ instrumentName: "component",
instrumentDisplay: computed.computed(function () {
if (this._debugContainerKey) {
- return '{{' + this._debugContainerKey.split(':')[1] + '}}';
+ return "{{" + this._debugContainerKey.split(":")[1] + "}}";
}
}),
init: function () {
this._super.apply(this, arguments);
- this._keywords.view = this;
- property_set.set(this, 'context', this);
- property_set.set(this, 'controller', this);
+ property_set.set(this, "controller", this);
+ property_set.set(this, "context", this);
},
- defaultLayout: defaultComponentLayout['default'],
-
/**
A components template property is set by passing a block
during its invocation. It is executed within the parent context.
Example:
```handlebars
@@ -38107,17 +39877,17 @@
Specifying a template directly to a component is deprecated without
also specifying the layout property.
@deprecated
@property template
*/
- template: computed.computed('templateName', {
+ template: computed.computed("templateName", {
get: function () {
- var templateName = property_get.get(this, 'templateName');
- var template = this.templateForName(templateName, 'template');
+ var templateName = property_get.get(this, "templateName");
+ var template = this.templateForName(templateName, "template");
Ember['default'].assert("You specified the templateName " + templateName + " for " + this + ", but it did not exist.", !templateName || !!template);
- return template || property_get.get(this, 'defaultTemplate');
+ return template || property_get.get(this, "defaultTemplate");
},
set: function (key, value) {
return value;
}
}),
@@ -38128,43 +39898,26 @@
@deprecated
@property templateName
*/
templateName: null,
- _setupKeywords: function () {},
-
- _yield: function (context, options, morph, blockArguments) {
- var view = options.data.view;
- var parentView = this._parentView;
- var template = property_get.get(this, 'template');
-
- if (template) {
- Ember['default'].assert("A Component must have a parent view in order to yield.", parentView);
-
- view.appendChild(View['default'], {
- isVirtual: true,
- tagName: '',
- template: template,
- _blockArguments: blockArguments,
- _contextView: parentView,
- _morph: morph,
- context: property_get.get(parentView, 'context'),
- controller: property_get.get(parentView, 'controller')
- });
- }
- },
-
/**
If the component is currently inserted into the DOM of a parent view, this
property will point to the controller of the parent view.
@property targetObject
@type Ember.Controller
@default null
*/
- targetObject: computed.computed('_parentView', function (key) {
- var parentView = this._parentView;
- return parentView ? property_get.get(parentView, 'controller') : null;
+ targetObject: computed.computed("controller", function (key) {
+ if (this._targetObject) {
+ return this._targetObject;
+ }
+ if (this._controller) {
+ return this._controller;
+ }
+ var parentView = property_get.get(this, "parentView");
+ return parentView ? property_get.get(parentView, "controller") : null;
}),
/**
Triggers a named action on the controller context where the component is used if
this controller has registered for notifications of the action.
@@ -38239,26 +39992,30 @@
var actionName;
// Send the default action
if (action === undefined) {
- actionName = property_get.get(this, 'action');
- Ember['default'].assert("The default action was triggered on the component " + this.toString() + ", but the action name (" + actionName + ") was not a string.", isNone['default'](actionName) || typeof actionName === 'string');
+ actionName = property_get.get(this, "action");
+ Ember['default'].assert("The default action was triggered on the component " + this.toString() + ", but the action name (" + actionName + ") was not a string.", isNone['default'](actionName) || typeof actionName === "string" || typeof actionName === "function");
} else {
- actionName = property_get.get(this, action);
- Ember['default'].assert("The " + action + " action was triggered on the component " + this.toString() + ", but the action name (" + actionName + ") was not a string.", isNone['default'](actionName) || typeof actionName === 'string');
+ actionName = property_get.get(this, "attrs." + action) || property_get.get(this, action);
+ Ember['default'].assert("The " + action + " action was triggered on the component " + this.toString() + ", but the action name (" + actionName + ") was not a string.", isNone['default'](actionName) || typeof actionName === "string" || typeof actionName === "function");
}
// If no action name for that action could be found, just abort.
if (actionName === undefined) {
return;
}
- this.triggerAction({
- action: actionName,
- actionContext: contexts
- });
+ if (typeof actionName === "function") {
+ actionName.apply(null, contexts);
+ } else {
+ this.triggerAction({
+ action: actionName,
+ actionContext: contexts
+ });
+ }
},
send: function (actionName) {
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
@@ -38272,42 +40029,95 @@
if (!shouldBubble) {
return;
}
}
- if (target = property_get.get(this, 'target')) {
- var _target;
-
- Ember['default'].assert("The `target` for " + this + " (" + target + ") does not have a `send` method", typeof target.send === 'function');
- (_target = target).send.apply(_target, arguments);
+ if (target = property_get.get(this, "target")) {
+ Ember['default'].assert("The `target` for " + this + " (" + target + ") does not have a `send` method", typeof target.send === "function");
+ target.send.apply(target, arguments);
} else {
if (!hasAction) {
- throw new Error(Ember['default'].inspect(this) + ' had no action handler for: ' + actionName);
+ throw new Error(Ember['default'].inspect(this) + " had no action handler for: " + actionName);
}
}
}
+
+ /**
+ Returns true when the component was invoked with a block template.
+ Example (`hasBlock` will be `false`):
+ ```hbs
+ {{! templates/application.hbs }}
+ {{foo-bar}}
+ {{! templates/components/foo-bar.js }}
+ {{#if hasBlock}}
+ This will not be printed, because no block was provided
+ {{/if}}
+ ```
+ Example (`hasBlock` will be `true`):
+ ```hbs
+ {{! templates/application.hbs }}
+ {{#foo-bar}}
+ Hi!
+ {{/foo-bar}}
+ {{! templates/components/foo-bar.js }}
+ {{#if hasBlock}}
+ This will be printed because a block was provided
+ {{yield}}
+ {{/if}}
+ ```
+ @public
+ @property hasBlock
+ @returns Boolean
+ */
+
+ /**
+ Returns true when the component was invoked with a block parameter
+ supplied.
+ Example (`hasBlockParams` will be `false`):
+ ```hbs
+ {{! templates/application.hbs }}
+ {{#foo-bar}}
+ No block parameter.
+ {{/foo-bar}}
+ {{! templates/components/foo-bar.js }}
+ {{#if hasBlockParams}}
+ This will not be printed, because no block was provided
+ {{yield this}}
+ {{/if}}
+ ```
+ Example (`hasBlockParams` will be `true`):
+ ```hbs
+ {{! templates/application.hbs }}
+ {{#foo-bar as |foo|}}
+ Hi!
+ {{/foo-bar}}
+ {{! templates/components/foo-bar.js }}
+ {{#if hasBlockParams}}
+ This will be printed because a block was provided
+ {{yield this}}
+ {{/if}}
+ ```
+ @public
+ @property hasBlockParams
+ @returns Boolean
+ */
});
-
exports['default'] = Component;
});
-enifed('ember-views/views/container_view', ['exports', 'ember-metal/core', 'ember-metal/merge', 'ember-runtime/mixins/mutable_array', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-views/views/view', 'ember-views/views/states', 'ember-metal/error', 'ember-metal/enumerable_utils', 'ember-metal/computed', 'ember-metal/run_loop', 'ember-metal/properties', 'ember-metal/mixin', 'ember-runtime/system/native_array'], function (exports, Ember, merge, MutableArray, property_get, property_set, View, views__states, EmberError, enumerable_utils, computed, run, properties, mixin, native_array) {
+enifed('ember-views/views/container_view', ['exports', 'ember-metal/core', 'ember-runtime/mixins/mutable_array', 'ember-views/views/view', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/enumerable_utils', 'ember-metal/mixin', 'ember-htmlbars/templates/container-view'], function (exports, Ember, MutableArray, View, property_get, property_set, enumerable_utils, mixin, containerViewTemplate) {
'use strict';
- function K() {
- return this;
- }
+ containerViewTemplate['default'].meta.revision = "Ember@1.13.0-beta.1";
/**
@module ember
@submodule ember-views
*/
- var states = views__states.cloneStates(views__states.states);
-
/**
A `ContainerView` is an `Ember.View` subclass that implements `Ember.MutableArray`
allowing programmatic management of its child views.
## Setting Initial Child Views
@@ -38455,233 +40265,137 @@
@class ContainerView
@namespace Ember
@extends Ember.View
*/
var ContainerView = View['default'].extend(MutableArray['default'], {
- _states: states,
-
willWatchProperty: function (prop) {
- Ember['default'].deprecate("ContainerViews should not be observed as arrays. This behavior will change in future implementations of ContainerView.", !prop.match(/\[]/) && prop.indexOf('@') !== 0);
+ Ember['default'].deprecate("ContainerViews should not be observed as arrays. This behavior will change in future implementations of ContainerView.", !prop.match(/\[]/) && prop.indexOf("@") !== 0);
},
init: function () {
this._super.apply(this, arguments);
- var childViews = property_get.get(this, 'childViews');
- Ember['default'].deprecate('Setting `childViews` on a Container is deprecated.', Ember['default'].isEmpty(childViews));
+ var userChildViews = property_get.get(this, "childViews");
+ Ember['default'].deprecate("Setting `childViews` on a Container is deprecated.", Ember['default'].isEmpty(userChildViews));
// redefine view's childViews property that was obliterated
- properties.defineProperty(this, 'childViews', View['default'].childViewsProperty);
+ // 2.0TODO: Don't Ember.A() this so users disabling prototype extensions
+ // don't pay a penalty.
+ var childViews = this.childViews = Ember['default'].A([]);
- var _childViews = this._childViews;
-
- enumerable_utils.forEach(childViews, function (viewName, idx) {
+ enumerable_utils.forEach(userChildViews, function (viewName, idx) {
var view;
- if ('string' === typeof viewName) {
+ if ("string" === typeof viewName) {
view = property_get.get(this, viewName);
view = this.createChildView(view);
property_set.set(this, viewName, view);
} else {
view = this.createChildView(viewName);
}
- _childViews[idx] = view;
+ childViews[idx] = view;
}, this);
- var currentView = property_get.get(this, 'currentView');
+ var currentView = property_get.get(this, "currentView");
if (currentView) {
- if (!_childViews.length) {
- _childViews = this._childViews = this._childViews.slice();
+ if (!childViews.length) {
+ childViews = this.childViews = Ember['default'].A(this.childViews.slice());
}
- _childViews.push(this.createChildView(currentView));
+ childViews.push(this.createChildView(currentView));
}
+
+ property_set.set(this, "length", childViews.length);
},
- replace: function (idx, removedCount, addedViews) {
- var addedCount = addedViews ? property_get.get(addedViews, 'length') : 0;
- var self = this;
- Ember['default'].assert("You can't add a child to a container - the child is already a child of another view", native_array.A(addedViews).every(function (item) {
- return !item._parentView || item._parentView === self;
- }));
-
- this.arrayContentWillChange(idx, removedCount, addedCount);
- this.childViewsWillChange(this._childViews, idx, removedCount);
-
- if (addedCount === 0) {
- this._childViews.splice(idx, removedCount);
- } else {
- var args = [idx, removedCount].concat(addedViews);
- if (addedViews.length && !this._childViews.length) {
- this._childViews = this._childViews.slice();
- }
- this._childViews.splice.apply(this._childViews, args);
+ // Normally parentView and childViews are managed at render time. However,
+ // the ContainerView is an unusual legacy case. People expect to be able to
+ // push a child view into the ContainerView and have its parentView set
+ // appropriately. As a result, we link the child nodes ahead of time and
+ // ignore render-time linking.
+ appendChild: function (view) {
+ // This occurs if the view being appended is the empty view, rather than
+ // a view eagerly inserted into the childViews array.
+ if (view.parentView !== this) {
+ this.linkChild(view);
}
-
- this.arrayContentDidChange(idx, removedCount, addedCount);
- this.childViewsDidChange(this._childViews, idx, removedCount, addedCount);
-
- return this;
},
- objectAt: function (idx) {
- return this._childViews[idx];
- },
-
- length: computed.computed(function () {
- return this._childViews.length;
- })["volatile"](),
-
- /**
- Instructs each child view to render to the passed render buffer.
- @private
- @method render
- @param {Ember.RenderBuffer} buffer the buffer to render to
- */
- render: function (buffer) {
- var element = buffer.element();
- var dom = buffer.dom;
-
- if (this.tagName === '') {
- element = dom.createDocumentFragment();
- buffer._element = element;
- this._childViewsMorph = dom.appendMorph(element, this._morph.contextualElement);
- } else {
- this._childViewsMorph = dom.appendMorph(element);
+ _currentViewWillChange: mixin.beforeObserver("currentView", function () {
+ var currentView = property_get.get(this, "currentView");
+ if (currentView) {
+ currentView.destroy();
}
+ }),
- return element;
- },
-
- instrumentName: 'container',
-
- /**
- When a child view is removed, destroy its element so that
- it is removed from the DOM.
- The array observer that triggers this action is set up in the
- `renderToBuffer` method.
- @private
- @method childViewsWillChange
- @param {Ember.Array} views the child views array before mutation
- @param {Number} start the start position of the mutation
- @param {Number} removed the number of child views removed
- **/
- childViewsWillChange: function (views, start, removed) {
- this.propertyWillChange('childViews');
-
- if (removed > 0) {
- var changedViews = views.slice(start, start + removed);
- // transition to preRender before clearing parentView
- this.currentState.childViewsWillChange(this, views, start, removed);
- this.initializeViews(changedViews, null, null);
+ _currentViewDidChange: mixin.observer("currentView", function () {
+ var currentView = property_get.get(this, "currentView");
+ if (currentView) {
+ Ember['default'].assert("You tried to set a current view that already has a parent. Make sure you don't have multiple outlets in the same view.", !currentView.parentView);
+ this.pushObject(currentView);
}
- },
+ }),
- removeChild: function (child) {
- this.removeObject(child);
- return this;
- },
+ layout: containerViewTemplate['default'],
- /**
- When a child view is added, make sure the DOM gets updated appropriately.
- If the view has already rendered an element, we tell the child view to
- create an element and insert it into the DOM. If the enclosing container
- view has already written to a buffer, but not yet converted that buffer
- into an element, we insert the string representation of the child into the
- appropriate place in the buffer.
- @private
- @method childViewsDidChange
- @param {Ember.Array} views the array of child views after the mutation has occurred
- @param {Number} start the start position of the mutation
- @param {Number} removed the number of child views removed
- @param {Number} added the number of child views added
- */
- childViewsDidChange: function (views, start, removed, added) {
- if (added > 0) {
- var changedViews = views.slice(start, start + added);
- this.initializeViews(changedViews, this);
- this.currentState.childViewsDidChange(this, views, start, added);
- }
- this.propertyDidChange('childViews');
- },
+ replace: function (idx, removedCount) {
+ var _this = this;
- initializeViews: function (views, parentView) {
- enumerable_utils.forEach(views, function (view) {
- property_set.set(view, '_parentView', parentView);
+ var addedViews = arguments[2] === undefined ? [] : arguments[2];
- if (!view.container && parentView) {
- property_set.set(view, 'container', parentView.container);
+ var addedCount = property_get.get(addedViews, "length");
+ var childViews = property_get.get(this, "childViews");
+
+ Ember['default'].assert("You can't add a child to a container - the child is already a child of another view", function () {
+ for (var i = 0, l = addedViews.length; i < l; i++) {
+ var item = addedViews[i];
+ if (item.parentView && item.parentView !== _this) {
+ return false;
+ }
}
+ return true;
});
- },
- currentView: null,
+ this.arrayContentWillChange(idx, removedCount, addedCount);
- _currentViewWillChange: mixin.beforeObserver('currentView', function () {
- var currentView = property_get.get(this, 'currentView');
- if (currentView) {
- currentView.destroy();
- }
- }),
+ // Normally parentView and childViews are managed at render time. However,
+ // the ContainerView is an unusual legacy case. People expect to be able to
+ // push a child view into the ContainerView and have its parentView set
+ // appropriately.
+ //
+ // Because of this, we synchronously fix up the parentView/childViews tree
+ // as soon as views are added or removed, despite the fact that this will
+ // happen automatically when we render.
+ var removedViews = childViews.slice(idx, idx + removedCount);
+ enumerable_utils.forEach(removedViews, function (view) {
+ return _this.unlinkChild(view);
+ });
+ enumerable_utils.forEach(addedViews, function (view) {
+ return _this.linkChild(view);
+ });
- _currentViewDidChange: mixin.observer('currentView', function () {
- var currentView = property_get.get(this, 'currentView');
- if (currentView) {
- Ember['default'].assert("You tried to set a current view that already has a parent. Make sure you don't have multiple outlets in the same view.", !currentView._parentView);
- this.pushObject(currentView);
- }
- }),
+ childViews.splice.apply(childViews, [idx, removedCount].concat(addedViews));
- _ensureChildrenAreInDOM: function () {
- this.currentState.ensureChildrenAreInDOM(this);
- }
- });
+ this.notifyPropertyChange("childViews");
+ this.arrayContentDidChange(idx, removedCount, addedCount);
- merge['default'](states._default, {
- childViewsWillChange: K,
- childViewsDidChange: K,
- ensureChildrenAreInDOM: K
- });
+ //Ember.assert("You can't add a child to a container - the child is already a child of another view", emberA(addedViews).every(function(item) { return !item.parentView || item.parentView === self; }));
- merge['default'](states.inBuffer, {
- childViewsDidChange: function (parentView, views, start, added) {
- throw new EmberError['default']('You cannot modify child views while in the inBuffer state');
- }
- });
+ property_set.set(this, "length", childViews.length);
- merge['default'](states.hasElement, {
- childViewsWillChange: function (view, views, start, removed) {
- for (var i = start; i < start + removed; i++) {
- var _view = views[i];
- _view._unsubscribeFromStreamBindings();
- _view.remove();
- }
+ return this;
},
- childViewsDidChange: function (view, views, start, added) {
- run['default'].scheduleOnce('render', view, '_ensureChildrenAreInDOM');
- },
-
- ensureChildrenAreInDOM: function (view) {
- var childViews = view._childViews;
- var renderer = view._renderer;
-
- var refMorph = null;
- for (var i = childViews.length - 1; i >= 0; i--) {
- var childView = childViews[i];
- if (!childView._elementCreated) {
- renderer.renderTree(childView, view, refMorph);
- }
- refMorph = childView._morph;
- }
+ objectAt: function (idx) {
+ return property_get.get(this, "childViews")[idx];
}
});
exports['default'] = ContainerView;
});
-enifed('ember-views/views/core_view', ['exports', 'ember-views/system/renderer', 'dom-helper', 'ember-views/views/states', 'ember-runtime/system/object', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/action_handler', 'ember-metal/property_get', 'ember-metal/computed', 'ember-metal/utils'], function (exports, Renderer, DOMHelper, states, EmberObject, Evented, ActionHandler, property_get, computed, utils) {
+enifed('ember-views/views/core_view', ['exports', 'ember-metal-views/renderer', 'ember-views/views/states', 'ember-runtime/system/object', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/action_handler', 'ember-metal/property_get', 'ember-runtime/utils', 'htmlbars-runtime'], function (exports, Renderer, states, EmberObject, Evented, ActionHandler, property_get, utils, htmlbars_runtime) {
'use strict';
function K() {
return this;
@@ -38709,60 +40423,44 @@
@uses Ember.Evented
@uses Ember.ActionHandler
*/
var CoreView = EmberObject['default'].extend(Evented['default'], ActionHandler['default'], {
isView: true,
- isVirtual: false,
_states: states.cloneStates(states.states),
init: function () {
this._super.apply(this, arguments);
- this._state = 'preRender';
+ this._state = "preRender";
this.currentState = this._states.preRender;
- this._isVisible = property_get.get(this, 'isVisible');
+ this._isVisible = property_get.get(this, "isVisible");
// Fallback for legacy cases where the view was created directly
// via `create()` instead of going through the container.
if (!this.renderer) {
- renderer = renderer || new Renderer['default'](new DOMHelper['default']());
+ var DOMHelper = domHelper();
+ renderer = renderer || new Renderer['default'](new DOMHelper());
this.renderer = renderer;
}
+
+ this.isDestroyingSubtree = false;
+ this._dispatching = null;
},
/**
If the view is currently inserted into the DOM of a parent view, this
property will point to the parent of the view.
@property parentView
@type Ember.View
@default null
*/
- parentView: computed.computed('_parentView', function () {
- var parent = this._parentView;
+ parentView: null,
- if (parent && parent.isVirtual) {
- return property_get.get(parent, 'parentView');
- } else {
- return parent;
- }
- }),
-
_state: null,
- _parentView: null,
+ instrumentName: "core_view",
- // return the current view, not including virtual views
- concreteView: computed.computed('parentView', function () {
- if (!this.isVirtual) {
- return this;
- } else {
- return property_get.get(this, 'parentView.concreteView');
- }
- }),
-
- instrumentName: 'core_view',
-
instrumentDetails: function (hash) {
hash.object = this.toString();
hash.containerKey = this._debugContainerKey;
hash.view = this;
},
@@ -38787,35 +40485,34 @@
return method.apply(this, args);
}
},
has: function (name) {
- return utils.typeOf(this[name]) === 'function' || this._super(name);
+ return utils.typeOf(this[name]) === "function" || this._super(name);
},
destroy: function () {
- var parent = this._parentView;
+ var parent = this.parentView;
if (!this._super.apply(this, arguments)) {
return;
}
- // destroy the element -- this will avoid each child view destroying
- // the element over and over again...
- if (!this.removedFromDOM && this._renderer) {
- this._renderer.remove(this, true);
- }
+ this.currentState.cleanup(this);
- // remove from parent if found. Don't call removeFromParent,
- // as removeFromParent will try to remove the element from
- // the DOM again.
- if (parent) {
- parent.removeChild(this);
+ if (!this.ownerView.isDestroyingSubtree) {
+ this.ownerView.isDestroyingSubtree = true;
+ if (parent) {
+ parent.removeChild(this);
+ }
+ if (this._renderNode) {
+ Ember.assert("BUG: Render node exists without concomitant env.", this.ownerView.env);
+ htmlbars_runtime.internal.clearMorph(this._renderNode, this.ownerView.env, true);
+ }
+ this.ownerView.isDestroyingSubtree = false;
}
- this._transitionTo('destroying', false);
-
return this;
},
clearRenderedChildren: K,
_transitionTo: K,
@@ -38826,190 +40523,130 @@
isViewClass: true
});
var DeprecatedCoreView = CoreView.extend({
init: function () {
- Ember.deprecate('Ember.CoreView is deprecated. Please use Ember.View.', false);
+ Ember.deprecate("Ember.CoreView is deprecated. Please use Ember.View.", false);
this._super.apply(this, arguments);
}
});
+ var _domHelper;
+ function domHelper() {
+ return _domHelper = _domHelper || Ember.__loader.require("ember-htmlbars/system/dom-helper")["default"];
+ }
+
exports['default'] = CoreView;
exports.DeprecatedCoreView = DeprecatedCoreView;
});
-enifed('ember-views/views/each', ['exports', 'ember-metal/core', 'ember-runtime/system/string', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-views/views/collection_view', 'ember-metal/binding', 'ember-runtime/mixins/controller', 'ember-runtime/controllers/array_controller', 'ember-runtime/mixins/array', 'ember-metal/observer', 'ember-views/views/metamorph_view'], function (exports, Ember, string, property_get, property_set, CollectionView, ember_metal__binding, ControllerMixin, ArrayController, EmberArray, observer, _MetamorphView) {
+enifed('ember-views/views/legacy_each_view', ['exports', 'ember-htmlbars/templates/legacy-each', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/computed', 'ember-views/views/view', 'ember-views/views/collection_view'], function (exports, legacyEachTemplate, property_get, property_set, computed, View, collection_view) {
'use strict';
- exports['default'] = CollectionView['default'].extend(_MetamorphView._Metamorph, {
+ //2.0TODO: Remove this in 2.0
+ //This is a fallback path for the `{{#each}}` helper that supports deprecated
+ //behavior such as itemController.
- init: function () {
- var itemController = property_get.get(this, 'itemController');
- var binding;
+ exports['default'] = View['default'].extend({
+ template: legacyEachTemplate['default'],
+ tagName: "",
- if (itemController) {
- var controller = property_get.get(this, 'controller.container').lookupFactory('controller:array').create({
- _isVirtual: true,
- parentController: property_get.get(this, 'controller'),
- itemController: itemController,
- target: property_get.get(this, 'controller'),
- _eachView: this
- });
+ _arrayController: computed.computed(function () {
+ var itemController = this.getAttr("itemController");
+ var controller = property_get.get(this, "container").lookupFactory("controller:array").create({
+ _isVirtual: true,
+ parentController: property_get.get(this, "controller"),
+ itemController: itemController,
+ target: property_get.get(this, "controller"),
+ _eachView: this,
+ content: this.getAttr("content")
+ });
- this.disableContentObservers(function () {
- property_set.set(this, 'content', controller);
- binding = new ember_metal__binding.Binding('content', '_eachView.dataSource').oneWay();
- binding.connect(controller);
- });
+ return controller;
+ }),
- this._arrayController = controller;
- } else {
- this.disableContentObservers(function () {
- binding = new ember_metal__binding.Binding('content', 'dataSource').oneWay();
- binding.connect(this);
- });
- }
+ willUpdate: function (attrs) {
+ var itemController = this.getAttrFor(attrs, "itemController");
- return this._super.apply(this, arguments);
- },
-
- _assertArrayLike: function (content) {
- Ember['default'].assert(string.fmt("The value that #each loops over must be an Array. You " + "passed %@, but it should have been an ArrayController", [content.constructor]), !ControllerMixin['default'].detect(content) || content && content.isGenerated || content instanceof ArrayController['default']);
- Ember['default'].assert(string.fmt("The value that #each loops over must be an Array. You passed %@", [ControllerMixin['default'].detect(content) && content.get('model') !== undefined ? string.fmt("'%@' (wrapped in %@)", [content.get('model'), content]) : content]), EmberArray['default'].detect(content));
- },
-
- disableContentObservers: function (callback) {
- observer.removeBeforeObserver(this, 'content', null, '_contentWillChange');
- observer.removeObserver(this, 'content', null, '_contentDidChange');
-
- callback.call(this);
-
- observer.addBeforeObserver(this, 'content', null, '_contentWillChange');
- observer.addObserver(this, 'content', null, '_contentDidChange');
- },
-
- itemViewClass: _MetamorphView['default'],
- emptyViewClass: _MetamorphView['default'],
-
- createChildView: function (_view, attrs) {
- var view = this._super(_view, attrs);
-
- var content = property_get.get(view, 'content');
- var keyword = property_get.get(this, 'keyword');
-
- if (keyword) {
- view._keywords[keyword] = content;
+ if (itemController) {
+ var arrayController = property_get.get(this, "_arrayController");
+ property_set.set(arrayController, "content", this.getAttrFor(attrs, "content"));
}
-
- // If {{#each}} is looping over an array of controllers,
- // point each child view at their respective controller.
- if (content && content.isController) {
- property_set.set(view, 'controller', content);
- }
-
- return view;
},
- destroy: function () {
- if (!this._super.apply(this, arguments)) {
- return;
+ _arrangedContent: computed.computed("attrs.content", function () {
+ if (this.getAttr("itemController")) {
+ return property_get.get(this, "_arrayController");
}
- if (this._arrayController) {
- this._arrayController.destroy();
- }
+ return this.getAttr("content");
+ }),
- return this;
- }
+ _itemTagName: computed.computed(function () {
+ var tagName = property_get.get(this, "tagName");
+ return collection_view.CONTAINER_MAP[tagName];
+ })
});
});
-enifed('ember-views/views/metamorph_view', ['exports', 'ember-metal/core', 'ember-views/views/view', 'ember-metal/mixin'], function (exports, Ember, View, mixin) {
+enifed('ember-views/views/select', ['exports', 'ember-metal/enumerable_utils', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-views/views/view', 'ember-runtime/utils', 'ember-metal/is_none', 'ember-metal/computed', 'ember-runtime/system/native_array', 'ember-metal/mixin', 'ember-metal/properties', 'ember-htmlbars/templates/select', 'ember-htmlbars/templates/select-option', 'ember-htmlbars/templates/select-optgroup'], function (exports, enumerable_utils, property_get, property_set, View, utils, isNone, computed, native_array, mixin, properties, htmlbarsTemplate, selectOptionDefaultTemplate, selectOptgroupDefaultTemplate) {
'use strict';
- /*jshint newcap:false*/
- var _Metamorph = mixin.Mixin.create({
- isVirtual: true,
- tagName: '',
-
- instrumentName: 'metamorph',
-
- init: function () {
- this._super.apply(this, arguments);
- Ember['default'].deprecate('Supplying a tagName to Metamorph views is unreliable and is deprecated.' + ' You may be setting the tagName on a Handlebars helper that creates a Metamorph.', !this.tagName);
- }
- });
-
- exports['default'] = View['default'].extend(_Metamorph);
-
- exports._Metamorph = _Metamorph;
-
-});
-enifed('ember-views/views/select', ['exports', 'ember-metal/enumerable_utils', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-views/views/view', 'ember-views/views/collection_view', 'ember-metal/utils', 'ember-metal/is_none', 'ember-metal/computed', 'ember-runtime/system/native_array', 'ember-metal/mixin', 'ember-metal/properties', 'ember-htmlbars/templates/select', 'ember-htmlbars/templates/select-option'], function (exports, enumerable_utils, property_get, property_set, View, CollectionView, utils, isNone, computed, native_array, mixin, properties, htmlbarsTemplate, selectOptionDefaultTemplate) {
-
- 'use strict';
-
/**
@module ember
@submodule ember-views
*/
var defaultTemplate = htmlbarsTemplate['default'];
var SelectOption = View['default'].extend({
- instrumentDisplay: 'Ember.SelectOption',
+ instrumentDisplay: "Ember.SelectOption",
- tagName: 'option',
- attributeBindings: ['value', 'selected'],
+ tagName: "option",
+ attributeBindings: ["value", "selected"],
defaultTemplate: selectOptionDefaultTemplate['default'],
- init: function () {
+ content: null,
+
+ willRender: function () {
this.labelPathDidChange();
this.valuePathDidChange();
-
- this._super.apply(this, arguments);
},
selected: computed.computed(function () {
- var value = property_get.get(this, 'value');
- var selection = property_get.get(this, 'parentView.selection');
- if (property_get.get(this, 'parentView.multiple')) {
+ var value = property_get.get(this, "value");
+ var selection = property_get.get(this, "attrs.selection");
+ if (property_get.get(this, "attrs.multiple")) {
return selection && enumerable_utils.indexOf(selection, value) > -1;
} else {
// Primitives get passed through bindings as objects... since
// `new Number(4) !== 4`, we use `==` below
- return value === property_get.get(this, 'parentView.value');
+ return value == property_get.get(this, "attrs.parentValue"); // jshint ignore:line
}
- }).property('content', 'parentView.selection'),
+ }).property("attrs.content", "attrs.selection"),
- labelPathDidChange: mixin.observer('parentView.optionLabelPath', function () {
- var labelPath = property_get.get(this, 'parentView.optionLabelPath');
- properties.defineProperty(this, 'label', computed.computed.alias(labelPath));
+ labelPathDidChange: mixin.observer("attrs.optionLabelPath", function () {
+ var labelPath = property_get.get(this, "attrs.optionLabelPath");
+ properties.defineProperty(this, "label", computed.computed.alias(labelPath));
}),
- valuePathDidChange: mixin.observer('parentView.optionValuePath', function () {
- var valuePath = property_get.get(this, 'parentView.optionValuePath');
- properties.defineProperty(this, 'value', computed.computed.alias(valuePath));
+ valuePathDidChange: mixin.observer("attrs.optionValuePath", function () {
+ var valuePath = property_get.get(this, "attrs.optionValuePath");
+ properties.defineProperty(this, "value", computed.computed.alias(valuePath));
})
});
- var SelectOptgroup = CollectionView['default'].extend({
- instrumentDisplay: 'Ember.SelectOptgroup',
+ var SelectOptgroup = View['default'].extend({
+ instrumentDisplay: "Ember.SelectOptgroup",
- tagName: 'optgroup',
- attributeBindings: ['label'],
-
- selectionBinding: 'parentView.selection',
- multipleBinding: 'parentView.multiple',
- optionLabelPathBinding: 'parentView.optionLabelPath',
- optionValuePathBinding: 'parentView.optionValuePath',
-
- itemViewClassBinding: 'parentView.optionView'
+ tagName: "optgroup",
+ defaultTemplate: selectOptgroupDefaultTemplate['default'],
+ attributeBindings: ["label"]
});
/**
The `Ember.Select` view class renders a
[select](https://developer.mozilla.org/en/HTML/Element/select) HTML element,
@@ -39249,16 +40886,16 @@
@class Select
@namespace Ember
@extends Ember.View
*/
var Select = View['default'].extend({
- instrumentDisplay: 'Ember.Select',
+ instrumentDisplay: "Ember.Select",
- tagName: 'select',
- classNames: ['ember-select'],
+ tagName: "select",
+ classNames: ["ember-select"],
defaultTemplate: defaultTemplate,
- attributeBindings: ['autofocus', 'autocomplete', 'disabled', 'form', 'multiple', 'name', 'required', 'size', 'tabindex'],
+ attributeBindings: ["autofocus", "autocomplete", "disabled", "form", "multiple", "name", "required", "size", "tabindex"],
/**
The `multiple` attribute of the select element. Indicates whether multiple
options can be selected.
@property multiple
@@ -39326,17 +40963,17 @@
@type String
@default null
*/
value: computed.computed({
get: function (key) {
- var valuePath = property_get.get(this, '_valuePath');
- return valuePath ? property_get.get(this, 'selection.' + valuePath) : property_get.get(this, 'selection');
+ var valuePath = property_get.get(this, "_valuePath");
+ return valuePath ? property_get.get(this, "selection." + valuePath) : property_get.get(this, "selection");
},
set: function (key, value) {
return value;
}
- }).property('_valuePath', 'selection'),
+ }).property("_valuePath", "selection"),
/**
If given, a top-most dummy option will be rendered to serve as a user
prompt.
@property prompt
@@ -39349,19 +40986,19 @@
The path of the option labels. See [content](/api/classes/Ember.Select.html#property_content).
@property optionLabelPath
@type String
@default 'content'
*/
- optionLabelPath: 'content',
+ optionLabelPath: "content",
/**
The path of the option values. See [content](/api/classes/Ember.Select.html#property_content).
@property optionValuePath
@type String
@default 'content'
*/
- optionValuePath: 'content',
+ optionValuePath: "content",
/**
The path of the option group.
When this property is used, `content` should be sorted by `optionGroupPath`.
@property optionGroupPath
@@ -39377,174 +41014,185 @@
@default Ember.SelectOptgroup
*/
groupView: SelectOptgroup,
groupedContent: computed.computed(function () {
- var groupPath = property_get.get(this, 'optionGroupPath');
+ var groupPath = property_get.get(this, "optionGroupPath");
var groupedContent = native_array.A();
- var content = property_get.get(this, 'content') || [];
+ var content = property_get.get(this, "content") || [];
enumerable_utils.forEach(content, function (item) {
var label = property_get.get(item, groupPath);
- if (property_get.get(groupedContent, 'lastObject.label') !== label) {
+ if (property_get.get(groupedContent, "lastObject.label") !== label) {
groupedContent.pushObject({
label: label,
content: native_array.A()
});
}
- property_get.get(groupedContent, 'lastObject.content').push(item);
+ property_get.get(groupedContent, "lastObject.content").push(item);
});
return groupedContent;
- }).property('optionGroupPath', 'content.@each'),
+ }).property("optionGroupPath", "content.@each"),
/**
The view class for option.
@property optionView
@type Ember.View
@default Ember.SelectOption
*/
optionView: SelectOption,
- _change: function () {
- if (property_get.get(this, 'multiple')) {
- this._changeMultiple();
+ _change: function (hasDOM) {
+ if (property_get.get(this, "multiple")) {
+ this._changeMultiple(hasDOM);
} else {
- this._changeSingle();
+ this._changeSingle(hasDOM);
}
},
- selectionDidChange: mixin.observer('selection.@each', function () {
- var selection = property_get.get(this, 'selection');
- if (property_get.get(this, 'multiple')) {
+ selectionDidChange: mixin.observer("selection.@each", function () {
+ var selection = property_get.get(this, "selection");
+ if (property_get.get(this, "multiple")) {
if (!utils.isArray(selection)) {
- property_set.set(this, 'selection', native_array.A([selection]));
+ property_set.set(this, "selection", native_array.A([selection]));
return;
}
this._selectionDidChangeMultiple();
} else {
this._selectionDidChangeSingle();
}
}),
- valueDidChange: mixin.observer('value', function () {
- var content = property_get.get(this, 'content');
- var value = property_get.get(this, 'value');
- var valuePath = property_get.get(this, 'optionValuePath').replace(/^content\.?/, '');
- var selectedValue = valuePath ? property_get.get(this, 'selection.' + valuePath) : property_get.get(this, 'selection');
+ valueDidChange: mixin.observer("value", function () {
+ var content = property_get.get(this, "content");
+ var value = property_get.get(this, "value");
+ var valuePath = property_get.get(this, "optionValuePath").replace(/^content\.?/, "");
+ var selectedValue = valuePath ? property_get.get(this, "selection." + valuePath) : property_get.get(this, "selection");
var selection;
if (value !== selectedValue) {
selection = content ? content.find(function (obj) {
return value === (valuePath ? property_get.get(obj, valuePath) : obj);
}) : null;
- this.set('selection', selection);
+ this.set("selection", selection);
}
}),
_setDefaults: function () {
- var selection = property_get.get(this, 'selection');
- var value = property_get.get(this, 'value');
+ var selection = property_get.get(this, "selection");
+ var value = property_get.get(this, "value");
if (!isNone['default'](selection)) {
this.selectionDidChange();
}
if (!isNone['default'](value)) {
this.valueDidChange();
}
if (isNone['default'](selection)) {
- this._change();
+ this._change(false);
}
},
- _changeSingle: function () {
- var selectedIndex = this.$()[0].selectedIndex;
- var content = property_get.get(this, 'content');
- var prompt = property_get.get(this, 'prompt');
+ _changeSingle: function (hasDOM) {
+ var value = this.get("value");
+ var selectedIndex = hasDOM !== false ? this.$()[0].selectedIndex : this._selectedIndex(value);
+ var content = property_get.get(this, "content");
+ var prompt = property_get.get(this, "prompt");
- if (!content || !property_get.get(content, 'length')) {
+ if (!content || !property_get.get(content, "length")) {
return;
}
if (prompt && selectedIndex === 0) {
- property_set.set(this, 'selection', null);
+ property_set.set(this, "selection", null);
return;
}
if (prompt) {
selectedIndex -= 1;
}
- property_set.set(this, 'selection', content.objectAt(selectedIndex));
+ property_set.set(this, "selection", content.objectAt(selectedIndex));
},
- _changeMultiple: function () {
- var options = this.$('option:selected');
- var prompt = property_get.get(this, 'prompt');
+ _selectedIndex: function (value) {
+ var defaultIndex = arguments[1] === undefined ? 0 : arguments[1];
+
+ var content = property_get.get(this, "contentValues");
+
+ var selectionIndex = enumerable_utils.indexOf(content, value);
+
+ var prompt = property_get.get(this, "prompt");
+ if (prompt) {
+ selectionIndex += 1;
+ }
+
+ if (selectionIndex < 0) {
+ selectionIndex = defaultIndex;
+ }
+
+ return selectionIndex;
+ },
+
+ _changeMultiple: function (hasDOM) {
+ var options = hasDOM !== false ? this.$("option:selected") : [];
+ var prompt = property_get.get(this, "prompt");
var offset = prompt ? 1 : 0;
- var content = property_get.get(this, 'content');
- var selection = property_get.get(this, 'selection');
+ var content = property_get.get(this, "content");
+ var selection = property_get.get(this, "selection");
if (!content) {
return;
}
if (options) {
var selectedIndexes = options.map(function () {
return this.index - offset;
- }).toArray();
- var newSelection = content.objectsAt(selectedIndexes);
+ });
+ var newSelection = content.objectsAt([].slice.call(selectedIndexes));
if (utils.isArray(selection)) {
- enumerable_utils.replace(selection, 0, property_get.get(selection, 'length'), newSelection);
+ enumerable_utils.replace(selection, 0, property_get.get(selection, "length"), newSelection);
} else {
- property_set.set(this, 'selection', newSelection);
+ property_set.set(this, "selection", newSelection);
}
}
},
_selectionDidChangeSingle: function () {
- var value = property_get.get(this, 'value');
+ var value = property_get.get(this, "value");
var self = this;
if (value && value.then) {
value.then(function (resolved) {
// Ensure that we don't overwrite new value
- if (property_get.get(self, 'value') === value) {
+ if (property_get.get(self, "value") === value) {
self._setSelectedIndex(resolved);
}
});
} else {
this._setSelectedIndex(value);
}
},
_setSelectedIndex: function (selectionValue) {
- var el = property_get.get(this, 'element');
- var content = property_get.get(this, 'contentValues');
+ var el = property_get.get(this, "element");
if (!el) {
return;
}
- var selectionIndex = enumerable_utils.indexOf(content, selectionValue);
- var prompt = property_get.get(this, 'prompt');
-
- if (prompt) {
- selectionIndex += 1;
- }
- if (el) {
- el.selectedIndex = selectionIndex;
- }
+ el.selectedIndex = this._selectedIndex(selectionValue, -1);
},
- _valuePath: computed.computed('optionValuePath', function () {
- var optionValuePath = property_get.get(this, 'optionValuePath');
- return optionValuePath.replace(/^content\.?/, '');
+ _valuePath: computed.computed("optionValuePath", function () {
+ var optionValuePath = property_get.get(this, "optionValuePath");
+ return optionValuePath.replace(/^content\.?/, "");
}),
- contentValues: computed.computed('content.[]', '_valuePath', function () {
- var valuePath = property_get.get(this, '_valuePath');
- var content = property_get.get(this, 'content') || [];
+ contentValues: computed.computed("content.[]", "_valuePath", function () {
+ var valuePath = property_get.get(this, "_valuePath");
+ var content = property_get.get(this, "content") || [];
if (valuePath) {
return enumerable_utils.map(content, function (el) {
return property_get.get(el, valuePath);
});
@@ -39554,29 +41202,32 @@
});
}
}),
_selectionDidChangeMultiple: function () {
- var content = property_get.get(this, 'content');
- var selection = property_get.get(this, 'selection');
+ var content = property_get.get(this, "content");
+ var selection = property_get.get(this, "selection");
var selectedIndexes = content ? enumerable_utils.indexesOf(content, selection) : [-1];
- var prompt = property_get.get(this, 'prompt');
+ var prompt = property_get.get(this, "prompt");
var offset = prompt ? 1 : 0;
- var options = this.$('option');
+ var options = this.$("option");
var adjusted;
if (options) {
options.each(function () {
adjusted = this.index > -1 ? this.index - offset : -1;
this.selected = enumerable_utils.indexOf(selectedIndexes, adjusted) > -1;
});
}
},
+ willRender: function () {
+ this._setDefaults();
+ },
+
init: function () {
this._super.apply(this, arguments);
- this.on("didInsertElement", this, this._setDefaults);
this.on("change", this, this._change);
}
});
exports['default'] = Select;
@@ -39584,129 +41235,22 @@
exports.Select = Select;
exports.SelectOption = SelectOption;
exports.SelectOptgroup = SelectOptgroup;
});
-enifed('ember-views/views/simple_bound_view', ['exports', 'ember-metal/error', 'ember-metal/run_loop', 'ember-metal/utils'], function (exports, EmberError, run, utils) {
+enifed('ember-views/views/states', ['exports', 'ember-metal/platform/create', 'ember-metal/merge', 'ember-views/views/states/default', 'ember-views/views/states/pre_render', 'ember-views/views/states/has_element', 'ember-views/views/states/in_dom', 'ember-views/views/states/destroying'], function (exports, create, merge, _default, preRender, hasElement, inDOM, destroying) {
'use strict';
- exports.appendSimpleBoundView = appendSimpleBoundView;
-
- function K() {
- return this;
- }
-
- function SimpleBoundView(parentView, renderer, morph, stream) {
- this.stream = stream;
- this[utils.GUID_KEY] = utils.uuid();
- this._lastNormalizedValue = undefined;
- this.state = 'preRender';
- this.updateId = null;
- this._parentView = parentView;
- this.buffer = null;
- this._morph = morph;
- this.renderer = renderer;
- }
-
- SimpleBoundView.prototype = {
- isVirtual: true,
- isView: true,
- tagName: '',
-
- destroy: function () {
- if (this.updateId) {
- run['default'].cancel(this.updateId);
- this.updateId = null;
- }
- if (this._parentView) {
- this._parentView.removeChild(this);
- }
- this.morph = null;
- this.state = 'destroyed';
- },
-
- propertyWillChange: K,
-
- propertyDidChange: K,
-
- normalizedValue: function () {
- var result = this.stream.value();
-
- if (result === null || result === undefined) {
- return "";
- } else {
- return result;
- }
- },
-
- render: function (buffer) {
- var value = this.normalizedValue();
- this._lastNormalizedValue = value;
- buffer._element = value;
- },
-
- rerender: function () {
- switch (this.state) {
- case 'preRender':
- case 'destroyed':
- break;
- case 'inBuffer':
- throw new EmberError['default']("Something you did tried to replace an {{expression}} before it was inserted into the DOM.");
- case 'hasElement':
- case 'inDOM':
- this.updateId = run['default'].scheduleOnce('render', this, 'update');
- break;
- }
- return this;
- },
-
- update: function () {
- this.updateId = null;
- var value = this.normalizedValue();
- // doesn't diff SafeString instances
- if (value !== this._lastNormalizedValue) {
- this._lastNormalizedValue = value;
- this._morph.setContent(value);
- }
- },
-
- _transitionTo: function (state) {
- this.state = state;
- }
- };
-
- SimpleBoundView.create = function (attrs) {
- return new SimpleBoundView(attrs._parentView, attrs.renderer, attrs._morph, attrs.stream);
- };
-
- SimpleBoundView.isViewClass = true;
-
- function appendSimpleBoundView(parentView, morph, stream) {
- var view = parentView.appendChild(SimpleBoundView, { _morph: morph, stream: stream });
-
- stream.subscribe(parentView._wrapAsScheduled(function () {
- run['default'].scheduleOnce('render', view, 'rerender');
- }));
- }
-
- exports['default'] = SimpleBoundView;
-
-});
-enifed('ember-views/views/states', ['exports', 'ember-metal/platform/create', 'ember-metal/merge', 'ember-views/views/states/default', 'ember-views/views/states/pre_render', 'ember-views/views/states/in_buffer', 'ember-views/views/states/has_element', 'ember-views/views/states/in_dom', 'ember-views/views/states/destroying'], function (exports, create, merge, _default, preRender, inBuffer, hasElement, inDOM, destroying) {
-
- 'use strict';
-
exports.cloneStates = cloneStates;
function cloneStates(from) {
var into = {};
into._default = {};
into.preRender = create['default'](into._default);
into.destroying = create['default'](into._default);
- into.inBuffer = create['default'](into._default);
into.hasElement = create['default'](into._default);
into.inDOM = create['default'](into.hasElement);
for (var stateName in from) {
if (!from.hasOwnProperty(stateName)) {
@@ -39720,30 +41264,21 @@
var states = {
_default: _default['default'],
preRender: preRender['default'],
inDOM: inDOM['default'],
- inBuffer: inBuffer['default'],
hasElement: hasElement['default'],
destroying: destroying['default']
};
exports.states = states;
});
-enifed('ember-views/views/states/default', ['exports', 'ember-metal/error'], function (exports, EmberError) {
+enifed('ember-views/views/states/default', ['exports', 'ember-metal/error', 'ember-metal/property_get', 'ember-metal/property_events', 'ember-views/compat/attrs-proxy'], function (exports, EmberError, property_get, property_events, attrs_proxy) {
'use strict';
- function K() {
- return this;
- }
-
- /**
- @module ember
- @submodule ember-views
- */
exports['default'] = {
// appendChild is only legal while rendering the buffer.
appendChild: function () {
throw new EmberError['default']("You can't use appendChild outside of the rendering process");
},
@@ -39754,25 +41289,50 @@
getElement: function () {
return null;
},
+ legacyAttrWillChange: function (view, key) {
+ if (key in view.attrs && !(key in view)) {
+ property_events.propertyWillChange(view, key);
+ }
+ },
+
+ legacyAttrDidChange: function (view, key) {
+ if (key in view.attrs && !(key in view)) {
+ property_events.propertyDidChange(view, key);
+ }
+ },
+
+ legacyPropertyDidChange: function (view, key) {
+ var attrs = view.attrs;
+
+ if (attrs && key in attrs) {
+ var possibleCell = attrs[key];
+
+ if (possibleCell && possibleCell[attrs_proxy.MUTABLE_CELL]) {
+ var value = property_get.get(view, key);
+ if (value === possibleCell.value) {
+ return;
+ }
+ possibleCell.update(value);
+ }
+ }
+ },
+
// Handle events from `Ember.EventDispatcher`
handleEvent: function () {
return true; // continue event propagation
},
- destroyElement: function (view) {
- if (view._renderer) {
- view._renderer.remove(view, false);
- }
+ cleanup: function () {},
+ destroyElement: function () {},
- return view;
+ rerender: function (view) {
+ view.renderer.ensureViewNotRendering(view);
},
-
- rerender: K,
- invokeObserver: K
+ invokeObserver: function () {}
};
});
enifed('ember-views/views/states/destroying', ['exports', 'ember-metal/merge', 'ember-metal/platform/create', 'ember-runtime/system/string', 'ember-views/views/states/default', 'ember-metal/error'], function (exports, merge, create, string, _default, EmberError) {
@@ -39782,62 +41342,74 @@
var destroying = create['default'](_default['default']);
merge['default'](destroying, {
appendChild: function () {
- throw new EmberError['default'](string.fmt(destroyingError, ['appendChild']));
+ throw new EmberError['default'](string.fmt(destroyingError, ["appendChild"]));
},
rerender: function () {
- throw new EmberError['default'](string.fmt(destroyingError, ['rerender']));
+ throw new EmberError['default'](string.fmt(destroyingError, ["rerender"]));
},
destroyElement: function () {
- throw new EmberError['default'](string.fmt(destroyingError, ['destroyElement']));
+ throw new EmberError['default'](string.fmt(destroyingError, ["destroyElement"]));
}
});
exports['default'] = destroying;
});
-enifed('ember-views/views/states/has_element', ['exports', 'ember-views/views/states/default', 'ember-metal/run_loop', 'ember-metal/merge', 'ember-metal/platform/create', 'ember-views/system/jquery', 'ember-metal/error', 'ember-metal/property_get'], function (exports, _default, run, merge, create, jQuery, EmberError, property_get) {
+enifed('ember-views/views/states/has_element', ['exports', 'ember-views/views/states/default', 'ember-metal/merge', 'ember-metal/platform/create', 'ember-views/system/jquery', 'ember-metal/property_get', 'htmlbars-runtime'], function (exports, _default, merge, create, jQuery, property_get, htmlbars_runtime) {
'use strict';
var hasElement = create['default'](_default['default']);
merge['default'](hasElement, {
$: function (view, sel) {
- var elem = view.get('concreteView').element;
+ var elem = view.element;
return sel ? jQuery['default'](sel, elem) : jQuery['default'](elem);
},
getElement: function (view) {
- var parent = property_get.get(view, 'parentView');
+ var parent = property_get.get(view, "parentView");
if (parent) {
- parent = property_get.get(parent, 'element');
+ parent = property_get.get(parent, "element");
}
if (parent) {
return view.findElementInParentElement(parent);
}
- return jQuery['default']("#" + property_get.get(view, 'elementId'))[0];
+ return jQuery['default']("#" + property_get.get(view, "elementId"))[0];
},
// once the view has been inserted into the DOM, rerendering is
// deferred to allow bindings to synchronize.
rerender: function (view) {
- if (view._root._morph && !view._elementInserted) {
- throw new EmberError['default']('Something you did caused a view to re-render after it rendered but before it was inserted into the DOM.');
- }
+ view.renderer.ensureViewNotRendering(view);
- run['default'].scheduleOnce('render', view, '_rerender');
+ var renderNode = view._renderNode;
+
+ renderNode.isDirty = true;
+ htmlbars_runtime.internal.visitChildren(renderNode.childNodes, function (node) {
+ if (node.state && node.state.manager) {
+ node.shouldReceiveAttrs = true;
+ }
+ node.isDirty = true;
+ });
+
+ renderNode.ownerNode.emberView.scheduleRevalidate(renderNode, view.toString(), "rerendering");
},
+ cleanup: function (view) {
+ view.currentState.destroyElement(view);
+ },
+
// once the view is already in the DOM, destroying it removes it
// from the DOM, nukes its element, and puts it back into the
// preRender state if inDOM.
destroyElement: function (view) {
- view._renderer.remove(view, false);
+ view.renderer.remove(view, false);
return view;
},
// Handle events from `Ember.EventDispatcher`
handleEvent: function (view, eventName, evt) {
@@ -39856,170 +41428,88 @@
});
exports['default'] = hasElement;
});
-enifed('ember-views/views/states/in_buffer', ['exports', 'ember-views/views/states/default', 'ember-metal/error', 'ember-views/system/jquery', 'ember-metal/platform/create', 'ember-metal/merge'], function (exports, _default, EmberError, jQuery, create, merge) {
-
- 'use strict';
-
- var inBuffer = create['default'](_default['default']);
-
- merge['default'](inBuffer, {
- $: function (view, sel) {
- // if we don't have an element yet, someone calling this.$() is
- // trying to update an element that isn't in the DOM. Instead,
- // rerender the view to allow the render method to reflect the
- // changes.
- view.rerender();
- return jQuery['default']();
- },
-
- // when a view is rendered in a buffer, rerendering it simply
- // replaces the existing buffer with a new one
- rerender: function (view) {
- throw new EmberError['default']("Something you did caused a view to re-render after it rendered but before it was inserted into the DOM.");
- },
-
- // when a view is rendered in a buffer, appending a child
- // view will render that view and append the resulting
- // buffer into its buffer.
- appendChild: function (view, childView, options) {
- var buffer = view.buffer;
- var _childViews = view._childViews;
-
- childView = view.createChildView(childView, options);
- if (!_childViews.length) {
- _childViews = view._childViews = _childViews.slice();
- }
- _childViews.push(childView);
-
- if (!childView._morph) {
- buffer.pushChildView(childView);
- }
-
- view.propertyDidChange('childViews');
-
- return childView;
- },
-
- appendAttr: function (view, attrNode) {
- var buffer = view.buffer;
- var _attrNodes = view._attrNodes;
-
- if (!_attrNodes.length) {
- _attrNodes = view._attrNodes = _attrNodes.slice();
- }
- _attrNodes.push(attrNode);
-
- if (!attrNode._morph) {
- Ember.assert("bound attributes that do not have a morph must have a buffer", !!buffer);
- buffer.pushAttrNode(attrNode);
- }
-
- view.propertyDidChange('childViews');
-
- return attrNode;
- },
-
- invokeObserver: function (target, observer) {
- observer.call(target);
- }
- });
-
- exports['default'] = inBuffer;
-
-});
enifed('ember-views/views/states/in_dom', ['exports', 'ember-metal/platform/create', 'ember-metal/merge', 'ember-metal/error', 'ember-metal/observer', 'ember-views/views/states/has_element'], function (exports, create, merge, EmberError, observer, hasElement) {
'use strict';
var inDOM = create['default'](hasElement['default']);
merge['default'](inDOM, {
enter: function (view) {
// Register the view for event handling. This hash is used by
// Ember.EventDispatcher to dispatch incoming events.
- if (!view.isVirtual) {
+ if (view.tagName !== "") {
view._register();
}
Ember.runInDebug(function () {
- observer.addBeforeObserver(view, 'elementId', function () {
+ observer.addBeforeObserver(view, "elementId", function () {
throw new EmberError['default']("Changing a view's elementId after creation is not allowed");
});
});
},
exit: function (view) {
- if (!this.isVirtual) {
- view._unregister();
- }
+ view._unregister();
},
appendAttr: function (view, attrNode) {
- var _attrNodes = view._attrNodes;
+ var childViews = view.childViews;
- if (!_attrNodes.length) {
- _attrNodes = view._attrNodes = _attrNodes.slice();
+ if (!childViews.length) {
+ childViews = view.childViews = childViews.slice();
}
- _attrNodes.push(attrNode);
+ childViews.push(attrNode);
- attrNode._parentView = view;
+ attrNode.parentView = view;
view.renderer.appendAttrTo(attrNode, view.element, attrNode.attrName);
- view.propertyDidChange('childViews');
+ view.propertyDidChange("childViews");
return attrNode;
}
});
exports['default'] = inDOM;
});
-enifed('ember-views/views/states/pre_render', ['exports', 'ember-views/views/states/default', 'ember-metal/platform/create'], function (exports, _default, create) {
+enifed('ember-views/views/states/pre_render', ['exports', 'ember-views/views/states/default', 'ember-metal/platform/create', 'ember-metal/merge'], function (exports, _default, create, merge) {
- 'use strict';
+ 'use strict';
- var preRender = create['default'](_default['default']);
+ var preRender = create['default'](_default['default']);
- exports['default'] = preRender;
+ merge['default'](preRender, {
+ legacyAttrWillChange: function (view, key) {},
+ legacyAttrDidChange: function (view, key) {},
+ legacyPropertyDidChange: function (view, key) {}
+ });
+ exports['default'] = preRender;
+
});
-enifed('ember-views/views/text_area', ['exports', 'ember-metal/property_get', 'ember-views/views/component', 'ember-views/mixins/text_support', 'ember-metal/mixin'], function (exports, property_get, Component, TextSupport, mixin) {
+enifed('ember-views/views/text_area', ['exports', 'ember-views/views/component', 'ember-views/mixins/text_support'], function (exports, Component, TextSupport) {
'use strict';
-
/**
@module ember
@submodule ember-views
*/
exports['default'] = Component['default'].extend(TextSupport['default'], {
- instrumentDisplay: '{{textarea}}',
+ instrumentDisplay: "{{textarea}}",
- classNames: ['ember-text-area'],
+ classNames: ["ember-text-area"],
tagName: "textarea",
- attributeBindings: ['rows', 'cols', 'name', 'selectionEnd', 'selectionStart', 'wrap', 'lang', 'dir'],
+ attributeBindings: ["rows", "cols", "name", "selectionEnd", "selectionStart", "wrap", "lang", "dir", "value"],
rows: null,
- cols: null,
-
- _updateElementValue: mixin.observer('value', function () {
- // We do this check so cursor position doesn't get affected in IE
- var value = property_get.get(this, 'value');
- var $el = this.$();
- if ($el && value !== $el.val()) {
- $el.val(value);
- }
- }),
-
- init: function () {
- this._super.apply(this, arguments);
- this.on("didInsertElement", this, this._updateElementValue);
- }
+ cols: null
});
});
enifed('ember-views/views/text_field', ['exports', 'ember-metal/core', 'ember-metal/computed', 'ember-metal/environment', 'ember-metal/platform/create', 'ember-views/views/component', 'ember-views/mixins/text_support'], function (exports, Ember, computed, environment, create, Component, TextSupport) {
@@ -40043,11 +41533,11 @@
return type;
}
if (!inputTypeTestElement) {
- inputTypeTestElement = document.createElement('input');
+ inputTypeTestElement = document.createElement("input");
}
try {
inputTypeTestElement.type = type;
} catch (e) {}
@@ -40057,15 +41547,15 @@
function getTypeComputed() {
return computed.computed({
get: function () {
- return 'text';
+ return "text";
},
set: function (key, value) {
- var type = 'text';
+ var type = "text";
if (canSetTypeOfInput(value)) {
type = value;
}
@@ -40091,15 +41581,15 @@
@namespace Ember
@extends Ember.Component
@uses Ember.TextSupport
*/
exports['default'] = Component['default'].extend(TextSupport['default'], {
- instrumentDisplay: '{{input type="text"}}',
+ instrumentDisplay: "{{input type=\"text\"}}",
- classNames: ['ember-text-field'],
+ classNames: ["ember-text-field"],
tagName: "input",
- attributeBindings: ['accept', 'autocomplete', 'autosave', 'dir', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'height', 'inputmode', 'lang', 'list', 'max', 'min', 'multiple', 'name', 'pattern', 'size', 'step', 'type', 'value', 'width'],
+ attributeBindings: ["accept", "autocomplete", "autosave", "dir", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "height", "inputmode", "lang", "list", "max", "min", "multiple", "name", "pattern", "size", "step", "type", "value", "width"],
defaultLayout: null,
/**
The `value` attribute of the input element. As the user inputs text, this
@@ -40152,11 +41642,11 @@
*/
max: null
});
});
-enifed('ember-views/views/view', ['exports', 'ember-metal/core', 'ember-runtime/mixins/evented', 'ember-runtime/system/object', 'ember-metal/error', 'ember-metal/property_get', 'ember-metal/run_loop', 'ember-metal/observer', 'ember-metal/utils', 'ember-metal/computed', 'ember-metal/mixin', 'ember-metal/deprecate_property', 'ember-metal/property_events', 'ember-views/system/jquery', 'ember-views/system/ext', 'ember-views/views/core_view', 'ember-views/mixins/view_stream_support', 'ember-views/mixins/view_keyword_support', 'ember-views/mixins/view_context_support', 'ember-views/mixins/view_child_views_support', 'ember-views/mixins/view_state_support', 'ember-views/mixins/template_rendering_support', 'ember-views/mixins/class_names_support', 'ember-views/mixins/attribute_bindings_support', 'ember-views/mixins/legacy_view_support', 'ember-views/mixins/instrumentation_support', 'ember-views/mixins/visibility_support'], function (exports, Ember, Evented, EmberObject, EmberError, property_get, run, ember_metal__observer, utils, computed, mixin, deprecate_property, property_events, jQuery, __dep13__, CoreView, ViewStreamSupport, ViewKeywordSupport, ViewContextSupport, ViewChildViewsSupport, ViewStateSupport, TemplateRenderingSupport, ClassNamesSupport, AttributeBindingsSupport, LegacyViewSupport, InstrumentationSupport, VisibilitySupport) {
+enifed('ember-views/views/view', ['exports', 'ember-metal/core', 'ember-runtime/mixins/evented', 'ember-runtime/system/object', 'ember-metal/error', 'ember-metal/property_get', 'ember-metal/run_loop', 'ember-metal/observer', 'ember-metal/utils', 'ember-metal/computed', 'ember-metal/mixin', 'ember-metal/deprecate_property', 'ember-views/system/jquery', 'ember-views/system/ext', 'ember-views/views/core_view', 'ember-views/mixins/view_context_support', 'ember-views/mixins/view_child_views_support', 'ember-views/mixins/view_state_support', 'ember-views/mixins/template_rendering_support', 'ember-views/mixins/class_names_support', 'ember-views/mixins/legacy_view_support', 'ember-views/mixins/instrumentation_support', 'ember-views/mixins/visibility_support', 'ember-views/compat/attrs-proxy'], function (exports, Ember, Evented, EmberObject, EmberError, property_get, run, ember_metal__observer, utils, computed, mixin, deprecate_property, jQuery, __dep12__, CoreView, ViewContextSupport, ViewChildViewsSupport, ViewStateSupport, TemplateRenderingSupport, ClassNamesSupport, LegacyViewSupport, InstrumentationSupport, VisibilitySupport, CompatAttrsProxy) {
'use strict';
// Ember.assert, Ember.deprecate, Ember.warn, Ember.TEMPLATES,
// jQuery, Ember.lookup,
@@ -40796,11 +42286,12 @@
@uses Ember.LegacyViewSupport
@uses Ember.InstrumentationSupport
@uses Ember.VisibilitySupport
*/
// jscs:disable validateIndentation
- var View = CoreView['default'].extend(ViewStreamSupport['default'], ViewKeywordSupport['default'], ViewContextSupport['default'], ViewChildViewsSupport['default'], ViewStateSupport['default'], TemplateRenderingSupport['default'], ClassNamesSupport['default'], AttributeBindingsSupport['default'], LegacyViewSupport['default'], InstrumentationSupport['default'], VisibilitySupport['default'], {
+ var View = CoreView['default'].extend(ViewContextSupport['default'], ViewChildViewsSupport['default'], ViewStateSupport['default'], TemplateRenderingSupport['default'], ClassNamesSupport['default'], LegacyViewSupport['default'], InstrumentationSupport['default'], VisibilitySupport['default'], CompatAttrsProxy['default'], {
+ concatenatedProperties: ["attributeBindings"],
/**
@property isView
@type Boolean
@default true
@@ -40840,16 +42331,16 @@
the template yourself.
@property template
@type Function
*/
- template: computed.computed('templateName', {
+ template: computed.computed("templateName", {
get: function () {
- var templateName = property_get.get(this, 'templateName');
- var template = this.templateForName(templateName, 'template');
+ var templateName = property_get.get(this, "templateName");
+ var template = this.templateForName(templateName, "template");
Ember['default'].assert("You specified the templateName " + templateName + " for " + this + ", but it did not exist.", !templateName || !!template);
- return template || property_get.get(this, 'defaultTemplate');
+ return template || property_get.get(this, "defaultTemplate");
},
set: function (key, value) {
if (value !== undefined) {
return value;
}
@@ -40867,156 +42358,100 @@
the rendering of the contents of the wrapper to the `template` property
on a subclass.
@property layout
@type Function
*/
- layout: computed.computed('layoutName', {
+ layout: computed.computed("layoutName", {
get: function (key) {
- var layoutName = property_get.get(this, 'layoutName');
- var layout = this.templateForName(layoutName, 'layout');
+ var layoutName = property_get.get(this, "layoutName");
+ var layout = this.templateForName(layoutName, "layout");
Ember['default'].assert("You specified the layoutName " + layoutName + " for " + this + ", but it did not exist.", !layoutName || !!layout);
- return layout || property_get.get(this, 'defaultLayout');
+ return layout || property_get.get(this, "defaultLayout");
},
set: function (key, value) {
return value;
}
}),
_yield: function (context, options, morph) {
- var template = property_get.get(this, 'template');
+ var template = property_get.get(this, "template");
if (template) {
- if (template.isHTMLBars) {
- return template.render(context, options, morph.contextualElement);
- } else {
- return template(context, options);
- }
+ return template.render(context, options, { contextualElement: morph.contextualElement }).fragment;
}
},
_blockArguments: EMPTY_ARRAY,
templateForName: function (name, type) {
if (!name) {
return;
}
- Ember['default'].assert("templateNames are not allowed to contain periods: " + name, name.indexOf('.') === -1);
+ Ember['default'].assert("templateNames are not allowed to contain periods: " + name, name.indexOf(".") === -1);
if (!this.container) {
- throw new EmberError['default']('Container was not found when looking up a views template. ' + 'This is most likely due to manually instantiating an Ember.View. ' + 'See: http://git.io/EKPpnA');
+ throw new EmberError['default']("Container was not found when looking up a views template. " + "This is most likely due to manually instantiating an Ember.View. " + "See: http://git.io/EKPpnA");
}
- return this.container.lookup('template:' + name);
+ return this.container.lookup("template:" + name);
},
/**
If a value that affects template rendering changes, the view should be
re-rendered to reflect the new value.
@method _contextDidChange
@private
*/
- _contextDidChange: mixin.observer('context', function () {
+ _contextDidChange: mixin.observer("context", function () {
this.rerender();
}),
- // When it's a virtual view, we need to notify the parent that their
- // childViews will change.
- _childViewsWillChange: mixin.beforeObserver('childViews', function () {
- if (this.isVirtual) {
- var parentView = property_get.get(this, 'parentView');
- if (parentView) {
- property_events.propertyWillChange(parentView, 'childViews');
- }
- }
- }),
-
- // When it's a virtual view, we need to notify the parent that their
- // childViews did change.
- _childViewsDidChange: mixin.observer('childViews', function () {
- if (this.isVirtual) {
- var parentView = property_get.get(this, 'parentView');
- if (parentView) {
- property_events.propertyDidChange(parentView, 'childViews');
- }
- }
- }),
-
/**
Return the nearest ancestor that is an instance of the provided
class or mixin.
@method nearestOfType
@param {Class,Mixin} klass Subclass of Ember.View (or Ember.View itself),
or an instance of Ember.Mixin.
@return Ember.View
*/
nearestOfType: function (klass) {
- var view = property_get.get(this, 'parentView');
+ var view = property_get.get(this, "parentView");
var isOfType = klass instanceof mixin.Mixin ? function (view) {
return klass.detect(view);
} : function (view) {
return klass.detect(view.constructor);
};
while (view) {
if (isOfType(view)) {
return view;
}
- view = property_get.get(view, 'parentView');
+ view = property_get.get(view, "parentView");
}
},
/**
Return the nearest ancestor that has a given property.
@method nearestWithProperty
@param {String} property A property name
@return Ember.View
*/
nearestWithProperty: function (property) {
- var view = property_get.get(this, 'parentView');
+ var view = property_get.get(this, "parentView");
while (view) {
if (property in view) {
return view;
}
- view = property_get.get(view, 'parentView');
+ view = property_get.get(view, "parentView");
}
},
/**
- When the parent view changes, recursively invalidate `controller`
- @method _parentViewDidChange
- @private
- */
- _parentViewDidChange: mixin.observer('_parentView', function () {
- if (this.isDestroying) {
- return;
- }
-
- this._setupKeywords();
- this.trigger('parentViewDidChange');
-
- if (property_get.get(this, 'parentView.controller') && !property_get.get(this, 'controller')) {
- this.notifyPropertyChange('controller');
- }
- }),
-
- _controllerDidChange: mixin.observer('controller', function () {
- if (this.isDestroying) {
- return;
- }
-
- this.rerender();
-
- this.forEachChildView(function (view) {
- view.propertyDidChange('controller');
- });
- }),
-
- /**
Renders the view again. This will work regardless of whether the
view is already in the DOM or not. If the view is in the DOM, the
rendering process will be deferred to give bindings a chance
to synchronize.
If children were added during the rendering process using `appendChild`,
@@ -41039,11 +42474,11 @@
_rerender: function () {
if (this.isDestroying || this.isDestroyed) {
return;
}
- this._renderer.renderTree(this, this._parentView);
+ this._renderer.renderTree(this, this.parentView);
},
/**
Given a property name, returns a dasherized version of that
property name if the property evaluates to a non-falsy value.
@@ -41077,16 +42512,16 @@
@method $
@param {String} [selector] a jQuery-compatible selector string
@return {jQuery} the jQuery object for the DOM node
*/
$: function (sel) {
- Ember['default'].assert('You cannot access this.$() on a component with `tagName: \'\'` specified.', this.tagName !== '');
+ Ember['default'].assert("You cannot access this.$() on a component with `tagName: ''` specified.", this.tagName !== "");
return this.currentState.$(this, sel);
},
forEachChildView: function (callback) {
- var childViews = this._childViews;
+ var childViews = this.childViews;
if (!childViews) {
return this;
}
@@ -41119,11 +42554,11 @@
*/
appendTo: function (selector) {
var target = jQuery['default'](selector);
Ember['default'].assert("You tried to append to (" + selector + ") but that isn't in the DOM", target.length > 0);
- Ember['default'].assert("You cannot append to an existing Ember.View. Consider using Ember.ContainerView instead.", !target.is('.ember-view') && !target.parents().is('.ember-view'));
+ Ember['default'].assert("You cannot append to an existing Ember.View. Consider using Ember.ContainerView instead.", !target.is(".ember-view") && !target.parents().is(".ember-view"));
this.renderer.appendTo(this, target[0]);
return this;
},
@@ -41161,11 +42596,11 @@
@method renderToElement
@param {String} tagName The tag of the element to create and render into. Defaults to "body".
@return {HTMLBodyElement} element
*/
renderToElement: function (tagName) {
- tagName = tagName || 'body';
+ tagName = tagName || "body";
var element = this.renderer._dom.createElement(tagName);
this.renderer.appendTo(this, element);
return element;
@@ -41184,11 +42619,11 @@
*/
replaceIn: function (selector) {
var target = jQuery['default'](selector);
Ember['default'].assert("You tried to replace in (" + selector + ") but that isn't in the DOM", target.length > 0);
- Ember['default'].assert("You cannot replace an existing Ember.View. Consider using Ember.ContainerView instead.", !target.is('.ember-view') && !target.parents().is('.ember-view'));
+ Ember['default'].assert("You cannot replace an existing Ember.View. Consider using Ember.ContainerView instead.", !target.is(".ember-view") && !target.parents().is(".ember-view"));
this.renderer.replaceIn(this, target[0]);
return this;
},
@@ -41222,10 +42657,13 @@
// In the interim, we will just re-render if that happens. It is more
// important than elements get garbage collected.
if (!this.removedFromDOM) {
this.destroyElement();
}
+
+ // Set flag to avoid future renders
+ this._willInsert = false;
},
/**
The HTML `id` of the view's element in the DOM. You can provide this
value yourself but it must be unique (just as in HTML):
@@ -41277,12 +42715,11 @@
createElement: function () {
if (this.element) {
return this;
}
- this._didCreateElementWithoutMorph = true;
- this.renderer.renderTree(this);
+ this.renderer.createElement(this);
return this;
},
/**
@@ -41341,34 +42778,10 @@
Called when the parentView property has changed.
@event parentViewDidChange
*/
parentViewDidChange: K,
- applyAttributesToBuffer: function (buffer) {
- // Creates observers for all registered class name and attribute bindings,
- // then adds them to the element.
-
- this._applyClassNameBindings();
-
- // Pass the render buffer so the method can apply attributes directly.
- // This isn't needed for class name bindings because they use the
- // existing classNames infrastructure.
- this._applyAttributeBindings(buffer);
-
- buffer.setClasses(this.classNames);
- buffer.id(this.elementId);
-
- var role = property_get.get(this, 'ariaRole');
- if (role) {
- buffer.attr('role', role);
- }
-
- if (property_get.get(this, 'isVisible') === false) {
- buffer.style('display', 'none');
- }
- },
-
// ..........................................................
// STANDARD RENDER PROPERTIES
//
/**
@@ -41383,10 +42796,17 @@
// We leave this null by default so we can tell the difference between
// the default case and a user-specified tag.
tagName: null,
+ /*
+ Used to specify a default tagName that can be overridden when extending
+ or invoking from a template.
+ @property _defaultTagName
+ @private
+ */
+
/**
The WAI-ARIA role of the control represented by this view. For example, a
button may have a role of type 'button', or a pane may have a role of
type 'alertdialog'. This property is used by assistive software to help
visually challenged users navigate rich web applications.
@@ -41396,10 +42816,45 @@
@type String
@default null
*/
ariaRole: null,
+ /**
+ Normally, Ember's component model is "write-only". The component takes a
+ bunch of attributes that it got passed in, and uses them to render its
+ template.
+ One nice thing about this model is that if you try to set a value to the
+ same thing as last time, Ember (through HTMLBars) will avoid doing any
+ work on the DOM.
+ This is not just a performance optimization. If an attribute has not
+ changed, it is important not to clobber the element's "hidden state".
+ For example, if you set an input's `value` to the same value as before,
+ it will clobber selection state and cursor position. In other words,
+ setting an attribute is not **always** idempotent.
+ This method provides a way to read an element's attribute and also
+ update the last value Ember knows about at the same time. This makes
+ setting an attribute idempotent.
+ In particular, what this means is that if you get an `<input>` element's
+ `value` attribute and then re-render the template with the same value,
+ it will avoid clobbering the cursor and selection position.
+ Since most attribute sets are idempotent in the browser, you typically
+ can get away with reading attributes using jQuery, but the most reliable
+ way to do so is through this method.
+ @method readDOMAttr
+ @param {String} name the name of the attribute
+ @return String
+ */
+ readDOMAttr: function (name) {
+ var attr = this._renderNode.childNodes.filter(function (node) {
+ return node.attrName === name;
+ })[0];
+ if (!attr) {
+ return null;
+ }
+ return attr.getContent();
+ },
+
// .......................................................
// CORE DISPLAY METHODS
//
/**
@@ -41409,14 +42864,16 @@
dispatch
@method init
@private
*/
init: function () {
- if (!this.isVirtual && !this.elementId) {
+ if (!this.elementId) {
this.elementId = utils.guidFor(this);
}
+ this.scheduledRevalidation = false;
+
this._super.apply(this, arguments);
if (!this._viewRegistry) {
this._viewRegistry = View.views;
}
@@ -41424,22 +42881,48 @@
__defineNonEnumerable: function (property) {
this[property.name] = property.descriptor.value;
},
- appendAttr: function (node) {
- return this.currentState.appendAttr(this, node);
+ revalidate: function () {
+ this.renderer.revalidateTopLevelView(this);
+ this.scheduledRevalidation = false;
},
+ scheduleRevalidate: function (node, label, manualRerender) {
+ if (node && !this._dispatching && node.guid in this.env.renderedNodes) {
+ if (manualRerender) {
+ Ember['default'].deprecate("You manually rerendered " + label + " (a parent component) from a child component during the rendering process. This rarely worked in Ember 1.x and will be removed in Ember 2.0");
+ } else {
+ Ember['default'].deprecate("You modified " + label + " twice in a single render. This was unreliable in Ember 1.x and will be removed in Ember 2.0");
+ }
+ run['default'].scheduleOnce("render", this, this.revalidate);
+ return;
+ }
+
+ Ember['default'].deprecate("A property of " + this + " was modified inside the " + this._dispatching + " hook. You should never change properties on components, services or models during " + this._dispatching + " because it causes significant performance degradation.", !this._dispatching);
+
+ if (!this.scheduledRevalidation || this._dispatching) {
+ this.scheduledRevalidation = true;
+ run['default'].scheduleOnce("render", this, this.revalidate);
+ }
+ },
+
+ appendAttr: function (node, buffer) {
+ return this.currentState.appendAttr(this, node, buffer);
+ },
+
+ templateRenderer: null,
+
/**
Removes the view from its `parentView`, if one is found. Otherwise
does nothing.
@method removeFromParent
@return {Ember.View} receiver
*/
removeFromParent: function () {
- var parent = this._parentView;
+ var parent = this.parentView;
// Remove DOM element from parent
this.remove();
if (parent) {
@@ -41455,22 +42938,27 @@
memory manager.
@method destroy
*/
destroy: function () {
// get parentView before calling super because it'll be destroyed
- var nonVirtualParentView = property_get.get(this, 'parentView');
+ var parentView = this.parentView;
var viewName = this.viewName;
if (!this._super.apply(this, arguments)) {
return;
}
// remove from non-virtual parent view if viewName was specified
- if (viewName && nonVirtualParentView) {
- nonVirtualParentView.set(viewName, null);
+ if (viewName && parentView) {
+ parentView.set(viewName, null);
}
+ // Destroy HTMLbars template
+ if (this.lastResult) {
+ this.lastResult.destroy();
+ }
+
return this;
},
// .......................................................
// EVENT HANDLING
@@ -41510,43 +42998,43 @@
_unregister: function () {
delete this._viewRegistry[this.elementId];
},
registerObserver: function (root, path, target, observer) {
- if (!observer && 'function' === typeof target) {
+ if (!observer && "function" === typeof target) {
observer = target;
target = null;
}
- if (!root || typeof root !== 'object') {
+ if (!root || typeof root !== "object") {
return;
}
var scheduledObserver = this._wrapAsScheduled(observer);
ember_metal__observer.addObserver(root, path, target, scheduledObserver);
- this.one('willClearRender', function () {
+ this.one("willClearRender", function () {
ember_metal__observer.removeObserver(root, path, target, scheduledObserver);
});
},
_wrapAsScheduled: function (fn) {
var view = this;
var stateCheckedFn = function () {
view.currentState.invokeObserver(this, fn);
};
var scheduledFn = function () {
- run['default'].scheduleOnce('render', this, stateCheckedFn);
+ run['default'].scheduleOnce("render", this, stateCheckedFn);
};
return scheduledFn;
}
});
// jscs:enable validateIndentation
- deprecate_property.deprecateProperty(View.prototype, 'state', '_state');
- deprecate_property.deprecateProperty(View.prototype, 'states', '_states');
+ deprecate_property.deprecateProperty(View.prototype, "state", "_state");
+ deprecate_property.deprecateProperty(View.prototype, "states", "_states");
/*
Describe how the specified actions should behave in the various
states that a view can exist in. Possible states:
@@ -41574,19 +43062,19 @@
// are done on the DOM element.
var mutation = EmberObject['default'].extend(Evented['default']).create();
// TODO MOVE TO RENDERER HOOKS
View.addMutationListener = function (callback) {
- mutation.on('change', callback);
+ mutation.on("change", callback);
};
View.removeMutationListener = function (callback) {
- mutation.off('change', callback);
+ mutation.off("change", callback);
};
View.notifyMutationListeners = function () {
- mutation.trigger('change');
+ mutation.trigger("change");
};
/**
Global views hash
@@ -41603,1455 +43091,3251 @@
// method.
View.childViewsProperty = ViewChildViewsSupport.childViewsProperty;
exports['default'] = View;
- exports.ViewKeywordSupport = ViewKeywordSupport['default'];
- exports.ViewStreamSupport = ViewStreamSupport['default'];
exports.ViewContextSupport = ViewContextSupport['default'];
exports.ViewChildViewsSupport = ViewChildViewsSupport['default'];
exports.ViewStateSupport = ViewStateSupport['default'];
exports.TemplateRenderingSupport = TemplateRenderingSupport['default'];
exports.ClassNamesSupport = ClassNamesSupport['default'];
- exports.AttributeBindingsSupport = AttributeBindingsSupport['default'];
});
-enifed('ember-views/views/with_view', ['exports', 'ember-metal/property_set', 'ember-views/views/metamorph_view', 'ember-views/mixins/normalized_rerender_if_needed', 'ember-metal/run_loop', 'ember-htmlbars/system/render-view'], function (exports, property_set, _MetamorphView, NormalizedRerenderIfNeededSupport, run, renderView) {
+enifed('ember', ['ember-metal', 'ember-runtime', 'ember-views', 'ember-routing', 'ember-application', 'ember-extension-support', 'ember-htmlbars', 'ember-routing-htmlbars', 'ember-routing-views', 'ember-metal/environment', 'ember-runtime/system/lazy_load'], function (__dep0__, __dep1__, __dep2__, __dep3__, __dep4__, __dep5__, __dep6__, __dep7__, __dep8__, environment, lazy_load) {
'use strict';
+ // require the main entry points for each of these packages
+ // this is so that the global exports occur properly
+ if (Ember.__loader.registry["ember-template-compiler"]) {
+ requireModule("ember-template-compiler");
+ }
+
+ // do this to ensure that Ember.Test is defined properly on the global
+ // if it is present.
+ if (Ember.__loader.registry["ember-testing"]) {
+ requireModule("ember-testing");
+ }
+
+ lazy_load.runLoadHooks("Ember");
+
/**
+ Ember
+
@module ember
- @submodule ember-views
*/
- exports['default'] = _MetamorphView['default'].extend(NormalizedRerenderIfNeededSupport['default'], {
- init: function () {
- this._super.apply(this, arguments);
+ Ember.deprecate("Usage of Ember is deprecated for Internet Explorer 6 and 7, support will be removed in the next major version.", !environment['default'].userAgent.match(/MSIE [67]/));
- var self = this;
+});
+enifed('htmlbars-runtime', ['exports', './htmlbars-runtime/hooks', './htmlbars-runtime/render', '../htmlbars-util/morph-utils', '../htmlbars-util/template-utils', './htmlbars-runtime/expression-visitor', 'htmlbars-runtime/hooks'], function (exports, hooks, render, morph_utils, template_utils, expression_visitor, htmlbars_runtime__hooks) {
- this.withValue.subscribe(this._wrapAsScheduled(function () {
- run['default'].scheduleOnce('render', self, 'rerenderIfNeeded');
- }));
+ 'use strict';
- var controllerName = this.controllerName;
- if (controllerName) {
- var controllerFactory = this.container.lookupFactory('controller:' + controllerName);
- var controller = controllerFactory.create({
- parentController: this.previousContext,
- target: this.previousContext
- });
+ var internal = {
+ blockFor: template_utils.blockFor,
+ manualElement: render.manualElement,
+ hostBlock: htmlbars_runtime__hooks.hostBlock,
+ continueBlock: htmlbars_runtime__hooks.continueBlock,
+ hostYieldWithShadowTemplate: htmlbars_runtime__hooks.hostYieldWithShadowTemplate,
+ visitChildren: morph_utils.visitChildren,
+ validateChildMorphs: expression_visitor.validateChildMorphs,
+ clearMorph: template_utils.clearMorph
+ };
- this._generatedController = controller;
+ exports.hooks = hooks['default'];
+ exports.render = render['default'];
+ exports.internal = internal;
- if (this.preserveContext) {
- this._blockArguments = [controller];
- this.withValue.subscribe(function (modelStream) {
- property_set.set(controller, 'model', modelStream.value());
- });
- } else {
- property_set.set(this, 'controller', controller);
- }
+});
+enifed('htmlbars-runtime/expression-visitor', ['exports', '../htmlbars-util/object-utils', '../htmlbars-util/morph-utils'], function (exports, object_utils, morph_utils) {
- property_set.set(controller, 'model', this.withValue.value());
- } else {
- if (this.preserveContext) {
- this._blockArguments = [this.withValue];
- }
+ 'use strict';
+
+ var base = {
+ acceptExpression: function (node, morph, env, scope) {
+ var ret = { value: null };
+
+ // Primitive literals are unambiguously non-array representations of
+ // themselves.
+ if (typeof node !== "object" || node === null) {
+ ret.value = node;
+ return ret;
}
+
+ switch (node[0]) {
+ // can be used by manualElement
+ case "value":
+ ret.value = node[1];break;
+ case "get":
+ ret.value = this.get(node, morph, env, scope);break;
+ case "subexpr":
+ ret.value = this.subexpr(node, morph, env, scope);break;
+ case "concat":
+ ret.value = this.concat(node, morph, env, scope);break;
+ }
+
+ return ret;
},
- normalizedValue: function () {
- return this.withValue.value();
+ acceptParamsAndHash: function (env, scope, morph, path, params, hash) {
+ params = params && this.acceptParams(params, morph, env, scope);
+ hash = hash && this.acceptHash(hash, morph, env, scope);
+
+ morph_utils.linkParams(env, scope, morph, path, params, hash);
+ return [params, hash];
},
- render: function (buffer) {
- var withValue = this.normalizedValue();
- this._lastNormalizedValue = withValue;
+ acceptParams: function (nodes, morph, env, scope) {
+ if (morph.linkedParams) {
+ return morph.linkedParams.params;
+ }
- if (!this.preserveContext && !this.controllerName) {
- property_set.set(this, '_context', withValue);
+ var arr = new Array(nodes.length);
+
+ for (var i = 0, l = nodes.length; i < l; i++) {
+ arr[i] = this.acceptExpression(nodes[i], morph, env, scope, null, null).value;
}
- var template = withValue ? this.mainTemplate : this.inverseTemplate;
- renderView['default'](this, buffer, template);
+ return arr;
},
- willDestroy: function () {
- this._super.apply(this, arguments);
+ acceptHash: function (pairs, morph, env, scope) {
+ if (morph.linkedParams) {
+ return morph.linkedParams.hash;
+ }
- if (this._generatedController) {
- this._generatedController.destroy();
+ var object = {};
+
+ for (var i = 0, l = pairs.length; i < l; i += 2) {
+ object[pairs[i]] = this.acceptExpression(pairs[i + 1], morph, env, scope, null, null).value;
}
+
+ return object;
+ },
+
+ // [ 'get', path ]
+ get: function (node, morph, env, scope) {
+ return env.hooks.get(env, scope, node[1]);
+ },
+
+ // [ 'subexpr', path, params, hash ]
+ subexpr: function (node, morph, env, scope) {
+ var path = node[1],
+ params = node[2],
+ hash = node[3];
+ return env.hooks.subexpr(env, scope, path, this.acceptParams(params, morph, env, scope), this.acceptHash(hash, morph, env, scope));
+ },
+
+ // [ 'concat', parts ]
+ concat: function (node, morph, env, scope) {
+ return env.hooks.concat(env, this.acceptParams(node[1], morph, env, scope));
}
+ };
+
+ var AlwaysDirtyVisitor = object_utils.merge(object_utils.createObject(base), {
+ // [ 'block', path, params, hash, templateId, inverseId ]
+ block: function (node, morph, env, scope, template, visitor) {
+ var path = node[1],
+ params = node[2],
+ hash = node[3],
+ templateId = node[4],
+ inverseId = node[5];
+ var paramsAndHash = this.acceptParamsAndHash(env, scope, morph, path, params, hash);
+
+ morph.isDirty = morph.isSubtreeDirty = false;
+ env.hooks.block(morph, env, scope, path, paramsAndHash[0], paramsAndHash[1], templateId === null ? null : template.templates[templateId], inverseId === null ? null : template.templates[inverseId], visitor);
+ },
+
+ // [ 'inline', path, params, hash ]
+ inline: function (node, morph, env, scope, visitor) {
+ var path = node[1],
+ params = node[2],
+ hash = node[3];
+ var paramsAndHash = this.acceptParamsAndHash(env, scope, morph, path, params, hash);
+
+ morph.isDirty = morph.isSubtreeDirty = false;
+ env.hooks.inline(morph, env, scope, path, paramsAndHash[0], paramsAndHash[1], visitor);
+ },
+
+ // [ 'content', path ]
+ content: function (node, morph, env, scope, visitor) {
+ var path = node[1];
+
+ morph.isDirty = morph.isSubtreeDirty = false;
+
+ if (isHelper(env, scope, path)) {
+ env.hooks.inline(morph, env, scope, path, [], {}, visitor);
+ return;
+ }
+
+ var params;
+ if (morph.linkedParams) {
+ params = morph.linkedParams.params;
+ } else {
+ params = [env.hooks.get(env, scope, path)];
+ }
+
+ morph_utils.linkParams(env, scope, morph, "@range", params, null);
+ env.hooks.range(morph, env, scope, path, params[0], visitor);
+ },
+
+ // [ 'element', path, params, hash ]
+ element: function (node, morph, env, scope, visitor) {
+ var path = node[1],
+ params = node[2],
+ hash = node[3];
+ var paramsAndHash = this.acceptParamsAndHash(env, scope, morph, path, params, hash);
+
+ morph.isDirty = morph.isSubtreeDirty = false;
+ env.hooks.element(morph, env, scope, path, paramsAndHash[0], paramsAndHash[1], visitor);
+ },
+
+ // [ 'attribute', name, value ]
+ attribute: function (node, morph, env, scope) {
+ var name = node[1],
+ value = node[2];
+ var paramsAndHash = this.acceptParamsAndHash(env, scope, morph, "@attribute", [value], null);
+
+ morph.isDirty = morph.isSubtreeDirty = false;
+ env.hooks.attribute(morph, env, scope, name, paramsAndHash[0][0]);
+ },
+
+ // [ 'component', path, attrs, templateId, inverseId ]
+ component: function (node, morph, env, scope, template, visitor) {
+ var path = node[1],
+ attrs = node[2],
+ templateId = node[3],
+ inverseId = node[4];
+ var paramsAndHash = this.acceptParamsAndHash(env, scope, morph, path, [], attrs);
+ var templates = {
+ "default": template.templates[templateId],
+ inverse: template.templates[inverseId]
+ };
+
+ morph.isDirty = morph.isSubtreeDirty = false;
+ env.hooks.component(morph, env, scope, path, paramsAndHash[0], paramsAndHash[1], templates, visitor);
+ }
});
-});
-enifed('ember', ['ember-metal', 'ember-runtime', 'ember-views', 'ember-routing', 'ember-application', 'ember-extension-support', 'ember-htmlbars', 'ember-routing-htmlbars', 'ember-routing-views', 'ember-metal/environment', 'ember-runtime/system/lazy_load'], function (__dep0__, __dep1__, __dep2__, __dep3__, __dep4__, __dep5__, __dep6__, __dep7__, __dep8__, environment, lazy_load) {
+ exports['default'] = object_utils.merge(object_utils.createObject(base), {
+ // [ 'block', path, params, hash, templateId, inverseId ]
+ block: function (node, morph, env, scope, template, visitor) {
+ dirtyCheck(env, morph, visitor, function (visitor) {
+ AlwaysDirtyVisitor.block(node, morph, env, scope, template, visitor);
+ });
+ },
- 'use strict';
+ // [ 'inline', path, params, hash ]
+ inline: function (node, morph, env, scope, visitor) {
+ dirtyCheck(env, morph, visitor, function (visitor) {
+ AlwaysDirtyVisitor.inline(node, morph, env, scope, visitor);
+ });
+ },
- // require the main entry points for each of these packages
- // this is so that the global exports occur properly
- if (Ember.__loader.registry['ember-template-compiler']) {
- requireModule('ember-template-compiler');
+ // [ 'content', path ]
+ content: function (node, morph, env, scope, visitor) {
+ dirtyCheck(env, morph, visitor, function (visitor) {
+ AlwaysDirtyVisitor.content(node, morph, env, scope, visitor);
+ });
+ },
+
+ // [ 'element', path, params, hash ]
+ element: function (node, morph, env, scope, template, visitor) {
+ dirtyCheck(env, morph, visitor, function (visitor) {
+ AlwaysDirtyVisitor.element(node, morph, env, scope, template, visitor);
+ });
+ },
+
+ // [ 'attribute', name, value ]
+ attribute: function (node, morph, env, scope, template) {
+ dirtyCheck(env, morph, null, function () {
+ AlwaysDirtyVisitor.attribute(node, morph, env, scope, template);
+ });
+ },
+
+ // [ 'component', path, attrs, templateId ]
+ component: function (node, morph, env, scope, template, visitor) {
+ dirtyCheck(env, morph, visitor, function (visitor) {
+ AlwaysDirtyVisitor.component(node, morph, env, scope, template, visitor);
+ });
+ } });
+
+ function dirtyCheck(env, morph, visitor, callback) {
+ var isDirty = morph.isDirty;
+ var isSubtreeDirty = morph.isSubtreeDirty;
+
+ if (isSubtreeDirty) {
+ visitor = AlwaysDirtyVisitor;
+ }
+
+ if (isDirty || isSubtreeDirty) {
+ callback(visitor);
+ } else {
+ if (morph.lastEnv) {
+ env = object_utils.merge(object_utils.shallowCopy(morph.lastEnv), env);
+ }
+ morph_utils.validateChildMorphs(env, morph, visitor);
+ }
}
- // do this to ensure that Ember.Test is defined properly on the global
- // if it is present.
- if (Ember.__loader.registry['ember-testing']) {
- requireModule('ember-testing');
+ function isHelper(env, scope, path) {
+ return env.hooks.keywords[path] !== undefined || env.hooks.hasHelper(env, scope, path);
}
- lazy_load.runLoadHooks('Ember');
+ exports.AlwaysDirtyVisitor = AlwaysDirtyVisitor;
+});
+enifed('htmlbars-runtime/hooks', ['exports', './render', '../morph-range/morph-list', '../htmlbars-util/object-utils', '../htmlbars-util/morph-utils', '../htmlbars-util/template-utils'], function (exports, render, MorphList, object_utils, morph_utils, template_utils) {
+
+ 'use strict';
+
+ exports.wrap = wrap;
+ exports.wrapForHelper = wrapForHelper;
+ exports.hostYieldWithShadowTemplate = hostYieldWithShadowTemplate;
+ exports.createScope = createScope;
+ exports.createFreshScope = createFreshScope;
+ exports.bindShadowScope = bindShadowScope;
+ exports.createChildScope = createChildScope;
+ exports.bindSelf = bindSelf;
+ exports.updateSelf = updateSelf;
+ exports.bindLocal = bindLocal;
+ exports.updateLocal = updateLocal;
+ exports.bindBlock = bindBlock;
+ exports.block = block;
+ exports.continueBlock = continueBlock;
+ exports.hostBlock = hostBlock;
+ exports.handleRedirect = handleRedirect;
+ exports.handleKeyword = handleKeyword;
+ exports.linkRenderNode = linkRenderNode;
+ exports.inline = inline;
+ exports.keyword = keyword;
+ exports.invokeHelper = invokeHelper;
+ exports.classify = classify;
+ exports.partial = partial;
+ exports.range = range;
+ exports.element = element;
+ exports.attribute = attribute;
+ exports.subexpr = subexpr;
+ exports.get = get;
+ exports.getRoot = getRoot;
+ exports.getChild = getChild;
+ exports.getValue = getValue;
+ exports.getCellOrValue = getCellOrValue;
+ exports.component = component;
+ exports.concat = concat;
+ exports.hasHelper = hasHelper;
+ exports.lookupHelper = lookupHelper;
+ exports.bindScope = bindScope;
+ exports.updateScope = updateScope;
+
/**
- Ember
+ HTMLBars delegates the runtime behavior of a template to
+ hooks provided by the host environment. These hooks explain
+ the lexical environment of a Handlebars template, the internal
+ representation of references, and the interaction between an
+ HTMLBars template and the DOM it is managing.
- @module ember
+ While HTMLBars host hooks have access to all of this internal
+ machinery, templates and helpers have access to the abstraction
+ provided by the host hooks.
+
+ ## The Lexical Environment
+
+ The default lexical environment of an HTMLBars template includes:
+
+ * Any local variables, provided by *block arguments*
+ * The current value of `self`
+
+ ## Simple Nesting
+
+ Let's look at a simple template with a nested block:
+
+ ```hbs
+ <h1>{{title}}</h1>
+
+ {{#if author}}
+ <p class="byline">{{author}}</p>
+ {{/if}}
+ ```
+
+ In this case, the lexical environment at the top-level of the
+ template does not change inside of the `if` block. This is
+ achieved via an implementation of `if` that looks like this:
+
+ ```js
+ registerHelper('if', function(params) {
+ if (!!params[0]) {
+ return this.yield();
+ }
+ });
+ ```
+
+ A call to `this.yield` invokes the child template using the
+ current lexical environment.
+
+ ## Block Arguments
+
+ It is possible for nested blocks to introduce new local
+ variables:
+
+ ```hbs
+ {{#count-calls as |i|}}
+ <h1>{{title}}</h1>
+ <p>Called {{i}} times</p>
+ {{/count}}
+ ```
+
+ In this example, the child block inherits its surrounding
+ lexical environment, but augments it with a single new
+ variable binding.
+
+ The implementation of `count-calls` supplies the value of
+ `i`, but does not otherwise alter the environment:
+
+ ```js
+ var count = 0;
+ registerHelper('count-calls', function() {
+ return this.yield([ ++count ]);
+ });
+ ```
*/
- Ember.deprecate('Usage of Ember is deprecated for Internet Explorer 6 and 7, support will be removed in the next major version.', !environment['default'].userAgent.match(/MSIE [67]/));
+ function wrap(template) {
+ if (template === null) {
+ return null;
+ }
-});
-enifed("htmlbars-util",
- ["./htmlbars-util/safe-string","./htmlbars-util/handlebars/utils","./htmlbars-util/namespaces","exports"],
- function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
- "use strict";
- var SafeString = __dependency1__["default"];
- var escapeExpression = __dependency2__.escapeExpression;
- var getAttrNamespace = __dependency3__.getAttrNamespace;
+ return {
+ meta: template.meta,
+ arity: template.arity,
+ raw: template,
+ render: function (self, env, options, blockArguments) {
+ var scope = env.hooks.createFreshScope();
- __exports__.SafeString = SafeString;
- __exports__.escapeExpression = escapeExpression;
- __exports__.getAttrNamespace = getAttrNamespace;
- });
-enifed("htmlbars-util/array-utils",
- ["exports"],
- function(__exports__) {
- "use strict";
- function forEach(array, callback, binding) {
- var i, l;
- if (binding === undefined) {
- for (i = 0, l = array.length; i < l; i++) {
- callback(array[i], i, array);
- }
+ options = options || {};
+ options.self = self;
+ options.blockArguments = blockArguments;
+
+ return render['default'](template, env, scope, options);
+ }
+ };
+ }
+
+ function wrapForHelper(template, env, scope, morph, renderState, visitor) {
+ if (!template) {
+ return {
+ yieldIn: yieldInShadowTemplate(null, env, scope, morph, renderState, visitor)
+ };
+ }
+
+ var yieldArgs = yieldTemplate(template, env, scope, morph, renderState, visitor);
+
+ return {
+ meta: template.meta,
+ arity: template.arity,
+ yield: yieldArgs,
+ yieldItem: yieldItem(template, env, scope, morph, renderState, visitor),
+ yieldIn: yieldInShadowTemplate(template, env, scope, morph, renderState, visitor),
+ raw: template,
+
+ render: function (self, blockArguments) {
+ yieldArgs(blockArguments, self);
+ }
+ };
+ }
+
+ function yieldTemplate(template, env, parentScope, morph, renderState, visitor) {
+ return function (blockArguments, self) {
+ renderState.clearMorph = null;
+
+ if (morph.morphList) {
+ renderState.morphList = morph.morphList.firstChildMorph;
+ renderState.morphList = null;
+ }
+
+ var scope = parentScope;
+
+ if (morph.lastYielded && isStableTemplate(template, morph.lastYielded)) {
+ return morph.lastResult.revalidateWith(env, undefined, self, blockArguments, visitor);
+ }
+
+ // Check to make sure that we actually **need** a new scope, and can't
+ // share the parent scope. Note that we need to move this check into
+ // a host hook, because the host's notion of scope may require a new
+ // scope in more cases than the ones we can determine statically.
+ if (self !== undefined || parentScope === null || template.arity) {
+ scope = env.hooks.createChildScope(parentScope);
+ }
+
+ morph.lastYielded = { self: self, template: template, shadowTemplate: null };
+
+ // Render the template that was selected by the helper
+ render['default'](template, env, scope, { renderNode: morph, self: self, blockArguments: blockArguments });
+ };
+ }
+
+ function yieldItem(template, env, parentScope, morph, renderState, visitor) {
+ var currentMorph = null;
+ var morphList = morph.morphList;
+ if (morphList) {
+ currentMorph = morphList.firstChildMorph;
+ renderState.morphListStart = currentMorph;
+ }
+
+ return function (key, blockArguments, self) {
+ if (typeof key !== "string") {
+ throw new Error("You must provide a string key when calling `yieldItem`; you provided " + key);
+ }
+
+ var morphList, morphMap;
+
+ if (!morph.morphList) {
+ morph.morphList = new MorphList['default']();
+ morph.morphMap = {};
+ morph.setMorphList(morph.morphList);
+ }
+
+ morphList = morph.morphList;
+ morphMap = morph.morphMap;
+
+ if (currentMorph && currentMorph.key === key) {
+ yieldTemplate(template, env, parentScope, currentMorph, renderState, visitor)(blockArguments, self);
+ currentMorph = currentMorph.nextMorph;
+ } else if (currentMorph && morphMap[key] !== undefined) {
+ var foundMorph = morphMap[key];
+ yieldTemplate(template, env, parentScope, foundMorph, renderState, visitor)(blockArguments, self);
+ morphList.insertBeforeMorph(foundMorph, currentMorph);
} else {
- for (i = 0, l = array.length; i < l; i++) {
- callback.call(binding, array[i], i, array);
+ var childMorph = render.createChildMorph(env.dom, morph);
+ childMorph.key = key;
+ morphMap[key] = childMorph;
+ morphList.insertBeforeMorph(childMorph, currentMorph);
+ yieldTemplate(template, env, parentScope, childMorph, renderState, visitor)(blockArguments, self);
+ }
+
+ renderState.morphListStart = currentMorph;
+ renderState.clearMorph = morph.childNodes;
+ morph.childNodes = null;
+ };
+ }
+
+ function isStableTemplate(template, lastYielded) {
+ return !lastYielded.shadowTemplate && template === lastYielded.template;
+ }
+
+ function yieldInShadowTemplate(template, env, parentScope, morph, renderState, visitor) {
+ var hostYield = hostYieldWithShadowTemplate(template, env, parentScope, morph, renderState, visitor);
+
+ return function (shadowTemplate, self) {
+ hostYield(shadowTemplate, env, self, []);
+ };
+ }
+ function hostYieldWithShadowTemplate(template, env, parentScope, morph, renderState, visitor) {
+ return function (shadowTemplate, env, self, blockArguments) {
+ renderState.clearMorph = null;
+
+ if (morph.lastYielded && isStableShadowRoot(template, shadowTemplate, morph.lastYielded)) {
+ return morph.lastResult.revalidateWith(env, undefined, self, blockArguments, visitor);
+ }
+
+ var shadowScope = env.hooks.createFreshScope();
+ env.hooks.bindShadowScope(env, parentScope, shadowScope, renderState.shadowOptions);
+ blockToYield.arity = template.arity;
+ env.hooks.bindBlock(env, shadowScope, blockToYield);
+
+ morph.lastYielded = { self: self, template: template, shadowTemplate: shadowTemplate };
+
+ // Render the shadow template with the block available
+ render['default'](shadowTemplate.raw, env, shadowScope, { renderNode: morph, self: self, blockArguments: blockArguments });
+ };
+
+ function blockToYield(env, blockArguments, self, renderNode, shadowParent, visitor) {
+ if (renderNode.lastResult) {
+ renderNode.lastResult.revalidateWith(env, undefined, undefined, blockArguments, visitor);
+ } else {
+ var scope = parentScope;
+
+ // Since a yielded template shares a `self` with its original context,
+ // we only need to create a new scope if the template has block parameters
+ if (template.arity) {
+ scope = env.hooks.createChildScope(parentScope);
}
+
+ render['default'](template, env, scope, { renderNode: renderNode, self: self, blockArguments: blockArguments });
}
}
+ }
- __exports__.forEach = forEach;function map(array, callback) {
- var output = [];
- var i, l;
+ function isStableShadowRoot(template, shadowTemplate, lastYielded) {
+ return template === lastYielded.template && shadowTemplate === lastYielded.shadowTemplate;
+ }
- for (i = 0, l = array.length; i < l; i++) {
- output.push(callback(array[i], i, array));
+ function optionsFor(template, inverse, env, scope, morph, visitor) {
+ var renderState = { morphListStart: null, clearMorph: morph, shadowOptions: null };
+
+ return {
+ templates: {
+ template: wrapForHelper(template, env, scope, morph, renderState, visitor),
+ inverse: wrapForHelper(inverse, env, scope, morph, renderState, visitor)
+ },
+ renderState: renderState
+ };
+ }
+
+ function thisFor(options) {
+ return {
+ arity: options.template.arity,
+ yield: options.template.yield,
+ yieldItem: options.template.yieldItem,
+ yieldIn: options.template.yieldIn
+ };
+ }
+ function createScope(env, parentScope) {
+ if (parentScope) {
+ return env.hooks.createChildScope(parentScope);
+ } else {
+ return env.hooks.createFreshScope();
+ }
+ }
+
+ function createFreshScope() {
+ // because `in` checks have unpredictable performance, keep a
+ // separate dictionary to track whether a local was bound.
+ // See `bindLocal` for more information.
+ return { self: null, blocks: {}, locals: {}, localPresent: {} };
+ }
+
+ function bindShadowScope(env /*, parentScope, shadowScope */) {
+ return env.hooks.createFreshScope();
+ }
+
+ function createChildScope(parent) {
+ var scope = object_utils.createObject(parent);
+ scope.locals = object_utils.createObject(parent.locals);
+ return scope;
+ }
+
+ function bindSelf(env, scope, self) {
+ scope.self = self;
+ }
+
+ function updateSelf(env, scope, self) {
+ env.hooks.bindSelf(env, scope, self);
+ }
+
+ function bindLocal(env, scope, name, value) {
+ scope.localPresent[name] = true;
+ scope.locals[name] = value;
+ }
+
+ function updateLocal(env, scope, name, value) {
+ env.hooks.bindLocal(env, scope, name, value);
+ }
+
+ function bindBlock(env, scope, block) {
+ var name = arguments[3] === undefined ? "default" : arguments[3];
+
+ scope.blocks[name] = block;
+ }
+
+ function block(morph, env, scope, path, params, hash, template, inverse, visitor) {
+ if (handleRedirect(morph, env, scope, path, params, hash, template, inverse, visitor)) {
+ return;
+ }
+
+ continueBlock(morph, env, scope, path, params, hash, template, inverse, visitor);
+ }
+
+ function continueBlock(morph, env, scope, path, params, hash, template, inverse, visitor) {
+ hostBlock(morph, env, scope, template, inverse, null, visitor, function (options) {
+ var helper = env.hooks.lookupHelper(env, scope, path);
+ return env.hooks.invokeHelper(morph, env, scope, visitor, params, hash, helper, options.templates, thisFor(options.templates));
+ });
+ }
+
+ function hostBlock(morph, env, scope, template, inverse, shadowOptions, visitor, callback) {
+ var options = optionsFor(template, inverse, env, scope, morph, visitor);
+ template_utils.renderAndCleanup(morph, env, options, shadowOptions, callback);
+ }
+
+ function handleRedirect(morph, env, scope, path, params, hash, template, inverse, visitor) {
+ var redirect = env.hooks.classify(env, scope, path);
+ if (redirect) {
+ switch (redirect) {
+ case "component":
+ env.hooks.component(morph, env, scope, path, params, hash, { "default": template, inverse: inverse }, visitor);break;
+ case "inline":
+ env.hooks.inline(morph, env, scope, path, params, hash, visitor);break;
+ case "block":
+ env.hooks.block(morph, env, scope, path, params, hash, template, inverse, visitor);break;
+ default:
+ throw new Error("Internal HTMLBars redirection to " + redirect + " not supported");
}
+ return true;
+ }
- return output;
+ if (handleKeyword(path, morph, env, scope, params, hash, template, inverse, visitor)) {
+ return true;
}
- __exports__.map = map;var getIdx;
- if (Array.prototype.indexOf) {
- getIdx = function(array, obj, from){
- return array.indexOf(obj, from);
- };
+ return false;
+ }
+
+ function handleKeyword(path, morph, env, scope, params, hash, template, inverse, visitor) {
+ var keyword = env.hooks.keywords[path];
+ if (!keyword) {
+ return false;
+ }
+
+ if (typeof keyword === "function") {
+ return keyword(morph, env, scope, params, hash, template, inverse, visitor);
+ }
+
+ if (keyword.willRender) {
+ keyword.willRender(morph, env);
+ }
+
+ var lastState, newState;
+ if (keyword.setupState) {
+ lastState = object_utils.shallowCopy(morph.state);
+ newState = morph.state = keyword.setupState(lastState, env, scope, params, hash);
+ }
+
+ if (keyword.childEnv) {
+ morph.lastEnv = keyword.childEnv(morph.state);
+ env = object_utils.merge(object_utils.shallowCopy(morph.lastEnv), env);
+ }
+
+ var firstTime = !morph.rendered;
+
+ if (keyword.isEmpty) {
+ var isEmpty = keyword.isEmpty(morph.state, env, scope, params, hash);
+
+ if (isEmpty) {
+ if (!firstTime) {
+ template_utils.clearMorph(morph, env, false);
+ }
+ return true;
+ }
+ }
+
+ if (firstTime) {
+ if (keyword.render) {
+ keyword.render(morph, env, scope, params, hash, template, inverse, visitor);
+ }
+ morph.rendered = true;
+ return true;
+ }
+
+ var isStable;
+ if (keyword.isStable) {
+ isStable = keyword.isStable(lastState, newState);
} else {
- getIdx = function(array, obj, from) {
- if (from === undefined || from === null) {
- from = 0;
- } else if (from < 0) {
- from = Math.max(0, array.length + from);
+ isStable = stableState(lastState, newState);
+ }
+
+ if (isStable) {
+ if (keyword.rerender) {
+ var newEnv = keyword.rerender(morph, env, scope, params, hash, template, inverse, visitor);
+ env = newEnv || env;
+ }
+ morph_utils.validateChildMorphs(env, morph, visitor);
+ return true;
+ } else {
+ template_utils.clearMorph(morph, env, false);
+ }
+
+ // If the node is unstable, re-render from scratch
+ if (keyword.render) {
+ keyword.render(morph, env, scope, params, hash, template, inverse, visitor);
+ morph.rendered = true;
+ return true;
+ }
+ }
+
+ function stableState(oldState, newState) {
+ if (object_utils.keyLength(oldState) !== object_utils.keyLength(newState)) {
+ return false;
+ }
+
+ for (var prop in oldState) {
+ if (oldState[prop] !== newState[prop]) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ function linkRenderNode() {
+ return;
+ }
+
+ function inline(morph, env, scope, path, params, hash, visitor) {
+ if (handleRedirect(morph, env, scope, path, params, hash, null, null, visitor)) {
+ return;
+ }
+
+ var options = optionsFor(null, null, env, scope, morph);
+
+ var helper = env.hooks.lookupHelper(env, scope, path);
+ var result = env.hooks.invokeHelper(morph, env, scope, visitor, params, hash, helper, options.templates, thisFor(options.templates));
+
+ if (result && result.value) {
+ var value = result.value;
+ if (morph.lastValue !== value) {
+ morph.setContent(value);
+ }
+ morph.lastValue = value;
+ }
+ }
+
+ function keyword(path, morph, env, scope, params, hash, template, inverse, visitor) {
+ handleKeyword(path, morph, env, scope, params, hash, template, inverse, visitor);
+ }
+
+ function invokeHelper(morph, env, scope, visitor, _params, _hash, helper, templates, context) {
+ var params = normalizeArray(env, _params);
+ var hash = normalizeObject(env, _hash);
+ return { value: helper.call(context, params, hash, templates) };
+ }
+
+ function normalizeArray(env, array) {
+ var out = new Array(array.length);
+
+ for (var i = 0, l = array.length; i < l; i++) {
+ out[i] = env.hooks.getCellOrValue(array[i]);
+ }
+
+ return out;
+ }
+
+ function normalizeObject(env, object) {
+ var out = {};
+
+ for (var prop in object) {
+ out[prop] = env.hooks.getCellOrValue(object[prop]);
+ }
+
+ return out;
+ }
+ function classify() {
+ return null;
+ }
+
+ var keywords = {
+ partial: function (morph, env, scope, params) {
+ var value = env.hooks.partial(morph, env, scope, params[0]);
+ morph.setContent(value);
+ return true;
+ },
+
+ yield: function (morph, env, scope, params, hash, template, inverse, visitor) {
+ // the current scope is provided purely for the creation of shadow
+ // scopes; it should not be provided to user code.
+
+ var to = env.hooks.getValue(hash.to) || "default";
+ if (scope.blocks[to]) {
+ scope.blocks[to](env, params, hash.self, morph, scope, visitor);
+ }
+ return true;
+ },
+
+ hasBlock: function (morph, env, scope, params) {
+ var name = env.hooks.getValue(params[0]) || "default";
+ return !!scope.blocks[name];
+ },
+
+ hasBlockParams: function (morph, env, scope, params) {
+ var name = env.hooks.getValue(params[0]) || "default";
+ return !!(scope.blocks[name] && scope.blocks[name].arity);
+ }
+
+ };function partial(renderNode, env, scope, path) {
+ var template = env.partials[path];
+ return template.render(scope.self, env, {}).fragment;
+ }
+
+ function range(morph, env, scope, path, value, visitor) {
+ if (handleRedirect(morph, env, scope, path, [value], {}, null, null, visitor)) {
+ return;
+ }
+
+ value = env.hooks.getValue(value);
+
+ if (morph.lastValue !== value) {
+ morph.setContent(value);
+ }
+
+ morph.lastValue = value;
+ }
+
+ function element(morph, env, scope, path, params, hash, visitor) {
+ if (handleRedirect(morph, env, scope, path, params, hash, null, null, visitor)) {
+ return;
+ }
+
+ var helper = env.hooks.lookupHelper(env, scope, path);
+ if (helper) {
+ env.hooks.invokeHelper(null, env, scope, null, params, hash, helper, { element: morph.element });
+ }
+ }
+
+ function attribute(morph, env, scope, name, value) {
+ value = env.hooks.getValue(value);
+
+ if (morph.lastValue !== value) {
+ morph.setContent(value);
+ }
+
+ morph.lastValue = value;
+ }
+
+ function subexpr(env, scope, helperName, params, hash) {
+ var helper = env.hooks.lookupHelper(env, scope, helperName);
+ var result = env.hooks.invokeHelper(null, env, scope, null, params, hash, helper, {});
+ if (result && result.value) {
+ return result.value;
+ }
+ }
+
+ function get(env, scope, path) {
+ if (path === "") {
+ return scope.self;
+ }
+
+ var keys = path.split(".");
+ var value = env.hooks.getRoot(scope, keys[0])[0];
+
+ for (var i = 1; i < keys.length; i++) {
+ if (value) {
+ value = env.hooks.getChild(value, keys[i]);
+ } else {
+ break;
+ }
+ }
+
+ return value;
+ }
+
+ function getRoot(scope, key) {
+ if (scope.localPresent[key]) {
+ return [scope.locals[key]];
+ } else if (scope.self) {
+ return [scope.self[key]];
+ } else {
+ return [undefined];
+ }
+ }
+
+ function getChild(value, key) {
+ return value[key];
+ }
+
+ function getValue(reference) {
+ return reference;
+ }
+
+ function getCellOrValue(reference) {
+ return reference;
+ }
+
+ function component(morph, env, scope, tagName, params, attrs, templates, visitor) {
+ if (env.hooks.hasHelper(env, scope, tagName)) {
+ return env.hooks.block(morph, env, scope, tagName, params, attrs, templates["default"], templates.inverse, visitor);
+ }
+
+ componentFallback(morph, env, scope, tagName, attrs, templates["default"]);
+ }
+
+ function concat(env, params) {
+ var value = "";
+ for (var i = 0, l = params.length; i < l; i++) {
+ value += env.hooks.getValue(params[i]);
+ }
+ return value;
+ }
+
+ function componentFallback(morph, env, scope, tagName, attrs, template) {
+ var element = env.dom.createElement(tagName);
+ for (var name in attrs) {
+ element.setAttribute(name, env.hooks.getValue(attrs[name]));
+ }
+ var fragment = render['default'](template, env, scope, {}).fragment;
+ element.appendChild(fragment);
+ morph.setNode(element);
+ }
+ function hasHelper(env, scope, helperName) {
+ return env.helpers[helperName] !== undefined;
+ }
+
+ function lookupHelper(env, scope, helperName) {
+ return env.helpers[helperName];
+ }
+
+ function bindScope() {}
+
+ function updateScope(env, scope) {
+ env.hooks.bindScope(env, scope);
+ }
+
+ exports['default'] = {
+ // fundamental hooks that you will likely want to override
+ bindLocal: bindLocal,
+ bindSelf: bindSelf,
+ bindScope: bindScope,
+ classify: classify,
+ component: component,
+ concat: concat,
+ createFreshScope: createFreshScope,
+ getChild: getChild,
+ getRoot: getRoot,
+ getValue: getValue,
+ getCellOrValue: getCellOrValue,
+ keywords: keywords,
+ linkRenderNode: linkRenderNode,
+ partial: partial,
+ subexpr: subexpr,
+
+ // fundamental hooks with good default behavior
+ bindBlock: bindBlock,
+ bindShadowScope: bindShadowScope,
+ updateLocal: updateLocal,
+ updateSelf: updateSelf,
+ updateScope: updateScope,
+ createChildScope: createChildScope,
+ hasHelper: hasHelper,
+ lookupHelper: lookupHelper,
+ invokeHelper: invokeHelper,
+ cleanupRenderNode: null,
+ destroyRenderNode: null,
+ willCleanupTree: null,
+ didCleanupTree: null,
+ willRenderNode: null,
+ didRenderNode: null,
+
+ // derived hooks
+ attribute: attribute,
+ block: block,
+ createScope: createScope,
+ element: element,
+ get: get,
+ inline: inline,
+ range: range,
+ keyword: keyword
+ };
+ /* morph, env, scope, params, hash */ /* env, scope, path */ /* env, scope */
+ // this function is used to handle host-specified extensions to scope
+ // other than `self`, `locals` and `block`.
+
+ exports.keywords = keywords;
+
+});
+enifed('htmlbars-runtime/morph', ['exports', '../morph-range', '../htmlbars-util/object-utils'], function (exports, MorphBase, object_utils) {
+
+ 'use strict';
+
+ var guid = 1;
+
+ function HTMLBarsMorph(domHelper, contextualElement) {
+ this.super$constructor(domHelper, contextualElement);
+
+ this.state = {};
+ this.ownerNode = null;
+ this.isDirty = false;
+ this.isSubtreeDirty = false;
+ this.lastYielded = null;
+ this.lastResult = null;
+ this.lastValue = null;
+ this.lastEnv = null;
+ this.morphList = null;
+ this.morphMap = null;
+ this.key = null;
+ this.linkedParams = null;
+ this.rendered = false;
+ this.guid = "range" + guid++;
+ }
+
+ HTMLBarsMorph.empty = function (domHelper, contextualElement) {
+ var morph = new HTMLBarsMorph(domHelper, contextualElement);
+ morph.clear();
+ return morph;
+ };
+
+ HTMLBarsMorph.create = function (domHelper, contextualElement, node) {
+ var morph = new HTMLBarsMorph(domHelper, contextualElement);
+ morph.setNode(node);
+ return morph;
+ };
+
+ HTMLBarsMorph.attach = function (domHelper, contextualElement, firstNode, lastNode) {
+ var morph = new HTMLBarsMorph(domHelper, contextualElement);
+ morph.setRange(firstNode, lastNode);
+ return morph;
+ };
+
+ var prototype = HTMLBarsMorph.prototype = object_utils.createObject(MorphBase['default'].prototype);
+ prototype.constructor = HTMLBarsMorph;
+ prototype.super$constructor = MorphBase['default'];
+
+ exports['default'] = HTMLBarsMorph;
+
+});
+enifed('htmlbars-runtime/render', ['exports', '../htmlbars-util/array-utils', '../htmlbars-util/morph-utils', './expression-visitor', './morph', '../htmlbars-util/template-utils'], function (exports, array_utils, morph_utils, ExpressionVisitor, Morph, template_utils) {
+
+ 'use strict';
+
+ exports.manualElement = manualElement;
+ exports.createChildMorph = createChildMorph;
+ exports.getCachedFragment = getCachedFragment;
+
+ exports['default'] = render;
+
+ var svgNamespace = "http://www.w3.org/2000/svg";
+ function render(template, env, scope, options) {
+ var dom = env.dom;
+ var contextualElement;
+
+ if (options) {
+ if (options.renderNode) {
+ contextualElement = options.renderNode.contextualElement;
+ } else if (options.contextualElement) {
+ contextualElement = options.contextualElement;
+ }
+ }
+
+ dom.detectNamespace(contextualElement);
+
+ var renderResult = RenderResult.build(env, scope, template, options, contextualElement);
+ renderResult.render();
+
+ return renderResult;
+ }
+
+ function RenderResult(env, scope, options, rootNode, nodes, fragment, template, shouldSetContent) {
+ this.root = rootNode;
+ this.fragment = fragment;
+
+ this.nodes = nodes;
+ this.template = template;
+ this.env = env;
+ this.scope = scope;
+ this.shouldSetContent = shouldSetContent;
+
+ this.bindScope();
+
+ if (options.self !== undefined) {
+ this.bindSelf(options.self);
+ }
+ if (options.blockArguments !== undefined) {
+ this.bindLocals(options.blockArguments);
+ }
+ }
+
+ RenderResult.build = function (env, scope, template, options, contextualElement) {
+ var dom = env.dom;
+ var fragment = getCachedFragment(template, env);
+ var nodes = template.buildRenderNodes(dom, fragment, contextualElement);
+
+ var rootNode, ownerNode, shouldSetContent;
+
+ if (options && options.renderNode) {
+ rootNode = options.renderNode;
+ ownerNode = rootNode.ownerNode;
+ shouldSetContent = true;
+ } else {
+ rootNode = dom.createMorph(null, fragment.firstChild, fragment.lastChild, contextualElement);
+ ownerNode = rootNode;
+ initializeNode(rootNode, ownerNode);
+ shouldSetContent = false;
+ }
+
+ if (rootNode.childNodes) {
+ morph_utils.visitChildren(rootNode.childNodes, function (node) {
+ template_utils.clearMorph(node, env, true);
+ });
+ }
+
+ rootNode.childNodes = nodes;
+
+ array_utils.forEach(nodes, function (node) {
+ initializeNode(node, ownerNode);
+ });
+
+ return new RenderResult(env, scope, options, rootNode, nodes, fragment, template, shouldSetContent);
+ };
+ function manualElement(tagName, attributes) {
+ var statements = [];
+
+ for (var key in attributes) {
+ if (typeof attributes[key] === "string") {
+ continue;
+ }
+ statements.push(["attribute", key, attributes[key]]);
+ }
+
+ statements.push(["content", "yield"]);
+
+ var template = {
+ arity: 0,
+ cachedFragment: null,
+ hasRendered: false,
+ buildFragment: function buildFragment(dom) {
+ var el0 = dom.createDocumentFragment();
+ if (tagName === "svg") {
+ dom.setNamespace(svgNamespace);
}
- for (var i = from, l= array.length; i < l; i++) {
- if (array[i] === obj) {
- return i;
+ var el1 = dom.createElement(tagName);
+
+ for (var key in attributes) {
+ if (typeof attributes[key] !== "string") {
+ continue;
}
+ dom.setAttribute(el1, key, attributes[key]);
}
- return -1;
- };
+
+ var el2 = dom.createComment("");
+ dom.appendChild(el1, el2);
+ dom.appendChild(el0, el1);
+ return el0;
+ },
+ buildRenderNodes: function buildRenderNodes(dom, fragment) {
+ var element = dom.childAt(fragment, [0]);
+ var morphs = [];
+
+ for (var key in attributes) {
+ if (typeof attributes[key] === "string") {
+ continue;
+ }
+ morphs.push(dom.createAttrMorph(element, key));
+ }
+
+ morphs.push(dom.createMorphAt(element, 0, 0));
+ return morphs;
+ },
+ statements: statements,
+ locals: [],
+ templates: []
+ };
+
+ return template;
+ }
+
+ RenderResult.prototype.render = function () {
+ this.root.lastResult = this;
+ this.root.rendered = true;
+ this.populateNodes(ExpressionVisitor.AlwaysDirtyVisitor);
+
+ if (this.shouldSetContent) {
+ this.root.setContent(this.fragment);
}
+ };
- var indexOfArray = getIdx;
- __exports__.indexOfArray = indexOfArray;
- });
-enifed("htmlbars-util/handlebars/safe-string",
- ["exports"],
- function(__exports__) {
- "use strict";
- // Build out our basic SafeString type
- function SafeString(string) {
- this.string = string;
+ RenderResult.prototype.dirty = function () {
+ morph_utils.visitChildren([this.root], function (node) {
+ node.isDirty = true;
+ });
+ };
+
+ RenderResult.prototype.revalidate = function (env, self, blockArguments, scope) {
+ this.revalidateWith(env, scope, self, blockArguments, ExpressionVisitor['default']);
+ };
+
+ RenderResult.prototype.rerender = function (env, self, blockArguments, scope) {
+ this.revalidateWith(env, scope, self, blockArguments, ExpressionVisitor.AlwaysDirtyVisitor);
+ };
+
+ RenderResult.prototype.revalidateWith = function (env, scope, self, blockArguments, visitor) {
+ if (env !== undefined) {
+ this.env = env;
}
+ if (scope !== undefined) {
+ this.scope = scope;
+ }
+ this.updateScope();
- SafeString.prototype.toString = SafeString.prototype.toHTML = function() {
- return "" + this.string;
- };
+ if (self !== undefined) {
+ this.updateSelf(self);
+ }
+ if (blockArguments !== undefined) {
+ this.updateLocals(blockArguments);
+ }
- __exports__["default"] = SafeString;
- });
-enifed("htmlbars-util/handlebars/utils",
- ["./safe-string","exports"],
- function(__dependency1__, __exports__) {
- "use strict";
- /*jshint -W004 */
- var SafeString = __dependency1__["default"];
+ this.populateNodes(visitor);
+ };
- var escape = {
- "&": "&",
- "<": "<",
- ">": ">",
- '"': """,
- "'": "'",
- "`": "`"
- };
+ RenderResult.prototype.destroy = function () {
+ var rootNode = this.root;
+ template_utils.clearMorph(rootNode, this.env, true);
+ };
- var badChars = /[&<>"'`]/g;
- var possible = /[&<>"'`]/;
+ RenderResult.prototype.populateNodes = function (visitor) {
+ var env = this.env;
+ var scope = this.scope;
+ var template = this.template;
+ var nodes = this.nodes;
+ var statements = template.statements;
+ var i, l;
- function escapeChar(chr) {
- return escape[chr];
+ for (i = 0, l = statements.length; i < l; i++) {
+ var statement = statements[i];
+ var morph = nodes[i];
+
+ if (env.hooks.willRenderNode) {
+ env.hooks.willRenderNode(morph, env, scope);
+ }
+
+ switch (statement[0]) {
+ case "block":
+ visitor.block(statement, morph, env, scope, template, visitor);break;
+ case "inline":
+ visitor.inline(statement, morph, env, scope, visitor);break;
+ case "content":
+ visitor.content(statement, morph, env, scope, visitor);break;
+ case "element":
+ visitor.element(statement, morph, env, scope, template, visitor);break;
+ case "attribute":
+ visitor.attribute(statement, morph, env, scope);break;
+ case "component":
+ visitor.component(statement, morph, env, scope, template, visitor);break;
+ }
+
+ if (env.hooks.didRenderNode) {
+ env.hooks.didRenderNode(morph, env, scope);
+ }
}
+ };
- function extend(obj /* , ...source */) {
- for (var i = 1; i < arguments.length; i++) {
- for (var key in arguments[i]) {
- if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
- obj[key] = arguments[i][key];
- }
+ RenderResult.prototype.bindScope = function () {
+ this.env.hooks.bindScope(this.env, this.scope);
+ };
+
+ RenderResult.prototype.updateScope = function () {
+ this.env.hooks.updateScope(this.env, this.scope);
+ };
+
+ RenderResult.prototype.bindSelf = function (self) {
+ this.env.hooks.bindSelf(this.env, this.scope, self);
+ };
+
+ RenderResult.prototype.updateSelf = function (self) {
+ this.env.hooks.updateSelf(this.env, this.scope, self);
+ };
+
+ RenderResult.prototype.bindLocals = function (blockArguments) {
+ var localNames = this.template.locals;
+
+ for (var i = 0, l = localNames.length; i < l; i++) {
+ this.env.hooks.bindLocal(this.env, this.scope, localNames[i], blockArguments[i]);
+ }
+ };
+
+ RenderResult.prototype.updateLocals = function (blockArguments) {
+ var localNames = this.template.locals;
+
+ for (var i = 0, l = localNames.length; i < l; i++) {
+ this.env.hooks.updateLocal(this.env, this.scope, localNames[i], blockArguments[i]);
+ }
+ };
+
+ function initializeNode(node, owner) {
+ node.ownerNode = owner;
+ }
+ function createChildMorph(dom, parentMorph, contextualElement) {
+ var morph = Morph['default'].empty(dom, contextualElement || parentMorph.contextualElement);
+ initializeNode(morph, parentMorph.ownerNode);
+ return morph;
+ }
+
+ function getCachedFragment(template, env) {
+ var dom = env.dom,
+ fragment;
+ if (env.useFragmentCache && dom.canClone) {
+ if (template.cachedFragment === null) {
+ fragment = template.buildFragment(dom);
+ if (template.hasRendered) {
+ template.cachedFragment = fragment;
+ } else {
+ template.hasRendered = true;
}
}
+ if (template.cachedFragment) {
+ fragment = dom.cloneNode(template.cachedFragment, true);
+ }
+ } else if (!fragment) {
+ fragment = template.buildFragment(dom);
+ }
- return obj;
+ return fragment;
+ }
+
+});
+enifed('htmlbars-util', ['exports', './htmlbars-util/safe-string', './htmlbars-util/handlebars/utils', './htmlbars-util/namespaces', './htmlbars-util/morph-utils'], function (exports, SafeString, utils, namespaces, morph_utils) {
+
+ 'use strict';
+
+
+
+ exports.SafeString = SafeString['default'];
+ exports.escapeExpression = utils.escapeExpression;
+ exports.getAttrNamespace = namespaces.getAttrNamespace;
+ exports.validateChildMorphs = morph_utils.validateChildMorphs;
+ exports.linkParams = morph_utils.linkParams;
+ exports.dump = morph_utils.dump;
+
+});
+enifed('htmlbars-util/array-utils', ['exports'], function (exports) {
+
+ 'use strict';
+
+ exports.forEach = forEach;
+ exports.map = map;
+
+ function forEach(array, callback, binding) {
+ var i, l;
+ if (binding === undefined) {
+ for (i = 0, l = array.length; i < l; i++) {
+ callback(array[i], i, array);
+ }
+ } else {
+ for (i = 0, l = array.length; i < l; i++) {
+ callback.call(binding, array[i], i, array);
+ }
}
+ }
- __exports__.extend = extend;var toString = Object.prototype.toString;
- __exports__.toString = toString;
- // Sourced from lodash
- // https://github.com/bestiejs/lodash/blob/master/LICENSE.txt
- var isFunction = function(value) {
- return typeof value === 'function';
+ function map(array, callback) {
+ var output = [];
+ var i, l;
+
+ for (i = 0, l = array.length; i < l; i++) {
+ output.push(callback(array[i], i, array));
+ }
+
+ return output;
+ }
+
+ var getIdx;
+ if (Array.prototype.indexOf) {
+ getIdx = function (array, obj, from) {
+ return array.indexOf(obj, from);
};
- // fallback for older versions of Chrome and Safari
- /* istanbul ignore next */
- if (isFunction(/x/)) {
- isFunction = function(value) {
- return typeof value === 'function' && toString.call(value) === '[object Function]';
- };
+ } else {
+ getIdx = function (array, obj, from) {
+ if (from === undefined || from === null) {
+ from = 0;
+ } else if (from < 0) {
+ from = Math.max(0, array.length + from);
+ }
+ for (var i = from, l = array.length; i < l; i++) {
+ if (array[i] === obj) {
+ return i;
+ }
+ }
+ return -1;
+ };
+ }
+
+ var indexOfArray = getIdx;
+
+ exports.indexOfArray = indexOfArray;
+
+});
+enifed('htmlbars-util/handlebars/safe-string', ['exports'], function (exports) {
+
+ 'use strict';
+
+ // Build out our basic SafeString type
+ function SafeString(string) {
+ this.string = string;
+ }
+
+ SafeString.prototype.toString = SafeString.prototype.toHTML = function () {
+ return '' + this.string;
+ };
+
+ exports['default'] = SafeString;
+
+});
+enifed('htmlbars-util/handlebars/utils', ['exports'], function (exports) {
+
+ 'use strict';
+
+ exports.extend = extend;
+ exports.indexOf = indexOf;
+ exports.escapeExpression = escapeExpression;
+ exports.isEmpty = isEmpty;
+ exports.blockParams = blockParams;
+ exports.appendContextPath = appendContextPath;
+
+ var escape = {
+ '&': '&',
+ '<': '<',
+ '>': '>',
+ '"': '"',
+ '\'': ''',
+ '`': '`'
+ };
+
+ var badChars = /[&<>"'`]/g,
+ possible = /[&<>"'`]/;
+
+ function escapeChar(chr) {
+ return escape[chr];
+ }
+ function extend(obj /* , ...source */) {
+ for (var i = 1; i < arguments.length; i++) {
+ for (var key in arguments[i]) {
+ if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
+ obj[key] = arguments[i][key];
+ }
+ }
}
- var isFunction;
- __exports__.isFunction = isFunction;
- /* istanbul ignore next */
- var isArray = Array.isArray || function(value) {
- return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;
+
+ return obj;
+ }
+
+ var toString = Object.prototype.toString;
+
+ var isFunction = function (value) {
+ return typeof value === 'function';
+ };
+ // fallback for older versions of Chrome and Safari
+ /* istanbul ignore next */
+ if (isFunction(/x/)) {
+ isFunction = function (value) {
+ return typeof value === 'function' && toString.call(value) === '[object Function]';
};
- __exports__.isArray = isArray;
+ }
+ var isFunction;
+ var isArray = Array.isArray || function (value) {
+ return value && typeof value === 'object' ? toString.call(value) === '[object Array]' : false;
+ };function indexOf(array, value) {
+ for (var i = 0, len = array.length; i < len; i++) {
+ if (array[i] === value) {
+ return i;
+ }
+ }
+ return -1;
+ }
- function escapeExpression(string) {
+ function escapeExpression(string) {
+ if (typeof string !== 'string') {
// don't escape SafeStrings, since they're already safe
if (string && string.toHTML) {
return string.toHTML();
} else if (string == null) {
- return "";
+ return '';
} else if (!string) {
return string + '';
}
// Force a string conversion as this will be done by the append regardless and
// the regex test will do this transparently behind the scenes, causing issues if
// an object's to string has escaped characters in it.
- string = "" + string;
+ string = '' + string;
+ }
- if(!possible.test(string)) { return string; }
- return string.replace(badChars, escapeChar);
+ if (!possible.test(string)) {
+ return string;
}
+ return string.replace(badChars, escapeChar);
+ }
- __exports__.escapeExpression = escapeExpression;function isEmpty(value) {
- if (!value && value !== 0) {
- return true;
- } else if (isArray(value) && value.length === 0) {
- return true;
- } else {
- return false;
- }
+ function isEmpty(value) {
+ if (!value && value !== 0) {
+ return true;
+ } else if (isArray(value) && value.length === 0) {
+ return true;
+ } else {
+ return false;
}
+ }
- __exports__.isEmpty = isEmpty;function appendContextPath(contextPath, id) {
- return (contextPath ? contextPath + '.' : '') + id;
+ function blockParams(params, ids) {
+ params.path = ids;
+ return params;
+ }
+
+ function appendContextPath(contextPath, id) {
+ return (contextPath ? contextPath + '.' : '') + id;
+ }
+
+ exports.toString = toString;
+ exports.isFunction = isFunction;
+ exports.isArray = isArray;
+
+});
+enifed('htmlbars-util/morph-utils', ['exports'], function (exports) {
+
+ 'use strict';
+
+ exports.visitChildren = visitChildren;
+ exports.validateChildMorphs = validateChildMorphs;
+ exports.linkParams = linkParams;
+ exports.dump = dump;
+
+ /*globals console*/
+
+ function visitChildren(nodes, callback) {
+ if (!nodes || nodes.length === 0) {
+ return;
}
- __exports__.appendContextPath = appendContextPath;
- });
-enifed("htmlbars-util/namespaces",
- ["exports"],
- function(__exports__) {
- "use strict";
- // ref http://dev.w3.org/html5/spec-LC/namespaces.html
- var defaultNamespaces = {
- html: 'http://www.w3.org/1999/xhtml',
- mathml: 'http://www.w3.org/1998/Math/MathML',
- svg: 'http://www.w3.org/2000/svg',
- xlink: 'http://www.w3.org/1999/xlink',
- xml: 'http://www.w3.org/XML/1998/namespace'
- };
+ nodes = nodes.slice();
- function getAttrNamespace(attrName) {
- var namespace;
+ while (nodes.length) {
+ var node = nodes.pop();
+ callback(node);
- var colonIndex = attrName.indexOf(':');
- if (colonIndex !== -1) {
- var prefix = attrName.slice(0, colonIndex);
- namespace = defaultNamespaces[prefix];
- }
+ if (node.childNodes) {
+ nodes.push.apply(nodes, node.childNodes);
+ } else if (node.firstChildMorph) {
+ var current = node.firstChildMorph;
- return namespace || null;
+ while (current) {
+ nodes.push(current);
+ current = current.nextMorph;
+ }
+ } else if (node.morphList) {
+ nodes.push(node.morphList);
+ }
}
+ }
- __exports__.getAttrNamespace = getAttrNamespace;
- });
-enifed("htmlbars-util/object-utils",
- ["exports"],
- function(__exports__) {
- "use strict";
- function merge(options, defaults) {
- for (var prop in defaults) {
- if (options.hasOwnProperty(prop)) { continue; }
- options[prop] = defaults[prop];
+ function validateChildMorphs(env, morph, visitor) {
+ var morphList = morph.morphList;
+ if (morph.morphList) {
+ var current = morphList.firstChildMorph;
+
+ while (current) {
+ var next = current.nextMorph;
+ validateChildMorphs(env, current, visitor);
+ current = next;
}
- return options;
+ } else if (morph.lastResult) {
+ morph.lastResult.revalidateWith(env, undefined, undefined, undefined, visitor);
+ } else if (morph.childNodes) {
+ // This means that the childNodes were wired up manually
+ for (var i = 0, l = morph.childNodes.length; i < l; i++) {
+ validateChildMorphs(env, morph.childNodes[i], visitor);
+ }
}
+ }
- __exports__.merge = merge;
- });
-enifed("htmlbars-util/quoting",
- ["exports"],
- function(__exports__) {
- "use strict";
- function escapeString(str) {
- str = str.replace(/\\/g, "\\\\");
- str = str.replace(/"/g, '\\"');
- str = str.replace(/\n/g, "\\n");
- return str;
+ function linkParams(env, scope, morph, path, params, hash) {
+ if (morph.linkedParams) {
+ return;
}
- __exports__.escapeString = escapeString;
+ if (env.hooks.linkRenderNode(morph, env, scope, path, params, hash)) {
+ morph.linkedParams = { params: params, hash: hash };
+ }
+ }
- function string(str) {
- return '"' + escapeString(str) + '"';
+ function dump(node) {
+ console.group(node, node.isDirty);
+
+ if (node.childNodes) {
+ map(node.childNodes, dump);
+ } else if (node.firstChildMorph) {
+ var current = node.firstChildMorph;
+
+ while (current) {
+ dump(current);
+ current = current.nextMorph;
+ }
+ } else if (node.morphList) {
+ dump(node.morphList);
}
- __exports__.string = string;
+ console.groupEnd();
+ }
- function array(a) {
- return "[" + a + "]";
+ function map(nodes, cb) {
+ for (var i = 0, l = nodes.length; i < l; i++) {
+ cb(nodes[i]);
}
+ }
- __exports__.array = array;
+});
+enifed('htmlbars-util/namespaces', ['exports'], function (exports) {
- function hash(pairs) {
- return "{" + pairs.join(", ") + "}";
+ 'use strict';
+
+ exports.getAttrNamespace = getAttrNamespace;
+
+ var defaultNamespaces = {
+ html: 'http://www.w3.org/1999/xhtml',
+ mathml: 'http://www.w3.org/1998/Math/MathML',
+ svg: 'http://www.w3.org/2000/svg',
+ xlink: 'http://www.w3.org/1999/xlink',
+ xml: 'http://www.w3.org/XML/1998/namespace'
+ };
+ function getAttrNamespace(attrName) {
+ var namespace;
+
+ var colonIndex = attrName.indexOf(':');
+ if (colonIndex !== -1) {
+ var prefix = attrName.slice(0, colonIndex);
+ namespace = defaultNamespaces[prefix];
}
- __exports__.hash = hash;function repeat(chars, times) {
- var str = "";
- while (times--) {
- str += chars;
+ return namespace || null;
+ }
+
+});
+enifed('htmlbars-util/object-utils', ['exports'], function (exports) {
+
+ 'use strict';
+
+ exports.merge = merge;
+ exports.createObject = createObject;
+ exports.objectKeys = objectKeys;
+ exports.shallowCopy = shallowCopy;
+ exports.keySet = keySet;
+ exports.keyLength = keyLength;
+
+ function merge(options, defaults) {
+ for (var prop in defaults) {
+ if (options.hasOwnProperty(prop)) {
+ continue;
}
- return str;
+ options[prop] = defaults[prop];
}
+ return options;
+ }
- __exports__.repeat = repeat;
- });
-enifed("htmlbars-util/safe-string",
- ["./handlebars/safe-string","exports"],
- function(__dependency1__, __exports__) {
- "use strict";
- var SafeString = __dependency1__["default"];
+ function createObject(obj) {
+ if (typeof Object.create === 'function') {
+ return Object.create(obj);
+ } else {
+ var Temp = function () {};
+ Temp.prototype = obj;
+ return new Temp();
+ }
+ }
- __exports__["default"] = SafeString;
- });
-enifed("morph-attr",
- ["./morph-attr/sanitize-attribute-value","./dom-helper/prop","./dom-helper/build-html-dom","./htmlbars-util","exports"],
- function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {
- "use strict";
- var sanitizeAttributeValue = __dependency1__.sanitizeAttributeValue;
- var isAttrRemovalValue = __dependency2__.isAttrRemovalValue;
- var normalizeProperty = __dependency2__.normalizeProperty;
- var svgNamespace = __dependency3__.svgNamespace;
- var getAttrNamespace = __dependency4__.getAttrNamespace;
-
- function updateProperty(value) {
- this.domHelper.setPropertyStrict(this.element, this.attrName, value);
+ function objectKeys(obj) {
+ if (typeof Object.keys === 'function') {
+ return Object.keys(obj);
+ } else {
+ return legacyKeys(obj);
}
+ }
- function updateAttribute(value) {
- if (isAttrRemovalValue(value)) {
- this.domHelper.removeAttribute(this.element, this.attrName);
- } else {
- this.domHelper.setAttribute(this.element, this.attrName, value);
+ function shallowCopy(obj) {
+ return merge({}, obj);
+ }
+
+ function legacyKeys(obj) {
+ var keys = [];
+
+ for (var prop in obj) {
+ if (obj.hasOwnProperty(prop)) {
+ keys.push(prop);
}
}
- function updateAttributeNS(value) {
- if (isAttrRemovalValue(value)) {
- this.domHelper.removeAttribute(this.element, this.attrName);
- } else {
- this.domHelper.setAttributeNS(this.element, this.namespace, this.attrName, value);
+ return keys;
+ }
+ function keySet(obj) {
+ var set = {};
+
+ for (var prop in obj) {
+ if (obj.hasOwnProperty(prop)) {
+ set[prop] = true;
}
}
- function AttrMorph(element, attrName, domHelper, namespace) {
- this.element = element;
- this.domHelper = domHelper;
- this.namespace = namespace !== undefined ? namespace : getAttrNamespace(attrName);
- this.escaped = true;
+ return set;
+ }
- var normalizedAttrName = normalizeProperty(this.element, attrName);
- if (this.namespace) {
- this._update = updateAttributeNS;
- this.attrName = attrName;
- } else {
- if (element.namespaceURI === svgNamespace || attrName === 'style' || !normalizedAttrName) {
- this.attrName = attrName;
- this._update = updateAttribute;
- } else {
- this.attrName = normalizedAttrName;
- this._update = updateProperty;
- }
+ function keyLength(obj) {
+ var count = 0;
+
+ for (var prop in obj) {
+ if (obj.hasOwnProperty(prop)) {
+ count++;
}
}
- AttrMorph.prototype.setContent = function (value) {
- if (this.escaped) {
- var sanitized = sanitizeAttributeValue(this.domHelper, this.element, this.attrName, value);
- this._update(sanitized, this.namespace);
- } else {
- this._update(value, this.namespace);
- }
- };
+ return count;
+ }
- __exports__["default"] = AttrMorph;
+});
+enifed('htmlbars-util/quoting', ['exports'], function (exports) {
- __exports__.sanitizeAttributeValue = sanitizeAttributeValue;
- });
-enifed("morph-attr/sanitize-attribute-value",
- ["exports"],
- function(__exports__) {
- "use strict";
- /* jshint scripturl:true */
+ 'use strict';
- var badProtocols = {
- 'javascript:': true,
- 'vbscript:': true
- };
+ exports.hash = hash;
+ exports.repeat = repeat;
+ exports.escapeString = escapeString;
+ exports.string = string;
+ exports.array = array;
- var badTags = {
- 'A': true,
- 'BODY': true,
- 'LINK': true,
- 'IMG': true,
- 'IFRAME': true,
- 'BASE': true
- };
+ function escapeString(str) {
+ str = str.replace(/\\/g, "\\\\");
+ str = str.replace(/"/g, "\\\"");
+ str = str.replace(/\n/g, "\\n");
+ return str;
+ }
- var badTagsForDataURI = {
- 'EMBED': true
- };
+ function string(str) {
+ return "\"" + escapeString(str) + "\"";
+ }
- var badAttributes = {
- 'href': true,
- 'src': true,
- 'background': true
- };
- __exports__.badAttributes = badAttributes;
- var badAttributesForDataURI = {
- 'src': true
- };
+ function array(a) {
+ return "[" + a + "]";
+ }
- function sanitizeAttributeValue(dom, element, attribute, value) {
- var tagName;
+ function hash(pairs) {
+ return "{" + pairs.join(", ") + "}";
+ }
- if (!element) {
- tagName = null;
+ function repeat(chars, times) {
+ var str = "";
+ while (times--) {
+ str += chars;
+ }
+ return str;
+ }
+
+});
+enifed('htmlbars-util/safe-string', ['exports', './handlebars/safe-string'], function (exports, SafeString) {
+
+ 'use strict';
+
+ exports['default'] = SafeString['default'];
+
+});
+enifed('htmlbars-util/template-utils', ['exports', '../htmlbars-util/morph-utils'], function (exports, morph_utils) {
+
+ 'use strict';
+
+ exports.blockFor = blockFor;
+ exports.renderAndCleanup = renderAndCleanup;
+ exports.clearMorph = clearMorph;
+
+ function blockFor(render, template, blockOptions) {
+ var block = function (env, blockArguments, self, renderNode, parentScope, visitor) {
+ if (renderNode.lastResult) {
+ renderNode.lastResult.revalidateWith(env, undefined, self, blockArguments, visitor);
} else {
- tagName = element.tagName.toUpperCase();
+ var options = { renderState: { morphListStart: null, clearMorph: renderNode, shadowOptions: null } };
+
+ var scope = blockOptions.scope;
+ var shadowScope = scope ? env.hooks.createChildScope(scope) : env.hooks.createFreshScope();
+
+ env.hooks.bindShadowScope(env, parentScope, shadowScope, blockOptions.options);
+
+ if (self !== undefined) {
+ env.hooks.bindSelf(env, shadowScope, self);
+ } else if (blockOptions.self !== undefined) {
+ env.hooks.bindSelf(env, shadowScope, blockOptions.self);
+ }
+
+ bindBlocks(env, shadowScope, blockOptions.yieldTo);
+
+ renderAndCleanup(renderNode, env, options, null, function () {
+ options.renderState.clearMorph = null;
+ render(template, env, shadowScope, { renderNode: renderNode, blockArguments: blockArguments });
+ });
}
+ };
- if (value && value.toHTML) {
- return value.toHTML();
+ block.arity = template.arity;
+
+ return block;
+ }
+
+ function bindBlocks(env, shadowScope, blocks) {
+ if (!blocks) {
+ return;
+ }
+ if (typeof blocks === 'function') {
+ env.hooks.bindBlock(env, shadowScope, blocks);
+ } else {
+ for (var name in blocks) {
+ if (blocks.hasOwnProperty(name)) {
+ env.hooks.bindBlock(env, shadowScope, blocks[name], name);
+ }
}
+ }
+ }
+ function renderAndCleanup(morph, env, options, shadowOptions, callback) {
+ options.renderState.shadowOptions = shadowOptions;
+ var result = callback(options);
- if ((tagName === null || badTags[tagName]) && badAttributes[attribute]) {
- var protocol = dom.protocolForURL(value);
- if (badProtocols[protocol] === true) {
- return 'unsafe:' + value;
+ if (result && result.handled) {
+ return;
+ }
+
+ var item = options.renderState.morphListStart;
+ var toClear = options.renderState.clearMorph;
+ var morphMap = morph.morphMap;
+
+ while (item) {
+ var next = item.nextMorph;
+ delete morphMap[item.key];
+ clearMorph(item, env, true);
+ item.destroy();
+ item = next;
+ }
+
+ if (toClear) {
+ if (Object.prototype.toString.call(toClear) === '[object Array]') {
+ for (var i = 0, l = toClear.length; i < l; i++) {
+ clearMorph(toClear[i], env);
}
+ } else {
+ clearMorph(toClear, env);
}
+ }
+ }
- if (badTagsForDataURI[tagName] && badAttributesForDataURI[attribute]) {
- return 'unsafe:' + value;
+ function clearMorph(morph, env, destroySelf) {
+ var cleanup = env.hooks.cleanupRenderNode;
+ var destroy = env.hooks.destroyRenderNode;
+ var willCleanup = env.hooks.willCleanupTree;
+ var didCleanup = env.hooks.didCleanupTree;
+
+ function destroyNode(node) {
+ if (cleanup) {
+ cleanup(node);
}
+ if (destroy) {
+ destroy(node);
+ }
+ }
- return value;
+ if (willCleanup) {
+ willCleanup(env, morph, destroySelf);
}
+ if (cleanup) {
+ cleanup(morph);
+ }
+ if (destroySelf && destroy) {
+ destroy(morph);
+ }
- __exports__.sanitizeAttributeValue = sanitizeAttributeValue;
- });
-enifed("morph-range",
- ["./morph-range/utils","exports"],
- function(__dependency1__, __exports__) {
- "use strict";
- var clear = __dependency1__.clear;
- var insertBefore = __dependency1__.insertBefore;
+ morph_utils.visitChildren(morph.childNodes, destroyNode);
- function Morph(domHelper, contextualElement) {
- this.domHelper = domHelper;
- // context if content if current content is detached
- this.contextualElement = contextualElement;
+ // TODO: Deal with logical children that are not in the DOM tree
+ morph.clear();
+ if (didCleanup) {
+ didCleanup(env, morph, destroySelf);
+ }
- // flag to force text to setContent to be treated as html
- this.parseTextAsHTML = false;
+ morph.lastResult = null;
+ morph.lastYielded = null;
+ morph.childNodes = null;
+ }
- this.firstNode = null;
- this.lastNode = null;
+});
+enifed('morph-attr', ['exports', './morph-attr/sanitize-attribute-value', './dom-helper/prop', './dom-helper/build-html-dom', './htmlbars-util'], function (exports, sanitize_attribute_value, prop, build_html_dom, htmlbars_util) {
- // morph graph
- this.parentMorph = null;
- this.firstChildMorph = null;
- this.lastChildMorph = null;
+ 'use strict';
- this.previousMorph = null;
- this.nextMorph = null;
+ function getProperty() {
+ return this.domHelper.getPropertyStrict(this.element, this.attrName);
+ }
+
+ function updateProperty(value) {
+ if (this._renderedInitially === true || !prop.isAttrRemovalValue(value)) {
+ // do not render if initial value is undefined or null
+ this.domHelper.setPropertyStrict(this.element, this.attrName, value);
}
- Morph.prototype.setContent = function Morph$setContent(content) {
- if (content === null || content === undefined) {
- return this.clear();
- }
+ this._renderedInitially = true;
+ }
- var type = typeof content;
- switch (type) {
- case 'string':
- if (this.parseTextAsHTML) {
- return this.setHTML(content);
- }
- return this.setText(content);
- case 'object':
- if (typeof content.nodeType === 'number') {
- return this.setNode(content);
- }
- /* Handlebars.SafeString */
- if (typeof content.toHTML === 'function') {
- return this.setHTML(content.toHTML());
- }
- if (this.parseTextAsHTML) {
- return this.setHTML(content.toString());
- }
- /* falls through */
- case 'boolean':
- case 'number':
- return this.setText(content.toString());
- default:
- throw new TypeError('unsupported content');
- }
- };
+ function getAttribute() {
+ return this.domHelper.getAttribute(this.element, this.attrName);
+ }
- Morph.prototype.clear = function Morph$clear() {
- return this.setNode(this.domHelper.createComment(''));
- };
+ function updateAttribute(value) {
+ if (prop.isAttrRemovalValue(value)) {
+ this.domHelper.removeAttribute(this.element, this.attrName);
+ } else {
+ this.domHelper.setAttribute(this.element, this.attrName, value);
+ }
+ }
- Morph.prototype.setText = function Morph$setText(text) {
- var firstNode = this.firstNode;
- var lastNode = this.lastNode;
+ function getAttributeNS() {
+ return this.domHelper.getAttributeNS(this.element, this.namespace, this.attrName);
+ }
- if (firstNode &&
- lastNode === firstNode &&
- firstNode.nodeType === 3) {
- firstNode.nodeValue = text;
- return firstNode;
- }
+ function updateAttributeNS(value) {
+ if (prop.isAttrRemovalValue(value)) {
+ this.domHelper.removeAttribute(this.element, this.attrName);
+ } else {
+ this.domHelper.setAttributeNS(this.element, this.namespace, this.attrName, value);
+ }
+ }
- return this.setNode(
- text ? this.domHelper.createTextNode(text) : this.domHelper.createComment('')
- );
- };
+ var UNSET = { unset: true };
- Morph.prototype.setNode = function Morph$setNode(newNode) {
- var firstNode, lastNode;
- switch (newNode.nodeType) {
- case 3:
- firstNode = newNode;
- lastNode = newNode;
- break;
- case 11:
- firstNode = newNode.firstChild;
- lastNode = newNode.lastChild;
- if (firstNode === null) {
- firstNode = this.domHelper.createComment('');
- newNode.appendChild(firstNode);
- lastNode = firstNode;
- }
- break;
- default:
- firstNode = newNode;
- lastNode = newNode;
- break;
- }
+ var guid = 1;
- var previousFirstNode = this.firstNode;
- if (previousFirstNode !== null) {
+ function AttrMorph(element, attrName, domHelper, namespace) {
+ this.element = element;
+ this.domHelper = domHelper;
+ this.namespace = namespace !== undefined ? namespace : htmlbars_util.getAttrNamespace(attrName);
+ this.state = {};
+ this.isDirty = false;
+ this.escaped = true;
+ this.lastValue = UNSET;
+ this.linkedParams = null;
+ this.guid = "attr" + guid++;
+ this.rendered = false;
+ this._renderedInitially = false;
- var parentNode = previousFirstNode.parentNode;
- insertBefore(parentNode, firstNode, lastNode, previousFirstNode);
- clear(parentNode, previousFirstNode, this.lastNode);
+ var normalizedAttrName = prop.normalizeProperty(this.element, attrName);
+ if (this.namespace) {
+ this._update = updateAttributeNS;
+ this._get = getAttributeNS;
+ this.attrName = attrName;
+ } else {
+ if (element.namespaceURI === build_html_dom.svgNamespace || attrName === "style" || !normalizedAttrName) {
+ this.attrName = attrName;
+ this._update = updateAttribute;
+ this._get = getAttribute;
+ } else {
+ this.attrName = normalizedAttrName;
+ this._update = updateProperty;
+ this._get = getProperty;
}
+ }
+ }
- this.firstNode = firstNode;
- this.lastNode = lastNode;
+ AttrMorph.prototype.setContent = function (value) {
+ if (this.lastValue === value) {
+ return;
+ }
+ this.lastValue = value;
- if (this.parentMorph) {
- syncFirstNode(this);
- syncLastNode(this);
+ if (this.escaped) {
+ var sanitized = sanitize_attribute_value.sanitizeAttributeValue(this.domHelper, this.element, this.attrName, value);
+ this._update(sanitized, this.namespace);
+ } else {
+ this._update(value, this.namespace);
+ }
+ };
+
+ AttrMorph.prototype.getContent = function () {
+ var value = this.lastValue = this._get();
+ return value;
+ };
+
+ // renderAndCleanup calls `clear` on all items in the morph map
+ // just before calling `destroy` on the morph.
+ //
+ // As a future refactor this could be changed to set the property
+ // back to its original/default value.
+ AttrMorph.prototype.clear = function () {};
+
+ AttrMorph.prototype.destroy = function () {
+ this.element = null;
+ this.domHelper = null;
+ };
+
+ exports['default'] = AttrMorph;
+
+ exports.sanitizeAttributeValue = sanitize_attribute_value.sanitizeAttributeValue;
+
+});
+enifed('morph-attr/sanitize-attribute-value', ['exports'], function (exports) {
+
+ 'use strict';
+
+ exports.sanitizeAttributeValue = sanitizeAttributeValue;
+
+ var badProtocols = {
+ 'javascript:': true,
+ 'vbscript:': true
+ };
+
+ var badTags = {
+ 'A': true,
+ 'BODY': true,
+ 'LINK': true,
+ 'IMG': true,
+ 'IFRAME': true,
+ 'BASE': true
+ };
+
+ var badTagsForDataURI = {
+ 'EMBED': true
+ };
+
+ var badAttributes = {
+ 'href': true,
+ 'src': true,
+ 'background': true
+ };
+
+ var badAttributesForDataURI = {
+ 'src': true
+ };
+ function sanitizeAttributeValue(dom, element, attribute, value) {
+ var tagName;
+
+ if (!element) {
+ tagName = null;
+ } else {
+ tagName = element.tagName.toUpperCase();
+ }
+
+ if (value && value.toHTML) {
+ return value.toHTML();
+ }
+
+ if ((tagName === null || badTags[tagName]) && badAttributes[attribute]) {
+ var protocol = dom.protocolForURL(value);
+ if (badProtocols[protocol] === true) {
+ return 'unsafe:' + value;
}
+ }
- return newNode;
- };
+ if (badTagsForDataURI[tagName] && badAttributesForDataURI[attribute]) {
+ return 'unsafe:' + value;
+ }
- function syncFirstNode(_morph) {
- var morph = _morph;
- var parentMorph;
- while (parentMorph = morph.parentMorph) {
- if (morph !== parentMorph.firstChildMorph) {
- break;
+ return value;
+ }
+
+ exports.badAttributes = badAttributes;
+
+});
+enifed('morph-range', ['exports', './morph-range/utils'], function (exports, utils) {
+
+ 'use strict';
+
+ function Morph(domHelper, contextualElement) {
+ this.domHelper = domHelper;
+ // context if content if current content is detached
+ this.contextualElement = contextualElement;
+ // inclusive range of morph
+ // these should be nodeType 1, 3, or 8
+ this.firstNode = null;
+ this.lastNode = null;
+
+ // flag to force text to setContent to be treated as html
+ this.parseTextAsHTML = false;
+
+ // morph list graph
+ this.parentMorphList = null;
+ this.previousMorph = null;
+ this.nextMorph = null;
+ }
+
+ Morph.empty = function (domHelper, contextualElement) {
+ var morph = new Morph(domHelper, contextualElement);
+ morph.clear();
+ return morph;
+ };
+
+ Morph.create = function (domHelper, contextualElement, node) {
+ var morph = new Morph(domHelper, contextualElement);
+ morph.setNode(node);
+ return morph;
+ };
+
+ Morph.attach = function (domHelper, contextualElement, firstNode, lastNode) {
+ var morph = new Morph(domHelper, contextualElement);
+ morph.setRange(firstNode, lastNode);
+ return morph;
+ };
+
+ Morph.prototype.setContent = function Morph$setContent(content) {
+ if (content === null || content === undefined) {
+ return this.clear();
+ }
+
+ var type = typeof content;
+ switch (type) {
+ case 'string':
+ if (this.parseTextAsHTML) {
+ return this.setHTML(content);
}
- if (morph.firstNode === parentMorph.firstNode) {
- break;
+ return this.setText(content);
+ case 'object':
+ if (typeof content.nodeType === 'number') {
+ return this.setNode(content);
}
+ /* Handlebars.SafeString */
+ if (typeof content.string === 'string') {
+ return this.setHTML(content.string);
+ }
+ if (this.parseTextAsHTML) {
+ return this.setHTML(content.toString());
+ }
+ /* falls through */
+ case 'boolean':
+ case 'number':
+ return this.setText(content.toString());
+ default:
+ throw new TypeError('unsupported content');
+ }
+ };
- parentMorph.firstNode = morph.firstNode;
+ Morph.prototype.clear = function Morph$clear() {
+ var node = this.setNode(this.domHelper.createComment(''));
+ return node;
+ };
- morph = parentMorph;
- }
+ Morph.prototype.setText = function Morph$setText(text) {
+ var firstNode = this.firstNode;
+ var lastNode = this.lastNode;
+
+ if (firstNode && lastNode === firstNode && firstNode.nodeType === 3) {
+ firstNode.nodeValue = text;
+ return firstNode;
}
- function syncLastNode(_morph) {
- var morph = _morph;
- var parentMorph;
- while (parentMorph = morph.parentMorph) {
- if (morph !== parentMorph.lastChildMorph) {
- break;
+ return this.setNode(text ? this.domHelper.createTextNode(text) : this.domHelper.createComment(''));
+ };
+
+ Morph.prototype.setNode = function Morph$setNode(newNode) {
+ var firstNode, lastNode;
+ switch (newNode.nodeType) {
+ case 3:
+ firstNode = newNode;
+ lastNode = newNode;
+ break;
+ case 11:
+ firstNode = newNode.firstChild;
+ lastNode = newNode.lastChild;
+ if (firstNode === null) {
+ firstNode = this.domHelper.createComment('');
+ newNode.appendChild(firstNode);
+ lastNode = firstNode;
}
- if (morph.lastNode === parentMorph.lastNode) {
- break;
- }
+ break;
+ default:
+ firstNode = newNode;
+ lastNode = newNode;
+ break;
+ }
- parentMorph.lastNode = morph.lastNode;
+ this.setRange(firstNode, lastNode);
- morph = parentMorph;
+ return newNode;
+ };
+
+ Morph.prototype.setRange = function (firstNode, lastNode) {
+ var previousFirstNode = this.firstNode;
+ if (previousFirstNode !== null) {
+
+ var parentNode = previousFirstNode.parentNode;
+ if (parentNode !== null) {
+ utils.insertBefore(parentNode, firstNode, lastNode, previousFirstNode);
+ utils.clear(parentNode, previousFirstNode, this.lastNode);
}
}
- // return morph content to an undifferentiated state
- // drops knowledge that the node has content.
- // this is for rerender, I need to test, but basically
- // the idea is to leave the content, but allow render again
- // without appending, so n
- Morph.prototype.reset = function Morph$reset() {
- this.firstChildMorph = null;
- this.lastChildMorph = null;
- };
+ this.firstNode = firstNode;
+ this.lastNode = lastNode;
- Morph.prototype.destroy = function Morph$destroy() {
- var parentMorph = this.parentMorph;
- var previousMorph = this.previousMorph;
- var nextMorph = this.nextMorph;
- var firstNode = this.firstNode;
- var lastNode = this.lastNode;
- var parentNode = firstNode && firstNode.parentNode;
+ if (this.parentMorphList) {
+ this._syncFirstNode();
+ this._syncLastNode();
+ }
+ };
- if (previousMorph) {
- if (nextMorph) {
- previousMorph.nextMorph = nextMorph;
- nextMorph.previousMorph = previousMorph;
- } else {
- previousMorph.nextMorph = null;
- if (parentMorph) { parentMorph.lastChildMorph = previousMorph; }
- }
+ Morph.prototype.destroy = function Morph$destroy() {
+ this.unlink();
+
+ var firstNode = this.firstNode;
+ var lastNode = this.lastNode;
+ var parentNode = firstNode && firstNode.parentNode;
+
+ this.firstNode = null;
+ this.lastNode = null;
+
+ utils.clear(parentNode, firstNode, lastNode);
+ };
+
+ Morph.prototype.unlink = function Morph$unlink() {
+ var parentMorphList = this.parentMorphList;
+ var previousMorph = this.previousMorph;
+ var nextMorph = this.nextMorph;
+
+ if (previousMorph) {
+ if (nextMorph) {
+ previousMorph.nextMorph = nextMorph;
+ nextMorph.previousMorph = previousMorph;
} else {
- if (nextMorph) {
- nextMorph.previousMorph = null;
- if (parentMorph) { parentMorph.firstChildMorph = nextMorph; }
- } else if (parentMorph) {
- parentMorph.lastChildMorph = parentMorph.firstChildMorph = null;
- }
+ previousMorph.nextMorph = null;
+ parentMorphList.lastChildMorph = previousMorph;
}
+ } else {
+ if (nextMorph) {
+ nextMorph.previousMorph = null;
+ parentMorphList.firstChildMorph = nextMorph;
+ } else if (parentMorphList) {
+ parentMorphList.lastChildMorph = parentMorphList.firstChildMorph = null;
+ }
+ }
- this.parentMorph = null;
- this.firstNode = null;
- this.lastNode = null;
+ this.parentMorphList = null;
+ this.nextMorph = null;
+ this.previousMorph = null;
- if (parentMorph) {
- if (!parentMorph.firstChildMorph) {
- // list is empty
- parentMorph.clear();
- return;
- } else {
- syncFirstNode(parentMorph.firstChildMorph);
- syncLastNode(parentMorph.lastChildMorph);
- }
+ if (parentMorphList && parentMorphList.mountedMorph) {
+ if (!parentMorphList.firstChildMorph) {
+ // list is empty
+ parentMorphList.mountedMorph.clear();
+ return;
+ } else {
+ parentMorphList.firstChildMorph._syncFirstNode();
+ parentMorphList.lastChildMorph._syncLastNode();
}
+ }
+ };
- clear(parentNode, firstNode, lastNode);
- };
+ Morph.prototype.setHTML = function (text) {
+ var fragment = this.domHelper.parseHTML(text, this.contextualElement);
+ return this.setNode(fragment);
+ };
- Morph.prototype.setHTML = function(text) {
- var fragment = this.domHelper.parseHTML(text, this.contextualElement);
- return this.setNode(fragment);
- };
+ Morph.prototype.setMorphList = function Morph$appendMorphList(morphList) {
+ morphList.mountedMorph = this;
+ this.clear();
- Morph.prototype.appendContent = function(content) {
- return this.insertContentBeforeMorph(content, null);
- };
+ var originalFirstNode = this.firstNode;
- Morph.prototype.insertContentBeforeMorph = function (content, referenceMorph) {
- var morph = new Morph(this.domHelper, this.contextualElement);
- morph.setContent(content);
- this.insertBeforeMorph(morph, referenceMorph);
- return morph;
- };
+ if (morphList.firstChildMorph) {
+ this.firstNode = morphList.firstChildMorph.firstNode;
+ this.lastNode = morphList.lastChildMorph.lastNode;
- Morph.prototype.appendMorph = function(morph) {
- this.insertBeforeMorph(morph, null);
- };
+ var current = morphList.firstChildMorph;
- Morph.prototype.insertBeforeMorph = function(morph, referenceMorph) {
- if (referenceMorph && referenceMorph.parentMorph !== this) {
- throw new Error('The morph before which the new morph is to be inserted is not a child of this morph.');
+ while (current) {
+ var next = current.nextMorph;
+ current.insertBeforeNode(originalFirstNode, null);
+ current = next;
}
+ originalFirstNode.parentNode.removeChild(originalFirstNode);
+ }
+ };
- morph.parentMorph = this;
+ Morph.prototype._syncFirstNode = function Morph$syncFirstNode() {
+ var morph = this;
+ var parentMorphList;
+ while (parentMorphList = morph.parentMorphList) {
+ if (parentMorphList.mountedMorph === null) {
+ break;
+ }
+ if (morph !== parentMorphList.firstChildMorph) {
+ break;
+ }
+ if (morph.firstNode === parentMorphList.mountedMorph.firstNode) {
+ break;
+ }
- var parentNode = this.firstNode.parentNode;
+ parentMorphList.mountedMorph.firstNode = morph.firstNode;
- insertBefore(
- parentNode,
- morph.firstNode,
- morph.lastNode,
- referenceMorph ? referenceMorph.firstNode : this.lastNode.nextSibling
- );
+ morph = parentMorphList.mountedMorph;
+ }
+ };
- // was not in list mode replace current content
- if (!this.firstChildMorph) {
- clear(parentNode, this.firstNode, this.lastNode);
+ Morph.prototype._syncLastNode = function Morph$syncLastNode() {
+ var morph = this;
+ var parentMorphList;
+ while (parentMorphList = morph.parentMorphList) {
+ if (parentMorphList.mountedMorph === null) {
+ break;
}
-
- var previousMorph = referenceMorph ? referenceMorph.previousMorph : this.lastChildMorph;
- if (previousMorph) {
- previousMorph.nextMorph = morph;
- morph.previousMorph = previousMorph;
- } else {
- this.firstChildMorph = morph;
+ if (morph !== parentMorphList.lastChildMorph) {
+ break;
}
-
- if (referenceMorph) {
- referenceMorph.previousMorph = morph;
- morph.nextMorph = referenceMorph;
- } else {
- this.lastChildMorph = morph;
+ if (morph.lastNode === parentMorphList.mountedMorph.lastNode) {
+ break;
}
- syncFirstNode(this.firstChildMorph);
- syncLastNode(this.lastChildMorph);
- };
+ parentMorphList.mountedMorph.lastNode = morph.lastNode;
- __exports__["default"] = Morph;
- });
-enifed("morph-range/utils",
- ["exports"],
- function(__exports__) {
- "use strict";
- // inclusive of both nodes
- function clear(parentNode, firstNode, lastNode) {
- if (!parentNode) { return; }
+ morph = parentMorphList.mountedMorph;
+ }
+ };
- var node = firstNode;
- var nextNode;
- do {
- nextNode = node.nextSibling;
- parentNode.removeChild(node);
- if (node === lastNode) {
- break;
- }
- node = nextNode;
- } while (node);
+ Morph.prototype.insertBeforeNode = function Morph$insertBeforeNode(parent, reference) {
+ var current = this.firstNode;
+
+ while (current) {
+ var next = current.nextSibling;
+ parent.insertBefore(current, reference);
+ current = next;
}
+ };
- __exports__.clear = clear;function insertBefore(parentNode, firstNode, lastNode, _refNode) {
- var node = lastNode;
- var refNode = _refNode;
- var prevNode;
- do {
- prevNode = node.previousSibling;
- parentNode.insertBefore(node, refNode);
- if (node === firstNode) {
- break;
- }
- refNode = node;
- node = prevNode;
- } while (node);
+ Morph.prototype.appendToNode = function Morph$appendToNode(parent) {
+ this.insertBeforeNode(parent, null);
+ };
+
+ exports['default'] = Morph;
+
+});
+enifed('morph-range/morph-list', ['exports', './utils'], function (exports, utils) {
+
+ 'use strict';
+
+ function MorphList() {
+ // morph graph
+ this.firstChildMorph = null;
+ this.lastChildMorph = null;
+
+ this.mountedMorph = null;
+ }
+
+ var prototype = MorphList.prototype;
+
+ prototype.clear = function MorphList$clear() {
+ var current = this.firstChildMorph;
+
+ while (current) {
+ var next = current.nextMorph;
+ current.previousMorph = null;
+ current.nextMorph = null;
+ current.parentMorphList = null;
+ current = next;
}
- __exports__.insertBefore = insertBefore;
- });
-enifed("route-recognizer",
- ["./route-recognizer/dsl","exports"],
- function(__dependency1__, __exports__) {
- "use strict";
- var map = __dependency1__["default"];
+ this.firstChildMorph = this.lastChildMorph = null;
+ };
- var specials = [
- '/', '.', '*', '+', '?', '|',
- '(', ')', '[', ']', '{', '}', '\\'
- ];
+ prototype.destroy = function MorphList$destroy() {};
- var escapeRegex = new RegExp('(\\' + specials.join('|\\') + ')', 'g');
+ prototype.appendMorph = function MorphList$appendMorph(morph) {
+ this.insertBeforeMorph(morph, null);
+ };
- function isArray(test) {
- return Object.prototype.toString.call(test) === "[object Array]";
+ prototype.insertBeforeMorph = function MorphList$insertBeforeMorph(morph, referenceMorph) {
+ if (morph.parentMorphList !== null) {
+ morph.unlink();
}
+ if (referenceMorph && referenceMorph.parentMorphList !== this) {
+ throw new Error('The morph before which the new morph is to be inserted is not a child of this morph.');
+ }
- // A Segment represents a segment in the original route description.
- // Each Segment type provides an `eachChar` and `regex` method.
- //
- // The `eachChar` method invokes the callback with one or more character
- // specifications. A character specification consumes one or more input
- // characters.
- //
- // The `regex` method returns a regex fragment for the segment. If the
- // segment is a dynamic of star segment, the regex fragment also includes
- // a capture.
- //
- // A character specification contains:
- //
- // * `validChars`: a String with a list of all valid characters, or
- // * `invalidChars`: a String with a list of all invalid characters
- // * `repeat`: true if the character specification can repeat
+ var mountedMorph = this.mountedMorph;
- function StaticSegment(string) { this.string = string; }
- StaticSegment.prototype = {
- eachChar: function(callback) {
- var string = this.string, ch;
+ if (mountedMorph) {
- for (var i=0, l=string.length; i<l; i++) {
- ch = string.charAt(i);
- callback({ validChars: ch });
- }
- },
+ var parentNode = mountedMorph.firstNode.parentNode;
+ var referenceNode = referenceMorph ? referenceMorph.firstNode : mountedMorph.lastNode.nextSibling;
- regex: function() {
- return this.string.replace(escapeRegex, '\\$1');
- },
+ utils.insertBefore(parentNode, morph.firstNode, morph.lastNode, referenceNode);
- generate: function() {
- return this.string;
+ // was not in list mode replace current content
+ if (!this.firstChildMorph) {
+ utils.clear(this.mountedMorph.firstNode.parentNode, this.mountedMorph.firstNode, this.mountedMorph.lastNode);
}
- };
+ }
- function DynamicSegment(name) { this.name = name; }
- DynamicSegment.prototype = {
- eachChar: function(callback) {
- callback({ invalidChars: "/", repeat: true });
- },
+ morph.parentMorphList = this;
- regex: function() {
- return "([^/]+)";
- },
+ var previousMorph = referenceMorph ? referenceMorph.previousMorph : this.lastChildMorph;
+ if (previousMorph) {
+ previousMorph.nextMorph = morph;
+ morph.previousMorph = previousMorph;
+ } else {
+ this.firstChildMorph = morph;
+ }
- generate: function(params) {
- return params[this.name];
- }
- };
+ if (referenceMorph) {
+ referenceMorph.previousMorph = morph;
+ morph.nextMorph = referenceMorph;
+ } else {
+ this.lastChildMorph = morph;
+ }
- function StarSegment(name) { this.name = name; }
- StarSegment.prototype = {
- eachChar: function(callback) {
- callback({ invalidChars: "", repeat: true });
- },
+ this.firstChildMorph._syncFirstNode();
+ this.lastChildMorph._syncLastNode();
+ };
- regex: function() {
- return "(.+)";
- },
+ prototype.removeChildMorph = function MorphList$removeChildMorph(morph) {
+ if (morph.parentMorphList !== this) {
+ throw new Error('Cannot remove a morph from a parent it is not inside of');
+ }
- generate: function(params) {
- return params[this.name];
+ morph.destroy();
+ };
+
+ exports['default'] = MorphList;
+
+});
+enifed('morph-range/morph-list.umd', ['./morph-list'], function (MorphList) {
+
+ 'use strict';
+
+ (function (root, factory) {
+ if (typeof enifed === 'function' && enifed.amd) {
+ enifed([], factory);
+ } else if (typeof exports === 'object') {
+ module.exports = factory();
+ } else {
+ root.MorphList = factory();
+ }
+ })(undefined, function () {
+ return MorphList['default'];
+ });
+
+});
+enifed('morph-range/utils', ['exports'], function (exports) {
+
+ 'use strict';
+
+ exports.clear = clear;
+ exports.insertBefore = insertBefore;
+
+ // inclusive of both nodes
+ function clear(parentNode, firstNode, lastNode) {
+ if (!parentNode) {
+ return;
+ }
+
+ var node = firstNode;
+ var nextNode;
+ do {
+ nextNode = node.nextSibling;
+ parentNode.removeChild(node);
+ if (node === lastNode) {
+ break;
}
- };
+ node = nextNode;
+ } while (node);
+ }
- function EpsilonSegment() {}
- EpsilonSegment.prototype = {
- eachChar: function() {},
- regex: function() { return ""; },
- generate: function() { return ""; }
- };
+ function insertBefore(parentNode, firstNode, lastNode, _refNode) {
+ var node = lastNode;
+ var refNode = _refNode;
+ var prevNode;
+ do {
+ prevNode = node.previousSibling;
+ parentNode.insertBefore(node, refNode);
+ if (node === firstNode) {
+ break;
+ }
+ refNode = node;
+ node = prevNode;
+ } while (node);
+ }
- function parse(route, names, types) {
- // normalize route as not starting with a "/". Recognition will
- // also normalize.
- if (route.charAt(0) === "/") { route = route.substr(1); }
+});
+enifed('route-recognizer', ['exports', './route-recognizer/dsl'], function (exports, map) {
- var segments = route.split("/"), results = [];
+ 'use strict';
- for (var i=0, l=segments.length; i<l; i++) {
- var segment = segments[i], match;
+ var specials = ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\'];
- if (match = segment.match(/^:([^\/]+)$/)) {
- results.push(new DynamicSegment(match[1]));
- names.push(match[1]);
- types.dynamics++;
- } else if (match = segment.match(/^\*([^\/]+)$/)) {
- results.push(new StarSegment(match[1]));
- names.push(match[1]);
- types.stars++;
- } else if(segment === "") {
- results.push(new EpsilonSegment());
- } else {
- results.push(new StaticSegment(segment));
- types.statics++;
- }
+ var escapeRegex = new RegExp('(\\' + specials.join('|\\') + ')', 'g');
+
+ function isArray(test) {
+ return Object.prototype.toString.call(test) === '[object Array]';
+ }
+
+ // A Segment represents a segment in the original route description.
+ // Each Segment type provides an `eachChar` and `regex` method.
+ //
+ // The `eachChar` method invokes the callback with one or more character
+ // specifications. A character specification consumes one or more input
+ // characters.
+ //
+ // The `regex` method returns a regex fragment for the segment. If the
+ // segment is a dynamic of star segment, the regex fragment also includes
+ // a capture.
+ //
+ // A character specification contains:
+ //
+ // * `validChars`: a String with a list of all valid characters, or
+ // * `invalidChars`: a String with a list of all invalid characters
+ // * `repeat`: true if the character specification can repeat
+
+ function StaticSegment(string) {
+ this.string = string;
+ }
+ StaticSegment.prototype = {
+ eachChar: function (callback) {
+ var string = this.string,
+ ch;
+
+ for (var i = 0, l = string.length; i < l; i++) {
+ ch = string.charAt(i);
+ callback({ validChars: ch });
}
+ },
- return results;
+ regex: function () {
+ return this.string.replace(escapeRegex, '\\$1');
+ },
+
+ generate: function () {
+ return this.string;
}
+ };
- // A State has a character specification and (`charSpec`) and a list of possible
- // subsequent states (`nextStates`).
- //
- // If a State is an accepting state, it will also have several additional
- // properties:
- //
- // * `regex`: A regular expression that is used to extract parameters from paths
- // that reached this accepting state.
- // * `handlers`: Information on how to convert the list of captures into calls
- // to registered handlers with the specified parameters
- // * `types`: How many static, dynamic or star segments in this route. Used to
- // decide which route to use if multiple registered routes match a path.
- //
- // Currently, State is implemented naively by looping over `nextStates` and
- // comparing a character specification against a character. A more efficient
- // implementation would use a hash of keys pointing at one or more next states.
+ function DynamicSegment(name) {
+ this.name = name;
+ }
+ DynamicSegment.prototype = {
+ eachChar: function (callback) {
+ callback({ invalidChars: '/', repeat: true });
+ },
- function State(charSpec) {
- this.charSpec = charSpec;
- this.nextStates = [];
+ regex: function () {
+ return '([^/]+)';
+ },
+
+ generate: function (params) {
+ return params[this.name];
}
+ };
- State.prototype = {
- get: function(charSpec) {
- var nextStates = this.nextStates;
+ function StarSegment(name) {
+ this.name = name;
+ }
+ StarSegment.prototype = {
+ eachChar: function (callback) {
+ callback({ invalidChars: '', repeat: true });
+ },
- for (var i=0, l=nextStates.length; i<l; i++) {
- var child = nextStates[i];
+ regex: function () {
+ return '(.+)';
+ },
- var isEqual = child.charSpec.validChars === charSpec.validChars;
- isEqual = isEqual && child.charSpec.invalidChars === charSpec.invalidChars;
+ generate: function (params) {
+ return params[this.name];
+ }
+ };
- if (isEqual) { return child; }
- }
- },
+ function EpsilonSegment() {}
+ EpsilonSegment.prototype = {
+ eachChar: function () {},
+ regex: function () {
+ return '';
+ },
+ generate: function () {
+ return '';
+ }
+ };
- put: function(charSpec) {
- var state;
+ function parse(route, names, types) {
+ // normalize route as not starting with a "/". Recognition will
+ // also normalize.
+ if (route.charAt(0) === '/') {
+ route = route.substr(1);
+ }
- // If the character specification already exists in a child of the current
- // state, just return that state.
- if (state = this.get(charSpec)) { return state; }
+ var segments = route.split('/'),
+ results = [];
- // Make a new state for the character spec
- state = new State(charSpec);
+ for (var i = 0, l = segments.length; i < l; i++) {
+ var segment = segments[i],
+ match;
- // Insert the new state as a child of the current state
- this.nextStates.push(state);
+ if (match = segment.match(/^:([^\/]+)$/)) {
+ results.push(new DynamicSegment(match[1]));
+ names.push(match[1]);
+ types.dynamics++;
+ } else if (match = segment.match(/^\*([^\/]+)$/)) {
+ results.push(new StarSegment(match[1]));
+ names.push(match[1]);
+ types.stars++;
+ } else if (segment === '') {
+ results.push(new EpsilonSegment());
+ } else {
+ results.push(new StaticSegment(segment));
+ types.statics++;
+ }
+ }
- // If this character specification repeats, insert the new state as a child
- // of itself. Note that this will not trigger an infinite loop because each
- // transition during recognition consumes a character.
- if (charSpec.repeat) {
- state.nextStates.push(state);
- }
+ return results;
+ }
- // Return the new state
- return state;
- },
+ // A State has a character specification and (`charSpec`) and a list of possible
+ // subsequent states (`nextStates`).
+ //
+ // If a State is an accepting state, it will also have several additional
+ // properties:
+ //
+ // * `regex`: A regular expression that is used to extract parameters from paths
+ // that reached this accepting state.
+ // * `handlers`: Information on how to convert the list of captures into calls
+ // to registered handlers with the specified parameters
+ // * `types`: How many static, dynamic or star segments in this route. Used to
+ // decide which route to use if multiple registered routes match a path.
+ //
+ // Currently, State is implemented naively by looping over `nextStates` and
+ // comparing a character specification against a character. A more efficient
+ // implementation would use a hash of keys pointing at one or more next states.
- // Find a list of child states matching the next character
- match: function(ch) {
- // DEBUG "Processing `" + ch + "`:"
- var nextStates = this.nextStates,
- child, charSpec, chars;
+ function State(charSpec) {
+ this.charSpec = charSpec;
+ this.nextStates = [];
+ }
- // DEBUG " " + debugState(this)
- var returned = [];
+ State.prototype = {
+ get: function (charSpec) {
+ var nextStates = this.nextStates;
- for (var i=0, l=nextStates.length; i<l; i++) {
- child = nextStates[i];
+ for (var i = 0, l = nextStates.length; i < l; i++) {
+ var child = nextStates[i];
- charSpec = child.charSpec;
+ var isEqual = child.charSpec.validChars === charSpec.validChars;
+ isEqual = isEqual && child.charSpec.invalidChars === charSpec.invalidChars;
- if (typeof (chars = charSpec.validChars) !== 'undefined') {
- if (chars.indexOf(ch) !== -1) { returned.push(child); }
- } else if (typeof (chars = charSpec.invalidChars) !== 'undefined') {
- if (chars.indexOf(ch) === -1) { returned.push(child); }
- }
+ if (isEqual) {
+ return child;
}
-
- return returned;
}
+ },
- /** IF DEBUG
- , debug: function() {
- var charSpec = this.charSpec,
- debug = "[",
- chars = charSpec.validChars || charSpec.invalidChars;
+ put: function (charSpec) {
+ var state;
- if (charSpec.invalidChars) { debug += "^"; }
- debug += chars;
- debug += "]";
+ // If the character specification already exists in a child of the current
+ // state, just return that state.
+ if (state = this.get(charSpec)) {
+ return state;
+ }
- if (charSpec.repeat) { debug += "+"; }
+ // Make a new state for the character spec
+ state = new State(charSpec);
- return debug;
+ // Insert the new state as a child of the current state
+ this.nextStates.push(state);
+
+ // If this character specification repeats, insert the new state as a child
+ // of itself. Note that this will not trigger an infinite loop because each
+ // transition during recognition consumes a character.
+ if (charSpec.repeat) {
+ state.nextStates.push(state);
}
- END IF **/
- };
- /** IF DEBUG
- function debug(log) {
- console.log(log);
- }
+ // Return the new state
+ return state;
+ },
- function debugState(state) {
- return state.nextStates.map(function(n) {
- if (n.nextStates.length === 0) { return "( " + n.debug() + " [accepting] )"; }
- return "( " + n.debug() + " <then> " + n.nextStates.map(function(s) { return s.debug() }).join(" or ") + " )";
- }).join(", ")
- }
- END IF **/
+ // Find a list of child states matching the next character
+ match: function (ch) {
+ // DEBUG "Processing `" + ch + "`:"
+ var nextStates = this.nextStates,
+ child,
+ charSpec,
+ chars;
- // This is a somewhat naive strategy, but should work in a lot of cases
- // A better strategy would properly resolve /posts/:id/new and /posts/edit/:id.
- //
- // This strategy generally prefers more static and less dynamic matching.
- // Specifically, it
- //
- // * prefers fewer stars to more, then
- // * prefers using stars for less of the match to more, then
- // * prefers fewer dynamic segments to more, then
- // * prefers more static segments to more
- function sortSolutions(states) {
- return states.sort(function(a, b) {
- if (a.types.stars !== b.types.stars) { return a.types.stars - b.types.stars; }
+ // DEBUG " " + debugState(this)
+ var returned = [];
- if (a.types.stars) {
- if (a.types.statics !== b.types.statics) { return b.types.statics - a.types.statics; }
- if (a.types.dynamics !== b.types.dynamics) { return b.types.dynamics - a.types.dynamics; }
+ for (var i = 0, l = nextStates.length; i < l; i++) {
+ child = nextStates[i];
+
+ charSpec = child.charSpec;
+
+ if (typeof (chars = charSpec.validChars) !== 'undefined') {
+ if (chars.indexOf(ch) !== -1) {
+ returned.push(child);
+ }
+ } else if (typeof (chars = charSpec.invalidChars) !== 'undefined') {
+ if (chars.indexOf(ch) === -1) {
+ returned.push(child);
+ }
}
+ }
- if (a.types.dynamics !== b.types.dynamics) { return a.types.dynamics - b.types.dynamics; }
- if (a.types.statics !== b.types.statics) { return b.types.statics - a.types.statics; }
+ return returned;
+ }
- return 0;
- });
+ /** IF DEBUG
+ , debug: function() {
+ var charSpec = this.charSpec,
+ debug = "[",
+ chars = charSpec.validChars || charSpec.invalidChars;
+ if (charSpec.invalidChars) { debug += "^"; }
+ debug += chars;
+ debug += "]";
+ if (charSpec.repeat) { debug += "+"; }
+ return debug;
}
+ END IF **/
+ };
- function recognizeChar(states, ch) {
- var nextStates = [];
+ /** IF DEBUG
+ function debug(log) {
+ console.log(log);
+ }
- for (var i=0, l=states.length; i<l; i++) {
- var state = states[i];
+ function debugState(state) {
+ return state.nextStates.map(function(n) {
+ if (n.nextStates.length === 0) { return "( " + n.debug() + " [accepting] )"; }
+ return "( " + n.debug() + " <then> " + n.nextStates.map(function(s) { return s.debug() }).join(" or ") + " )";
+ }).join(", ")
+ }
+ END IF **/
- nextStates = nextStates.concat(state.match(ch));
+ // This is a somewhat naive strategy, but should work in a lot of cases
+ // A better strategy would properly resolve /posts/:id/new and /posts/edit/:id.
+ //
+ // This strategy generally prefers more static and less dynamic matching.
+ // Specifically, it
+ //
+ // * prefers fewer stars to more, then
+ // * prefers using stars for less of the match to more, then
+ // * prefers fewer dynamic segments to more, then
+ // * prefers more static segments to more
+ function sortSolutions(states) {
+ return states.sort(function (a, b) {
+ if (a.types.stars !== b.types.stars) {
+ return a.types.stars - b.types.stars;
}
- return nextStates;
- }
+ if (a.types.stars) {
+ if (a.types.statics !== b.types.statics) {
+ return b.types.statics - a.types.statics;
+ }
+ if (a.types.dynamics !== b.types.dynamics) {
+ return b.types.dynamics - a.types.dynamics;
+ }
+ }
- var oCreate = Object.create || function(proto) {
- function F() {}
- F.prototype = proto;
- return new F();
- };
+ if (a.types.dynamics !== b.types.dynamics) {
+ return a.types.dynamics - b.types.dynamics;
+ }
+ if (a.types.statics !== b.types.statics) {
+ return b.types.statics - a.types.statics;
+ }
- function RecognizeResults(queryParams) {
- this.queryParams = queryParams || {};
- }
- RecognizeResults.prototype = oCreate({
- splice: Array.prototype.splice,
- slice: Array.prototype.slice,
- push: Array.prototype.push,
- length: 0,
- queryParams: null
+ return 0;
});
+ }
- function findHandler(state, path, queryParams) {
- var handlers = state.handlers, regex = state.regex;
- var captures = path.match(regex), currentCapture = 1;
- var result = new RecognizeResults(queryParams);
+ function recognizeChar(states, ch) {
+ var nextStates = [];
- for (var i=0, l=handlers.length; i<l; i++) {
- var handler = handlers[i], names = handler.names, params = {};
+ for (var i = 0, l = states.length; i < l; i++) {
+ var state = states[i];
- for (var j=0, m=names.length; j<m; j++) {
- params[names[j]] = captures[currentCapture++];
- }
+ nextStates = nextStates.concat(state.match(ch));
+ }
- result.push({ handler: handler.handler, params: params, isDynamic: !!names.length });
- }
+ return nextStates;
+ }
- return result;
- }
+ var oCreate = Object.create || function (proto) {
+ function F() {}
+ F.prototype = proto;
+ return new F();
+ };
- function addSegment(currentState, segment) {
- segment.eachChar(function(ch) {
- var state;
+ function RecognizeResults(queryParams) {
+ this.queryParams = queryParams || {};
+ }
+ RecognizeResults.prototype = oCreate({
+ splice: Array.prototype.splice,
+ slice: Array.prototype.slice,
+ push: Array.prototype.push,
+ length: 0,
+ queryParams: null
+ });
- currentState = currentState.put(ch);
- });
+ function findHandler(state, path, queryParams) {
+ var handlers = state.handlers,
+ regex = state.regex;
+ var captures = path.match(regex),
+ currentCapture = 1;
+ var result = new RecognizeResults(queryParams);
- return currentState;
- }
+ for (var i = 0, l = handlers.length; i < l; i++) {
+ var handler = handlers[i],
+ names = handler.names,
+ params = {};
- function decodeQueryParamPart(part) {
- // http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1
- part = part.replace(/\+/gm, '%20');
- return decodeURIComponent(part);
+ for (var j = 0, m = names.length; j < m; j++) {
+ params[names[j]] = captures[currentCapture++];
+ }
+
+ result.push({ handler: handler.handler, params: params, isDynamic: !!names.length });
}
- // The main interface
+ return result;
+ }
- var RouteRecognizer = function() {
- this.rootState = new State();
- this.names = {};
- };
+ function addSegment(currentState, segment) {
+ segment.eachChar(function (ch) {
+ var state;
+ currentState = currentState.put(ch);
+ });
- RouteRecognizer.prototype = {
- add: function(routes, options) {
- var currentState = this.rootState, regex = "^",
- types = { statics: 0, dynamics: 0, stars: 0 },
- handlers = [], allSegments = [], name;
+ return currentState;
+ }
- var isEmpty = true;
+ function decodeQueryParamPart(part) {
+ // http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1
+ part = part.replace(/\+/gm, '%20');
+ return decodeURIComponent(part);
+ }
- for (var i=0, l=routes.length; i<l; i++) {
- var route = routes[i], names = [];
+ // The main interface
- var segments = parse(route.path, names, types);
+ var RouteRecognizer = function () {
+ this.rootState = new State();
+ this.names = {};
+ };
- allSegments = allSegments.concat(segments);
+ RouteRecognizer.prototype = {
+ add: function (routes, options) {
+ var currentState = this.rootState,
+ regex = '^',
+ types = { statics: 0, dynamics: 0, stars: 0 },
+ handlers = [],
+ allSegments = [],
+ name;
- for (var j=0, m=segments.length; j<m; j++) {
- var segment = segments[j];
+ var isEmpty = true;
- if (segment instanceof EpsilonSegment) { continue; }
+ for (var i = 0, l = routes.length; i < l; i++) {
+ var route = routes[i],
+ names = [];
- isEmpty = false;
+ var segments = parse(route.path, names, types);
- // Add a "/" for the new segment
- currentState = currentState.put({ validChars: "/" });
- regex += "/";
+ allSegments = allSegments.concat(segments);
- // Add a representation of the segment to the NFA and regex
- currentState = addSegment(currentState, segment);
- regex += segment.regex();
+ for (var j = 0, m = segments.length; j < m; j++) {
+ var segment = segments[j];
+
+ if (segment instanceof EpsilonSegment) {
+ continue;
}
- var handler = { handler: route.handler, names: names };
- handlers.push(handler);
- }
+ isEmpty = false;
- if (isEmpty) {
- currentState = currentState.put({ validChars: "/" });
- regex += "/";
+ // Add a "/" for the new segment
+ currentState = currentState.put({ validChars: '/' });
+ regex += '/';
+
+ // Add a representation of the segment to the NFA and regex
+ currentState = addSegment(currentState, segment);
+ regex += segment.regex();
}
- currentState.handlers = handlers;
- currentState.regex = new RegExp(regex + "$");
- currentState.types = types;
+ var handler = { handler: route.handler, names: names };
+ handlers.push(handler);
+ }
- if (name = options && options.as) {
- this.names[name] = {
- segments: allSegments,
- handlers: handlers
- };
- }
- },
+ if (isEmpty) {
+ currentState = currentState.put({ validChars: '/' });
+ regex += '/';
+ }
- handlersFor: function(name) {
- var route = this.names[name], result = [];
- if (!route) { throw new Error("There is no route named " + name); }
+ currentState.handlers = handlers;
+ currentState.regex = new RegExp(regex + '$');
+ currentState.types = types;
- for (var i=0, l=route.handlers.length; i<l; i++) {
- result.push(route.handlers[i]);
- }
+ if (name = options && options.as) {
+ this.names[name] = {
+ segments: allSegments,
+ handlers: handlers
+ };
+ }
+ },
- return result;
- },
+ handlersFor: function (name) {
+ var route = this.names[name],
+ result = [];
+ if (!route) {
+ throw new Error('There is no route named ' + name);
+ }
- hasRoute: function(name) {
- return !!this.names[name];
- },
+ for (var i = 0, l = route.handlers.length; i < l; i++) {
+ result.push(route.handlers[i]);
+ }
- generate: function(name, params) {
- var route = this.names[name], output = "";
- if (!route) { throw new Error("There is no route named " + name); }
+ return result;
+ },
- var segments = route.segments;
+ hasRoute: function (name) {
+ return !!this.names[name];
+ },
- for (var i=0, l=segments.length; i<l; i++) {
- var segment = segments[i];
+ generate: function (name, params) {
+ var route = this.names[name],
+ output = '';
+ if (!route) {
+ throw new Error('There is no route named ' + name);
+ }
- if (segment instanceof EpsilonSegment) { continue; }
+ var segments = route.segments;
- output += "/";
- output += segment.generate(params);
+ for (var i = 0, l = segments.length; i < l; i++) {
+ var segment = segments[i];
+
+ if (segment instanceof EpsilonSegment) {
+ continue;
}
- if (output.charAt(0) !== '/') { output = '/' + output; }
+ output += '/';
+ output += segment.generate(params);
+ }
- if (params && params.queryParams) {
- output += this.generateQueryString(params.queryParams, route.handlers);
- }
+ if (output.charAt(0) !== '/') {
+ output = '/' + output;
+ }
- return output;
- },
+ if (params && params.queryParams) {
+ output += this.generateQueryString(params.queryParams, route.handlers);
+ }
- generateQueryString: function(params, handlers) {
- var pairs = [];
- var keys = [];
- for(var key in params) {
- if (params.hasOwnProperty(key)) {
- keys.push(key);
- }
+ return output;
+ },
+
+ generateQueryString: function (params, handlers) {
+ var pairs = [];
+ var keys = [];
+ for (var key in params) {
+ if (params.hasOwnProperty(key)) {
+ keys.push(key);
}
- keys.sort();
- for (var i = 0, len = keys.length; i < len; i++) {
- key = keys[i];
- var value = params[key];
- if (value == null) {
- continue;
+ }
+ keys.sort();
+ for (var i = 0, len = keys.length; i < len; i++) {
+ key = keys[i];
+ var value = params[key];
+ if (value == null) {
+ continue;
+ }
+ var pair = encodeURIComponent(key);
+ if (isArray(value)) {
+ for (var j = 0, l = value.length; j < l; j++) {
+ var arrayPair = key + '[]' + '=' + encodeURIComponent(value[j]);
+ pairs.push(arrayPair);
}
- var pair = encodeURIComponent(key);
- if (isArray(value)) {
- for (var j = 0, l = value.length; j < l; j++) {
- var arrayPair = key + '[]' + '=' + encodeURIComponent(value[j]);
- pairs.push(arrayPair);
- }
- } else {
- pair += "=" + encodeURIComponent(value);
- pairs.push(pair);
- }
+ } else {
+ pair += '=' + encodeURIComponent(value);
+ pairs.push(pair);
}
+ }
- if (pairs.length === 0) { return ''; }
+ if (pairs.length === 0) {
+ return '';
+ }
- return "?" + pairs.join("&");
- },
+ return '?' + pairs.join('&');
+ },
- parseQueryString: function(queryString) {
- var pairs = queryString.split("&"), queryParams = {};
- for(var i=0; i < pairs.length; i++) {
- var pair = pairs[i].split('='),
- key = decodeQueryParamPart(pair[0]),
- keyLength = key.length,
- isArray = false,
- value;
- if (pair.length === 1) {
- value = 'true';
- } else {
- //Handle arrays
- if (keyLength > 2 && key.slice(keyLength -2) === '[]') {
- isArray = true;
- key = key.slice(0, keyLength - 2);
- if(!queryParams[key]) {
- queryParams[key] = [];
- }
+ parseQueryString: function (queryString) {
+ var pairs = queryString.split('&'),
+ queryParams = {};
+ for (var i = 0; i < pairs.length; i++) {
+ var pair = pairs[i].split('='),
+ key = decodeQueryParamPart(pair[0]),
+ keyLength = key.length,
+ isArray = false,
+ value;
+ if (pair.length === 1) {
+ value = 'true';
+ } else {
+ //Handle arrays
+ if (keyLength > 2 && key.slice(keyLength - 2) === '[]') {
+ isArray = true;
+ key = key.slice(0, keyLength - 2);
+ if (!queryParams[key]) {
+ queryParams[key] = [];
}
- value = pair[1] ? decodeQueryParamPart(pair[1]) : '';
}
- if (isArray) {
- queryParams[key].push(value);
- } else {
- queryParams[key] = value;
- }
+ value = pair[1] ? decodeQueryParamPart(pair[1]) : '';
}
- return queryParams;
- },
+ if (isArray) {
+ queryParams[key].push(value);
+ } else {
+ queryParams[key] = value;
+ }
+ }
+ return queryParams;
+ },
- recognize: function(path) {
- var states = [ this.rootState ],
- pathLen, i, l, queryStart, queryParams = {},
- isSlashDropped = false;
+ recognize: function (path) {
+ var states = [this.rootState],
+ pathLen,
+ i,
+ l,
+ queryStart,
+ queryParams = {},
+ isSlashDropped = false;
- queryStart = path.indexOf('?');
- if (queryStart !== -1) {
- var queryString = path.substr(queryStart + 1, path.length);
- path = path.substr(0, queryStart);
- queryParams = this.parseQueryString(queryString);
- }
+ queryStart = path.indexOf('?');
+ if (queryStart !== -1) {
+ var queryString = path.substr(queryStart + 1, path.length);
+ path = path.substr(0, queryStart);
+ queryParams = this.parseQueryString(queryString);
+ }
- path = decodeURI(path);
+ path = decodeURI(path);
- // DEBUG GROUP path
+ // DEBUG GROUP path
- if (path.charAt(0) !== "/") { path = "/" + path; }
+ if (path.charAt(0) !== '/') {
+ path = '/' + path;
+ }
- pathLen = path.length;
- if (pathLen > 1 && path.charAt(pathLen - 1) === "/") {
- path = path.substr(0, pathLen - 1);
- isSlashDropped = true;
- }
+ pathLen = path.length;
+ if (pathLen > 1 && path.charAt(pathLen - 1) === '/') {
+ path = path.substr(0, pathLen - 1);
+ isSlashDropped = true;
+ }
- for (i=0, l=path.length; i<l; i++) {
- states = recognizeChar(states, path.charAt(i));
- if (!states.length) { break; }
+ for (i = 0, l = path.length; i < l; i++) {
+ states = recognizeChar(states, path.charAt(i));
+ if (!states.length) {
+ break;
}
+ }
- // END DEBUG GROUP
+ // END DEBUG GROUP
- var solutions = [];
- for (i=0, l=states.length; i<l; i++) {
- if (states[i].handlers) { solutions.push(states[i]); }
+ var solutions = [];
+ for (i = 0, l = states.length; i < l; i++) {
+ if (states[i].handlers) {
+ solutions.push(states[i]);
}
+ }
- states = sortSolutions(solutions);
+ states = sortSolutions(solutions);
- var state = solutions[0];
+ var state = solutions[0];
- if (state && state.handlers) {
- // if a trailing slash was dropped and a star segment is the last segment
- // specified, put the trailing slash back
- if (isSlashDropped && state.regex.source.slice(-5) === "(.+)$") {
- path = path + "/";
- }
- return findHandler(state, path, queryParams);
+ if (state && state.handlers) {
+ // if a trailing slash was dropped and a star segment is the last segment
+ // specified, put the trailing slash back
+ if (isSlashDropped && state.regex.source.slice(-5) === '(.+)$') {
+ path = path + '/';
}
+ return findHandler(state, path, queryParams);
}
- };
+ }
+ };
- RouteRecognizer.prototype.map = map;
+ RouteRecognizer.prototype.map = map['default'];
- RouteRecognizer.VERSION = '0.1.5';
+ RouteRecognizer.VERSION = '0.1.5';
- __exports__["default"] = RouteRecognizer;
- });
-enifed("route-recognizer/dsl",
- ["exports"],
- function(__exports__) {
- "use strict";
- function Target(path, matcher, delegate) {
- this.path = path;
- this.matcher = matcher;
- this.delegate = delegate;
- }
+ exports['default'] = RouteRecognizer;
- Target.prototype = {
- to: function(target, callback) {
- var delegate = this.delegate;
+});
+enifed('route-recognizer/dsl', ['exports'], function (exports) {
- if (delegate && delegate.willAddRoute) {
- target = delegate.willAddRoute(this.matcher.target, target);
- }
+ 'use strict';
- this.matcher.add(this.path, target);
+ function Target(path, matcher, delegate) {
+ this.path = path;
+ this.matcher = matcher;
+ this.delegate = delegate;
+ }
- if (callback) {
- if (callback.length === 0) { throw new Error("You must have an argument in the function passed to `to`"); }
- this.matcher.addChild(this.path, target, callback, this.delegate);
- }
- return this;
+ Target.prototype = {
+ to: function (target, callback) {
+ var delegate = this.delegate;
+
+ if (delegate && delegate.willAddRoute) {
+ target = delegate.willAddRoute(this.matcher.target, target);
}
- };
- function Matcher(target) {
- this.routes = {};
- this.children = {};
- this.target = target;
+ this.matcher.add(this.path, target);
+
+ if (callback) {
+ if (callback.length === 0) {
+ throw new Error("You must have an argument in the function passed to `to`");
+ }
+ this.matcher.addChild(this.path, target, callback, this.delegate);
+ }
+ return this;
}
+ };
- Matcher.prototype = {
- add: function(path, handler) {
- this.routes[path] = handler;
- },
+ function Matcher(target) {
+ this.routes = {};
+ this.children = {};
+ this.target = target;
+ }
- addChild: function(path, target, callback, delegate) {
- var matcher = new Matcher(target);
- this.children[path] = matcher;
+ Matcher.prototype = {
+ add: function (path, handler) {
+ this.routes[path] = handler;
+ },
- var match = generateMatch(path, matcher, delegate);
+ addChild: function (path, target, callback, delegate) {
+ var matcher = new Matcher(target);
+ this.children[path] = matcher;
- if (delegate && delegate.contextEntered) {
- delegate.contextEntered(target, match);
- }
+ var match = generateMatch(path, matcher, delegate);
- callback(match);
+ if (delegate && delegate.contextEntered) {
+ delegate.contextEntered(target, match);
}
- };
- function generateMatch(startingPath, matcher, delegate) {
- return function(path, nestedCallback) {
- var fullPath = startingPath + path;
-
- if (nestedCallback) {
- nestedCallback(generateMatch(fullPath, matcher, delegate));
- } else {
- return new Target(startingPath + path, matcher, delegate);
- }
- };
+ callback(match);
}
+ };
- function addRoute(routeArray, path, handler) {
- var len = 0;
- for (var i=0, l=routeArray.length; i<l; i++) {
- len += routeArray[i].path.length;
+ function generateMatch(startingPath, matcher, delegate) {
+ return function (path, nestedCallback) {
+ var fullPath = startingPath + path;
+
+ if (nestedCallback) {
+ nestedCallback(generateMatch(fullPath, matcher, delegate));
+ } else {
+ return new Target(startingPath + path, matcher, delegate);
}
+ };
+ }
- path = path.substr(len);
- var route = { path: path, handler: handler };
- routeArray.push(route);
+ function addRoute(routeArray, path, handler) {
+ var len = 0;
+ for (var i = 0, l = routeArray.length; i < l; i++) {
+ len += routeArray[i].path.length;
}
- function eachRoute(baseRoute, matcher, callback, binding) {
- var routes = matcher.routes;
+ path = path.substr(len);
+ var route = { path: path, handler: handler };
+ routeArray.push(route);
+ }
- for (var path in routes) {
- if (routes.hasOwnProperty(path)) {
- var routeArray = baseRoute.slice();
- addRoute(routeArray, path, routes[path]);
+ function eachRoute(baseRoute, matcher, callback, binding) {
+ var routes = matcher.routes;
- if (matcher.children[path]) {
- eachRoute(routeArray, matcher.children[path], callback, binding);
- } else {
- callback.call(binding, routeArray);
- }
+ for (var path in routes) {
+ if (routes.hasOwnProperty(path)) {
+ var routeArray = baseRoute.slice();
+ addRoute(routeArray, path, routes[path]);
+
+ if (matcher.children[path]) {
+ eachRoute(routeArray, matcher.children[path], callback, binding);
+ } else {
+ callback.call(binding, routeArray);
}
}
}
+ }
- __exports__["default"] = function(callback, addRouteCallback) {
- var matcher = new Matcher();
+ exports['default'] = function (callback, addRouteCallback) {
+ var matcher = new Matcher();
- callback(generateMatch("", matcher, this.delegate));
+ callback(generateMatch("", matcher, this.delegate));
- eachRoute([], matcher, function(route) {
- if (addRouteCallback) { addRouteCallback(this, route); }
- else { this.add(route); }
- }, this);
- }
- });
+ eachRoute([], matcher, function (route) {
+ if (addRouteCallback) {
+ addRouteCallback(this, route);
+ } else {
+ this.add(route);
+ }
+ }, this);
+ }
+
+});
enifed("router",
["./router/router","exports"],
function(__dependency1__, __exports__) {
"use strict";
var Router = __dependency1__["default"];
\ No newline at end of file