Example #1
0
 var nameLengths = EnumerableUtils.map(libs, function(item) {
   return get(item, 'name.length');
 });
test("on first retrieval, array computed properties with multiple dependent keys are computed", function() {
  deepEqual(get(obj, 'evenNumbersMultiDep'), [2, 4, 6, 8], "array computed properties are correct on first invocation");
});
 removedItem: function(array, item, changeMeta) {
   array.pushObject('r:' + get(item, 'propA') + ':' + get(item, 'propB') + ':' + get(item, 'propC'));
   return array;
 }
Example #4
0
function getTemplate(componentOrView) {
  return componentOrView.isComponent ? get(componentOrView, '_template') : get(componentOrView, 'template');
}
Example #5
0
    Allows you to specify a controller action to invoke when a key-up event is
    fired. To use this method, give your field a `key-up` attribute. The value
    of that attribute should be the name of the action in your controller
    that you wish to invoke.

    For an example on how to use the `key-up` attribute, please reference the
    example near the top of this file.

    @method keyUp
    @param {Event} event
    @private
  */
  keyUp(event) {
    this.interpretKeyEvents(event);

    this.sendAction('key-up', get(this, 'value'), event);
  },

  /**
    Allows you to specify a controller action to invoke when a key-down event is
    fired. To use this method, give your field a `key-down` attribute. The value
    of that attribute should be the name of the action in your controller that
    you wish to invoke.

    For an example on how to use the `key-down` attribute, please reference the
    example near the top of this file.

    @method keyDown
    @param {Event} event
    @private
  */
Example #6
0
QUnit.test('[null, Foo.bar] -> Foo.bar', function() {
  set(null, 'Foo.bar', 'BAM');
  equal(get(Ember.lookup.Foo, 'bar'), 'BAM');
});
Example #7
0
 testObserver(function(obj, key, fn) {
   defineProperty(obj, 'computed', computed(fn).property(key + '.bar'));
   get(obj, 'computed');
 }, function(obj, key, fn) {
Example #8
0
  isStable(lastState, nextState) {
    return isStable(lastState.outletState, nextState.outletState);
  },

  isEmpty(state) {
    return isEmpty(state.outletState);
  },

  render(renderNode, env, scope, params, hash, template, inverse, visitor) {
    var state = renderNode.state;
    var parentView = env.view;
    var outletState = state.outletState;
    var toRender = outletState.render;
    var namespace = env.container.lookup('application:main');
    var LOG_VIEW_LOOKUPS = get(namespace, 'LOG_VIEW_LOOKUPS');

    var ViewClass = outletState.render.ViewClass;

    if (!state.hasParentOutlet && !ViewClass) {
      ViewClass = env.container.lookupFactory('view:toplevel');
    }

    var options = {
      component: ViewClass,
      self: toRender.controller,
      createOptions: {
        controller: toRender.controller
      }
    };
Example #9
0
QUnit.test("returns empty jQuery object if filter passed that does not match item in parent", function() {
  ok(get(view, 'element'), 'precond - should have element');

  var jquery = view.$('body'); // would normally work if not scoped to view
  equal(jquery.length, 0, 'view.$(body) should have no elements');
});
Example #10
0
  active: computed('attrs.params', '_routing.currentState', function computeLinkToComponentActive() {
    let currentState = get(this, '_routing.currentState');
    if (!currentState) { return false; }

    return this._computeActive(currentState);
  }),
Example #11
0
  transitioningOut: computed('active', 'willBeActive', function computeLinkToComponentTransitioningOut() {
    let willBeActive = get(this, 'willBeActive');
    if (typeof willBeActive === 'undefined') { return false; }

    return get(this, 'active') && !willBeActive && 'ember-transitioning-out';
  }),
Example #12
0
    ```

    NOTE: If you do override `init` for a framework class like `Ember.View`,
    be sure to call `this._super(...arguments)` in your
    `init` declaration! If you don't, Ember may not have an opportunity to
    do important setup work, and you'll see strange behavior in your
    application.

    @method init
    @private
  */
  init() {
    this._super(...arguments);

    // Map desired event name to invoke function
    let eventName = get(this, 'eventName');
    this.on(eventName, this, this._invoke);
  },

  _routing: inject.service('-routing'),

  /**
    Accessed as a classname binding to apply the `LinkComponent`'s `disabledClass`
    CSS `class` to the element when the link is disabled.

    When `true` interactions with the element will not trigger route changes.
    @property disabled
    @private
  */
  disabled: computed({
    get(key, value) {
Example #13
0
 isEqual: function(a,b) {
   if (!(a instanceof Set)) return false;
   if (!(b instanceof Set)) return false;
   return get(a, 'firstObject') === get(b, 'firstObject');
 },
Example #14
0
    registry.register('helper:-capitalize', helper(function([value]) {
      return value.toUpperCase();
    }));

    registry.register('helper:-capitalizeName', Helper.extend({
      destroy() {
        this.removeObserver('value.firstName');
        this._super(...arguments);
      },
      compute([value]) {
        if (this.get('value')) {
          this.removeObserver('value.firstName');
        }
        this.set('value', value);
        this.addObserver('value.firstName', this, this.recompute);
        return (value ? get(value, 'firstName').toUpperCase() : '');
      }
    }));

    registry.register('helper:-fauxconcat', helper(function(params) {
      return params.join('');
    }));

    registry.register('helper:-concatNames', Helper.extend({
      destroy() {
        this.teardown();
        this._super(...arguments);
      },
      teardown() {
        this.removeObserver('value.firstName');
        this.removeObserver('value.lastName');
Example #15
0
QUnit.test('[obj, foo] -> obj.foo', function() {
  set(obj, 'foo', 'BAM');
  equal(get(obj, 'foo'), 'BAM');
});
 var getterAndSetter = function(key, value) {
   count++;
   get(this, 'bar');
   return 'bar '+count;
 };
Example #17
0
QUnit.test('[obj, this.foo.bar] -> obj.foo.bar', function() {
  set(obj, 'this.foo.bar', 'BAM');
  equal(get(obj, 'foo.bar'), 'BAM');
});
 func = function() {
   count++;
   return get(obj, 'foo.bar.baz.biff')+' '+count;
 };
Example #19
0
 targetObject: computed(function(key) {
   var parentView = get(this, '_parentView');
   return parentView ? get(parentView, 'controller') : null;
 }).property('_parentView'),
Example #20
0
 controllerName: computed(function() {
   return "controller:" + get(this, 'model.name') + ' of ' + get(this, 'parentController.company');
 })
Example #21
0
 foo: computed(function() {
   set(this, 'count', get(this, 'count') + 1);
   return emberGet(get(this, 'bar'), 'baz') + ' ' + get(this, 'count');
 }).property('bar.baz')
Example #22
0
 lastObject: computed(function() {
   return this.objectAt(get(this, 'length') - 1);
 }),
Example #23
0
 pop: function() {
   if (get(this, 'isFrozen')) throw new EmberError(FROZEN_ERROR);
   var obj = this.length > 0 ? this[this.length-1] : null;
   this.remove(obj);
   return obj;
 },
Example #24
0
 $: function(view, sel) {
   var elem = get(view, 'element');
   return sel ? jQuery(sel, elem) : jQuery(elem);
 },
Example #25
0
  Obj.create().frozenCopy();
});

var CopyableObject = EmberObject.extend(Copyable, {

  id: null,

  init() {
    this._super(...arguments);
    set(this, 'id', generateGuid());
  },

  copy() {
    var ret = new CopyableObject();
    set(ret, 'id', get(this, 'id'));
    return ret;
  }
});

CopyableTests.extend({

  name: 'Copyable Basic Test',

  newObject() {
    return new CopyableObject();
  },

  isEqual(a, b) {
    if (!(a instanceof CopyableObject) || !(b instanceof CopyableObject)) {
      return false;
Example #26
0
 getElement: function(view) {
   var parent = get(view, 'parentView');
   if (parent) { parent = get(parent, 'element'); }
   if (parent) { return view.findElementInParentElement(parent); }
   return jQuery("#" + get(view, 'elementId'))[0];
 },
test("on first retrieval, array computed properties dependent on nested objects are computed", function() {
  deepEqual(get(obj, 'evenNestedNumbers'), [2,4,6], "array computed properties are correct on first invocation");
});
Example #28
0
QUnit.test('[Foo, bar] -> Foo.bar', function() {
  Ember.lookup.Foo = { toString() { return 'Foo'; } }; // Behave like an Ember.Namespace

  set(Ember.lookup.Foo, 'bar', 'baz');
  equal(get(Ember.lookup.Foo, 'bar'), 'baz');
});
 addedItem: function (array, item) {
   array.pushObject(get(item, 'first.firstObject'));
   return array;
 }
Example #30
0
  buildRegistry() {
    var registry = this.registry = Application.buildRegistry(this);

    return registry;
  },

  /**
    Create a container for the current application's registry.

    @private
    @method buildInstance
    @return {Ember.Container} the configured container
  */
  buildInstance() {
    return ApplicationInstance.create({
      customEvents: get(this, 'customEvents'),
      rootElement: get(this, 'rootElement'),
      applicationRegistry: this.registry
    });
  },

  buildDefaultInstance() {
    var instance = this.buildInstance();

    // For the default instance only, set the view registry to the global
    // Ember.View.views hash for backwards-compatibility.
    EmberView.views = instance.container.lookup('-view-registry:main');

    // TODO2.0: Legacy support for App.__container__
    // and global methods on App that rely on a single,
    // default instance.