_id
stringlengths 2
6
| title
stringlengths 0
58
| partition
stringclasses 3
values | text
stringlengths 52
373k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q63000
|
test
|
function(fullName, factory, options) {
validateFullName(fullName);
if (factory === undefined) {
throw new TypeError('Attempting to register an unknown factory: `' + fullName + '`');
}
var normalizedName = this.normalize(fullName);
if (this.cache.has(normalizedName)) {
throw new Error('Cannot re-register: `' + fullName +'`, as it has already been looked up.');
}
this.registry.set(normalizedName, factory);
this._options.set(normalizedName, options || {});
}
|
javascript
|
{
"resource": ""
}
|
|
q63001
|
test
|
function(fullName) {
validateFullName(fullName);
var normalizedName = this.normalize(fullName);
this.registry.remove(normalizedName);
this.cache.remove(normalizedName);
this.factoryCache.remove(normalizedName);
this.resolveCache.remove(normalizedName);
this._options.remove(normalizedName);
}
|
javascript
|
{
"resource": ""
}
|
|
q63002
|
test
|
function(fullName) {
validateFullName(fullName);
var normalizedName = this.normalize(fullName);
var cached = this.resolveCache.get(normalizedName);
if (cached) { return cached; }
var resolved = this.resolver(normalizedName) || this.registry.get(normalizedName);
this.resolveCache.set(normalizedName, resolved);
return resolved;
}
|
javascript
|
{
"resource": ""
}
|
|
q63003
|
test
|
function(type, property, fullName) {
validateFullName(fullName);
if (this.parent) { illegalChildOperation('typeInjection'); }
addTypeInjection(this.typeInjections, type, property, fullName);
}
|
javascript
|
{
"resource": ""
}
|
|
q63004
|
test
|
function(fullName, property, injectionName) {
if (this.parent) { illegalChildOperation('injection'); }
validateFullName(injectionName);
var normalizedInjectionName = this.normalize(injectionName);
if (fullName.indexOf(':') === -1) {
return this.typeInjection(fullName, property, normalizedInjectionName);
}
validateFullName(fullName);
var normalizedName = this.normalize(fullName);
addInjection(this.injections, normalizedName, property, normalizedInjectionName);
}
|
javascript
|
{
"resource": ""
}
|
|
q63005
|
test
|
function(type, property, fullName) {
if (this.parent) { illegalChildOperation('factoryTypeInjection'); }
addTypeInjection(this.factoryTypeInjections, type, property, this.normalize(fullName));
}
|
javascript
|
{
"resource": ""
}
|
|
q63006
|
test
|
function(key) {
var dict = this.dict;
if (dict.hasOwnProperty(key)) {
return dict[key];
}
if (this.parent) {
return this.parent.get(key);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63007
|
test
|
function(key) {
var dict = this.dict;
if (dict.hasOwnProperty(key)) {
return true;
}
if (this.parent) {
return this.parent.has(key);
}
return false;
}
|
javascript
|
{
"resource": ""
}
|
|
q63008
|
test
|
function(callback, binding) {
var dict = this.dict;
for (var prop in dict) {
if (dict.hasOwnProperty(prop)) {
callback.call(binding, prop, dict[prop]);
}
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63009
|
test
|
function(str) {
var cache = STRING_DASHERIZE_CACHE,
hit = cache.hasOwnProperty(str),
ret;
if (hit) {
return cache[str];
} else {
ret = Ember.String.decamelize(str).replace(STRING_DASHERIZE_REGEXP,'-');
cache[str] = ret;
}
return ret;
}
|
javascript
|
{
"resource": ""
}
|
|
q63010
|
test
|
function(keyName, increment) {
if (Ember.isNone(increment)) { increment = 1; }
Ember.assert("Must pass a numeric value to incrementProperty", (!isNaN(parseFloat(increment)) && isFinite(increment)));
set(this, keyName, (get(this, keyName) || 0) + increment);
return get(this, keyName);
}
|
javascript
|
{
"resource": ""
}
|
|
q63011
|
test
|
function(keyName, decrement) {
if (Ember.isNone(decrement)) { decrement = 1; }
Ember.assert("Must pass a numeric value to decrementProperty", (!isNaN(parseFloat(decrement)) && isFinite(decrement)));
set(this, keyName, (get(this, keyName) || 0) - decrement);
return get(this, keyName);
}
|
javascript
|
{
"resource": ""
}
|
|
q63012
|
test
|
function() {
var Class = makeCtor(), proto;
Class.ClassMixin = Mixin.create(this.ClassMixin);
Class.PrototypeMixin = Mixin.create(this.PrototypeMixin);
Class.ClassMixin.ownerConstructor = Class;
Class.PrototypeMixin.ownerConstructor = Class;
reopen.apply(Class.PrototypeMixin, arguments);
Class.superclass = this;
Class.__super__ = this.prototype;
proto = Class.prototype = o_create(this.prototype);
proto.constructor = Class;
generateGuid(proto);
meta(proto).proto = proto; // this will disable observers on prototype
Class.ClassMixin.apply(Class);
return Class;
}
|
javascript
|
{
"resource": ""
}
|
|
q63013
|
test
|
function(key) {
var meta = this.proto()[META_KEY],
desc = meta && meta.descs[key];
Ember.assert("metaForProperty() could not find a computed property with key '"+key+"'.", !!desc && desc instanceof Ember.ComputedProperty);
return desc._meta || {};
}
|
javascript
|
{
"resource": ""
}
|
|
q63014
|
test
|
function(key, value) {
var exactValue = function(item) { return get(item, key) === value; },
hasValue = function(item) { return !!get(item, key); },
use = (arguments.length === 2 ? exactValue : hasValue);
return this.reject(use);
}
|
javascript
|
{
"resource": ""
}
|
|
q63015
|
test
|
function(value) {
if (!this.contains(value)) return this; // nothing to do
var ret = Ember.A();
this.forEach(function(k) {
if (k !== value) ret[ret.length] = k;
}) ;
return ret ;
}
|
javascript
|
{
"resource": ""
}
|
|
q63016
|
test
|
function() {
var ret = Ember.A();
this.forEach(function(k) {
if (a_indexOf(ret, k)<0) ret.push(k);
});
return ret;
}
|
javascript
|
{
"resource": ""
}
|
|
q63017
|
test
|
function(startIdx, removeAmt, addAmt) {
// if no args are passed assume everything changes
if (startIdx===undefined) {
startIdx = 0;
removeAmt = addAmt = -1;
} else {
if (removeAmt === undefined) removeAmt=-1;
if (addAmt === undefined) addAmt=-1;
}
// Make sure the @each proxy is set up if anyone is observing @each
if (Ember.isWatching(this, '@each')) { get(this, '@each'); }
Ember.sendEvent(this, '@array:before', [this, startIdx, removeAmt, addAmt]);
var removing, lim;
if (startIdx>=0 && removeAmt>=0 && get(this, 'hasEnumerableObservers')) {
removing = [];
lim = startIdx+removeAmt;
for(var idx=startIdx;idx<lim;idx++) removing.push(this.objectAt(idx));
} else {
removing = removeAmt;
}
this.enumerableContentWillChange(removing, addAmt);
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q63018
|
test
|
function(startIdx, removeAmt, addAmt) {
// if no args are passed assume everything changes
if (startIdx===undefined) {
startIdx = 0;
removeAmt = addAmt = -1;
} else {
if (removeAmt === undefined) removeAmt=-1;
if (addAmt === undefined) addAmt=-1;
}
var adding, lim;
if (startIdx>=0 && addAmt>=0 && get(this, 'hasEnumerableObservers')) {
adding = [];
lim = startIdx+addAmt;
for(var idx=startIdx;idx<lim;idx++) adding.push(this.objectAt(idx));
} else {
adding = addAmt;
}
this.enumerableContentDidChange(removeAmt, adding);
Ember.sendEvent(this, '@array:change', [this, startIdx, removeAmt, addAmt]);
var length = get(this, 'length'),
cachedFirst = cacheFor(this, 'firstObject'),
cachedLast = cacheFor(this, 'lastObject');
if (this.objectAt(0) !== cachedFirst) {
Ember.propertyWillChange(this, 'firstObject');
Ember.propertyDidChange(this, 'firstObject');
}
if (this.objectAt(length-1) !== cachedLast) {
Ember.propertyWillChange(this, 'lastObject');
Ember.propertyDidChange(this, 'lastObject');
}
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q63019
|
ReduceComputedProperty
|
test
|
function ReduceComputedProperty(options) {
var cp = this;
this.options = options;
this._dependentKeys = null;
// A map of dependentKey -> [itemProperty, ...] that tracks what properties of
// items in the array we must track to update this property.
this._itemPropertyKeys = {};
this._previousItemPropertyKeys = {};
this.readOnly();
this.cacheable();
this.recomputeOnce = function(propertyName) {
// What we really want to do is coalesce by <cp, propertyName>.
// We need a form of `scheduleOnce` that accepts an arbitrary token to
// coalesce by, in addition to the target and method.
Ember.run.once(this, recompute, propertyName);
};
var recompute = function(propertyName) {
var dependentKeys = cp._dependentKeys,
meta = cp._instanceMeta(this, propertyName),
callbacks = cp._callbacks();
reset.call(this, cp, propertyName);
meta.dependentArraysObserver.suspendArrayObservers(function () {
forEach(cp._dependentKeys, function (dependentKey) {
Ember.assert(
"dependent array " + dependentKey + " must be an `Ember.Array`. " +
"If you are not extending arrays, you will need to wrap native arrays with `Ember.A`",
!(Ember.isArray(get(this, dependentKey)) && !Ember.Array.detect(get(this, dependentKey))));
if (!partiallyRecomputeFor(this, dependentKey)) { return; }
var dependentArray = get(this, dependentKey),
previousDependentArray = meta.dependentArrays[dependentKey];
if (dependentArray === previousDependentArray) {
// The array may be the same, but our item property keys may have
// changed, so we set them up again. We can't easily tell if they've
// changed: the array may be the same object, but with different
// contents.
if (cp._previousItemPropertyKeys[dependentKey]) {
delete cp._previousItemPropertyKeys[dependentKey];
meta.dependentArraysObserver.setupPropertyObservers(dependentKey, cp._itemPropertyKeys[dependentKey]);
}
} else {
meta.dependentArrays[dependentKey] = dependentArray;
if (previousDependentArray) {
meta.dependentArraysObserver.teardownObservers(previousDependentArray, dependentKey);
}
if (dependentArray) {
meta.dependentArraysObserver.setupObservers(dependentArray, dependentKey);
}
}
}, this);
}, this);
forEach(cp._dependentKeys, function(dependentKey) {
if (!partiallyRecomputeFor(this, dependentKey)) { return; }
var dependentArray = get(this, dependentKey);
if (dependentArray) {
addItems.call(this, dependentArray, callbacks, cp, propertyName, meta);
}
}, this);
};
this.func = function (propertyName) {
Ember.assert("Computed reduce values require at least one dependent key", cp._dependentKeys);
recompute.call(this, propertyName);
return cp._instanceMeta(this, propertyName).getValue();
};
}
|
javascript
|
{
"resource": ""
}
|
q63020
|
test
|
function(objects) {
Ember.beginPropertyChanges(this);
forEach(objects, function(obj) { this.addObject(obj); }, this);
Ember.endPropertyChanges(this);
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q63021
|
test
|
function(objects) {
Ember.beginPropertyChanges(this);
forEach(objects, function(obj) { this.removeObject(obj); }, this);
Ember.endPropertyChanges(this);
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q63022
|
test
|
function(name) {
var args = [], i, l;
for (i = 1, l = arguments.length; i < l; i++) {
args.push(arguments[i]);
}
Ember.sendEvent(this, name, args);
}
|
javascript
|
{
"resource": ""
}
|
|
q63023
|
test
|
function(resolve, reject, label) {
var deferred, promise, entity;
entity = this;
deferred = get(this, '_deferred');
promise = deferred.promise;
function fulfillmentHandler(fulfillment) {
if (fulfillment === promise) {
return resolve(entity);
} else {
return resolve(fulfillment);
}
}
return promise.then(resolve && fulfillmentHandler, reject, label);
}
|
javascript
|
{
"resource": ""
}
|
|
q63024
|
test
|
function(value) {
var deferred, promise;
deferred = get(this, '_deferred');
promise = deferred.promise;
if (value === this) {
deferred.resolve(promise);
} else {
deferred.resolve(value);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63025
|
test
|
function(props) {
var hashName;
if (!props._actions) {
Ember.assert("'actions' should not be a function", typeof(props.actions) !== 'function');
if (typeOf(props.actions) === 'object') {
hashName = 'actions';
} else if (typeOf(props.events) === 'object') {
Ember.deprecate('Action handlers contained in an `events` object are deprecated in favor of putting them in an `actions` object', false);
hashName = 'events';
}
if (hashName) {
props._actions = Ember.merge(props._actions || {}, props[hashName]);
}
delete props[hashName];
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63026
|
test
|
function(actionName) {
var args = [].slice.call(arguments, 1), target;
if (this._actions && this._actions[actionName]) {
if (this._actions[actionName].apply(this, args) === true) {
// handler returned true, so this action will bubble
} else {
return;
}
} else if (!Ember.FEATURES.isEnabled('ember-routing-drop-deprecated-action-style') && this.deprecatedSend && this.deprecatedSendHandles && this.deprecatedSendHandles(actionName)) {
Ember.warn("The current default is deprecated but will prefer to handle actions directly on the controller instead of a similarly named action in the actions hash. To turn off this deprecated feature set: Ember.FEATURES['ember-routing-drop-deprecated-action-style'] = true");
if (this.deprecatedSend.apply(this, [].slice.call(arguments)) === true) {
// handler return true, so this action will bubble
} else {
return;
}
}
if (target = get(this, 'target')) {
Ember.assert("The `target` for " + this + " (" + target + ") does not have a `send` method", typeof target.send === 'function');
target.send.apply(target, arguments);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63027
|
test
|
function (index, newItems) {
var count = get(newItems, 'length');
if (count < 1) { return; }
var match = this._findArrayOperation(index),
arrayOperation = match.operation,
arrayOperationIndex = match.index,
arrayOperationRangeStart = match.rangeStart,
composeIndex,
splitIndex,
splitItems,
splitArrayOperation,
newArrayOperation;
newArrayOperation = new ArrayOperation(INSERT, count, newItems);
if (arrayOperation) {
if (!match.split) {
// insert left of arrayOperation
this._operations.splice(arrayOperationIndex, 0, newArrayOperation);
composeIndex = arrayOperationIndex;
} else {
this._split(arrayOperationIndex, index - arrayOperationRangeStart, newArrayOperation);
composeIndex = arrayOperationIndex + 1;
}
} else {
// insert at end
this._operations.push(newArrayOperation);
composeIndex = arrayOperationIndex;
}
this._composeInsert(composeIndex);
}
|
javascript
|
{
"resource": ""
}
|
|
q63028
|
test
|
function (index, count) {
if (count < 1) { return; }
var match = this._findArrayOperation(index),
arrayOperation = match.operation,
arrayOperationIndex = match.index,
arrayOperationRangeStart = match.rangeStart,
newArrayOperation,
composeIndex;
newArrayOperation = new ArrayOperation(DELETE, count);
if (!match.split) {
// insert left of arrayOperation
this._operations.splice(arrayOperationIndex, 0, newArrayOperation);
composeIndex = arrayOperationIndex;
} else {
this._split(arrayOperationIndex, index - arrayOperationRangeStart, newArrayOperation);
composeIndex = arrayOperationIndex + 1;
}
return this._composeDelete(composeIndex);
}
|
javascript
|
{
"resource": ""
}
|
|
q63029
|
test
|
function (index) {
var newArrayOperation = this._operations[index],
leftArrayOperation = this._operations[index-1], // may be undefined
rightArrayOperation = this._operations[index+1], // may be undefined
leftOp = leftArrayOperation && leftArrayOperation.type,
rightOp = rightArrayOperation && rightArrayOperation.type;
if (leftOp === INSERT) {
// merge left
leftArrayOperation.count += newArrayOperation.count;
leftArrayOperation.items = leftArrayOperation.items.concat(newArrayOperation.items);
if (rightOp === INSERT) {
// also merge right (we have split an insert with an insert)
leftArrayOperation.count += rightArrayOperation.count;
leftArrayOperation.items = leftArrayOperation.items.concat(rightArrayOperation.items);
this._operations.splice(index, 2);
} else {
// only merge left
this._operations.splice(index, 1);
}
} else if (rightOp === INSERT) {
// merge right
newArrayOperation.count += rightArrayOperation.count;
newArrayOperation.items = newArrayOperation.items.concat(rightArrayOperation.items);
this._operations.splice(index + 1, 1);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63030
|
ArrayOperation
|
test
|
function ArrayOperation (operation, count, items) {
this.type = operation; // RETAIN | INSERT | DELETE
this.count = count;
this.items = items;
}
|
javascript
|
{
"resource": ""
}
|
q63031
|
ArrayOperationMatch
|
test
|
function ArrayOperationMatch(operation, index, split, rangeStart) {
this.operation = operation;
this.index = index;
this.split = split;
this.rangeStart = rangeStart;
}
|
javascript
|
{
"resource": ""
}
|
q63032
|
test
|
function(index, match) {
var returnValue = -1,
itemType = match ? RETAIN : FILTER,
self = this;
this._findOperation(index, function(operation, operationIndex, rangeStart, rangeEnd, seenInSubArray) {
var newOperation, splitOperation;
if (itemType === operation.type) {
++operation.count;
} else if (index === rangeStart) {
// insert to the left of `operation`
self._operations.splice(operationIndex, 0, new Operation(itemType, 1));
} else {
newOperation = new Operation(itemType, 1);
splitOperation = new Operation(operation.type, rangeEnd - index + 1);
operation.count = index - rangeStart;
self._operations.splice(operationIndex + 1, 0, newOperation, splitOperation);
}
if (match) {
if (operation.type === RETAIN) {
returnValue = seenInSubArray + (index - rangeStart);
} else {
returnValue = seenInSubArray;
}
}
self._composeAt(operationIndex);
}, function(seenInSubArray) {
self._operations.push(new Operation(itemType, 1));
if (match) {
returnValue = seenInSubArray;
}
self._composeAt(self._operations.length-1);
});
return returnValue;
}
|
javascript
|
{
"resource": ""
}
|
|
q63033
|
test
|
function(index) {
var returnValue = -1,
self = this;
this._findOperation(index, function (operation, operationIndex, rangeStart, rangeEnd, seenInSubArray) {
if (operation.type === RETAIN) {
returnValue = seenInSubArray + (index - rangeStart);
}
if (operation.count > 1) {
--operation.count;
} else {
self._operations.splice(operationIndex, 1);
self._composeAt(operationIndex);
}
}, function() {
throw new Ember.Error("Can't remove an item that has never been added.");
});
return returnValue;
}
|
javascript
|
{
"resource": ""
}
|
|
q63034
|
test
|
function(keyName, value) {
var ret;
ret = new EachArray(this._content, keyName, this);
Ember.defineProperty(this, keyName, null, ret);
this.beginObservingContentKey(keyName);
return ret;
}
|
javascript
|
{
"resource": ""
}
|
|
q63035
|
test
|
function(idx, amt, objects) {
if (this.isFrozen) throw Ember.FROZEN_ERROR;
// if we replaced exactly the same number of items, then pass only the
// replaced range. Otherwise, pass the full remaining array length
// since everything has shifted
var len = objects ? get(objects, 'length') : 0;
this.arrayContentWillChange(idx, amt, len);
if (len === 0) {
this.splice(idx, amt);
} else {
replace(this, idx, amt, objects);
}
this.arrayContentDidChange(idx, amt, len);
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q63036
|
test
|
function() {
if (this.isFrozen) { throw new Ember.Error(Ember.FROZEN_ERROR); }
var len = get(this, 'length');
if (len === 0) { return this; }
var guid;
this.enumerableContentWillChange(len, 0);
Ember.propertyWillChange(this, 'firstObject');
Ember.propertyWillChange(this, 'lastObject');
for (var i=0; i < len; i++) {
guid = guidFor(this[i]);
delete this[guid];
delete this[i];
}
set(this, 'length', 0);
Ember.propertyDidChange(this, 'firstObject');
Ember.propertyDidChange(this, 'lastObject');
this.enumerableContentDidChange(len, 0);
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q63037
|
test
|
function() {
if (get(this, 'isFrozen')) throw new Ember.Error(Ember.FROZEN_ERROR);
var obj = this.length > 0 ? this[this.length-1] : null;
this.remove(obj);
return obj;
}
|
javascript
|
{
"resource": ""
}
|
|
q63038
|
test
|
function(element, id) {
if (element.getAttribute('id') === id) { return element; }
var len = element.childNodes.length, idx, node, found;
for (idx=0; idx<len; idx++) {
node = element.childNodes[idx];
found = node.nodeType === 1 && findChildById(node, id);
if (found) { return found; }
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63039
|
test
|
function(className) {
// lazily create elementClasses
this.elementClasses = (this.elementClasses || new ClassSet());
this.elementClasses.add(className);
this.classes = this.elementClasses.list;
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q63040
|
test
|
function(name, value) {
var attributes = this.elementAttributes = (this.elementAttributes || {});
if (arguments.length === 1) {
return attributes[name];
} else {
attributes[name] = value;
}
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q63041
|
test
|
function(name, value) {
var properties = this.elementProperties = (this.elementProperties || {});
if (arguments.length === 1) {
return properties[name];
} else {
properties[name] = value;
}
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q63042
|
test
|
function() {
if (this._hasElement && this._element) {
// Firefox versions < 11 do not have support for element.outerHTML.
var thisElement = this.element(), outerHTML = thisElement.outerHTML;
if (typeof outerHTML === 'undefined') {
return Ember.$('<div/>').append(thisElement).html();
}
return outerHTML;
} else {
return this.innerString();
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63043
|
test
|
function(addedEvents, rootElement) {
var event, events = get(this, 'events');
Ember.$.extend(events, addedEvents || {});
if (!Ember.isNone(rootElement)) {
set(this, 'rootElement', rootElement);
}
rootElement = Ember.$(get(this, 'rootElement'));
Ember.assert(fmt('You cannot use the same root element (%@) multiple times in an Ember.Application', [rootElement.selector || rootElement[0].tagName]), !rootElement.is('.ember-application'));
Ember.assert('You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application', !rootElement.closest('.ember-application').length);
Ember.assert('You cannot make a new Ember.Application using a root element that is an ancestor of an existing Ember.Application', !rootElement.find('.ember-application').length);
rootElement.addClass('ember-application');
Ember.assert('Unable to add "ember-application" class to rootElement. Make sure you set rootElement to the body or an element in the body.', rootElement.is('.ember-application'));
for (event in events) {
if (events.hasOwnProperty(event)) {
this.setupHandler(rootElement, event, events[event]);
}
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63044
|
test
|
function(rootElement, event, eventName) {
var self = this;
rootElement.on(event + '.ember', '.ember-view', function(evt, triggeringManager) {
var view = Ember.View.views[this.id],
result = true, manager = null;
manager = self._findNearestEventManager(view, eventName);
if (manager && manager !== triggeringManager) {
result = self._dispatchEvent(manager, evt, eventName, view);
} else if (view) {
result = self._bubbleEvent(view, evt, eventName);
} else {
evt.stopPropagation();
}
return result;
});
rootElement.on(event + '.ember', '[data-ember-action]', function(evt) {
var actionId = Ember.$(evt.currentTarget).attr('data-ember-action'),
action = Ember.Handlebars.ActionHelper.registeredActions[actionId];
// We have to check for action here since in some cases, jQuery will trigger
// an event on `removeChild` (i.e. focusout) after we've already torn down the
// action handlers for the view.
if (action && action.eventName === eventName) {
return action.handler(evt);
}
});
}
|
javascript
|
{
"resource": ""
}
|
|
q63045
|
test
|
function(klass) {
Ember.deprecate("nearestInstanceOf is deprecated and will be removed from future releases. Use nearestOfType.");
var view = get(this, 'parentView');
while (view) {
if (view instanceof klass) { return view; }
view = get(view, 'parentView');
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63046
|
test
|
function(property) {
var view = get(this, 'parentView');
while (view) {
if (property in view) { return view; }
view = get(view, 'parentView');
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63047
|
test
|
function(klass) {
var view = get(this, 'parentView');
while (view) {
if (get(view, 'parentView') instanceof klass) { return view; }
view = get(view, 'parentView');
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63048
|
test
|
function(buffer) {
// If this view has a layout, it is the responsibility of the
// the layout to render the view's template. Otherwise, render the template
// directly.
var template = get(this, 'layout') || get(this, 'template');
if (template) {
var context = get(this, 'context');
var keywords = this.cloneKeywords();
var output;
var data = {
view: this,
buffer: buffer,
isRenderData: true,
keywords: keywords,
insideGroup: get(this, 'templateData.insideGroup')
};
// Invoke the template with the provided template context, which
// is the view's controller by default. A hash of data is also passed that provides
// the template with access to the view and render buffer.
Ember.assert('template must be a function. Did you mean to call Ember.Handlebars.compile("...") or specify templateName instead?', typeof template === 'function');
// The template should write directly to the render buffer instead
// of returning a string.
output = template(context, { data: data });
// If the template returned a string instead of writing to the buffer,
// push the string onto the buffer.
if (output !== undefined) { buffer.push(output); }
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63049
|
test
|
function() {
// Get the current value of the property
newClass = this._classStringForProperty(binding);
elem = this.$();
// If we had previously added a class to the element, remove it.
if (oldClass) {
elem.removeClass(oldClass);
// Also remove from classNames so that if the view gets rerendered,
// the class doesn't get added back to the DOM.
classNames.removeObject(oldClass);
}
// If necessary, add a new class. Make sure we keep track of it so
// it can be removed in the future.
if (newClass) {
elem.addClass(newClass);
oldClass = newClass;
} else {
oldClass = null;
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63050
|
test
|
function(buffer, attributeBindings) {
var attributeValue,
unspecifiedAttributeBindings = this._unspecifiedAttributeBindings = this._unspecifiedAttributeBindings || {};
a_forEach(attributeBindings, function(binding) {
var split = binding.split(':'),
property = split[0],
attributeName = split[1] || property;
if (property in this) {
this._setupAttributeBindingObservation(property, attributeName);
// Determine the current value and add it to the render buffer
// if necessary.
attributeValue = get(this, property);
Ember.View.applyAttributeBindings(buffer, attributeName, attributeValue);
} else {
unspecifiedAttributeBindings[property] = attributeName;
}
}, this);
// Lazily setup setUnknownProperty after attributeBindings are initially applied
this.setUnknownProperty = this._setUnknownProperty;
}
|
javascript
|
{
"resource": ""
}
|
|
q63051
|
test
|
function(key, value) {
var attributeName = this._unspecifiedAttributeBindings && this._unspecifiedAttributeBindings[key];
if (attributeName) {
this._setupAttributeBindingObservation(key, attributeName);
}
defineProperty(this, key);
return set(this, key, value);
}
|
javascript
|
{
"resource": ""
}
|
|
q63052
|
test
|
function(path) {
var split = path.split(':'),
propertyPath = split[0],
classNames = "",
className,
falsyClassName;
// check if the property is defined as prop:class or prop:trueClass:falseClass
if (split.length > 1) {
className = split[1];
if (split.length === 3) { falsyClassName = split[2]; }
classNames = ':' + className;
if (falsyClassName) { classNames += ":" + falsyClassName; }
}
return {
path: propertyPath,
classNames: classNames,
className: (className === '') ? undefined : className,
falsyClassName: falsyClassName
};
}
|
javascript
|
{
"resource": ""
}
|
|
q63053
|
test
|
function(view, childView, options) {
var buffer = view.buffer, _childViews = view._childViews;
childView = view.createChildView(childView, options);
if (!_childViews.length) { _childViews = view._childViews = _childViews.slice(); }
_childViews.push(childView);
childView.renderToBuffer(buffer);
view.propertyDidChange('childViews');
return childView;
}
|
javascript
|
{
"resource": ""
}
|
|
q63054
|
test
|
function(view) {
view.clearBuffer();
var viewCollection = view._notifyWillDestroyElement();
viewCollection.transitionTo('preRender', false);
return view;
}
|
javascript
|
{
"resource": ""
}
|
|
q63055
|
test
|
function(view) {
view.triggerRecursively('willClearRender');
view.clearRenderedChildren();
view.domManager.replace(view);
return view;
}
|
javascript
|
{
"resource": ""
}
|
|
q63056
|
test
|
function(view) {
view._notifyWillDestroyElement();
view.domManager.remove(view);
set(view, 'element', null);
if (view._scheduledInsert) {
Ember.run.cancel(view._scheduledInsert);
view._scheduledInsert = null;
}
return view;
}
|
javascript
|
{
"resource": ""
}
|
|
q63057
|
test
|
function(view, eventName, evt) {
if (view.has(eventName)) {
// Handler should be able to re-dispatch events, so we don't
// preventDefault or stopPropagation.
return view.trigger(eventName, evt);
} else {
return true; // continue event propagation
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63058
|
test
|
function(views, start, removed) {
this.propertyWillChange('childViews');
if (removed > 0) {
var changedViews = views.slice(start, start+removed);
// transition to preRender before clearing parentView
this.currentState.childViewsWillChange(this, views, start, removed);
this.initializeViews(changedViews, null, null);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63059
|
test
|
function(views, start, removed, added) {
if (added > 0) {
var changedViews = views.slice(start, start+added);
this.initializeViews(changedViews, this, get(this, 'templateData'));
this.currentState.childViewsDidChange(this, views, start, added);
}
this.propertyDidChange('childViews');
}
|
javascript
|
{
"resource": ""
}
|
|
q63060
|
test
|
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 = this._childViews, childView, idx, len;
len = this._childViews.length;
var removingAll = removedCount === len;
if (removingAll) {
this.currentState.empty(this);
this.invokeRecursively(function(view) {
view.removedFromDOM = true;
}, false);
}
for (idx = start + removedCount - 1; idx >= start; idx--) {
childView = childViews[idx];
childView.destroy();
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63061
|
test
|
function(content, start, removed, added) {
var addedViews = [], view, item, idx, len, itemViewClass,
emptyView;
len = content ? get(content, 'length') : 0;
if (len) {
itemViewClass = get(this, 'itemViewClass');
if ('string' === typeof itemViewClass) {
itemViewClass = get(itemViewClass) || itemViewClass;
}
Ember.assert(fmt("itemViewClass must be a subclass of Ember.View, not %@",
[itemViewClass]),
'string' === typeof itemViewClass || Ember.View.detect(itemViewClass));
for (idx = start; idx < start+added; idx++) {
item = content.objectAt(idx);
view = this.createChildView(itemViewClass, {
content: item,
contentIndex: idx
});
addedViews.push(view);
}
} else {
emptyView = get(this, 'emptyView');
if (!emptyView) { return; }
if ('string' === typeof emptyView) {
emptyView = get(emptyView) || emptyView;
}
emptyView = this.createChildView(emptyView);
addedViews.push(emptyView);
set(this, 'emptyView', emptyView);
if (Ember.CoreView.detect(emptyView)) {
this._createdEmptyView = emptyView;
}
}
this.replace(start, 0, addedViews);
}
|
javascript
|
{
"resource": ""
}
|
|
q63062
|
test
|
function(action) {
var actionName,
contexts = a_slice.call(arguments, 1);
// Send the default action
if (action === undefined) {
actionName = get(this, 'action');
Ember.assert("The default action was triggered on the component " + this.toString() +
", but the action name (" + actionName + ") was not a string.",
isNone(actionName) || typeof actionName === 'string');
} else {
actionName = get(this, action);
Ember.assert("The " + action + " action was triggered on the component " +
this.toString() + ", but the action name (" + actionName +
") was not a string.",
isNone(actionName) || typeof actionName === 'string');
}
// If no action name for that action could be found, just abort.
if (actionName === undefined) { return; }
this.triggerAction({
action: actionName,
actionContext: contexts
});
}
|
javascript
|
{
"resource": ""
}
|
|
q63063
|
evaluateUnboundHelper
|
test
|
function evaluateUnboundHelper(context, fn, normalizedProperties, options) {
var args = [],
hash = options.hash,
boundOptions = hash.boundOptions,
types = slice.call(options.types, 1),
loc,
len,
property,
propertyType,
boundOption;
for (boundOption in boundOptions) {
if (!boundOptions.hasOwnProperty(boundOption)) { continue; }
hash[boundOption] = Ember.Handlebars.get(context, boundOptions[boundOption], options);
}
for(loc = 0, len = normalizedProperties.length; loc < len; ++loc) {
property = normalizedProperties[loc];
propertyType = types[loc];
if(propertyType === "ID") {
args.push(Ember.Handlebars.get(property.root, property.path, options));
} else {
args.push(property.path);
}
}
args.push(options);
return fn.apply(context, args);
}
|
javascript
|
{
"resource": ""
}
|
q63064
|
test
|
function(view) {
var morph = view.morph;
view.transitionTo('preRender');
Ember.run.schedule('render', this, function renderMetamorphView() {
if (view.isDestroying) { return; }
view.clearRenderedChildren();
var buffer = view.renderToBuffer();
view.invokeRecursively(function(view) {
view.propertyWillChange('element');
});
view.triggerRecursively('willInsertElement');
morph.replaceWith(buffer.string());
view.transitionTo('inDOM');
view.invokeRecursively(function(view) {
view.propertyDidChange('element');
});
view.triggerRecursively('didInsertElement');
notifyMutationListeners();
});
}
|
javascript
|
{
"resource": ""
}
|
|
q63065
|
bind
|
test
|
function bind(property, options, preserveContext, shouldDisplay, valueNormalizer, childProperties) {
var data = options.data,
fn = options.fn,
inverse = options.inverse,
view = data.view,
currentContext = this,
normalized, observer, i;
normalized = normalizePath(currentContext, property, data);
// Set up observers for observable objects
if ('object' === typeof this) {
if (data.insideGroup) {
observer = function() {
Ember.run.once(view, 'rerender');
};
var template, context, result = handlebarsGet(currentContext, property, options);
result = valueNormalizer ? valueNormalizer(result) : result;
context = preserveContext ? currentContext : result;
if (shouldDisplay(result)) {
template = fn;
} else if (inverse) {
template = inverse;
}
template(context, { data: options.data });
} else {
// 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._HandlebarsBoundView for more.
var bindView = view.createChildView(Ember._HandlebarsBoundView, {
preserveContext: preserveContext,
shouldDisplayFunc: shouldDisplay,
valueNormalizerFunc: valueNormalizer,
displayTemplate: fn,
inverseTemplate: inverse,
path: property,
pathRoot: currentContext,
previousContext: currentContext,
isEscaped: !options.hash.unescaped,
templateData: options.data
});
if (options.hash.controller) {
bindView.set('_contextController', this.container.lookupFactory('controller:'+options.hash.controller).create({
container: currentContext.container,
parentController: currentContext,
target: currentContext
}));
}
view.appendChild(bindView);
observer = function() {
Ember.run.scheduleOnce('render', bindView, 'rerenderIfNeeded');
};
}
// Observes the given property on the context and
// tells the Ember._HandlebarsBoundView 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 (normalized.path !== '') {
view.registerObserver(normalized.root, normalized.path, observer);
if (childProperties) {
for (i=0; i<childProperties.length; i++) {
view.registerObserver(normalized.root, normalized.path+'.'+childProperties[i], observer);
}
}
}
} else {
// The object is not observable, so just render it out and
// be done with it.
data.buffer.push(handlebarsGetEscaped(currentContext, property, options));
}
}
|
javascript
|
{
"resource": ""
}
|
q63066
|
_addMetamorphCheck
|
test
|
function _addMetamorphCheck() {
Ember.Handlebars.EachView.reopen({
_checkMetamorph: Ember.on('didInsertElement', function() {
Ember.assert("The metamorph tags, " +
this.morph.start + " and " + this.morph.end +
", have different parents.\nThe browser has fixed your template to output valid HTML (for example, check that you have properly closed all tags and have used a TBODY tag when creating a table with '{{#each}}')",
document.getElementById( this.morph.start ).parentNode ===
document.getElementById( this.morph.end ).parentNode
);
})
});
}
|
javascript
|
{
"resource": ""
}
|
q63067
|
test
|
function() {
if (this.state) {
forEach(this.state.handlerInfos, function(handlerInfo) {
var handler = handlerInfo.handler;
if (handler.exit) {
handler.exit();
}
});
}
this.state = new TransitionState();
this.currentHandlerInfos = null;
}
|
javascript
|
{
"resource": ""
}
|
|
q63068
|
test
|
function() {
this.router = this.router || this.constructor.map(Ember.K);
var router = this.router,
location = get(this, 'location'),
container = this.container,
self = this,
initialURL = get(this, 'initialURL');
// Allow the Location class to cancel the router setup while it refreshes
// the page
if (get(location, 'cancelRouterSetup')) {
return;
}
this._setupRouter(router, location);
container.register('view:default', DefaultView);
container.register('view:toplevel', Ember.View.extend());
location.onUpdateURL(function(url) {
self.handleURL(url);
});
if (typeof initialURL === "undefined") {
initialURL = location.getURL();
}
this.handleURL(initialURL);
}
|
javascript
|
{
"resource": ""
}
|
|
q63069
|
test
|
function(context, transition) {
var controllerName = this.controllerName || this.routeName,
controller = this.controllerFor(controllerName, true);
if (!controller) {
controller = this.generateController(controllerName, context);
}
// Assign the route's controller so that it can more easily be
// referenced in action handlers
this.controller = controller;
if (this.setupControllers) {
Ember.deprecate("Ember.Route.setupControllers is deprecated. Please use Ember.Route.setupController(controller, model) instead.");
this.setupControllers(controller, context);
} else {
this.setupController(controller, context);
}
if (this.renderTemplates) {
Ember.deprecate("Ember.Route.renderTemplates is deprecated. Please use Ember.Route.renderTemplate(controller, model) instead.");
this.renderTemplates(context);
} else {
this.renderTemplate(controller, context);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63070
|
test
|
function(params, transition) {
var match, name, sawParams, value;
for (var prop in params) {
if (prop === 'queryParams') { continue; }
if (match = prop.match(/^(.*)_id$/)) {
name = match[1];
value = params[prop];
}
sawParams = true;
}
if (!name && sawParams) { return Ember.copy(params); }
else if (!name) {
if (transition.resolveIndex !== transition.state.handlerInfos.length-1) { return; }
var parentModel = transition.state.handlerInfos[transition.resolveIndex-1].context;
return parentModel;
}
return this.findModel(name, value);
}
|
javascript
|
{
"resource": ""
}
|
|
q63071
|
test
|
function(model, params) {
if (params.length < 1) { return; }
if (!model) { return; }
var name = params[0], object = {};
if (/_id$/.test(name) && params.length === 1) {
object[name] = get(model, "id");
} else {
object = getProperties(model, params);
}
return object;
}
|
javascript
|
{
"resource": ""
}
|
|
q63072
|
test
|
function(name, _skipAssert) {
var container = this.container,
route = container.lookup('route:'+name),
controller;
if (route && route.controllerName) {
name = route.controllerName;
}
controller = container.lookup('controller:' + name);
// NOTE: We're specifically checking that skipAssert is true, because according
// to the old API the second parameter was model. We do not want people who
// passed a model to skip the assertion.
Ember.assert("The controller named '"+name+"' could not be found. Make sure " +
"that this route exists and has already been entered at least " +
"once. If you are accessing a controller not associated with a " +
"route, make sure the controller class is explicitly defined.",
controller || _skipAssert === true);
return controller;
}
|
javascript
|
{
"resource": ""
}
|
|
q63073
|
test
|
function(options) {
if (!options || typeof options === "string") {
var outletName = options;
options = {};
options.outlet = outletName;
}
options.parentView = options.parentView ? options.parentView.replace(/\//g, '.') : parentTemplate(this);
options.outlet = options.outlet || 'main';
var parentView = this.router._lookupActiveView(options.parentView);
if (parentView) { parentView.disconnectOutlet(options.outlet); }
}
|
javascript
|
{
"resource": ""
}
|
|
q63074
|
test
|
function(){
var helperParameters = this.parameters,
linkTextPath = helperParameters.options.linkTextPath,
paths = getResolvedPaths(helperParameters),
length = paths.length,
path, i, normalizedPath;
if (linkTextPath) {
normalizedPath = Ember.Handlebars.normalizePath(helperParameters.context, linkTextPath, helperParameters.options.data);
this.registerObserver(normalizedPath.root, normalizedPath.path, this, this.rerender);
}
for(i=0; i < length; i++) {
path = paths[i];
if (null === path) {
// A literal value was provided, not a path, so nothing to observe.
continue;
}
normalizedPath = Ember.Handlebars.normalizePath(helperParameters.context, path, helperParameters.options.data);
this.registerObserver(normalizedPath.root, normalizedPath.path, this, this._paramsChanged);
}
var queryParamsObject = this.queryParamsObject;
if (queryParamsObject) {
var values = queryParamsObject.values;
// Install observers for all of the hash options
// provided in the (query-params) subexpression.
for (var k in values) {
if (!values.hasOwnProperty(k)) { continue; }
if (queryParamsObject.types[k] === 'ID') {
normalizedPath = Ember.Handlebars.normalizePath(helperParameters.context, values[k], helperParameters.options.data);
this.registerObserver(normalizedPath.root, normalizedPath.path, this, this._paramsChanged);
}
}
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63075
|
test
|
function(event) {
if (!isSimpleClick(event)) { return true; }
if (this.preventDefault !== false) { event.preventDefault(); }
if (this.bubbles === false) { event.stopPropagation(); }
if (get(this, '_isDisabled')) { return false; }
if (get(this, 'loading')) {
Ember.Logger.warn("This link-to is in an inactive loading state because at least one of its parameters presently has a null/undefined value, or the provided route name is invalid.");
return false;
}
var router = get(this, 'router'),
routeArgs = get(this, 'routeArgs');
var transition;
if (get(this, 'replace')) {
transition = router.replaceWith.apply(router, routeArgs);
} else {
transition = router.transitionTo.apply(router, routeArgs);
}
// Schedule eager URL update, but after we've given the transition
// a chance to synchronously redirect.
// We need to always generate the URL instead of using the href because
// the href will include any rootURL set, but the router expects a URL
// without it! Note that we don't use the first level router because it
// calls location.formatURL(), which also would add the rootURL!
var url = router.router.generate.apply(router.router, get(this, 'routeArgs'));
Ember.run.scheduleOnce('routerTransitions', this, this._eagerUpdateUrl, transition, url);
}
|
javascript
|
{
"resource": ""
}
|
|
q63076
|
test
|
function() {
// target may be either another controller or a router
var target = get(this, 'target'),
method = target.replaceRoute || target.replaceWith;
return method.apply(target, arguments);
}
|
javascript
|
{
"resource": ""
}
|
|
q63077
|
test
|
function(outletName, view) {
var existingView = get(this, '_outlets.'+outletName);
return existingView &&
existingView.constructor === view.constructor &&
existingView.get('template') === view.get('template') &&
existingView.get('context') === view.get('context');
}
|
javascript
|
{
"resource": ""
}
|
|
q63078
|
test
|
function() {
if (this.isDestroyed) return; // _outlets will be gone anyway
var outlets = get(this, '_outlets');
var pendingDisconnections = this._pendingDisconnections;
this._pendingDisconnections = null;
for (var outletName in pendingDisconnections) {
set(outlets, outletName, null);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63079
|
test
|
function () {
// AutoLocation has it at _location, HashLocation at .location.
// Being nice and not changing
var href = (this._location || this.location).href,
hashIndex = href.indexOf('#');
if (hashIndex === -1) {
return '';
} else {
return href.substr(hashIndex);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63080
|
test
|
function(path) {
var state = { path: path };
get(this, 'history').replaceState(state, null, path);
// store state if browser doesn't support `history.state`
if (!supportsHistoryState) {
this._historyState = state;
}
// used for webkit workaround
this._previousURL = this.getURL();
}
|
javascript
|
{
"resource": ""
}
|
|
q63081
|
test
|
function(callback) {
var guid = Ember.guidFor(this),
self = this;
Ember.$(window).on('popstate.ember-location-'+guid, function(e) {
// Ignore initial page load popstate event in Chrome
if (!popstateFired) {
popstateFired = true;
if (self.getURL() === self._previousURL) { return; }
}
callback(self.getURL());
});
}
|
javascript
|
{
"resource": ""
}
|
|
q63082
|
test
|
function (options) {
if (options && options.rootURL) {
Ember.assert('rootURL must end with a trailing forward slash e.g. "/app/"', options.rootURL.charAt(options.rootURL.length-1) === '/');
this.rootURL = options.rootURL;
}
var historyPath, hashPath,
cancelRouterSetup = false,
implementationClass = this._NoneLocation,
currentPath = this._getFullPath();
if (this._getSupportsHistory()) {
historyPath = this._getHistoryPath();
// Since we support history paths, let's be sure we're using them else
// switch the location over to it.
if (currentPath === historyPath) {
implementationClass = this._HistoryLocation;
} else {
cancelRouterSetup = true;
this._replacePath(historyPath);
}
} else if (this._getSupportsHashChange()) {
hashPath = this._getHashPath();
// Be sure we're using a hashed path, otherwise let's switch over it to so
// we start off clean and consistent. We'll count an index path with no
// hash as "good enough" as well.
if (currentPath === hashPath || (currentPath === '/' && hashPath === '/#/')) {
implementationClass = this._HashLocation;
} else {
// Our URL isn't in the expected hash-supported format, so we want to
// cancel the router setup and replace the URL to start off clean
cancelRouterSetup = true;
this._replacePath(hashPath);
}
}
var implementation = implementationClass.create.apply(implementationClass, arguments);
if (cancelRouterSetup) {
set(implementation, 'cancelRouterSetup', true);
}
return implementation;
}
|
javascript
|
{
"resource": ""
}
|
|
q63083
|
test
|
function(fullName) {
var parsedName = this.parseName(fullName),
resolveMethodName = parsedName.resolveMethodName;
if (!(parsedName.name && parsedName.type)) {
throw new TypeError("Invalid fullName: `" + fullName + "`, must be of the form `type:name` ");
}
if (this[resolveMethodName]) {
var resolved = this[resolveMethodName](parsedName);
if (resolved) { return resolved; }
}
return this.resolveOther(parsedName);
}
|
javascript
|
{
"resource": ""
}
|
|
q63084
|
test
|
function(parsedName) {
var templateName = parsedName.fullNameWithoutType.replace(/\./g, '/');
if (Ember.TEMPLATES[templateName]) {
return Ember.TEMPLATES[templateName];
}
templateName = decamelize(templateName);
if (Ember.TEMPLATES[templateName]) {
return Ember.TEMPLATES[templateName];
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63085
|
test
|
function() {
if (this.Router === false) { return; }
var container = this.__container__;
if (this.Router) {
container.unregister('router:main');
container.register('router:main', this.Router);
}
return container.lookupFactory('router:main');
}
|
javascript
|
{
"resource": ""
}
|
|
q63086
|
test
|
function() {
var self = this;
if (!this.$ || this.$.isReady) {
Ember.run.schedule('actions', self, '_initialize');
} else {
this.$().ready(function runInitialize() {
Ember.run(self, '_initialize');
});
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63087
|
test
|
function() {
Ember.assert("You must call advanceReadiness on an instance of Ember.Application", this instanceof Ember.Application);
this._readinessDeferrals--;
if (this._readinessDeferrals === 0) {
Ember.run.once(this, this.didBecomeReady);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63088
|
test
|
function() {
var customEvents = get(this, 'customEvents'),
rootElement = get(this, 'rootElement'),
dispatcher = this.__container__.lookup('event_dispatcher:main');
set(this, 'eventDispatcher', dispatcher);
dispatcher.setup(customEvents, rootElement);
}
|
javascript
|
{
"resource": ""
}
|
|
q63089
|
test
|
function(namespace) {
var container = new Ember.Container();
Ember.Container.defaultContainer = new DeprecatedContainer(container);
container.set = Ember.set;
container.resolver = resolverFor(namespace);
container.normalize = container.resolver.normalize;
container.describe = container.resolver.describe;
container.makeToString = container.resolver.makeToString;
container.optionsForType('component', { singleton: false });
container.optionsForType('view', { singleton: false });
container.optionsForType('template', { instantiate: false });
container.optionsForType('helper', { instantiate: false });
container.register('application:main', namespace, { instantiate: false });
container.register('controller:basic', Ember.Controller, { instantiate: false });
container.register('controller:object', Ember.ObjectController, { instantiate: false });
container.register('controller:array', Ember.ArrayController, { instantiate: false });
container.register('route:basic', Ember.Route, { instantiate: false });
container.register('event_dispatcher:main', Ember.EventDispatcher);
container.register('router:main', Ember.Router);
container.injection('router:main', 'namespace', 'application:main');
container.register('location:auto', Ember.AutoLocation);
container.register('location:hash', Ember.HashLocation);
container.register('location:history', Ember.HistoryLocation);
container.register('location:none', Ember.NoneLocation);
container.injection('controller', 'target', 'router:main');
container.injection('controller', 'namespace', 'application:main');
container.injection('route', 'router', 'router:main');
container.injection('location', 'rootURL', '-location-setting:root-url');
// DEBUGGING
container.register('resolver-for-debugging:main', container.resolver.__resolver__, { instantiate: false });
container.injection('container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main');
container.injection('data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main');
// Custom resolver authors may want to register their own ContainerDebugAdapter with this key
container.register('container-debug-adapter:main', Ember.ContainerDebugAdapter);
return container;
}
|
javascript
|
{
"resource": ""
}
|
|
q63090
|
test
|
function(type, recordsAdded, recordsUpdated, recordsRemoved) {
var self = this, releaseMethods = Ember.A(), records = this.getRecords(type), release;
var recordUpdated = function(updatedRecord) {
recordsUpdated([updatedRecord]);
};
var recordsToSend = records.map(function(record) {
releaseMethods.push(self.observeRecord(record, recordUpdated));
return self.wrapRecord(record);
});
var contentDidChange = function(array, idx, removedCount, addedCount) {
for (var i = idx; i < idx + addedCount; i++) {
var record = array.objectAt(i);
var wrapped = self.wrapRecord(record);
releaseMethods.push(self.observeRecord(record, recordUpdated));
recordsAdded([wrapped]);
}
if (removedCount) {
recordsRemoved(idx, removedCount);
}
};
var observer = { didChange: contentDidChange, willChange: Ember.K };
records.addArrayObserver(self, observer);
release = function() {
releaseMethods.forEach(function(fn) { fn(); });
records.removeArrayObserver(self, observer);
self.releaseMethods.removeObject(release);
};
recordsAdded(recordsToSend);
this.releaseMethods.pushObject(release);
return release;
}
|
javascript
|
{
"resource": ""
}
|
|
q63091
|
test
|
function(type, typesUpdated) {
var self = this, records = this.getRecords(type);
var onChange = function() {
typesUpdated([self.wrapModelType(type)]);
};
var observer = {
didChange: function() {
Ember.run.scheduleOnce('actions', this, onChange);
},
willChange: Ember.K
};
records.addArrayObserver(this, observer);
var release = function() {
records.removeArrayObserver(self, observer);
};
return release;
}
|
javascript
|
{
"resource": ""
}
|
|
q63092
|
test
|
function() {
var namespaces = Ember.A(Ember.Namespace.NAMESPACES), types = Ember.A();
namespaces.forEach(function(namespace) {
for (var key in namespace) {
if (!namespace.hasOwnProperty(key)) { continue; }
var name = Ember.String.dasherize(key);
if (!(namespace instanceof Ember.Application) && namespace.toString()) {
name = namespace + '/' + name;
}
types.push(name);
}
});
return types;
}
|
javascript
|
{
"resource": ""
}
|
|
q63093
|
test
|
function(context, callback) {
if (arguments.length === 1) {
callback = context;
context = null;
}
if (!this.waiters) {
this.waiters = Ember.A();
}
this.waiters.push([context, callback]);
}
|
javascript
|
{
"resource": ""
}
|
|
q63094
|
test
|
function(context, callback) {
var pair;
if (!this.waiters) { return; }
if (arguments.length === 1) {
callback = context;
context = null;
}
pair = [context, callback];
this.waiters = Ember.A(this.waiters.filter(function(elt) {
return Ember.compare(elt, pair)!==0;
}));
}
|
javascript
|
{
"resource": ""
}
|
|
q63095
|
test
|
function() {
for (var name in helpers) {
this.helperContainer[name] = this.originalMethods[name];
delete this.testHelpers[name];
delete this.originalMethods[name];
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63096
|
protoWrap
|
test
|
function protoWrap(proto, name, callback, isAsync) {
proto[name] = function() {
var args = arguments;
if (isAsync) {
return callback.apply(this, args);
} else {
return this.then(function() {
return callback.apply(this, args);
});
}
};
}
|
javascript
|
{
"resource": ""
}
|
q63097
|
toPropertyDescriptor
|
test
|
function toPropertyDescriptor(obj) {
if (Object(obj) !== obj) {
throw new TypeError("property descriptor should be an Object, given: "+
obj);
}
var desc = {};
if ('enumerable' in obj) { desc.enumerable = !!obj.enumerable; }
if ('configurable' in obj) { desc.configurable = !!obj.configurable; }
if ('value' in obj) { desc.value = obj.value; }
if ('writable' in obj) { desc.writable = !!obj.writable; }
if ('get' in obj) {
var getter = obj.get;
if (getter !== undefined && typeof getter !== "function") {
throw new TypeError("property descriptor 'get' attribute must be "+
"callable or undefined, given: "+getter);
}
desc.get = getter;
}
if ('set' in obj) {
var setter = obj.set;
if (setter !== undefined && typeof setter !== "function") {
throw new TypeError("property descriptor 'set' attribute must be "+
"callable or undefined, given: "+setter);
}
desc.set = setter;
}
if ('get' in desc || 'set' in desc) {
if ('value' in desc || 'writable' in desc) {
throw new TypeError("property descriptor cannot be both a data and an "+
"accessor descriptor: "+obj);
}
}
return desc;
}
|
javascript
|
{
"resource": ""
}
|
q63098
|
normalizePropertyDescriptor
|
test
|
function normalizePropertyDescriptor(attributes) {
var desc = toPropertyDescriptor(attributes);
// Note: no need to call FromGenericPropertyDescriptor(desc), as we represent
// "internal" property descriptors as proper Objects from the start
for (var name in attributes) {
if (!isStandardAttribute(name)) {
Object.defineProperty(desc, name,
{ value: attributes[name],
writable: true,
enumerable: true,
configurable: true });
}
}
return desc;
}
|
javascript
|
{
"resource": ""
}
|
q63099
|
isCompatibleDescriptor
|
test
|
function isCompatibleDescriptor(extensible, current, desc) {
if (current === undefined && extensible === false) {
return false;
}
if (current === undefined && extensible === true) {
return true;
}
if (isEmptyDescriptor(desc)) {
return true;
}
if (isEquivalentDescriptor(current, desc)) {
return true;
}
if (current.configurable === false) {
if (desc.configurable === true) {
return false;
}
if ('enumerable' in desc && desc.enumerable !== current.enumerable) {
return false;
}
}
if (isGenericDescriptor(desc)) {
return true;
}
if (isDataDescriptor(current) !== isDataDescriptor(desc)) {
if (current.configurable === false) {
return false;
}
return true;
}
if (isDataDescriptor(current) && isDataDescriptor(desc)) {
if (current.configurable === false) {
if (current.writable === false && desc.writable === true) {
return false;
}
if (current.writable === false) {
if ('value' in desc && !sameValue(desc.value, current.value)) {
return false;
}
}
}
return true;
}
if (isAccessorDescriptor(current) && isAccessorDescriptor(desc)) {
if (current.configurable === false) {
if ('set' in desc && !sameValue(desc.set, current.set)) {
return false;
}
if ('get' in desc && !sameValue(desc.get, current.get)) {
return false;
}
}
}
return true;
}
|
javascript
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.