- Ember.View.create({
- attributeBindings: ['type'],
- type: 'button'
- });
-
- If the value of the property is a Boolean, the name of that property is
- added as an attribute.
-
- // Renders something like
- Ember.View.create({
- attributeBindings: ['enabled'],
- enabled: true
- });
- */
- attributeBindings: [],
-
- state: 'preRender',
-
- // .......................................................
- // CORE DISPLAY METHODS
- //
-
- /**
- @private
-
- Setup a view, but do not finish waking it up.
- - configure childViews
- - register the view with the global views hash, which is used for event
- dispatch
- */
- init: function () {
- this._super();
-
- // Register the view for event handling. This hash is used by
- // Ember.RootResponder to dispatch incoming events.
- Ember.View.views[get(this, 'elementId')] = this;
-
- var childViews = get(this, '_childViews').slice();
-
- // setup child views. be sure to clone the child views array first
- set(this, '_childViews', childViews);
-
- ember_assert("Only arrays are allowed for 'classNameBindings'", Ember.typeOf(this.classNameBindings) === 'array');
- this.classNameBindings = Ember.A(this.classNameBindings.slice());
-
- ember_assert("Only arrays are allowed for 'classNames'", Ember.typeOf(this.classNames) === 'array');
- this.classNames = Ember.A(this.classNames.slice());
-
- var viewController = get(this, 'viewController');
- if (viewController) {
- viewController = Ember.getPath(viewController);
- if (viewController) {
- set(viewController, 'view', this);
- }
- }
- },
-
- appendChild: function (view, options) {
- return this.invokeForState('appendChild', view, options);
- },
-
- /**
- Removes the child view from the parent view.
-
- @param {Ember.View} view
- @returns {Ember.View} receiver
- */
- removeChild: function (view) {
- // If we're destroying, the entire subtree will be
- // freed, and the DOM will be handled separately,
- // so no need to mess with childViews.
- if (this.isDestroying) {
- return;
- }
-
- // update parent node
- set(view, '_parentView', null);
-
- // remove view from childViews array.
- var childViews = get(this, '_childViews');
- Ember.ArrayUtils.removeObject(childViews, view);
-
- this.propertyDidChange('childViews');
-
- return this;
- },
-
- /**
- Removes all children from the parentView.
-
- @returns {Ember.View} receiver
- */
- removeAllChildren: function () {
- return this.mutateChildViews(function (view) {
- this.removeChild(view);
- });
- },
-
- destroyAllChildren: function () {
- return this.mutateChildViews(function (view) {
- view.destroy();
- });
- },
-
- /**
- Removes the view from its parentView, if one is found. Otherwise
- does nothing.
-
- @returns {Ember.View} receiver
- */
- removeFromParent: function () {
- var parent = get(this, '_parentView');
-
- // Remove DOM element from parent
- this.remove();
-
- if (parent) {
- parent.removeChild(this);
- }
- return this;
- },
-
- /**
- You must call `destroy` on a view to destroy the view (and all of its
- child views). This will remove the view from any parent node, then make
- sure that the DOM element managed by the view can be released by the
- memory manager.
- */
- willDestroy: function () {
- // calling this._super() will nuke computed properties and observers,
- // so collect any information we need before calling super.
- var childViews = get(this, '_childViews'),
- parent = get(this, '_parentView'),
- elementId = get(this, 'elementId'),
- childLen;
-
- // destroy the element -- this will avoid each child view destroying
- // the element over and over again...
- if (!this.removedFromDOM) {
- this.destroyElement();
- }
-
- // remove from non-virtual parent view if viewName was specified
- if (this.viewName) {
- var nonVirtualParentView = get(this, 'parentView');
- if (nonVirtualParentView) {
- set(nonVirtualParentView, this.viewName, null);
- }
- }
-
- // 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);
- }
-
- this.state = 'destroyed';
-
- childLen = get(childViews, 'length');
- for (var i = childLen - 1; i >= 0; i--) {
- childViews[i].removedFromDOM = true;
- childViews[i].destroy();
- }
-
- // next remove view from global hash
- delete Ember.View.views[get(this, 'elementId')];
- },
-
- /**
- Instantiates a view to be added to the childViews array during view
- initialization. You generally will not call this method directly unless
- you are overriding createChildViews(). Note that this method will
- automatically configure the correct settings on the new view instance to
- act as a child of the parent.
-
- @param {Class} viewClass
- @param {Hash} [attrs] Attributes to add
- @returns {Ember.View} new instance
- @test in createChildViews
- */
- createChildView: function (view, attrs) {
- var coreAttrs;
-
- if (Ember.View.detect(view)) {
- coreAttrs = { _parentView: this };
- if (attrs) {
- view = view.create(coreAttrs, attrs);
- } else {
- view = view.create(coreAttrs);
- }
-
- var viewName = view.viewName;
-
- // don't set the property on a virtual view, as they are invisible to
- // consumers of the view API
- if (viewName) {
- set(get(this, 'concreteView'), viewName, view);
- }
- } else {
- ember_assert('must pass instance of View', view instanceof Ember.View);
- set(view, '_parentView', this);
- }
-
- return view;
- },
-
- becameVisible: Ember.K,
- becameHidden: Ember.K,
-
- /**
- @private
-
- When the view's `isVisible` property changes, toggle the visibility
- element of the actual DOM element.
- */
- _isVisibleDidChange: Ember.observer(function () {
- var isVisible = get(this, 'isVisible');
-
- this.$().toggle(isVisible);
-
- if (this._isAncestorHidden()) {
- return;
- }
-
- if (isVisible) {
- this._notifyBecameVisible();
- } else {
- this._notifyBecameHidden();
- }
- }, 'isVisible'),
-
- _notifyBecameVisible: function () {
- this.fire('becameVisible');
-
- this.forEachChildView(function (view) {
- var isVisible = get(view, 'isVisible');
-
- if (isVisible || isVisible === null) {
- view._notifyBecameVisible();
- }
- });
- },
-
- _notifyBecameHidden: function () {
- this.fire('becameHidden');
- this.forEachChildView(function (view) {
- var isVisible = get(view, 'isVisible');
-
- if (isVisible || isVisible === null) {
- view._notifyBecameHidden();
- }
- });
- },
-
- _isAncestorHidden: function () {
- var parent = get(this, 'parentView');
-
- while (parent) {
- if (get(parent, 'isVisible') === false) {
- return true;
- }
-
- parent = get(parent, 'parentView');
- }
-
- return false;
- },
-
- clearBuffer: function () {
- this.invokeRecursively(function (view) {
- this.buffer = null;
- });
- },
-
- transitionTo: function (state, children) {
- this.state = state;
-
- if (children !== false) {
- this.forEachChildView(function (view) {
- view.transitionTo(state);
- });
- }
- },
-
- /**
- @private
-
- Override the default event firing from Ember.Evented to
- also call methods with the given name.
- */
- fire: function (name) {
- if (this[name]) {
- this[name].apply(this, [].slice.call(arguments, 1));
- }
- this._super.apply(this, arguments);
- },
-
- // .......................................................
- // EVENT HANDLING
- //
-
- /**
- @private
-
- Handle events from `Ember.EventDispatcher`
- */
- handleEvent: function (eventName, evt) {
- return this.invokeForState('handleEvent', eventName, evt);
- }
-
- });
-
- /**
- Describe how the specified actions should behave in the various
- states that a view can exist in. Possible states:
-
- * preRender: when a view is first instantiated, and after its
- element was destroyed, it is in the preRender state
- * inBuffer: once a view has been rendered, but before it has
- been inserted into the DOM, it is in the inBuffer state
- * inDOM: once a view has been inserted into the DOM it is in
- the inDOM state. A view spends the vast majority of its
- existence in this state.
- * destroyed: once a view has been destroyed (using the destroy
- method), it is in this state. No further actions can be invoked
- on a destroyed view.
- */
-
- // in the destroyed state, everything is illegal
-
- // before rendering has begun, all legal manipulations are noops.
-
- // inside the buffer, legal manipulations are done on the buffer
-
- // once the view has been inserted into the DOM, legal manipulations
- // are done on the DOM element.
-
- /** @private */
- var DOMManager = {
- prepend: function (view, childView) {
- childView._insertElementLater(function () {
- var element = view.$();
- element.prepend(childView.$());
- });
- },
-
- after: function (view, nextView) {
- nextView._insertElementLater(function () {
- var element = view.$();
- element.after(nextView.$());
- });
- },
-
- replace: function (view) {
- var element = get(view, 'element');
-
- set(view, 'element', null);
-
- view._insertElementLater(function () {
- Ember.$(element).replaceWith(get(view, 'element'));
- });
- },
-
- remove: function (view) {
- var elem = get(view, 'element');
-
- set(view, 'element', null);
- view._lastInsert = null;
-
- Ember.$(elem).remove();
- },
-
- empty: function (view) {
- view.$().empty();
- }
- };
-
- Ember.View.reopen({
- states: Ember.View.states,
- domManager: DOMManager
- });
-
-// Create a global view hash.
- Ember.View.views = {};
-
-// If someone overrides the child views computed property when
-// defining their class, we want to be able to process the user's
-// supplied childViews and then restore the original computed property
-// at view initialization time. This happens in Ember.ContainerView's init
-// method.
- Ember.View.childViewsProperty = childViewsProperty;
-
- Ember.View.applyAttributeBindings = function (elem, name, value) {
- var type = Ember.typeOf(value);
- var currentValue = elem.attr(name);
-
- // if this changes, also change the logic in ember-handlebars/lib/helpers/binding.js
- if ((type === 'string' || (type === 'number' && !isNaN(value))) && value !== currentValue) {
- elem.attr(name, value);
- } else if (value && type === 'boolean') {
- elem.attr(name, name);
- } else if (!value) {
- elem.removeAttr(name);
- }
- };
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember - JavaScript Application Framework
-// Copyright: ©2006-2011 Strobe Inc. and contributors.
-// Portions ©2008-2011 Apple Inc. All rights reserved.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- var get = Ember.get, set = Ember.set;
-
- Ember.View.states = {
- _default: {
- // appendChild is only legal while rendering the buffer.
- appendChild: function () {
- throw "You can't use appendChild outside of the rendering process";
- },
-
- $: function () {
- return Ember.$();
- },
-
- getElement: function () {
- return null;
- },
-
- // Handle events from `Ember.EventDispatcher`
- handleEvent: function () {
- return true; // continue event propagation
- },
-
- destroyElement: function (view) {
- set(view, 'element', null);
- view._lastInsert = null;
- return view;
- }
- }
- };
-
- Ember.View.reopen({
- states: Ember.View.states
- });
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember - JavaScript Application Framework
-// Copyright: ©2006-2011 Strobe Inc. and contributors.
-// Portions ©2008-2011 Apple Inc. All rights reserved.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- Ember.View.states.preRender = {
- parentState: Ember.View.states._default,
-
- // a view leaves the preRender state once its element has been
- // created (createElement).
- insertElement: function (view, fn) {
- if (view._lastInsert !== Ember.guidFor(fn)) {
- return;
- }
- view.createElement();
- view._notifyWillInsertElement(true);
- // after createElement, the view will be in the hasElement state.
- fn.call(view);
- view.transitionTo('inDOM');
- view._notifyDidInsertElement();
- },
-
- // This exists for the removal warning, remove later
- $: function (view) {
- if (view._willInsertElementAccessUnsupported) {
- console.error("Getting element from willInsertElement is unreliable and no longer supported.");
- }
- return Ember.$();
- },
-
- empty: Ember.K,
-
- // This exists for the removal warning, remove later
- getElement: function (view) {
- if (view._willInsertElementAccessUnsupported) {
- console.error("Getting element from willInsertElement is unreliable and no longer supported.");
- }
- return null;
- },
-
- setElement: function (view, value) {
- view.beginPropertyChanges();
- view.invalidateRecursively('element');
-
- if (value !== null) {
- view.transitionTo('hasElement');
- }
-
- view.endPropertyChanges();
-
- return value;
- }
- };
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember - JavaScript Application Framework
-// Copyright: ©2006-2011 Strobe Inc. and contributors.
-// Portions ©2008-2011 Apple Inc. All rights reserved.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- var get = Ember.get, set = Ember.set, meta = Ember.meta;
-
- Ember.View.states.inBuffer = {
- parentState: Ember.View.states._default,
-
- $: 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 Ember.$();
- },
-
- // when a view is rendered in a buffer, rerendering it simply
- // replaces the existing buffer with a new one
- rerender: function (view) {
- ember_deprecate("Something you did caused a view to re-render after it rendered but before it was inserted into the DOM. Because this is avoidable and the cause of significant performance issues in applications, this behavior is deprecated. If you want to use the debugger to find out what caused this, you can set ENV.RAISE_ON_DEPRECATION to true.");
-
- view._notifyWillRerender();
-
- view.clearRenderedChildren();
- view.renderToBuffer(view.buffer, 'replaceWith');
- },
-
- // 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;
-
- childView = this.createChildView(childView, options);
- get(view, '_childViews').push(childView);
-
- childView.renderToBuffer(buffer);
-
- view.propertyDidChange('childViews');
-
- return childView;
- },
-
- // when a view is rendered in a buffer, destroying the
- // element will simply destroy the buffer and put the
- // state back into the preRender state.
- destroyElement: function (view) {
- view.clearBuffer();
- view._notifyWillDestroyElement();
- view.transitionTo('preRender');
-
- return view;
- },
-
- empty: function () {
- throw "EWOT";
- },
-
- // It should be impossible for a rendered view to be scheduled for
- // insertion.
- insertElement: function () {
- throw "You can't insert an element that has already been rendered";
- },
-
- setElement: function (view, value) {
- view.invalidateRecursively('element');
-
- if (value === null) {
- view.transitionTo('preRender');
- } else {
- view.clearBuffer();
- view.transitionTo('hasElement');
- }
-
- return value;
- }
- };
-
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember - JavaScript Application Framework
-// Copyright: ©2006-2011 Strobe Inc. and contributors.
-// Portions ©2008-2011 Apple Inc. All rights reserved.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- var get = Ember.get, set = Ember.set, meta = Ember.meta;
-
- Ember.View.states.hasElement = {
- parentState: Ember.View.states._default,
-
- $: function (view, sel) {
- var elem = get(view, 'element');
- return sel ? Ember.$(sel, elem) : Ember.$(elem);
- },
-
- getElement: function (view) {
- var parent = get(view, 'parentView');
- if (parent) {
- parent = get(parent, 'element');
- }
- if (parent) {
- return view.findElementInParentElement(parent);
- }
- return Ember.$("#" + get(view, 'elementId'))[0];
- },
-
- setElement: function (view, value) {
- if (value === null) {
- view.invalidateRecursively('element');
-
- view.transitionTo('preRender');
- } else {
- throw "You cannot set an element to a non-null value when the element is already in the DOM.";
- }
-
- return value;
- },
-
- // once the view has been inserted into the DOM, rerendering is
- // deferred to allow bindings to synchronize.
- rerender: function (view) {
- view._notifyWillRerender();
-
- view.clearRenderedChildren();
-
- view.domManager.replace(view);
- return 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._notifyWillDestroyElement();
- view.domManager.remove(view);
- return view;
- },
-
- empty: function (view) {
- var _childViews = get(view, '_childViews'), len, idx;
- if (_childViews) {
- len = get(_childViews, 'length');
- for (idx = 0; idx < len; idx++) {
- _childViews[idx]._notifyWillDestroyElement();
- }
- }
- view.domManager.empty(view);
- },
-
- // Handle events from `Ember.EventDispatcher`
- handleEvent: function (view, eventName, evt) {
- var handler = view[eventName];
- if (Ember.typeOf(handler) === 'function') {
- return handler.call(view, evt);
- } else {
- return true; // continue event propagation
- }
- }
- };
-
- Ember.View.states.inDOM = {
- parentState: Ember.View.states.hasElement,
-
- insertElement: function (view, fn) {
- if (view._lastInsert !== Ember.guidFor(fn)) {
- return;
- }
- throw "You can't insert an element into the DOM that has already been inserted";
- }
- };
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember - JavaScript Application Framework
-// Copyright: ©2006-2011 Strobe Inc. and contributors.
-// Portions ©2008-2011 Apple Inc. All rights reserved.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- var destroyedError = "You can't call %@ on a destroyed view", fmt = Ember.String.fmt;
-
- Ember.View.states.destroyed = {
- parentState: Ember.View.states._default,
-
- appendChild: function () {
- throw fmt(destroyedError, ['appendChild']);
- },
- rerender: function () {
- throw fmt(destroyedError, ['rerender']);
- },
- destroyElement: function () {
- throw fmt(destroyedError, ['destroyElement']);
- },
- empty: function () {
- throw fmt(destroyedError, ['empty']);
- },
-
- setElement: function () {
- throw fmt(destroyedError, ["set('element', ...)"]);
- },
-
- // Since element insertion is scheduled, don't do anything if
- // the view has been destroyed between scheduling and execution
- insertElement: Ember.K
- };
-
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember - JavaScript Application Framework
-// Copyright: ©2006-2011 Strobe Inc. and contributors.
-// Portions ©2008-2011 Apple Inc. All rights reserved.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember - JavaScript Application Framework
-// Copyright: ©2006-2011 Strobe Inc. and contributors.
-// Portions ©2008-2011 Apple Inc. All rights reserved.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- var get = Ember.get, set = Ember.set, meta = Ember.meta;
- var forEach = Ember.ArrayUtils.forEach;
-
- var childViewsProperty = Ember.computed(function () {
- return get(this, '_childViews');
- }).property('_childViews').cacheable();
-
- /**
- @class
-
- A `ContainerView` is an `Ember.View` subclass that allows for manual or programatic
- management of a view's `childViews` array that will correctly update the `ContainerView`
- instance's rendered DOM representation.
-
- ## Setting Initial Child Views
- The initial array of child views can be set in one of two ways. You can provide
- a `childViews` property at creation time that contains instance of `Ember.View`:
-
-
- aContainer = Ember.ContainerView.create({
- childViews: [Ember.View.create(), Ember.View.create()]
- })
-
- You can also provide a list of property names whose values are instances of `Ember.View`:
-
- aContainer = Ember.ContainerView.create({
- childViews: ['aView', 'bView', 'cView'],
- aView: Ember.View.create(),
- bView: Ember.View.create()
- cView: Ember.View.create()
- })
-
- The two strategies can be combined:
-
- aContainer = Ember.ContainerView.create({
- childViews: ['aView', Ember.View.create()],
- aView: Ember.View.create()
- })
-
- Each child view's rendering will be inserted into the container's rendered HTML in the same
- order as its position in the `childViews` property.
-
- ## Adding and Removing Child Views
- The views in a container's `childViews` array should be added and removed by manipulating
- the `childViews` property directly.
-
- To remove a view pass that view into a `removeObject` call on the container's `childViews` property.
-
- Given an empty `` the following code
-
- aContainer = Ember.ContainerView.create({
- classNames: ['the-container'],
- childViews: ['aView', 'bView'],
- aView: Ember.View.create({
- template: Ember.Handlebars.compile("A")
- }),
- bView: Ember.View.create({
- template: Ember.Handlebars.compile("B")
- })
- })
-
- aContainer.appendTo('body')
-
- Results in the HTML
-
-
-
- Removing a view
-
- aContainer.get('childViews') // [aContainer.aView, aContainer.bView]
- aContainer.get('childViews').removeObject(aContainer.get('bView'))
- aContainer.get('childViews') // [aContainer.aView]
-
- Will result in the following HTML
-
-
-
-
- Similarly, adding a child view is accomplished by adding `Ember.View` instances to the
- container's `childViews` property.
-
- Given an empty `` the following code
-
- aContainer = Ember.ContainerView.create({
- classNames: ['the-container'],
- childViews: ['aView', 'bView'],
- aView: Ember.View.create({
- template: Ember.Handlebars.compile("A")
- }),
- bView: Ember.View.create({
- template: Ember.Handlebars.compile("B")
- })
- })
-
- aContainer.appendTo('body')
-
- Results in the HTML
-
-
-
- Adding a view
-
- AnotherViewClass = Ember.View.extend({
- template: Ember.Handlebars.compile("Another view")
- })
-
- aContainer.get('childViews') // [aContainer.aView, aContainer.bView]
- aContainer.get('childViews').pushObject(AnotherViewClass.create())
- aContainer.get('childViews') // [aContainer.aView,
]
-
- Will result in the following HTML
-
-
-
-
- Direct manipulation of childViews presence or absence in the DOM via calls to
- `remove` or `removeFromParent` or calls to a container's `removeChild` may not behave
- correctly.
-
- Calling `remove()` on a child view will remove the view's HTML, but it will remain as part of its
- container's `childView`s property.
-
- Calling `removeChild()` on the container will remove the passed view instance from the container's
- `childView`s but keep its HTML within the container's rendered view.
-
- Calling `removeFromParent()` behaves as expected but should be avoided in favor of direct
- manipulation of a container's `childViews` property.
-
- aContainer = Ember.ContainerView.create({
- classNames: ['the-container'],
- childViews: ['aView', 'bView'],
- aView: Ember.View.create({
- template: Ember.Handlebars.compile("A")
- }),
- bView: Ember.View.create({
- template: Ember.Handlebars.compile("B")
- })
- })
-
- aContainer.appendTo('body')
-
- Results in the HTML
-
-
-
- Calling `aContainer.get('aView').removeFromParent()` will result in the following HTML
-
-
-
- And the `Ember.View` instance stored in `aContainer.aView` will be removed from `aContainer`'s
- `childViews` array.
-
-
- ## Templates and Layout
- A `template`, `templateName`, `defaultTemplate`, `layout`, `layoutName` or `defaultLayout`
- property on a container view will not result in the template or layout being rendered.
- The HTML contents of a `Ember.ContainerView`'s DOM representation will only be the rendered HTML
- of its child views.
-
- @extends Ember.View
- */
-
- Ember.ContainerView = Ember.View.extend({
-
- init: function () {
- var childViews = get(this, 'childViews');
- Ember.defineProperty(this, 'childViews', childViewsProperty);
-
- this._super();
-
- var _childViews = get(this, '_childViews');
-
- forEach(childViews, function (viewName, idx) {
- var view;
-
- if ('string' === typeof viewName) {
- view = get(this, viewName);
- view = this.createChildView(view);
- set(this, viewName, view);
- } else {
- view = this.createChildView(viewName);
- }
-
- _childViews[idx] = view;
- }, this);
-
- // Make the _childViews array observable
- Ember.A(_childViews);
-
- // Sets up an array observer on the child views array. This
- // observer will detect when child views are added or removed
- // and update the DOM to reflect the mutation.
- get(this, 'childViews').addArrayObserver(this, {
- willChange: 'childViewsWillChange',
- didChange: 'childViewsDidChange'
- });
- },
-
- /**
- Instructs each child view to render to the passed render buffer.
-
- @param {Ember.RenderBuffer} buffer the buffer to render to
- @private
- */
- render: function (buffer) {
- this.forEachChildView(function (view) {
- view.renderToBuffer(buffer);
- });
- },
-
- /**
- When the container view is destroyed, tear down the child views
- array observer.
-
- @private
- */
- willDestroy: function () {
- get(this, 'childViews').removeArrayObserver(this, {
- willChange: 'childViewsWillChange',
- didChange: 'childViewsDidChange'
- });
-
- this._super();
- },
-
- /**
- 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
- @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) {
- if (removed === 0) {
- return;
- }
-
- var changedViews = views.slice(start, start + removed);
- this.initializeViews(changedViews, null, null);
-
- this.invokeForState('childViewsWillChange', views, start, removed);
- },
-
- /**
- 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
- @param {Ember.Array} views the array of child views afte the mutation has occurred
- @param {Number} start the start position of the mutation
- @param {Number} removed the number of child views removed
- @param {Number} the number of child views added
- */
- childViewsDidChange: function (views, start, removed, added) {
- var len = get(views, 'length');
-
- // No new child views were added; bail out.
- if (added === 0) return;
-
- var changedViews = views.slice(start, start + added);
- this.initializeViews(changedViews, this, get(this, 'templateData'));
-
- // Let the current state handle the changes
- this.invokeForState('childViewsDidChange', views, start, added);
- },
-
- initializeViews: function (views, parentView, templateData) {
- forEach(views, function (view) {
- set(view, '_parentView', parentView);
- set(view, 'templateData', templateData);
- });
- },
-
- /**
- Schedules a child view to be inserted into the DOM after bindings have
- finished syncing for this run loop.
-
- @param {Ember.View} view the child view to insert
- @param {Ember.View} prev the child view after which the specified view should
- be inserted
- @private
- */
- _scheduleInsertion: function (view, prev) {
- if (prev) {
- prev.domManager.after(prev, view);
- } else {
- this.domManager.prepend(this, view);
- }
- }
- });
-
-// Ember.ContainerView extends the default view states to provide different
-// behavior for childViewsWillChange and childViewsDidChange.
- Ember.ContainerView.states = {
- parent: Ember.View.states,
-
- inBuffer: {
- childViewsDidChange: function (parentView, views, start, added) {
- var buffer = parentView.buffer,
- startWith, prev, prevBuffer, view;
-
- // Determine where to begin inserting the child view(s) in the
- // render buffer.
- if (start === 0) {
- // If views were inserted at the beginning, prepend the first
- // view to the render buffer, then begin inserting any
- // additional views at the beginning.
- view = views[start];
- startWith = start + 1;
- view.renderToBuffer(buffer, 'prepend');
- } else {
- // Otherwise, just insert them at the same place as the child
- // views mutation.
- view = views[start - 1];
- startWith = start;
- }
-
- for (var i = startWith; i < start + added; i++) {
- prev = view;
- view = views[i];
- prevBuffer = prev.buffer;
- view.renderToBuffer(prevBuffer, 'insertAfter');
- }
- }
- },
-
- hasElement: {
- childViewsWillChange: function (view, views, start, removed) {
- for (var i = start; i < start + removed; i++) {
- views[i].remove();
- }
- },
-
- childViewsDidChange: function (view, views, start, added) {
- // If the DOM element for this container view already exists,
- // schedule each child view to insert its DOM representation after
- // bindings have finished syncing.
- var prev = start === 0 ? null : views[start - 1];
-
- for (var i = start; i < start + added; i++) {
- view = views[i];
- this._scheduleInsertion(view, prev);
- prev = view;
- }
- }
- }
- };
-
- Ember.ContainerView.states.inDOM = {
- parentState: Ember.ContainerView.states.hasElement
- };
-
- Ember.ContainerView.reopen({
- states: Ember.ContainerView.states
- });
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember - JavaScript Application Framework
-// Copyright: ©2006-2011 Strobe Inc. and contributors.
-// Portions ©2008-2011 Apple Inc. All rights reserved.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- var get = Ember.get, set = Ember.set, fmt = Ember.String.fmt;
-
- /**
- @class
-
- `Ember.CollectionView` is an `Ember.View` descendent responsible for managing a
- collection (an array or array-like object) by maintaing a child view object and
- associated DOM representation for each item in the array and ensuring that child
- views and their associated rendered HTML are updated when items in the array
- are added, removed, or replaced.
-
- ## Setting content
- The managed collection of objects is referenced as the `Ember.CollectionView` instance's
- `content` property.
-
- someItemsView = Ember.CollectionView.create({
- content: ['A', 'B','C']
- })
-
- The view for each item in the collection will have its `content` property set
- to the item.
-
- ## Specifying itemViewClass
- By default the view class for each item in the managed collection will be an instance
- of `Ember.View`. You can supply a different class by setting the `CollectionView`'s
- `itemViewClass` property.
-
- Given an empty `` and the following code:
-
-
- someItemsView = Ember.CollectionView.create({
- classNames: ['a-collection'],
- content: ['A','B','C'],
- itemViewClass: Ember.View.extend({
- template: Ember.Handlebars.compile("the letter: {{content}}")
- })
- })
-
- someItemsView.appendTo('body')
-
- Will result in the following HTML structure
-
-
-
the letter: A
-
the letter: B
-
the letter: C
-
-
-
- ## Automatic matching of parent/child tagNames
- Setting the `tagName` property of a `CollectionView` to any of
- "ul", "ol", "table", "thead", "tbody", "tfoot", "tr", or "select" will result
- in the item views receiving an appropriately matched `tagName` property.
-
-
- Given an empty `` and the following code:
-
- anUndorderedListView = Ember.CollectionView.create({
- tagName: 'ul',
- content: ['A','B','C'],
- itemViewClass: Ember.View.extend({
- template: Ember.Handlebars.compile("the letter: {{content}}")
- })
- })
-
- anUndorderedListView.appendTo('body')
-
- Will result in the following HTML structure
-
-
- the letter: A
- the letter: B
- the letter: C
-
-
- Additional tagName pairs can be provided by adding to `Ember.CollectionView.CONTAINER_MAP `
-
- Ember.CollectionView.CONTAINER_MAP['article'] = 'section'
-
-
- ## Empty View
- You can provide an `Ember.View` subclass to the `Ember.CollectionView` instance as its
- `emptyView` property. If the `content` property of a `CollectionView` is set to `null`
- or an empty array, an instance of this view will be the `CollectionView`s only child.
-
- aListWithNothing = Ember.CollectionView.create({
- classNames: ['nothing']
- content: null,
- emptyView: Ember.View.extend({
- template: Ember.Handlebars.compile("The collection is empty")
- })
- })
-
- aListWithNothing.appendTo('body')
-
- Will result in the following HTML structure
-
-
-
- The collection is empty
-
-
-
- ## Adding and Removing items
- The `childViews` property of a `CollectionView` should not be directly manipulated. Instead,
- add, remove, replace items from its `content` property. This will trigger
- appropriate changes to its rendered HTML.
-
- ## Use in templates via the `{{collection}}` Ember.Handlebars helper
- Ember.Handlebars provides a helper specifically for adding `CollectionView`s to templates.
- See `Ember.Handlebars.collection` for more details
-
- @since Ember 0.9
- @extends Ember.ContainerView
- */
- Ember.CollectionView = Ember.ContainerView.extend(
- /** @scope Ember.CollectionView.prototype */ {
-
- /**
- A list of items to be displayed by the Ember.CollectionView.
-
- @type Ember.Array
- @default null
- */
- content: null,
-
- /**
- An optional view to display if content is set to an empty array.
-
- @type Ember.View
- @default null
- */
- emptyView: null,
-
- /**
- @type Ember.View
- @default Ember.View
- */
- itemViewClass: Ember.View,
-
- /** @private */
- init: function () {
- var ret = this._super();
- this._contentDidChange();
- return ret;
- },
-
- _contentWillChange: Ember.beforeObserver(function () {
- var content = this.get('content');
-
- if (content) {
- content.removeArrayObserver(this);
- }
- var len = content ? get(content, 'length') : 0;
- this.arrayWillChange(content, 0, len);
- }, 'content'),
-
- /**
- @private
-
- Check to make sure that the content has changed, and if so,
- update the children directly. This is always scheduled
- asynchronously, to allow the element to be created before
- bindings have synchronized and vice versa.
- */
- _contentDidChange: Ember.observer(function () {
- var content = get(this, 'content');
-
- if (content) {
- ember_assert(fmt("an Ember.CollectionView's content must implement Ember.Array. You passed %@", [content]), Ember.Array.detect(content));
- content.addArrayObserver(this);
- }
-
- var len = content ? get(content, 'length') : 0;
- this.arrayDidChange(content, 0, null, len);
- }, 'content'),
-
- willDestroy: function () {
- var content = get(this, 'content');
- if (content) {
- content.removeArrayObserver(this);
- }
-
- this._super();
- },
-
- arrayWillChange: function (content, start, removedCount) {
- // If the contents were empty before and this template collection has an
- // empty view remove it now.
- var emptyView = get(this, 'emptyView');
- if (emptyView && emptyView instanceof Ember.View) {
- 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 = get(this, 'childViews'), childView, idx, len;
-
- len = get(childViews, 'length');
-
- var removingAll = removedCount === len;
-
- if (removingAll) {
- this.invokeForState('empty');
- }
-
- for (idx = start + removedCount - 1; idx >= start; idx--) {
- childView = childViews[idx];
- if (removingAll) {
- childView.removedFromDOM = true;
- }
- childView.destroy();
- }
- },
-
- /**
- Called when a mutation to the underlying content array occurs.
-
- This method will replay that mutation against the views that compose the
- Ember.CollectionView, ensuring that the view reflects the model.
-
- This array observer is added in contentDidChange.
-
- @param {Array} addedObjects
- the objects that were added to the content
-
- @param {Array} removedObjects
- the objects that were removed from the content
-
- @param {Number} changeIndex
- the index at which the changes occurred
- */
- arrayDidChange: function (content, start, removed, added) {
- var itemViewClass = get(this, 'itemViewClass'),
- childViews = get(this, 'childViews'),
- addedViews = [], view, item, idx, len, itemTagName;
-
- if ('string' === typeof itemViewClass) {
- itemViewClass = Ember.getPath(itemViewClass);
- }
-
- ember_assert(fmt("itemViewClass must be a subclass of Ember.View, not %@", [itemViewClass]), Ember.View.detect(itemViewClass));
-
- len = content ? get(content, 'length') : 0;
- if (len) {
- for (idx = start; idx < start + added; idx++) {
- item = content.objectAt(idx);
-
- view = this.createChildView(itemViewClass, {
- content: item,
- contentIndex: idx
- });
-
- addedViews.push(view);
- }
- } else {
- var emptyView = get(this, 'emptyView');
- if (!emptyView) {
- return;
- }
-
- emptyView = this.createChildView(emptyView);
- addedViews.push(emptyView);
- set(this, 'emptyView', emptyView);
- }
- childViews.replace(start, 0, addedViews);
- },
-
- createChildView: function (view, attrs) {
- view = this._super(view, attrs);
-
- var itemTagName = get(view, 'tagName');
- var tagName = (itemTagName === null || itemTagName === undefined) ? Ember.CollectionView.CONTAINER_MAP[get(this, 'tagName')] : itemTagName;
-
- set(view, 'tagName', tagName);
-
- return view;
- }
- });
-
- /**
- @static
-
- A map of parent tags to their default child tags. You can add
- additional parent tags if you want collection views that use
- a particular parent tag to default to a child tag.
-
- @type Hash
- @constant
- */
- Ember.CollectionView.CONTAINER_MAP = {
- ul: 'li',
- ol: 'li',
- table: 'tr',
- thead: 'tr',
- tbody: 'tr',
- tfoot: 'tr',
- tr: 'td',
- select: 'option'
- };
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember - JavaScript Application Framework
-// Copyright: ©2006-2011 Strobe Inc. and contributors.
-// Portions ©2008-2011 Apple Inc. All rights reserved.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember - JavaScript Application Framework
-// Copyright: ©2006-2011 Strobe Inc. and contributors.
-// Portions ©2008-2011 Apple Inc. All rights reserved.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-
- /*globals jQuery*/
-
-})();
-
-(function () {
- var get = Ember.get, set = Ember.set, getPath = Ember.getPath;
-
- Ember.State = Ember.Object.extend({
- isState: true,
- parentState: null,
- start: null,
- name: null,
- path: Ember.computed(function () {
- var parentPath = getPath(this, 'parentState.path'),
- path = get(this, 'name');
-
- if (parentPath) {
- path = parentPath + '.' + path;
- }
-
- return path;
- }).property().cacheable(),
-
- init: function () {
- var states = get(this, 'states'), foundStates;
- var name;
-
- // As a convenience, loop over the properties
- // of this state and look for any that are other
- // Ember.State instances or classes, and move them
- // to the `states` hash. This avoids having to
- // create an explicit separate hash.
-
- if (!states) {
- states = {};
-
- for (name in this) {
- if (name === "constructor") {
- continue;
- }
- this.setupChild(states, name, this[name]);
- }
-
- set(this, 'states', states);
- } else {
- for (name in states) {
- this.setupChild(states, name, states[name]);
- }
- }
-
- set(this, 'routes', {});
- },
-
- setupChild: function (states, name, value) {
- if (!value) {
- return false;
- }
-
- if (Ember.State.detect(value)) {
- value = value.create({
- name: name
- });
- } else if (value.isState) {
- set(value, 'name', name);
- }
-
- if (value.isState) {
- set(value, 'parentState', this);
- states[name] = value;
- }
- },
-
- enter: Ember.K,
- exit: Ember.K
- });
-
-})();
-
-
-(function () {
- var get = Ember.get, set = Ember.set, getPath = Ember.getPath, fmt = Ember.String.fmt;
- /**
- @class
-
- StateManager is part of Ember's implementation of a finite state machine. A StateManager
- instance manages a number of properties that are instances of `Ember.State`,
- tracks the current active state, and triggers callbacks when states have changed.
-
- ## Defining States
-
- The states of StateManager can be declared in one of two ways. First, you can define
- a `states` property that contains all the states:
-
- managerA = Ember.StateManager.create({
- states: {
- stateOne: Ember.State.create(),
- stateTwo: Ember.State.create()
- }
- })
-
- managerA.get('states')
- // {
- // stateOne: Ember.State.create(),
- // stateTwo: Ember.State.create()
- // }
-
- You can also add instances of `Ember.State` (or an `Ember.State` subclass) directly as properties
- of a StateManager. These states will be collected into the `states` property for you.
-
- managerA = Ember.StateManager.create({
- stateOne: Ember.State.create(),
- stateTwo: Ember.State.create()
- })
-
- managerA.get('states')
- // {
- // stateOne: Ember.State.create(),
- // stateTwo: Ember.State.create()
- // }
-
- ## The Initial State
- When created a StateManager instance will immediately enter into the state
- defined as its `start` property or the state referenced by name in its
- `initialState` property:
-
- managerA = Ember.StateManager.create({
- start: Ember.State.create({})
- })
-
- managerA.getPath('currentState.name') // 'start'
-
- managerB = Ember.StateManager.create({
- initialState: 'beginHere',
- beginHere: Ember.State.create({})
- })
-
- managerB.getPath('currentState.name') // 'beginHere'
-
- Because it is a property you may also provided a computed function if you wish to derive
- an `initialState` programmatically:
-
- managerC = Ember.StateManager.create({
- initialState: function(){
- if (someLogic) {
- return 'active';
- } else {
- return 'passive';
- }
- }.property(),
- active: Ember.State.create({})
- passive: Ember.State.create({})
- })
-
- ## Moving Between States
- A StateManager can have any number of Ember.State objects as properties
- and can have a single one of these states as its current state.
-
- Calling `goToState` transitions between states:
-
- robotManager = Ember.StateManager.create({
- initialState: 'poweredDown',
- poweredDown: Ember.State.create({}),
- poweredUp: Ember.State.create({})
- })
-
- robotManager.getPath('currentState.name') // 'poweredDown'
- robotManager.goToState('poweredUp')
- robotManager.getPath('currentState.name') // 'poweredUp'
-
- Before transitioning into a new state the existing `currentState` will have its
- `exit` method called with with the StateManager instance as its first argument and
- an object representing the the transition as its second argument.
-
- After transitioning into a new state the new `currentState` will have its
- `enter` method called with with the StateManager instance as its first argument and
- an object representing the the transition as its second argument.
-
- robotManager = Ember.StateManager.create({
- initialState: 'poweredDown',
- poweredDown: Ember.State.create({
- exit: function(stateManager, transition){
- console.log("exiting the poweredDown state")
- }
- }),
- poweredUp: Ember.State.create({
- enter: function(stateManager, transition){
- console.log("entering the poweredUp state. Destroy all humans.")
- }
- })
- })
-
- robotManager.getPath('currentState.name') // 'poweredDown'
- robotManager.goToState('poweredUp')
- // will log
- // 'exiting the poweredDown state'
- // 'entering the poweredUp state. Destroy all humans.'
-
-
- Once a StateManager is already in a state, subsequent attempts to enter that state will
- not trigger enter or exit method calls. Attempts to transition into a state that the
- manager does not have will result in no changes in the StateManager's current state:
-
- robotManager = Ember.StateManager.create({
- initialState: 'poweredDown',
- poweredDown: Ember.State.create({
- exit: function(stateManager, transition){
- console.log("exiting the poweredDown state")
- }
- }),
- poweredUp: Ember.State.create({
- enter: function(stateManager, transition){
- console.log("entering the poweredUp state. Destroy all humans.")
- }
- })
- })
-
- robotManager.getPath('currentState.name') // 'poweredDown'
- robotManager.goToState('poweredUp')
- // will log
- // 'exiting the poweredDown state'
- // 'entering the poweredUp state. Destroy all humans.'
- robotManager.goToState('poweredUp') // no logging, no state change
-
- robotManager.goToState('someUnknownState') // silently fails
- robotManager.getPath('currentState.name') // 'poweredUp'
-
-
- Each state property may itself contain properties that are instances of Ember.State.
- The StateManager can transition to specific sub-states in a series of goToState method calls or
- via a single goToState with the full path to the specific state. The StateManager will also
- keep track of the full path to its currentState
-
-
- robotManager = Ember.StateManager.create({
- initialState: 'poweredDown',
- poweredDown: Ember.State.create({
- charging: Ember.State.create(),
- charged: Ember.State.create()
- }),
- poweredUp: Ember.State.create({
- mobile: Ember.State.create(),
- stationary: Ember.State.create()
- })
- })
-
- robotManager.getPath('currentState.name') // 'poweredDown'
-
- robotManager.goToState('poweredUp')
- robotManager.getPath('currentState.name') // 'poweredUp'
-
- robotManager.goToState('mobile')
- robotManager.getPath('currentState.name') // 'mobile'
-
- // transition via a state path
- robotManager.goToState('poweredDown.charging')
- robotManager.getPath('currentState.name') // 'charging'
-
- robotManager.getPath('currentState.get.path') // 'poweredDown.charging'
-
- Enter transition methods will be called for each state and nested child state in their
- hierarchical order. Exit methods will be called for each state and its nested states in
- reverse hierarchical order.
-
- Exit transitions for a parent state are not called when entering into one of its child states,
- only when transitioning to a new section of possible states in the hierarchy.
-
- robotManager = Ember.StateManager.create({
- initialState: 'poweredDown',
- poweredDown: Ember.State.create({
- enter: function(){},
- exit: function(){
- console.log("exited poweredDown state")
- },
- charging: Ember.State.create({
- enter: function(){},
- exit: function(){}
- }),
- charged: Ember.State.create({
- enter: function(){
- console.log("entered charged state")
- },
- exit: function(){
- console.log("exited charged state")
- }
- })
- }),
- poweredUp: Ember.State.create({
- enter: function(){
- console.log("entered poweredUp state")
- },
- exit: function(){},
- mobile: Ember.State.create({
- enter: function(){
- console.log("entered mobile state")
- },
- exit: function(){}
- }),
- stationary: Ember.State.create({
- enter: function(){},
- exit: function(){}
- })
- })
- })
-
-
- robotManager.get('currentState.get.path') // 'poweredDown'
- robotManager.goToState('charged')
- // logs 'entered charged state'
- // but does *not* log 'exited poweredDown state'
- robotManager.getPath('currentState.name') // 'charged
-
- robotManager.goToState('poweredUp.mobile')
- // logs
- // 'exited charged state'
- // 'exited poweredDown state'
- // 'entered poweredUp state'
- // 'entered mobile state'
-
- During development you can set a StateManager's `enableLogging` property to `true` to
- receive console messages of state transitions.
-
- robotManager = Ember.StateManager.create({
- enableLogging: true
- })
-
- ## Managing currentState with Actions
- To control which transitions between states are possible for a given state, StateManager
- can receive and route action messages to its states via the `send` method. Calling to `send` with
- an action name will begin searching for a method with the same name starting at the current state
- and moving up through the parent states in a state hierarchy until an appropriate method is found
- or the StateManager instance itself is reached.
-
- If an appropriately named method is found it will be called with the state manager as the first
- argument and an optional `context` object as the second argument.
-
- managerA = Ember.StateManager.create({
- initialState: 'stateOne.substateOne.subsubstateOne',
- stateOne: Ember.State.create({
- substateOne: Ember.State.create({
- anAction: function(manager, context){
- console.log("an action was called")
- },
- subsubstateOne: Ember.State.create({})
- })
- })
- })
-
- managerA.getPath('currentState.name') // 'subsubstateOne'
- managerA.send('anAction')
- // 'stateOne.substateOne.subsubstateOne' has no anAction method
- // so the 'anAction' method of 'stateOne.substateOne' is called
- // and logs "an action was called"
- // with managerA as the first argument
- // and no second argument
-
- someObject = {}
- managerA.send('anAction', someObject)
- // the 'anAction' method of 'stateOne.substateOne' is called again
- // with managerA as the first argument and
- // someObject as the second argument.
-
-
- If the StateManager attempts to send an action but does not find an appropriately named
- method in the current state or while moving upwards through the state hierarchy
- it will throw a new Ember.Error. Action detection only moves upwards through the state hierarchy
- from the current state. It does not search in other portions of the hierarchy.
-
- managerB = Ember.StateManager.create({
- initialState: 'stateOne.substateOne.subsubstateOne',
- stateOne: Ember.State.create({
- substateOne: Ember.State.create({
- subsubstateOne: Ember.State.create({})
- })
- }),
- stateTwo: Ember.State.create({
- anAction: function(manager, context){
- // will not be called below because it is
- // not a parent of the current state
- }
- })
- })
-
- managerB.getPath('currentState.name') // 'subsubstateOne'
- managerB.send('anAction')
- // Error: could not
- // respond to event anAction in state stateOne.substateOne.subsubstateOne.
-
- Inside of an action method the given state should delegate `goToState` calls on its
- StateManager.
-
- robotManager = Ember.StateManager.create({
- initialState: 'poweredDown.charging',
- poweredDown: Ember.State.create({
- charging: Ember.State.create({
- chargeComplete: function(manager, context){
- manager.goToState('charged')
- }
- }),
- charged: Ember.State.create({
- boot: function(manager, context){
- manager.goToState('poweredUp')
- }
- })
- }),
- poweredUp: Ember.State.create({
- beginExtermination: function(manager, context){
- manager.goToState('rampaging')
- },
- rampaging: Ember.State.create()
- })
- })
-
- robotManager.getPath('currentState.name') // 'charging'
- robotManager.send('boot') // throws error, no boot action
- // in current hierarchy
- robotManager.getPath('currentState.name') // remains 'charging'
-
- robotManager.send('beginExtermination') // throws error, no beginExtermination
- // action in current hierarchy
- robotManager.getPath('currentState.name') // remains 'charging'
-
- robotManager.send('chargeComplete')
- robotManager.getPath('currentState.name') // 'charged'
-
- robotManager.send('boot')
- robotManager.getPath('currentState.name') // 'poweredUp'
-
- robotManager.send('beginExtermination', allHumans)
- robotManager.getPath('currentState.name') // 'rampaging'
-
- **/
- Ember.StateManager = Ember.State.extend(
- /** @scope Ember.State.prototype */ {
-
- /**
- When creating a new statemanager, look for a default state to transition
- into. This state can either be named `start`, or can be specified using the
- `initialState` property.
- */
- init: function () {
- this._super();
-
- var initialState = get(this, 'initialState');
-
- if (!initialState && getPath(this, 'states.start')) {
- initialState = 'start';
- }
-
- if (initialState) {
- this.goToState(initialState);
- }
- },
-
- currentState: null,
-
- /**
- @property
-
- If set to true, `errorOnUnhandledEvents` will cause an exception to be
- raised if you attempt to send an event to a state manager that is not
- handled by the current state or any of its parent states.
- */
- errorOnUnhandledEvent: true,
-
- send: function (event, context) {
- this.sendRecursively(event, get(this, 'currentState'), context);
- },
-
- sendRecursively: function (event, currentState, context) {
- var log = this.enableLogging;
-
- var action = currentState[event];
-
- if (action) {
- if (log) {
- console.log(fmt("STATEMANAGER: Sending event '%@' to state %@.", [event, get(currentState, 'path')]));
- }
- action.call(currentState, this, context);
- } else {
- var parentState = get(currentState, 'parentState');
- if (parentState) {
- this.sendRecursively(event, parentState, context);
- } else if (get(this, 'errorOnUnhandledEvent')) {
- throw new Ember.Error(this.toString() + " could not respond to event " + event + " in state " + getPath(this, 'currentState.path') + ".");
- }
- }
- },
-
- findStatesByRoute: function (state, route) {
- if (!route || route === "") {
- return undefined;
- }
- var r = route.split('.'), ret = [];
-
- for (var i = 0, len = r.length; i < len; i += 1) {
- var states = get(state, 'states');
-
- if (!states) {
- return undefined;
- }
-
- var s = get(states, r[i]);
- if (s) {
- state = s;
- ret.push(s);
- }
- else {
- return undefined;
- }
- }
-
- return ret;
- },
-
- goToState: function (name) {
- if (Ember.empty(name)) {
- return;
- }
-
- var currentState = get(this, 'currentState') || this, state, newState;
-
- var exitStates = [], enterStates;
-
- state = currentState;
-
- if (state.routes[name]) {
- // cache hit
- exitStates = state.routes[name].exitStates;
- enterStates = state.routes[name].enterStates;
- state = state.routes[name].futureState;
- } else {
- // cache miss
-
- newState = this.findStatesByRoute(currentState, name);
-
- while (state && !newState) {
- exitStates.unshift(state);
-
- state = get(state, 'parentState');
- if (!state) {
- newState = this.findStatesByRoute(this, name);
- if (!newState) {
- return;
- }
- }
- newState = this.findStatesByRoute(state, name);
- }
-
- enterStates = newState.slice(0);
- exitStates = exitStates.slice(0);
-
- if (enterStates.length > 0) {
- state = enterStates[enterStates.length - 1];
-
- while (enterStates.length > 0 && enterStates[0] === exitStates[0]) {
- enterStates.shift();
- exitStates.shift();
- }
- }
-
- currentState.routes[name] = {
- exitStates: exitStates,
- enterStates: enterStates,
- futureState: state
- };
- }
-
- this.enterState(exitStates, enterStates, state);
- },
-
- getState: function (name) {
- var state = get(this, name),
- parentState = get(this, 'parentState');
-
- if (state) {
- return state;
- } else if (parentState) {
- return parentState.getState(name);
- }
- },
-
- asyncEach: function (list, callback, doneCallback) {
- var async = false, self = this;
-
- if (!list.length) {
- if (doneCallback) {
- doneCallback.call(this);
- }
- return;
- }
-
- var head = list[0];
- var tail = list.slice(1);
-
- var transition = {
- async: function () {
- async = true;
- },
- resume: function () {
- self.asyncEach(tail, callback, doneCallback);
- }
- };
-
- callback.call(this, head, transition);
-
- if (!async) {
- transition.resume();
- }
- },
-
- enterState: function (exitStates, enterStates, state) {
- var log = this.enableLogging;
-
- var stateManager = this;
-
- exitStates = exitStates.slice(0).reverse();
- this.asyncEach(exitStates, function (state, transition) {
- state.exit(stateManager, transition);
- }, function () {
- this.asyncEach(enterStates, function (state, transition) {
- if (log) {
- console.log("STATEMANAGER: Entering " + get(state, 'path'));
- }
- state.enter(stateManager, transition);
- }, function () {
- var startState = state, enteredState, initialState;
-
- initialState = get(startState, 'initialState');
-
- if (!initialState) {
- initialState = 'start';
- }
-
- // right now, start states cannot be entered asynchronously
- while (startState = get(get(startState, 'states'), initialState)) {
- enteredState = startState;
-
- if (log) {
- console.log("STATEMANAGER: Entering " + get(startState, 'path'));
- }
- startState.enter(stateManager);
-
- initialState = get(startState, 'initialState');
-
- if (!initialState) {
- initialState = 'start';
- }
- }
-
- set(this, 'currentState', enteredState || state);
- });
- });
- }
- });
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Statecharts
-// Copyright: ©2011 Living Social Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-
-})();
-
-(function () {
- var get = Ember.get, set = Ember.set, getPath = Ember.getPath, fmt = Ember.String.fmt;
-
- /**
- @class
-
- ## Interactions with Ember's View System.
- When combined with instances of `Ember.ViewState`, StateManager is designed to
- interact with Ember's view system to control which views are added to
- and removed from the DOM based on the manager's current state.
-
- By default, a StateManager will manage views inside the 'body' element. This can be
- customized by setting the `rootElement` property to a CSS selector of an existing
- HTML element you would prefer to receive view rendering.
-
-
- viewStates = Ember.StateManager.create({
- rootElement: '#some-other-element'
- })
-
- You can also specify a particular instance of `Ember.ContainerView` you would like to receive
- view rendering by setting the `rootView` property. You will be responsible for placing
- this element into the DOM yourself.
-
- aLayoutView = Ember.ContainerView.create()
-
- // make sure this view instance is added to the browser
- aLayoutView.appendTo('body')
-
- App.viewStates = Ember.StateManager.create({
- rootView: aLayoutView
- })
-
-
- Once you have an instance of StateManager controlling a view, you can provide states
- that are instances of `Ember.ViewState`. When the StateManager enters a state
- that is an instance of `Ember.ViewState` that `ViewState`'s `view` property will be
- instantiated and inserted into the StateManager's `rootView` or `rootElement`.
- When a state is exited, the `ViewState`'s view will be removed from the StateManager's
- view.
-
- ContactListView = Ember.View.extend({
- classNames: ['my-contacts-css-class'],
- defaultTemplate: Ember.Handlebars.compile('People ')
- })
-
- PhotoListView = Ember.View.extend({
- classNames: ['my-photos-css-class'],
- defaultTemplate: Ember.Handlebars.compile('Photos ')
- })
-
- viewStates = Ember.StateManager.create({
- showingPeople: Ember.ViewState.create({
- view: ContactListView
- }),
- showingPhotos: Ember.ViewState.create({
- view: PhotoListView
- })
- })
-
- viewStates.goToState('showingPeople')
-
- The above code will change the rendered HTML from
-
-
-
- to
-
-
-
-
People
-
-
-
- Changing the current state via `goToState` from `showingPeople` to
- `showingPhotos` will remove the `showingPeople` view and add the `showingPhotos` view:
-
- viewStates.goToState('showingPhotos')
-
- will change the rendered HTML to
-
-
-
-
Photos
-
-
-
-
- When entering nested `ViewState`s, each state's view will be draw into the the StateManager's
- `rootView` or `rootElement` as siblings.
-
-
- ContactListView = Ember.View.extend({
- classNames: ['my-contacts-css-class'],
- defaultTemplate: Ember.Handlebars.compile('People ')
- })
-
- EditAContactView = Ember.View.extend({
- classNames: ['editing-a-contact-css-class'],
- defaultTemplate: Ember.Handlebars.compile('Editing...')
- })
-
- viewStates = Ember.StateManager.create({
- showingPeople: Ember.ViewState.create({
- view: ContactListView,
-
- withEditingPanel: Ember.ViewState.create({
- view: EditAContactView
- })
- })
- })
-
-
- viewStates.goToState('showingPeople.withEditingPanel')
-
-
- Will result in the following rendered HTML:
-
-
-
-
People
-
-
-
- Editing...
-
-
-
-
- ViewState views are added and removed from their StateManager's view via their
- `enter` and `exit` methods. If you need to override these methods, be sure to call
- `_super` to maintain the adding and removing behavior:
-
- viewStates = Ember.StateManager.create({
- aState: Ember.ViewState.create({
- view: Ember.View.extend({}),
- enter: function(manager, transition){
- // calling _super ensures this view will be
- // properly inserted
- this._super();
-
- // now you can do other things
- }
- })
- })
-
- ## Managing Multiple Sections of A Page With States
- Multiple StateManagers can be combined to control multiple areas of an application's rendered views.
- Given the following HTML body:
-
-
-
-
-
-
-
- You could separately manage view state for each section with two StateManagers
-
- navigationStates = Ember.StateManager.create({
- rootElement: '#sidebar-nav',
- userAuthenticated: Em.ViewState.create({
- view: Ember.View.extend({})
- }),
- userNotAuthenticated: Em.ViewState.create({
- view: Ember.View.extend({})
- })
- })
-
- contentStates = Ember.StateManager.create({
- rootElement: '#content-area',
- books: Em.ViewState.create({
- view: Ember.View.extend({})
- }),
- music: Em.ViewState.create({
- view: Ember.View.extend({})
- })
- })
-
-
- If you prefer to start with an empty body and manage state programmatically you
- can also take advantage of StateManager's `rootView` property and the ability of
- `Ember.ContainerView`s to manually manage their child views.
-
-
- dashboard = Ember.ContainerView.create({
- childViews: ['navigationAreaView', 'contentAreaView'],
- navigationAreaView: Ember.ContainerView.create({}),
- contentAreaView: Ember.ContainerView.create({})
- })
-
- navigationStates = Ember.StateManager.create({
- rootView: dashboard.get('navigationAreaView'),
- userAuthenticated: Em.ViewState.create({
- view: Ember.View.extend({})
- }),
- userNotAuthenticated: Em.ViewState.create({
- view: Ember.View.extend({})
- })
- })
-
- contentStates = Ember.StateManager.create({
- rootView: dashboard.get('contentAreaView'),
- books: Em.ViewState.create({
- view: Ember.View.extend({})
- }),
- music: Em.ViewState.create({
- view: Ember.View.extend({})
- })
- })
-
- dashboard.appendTo('body')
-
- ## User Manipulation of State via `{{action}}` Helpers
- The Handlebars `{{action}}` helper is StateManager-aware and will use StateManager action sending
- to connect user interaction to action-based state transitions.
-
- Given the following body and handlebars template
-
-
-
-
-
- And application code
-
- App = Ember.Application.create()
- App.appStates = Ember.StateManager.create({
- initialState: 'aState',
- aState: Ember.State.create({
- anAction: function(manager, context){}
- }),
- bState: Ember.State.create({})
- })
-
- A user initiated click or touch event on "Go" will trigger the 'anAction' method of
- `App.appStates.aState` with `App.appStates` as the first argument and a
- `jQuery.Event` object as the second object. The `jQuery.Event` will include a property
- `view` that references the `Ember.View` object that was interacted with.
-
- **/
-
- Ember.StateManager.reopen({
-
- /**
- @property
-
- If the current state is a view state or the descendent of a view state,
- this property will be the view associated with it. If there is no
- view state active in this state manager, this value will be null.
- */
- currentView: Ember.computed(function () {
- var currentState = get(this, 'currentState'),
- view;
-
- while (currentState) {
- if (get(currentState, 'isViewState')) {
- view = get(currentState, 'view');
- if (view) {
- return view;
- }
- }
-
- currentState = get(currentState, 'parentState');
- }
-
- return null;
- }).property('currentState').cacheable(),
-
- });
-
-})();
-
-
-(function () {
- var get = Ember.get, set = Ember.set;
-
- Ember.ViewState = Ember.State.extend({
- isViewState: true,
-
- enter: function (stateManager) {
- var view = get(this, 'view'), root, childViews;
-
- if (view) {
- if (Ember.View.detect(view)) {
- view = view.create();
- set(this, 'view', view);
- }
-
- ember_assert('view must be an Ember.View', view instanceof Ember.View);
-
- root = stateManager.get('rootView');
-
- if (root) {
- childViews = get(root, 'childViews');
- childViews.pushObject(view);
- } else {
- root = stateManager.get('rootElement') || 'body';
- view.appendTo(root);
- }
- }
- },
-
- exit: function (stateManager) {
- var view = get(this, 'view');
-
- if (view) {
- // If the view has a parent view, then it is
- // part of a view hierarchy and should be removed
- // from its parent.
- if (get(view, 'parentView')) {
- view.removeFromParent();
- } else {
-
- // Otherwise, the view is a "root view" and
- // was appended directly to the DOM.
- view.remove();
- }
- }
- }
- });
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Statecharts
-// Copyright: ©2011 Living Social Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-
-})();
-
-(function () {
-// ==========================================================================
-// Project: metamorph
-// Copyright: ©2011 My Company Inc. All rights reserved.
-// ==========================================================================
-
- (function (window) {
-
- var K = function () {
- },
- guid = 0,
- document = window.document,
-
- // Feature-detect the W3C range API, the extended check is for IE9 which only partially supports ranges
- supportsRange = ('createRange' in document) && (typeof Range !== 'undefined') && Range.prototype.createContextualFragment,
-
- // 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
- needsShy = (function () {
- var testEl = document.createElement('div');
- testEl.innerHTML = "
";
- testEl.firstChild.innerHTML = "";
- return testEl.firstChild.innerHTML === '';
- })();
-
- // Constructor that supports either Metamorph('foo') or new
- // Metamorph('foo');
- //
- // Takes a string of HTML as the argument.
-
- var Metamorph = function (html) {
- var self;
-
- if (this instanceof Metamorph) {
- self = this;
- } else {
- self = new K();
- }
-
- self.innerHTML = html;
- var myGuid = 'metamorph-' + (guid++);
- self.start = myGuid + '-start';
- self.end = myGuid + '-end';
-
- return self;
- };
-
- K.prototype = Metamorph.prototype;
-
- var rangeFor, htmlFunc, removeFunc, outerHTMLFunc, appendToFunc, afterFunc, prependFunc, startTagFunc, endTagFunc;
-
- outerHTMLFunc = function () {
- return this.startTag() + this.innerHTML + this.endTag();
- };
-
- startTagFunc = function () {
- return "";
- };
-
- endTagFunc = function () {
- return "";
- };
-
- // If we have the W3C range API, this process is relatively straight forward.
- if (supportsRange) {
-
- // Get a range for the current morph. Optionally include the starting and
- // ending placeholders.
- rangeFor = function (morph, outerToo) {
- var range = document.createRange();
- var before = document.getElementById(morph.start);
- var after = document.getElementById(morph.end);
-
- if (outerToo) {
- range.setStartBefore(before);
- range.setEndAfter(after);
- } else {
- range.setStartAfter(before);
- range.setEndBefore(after);
- }
-
- return range;
- };
-
- htmlFunc = function (html, outerToo) {
- // get a range for the current metamorph object
- var range = rangeFor(this, outerToo);
-
- // delete the contents of the range, which will be the
- // nodes between the starting and ending placeholder.
- range.deleteContents();
-
- // create a new document fragment for the HTML
- var fragment = range.createContextualFragment(html);
-
- // insert the fragment into the range
- range.insertNode(fragment);
- };
-
- removeFunc = function () {
- // get a range for the current metamorph object including
- // the starting and ending placeholders.
- var range = rangeFor(this, true);
-
- // delete the entire range.
- range.deleteContents();
- };
-
- appendToFunc = function (node) {
- var range = document.createRange();
- range.setStart(node);
- range.collapse(false);
- var frag = range.createContextualFragment(this.outerHTML());
- node.appendChild(frag);
- };
-
- afterFunc = function (html) {
- var range = document.createRange();
- var after = document.getElementById(this.end);
-
- range.setStartAfter(after);
- range.setEndAfter(after);
-
- var fragment = range.createContextualFragment(html);
- range.insertNode(fragment);
- };
-
- prependFunc = function (html) {
- var range = document.createRange();
- var start = document.getElementById(this.start);
-
- range.setStartAfter(start);
- range.setEndAfter(start);
-
- var fragment = range.createContextualFragment(html);
- range.insertNode(fragment);
- };
-
- } else {
- /**
- * This code is mostly taken from jQuery, with one exception. In jQuery's case, we
- * have some HTML and we need to figure out how to convert it into some nodes.
- *
- * In this case, jQuery needs to scan the HTML looking for an opening tag and use
- * that as the key for the wrap map. In our case, we know the parent node, and
- * can use its type as the key for the wrap map.
- **/
- var wrapMap = {
- select: [ 1, "", " " ],
- fieldset: [ 1, "", " " ],
- table: [ 1, "" ],
- tbody: [ 2, "" ],
- tr: [ 3, "" ],
- colgroup: [ 2, "" ],
- map: [ 1, "", " " ],
- _default: [ 0, "", "" ]
- };
-
- /**
- * Given a parent node and some HTML, generate a set of nodes. Return the first
- * node, which will allow us to traverse the rest using nextSibling.
- *
- * We need to do this because innerHTML in IE does not really parse the nodes.
- **/
- var firstNodeFor = function (parentNode, html) {
- var arr = wrapMap[parentNode.tagName.toLowerCase()] || wrapMap._default;
- var depth = arr[0], start = arr[1], end = arr[2];
-
- if (needsShy) {
- html = '' + html;
- }
-
- var element = document.createElement('div');
- element.innerHTML = start + html + end;
-
- for (var i = 0; i <= depth; i++) {
- element = element.firstChild;
- }
-
- // Look for to remove it.
- if (needsShy) {
- var shyElement = element;
-
- // Sometimes we get nameless elements with the shy inside
- while (shyElement.nodeType === 1 && !shyElement.nodeName && shyElement.childNodes.length === 1) {
- shyElement = shyElement.firstChild;
- }
-
- // At this point it's the actual unicode character.
- if (shyElement.nodeType === 3 && shyElement.nodeValue.charAt(0) === "\u00AD") {
- shyElement.nodeValue = shyElement.nodeValue.slice(1);
- }
- }
-
- return element;
- };
-
- /**
- * In some cases, Internet Explorer can create an anonymous node in
- * the hierarchy with no tagName. You can create this scenario via:
- *
- * div = document.createElement("div");
- * div.innerHTML = "";
- * div.firstChild.firstChild.tagName //=> ""
- *
- * If our script markers are inside such a node, we need to find that
- * node and use *it* as the marker.
- **/
- var realNode = function (start) {
- while (start.parentNode.tagName === "") {
- start = start.parentNode;
- }
-
- return start;
- };
-
- /**
- * When automatically adding a tbody, Internet Explorer inserts the
- * tbody immediately before the first . Other browsers create it
- * before the first node, no matter what.
- *
- * This means the the following code:
- *
- * div = document.createElement("div");
- * div.innerHTML = "
- *
- * Generates the following DOM in IE:
- *
- * + div
- * + table
- * - script id='first'
- * + tbody
- * + tr
- * + td
- * - "hi"
- * - script id='last'
- *
- * Which means that the two script tags, even though they were
- * inserted at the same point in the hierarchy in the original
- * HTML, now have different parents.
- *
- * This code reparents the first script tag by making it the tbody's
- * first child.
- **/
- var fixParentage = function (start, end) {
- if (start.parentNode !== end.parentNode) {
- end.parentNode.insertBefore(start, end.parentNode.firstChild);
- }
- };
-
- htmlFunc = function (html, outerToo) {
- // get the real starting node. see realNode for details.
- var start = realNode(document.getElementById(this.start));
- var end = document.getElementById(this.end);
- var parentNode = end.parentNode;
- var node, nextSibling, last;
-
- // make sure that the start and end nodes share the same
- // parent. If not, fix it.
- fixParentage(start, end);
-
- // remove all of the nodes after the starting placeholder and
- // before the ending placeholder.
- node = start.nextSibling;
- while (node) {
- nextSibling = node.nextSibling;
- last = node === end;
-
- // if this is the last node, and we want to remove it as well,
- // set the `end` node to the next sibling. This is because
- // for the rest of the function, we insert the new nodes
- // before the end (note that insertBefore(node, null) is
- // the same as appendChild(node)).
- //
- // if we do not want to remove it, just break.
- if (last) {
- if (outerToo) {
- end = node.nextSibling;
- } else {
- break;
- }
- }
-
- node.parentNode.removeChild(node);
-
- // if this is the last node and we didn't break before
- // (because we wanted to remove the outer nodes), break
- // now.
- if (last) {
- break;
- }
-
- node = nextSibling;
- }
-
- // get the first node for the HTML string, even in cases like
- // tables and lists where a simple innerHTML on a div would
- // swallow some of the content.
- node = firstNodeFor(start.parentNode, html);
-
- // copy the nodes for the HTML between the starting and ending
- // placeholder.
- while (node) {
- nextSibling = node.nextSibling;
- parentNode.insertBefore(node, end);
- node = nextSibling;
- }
- };
-
- // remove the nodes in the DOM representing this metamorph.
- //
- // this includes the starting and ending placeholders.
- removeFunc = function () {
- var start = realNode(document.getElementById(this.start));
- var end = document.getElementById(this.end);
-
- this.html('');
- start.parentNode.removeChild(start);
- end.parentNode.removeChild(end);
- };
-
- appendToFunc = function (parentNode) {
- var node = firstNodeFor(parentNode, this.outerHTML());
-
- while (node) {
- nextSibling = node.nextSibling;
- parentNode.appendChild(node);
- node = nextSibling;
- }
- };
-
- afterFunc = function (html) {
- // get the real starting node. see realNode for details.
- var end = document.getElementById(this.end);
- var insertBefore = end.nextSibling;
- var parentNode = end.parentNode;
- var nextSibling;
- var node;
-
- // get the first node for the HTML string, even in cases like
- // tables and lists where a simple innerHTML on a div would
- // swallow some of the content.
- node = firstNodeFor(parentNode, html);
-
- // copy the nodes for the HTML between the starting and ending
- // placeholder.
- while (node) {
- nextSibling = node.nextSibling;
- parentNode.insertBefore(node, insertBefore);
- node = nextSibling;
- }
- };
-
- prependFunc = function (html) {
- var start = document.getElementById(this.start);
- var parentNode = start.parentNode;
- var nextSibling;
- var node;
-
- node = firstNodeFor(parentNode, html);
- var insertBefore = start.nextSibling;
-
- while (node) {
- nextSibling = node.nextSibling;
- parentNode.insertBefore(node, insertBefore);
- node = nextSibling;
- }
- }
- }
-
- Metamorph.prototype.html = function (html) {
- this.checkRemoved();
- if (html === undefined) {
- return this.innerHTML;
- }
-
- htmlFunc.call(this, html);
-
- this.innerHTML = html;
- };
-
- Metamorph.prototype.replaceWith = function (html) {
- this.checkRemoved();
- htmlFunc.call(this, html, true);
- };
-
- Metamorph.prototype.remove = removeFunc;
- Metamorph.prototype.outerHTML = outerHTMLFunc;
- Metamorph.prototype.appendTo = appendToFunc;
- Metamorph.prototype.after = afterFunc;
- Metamorph.prototype.prepend = prependFunc;
- Metamorph.prototype.startTag = startTagFunc;
- Metamorph.prototype.endTag = endTagFunc;
-
- Metamorph.prototype.isRemoved = function () {
- var before = document.getElementById(this.start);
- var after = document.getElementById(this.end);
-
- return !before || !after;
- };
-
- Metamorph.prototype.checkRemoved = function () {
- if (this.isRemoved()) {
- throw new Error("Cannot perform operations on a Metamorph that is not in the DOM.");
- }
- };
-
- window.Metamorph = Metamorph;
- })(this);
-
-
-})();
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- /*globals Handlebars */
- /**
- @namespace
- @name Handlebars
- @private
- */
-
- /**
- @namespace
- @name Handlebars.helpers
- @description Helpers for Handlebars templates
- */
-
- /**
- @class
-
- Prepares the Handlebars templating library for use inside Ember's view
- system.
-
- The Ember.Handlebars object is the standard Handlebars library, extended to use
- Ember's get() method instead of direct property access, which allows
- computed properties to be used inside templates.
-
- To use Ember.Handlebars, call Ember.Handlebars.compile(). This will return a
- function that you can call multiple times, with a context object as the first
- parameter:
-
- var template = Ember.Handlebars.compile("my {{cool}} template");
- var result = template({
- cool: "awesome"
- });
-
- console.log(result); // prints "my awesome template"
-
- Note that you won't usually need to use Ember.Handlebars yourself. Instead, use
- Ember.View, which takes care of integration into the view layer for you.
- */
- Ember.Handlebars = Ember.create(Handlebars);
-
- Ember.Handlebars.helpers = Ember.create(Handlebars.helpers);
-
- /**
- Override the the opcode compiler and JavaScript compiler for Handlebars.
- */
- Ember.Handlebars.Compiler = function () {
- };
- Ember.Handlebars.Compiler.prototype = Ember.create(Handlebars.Compiler.prototype);
- Ember.Handlebars.Compiler.prototype.compiler = Ember.Handlebars.Compiler;
-
- Ember.Handlebars.JavaScriptCompiler = function () {
- };
- Ember.Handlebars.JavaScriptCompiler.prototype = Ember.create(Handlebars.JavaScriptCompiler.prototype);
- Ember.Handlebars.JavaScriptCompiler.prototype.compiler = Ember.Handlebars.JavaScriptCompiler;
- Ember.Handlebars.JavaScriptCompiler.prototype.namespace = "Ember.Handlebars";
-
-
- Ember.Handlebars.JavaScriptCompiler.prototype.initializeBuffer = function () {
- return "''";
- };
-
- /**
- Override the default buffer for Ember Handlebars. By default, Handlebars creates
- an empty String at the beginning of each invocation and appends to it. Ember's
- Handlebars overrides this to append to a single shared buffer.
-
- @private
- */
- Ember.Handlebars.JavaScriptCompiler.prototype.appendToBuffer = function (string) {
- return "data.buffer.push(" + string + ");";
- };
-
- /**
- Rewrite simple mustaches from {{foo}} to {{bind "foo"}}. This means that all simple
- mustaches in Ember's Handlebars will also set up an observer to keep the DOM
- up to date when the underlying property changes.
-
- @private
- */
- Ember.Handlebars.Compiler.prototype.mustache = function (mustache) {
- if (mustache.params.length || mustache.hash) {
- return Handlebars.Compiler.prototype.mustache.call(this, mustache);
- } else {
- var id = new Handlebars.AST.IdNode(['_triageMustache']);
-
- // Update the mustache node to include a hash value indicating whether the original node
- // was escaped. This will allow us to properly escape values when the underlying value
- // changes and we need to re-render the value.
- if (mustache.escaped) {
- mustache.hash = mustache.hash || new Handlebars.AST.HashNode([]);
- mustache.hash.pairs.push(["escaped", new Handlebars.AST.StringNode("true")]);
- }
- mustache = new Handlebars.AST.MustacheNode([id].concat([mustache.id]), mustache.hash, !mustache.escaped);
- return Handlebars.Compiler.prototype.mustache.call(this, mustache);
- }
- };
-
- /**
- Used for precompilation of Ember Handlebars templates. This will not be used during normal
- app execution.
-
- @param {String} string The template to precompile
- */
- Ember.Handlebars.precompile = function (string) {
- var ast = Handlebars.parse(string);
- var options = { data: true, stringParams: true };
- var environment = new Ember.Handlebars.Compiler().compile(ast, options);
- return new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);
- };
-
- /**
- The entry point for Ember Handlebars. This replaces the default Handlebars.compile and turns on
- template-local data and String parameters.
-
- @param {String} string The template to compile
- */
- Ember.Handlebars.compile = function (string) {
- var ast = Handlebars.parse(string);
- var options = { data: true, stringParams: true };
- var environment = new Ember.Handlebars.Compiler().compile(ast, options);
- var templateSpec = new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);
-
- return Handlebars.template(templateSpec);
- };
-
- /**
- If a path starts with a reserved keyword, returns the root
- that should be used.
-
- @private
- */
- var normalizePath = Ember.Handlebars.normalizePath = function (root, path, data) {
- var keywords = (data && data.keywords) || {},
- keyword, isKeyword;
-
- // Get the first segment of the path. For example, if the
- // path is "foo.bar.baz", returns "foo".
- keyword = path.split('.', 1)[0];
-
- // Test to see if the first path is a keyword that has been
- // passed along in the view's data hash. If so, we will treat
- // that object as the new root.
- if (keywords.hasOwnProperty(keyword)) {
- // Look up the value in the template's data hash.
- root = keywords[keyword];
- isKeyword = true;
-
- // Handle cases where the entire path is the reserved
- // word. In that case, return the object itself.
- if (path === keyword) {
- path = '';
- } else {
- // Strip the keyword from the path and look up
- // the remainder from the newly found root.
- path = path.substr(keyword.length);
- }
- }
-
- return { root: root, path: path, isKeyword: isKeyword };
- };
- /**
- Lookup both on root and on window. If the path starts with
- a keyword, the corresponding object will be looked up in the
- template's data hash and used to resolve the path.
-
- @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
- */
-
- Ember.Handlebars.getPath = function (root, path, options) {
- var data = options && options.data,
- normalizedPath = normalizePath(root, path, data),
- value;
-
- // In cases where the path begins with a keyword, change the
- // root to the value represented by that keyword, and ensure
- // the path is relative to it.
- root = normalizedPath.root;
- path = normalizedPath.path;
-
- // TODO: Remove this `false` when the `getPath` globals support is removed
- value = Ember.getPath(root, path, false);
-
- if (value === undefined && root !== window && Ember.isGlobalPath(path)) {
- value = Ember.getPath(window, path);
- }
- return value;
- };
-
- /**
- Registers a helper in Handlebars that will be called if no property with the
- given name can be found on the current context object, and no helper with
- that name is registered.
-
- This throws an exception with a more helpful error message so the user can
- track down where the problem is happening.
-
- @name Handlebars.helpers.helperMissing
- @param {String} path
- @param {Hash} options
- */
- Ember.Handlebars.registerHelper('helperMissing', function (path, options) {
- var error, view = "";
-
- error = "%@ Handlebars error: Could not find property '%@' on object %@.";
- if (options.data) {
- view = options.data.view;
- }
- throw new Ember.Error(Ember.String.fmt(error, [view, path, this]));
- });
-
-
-})();
-
-
-(function () {
-
- Ember.String.htmlSafe = function (str) {
- return new Handlebars.SafeString(str);
- };
-
- var htmlSafe = Ember.String.htmlSafe;
-
- if (Ember.EXTEND_PROTOTYPES) {
-
- /**
- @see Ember.String.htmlSafe
- */
- String.prototype.htmlSafe = function () {
- return htmlSafe(this);
- };
-
- }
-
-})();
-
-
-(function () {
- /*jshint newcap:false*/
- var set = Ember.set, get = Ember.get, getPath = Ember.getPath;
-
- var DOMManager = {
- remove: function (view) {
- var morph = view.morph;
- if (morph.isRemoved()) {
- return;
- }
- set(view, 'element', null);
- view._lastInsert = null;
- morph.remove();
- },
-
- prepend: function (view, childView) {
- childView._insertElementLater(function () {
- var morph = view.morph;
- morph.prepend(childView.outerHTML);
- childView.outerHTML = null;
- });
- },
-
- after: function (view, nextView) {
- nextView._insertElementLater(function () {
- var morph = view.morph;
- morph.after(nextView.outerHTML);
- nextView.outerHTML = null;
- });
- },
-
- replace: function (view) {
- var morph = view.morph;
-
- view.transitionTo('preRender');
- view.clearRenderedChildren();
- var buffer = view.renderToBuffer();
-
- Ember.run.schedule('render', this, function () {
- if (get(view, 'isDestroyed')) {
- return;
- }
- view.invalidateRecursively('element');
- view._notifyWillInsertElement();
- morph.replaceWith(buffer.string());
- view.transitionTo('inDOM');
- view._notifyDidInsertElement();
- });
- },
-
- empty: function (view) {
- view.morph.html("");
- }
- };
-
-// The `morph` and `outerHTML` properties are internal only
-// and not observable.
-
- Ember.Metamorph = Ember.Mixin.create({
- isVirtual: true,
- tagName: '',
-
- init: function () {
- this._super();
- this.morph = Metamorph();
- },
-
- beforeRender: function (buffer) {
- buffer.push(this.morph.startTag());
- },
-
- afterRender: function (buffer) {
- buffer.push(this.morph.endTag());
- },
-
- createElement: function () {
- var buffer = this.renderToBuffer();
- this.outerHTML = buffer.string();
- this.clearBuffer();
- },
-
- domManager: DOMManager
- });
-
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- /*globals Handlebars */
-
- var get = Ember.get, set = Ember.set, getPath = Ember.Handlebars.getPath;
- /**
- @ignore
- @private
- @class
-
- Ember._BindableSpanView is a private view created by the Handlebars `{{bind}}`
- helpers that is used to keep track of bound properties.
-
- Every time a property is bound using a `{{mustache}}`, an anonymous subclass
- of Ember._BindableSpanView is created with the appropriate sub-template and
- context set up. When the associated property changes, just the template for
- this view will re-render.
- */
- Ember._BindableSpanView = Ember.View.extend(Ember.Metamorph,
- /** @scope Ember._BindableSpanView.prototype */{
-
- /**
- The function used to determine if the `displayTemplate` or
- `inverseTemplate` should be rendered. This should be a function that takes
- a value and returns a Boolean.
-
- @type Function
- @default null
- */
- shouldDisplayFunc: null,
-
- /**
- Whether the template rendered by this view gets passed the context object
- of its parent template, or gets passed the value of retrieving `property`
- from the previous context.
-
- For example, this is true when using the `{{#if}}` helper, because the
- template inside the helper should look up properties relative to the same
- object as outside the block. This would be false when used with `{{#with
- foo}}` because the template should receive the object found by evaluating
- `foo`.
-
- @type Boolean
- @default false
- */
- preserveContext: false,
-
- /**
- The template to render when `shouldDisplayFunc` evaluates to true.
-
- @type Function
- @default null
- */
- displayTemplate: null,
-
- /**
- The template to render when `shouldDisplayFunc` evaluates to false.
-
- @type Function
- @default null
- */
- inverseTemplate: null,
-
- /**
- The key to look up on `previousContext` that is passed to
- `shouldDisplayFunc` to determine which template to render.
-
- In addition, if `preserveContext` is false, this object will be passed to
- the template when rendering.
-
- @type String
- @default null
- */
- property: null,
-
- normalizedValue: Ember.computed(function () {
- var property = get(this, 'property'),
- context = get(this, 'previousContext'),
- valueNormalizer = get(this, 'valueNormalizerFunc'),
- result, templateData;
-
- // Use the current context as the result if no
- // property is provided.
- if (property === '') {
- result = context;
- } else {
- templateData = get(this, 'templateData');
- result = getPath(context, property, { data: templateData });
- }
-
- return valueNormalizer ? valueNormalizer(result) : result;
- }).property('property', 'previousContext', 'valueNormalizerFunc').volatile(),
-
- rerenderIfNeeded: function () {
- if (!get(this, 'isDestroyed') && get(this, 'normalizedValue') !== this._lastNormalizedValue) {
- this.rerender();
- }
- },
-
- /**
- Determines which template to invoke, sets up the correct state based on
- that logic, then invokes the default Ember.View `render` implementation.
-
- This method will first look up the `property` key on `previousContext`,
- then pass that value to the `shouldDisplayFunc` function. If that returns
- true, the `displayTemplate` function will be rendered to DOM. Otherwise,
- `inverseTemplate`, if specified, will be rendered.
-
- For example, if this Ember._BindableSpan represented the {{#with foo}}
- helper, it would look up the `foo` property of its context, and
- `shouldDisplayFunc` would always return true. The object found by looking
- up `foo` would be passed to `displayTemplate`.
-
- @param {Ember.RenderBuffer} buffer
- */
- render: function (buffer) {
- // If not invoked via a triple-mustache ({{{foo}}}), escape
- // the content of the template.
- var escape = get(this, 'isEscaped');
-
- var shouldDisplay = get(this, 'shouldDisplayFunc'),
- preserveContext = get(this, 'preserveContext'),
- context = get(this, 'previousContext');
-
- var inverseTemplate = get(this, 'inverseTemplate'),
- displayTemplate = get(this, 'displayTemplate');
-
- var result = get(this, 'normalizedValue');
- this._lastNormalizedValue = result;
-
- // First, test the conditional to see if we should
- // render the template or not.
- if (shouldDisplay(result)) {
- set(this, 'template', displayTemplate);
-
- // If we are preserving the context (for example, if this
- // is an #if block, call the template with the same object.
- if (preserveContext) {
- set(this, '_templateContext', context);
- } else {
- // Otherwise, determine if this is a block bind or not.
- // If so, pass the specified object to the template
- if (displayTemplate) {
- set(this, '_templateContext', result);
- } else {
- // This is not a bind block, just push the result of the
- // expression to the render context and return.
- if (result === null || result === undefined) {
- result = "";
- } else if (!(result instanceof Handlebars.SafeString)) {
- result = String(result);
- }
-
- if (escape) {
- result = Handlebars.Utils.escapeExpression(result);
- }
- buffer.push(result);
- return;
- }
- }
- } else if (inverseTemplate) {
- set(this, 'template', inverseTemplate);
-
- if (preserveContext) {
- set(this, '_templateContext', context);
- } else {
- set(this, '_templateContext', result);
- }
- } else {
- set(this, 'template', function () {
- return '';
- });
- }
-
- return this._super(buffer);
- }
- });
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- var get = Ember.get, getPath = Ember.Handlebars.getPath, set = Ember.set, fmt = Ember.String.fmt;
- var forEach = Ember.ArrayUtils.forEach;
-
- var EmberHandlebars = Ember.Handlebars, helpers = EmberHandlebars.helpers;
-
- (function () {
- // Binds a property into the DOM. This will create a hook in DOM that the
- // KVO system will look for and update if the property changes.
- var bind = function (property, options, preserveContext, shouldDisplay, valueNormalizer) {
- var data = options.data,
- fn = options.fn,
- inverse = options.inverse,
- view = data.view,
- ctx = this,
- normalized;
-
- normalized = Ember.Handlebars.normalizePath(ctx, property, data);
-
- ctx = normalized.root;
- property = normalized.path;
-
- // Set up observers for observable objects
- if ('object' === typeof this) {
- // Create the view that will wrap the output of this template/property
- // and add it to the nearest view's childViews array.
- // See the documentation of Ember._BindableSpanView for more.
- var bindView = view.createChildView(Ember._BindableSpanView, {
- preserveContext: preserveContext,
- shouldDisplayFunc: shouldDisplay,
- valueNormalizerFunc: valueNormalizer,
- displayTemplate: fn,
- inverseTemplate: inverse,
- property: property,
- previousContext: ctx,
- isEscaped: options.hash.escaped,
- templateData: options.data
- });
-
- view.appendChild(bindView);
-
- /** @private */
- var observer = function () {
- Ember.run.once(bindView, 'rerenderIfNeeded');
- };
-
- // Observes the given property on the context and
- // tells the Ember._BindableSpan to re-render. If property
- // is an empty string, we are printing the current context
- // object ({{this}}) so updating it is not our responsibility.
- if (property !== '') {
- Ember.addObserver(ctx, property, observer);
- }
- } else {
- // The object is not observable, so just render it out and
- // be done with it.
- data.buffer.push(getPath(this, property, options));
- }
- };
-
- /**
- '_triageMustache' is used internally select between a binding and helper for
- the given context. Until this point, it would be hard to determine if the
- mustache is a property reference or a regular helper reference. This triage
- helper resolves that.
-
- This would not be typically invoked by directly.
-
- @private
- @name Handlebars.helpers._triageMustache
- @param {String} property Property/helperID to triage
- @param {Function} fn Context to provide for rendering
- @returns {String} HTML string
- */
- EmberHandlebars.registerHelper('_triageMustache', function (property, fn) {
- ember_assert("You cannot pass more than one argument to the _triageMustache helper", arguments.length <= 2);
- if (helpers[property]) {
- return helpers[property].call(this, fn);
- }
- else {
- return helpers.bind.apply(this, arguments);
- }
- });
-
- /**
- `bind` can be used to display a value, then update that value if it
- changes. For example, if you wanted to print the `title` property of
- `content`:
-
- {{bind "content.title"}}
-
- This will return the `title` property as a string, then create a new
- observer at the specified path. If it changes, it will update the value in
- DOM. Note that if you need to support IE7 and IE8 you must modify the
- model objects properties using Ember.get() and Ember.set() for this to work as
- it relies on Ember's KVO system. For all other browsers this will be handled
- for you automatically.
-
- @private
- @name Handlebars.helpers.bind
- @param {String} property Property to bind
- @param {Function} fn Context to provide for rendering
- @returns {String} HTML string
- */
- EmberHandlebars.registerHelper('bind', function (property, fn) {
- ember_assert("You cannot pass more than one argument to the bind helper", arguments.length <= 2);
-
- var context = (fn.contexts && fn.contexts[0]) || this;
-
- return bind.call(context, property, fn, false, function (result) {
- return !Ember.none(result);
- });
- });
-
- /**
- Use the `boundIf` helper to create a conditional that re-evaluates
- whenever the bound value changes.
-
- {{#boundIf "content.shouldDisplayTitle"}}
- {{content.title}}
- {{/boundIf}}
-
- @private
- @name Handlebars.helpers.boundIf
- @param {String} property Property to bind
- @param {Function} fn Context to provide for rendering
- @returns {String} HTML string
- */
- EmberHandlebars.registerHelper('boundIf', function (property, fn) {
- var context = (fn.contexts && fn.contexts[0]) || this;
- var func = function (result) {
- if (Ember.typeOf(result) === 'array') {
- return get(result, 'length') !== 0;
- } else {
- return !!result;
- }
- };
-
- return bind.call(context, property, fn, true, func, func);
- });
- })();
-
- /**
- @name Handlebars.helpers.with
- @param {Function} context
- @param {Hash} options
- @returns {String} HTML string
- */
- EmberHandlebars.registerHelper('with', function (context, options) {
- ember_assert("You must pass exactly one argument to the with helper", arguments.length === 2);
- ember_assert("You must pass a block to the with helper", options.fn && options.fn !== Handlebars.VM.noop);
-
- return helpers.bind.call(options.contexts[0], context, options);
- });
-
-
- /**
- @name Handlebars.helpers.if
- @param {Function} context
- @param {Hash} options
- @returns {String} HTML string
- */
- EmberHandlebars.registerHelper('if', function (context, options) {
- ember_assert("You must pass exactly one argument to the if helper", arguments.length === 2);
- ember_assert("You must pass a block to the if helper", options.fn && options.fn !== Handlebars.VM.noop);
-
- return helpers.boundIf.call(options.contexts[0], context, options);
- });
-
- /**
- @name Handlebars.helpers.unless
- @param {Function} context
- @param {Hash} options
- @returns {String} HTML string
- */
- EmberHandlebars.registerHelper('unless', function (context, options) {
- ember_assert("You must pass exactly one argument to the unless helper", arguments.length === 2);
- ember_assert("You must pass a block to the unless helper", options.fn && options.fn !== Handlebars.VM.noop);
-
- var fn = options.fn, inverse = options.inverse;
-
- options.fn = inverse;
- options.inverse = fn;
-
- return helpers.boundIf.call(options.contexts[0], context, options);
- });
-
- /**
- `bindAttr` allows you to create a binding between DOM element attributes and
- Ember objects. For example:
-
-
-
- @name Handlebars.helpers.bindAttr
- @param {Hash} options
- @returns {String} HTML string
- */
- EmberHandlebars.registerHelper('bindAttr', function (options) {
-
- var attrs = options.hash;
-
- ember_assert("You must specify at least one hash argument to bindAttr", !!Ember.keys(attrs).length);
-
- var view = options.data.view;
- var ret = [];
- var ctx = this;
-
- // Generate a unique id for this element. This will be added as a
- // data attribute to the element so it can be looked up when
- // the bound property changes.
- var dataId = ++Ember.$.uuid;
-
- // Handle classes differently, as we can bind multiple classes
- var classBindings = attrs['class'];
- if (classBindings !== null && classBindings !== undefined) {
- var classResults = EmberHandlebars.bindClasses(this, classBindings, view, dataId, options);
- ret.push('class="' + Handlebars.Utils.escapeExpression(classResults.join(' ')) + '"');
- delete attrs['class'];
- }
-
- var attrKeys = Ember.keys(attrs);
-
- // For each attribute passed, create an observer and emit the
- // current value of the property as an attribute.
- forEach(attrKeys, function (attr) {
- var property = attrs[attr];
-
- ember_assert(fmt("You must provide a String for a bound attribute, not %@", [property]), typeof property === 'string');
-
- var value = (property === 'this') ? ctx : getPath(ctx, property, options),
- type = Ember.typeOf(value);
-
- ember_assert(fmt("Attributes must be numbers, strings or booleans, not %@", [value]), value === null || value === undefined || type === 'number' || type === 'string' || type === 'boolean');
-
- var observer, invoker;
-
- /** @private */
- observer = function observer() {
- var result = getPath(ctx, property, options);
-
- ember_assert(fmt("Attributes must be numbers, strings or booleans, not %@", [result]), result === null || result === undefined || typeof result === 'number' || typeof result === 'string' || typeof result === 'boolean');
-
- var elem = view.$("[data-bindattr-" + dataId + "='" + dataId + "']");
-
- // If we aren't able to find the element, it means the element
- // to which we were bound has been removed from the view.
- // In that case, we can assume the template has been re-rendered
- // and we need to clean up the observer.
- if (elem.length === 0) {
- Ember.removeObserver(ctx, property, invoker);
- return;
- }
-
- Ember.View.applyAttributeBindings(elem, attr, result);
- };
-
- /** @private */
- invoker = function () {
- Ember.run.once(observer);
- };
-
- // Add an observer to the view for when the property changes.
- // When the observer fires, find the element using the
- // unique data id and update the attribute to the new value.
- if (property !== 'this') {
- Ember.addObserver(ctx, property, invoker);
- }
-
- // if this changes, also change the logic in ember-views/lib/views/view.js
- if ((type === 'string' || (type === 'number' && !isNaN(value)))) {
- ret.push(attr + '="' + Handlebars.Utils.escapeExpression(value) + '"');
- } else if (value && type === 'boolean') {
- // The developer controls the attr name, so it should always be safe
- ret.push(attr + '="' + attr + '"');
- }
- }, this);
-
- // Add the unique identifier
- // NOTE: We use all lower-case since Firefox has problems with mixed case in SVG
- ret.push('data-bindattr-' + dataId + '="' + dataId + '"');
- return new EmberHandlebars.SafeString(ret.join(' '));
- });
-
- /**
- Helper that, given a space-separated string of property paths and a context,
- returns an array of class names. Calling this method also has the side
- effect of setting up observers at those property paths, such that if they
- change, the correct class name will be reapplied to the DOM element.
-
- For example, if you pass the string "fooBar", it will first look up the
- "fooBar" value of the context. If that value is true, it will add the
- "foo-bar" class to the current element (i.e., the dasherized form of
- "fooBar"). If the value is a string, it will add that string as the class.
- Otherwise, it will not add any new class name.
-
- @param {Ember.Object} context
- The context from which to lookup properties
-
- @param {String} classBindings
- A string, space-separated, of class bindings to use
-
- @param {Ember.View} view
- The view in which observers should look for the element to update
-
- @param {Srting} bindAttrId
- Optional bindAttr id used to lookup elements
-
- @returns {Array} An array of class names to add
- */
- EmberHandlebars.bindClasses = function (context, classBindings, view, bindAttrId, options) {
- var ret = [], newClass, value, elem;
-
- // Helper method to retrieve the property from the context and
- // determine which class string to return, based on whether it is
- // a Boolean or not.
- var classStringForProperty = function (property) {
- var split = property.split(':'),
- className = split[1];
-
- property = split[0];
-
- var val = property !== '' ? getPath(context, property, options) : true;
-
- // If the value is truthy and we're using the colon syntax,
- // we should return the className directly
- if (!!val && className) {
- return className;
-
- // 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 = property.split('.');
- return Ember.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 !== undefined && 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;
- }
- };
-
- // For each property passed, loop through and setup
- // an observer.
- forEach(classBindings.split(' '), function (binding) {
-
- // 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;
-
- var observer, invoker;
-
- // Set up an observer on the context. If the property changes, toggle the
- // class name.
- /** @private */
- observer = function () {
- // Get the current value of the property
- newClass = classStringForProperty(binding);
- elem = bindAttrId ? view.$("[data-bindattr-" + bindAttrId + "='" + bindAttrId + "']") : view.$();
-
- // If we can't find the element anymore, a parent template has been
- // re-rendered and we've been nuked. Remove the observer.
- if (elem.length === 0) {
- Ember.removeObserver(context, binding, invoker);
- } else {
- // If we had previously added a class to the element, remove it.
- if (oldClass) {
- elem.removeClass(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;
- }
- }
- };
-
- /** @private */
- invoker = function () {
- Ember.run.once(observer);
- };
-
- var property = binding.split(':')[0];
- if (property !== '') {
- Ember.addObserver(context, property, invoker);
- }
-
- // We've already setup the observer; now we just need to figure out the
- // correct behavior right now on the first pass through.
- value = classStringForProperty(binding);
-
- if (value) {
- ret.push(value);
-
- // Make sure we save the current value so that it can be removed if the
- // observer fires.
- oldClass = value;
- }
- });
-
- return ret;
- };
-
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- /*globals Handlebars ember_assert */
-
-// TODO: Don't require the entire module
- var get = Ember.get, set = Ember.set;
- var indexOf = Ember.ArrayUtils.indexOf;
- var PARENT_VIEW_PATH = /^parentView\./;
- var EmberHandlebars = Ember.Handlebars;
-
- /** @private */
- EmberHandlebars.ViewHelper = Ember.Object.create({
-
- viewClassFromHTMLOptions: function (viewClass, options, thisContext) {
- var hash = options.hash, data = options.data;
- var extensions = {},
- classes = hash['class'],
- dup = false;
-
- if (hash.id) {
- extensions.elementId = hash.id;
- dup = true;
- }
-
- if (classes) {
- classes = classes.split(' ');
- extensions.classNames = classes;
- dup = true;
- }
-
- if (hash.classBinding) {
- extensions.classNameBindings = hash.classBinding.split(' ');
- dup = true;
- }
-
- if (hash.classNameBindings) {
- extensions.classNameBindings = hash.classNameBindings.split(' ');
- dup = true;
- }
-
- if (hash.attributeBindings) {
- ember_assert("Setting 'attributeBindings' via Handlebars is not allowed. Please subclass Ember.View and set it there instead.");
- extensions.attributeBindings = null;
- dup = true;
- }
-
- if (dup) {
- hash = Ember.$.extend({}, hash);
- delete hash.id;
- delete hash['class'];
- delete hash.classBinding;
- }
-
- // Look for bindings passed to the helper and, if they are
- // local, make them relative to the current context instead of the
- // view.
- var path, normalized;
-
- for (var prop in hash) {
- if (!hash.hasOwnProperty(prop)) {
- continue;
- }
-
- // Test if the property ends in "Binding"
- if (Ember.IS_BINDING.test(prop)) {
- path = hash[prop];
-
- normalized = Ember.Handlebars.normalizePath(null, path, data);
- if (normalized.isKeyword) {
- hash[prop] = 'templateData.keywords.' + path;
- } else if (!Ember.isGlobalPath(path)) {
- if (path === 'this') {
- hash[prop] = 'bindingContext';
- } else {
- hash[prop] = 'bindingContext.' + path;
- }
- }
- }
- }
-
- // Make the current template context available to the view
- // for the bindings set up above.
- extensions.bindingContext = thisContext;
-
- return viewClass.extend(hash, extensions);
- },
-
- helper: function (thisContext, path, options) {
- var inverse = options.inverse,
- data = options.data,
- view = data.view,
- fn = options.fn,
- hash = options.hash,
- newView;
-
- if ('string' === typeof path) {
- newView = EmberHandlebars.getPath(thisContext, path, options);
- ember_assert("Unable to find view at path '" + path + "'", !!newView);
- } else {
- newView = path;
- }
-
- ember_assert(Ember.String.fmt('You must pass a view class to the #view helper, not %@ (%@)', [path, newView]), Ember.View.detect(newView));
-
- newView = this.viewClassFromHTMLOptions(newView, options, thisContext);
- var currentView = data.view;
- var viewOptions = {
- templateData: options.data
- };
-
- if (fn) {
- ember_assert("You cannot provide a template block if you also specified a templateName", !get(viewOptions, 'templateName') && !get(newView.proto(), 'templateName'));
- viewOptions.template = fn;
- }
-
- currentView.appendChild(newView, viewOptions);
- }
- });
-
- /**
- `{{view}}` inserts a new instance of `Ember.View` into a template passing its options
- to the `Ember.View`'s `create` method and using the supplied block as the view's own template.
-
- An empty `` and the following template:
-
-
-
- Will result in HTML structure:
-
-
-
-
-
- A span:
-
- Hello.
-
-
-
-
- ### parentView setting
- The `parentView` property of the new `Ember.View` instance created through `{{view}}`
- will be set to the `Ember.View` instance of the template where `{{view}}` was called.
-
- aView = Ember.View.create({
- template: Ember.Handlebars.compile("{{#view}} my parent: {{parentView.elementId}} {{/view}}")
- })
-
- aView.appendTo('body')
-
- Will result in HTML structure:
-
-
-
- my parent: ember1
-
-
-
-
-
- ### Setting CSS id and class attributes
- The HTML `id` attribute can be set on the `{{view}}`'s resulting element with the `id` option.
- This option will _not_ be passed to `Ember.View.create`.
-
-
-
- Results in the following HTML structure:
-
-
-
- hello.
-
-
-
- The HTML `class` attribute can be set on the `{{view}}`'s resulting element with
- the `class` or `classNameBindings` options. The `class` option
- will directly set the CSS `class` attribute and will not be passed to
- `Ember.View.create`. `classNameBindings` will be passed to `create` and use
- `Ember.View`'s class name binding functionality:
-
-
-
- Results in the following HTML structure:
-
-
-
- hello.
-
-
-
- ### Supplying a different view class
- `{{view}}` can take an optional first argument before its supplied options to specify a
- path to a custom view class.
-
-
-
- The first argument can also be a relative path. Ember will search for the view class
- starting at the `Ember.View` of the template where `{{view}}` was used as the root object:
-
-
- MyApp = Ember.Application.create({})
- MyApp.OuterView = Ember.View.extend({
- innerViewClass: Ember.View.extend({
- classNames: ['a-custom-view-class-as-property']
- }),
- template: Ember.Handlebars.compile('{{#view "innerViewClass"}} hi {{/view}}')
- })
-
- MyApp.OuterView.create().appendTo('body')
-
- Will result in the following HTML:
-
-
-
- ### Blockless use
- If you supply a custom `Ember.View` subclass that specifies its own template
- or provide a `templateName` option to `{{view}}` it can be used without supplying a block.
- Attempts to use both a `templateName` option and supply a block will throw an error.
-
-
-
- ### viewName property
- You can supply a `viewName` option to `{{view}}`. The `Ember.View` instance will
- be referenced as a property of its parent view by this name.
-
- aView = Ember.View.create({
- template: Ember.Handlebars.compile('{{#view viewName="aChildByName"}} hi {{/view}}')
- })
-
- aView.appendTo('body')
- aView.get('aChildByName') // the instance of Ember.View created by {{view}} helper
-
- @name Handlebars.helpers.view
- @param {String} path
- @param {Hash} options
- @returns {String} HTML string
- */
- EmberHandlebars.registerHelper('view', function (path, options) {
- ember_assert("The view helper only takes a single argument", arguments.length <= 2);
-
- // If no path is provided, treat path param as options.
- if (path && path.data && path.data.isRenderData) {
- options = path;
- path = "Ember.View";
- }
-
- return EmberHandlebars.ViewHelper.helper(this, path, options);
- });
-
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- /*globals Handlebars ember_assert */
-
-// TODO: Don't require all of this module
- var get = Ember.get, getPath = Ember.Handlebars.getPath, fmt = Ember.String.fmt;
-
- /**
- @name Handlebars.helpers.collection
- @param {String} path
- @param {Hash} options
- @returns {String} HTML string
-
- `{{collection}}` is a `Ember.Handlebars` helper for adding instances of
- `Ember.CollectionView` to a template. See `Ember.CollectionView` for additional
- information on how a `CollectionView` functions.
-
- `{{collection}}`'s primary use is as a block helper with a `contentBinding` option
- pointing towards an `Ember.Array`-compatible object. An `Ember.View` instance will
- be created for each item in its `content` property. Each view will have its own
- `content` property set to the appropriate item in the collection.
-
- The provided block will be applied as the template for each item's view.
-
- Given an empty `` the following template:
-
-
-
- And the following application code
-
- App = Ember.Application.create()
- App.items = [
- Ember.Object.create({name: 'Dave'}),
- Ember.Object.create({name: 'Mary'}),
- Ember.Object.create({name: 'Sara'})
- ]
-
- Will result in the HTML structure below
-
-
-
Hi Dave
-
Hi Mary
-
Hi Sara
-
-
- ### Blockless Use
- If you provide an `itemViewClass` option that has its own `template` you can omit
- the block.
-
- The following template:
-
-
-
- And application code
-
- App = Ember.Application.create()
- App.items = [
- Ember.Object.create({name: 'Dave'}),
- Ember.Object.create({name: 'Mary'}),
- Ember.Object.create({name: 'Sara'})
- ]
-
- App.AnItemView = Ember.View.extend({
- template: Ember.Handlebars.compile("Greetings {{content.name}}")
- })
-
- Will result in the HTML structure below
-
-
-
Greetings Dave
-
Greetings Mary
-
Greetings Sara
-
-
- ### Specifying a CollectionView subclass
- By default the `{{collection}}` helper will create an instance of `Ember.CollectionView`.
- You can supply a `Ember.CollectionView` subclass to the helper by passing it
- as the first argument:
-
-
-
-
- ### Forwarded `item.*`-named Options
- As with the `{{view}}`, helper options passed to the `{{collection}}` will be set on
- the resulting `Ember.CollectionView` as properties. Additionally, options prefixed with
- `item` will be applied to the views rendered for each item (note the camelcasing):
-
-
-
- Will result in the following HTML structure:
-
-
-
Howdy Dave
-
Howdy Mary
-
Howdy Sara
-
-
-
- */
- Ember.Handlebars.registerHelper('collection', function (path, options) {
- // If no path is provided, treat path param as options.
- if (path && path.data && path.data.isRenderData) {
- options = path;
- path = undefined;
- ember_assert("You cannot pass more than one argument to the collection helper", arguments.length === 1);
- } else {
- ember_assert("You cannot pass more than one argument to the collection helper", arguments.length === 2);
- }
-
- var fn = options.fn;
- var data = options.data;
- var inverse = options.inverse;
-
- // If passed a path string, convert that into an object.
- // Otherwise, just default to the standard class.
- var collectionClass;
- collectionClass = path ? getPath(this, path, options) : Ember.CollectionView;
- ember_assert(fmt("%@ #collection: Could not find %@", data.view, path), !!collectionClass);
-
- var hash = options.hash, itemHash = {}, match;
-
- // Extract item view class if provided else default to the standard class
- var itemViewClass, itemViewPath = hash.itemViewClass;
- var collectionPrototype = collectionClass.proto();
- delete hash.itemViewClass;
- itemViewClass = itemViewPath ? getPath(collectionPrototype, itemViewPath, options) : collectionPrototype.itemViewClass;
- ember_assert(fmt("%@ #collection: Could not find %@", data.view, itemViewPath), !!itemViewClass);
-
- // 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 (hash.hasOwnProperty(prop)) {
- match = prop.match(/^item(.)(.*)$/);
-
- if (match) {
- // Convert itemShouldFoo -> shouldFoo
- itemHash[match[1].toLowerCase() + match[2]] = hash[prop];
- // Delete from hash as this will end up getting passed to the
- // {{view}} helper method.
- delete hash[prop];
- }
- }
- }
-
- var tagName = hash.tagName || collectionPrototype.tagName;
-
- if (fn) {
- itemHash.template = fn;
- delete options.fn;
- }
-
- if (inverse && inverse !== Handlebars.VM.noop) {
- var emptyViewClass = Ember.View;
-
- if (hash.emptyViewClass) {
- emptyViewClass = Ember.View.detect(hash.emptyViewClass) ?
- hash.emptyViewClass : getPath(this, hash.emptyViewClass, options);
- }
-
- hash.emptyView = emptyViewClass.extend({
- template: inverse,
- tagName: itemHash.tagName
- });
- }
-
- if (hash.preserveContext) {
- itemHash._templateContext = Ember.computed(function () {
- return get(this, 'content');
- }).property('content');
- delete hash.preserveContext;
- }
-
- hash.itemViewClass = Ember.Handlebars.ViewHelper.viewClassFromHTMLOptions(itemViewClass, { data: data, hash: itemHash }, this);
-
- return Ember.Handlebars.helpers.view.call(this, collectionClass, options);
- });
-
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- /*globals Handlebars */
- var getPath = Ember.Handlebars.getPath;
-
- /**
- `unbound` allows you to output a property without binding. *Important:* The
- output will not be updated if the property changes. Use with caution.
-
- {{unbound somePropertyThatDoesntChange}}
-
- @name Handlebars.helpers.unbound
- @param {String} property
- @returns {String} HTML string
- */
- Ember.Handlebars.registerHelper('unbound', function (property, fn) {
- var context = (fn.contexts && fn.contexts[0]) || this;
- return getPath(context, property, fn);
- });
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-
- /*jshint debug:true*/
- var getPath = Ember.getPath;
-
- /**
- `log` allows you to output the value of a value in the current rendering
- context.
-
- {{log myVariable}}
-
- @name Handlebars.helpers.log
- @param {String} property
- */
- Ember.Handlebars.registerHelper('log', function (property, fn) {
- var context = (fn.contexts && fn.contexts[0]) || this;
- Ember.Logger.log(getPath(context, property));
- });
-
- /**
- The `debugger` helper executes the `debugger` statement in the current
- context.
-
- {{debugger}}
-
- @name Handlebars.helpers.debugger
- @param {String} property
- */
- Ember.Handlebars.registerHelper('debugger', function () {
- debugger;
- });
-
-})();
-
-
-(function () {
- Ember.Handlebars.EachView = Ember.CollectionView.extend(Ember.Metamorph, {
- itemViewClass: Ember.View.extend(Ember.Metamorph)
- });
-
- Ember.Handlebars.registerHelper('each', function (path, options) {
- options.hash.contentBinding = path;
- options.hash.preserveContext = true;
-
- // Set up emptyView as a metamorph with no tag
- options.hash.itemTagName = '';
- options.hash.emptyViewClass = Ember.View.extend(Ember.Metamorph);
-
- return Ember.Handlebars.helpers.collection.call(this, 'Ember.Handlebars.EachView', options);
- });
-
-})();
-
-
-(function () {
- /**
- `template` allows you to render a template from inside another template.
- This allows you to re-use the same template in multiple places. For example:
-
-
-
-
-
- This helper looks for templates in the global Ember.TEMPLATES hash. If you
- add <script> tags to your page with the `data-template-name` attribute set,
- they will be compiled and placed in this hash automatically.
-
- You can also manually register templates by adding them to the hash:
-
- Ember.TEMPLATES["my_cool_template"] = Ember.Handlebars.compile('{{user}} ');
-
- @name Handlebars.helpers.template
- @param {String} templateName the template to render
- */
-
- Ember.Handlebars.registerHelper('template', function (name, options) {
- var template = Ember.TEMPLATES[name];
-
- ember_assert("Unable to find template with name '" + name + "'.", !!template);
-
- Ember.TEMPLATES[name](this, { data: options.data });
- });
-
-})();
-
-
-(function () {
- var EmberHandlebars = Ember.Handlebars, getPath = EmberHandlebars.getPath;
-
- var ActionHelper = EmberHandlebars.ActionHelper = {
- registeredActions: {}
- };
-
- ActionHelper.registerAction = function (actionName, eventName, target, view, context) {
- var actionId = (++Ember.$.uuid).toString();
-
- ActionHelper.registeredActions[actionId] = {
- eventName: eventName,
- handler: function (event) {
- event.view = view;
- event.context = context;
-
- // Check for StateManager (or compatible object)
- if (target.isState && typeof target.send === 'function') {
- return target.send(actionName, event);
- } else {
- return target[actionName].call(target, event);
- }
- }
- };
-
- view.on('willRerender', function () {
- delete ActionHelper.registeredActions[actionId];
- });
-
- return actionId;
- };
-
- /**
- The `{{action}}` helper registers an HTML element within a template for
- DOM event handling. User interaction with that element will call the method
- on the template's associated `Ember.View` instance that has the same name
- as the first provided argument to `{{action}}`:
-
- Given the following Handlebars template on the page
-
-
-
- And application code
-
- AView = Ember.View.extend({
- templateName; 'a-template',
- anActionName: function(event){}
- })
-
- aView = AView.create()
- aView.appendTo('body')
-
- Will results in the following rendered HTML
-
-
-
- Clicking "click me" will trigger the `anActionName` method of the `aView` object with a
- `jQuery.Event` object as its argument. The `jQuery.Event` object will be extended to include
- a `view` property that is set to the original view interacted with (in this case the `aView` object).
-
-
- ### Specifying an Action Target
- A `target` option can be provided to change which object will receive the method call. This option must be
- a string representing a path to an object:
-
-
-
- Clicking "click me" in the rendered HTML of the above template will trigger the
- `anActionName` method of the object at `MyApplication.someObject`. The first argument
- to this method will be a `jQuery.Event` extended to include a `view` property that is
- set to the original view interacted with.
-
- A path relative to the template's `Ember.View` instance can also be used as a target:
-
-
-
- Clicking "click me" in the rendered HTML of the above template will trigger the
- `anActionName` method of the view's parent view.
-
- The `{{action}}` helper is `Ember.StateManager` aware. If the target of
- the action is an `Ember.StateManager` instance `{{action}}` will use the `send`
- functionality of StateManagers. The documentation for `Ember.StateManager` has additional
- information about this use.
-
- If an action's target does not implement a method that matches the supplied action name
- an error will be thrown.
-
-
-
-
- With the following application code
-
- AView = Ember.View.extend({
- templateName; 'a-template',
- // note: no method 'aMethodNameThatIsMissing'
- anActionName: function(event){}
- })
-
- aView = AView.create()
- aView.appendTo('body')
-
- Will throw `Uncaught TypeError: Cannot call method 'call' of undefined` when "click me" is clicked.
-
-
- ### Specifying DOM event type
- 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:
-
-
-
- See `Ember.EventDispatcher` for a list of acceptable DOM event names.
-
- Because `{{action}}` depends on Ember's event dispatch system it will only function if
- an `Ember.EventDispatcher` instance is available. An `Ember.EventDispatcher` instance
- will be created when a new `Ember.Application` is created. Having an instance of
- `Ember.Application` will satisfy this requirement.
-
- @name Handlebars.helpers.action
- @param {String} actionName
- @param {Hash} options
- */
- EmberHandlebars.registerHelper('action', function (actionName, options) {
- var hash = options.hash || {},
- eventName = hash.on || "click",
- view = options.data.view,
- target, context;
-
- if (view.isVirtual) {
- view = view.get('parentView');
- }
- target = hash.target ? getPath(this, hash.target, options) : view;
- context = options.contexts[0];
-
- var actionId = ActionHelper.registerAction(actionName, eventName, target, view, context);
- return new EmberHandlebars.SafeString('data-ember-action="' + actionId + '"');
- });
-
-})();
-
-
-(function () {
- var get = Ember.get, set = Ember.set;
-
- /**
-
- When used in a Handlebars template that is assigned to an `Ember.View` instance's
- `layout` property Ember will render the layout template first, inserting the view's
- own rendered output at the `{{ yield }}` location.
-
- An empty `` and the following application code:
-
- AView = Ember.View.extend({
- classNames: ['a-view-with-layout'],
- layout: Ember.Handlebars.compile('{{ yield }}
'),
- template: Ember.Handlebars.compile('I am wrapped ')
- })
-
- aView = AView.create()
- aView.appendTo('body')
-
- Will result in the following HTML output:
-
-
-
-
-
-
- The yield helper cannot be used outside of a template assigned to an `Ember.View`'s `layout` property
- and will throw an error if attempted.
-
- BView = Ember.View.extend({
- classNames: ['a-view-with-layout'],
- template: Ember.Handlebars.compile('{{yield}}')
- })
-
- bView = BView.create()
- bView.appendTo('body')
-
- // throws
- // Uncaught Error: assertion failed: You called yield in a template that was not a layout
-
- @name Handlebars.helpers.yield
- @param {Hash} options
- @returns {String} HTML string
- */
- Ember.Handlebars.registerHelper('yield', function (options) {
- var view = options.data.view, template;
-
- while (view && !get(view, 'layout')) {
- view = get(view, 'parentView');
- }
-
- ember_assert("You called yield in a template that was not a layout", !!view);
-
- template = get(view, 'template');
-
- if (template) {
- template(this, options);
- }
- });
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- var set = Ember.set, get = Ember.get;
-
- /**
- @class
-
- Creates an HTML input view in one of two formats.
-
- If a `title` property or binding is provided the input will be wrapped in
- a `div` and `label` tag. View properties like `classNames` will be applied to
- the outermost `div`. This behavior is deprecated and will issue a warning in development.
-
-
- {{view Ember.Checkbox classNames="applicaton-specific-checkbox" title="Some title"}}
-
-
-
- Some title
-
-
- If `title` isn't provided the view will render as an input element of the 'checkbox' type and HTML
- related properties will be applied directly to the input.
-
- {{view Ember.Checkbox classNames="applicaton-specific-checkbox"}}
-
-
-
- You can add a `label` tag yourself in the template where the Ember.Checkbox is being used.
-
-
- Some Title
- {{view Ember.Checkbox classNames="applicaton-specific-checkbox"}}
-
-
-
- The `checked` attribute of an Ember.Checkbox object should always be set
- through the Ember object or by interacting with its rendered element representation
- via the mouse, keyboard, or touch. Updating the value of the checkbox via jQuery will
- result in the checked value of the object and its element losing synchronization.
-
- */
- Ember.Checkbox = Ember.View.extend({
- classNames: ['ember-checkbox'],
-
- tagName: 'input',
-
- attributeBindings: ['type', 'checked', 'disabled'],
-
- type: "checkbox",
- checked: false,
- disabled: false,
-
- // Deprecated, use 'checked' instead
- title: null,
-
- value: Ember.computed(function (propName, value) {
- ember_deprecate("Ember.Checkbox's 'value' property has been renamed to 'checked' to match the html element attribute name");
- if (value !== undefined) {
- return set(this, 'checked', value);
- } else {
- return get(this, 'checked');
- }
- }).property('checked').volatile(),
-
- change: function () {
- Ember.run.once(this, this._updateElementValue);
- // returning false will cause IE to not change checkbox state
- },
-
- /**
- @private
- */
- _updateElementValue: function () {
- var input = get(this, 'title') ? this.$('input:checkbox') : this.$();
- set(this, 'checked', input.prop('checked'));
- },
-
- init: function () {
- if (get(this, 'title') || get(this, 'titleBinding')) {
- ember_deprecate("Automatically surrounding Ember.Checkbox inputs with a label by providing a 'title' property is deprecated");
- this.tagName = undefined;
- this.attributeBindings = [];
- this.defaultTemplate = Ember.Handlebars.compile(' {{title}} ');
- }
-
- this._super();
- }
- });
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- var get = Ember.get, set = Ember.set;
-
- /** @class */
- Ember.TextSupport = Ember.Mixin.create(
- /** @scope Ember.TextSupport.prototype */ {
-
- value: "",
-
- attributeBindings: ['placeholder', 'disabled', 'maxlength'],
- placeholder: null,
- disabled: false,
- maxlength: null,
-
- insertNewline: Ember.K,
- cancel: Ember.K,
-
- focusOut: function (event) {
- this._elementValueDidChange();
- },
-
- change: function (event) {
- this._elementValueDidChange();
- },
-
- keyUp: function (event) {
- this.interpretKeyEvents(event);
- },
-
- /**
- @private
- */
- interpretKeyEvents: function (event) {
- var map = Ember.TextSupport.KEY_EVENTS;
- var method = map[event.keyCode];
-
- this._elementValueDidChange();
- if (method) {
- return this[method](event);
- }
- },
-
- _elementValueDidChange: function () {
- set(this, 'value', this.$().val());
- }
-
- });
-
- Ember.TextSupport.KEY_EVENTS = {
- 13: 'insertNewline',
- 27: 'cancel'
- };
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- var get = Ember.get, set = Ember.set;
-
- /**
- @class
- @extends Ember.TextSupport
- */
- Ember.TextField = Ember.View.extend(Ember.TextSupport,
- /** @scope Ember.TextField.prototype */ {
-
- classNames: ['ember-text-field'],
-
- tagName: "input",
- attributeBindings: ['type', 'value', 'size'],
- type: "text",
- size: null
- });
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- var get = Ember.get, set = Ember.set;
-
- Ember.Button = Ember.View.extend(Ember.TargetActionSupport, {
- classNames: ['ember-button'],
- classNameBindings: ['isActive'],
-
- tagName: 'button',
-
- propagateEvents: false,
-
- attributeBindings: ['type', 'disabled', 'href'],
-
- /** @private
- Overrides TargetActionSupport's targetObject computed
- property to use Handlebars-specific path resolution.
- */
- targetObject: Ember.computed(function () {
- var target = get(this, 'target'),
- root = get(this, 'templateContext'),
- data = get(this, 'templateData');
-
- if (typeof target !== 'string') {
- return target;
- }
-
- return Ember.Handlebars.getPath(root, target, { data: data });
- }).property('target').cacheable(),
-
- // Defaults to 'button' if tagName is 'input' or 'button'
- type: Ember.computed(function (key, value) {
- var tagName = this.get('tagName');
- if (value !== undefined) {
- this._type = value;
- }
- if (this._type !== undefined) {
- return this._type;
- }
- if (tagName === 'input' || tagName === 'button') {
- return 'button';
- }
- }).property('tagName').cacheable(),
-
- disabled: false,
-
- // Allow 'a' tags to act like buttons
- href: Ember.computed(function () {
- return this.get('tagName') === 'a' ? '#' : null;
- }).property('tagName').cacheable(),
-
- mouseDown: function () {
- if (!get(this, 'disabled')) {
- set(this, 'isActive', true);
- this._mouseDown = true;
- this._mouseEntered = true;
- }
- return get(this, 'propagateEvents');
- },
-
- mouseLeave: function () {
- if (this._mouseDown) {
- set(this, 'isActive', false);
- this._mouseEntered = false;
- }
- },
-
- mouseEnter: function () {
- if (this._mouseDown) {
- set(this, 'isActive', true);
- this._mouseEntered = true;
- }
- },
-
- mouseUp: function (event) {
- if (get(this, 'isActive')) {
- // Actually invoke the button's target and action.
- // This method comes from the Ember.TargetActionSupport mixin.
- this.triggerAction();
- set(this, 'isActive', false);
- }
-
- this._mouseDown = false;
- this._mouseEntered = false;
- return get(this, 'propagateEvents');
- },
-
- keyDown: function (event) {
- // Handle space or enter
- if (event.keyCode === 13 || event.keyCode === 32) {
- this.mouseDown();
- }
- },
-
- keyUp: function (event) {
- // Handle space or enter
- if (event.keyCode === 13 || event.keyCode === 32) {
- this.mouseUp();
- }
- },
-
- // TODO: Handle proper touch behavior. Including should make inactive when
- // finger moves more than 20x outside of the edge of the button (vs mouse
- // which goes inactive as soon as mouse goes out of edges.)
-
- touchStart: function (touch) {
- return this.mouseDown(touch);
- },
-
- touchEnd: function (touch) {
- return this.mouseUp(touch);
- },
-
- init: function () {
- ember_deprecate("Ember.Button is deprecated and will be removed from future releases. Consider using the `{{action}}` helper.");
- this._super();
- }
- });
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- var get = Ember.get, set = Ember.set;
-
- /**
- @class
- @extends Ember.TextSupport
- */
- Ember.TextArea = Ember.View.extend(Ember.TextSupport,
- /** @scope Ember.TextArea.prototype */ {
-
- classNames: ['ember-text-area'],
-
- tagName: "textarea",
- attributeBindings: ['rows', 'cols'],
- rows: null,
- cols: null,
-
- /**
- @private
- */
- didInsertElement: function () {
- this._updateElementValue();
- },
-
- _updateElementValue: Ember.observer(function () {
- this.$().val(get(this, 'value'));
- }, 'value')
-
- });
-
-})();
-
-
-(function () {
- Ember.TabContainerView = Ember.View.extend();
-
-})();
-
-
-(function () {
- var get = Ember.get, getPath = Ember.getPath;
-
- Ember.TabPaneView = Ember.View.extend({
- tabsContainer: Ember.computed(function () {
- return this.nearestInstanceOf(Ember.TabContainerView);
- }).property().volatile(),
-
- isVisible: Ember.computed(function () {
- return get(this, 'viewName') === getPath(this, 'tabsContainer.currentView');
- }).property('tabsContainer.currentView').volatile()
- });
-
-})();
-
-
-(function () {
- var get = Ember.get, setPath = Ember.setPath;
-
- Ember.TabView = Ember.View.extend({
- tabsContainer: Ember.computed(function () {
- return this.nearestInstanceOf(Ember.TabContainerView);
- }).property().volatile(),
-
- mouseUp: function () {
- setPath(this, 'tabsContainer.currentView', get(this, 'value'));
- }
- });
-
-})();
-
-
-(function () {
-
-})();
-
-
-(function () {
- /*jshint eqeqeq:false */
-
- var set = Ember.set, get = Ember.get, getPath = Ember.getPath;
- var indexOf = Ember.ArrayUtils.indexOf, indexesOf = Ember.ArrayUtils.indexesOf;
-
- Ember.Select = Ember.View.extend({
- tagName: 'select',
- defaultTemplate: Ember.Handlebars.compile(
- '{{#if prompt}}{{prompt}} {{/if}}' +
- '{{#each content}}{{view Ember.SelectOption contentBinding="this"}}{{/each}}'
- ),
- attributeBindings: ['multiple'],
-
- multiple: false,
- content: null,
- selection: null,
- prompt: null,
-
- optionLabelPath: 'content',
- optionValuePath: 'content',
-
- didInsertElement: function () {
- var selection = get(this, 'selection');
-
- if (selection) {
- this.selectionDidChange();
- }
-
- this.change();
- },
-
- change: function () {
- if (get(this, 'multiple')) {
- this._changeMultiple();
- } else {
- this._changeSingle();
- }
- },
-
- selectionDidChange: Ember.observer(function () {
- var selection = get(this, 'selection'),
- isArray = Ember.isArray(selection);
- if (get(this, 'multiple')) {
- if (!isArray) {
- set(this, 'selection', Ember.A([selection]));
- return;
- }
- this._selectionDidChangeMultiple();
- } else {
- this._selectionDidChangeSingle();
- }
- }, 'selection'),
-
-
- _changeSingle: function () {
- var selectedIndex = this.$()[0].selectedIndex,
- content = get(this, 'content'),
- prompt = get(this, 'prompt');
-
- if (!content) {
- return;
- }
- if (prompt && selectedIndex === 0) {
- set(this, 'selection', null);
- return;
- }
-
- if (prompt) {
- selectedIndex -= 1;
- }
- set(this, 'selection', content.objectAt(selectedIndex));
- },
-
- _changeMultiple: function () {
- var options = this.$('option:selected'),
- prompt = get(this, 'prompt'),
- offset = prompt ? 1 : 0,
- content = get(this, 'content');
-
- if (!content) {
- return;
- }
- if (options) {
- var selectedIndexes = options.map(function () {
- return this.index - offset;
- }).toArray();
- set(this, 'selection', content.objectsAt(selectedIndexes));
- }
- },
-
- _selectionDidChangeSingle: function () {
- var el = this.$()[0],
- content = get(this, 'content'),
- selection = get(this, 'selection'),
- selectionIndex = indexOf(content, selection),
- prompt = get(this, 'prompt');
-
- if (prompt) {
- selectionIndex += 1;
- }
- if (el) {
- el.selectedIndex = selectionIndex;
- }
- },
-
- _selectionDidChangeMultiple: function () {
- var content = get(this, 'content'),
- selection = get(this, 'selection'),
- selectedIndexes = indexesOf(content, selection),
- prompt = get(this, 'prompt'),
- offset = prompt ? 1 : 0,
- options = this.$('option');
-
- if (options) {
- options.each(function () {
- this.selected = indexOf(selectedIndexes, this.index + offset) > -1;
- });
- }
- }
-
- });
-
- Ember.SelectOption = Ember.View.extend({
- tagName: 'option',
- defaultTemplate: Ember.Handlebars.compile("{{label}}"),
- attributeBindings: ['value', 'selected'],
-
- init: function () {
- this.labelPathDidChange();
- this.valuePathDidChange();
-
- this._super();
- },
-
- selected: Ember.computed(function () {
- var content = get(this, 'content'),
- selection = getPath(this, 'parentView.selection');
- if (getPath(this, 'parentView.multiple')) {
- return selection && indexOf(selection, content) > -1;
- } else {
- // Primitives get passed through bindings as objects... since
- // `new Number(4) !== 4`, we use `==` below
- return content == selection;
- }
- }).property('content', 'parentView.selection').volatile(),
-
- labelPathDidChange: Ember.observer(function () {
- var labelPath = getPath(this, 'parentView.optionLabelPath');
-
- if (!labelPath) {
- return;
- }
-
- Ember.defineProperty(this, 'label', Ember.computed(function () {
- return getPath(this, labelPath);
- }).property(labelPath).cacheable());
- }, 'parentView.optionLabelPath'),
-
- valuePathDidChange: Ember.observer(function () {
- var valuePath = getPath(this, 'parentView.optionValuePath');
-
- if (!valuePath) {
- return;
- }
-
- Ember.defineProperty(this, 'value', Ember.computed(function () {
- return getPath(this, valuePath);
- }).property(valuePath).cacheable());
- }, 'parentView.optionValuePath')
- });
-
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
- /*globals Handlebars */
-// Find templates stored in the head tag as script tags and make them available
-// to Ember.CoreView in the global Ember.TEMPLATES object. This will be run as as
-// jQuery DOM-ready callback.
-//
-// Script tags with "text/x-handlebars" will be compiled
-// with Ember's Handlebars and are suitable for use as a view's template.
-// Those with type="text/x-raw-handlebars" will be compiled with regular
-// Handlebars and are suitable for use in views' computed properties.
- Ember.Handlebars.bootstrap = function (ctx) {
- var selectors = 'script[type="text/x-handlebars"], script[type="text/x-raw-handlebars"]';
-
- if (Ember.ENV.LEGACY_HANDLEBARS_TAGS) {
- selectors += ', script[type="text/html"]';
- }
-
- ember_warn("Ember no longer parses text/html script tags by default. Set ENV.LEGACY_HANDLEBARS_TAGS = true to restore this functionality.", Ember.ENV.LEGACY_HANDLEBARS_TAGS || Ember.$('script[type="text/html"]').length === 0);
-
- Ember.$(selectors, ctx)
- .each(function () {
- // Get a reference to the script tag
- var script = Ember.$(this),
- type = script.attr('type');
-
- var compile = (script.attr('type') === 'text/x-raw-handlebars') ?
- Ember.$.proxy(Handlebars.compile, Handlebars) :
- Ember.$.proxy(Ember.Handlebars.compile, Ember.Handlebars),
- // 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.
- templateName = script.attr('data-template-name') || script.attr('id'),
- template = compile(script.html()),
- view, viewPath, elementId, tagName, options;
-
- if (templateName) {
- // For templates which have a name, we save them and then remove them from the DOM
- Ember.TEMPLATES[templateName] = template;
-
- // Remove script tag from DOM
- script.remove();
- } else {
- if (script.parents('head').length !== 0) {
- // don't allow inline templates in the head
- throw new Ember.Error("Template found in without a name specified. " +
- "Please provide a data-template-name attribute.\n" +
- script.html());
- }
-
- // For templates which will be evaluated inline in the HTML document, instantiates a new
- // view, and replaces the script tag holding the template with the new
- // view's DOM representation.
- //
- // Users can optionally specify a custom view subclass to use by setting the
- // data-view attribute of the script tag.
- viewPath = script.attr('data-view');
- view = viewPath ? Ember.getPath(viewPath) : Ember.View;
-
- // Get the id of the script, used by Ember.View's elementId property,
- // Look for data-element-id attribute.
- elementId = script.attr('data-element-id');
-
- // Users can optionally specify a custom tag name to use by setting the
- // data-tag-name attribute on the script tag.
- tagName = script.attr('data-tag-name');
-
- options = { template: template };
- if (elementId) {
- options.elementId = elementId;
- }
- if (tagName) {
- options.tagName = tagName;
- }
-
- view = view.create(options);
-
- view._insertElementLater(function () {
- script.replaceWith(this.$());
-
- // Avoid memory leak in IE
- script = null;
- });
- }
- });
- };
-
- Ember.$(document).ready(
- function () {
- Ember.Handlebars.bootstrap(Ember.$(document));
- }
- );
-
-})();
-
-
-(function () {
-// ==========================================================================
-// Project: Ember Handlebar Views
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-
-})();
-
-(function () {
-// ==========================================================================
-// Project: Ember
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-
-})();
diff --git a/app/assets/javascripts/ember/helpers/.gitkeep b/app/assets/javascripts/ember/helpers/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/app/assets/javascripts/ember/helpers/debug.js.coffee b/app/assets/javascripts/ember/helpers/debug.js.coffee
deleted file mode 100644
index f3242a34..00000000
--- a/app/assets/javascripts/ember/helpers/debug.js.coffee
+++ /dev/null
@@ -1,8 +0,0 @@
-Handlebars.registerHelper "debug", (optionalValue) ->
- console.log "Current Context"
- console.log "===================="
- console.log this
- if optionalValue
- console.log "Value"
- console.log "===================="
- console.log optionalValue
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/helpers/networks.js.coffee b/app/assets/javascripts/ember/helpers/networks.js.coffee
deleted file mode 100644
index 7eef98d5..00000000
--- a/app/assets/javascripts/ember/helpers/networks.js.coffee
+++ /dev/null
@@ -1,2 +0,0 @@
-Handlebars.registerHelper "each_network", (block)->
- block(network) for network in Coderwall.AllNetworksView.networks when network[0].toUpperCase() == @[0]
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/helpers/teams.js.coffee b/app/assets/javascripts/ember/helpers/teams.js.coffee
deleted file mode 100644
index a9ee4268..00000000
--- a/app/assets/javascripts/ember/helpers/teams.js.coffee
+++ /dev/null
@@ -1,2 +0,0 @@
-Handlebars.registerHelper "signed_in", ->
- UsersController.signedInUser?
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/models/.gitkeep b/app/assets/javascripts/ember/models/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/app/assets/javascripts/ember/models/event.js.coffee b/app/assets/javascripts/ember/models/event.js.coffee
deleted file mode 100644
index b9ffae2f..00000000
--- a/app/assets/javascripts/ember/models/event.js.coffee
+++ /dev/null
@@ -1,54 +0,0 @@
-Coderwall.Event = Ember.Resource.extend(
- resourceUrl: "/:username/events"
- resourceName: "event"
- resourceProperties: [ "version", "event_type", "tags", "url", "hiring" ]
- actionable: true
-
- tweetUrl: Ember.computed(->
- correctedUrl = encodeURI(@.url)
- unless /^https?::\/\//.test(correctedUrl)
- correctedUrl = "http://coderwall.com" + correctedUrl
- 'http://twitter.com/share?url=' + correctedUrl + '&via=coderwall&text=' + encodeURI(@.title) + '+%23protip&related=&count=vertical&lang=en'
- ).property().cacheable()
-
- teamHireUrl: Ember.computed(->
- @team.url + "#open-positions"
- ).property('url').cacheable()
-
- topTag: Ember.computed(->
- if @.tags.get('firstObject')? then @.tags.get('firstObject') else null
- ).property().cacheable()
-
- belongsToTeam: Ember.computed(->
- if @.team? then true else false
- ).property().cacheable()
-
- protipEvent: Ember.computed(->
- @event_type == 'protip_view' or @event_type == 'protip_upvote'
- ).property('event_type').cacheable()
-
- viewEvent: Ember.computed(->
- @event_type == 'protip_view' or @event_type == 'profile_view'
- ).property('event_type').cacheable()
-
-
- eventTypeString: Ember.computed(->
- switch @.event_type
- when 'new_protip' then 'New protip'
- when 'trending_protip' then 'Trending protip'
- when 'admin_message' then 'A message from Coderwall'
- when 'new_team' then 'created a new team'
- when 'new_skill' then 'added a skill'
- when 'endorsement' then 'endorsed you'
- when 'unlocked_achievement' then 'just unlocked an achievement'
- when 'profile_view' then 'viewed your profile'
- when 'protip_view' then 'viewed your protip'
- when 'protip_upvote' then 'upvoted your protip'
- when 'followed_team' then 'just followed your team'
- when 'followed_user' then 'just followed you'
- when 'new_mayor' then 'is mayor of'
- when 'new_comment' then 'commented on your protip'
- when 'comment_like' then 'liked your comment'
- when 'comment_reply' then 'replied to your comment'
- )
-)
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/models/team.js.coffee b/app/assets/javascripts/ember/models/team.js.coffee
deleted file mode 100644
index 48584063..00000000
--- a/app/assets/javascripts/ember/models/team.js.coffee
+++ /dev/null
@@ -1,47 +0,0 @@
-Coderwall.Team = Ember.Resource.extend(
- resourceUrl: "/teams"
- resourceName: "team"
- resourceProperties: [ "id", "name", "score", "size", "avatar", "country", "team_url", "follow_path",
- "followed" ]
-
- rounded_score: Ember.computed(->
- Math.round(@get("score"))
- ).property("score").cacheable()
-
- ordinalized_rank: Ember.computed(->
- @get("rank").toString().ordinalize()
- ).property("score", "rank").cacheable()
-
- has_more_than_min_members: Ember.computed(->
- @get("size") > 3
- ).property("size").cacheable()
-
- remaining_members: Ember.computed(->
- @get("size") - 3
- ).property("size").cacheable()
-
- follow_text: Ember.computed(->
- if @get("followed")
- "Unfollow"
- else
- "Follow"
- ).property("followed").cacheable()
-
-# followed: Ember.computed(->
-# Coderwall.teamsController.followedTeamsList[@get("id")]
-# ).property().cacheable()
-
- follow: ->
- team = @
- $.post(this.follow_path).success ->
- Coderwall.teamsController.updateFollowedTeam team.get("id")
- team.set("followed", Coderwall.teamsController.followedTeamsList[team.get("id")])
-
- followed_class: Ember.computed(->
- classes = "btn btn-large follow "
- if @get("followed")
- classes += "btn-primary"
- classes
- ).property("followed").cacheable()
-
-)
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/models/user.js.coffee b/app/assets/javascripts/ember/models/user.js.coffee
deleted file mode 100644
index 14ca8543..00000000
--- a/app/assets/javascripts/ember/models/user.js.coffee
+++ /dev/null
@@ -1,6 +0,0 @@
-Coderwall.User = Ember.Resource.extend(
- resourceUrl: "/users"
- resourceName: "user"
- resourceProperties: [ "username", "signed_in" ]
-
-)
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/networks.js.coffee b/app/assets/javascripts/ember/networks.js.coffee
deleted file mode 100644
index 95a6a5fa..00000000
--- a/app/assets/javascripts/ember/networks.js.coffee
+++ /dev/null
@@ -1,6 +0,0 @@
-#= require ./coderwall
-#= require_tree ./models
-#= require ./controllers/networks
-#= require_tree ./templates/networks
-#= require_tree ./helpers
-#= require_tree ./views/networks
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/teams.js.coffee b/app/assets/javascripts/ember/teams.js.coffee
deleted file mode 100644
index 6922f272..00000000
--- a/app/assets/javascripts/ember/teams.js.coffee
+++ /dev/null
@@ -1,26 +0,0 @@
-#= require ./coderwall
-#= require ./models/team
-#= require ./controllers/teams
-#= require_tree ./templates/teams
-#= require_tree ./helpers
-#= require_tree ./views/teams
-#= require search
-
-$ ->
- search_teams = (name, country) ->
- query = 'q=' + name
- query += '&country=' + country if country?
- # Coderwall.teamsController.clearAll()
- # $.getJSON encodeURI('/teams/search?' + query), (teams) ->
- # Coderwall.teamsController.loadAll teams
- $.getScript encodeURI('/teams/search?' + query)
-
- $('.country-link').click ->
- search_teams("*", $(this).find('.country-name').text())
-
- searchBox.enableSearch('#teams-search', search_teams)
- $('form.network-search').submit (e)->
- e.preventDefault()
- query = $('#teams-search').val()
- query = "" if query == $('#teams-search').attr('placeholder')
- search_teams(query, null)
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/templates/.gitkeep b/app/assets/javascripts/ember/templates/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/app/assets/javascripts/ember/templates/events/achievement.js.hbs.hamlbars b/app/assets/javascripts/ember/templates/events/achievement.js.hbs.hamlbars
deleted file mode 100644
index 20557213..00000000
--- a/app/assets/javascripts/ember/templates/events/achievement.js.hbs.hamlbars
+++ /dev/null
@@ -1,34 +0,0 @@
-.graphic
-.item
- .header.cf
- %ul.cf
- %li.user
- %img{:bind => {:src => 'event.user.profile_url'}}
- %a.user-name{:bind => {:href => 'event.user.profile_path'}}
- = hb 'event.user.username'
- = hb('if event.belongsToTeam') do
- %li.team
- %span
- of
- %img{:bind => {:src => 'event.team.avatar'}}
- %a{:bind => {:href => 'event.team.url'}}
- =hb 'event.team.name'
- %li.fragment
- = hb 'event.eventTypeString'
- .content.cf
- .badge-unlocked
- = hb('with event.achievement.image_path') do
- %img{:src => hb('image_path')}
- %a{:bind => {:src => 'event.user.profile_url'}}
- %span
- = hb 'event.achievement.name'
- .footer
- %p
- = hb 'event.achievement.achiever.first_name'
- unlocked the
- = hb 'event.achievement.name'
- achievement for
- = hb 'event.achievement.description'
- Only
- = hb 'event.achievement.percentage_of_achievers'
- ==% of developers on Coderwall have earned this achievement.
diff --git a/app/assets/javascripts/ember/templates/events/activity_list.js.hbs.hamlbars b/app/assets/javascripts/ember/templates/events/activity_list.js.hbs.hamlbars
deleted file mode 100644
index 5e2bd8ab..00000000
--- a/app/assets/javascripts/ember/templates/events/activity_list.js.hbs.hamlbars
+++ /dev/null
@@ -1,2 +0,0 @@
-= hb 'each events' do
- = hb 'view Coderwall.EventView', :eventBinding => 'this'
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/templates/events/admin.js.hbs.hamlbars b/app/assets/javascripts/ember/templates/events/admin.js.hbs.hamlbars
deleted file mode 100644
index 0471051c..00000000
--- a/app/assets/javascripts/ember/templates/events/admin.js.hbs.hamlbars
+++ /dev/null
@@ -1,10 +0,0 @@
-.graphic
-.item
- .header.cf
- %ul.cf
- %li.team
- =hb 'event.eventTypeString'
-
- .content.cf
- %p
- {{{event.message}}}
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/templates/events/comment.js.hbs.hamlbars b/app/assets/javascripts/ember/templates/events/comment.js.hbs.hamlbars
deleted file mode 100644
index f571562e..00000000
--- a/app/assets/javascripts/ember/templates/events/comment.js.hbs.hamlbars
+++ /dev/null
@@ -1,36 +0,0 @@
-.graphic
-.item
- .header.cf
- %ul.cf
- %li.user
- %img{:bind => {:src => 'event.user.profile_url'}}
- %a.user-name{:bind => {:href => 'event.user.profile_path'}}
- = hb 'event.user.username'
- = hb('if event.belongsToTeam') do
- %li.team
- %span
- of
- %img{:bind => {:src => 'event.team.avatar'}}
- %a{:bind => {:href => 'event.team.url'}}
- =hb 'event.team.name'
- %li.fragment
- = hb 'event.eventTypeString'
-
- .content.cf{:bind => {:id => 'event.public_id'}}
- %a.small-upvote.track{:bind => {:href => 'event.upvote_path'}, :rel => "nofollow", 'data-action' => 'upvote protip', 'data-from' => 'comment in feed', 'data-remote' => 'true', 'data-method' => 'post'}
- = hb('event.upvotes')
- %h1
- = hb('with event') do
- = hb('comment_action')
- %a{:bind => {:href => 'url'}}
- %blockquote
- = hb('title')
- = hb 'comment_or_like_message'
-
- =hb ('with event') do
- =hb ('if_repliable') do
- .footer.cf
- %ul.actions-list
- %li
- %a.reply{:href => hb('reply_url')}
- reply
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/templates/events/endorsement.js.hbs.hamlbars b/app/assets/javascripts/ember/templates/events/endorsement.js.hbs.hamlbars
deleted file mode 100644
index 3136e973..00000000
--- a/app/assets/javascripts/ember/templates/events/endorsement.js.hbs.hamlbars
+++ /dev/null
@@ -1,24 +0,0 @@
-.graphic
-.item
- .header.cf
- %ul.cf
- %li.user
- %img{:bind => {:src => 'event.user.profile_url'}}
- %a.user-name{:bind => {:href => 'event.user.profile_path'}}
- = hb 'event.user.username'
- = hb('if event.belongsToTeam') do
- %li.team
- %span
- of
- %img{:bind => {:src => 'event.team.avatar'}}
- %a{:bind => {:href => 'event.team.url'}}
- =hb 'event.team.name'
- %li.fragment
- = hb 'event.eventTypeString'
-
- .content.cf
- %h1
- = hb 'event.endorsement.endorser'
- thinks you are awesome at
- = hb 'event.endorsement.skill'
- , sweet!
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/templates/events/expert.js.hbs.hamlbars b/app/assets/javascripts/ember/templates/events/expert.js.hbs.hamlbars
deleted file mode 100644
index 832e43d5..00000000
--- a/app/assets/javascripts/ember/templates/events/expert.js.hbs.hamlbars
+++ /dev/null
@@ -1,32 +0,0 @@
-.graphic
-.item
- .header.cf
- %ul.cf
- %li.user
- %img{:bind => {:src => 'event.user.profile_url'}}
- %a.user-name{:bind => {:href => 'event.user.profile_path'}}
- = hb 'event.user.username'
- = hb('if event.belongsToTeam') do
- %li.team
- %span
- of
- %img{:bind => {:src => 'event.team.avatar'}}
- %a{:bind => {:href => 'event.team.url'}}
- =hb 'event.team.name'
- %li.fragment
- = hb 'event.eventTypeString'
- %li.fragment
- %a{:bind => {:href => 'event.network.url'}}
- =hb 'event.network.name'
- .content.cf
- %h1
- = hb 'event.user.username'
- is now the mayor of
- = hb 'event.network.name'
- .footer.cf
- %ul.actions-list
- %li
- = hb('with event.network.name') do
- %a.write-tip.track{:href => hb('write_tagged_protips_path'), 'data-action' => 'create protip', 'data-from' => 'expert in feed'}
- Create a tip about
- =hb('this')
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/templates/events/follow.js.hbs.hamlbars b/app/assets/javascripts/ember/templates/events/follow.js.hbs.hamlbars
deleted file mode 100644
index b933f5df..00000000
--- a/app/assets/javascripts/ember/templates/events/follow.js.hbs.hamlbars
+++ /dev/null
@@ -1,30 +0,0 @@
-.graphic
-.item
- .header.cf
- %ul.cf
- %li.user
- %img{:bind => {:src => 'event.user.profile_url'}}
- %a.user-name{:bind => {:href => 'event.user.profile_path'}}
- = hb 'event.user.username'
- = hb('if event.belongsToTeam') do
- %li.team
- %span
- of
- %img{:bind => {:src => 'event.team.avatar'}}
- %a{:bind => {:href => 'event.team.url'}}
- =hb 'event.team.name'
- %li.fragment
- = hb 'event.eventTypeString'
-
- .content.cf
- %h1
- Nice,
- = hb 'event.follow.follower'
- = hb 'with event.event_type' do
- = hb 'followed_text'
- Your protips and achievements will now show up in their activity feed.
- .footer
- %p
- Check out their
- %a.user-name{:bind => {:href => 'event.user.profile_path'}, :class => "track", 'data-action' => 'view user profile', 'data-from' => 'follow in feed'}
- profile
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/templates/events/more_activity.js.hbs.hamlbars b/app/assets/javascripts/ember/templates/events/more_activity.js.hbs.hamlbars
deleted file mode 100644
index 9accde89..00000000
--- a/app/assets/javascripts/ember/templates/events/more_activity.js.hbs.hamlbars
+++ /dev/null
@@ -1,5 +0,0 @@
-
-%a.track{:href => 'javascript:;', :event => { :on => 'click', :action => 'showUnreadActivity' }, 'data-action' => 'request more activity' }
- +
- = hb 'Coderwall.activityFeedController.unreadActivities.length'
- New activity items
diff --git a/app/assets/javascripts/ember/templates/events/protip.js.hbs.hamlbars b/app/assets/javascripts/ember/templates/events/protip.js.hbs.hamlbars
deleted file mode 100644
index bb5455a3..00000000
--- a/app/assets/javascripts/ember/templates/events/protip.js.hbs.hamlbars
+++ /dev/null
@@ -1,42 +0,0 @@
-.graphic
-.item
- .header.cf
- = hb('if event.team.hiring') do
- %a.hiring-ribbon.track{:bind => {:href => 'event.teamHireUrl'}, 'data-action' => 'view team jobs', 'data-from' => 'protip ribbon on dashboard'}
- %span Join us
- %ul.cf
- %li.user
- %img{:bind => {:src => 'event.user.profile_url'}}
- =hb 'event.eventTypeString'
- by
- %a.user-name{:bind => {:href => 'event.user.profile_path'}}
- = hb 'event.user.username'
- = hb('if event.belongsToTeam') do
- %li.team
- %span
- of
- %img{:bind => {:src => 'event.team.avatar'}}
- %a{:bind => {:href => 'event.team.url'}}
- =hb 'event.team.name'
- .content.cf{:bind => {:id => 'event.public_id'}}
- %a.small-upvote.track{:bind => {:href => 'event.upvote_path'}, :rel => "nofollow", 'data-action' => 'upvote protip', 'data-from' => 'protip in feed', 'data-remote' => 'true', 'data-method' => 'post'}
- = hb('event.upvotes')
- %a{:bind => {:href => 'event.url'}}
- %h1
- = hb('event.title')
- %ul.tags.cf
- = hb 'each event.tags' do
- %li
- %a.tag{:href => hb('tagged_protips_path')}
- =hb('this')
- .footer.cf
- %ul.actions-list
- = hb('if event.topTag') do
- %li
- = hb('with event.topTag') do
- %a.write-tip.track{:href => hb('write_tagged_protips_path'), 'data-action' => 'create protip', 'data-from' => 'protip in feed'}
- Create a tip about
- =hb('this')
- %li
- %a.tweet{:bind => {:href => 'event.tweetUrl'}}
- Tweet this
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/templates/events/skill.js.hbs.hamlbars b/app/assets/javascripts/ember/templates/events/skill.js.hbs.hamlbars
deleted file mode 100644
index 2471d0d1..00000000
--- a/app/assets/javascripts/ember/templates/events/skill.js.hbs.hamlbars
+++ /dev/null
@@ -1,30 +0,0 @@
-.graphic
-.item
- .header.cf
- %ul.cf
- %li.user
- %img{:bind => {:src => 'event.user.profile_url'}}
- %a.user-name{:bind => {:href => 'event.user.profile_path'}}
- = hb 'event.user.username'
- = hb('if event.belongsToTeam') do
- %li.team
- %span
- of
- %img{:bind => {:src => 'event.team.avatar'}}
- %a{:bind => {:href => 'event.team.url'}}
- =hb 'event.team.name'
- %li.fragment
- = hb 'event.eventTypeString'
-
- .content.cf
- %h1
- = hb('with event.skill.name') do
- %a{:href => hb('tagged_protips_path')}
- = hb 'this'
- .footer
- %ul.actions-list
- %li
- %a.add-skill.track{:bind => {:href => 'event.skill.add_path', :class => 'showSkill'}, :event => { :on => 'click', :action => 'addSkill' }, 'data-remote' => 'true', 'data-method' => 'post', 'data-action' => 'add skill', 'data-from' => 'skill in feed'}
- Add
- =hb('event.skill.name')
- to my skills
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/templates/events/stats.js.hbs.hamlbars b/app/assets/javascripts/ember/templates/events/stats.js.hbs.hamlbars
deleted file mode 100644
index 34721845..00000000
--- a/app/assets/javascripts/ember/templates/events/stats.js.hbs.hamlbars
+++ /dev/null
@@ -1,16 +0,0 @@
-%li.profile-views
- %span
- = hb('profileViews')
- %a{:bind => {:href => 'Coderwall.activityFeedController.profileUrl'}}Profile views
-%li.followers
- %span
- = hb('followers')
- %a{:bind => {:href => 'Coderwall.activityFeedController.connectionsUrl'}}Followers
-%li.protips
- %span
- = hb('protips')
- %a{:bind => {:href => 'Coderwall.activityFeedController.protipsUrl'}}Protips
-%li.upvotes
- %span
- = hb('protipUpvotes')
- Upvotes
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/templates/events/team.js.hbs.hamlbars b/app/assets/javascripts/ember/templates/events/team.js.hbs.hamlbars
deleted file mode 100644
index b9f10a92..00000000
--- a/app/assets/javascripts/ember/templates/events/team.js.hbs.hamlbars
+++ /dev/null
@@ -1,30 +0,0 @@
-.graphic
-.item
- .header.cf
- %ul.cf
- %li.user
- %img{:bind => {:src => 'event.user.profile_url'}}
- %a.user-name{:bind => {:href => 'event.user.profile_path'}}
- = hb 'event.user.username'
- =hb 'event.eventTypeString'
-
- .content.cf
- .team-added
- %img{:bind => {:src => 'event.team.avatar'}}
- %a{:bind => {:href => 'event.team.url'}}
- =hb 'event.team.name'
- .footnote
- =hb 'with event.team.skills' do
- =hb 'if any_skills' do
- %p
- =hb 'event.team.name'
- builds awesome stuff with
- =hb 'each event.team.skills' do
- %a.tag{:href => hb('tagged_protips_path')}
- =hb('this')
- .footer
- %ul.actions-list
- %li
- %a.follow.track{:bind => {:href => 'event.team.follow_path', :class => 'showTeam'}, :event => { :on => 'click', :action => 'followTeam' }, 'data-method' => 'post', 'data-remote' => 'true', 'data-action' => 'follow team', 'data-from' => 'team in feed'}
- Follow
- =hb('event.team.name')
diff --git a/app/assets/javascripts/ember/templates/events/view.js.hbs.hamlbars b/app/assets/javascripts/ember/templates/events/view.js.hbs.hamlbars
deleted file mode 100644
index dbaef7bb..00000000
--- a/app/assets/javascripts/ember/templates/events/view.js.hbs.hamlbars
+++ /dev/null
@@ -1,39 +0,0 @@
-.graphic
-.item
- .header.cf
- %ul.cf
- %li.user
- %img{:bind => {:src => 'event.user.profile_url'}}
- %a.user-name{:bind => {:href => 'event.user.profile_path'}}
- = hb 'event.user.username'
- = hb('if event.belongsToTeam') do
- %li.team
- %span
- of
- %img{:bind => {:src => 'event.team.avatar'}}
- %a{:bind => {:href => 'event.team.url'}}
- =hb 'event.team.name'
- %li.fragment
- = hb 'event.eventTypeString'
- .content.cf
- = hb 'if event.protipEvent' do
- -#%a.small-upvote
- -# = hb('event.upvotes')
- %h1
- Your protip
- %a{:bind => {:href => 'event.url'}}
- %blockquote
- = hb('event.title')
- = hb 'if event.viewEvent' do
- has been viewed by
- = hb 'event.views'
- people
- = hb 'else'
- has
- = hb 'event.upvotes'
- upvotes
- = hb 'else'
- %h1
- Your profile has been viewed by
- = hb 'event.views'
- people
\ No newline at end of file
diff --git a/app/assets/javascripts/ember/templates/networks/all_networks/a_z.js.hbs.hamlbars b/app/assets/javascripts/ember/templates/networks/all_networks/a_z.js.hbs.hamlbars
deleted file mode 100644
index 300147c2..00000000
--- a/app/assets/javascripts/ember/templates/networks/all_networks/a_z.js.hbs.hamlbars
+++ /dev/null
@@ -1,25 +0,0 @@
-%ol.networks-list
- = hb('each alphabet') do
- %li.cf
- %span.letter
- = hb 'this'
-
- = hb('each_network') do
- /Network
- .network.cf
- %h2
- %a{:bind => {:href => 'url'}}
- =hb 'name'
- %ul.tips-and-users
- %li
- %a.users{:bind => {:href => 'members_url'}}
- Members
- %span
- =hb 'members_count'
- %li
- %a.tips{:bind => {:href => 'url'}}
- Protips
- %span
- =hb 'protips_count'
- %a.join{:bind => {:href => 'join_url'}}
- =hb 'joinOrMember'
diff --git a/app/assets/javascripts/ember/templates/teams/index.js.hbs.hamlbars b/app/assets/javascripts/ember/templates/teams/index.js.hbs.hamlbars
deleted file mode 100644
index 6afba991..00000000
--- a/app/assets/javascripts/ember/templates/teams/index.js.hbs.hamlbars
+++ /dev/null
@@ -1,5 +0,0 @@
-%table.table.table-striped
- %tbody
- =hb 'each teams' do
- %tr
- =hb 'view Coderwall.ShowTeamView', :teamBinding => 'this'
diff --git a/app/assets/javascripts/ember/templates/teams/show.js.hbs.hamlbars b/app/assets/javascripts/ember/templates/teams/show.js.hbs.hamlbars
deleted file mode 100644
index 182426d6..00000000
--- a/app/assets/javascripts/ember/templates/teams/show.js.hbs.hamlbars
+++ /dev/null
@@ -1,21 +0,0 @@
-%tr.team.span10
- %td.rank.span1=hb 'team.ordinalized_rank'
- %td.teamname.span3
- %a{:bind => {:href => 'team.url'}}
- %img.team-avatar{:bind => {:src => 'team.avatar'}}
- %span=hb 'team.name'
- %td.members.span3
- =hb 'each team.members' do
- %a{:bind => {:href => 'profile_path' }}
- %img.thumb{:bind => {:src => 'avatar'}}
- =hb 'if team.has_more_than_min_members' do
- .size
- +
- =hb 'team.remaining_members'
- %td.score.span1
- .circle=hb 'team.rounded_score'
- %td.team-actions.span2
- =hb 'if signed_in' do
- %a{:event => {:action => 'follow'}, :bind => {:class => 'team.followed:btn-primary :btn :btn-large :follow'}}
- =hb 'team.follow_text'
-
diff --git a/app/assets/javascripts/ember/views/.gitkeep b/app/assets/javascripts/ember/views/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/app/assets/javascripts/ember/views/networks/network.js.coffee b/app/assets/javascripts/ember/views/networks/network.js.coffee
deleted file mode 100644
index 4651a8a7..00000000
--- a/app/assets/javascripts/ember/views/networks/network.js.coffee
+++ /dev/null
@@ -1,29 +0,0 @@
-Coderwall.AllNetworksView = Ember.View.create(
- alphabet: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U",
- "V", "W", "X", "Y", "Z"]
- tagName: "div"
- sortOrder: 'a_z'
- networksBinding: "Coderwall.networksController.content"
-
- templateName: (->
- templateName = if @get('sortOrder')? then @get('sortOrder') else "a_z"
- "networks/all_networks/" + templateName
- ).property("sortOrder").cacheable()
-
- sortByAlpyhabet: ->
- Coderwall.networksController.set('sortField', 'name')
- @set('sortOrder', 'a_z')
-
- sortByUpvotes: ->
- Coderwall.networksController.set('sortField', 'upvotes')
- @set('sortOrder', 'upvotes')
-
- sortByNewProtips: ->
- Coderwall.networksController.set('sortField', 'created_at')
- @set('sortOrder', 'new')
-
- showMembers: ->
-
-)
-
-Coderwall.AllNetworksView.appendTo('#networks')
diff --git a/app/assets/javascripts/ember/views/teams/index.js.coffee b/app/assets/javascripts/ember/views/teams/index.js.coffee
deleted file mode 100644
index 4689d03c..00000000
--- a/app/assets/javascripts/ember/views/teams/index.js.coffee
+++ /dev/null
@@ -1,7 +0,0 @@
-Coderwall.ListTeamsView = Ember.View.extend(
- templateName: "teams/index"
- teamsBinding: "Coderwall.teamsController"
-
- refreshListing: ->
- Coderwall.teamsController.findAll()
-)
diff --git a/app/assets/javascripts/ember/views/teams/show.js.coffee b/app/assets/javascripts/ember/views/teams/show.js.coffee
deleted file mode 100644
index 79f36dd3..00000000
--- a/app/assets/javascripts/ember/views/teams/show.js.coffee
+++ /dev/null
@@ -1,10 +0,0 @@
-Coderwall.ShowTeamView = Ember.View.extend(
- templateName: "teams/show"
- classNames: [ "team" ]
- tagName: "tr"
-
- follow: (e)->
- team = @get("team")
- team.follow()
- e.preventDefault()
-)
diff --git a/app/assets/javascripts/sorted-array.js.coffee b/app/assets/javascripts/sorted-array.js.coffee
deleted file mode 100644
index f7db7523..00000000
--- a/app/assets/javascripts/sorted-array.js.coffee
+++ /dev/null
@@ -1,50 +0,0 @@
-Ember.SortedArrayController = Ember.ArrayController.extend(
- sortOrder: "normal"
- sortFunction: null
- inputCollectionName: "content"
- outputCollectionName: "content"
- maxCollectionSize: -1
-
- init: ->
- @set(@inputCollectionName, [])
- @addObserver(@inputCollectionName + '.@each', ->
- @elementAdded())
- @addObserver(@outputCollectionName + '.@each', ->
- @trimArray())
-
- elementAdded: (->
- context = @
- content = @get(@inputCollectionName)
-
- if @sortOrder == "normal"
- if @sortFunction? then content.sort((a, b)->
- context.sortFunction(a, b))
- else
- content.sort()
- else if @sortOrder == "reverse"
- if @sortFunction? then content.sort((a, b)->
- context.sortFunction(b, a))
- else
- content.reverse()
- else if @sortOrder == "random"
- content.sort((a, b)->
- 0.5 - Math.random("deadbeef"))
-
- @set(@outputCollectionName, content)
- )
-
- trimArray: (->
- content = @get(@outputCollectionName)
- @set(@outputCollectionName,
- content.slice(0, @maxCollectionSize - 1))if (@maxCollectionSize > 0) and (content.length > @maxCollectionSize)
- )
-)
-
-#window.myArray = Ember.SortedArrayController.create()
-#myArray.content.pushObjects(["Jack", "Cassandra", "Raj"])
-
-#window.myArray2 = Ember.SortedArrayController.create({sortOrder: "reverse"})
-#myArray2.content.pushObjects(["Jack", "Cassandra", "Raj"])
-#
-#window.myArray3 = Ember.SortedArrayController.create({sortOrder: "random"})
-#myArray3.content.pushObjects(["Jack", "Cassandra", "Raj"])
diff --git a/app/views/teams/index.html.haml b/app/views/teams/index.html.haml
index 0c6e649a..67e4b520 100644
--- a/app/views/teams/index.html.haml
+++ b/app/views/teams/index.html.haml
@@ -1,7 +1,3 @@
--content_for :javascript do
- -#%script="logUsage('viewed', 'amazing teams');"
- =javascript_include_tag 'ember/teams'
-
-content_for :mixpanel do
=record_view_event('teams page')
diff --git a/config/application.rb b/config/application.rb
index dc5ec915..83e85658 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -24,7 +24,6 @@ class Application < Rails::Application
config.filter_parameters += [:password]
- config.ember.variant = Rails.env.downcase.to_sym
config.assets.js_compressor = :uglifier
config.after_initialize do
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index c83e5e69..e1066fd8 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -8,7 +8,6 @@
config.assets.precompile << 'protip.css'
config.assets.precompile << 'account.js'
config.assets.precompile << 'protips.js'
- config.assets.precompile << 'ember/dashboard.js'
config.assets.precompile << 'connections.js'
config.assets.precompile << 'jquery.js'
config.assets.precompile << 'jquery_ujs.js'
@@ -21,7 +20,6 @@
config.assets.precompile << 'html5shiv.js'
config.assets.precompile << 'tracking.js'
config.assets.precompile << 'teams.js'
- config.assets.precompile << 'ember/teams.js'
config.assets.precompile << 'jquery.scrolldepth.js'
config.assets.precompile << 'premium.js'
config.assets.precompile << 'premium-admin.js'
diff --git a/config/initializers/ember-rails.rb b/config/initializers/ember-rails.rb
deleted file mode 100644
index d8d23af8..00000000
--- a/config/initializers/ember-rails.rb
+++ /dev/null
@@ -1 +0,0 @@
-Coderwall::Application.config.handlebars.templates_root = 'ember/templates'
\ No newline at end of file
diff --git a/lib/templates/erb/humans.txt.erb b/lib/templates/erb/humans.txt.erb
index 10f705f1..db01798a 100644
--- a/lib/templates/erb/humans.txt.erb
+++ b/lib/templates/erb/humans.txt.erb
@@ -44,7 +44,7 @@ From: Crystal Lake, IL, United States
/* SITE */
Last update: <%= Date.today.strftime('%Y/%m/%d') %>
Standards: HTML5, CSS3
-Components: Ruby on Rails, jQuery, Sass, Backbone.js, Ember.js, PostgreSQL, ElasticSearch, MongoDB, Redis, etc.
+Components: Ruby on Rails, jQuery, Sass, Backbone.js, PostgreSQL, ElasticSearch, Redis, etc.
Software: Vim, Tmux, Vagrant, Git, etc.
Language: English
IDE: Vim
diff --git a/public/humans.txt b/public/humans.txt
index 546eee14..dbcead80 100644
--- a/public/humans.txt
+++ b/public/humans.txt
@@ -129,7 +129,7 @@ Location: China
/* SITE */
Last update: 2014/31/12
Standards: HTML5, CSS3
-Components: Ruby on Rails, jQuery, Sass, Backbone.js, Ember.js, PostgreSQL, ElasticSearch, Redis, etc.
+Components: Ruby on Rails, jQuery, Sass, Backbone.js, PostgreSQL, ElasticSearch, Redis, etc.
Software: Vim, Tmux, Vagrant, Git, etc.
Language: English
IDE: Vim
diff --git a/vendor/assets/javascripts/route_manager.js b/vendor/assets/javascripts/route_manager.js
deleted file mode 100644
index fe4c2cd6..00000000
--- a/vendor/assets/javascripts/route_manager.js
+++ /dev/null
@@ -1,566 +0,0 @@
-var get = Ember.get, set = Ember.set;
-
-/**
- Whether the browser supports HTML5 history.
- */
-var supportsHistory = !!(window.history && window.history.pushState);
-
-/**
- Whether the browser supports the hashchange event.
- */
-var supportsHashChange = ('onhashchange' in window) && (document.documentMode === undefined || document.documentMode > 7);
-
-/**
- @class
- Ember.RouteManager manages the browser location and changes states accordingly
- to the current location. The location can be programmatically set as follows:
-
- routeManager.set('location', 'notes/edit/4');
-
- Ember.RouteManager also supports HTML5 history, which uses a '/' instead of a
- '#!' in the URLs, so that all your website's URLs are consistent.
- */
-Ember.RouteManager = Ember.StateManager.extend({
-
- /**
- Set this property to true if you want to use HTML5 history, if available on
- the browser, instead of the location hash.
-
- HTML 5 history uses the history.pushState method and the window's popstate
- event.
-
- By default it is false, so your URLs will look like:
-
- http://domain.tld/my_app#!notes/edit/4
-
- If set to true and the browser supports pushState(), your URLs will look
- like:
-
- http://domain.tld/my_app/notes/edit/4
-
- You will also need to make sure that baseURI is properly configured, as
- well as your server so that your routes are properly pointing to your
- Ember application.
-
- @see http://dev.w3.org/html5/spec/history.html#the-history-interface
- @property
- @type {Boolean}
- */
- wantsHistory: false,
-
- /**
- A read-only boolean indicating whether or not HTML5 history is used. Based
- on the value of wantsHistory and the browser's support for pushState.
-
- @see wantsHistory
- @property
- @type {Boolean}
- */
- usesHistory: null,
-
- /**
- The base URI used to resolve routes (which are relative URLs). Only used
- when usesHistory is equal to true.
-
- The build tools automatically configure this value if you have the
- html5_history option activated in the Buildfile:
-
- config :my_app, :html5_history => true
-
- Alternatively, it uses by default the value of the href attribute of the
- tag of the HTML document. For example:
-
-
-
- The value can also be customized before or during the exectution of the
- main() method.
-
- @see http://www.w3.org/TR/html5/semantics.html#the-base-element
- @property
- @type {String}
- */
- baseURI: document.baseURI,
-
- /** @private
- A boolean value indicating whether or not the ping method has been called
- to setup the Ember.routes.
-
- @property
- @type {Boolean}
- */
- _didSetup: false,
-
- /** @private
- Internal representation of the current location hash.
-
- @property
- @type {String}
- */
- _location: null,
-
- /** @private
- Internal method used to extract and merge the parameters of a URL.
-
- @returns {Hash}
- */
- _extractParametersAndRoute: function (obj) {
- var params = {}, route = obj.route || '', separator, parts, i, len, crumbs, key;
- separator = (route.indexOf('?') < 0 && route.indexOf('&') >= 0) ? '&' : '?';
- parts = route.split(separator);
- route = parts[0];
- if (parts.length === 1) {
- parts = [];
- } else if (parts.length === 2) {
- parts = parts[1].split('&');
- } else if (parts.length > 2) {
- parts.shift();
- }
-
- // extract the parameters from the route string
- len = parts.length;
- for (i = 0; i < len; ++i) {
- crumbs = parts[i].split('=');
- params[crumbs[0]] = crumbs[1];
- }
-
- // overlay any parameter passed in obj
- for (key in obj) {
- if (obj.hasOwnProperty(key) && key !== 'route') {
- params[key] = '' + obj[key];
- }
- }
-
- // build the route
- parts = [];
- for (key in params) {
- parts.push([key, params[key]].join('='));
- }
- params.params = separator + parts.join('&');
- params.route = route;
-
- return params;
- },
-
- /**
- The current location hash. It is the part in the browser's location after
- the '#!' mark.
-
- @property
- @type {String}
- */
- location: Ember.computed(function (key, value) {
- this._skipRoute = false;
- return this._extractLocation(key, value);
- }).property(),
-
- _extractLocation: function (key, value) {
- var crumbs, encodedValue;
-
- if (value !== undefined) {
- if (value === null) {
- value = '';
- }
-
- if (typeof (value) === 'object') {
- crumbs = this._extractParametersAndRoute(value);
- value = crumbs.route + crumbs.params;
- }
-
- if (!this._skipPush && (!Ember.empty(value) || (this._location && this._location !== value))) {
- encodedValue = encodeURI(value);
-
- if (this.usesHistory) {
- encodedValue = '/' + encodedValue;
- window.history.pushState(null, null, get(this, 'baseURI') + encodedValue);
- } else if (encodedValue.length > 0 || window.location.hash.length > 0) {
- window.location.hash = '!' + encodedValue;
- }
- }
-
- this._location = value;
- }
-
- return this._location;
- },
-
- updateLocation: function (loc) {
- this._skipRoute = true;
- return this._extractLocation('location', loc);
- },
-
- /**
- Start this routemanager.
-
- Registers for the hashchange event if available. If not, it creates a
- timer that looks for location changes every 150ms.
- */
- start: function () {
- if (!this._didSetup) {
- this._didSetup = true;
- var state = '';
-
- if (get(this, 'wantsHistory') && supportsHistory) {
- this.usesHistory = true;
-
- // Move any hash state to url state
- if (!Ember.empty(window.location.hash)) {
- state = window.location.hash.slice(1);
- if (state.length > 0) {
- state = '/' + state;
- window.history.replaceState(null, null, get(this, 'baseURI') + state);
- }
- }
-
- this.popState();
- this.popState = jQuery.proxy(this.popState, this);
- jQuery(window).bind('popstate', this.popState);
-
- } else {
- this.usesHistory = false;
-
- if (get(this, 'wantsHistory')) {
- // Move any url state to hash
- var base = get(this, 'baseURI');
- var loc = (base.charAt(0) === '/') ? document.location.pathname : document.location.href.replace(document.location.hash, '');
- state = loc.slice(base.length + 1);
- if (state.length > 0) {
- window.location.href = base + '#!' + state;
- }
- }
-
- if (supportsHashChange) {
- this.hashChange();
- this.hashChange = jQuery.proxy(this.hashChange, this);
- jQuery(window).bind('hashchange', this.hashChange);
-
- } else {
- // we don't use a Ember.Timer because we don't want
- // a run loop to be triggered at each ping
- var _this = this, invokeHashChange = function () {
- _this.hashChange();
- _this._timerId = setTimeout(invokeHashChange, 100);
- };
-
- invokeHashChange();
- }
- }
- }
- },
-
- /**
- Stop this routemanager
- */
- stop: function () {
- if (this._didSetup) {
- if (get(this, 'wantsHistory') && supportsHistory) {
- jQuery(window).unbind('popstate', this.popState);
- } else {
- if (supportsHashChange) {
- jQuery(window).unbind('hashchange', this.hashChange);
- } else {
- clearTimeout(this._timerId);
- }
- }
- this._didSetup = false;
- }
- },
-
- destroy: function () {
- this.stop();
- this._super();
- },
-
- /**
- Observer of the 'location' property that calls the correct route handler
- when the location changes.
- */
- locationDidChange: Ember.observer(function () {
- this.trigger();
- }, 'location'),
-
- /**
- Triggers a route even if already in that route (does change the location, if
- it is not already changed, as well).
-
- If the location is not the same as the supplied location, this simply lets
- "location" handle it (which ends up coming back to here).
- */
- trigger: function () {
- var location = get(this, 'location'), params, route;
- params = this._extractParametersAndRoute({
- route: location
- });
- location = params.route;
- delete params.route;
- delete params.params;
-
- var result = this.getState(location, params);
- if (result) {
- set(this, 'params', result.params);
-
- // We switch states in two phases. The point of this is to handle
- // parameter-only location changes. This will correspond to the same
- // state path in the manager, but states with parts with changed
- // parameters should be re-entered:
-
- // 1. We go to the earliest clean state. This prevents
- // unnecessary transitions.
- if (result.cleanStates.length > 0) {
- var cleanState = result.cleanStates.join('.');
- this.goToState(cleanState);
- }
-
- // 2. We transition to the dirty state. This forces dirty
- // states to be transitioned.
- if (result.dirtyStates.length > 0) {
- var dirtyState = result.cleanStates.concat(result.dirtyStates).join('.');
- // Special case for re-entering the root state on a parameter change
- if (this.currentState && dirtyState === this.currentState.get('path')) {
- this.goToState('__nullState');
- }
- this.goToState(dirtyState);
- }
- } else {
- var states = get(this, 'states');
- if (states && get(states, "404")) {
- this.goToState("404");
- }
- }
- },
-
- getState: function (route, params) {
- var parts = route.split('/');
- parts = parts.filter(function (part) {
- return part !== '';
- });
-
- return this._findState(parts, this, [], [], params, false);
- },
-
- /** @private
- Recursive helper that the state and the params if a match is found
- */
- _findState: function (parts, state, cleanStates, dirtyStates, params) {
- parts = Ember.copy(parts);
-
- var hasChildren = false, name, states, childState;
- // sort desc based on priority
- states = [];
- for (name in state.states) {
- // 404 state is special and not matched
- childState = state.states[name];
- if (name == "404" || !Ember.State.detect(childState) && !( childState instanceof Ember.State)) {
- continue;
- }
- states.push({
- name: name,
- state: childState
- });
- }
- states = states.sort(function (a, b) {
- return (b.state.get('priority') || 0) - (a.state.get('priority') || 0);
- });
-
- for (var i = 0; i < states.length; i++) {
- name = states[i].name;
- childState = states[i].state;
- if (!( childState instanceof Ember.State)) {
- continue;
- }
- hasChildren = true;
-
- var result = this._matchState(parts, childState, params);
- if (!result) {
- continue;
- }
-
- var newParams = Ember.copy(params);
- jQuery.extend(newParams, result.params);
-
- var dirty = dirtyStates.length > 0 || result.dirty;
- var newCleanStates = cleanStates;
- var newDirtyStates = dirtyStates;
- if (dirty) {
- newDirtyStates = Ember.copy(newDirtyStates);
- newDirtyStates.push(name);
- } else {
- newCleanStates = Ember.copy(newCleanStates);
- newCleanStates.push(name);
- }
- result = this._findState(result.parts, childState, newCleanStates, newDirtyStates, newParams);
- if (result) {
- return result;
- }
- }
-
- if (!hasChildren && parts.length === 0) {
- return {
- state: state,
- params: params,
- cleanStates: cleanStates,
- dirtyStates: dirtyStates
- };
- }
- return null;
- },
-
- /** @private
- Check if a state accepts the parts with the params
-
- Returns the remaining parts as well as merged params if
- the state accepts.
-
- Will also set the dirty flag if the route is the same but
- the parameters have changed
- */
- _matchState: function (parts, state, params) {
- parts = Ember.copy(parts);
- params = Ember.copy(params);
- var dirty = false;
- var route = get(state, 'route');
- if (route) {
- var partDefinitions;
- // route could be either a string or regex
- if (typeof route == "string") {
- partDefinitions = route.split('/');
- } else if (route instanceof RegExp) {
- partDefinitions = [route];
- } else {
- Ember.assert("route must be either a string or regexp", false);
- }
-
- for (var i = 0; i < partDefinitions.length; i++) {
- if (parts.length === 0) {
- return false;
- }
- var part = parts.shift();
- var partDefinition = partDefinitions[i];
- var partParams = this._matchPart(partDefinition, part, state);
- if (!partParams) {
- return false;
- }
-
- var oldParams = this.get('params') || {};
- for (var param in partParams) {
- dirty = dirty || (oldParams[param] != partParams[param]);
- }
-
- jQuery.extend(params, partParams);
- }
- }
-
- var enabled = get(state, 'enabled');
- if (enabled !== undefined && !enabled) {
- return false;
- }
-
- return {
- parts: parts,
- params: params,
- dirty: dirty
- };
- },
-
- /** @private
- Returns params if the part matches the partDefinition
- */
- _matchPart: function (partDefinition, part, state) {
- var params = {};
-
- // Handle string parts
- if (typeof partDefinition == "string") {
-
- switch (partDefinition.slice(0, 1)) {
- // 1. dynamic routes
- case ':':
- var name = partDefinition.slice(1, partDefinition.length);
- params[name] = part;
- return params;
-
- // 2. wildcard routes
- case '*':
- return {};
-
- // 3. static routes
- default:
- if (partDefinition == part)
- return {};
- break;
- }
-
- return false;
- }
-
- if (partDefinition instanceof RegExp) {
- // JS doesn't support named capture groups in Regexes so instead
- // we can define a list of 'captures' which maps to the matched groups
- var captures = get(state, 'captures');
- var matches = partDefinition.exec(part);
-
- if (matches) {
- if (captures) {
- var len = captures.length, i;
- for (i = 0; i < len; ++i) {
- params[captures[i]] = matches[i + 1];
- }
- }
- return params;
- } else {
- return false;
- }
- }
-
- return false;
- },
-
- /**
- Event handler for the hashchange event. Called automatically by the browser
- if it supports the hashchange event, or by our timer if not.
- */
- hashChange: function (event) {
- var loc = window.location.hash;
- var routes = this;
-
- // Remove the '#!' prefix
- loc = (loc && loc.length > 1) ? loc.slice(2, loc.length) : '';
-
- if (!jQuery.browser.mozilla) {
- // because of bug https://bugzilla.mozilla.org/show_bug.cgi?id=483304
- loc = decodeURI(loc);
- }
-
- if (get(routes, 'location') !== loc && !routes._skipRoute) {
- Ember.run.once(function () {
- routes._skipPush = true;
- set(routes, 'location', loc);
- routes._skipPush = false;
- });
-
- }
- routes._skipRoute = false;
- },
-
- popState: function (event) {
- var routes = this;
- var base = get(routes, 'baseURI'), loc = (base.charAt(0) === '/') ? document.location.pathname : document.location.href;
-
- if (loc.slice(0, base.length) === base) {
- // Remove the base prefix and the extra '/'
- loc = loc.slice(base.length + 1, loc.length);
-
- if (get(routes, 'location') !== loc && !routes._skipRoute) {
- Ember.run.once(function () {
- routes._skipPush = true;
- set(routes, 'location', loc);
- routes._skipPush = false;
- });
-
- }
- }
- routes._skipRoute = false;
- },
-
- // This is used to re-enter a dirty root state
- __nullState: Ember.State.create({enabled: false})
-
-});
\ No newline at end of file