test('find children of 11', function (assert) { let row11 = groupRow.findRow(0); row11.expandChildren(); assert.ok(groupRow.findRow(1) === undefined, 'no children row by default'); var row111 = groupRow.createRow(1); assert.equal(row111.get('id'), 111, 'should return created row 111'); assert.equal(Ember.guidFor(groupRow.findRow(1)), Ember.guidFor(row111), 'should find created row 111'); });
test('find children of 12 when 11 is collapsed', function (assert) { let row12 = groupRow.findRow(1); row12.expandChildren(); assert.ok(groupRow.findRow(2) === undefined, 'no children row by default'); var row121 = groupRow.createRow(2); assert.equal(row121.get('id'), 121, 'should return created row 121'); assert.equal(Ember.guidFor(groupRow.findRow(2)), Ember.guidFor(row121), 'should find created row 121'); });
function getStreamFromView(view, obj, key) { var objGuid = Em.guidFor(obj); var keyGuid = Em.guidFor(key); var accessKey = `get-helper:${objGuid}-${keyGuid}`; var stream = view._getBindingForStream(accessKey); if (!stream._isGetHelperStream) { setupStream(view, obj, key, stream); } return stream; }
test("Objects are dropped on destruction", function() { var didDestroy = false; var object = Ember.Object.create({ willDestroy: function() { didDestroy = true; } }); var objectId = Ember.guidFor(object); wait() .then(function() { objectInspector.sendObject(object); return wait(); }) .then(function() { ok(!!objectInspector.sentObjects[objectId]); object.destroy(); return wait(); }) .then(function() { ok(didDestroy, 'Original willDestroy is preserved.'); ok(!objectInspector.sentObjects[objectId], 'Object is dropped'); equal(name, 'objectInspector:droppedObject'); deepEqual(message, { objectId: objectId }); }); });
child = elt.find(selector).filter(function() { var guid = Ember.guidFor(this); if (!seen[guid]) { seen[guid] = true; return true; } });
Ember.A(headTagsArray).forEach(function(tagDefinition) { if(!VALID_HEAD_TAGS.includes(tagDefinition.type)) { return; } let tagId = tagDefinition.tagId; if (!tagId) { tagId = Ember.guidFor(tagDefinition); } tagMap[tagId] = tagDefinition; });
(annotation.get('elements') || []).forEach(element => { allElements.removeObject(element); const guid = Ember.guidFor(element); const annotations = this.get(`annotations.${guid}`); if (annotations) { annotations.removeObject(annotation); if (!annotations.length) { this.set(`annotations.${guid}`, undefined); } } });
elements.forEach(element => { allElements.addObject(element); const guid = Ember.guidFor(element); let annotations = this.get(`annotations.${guid}`); if (!annotations) { annotations = []; this.set(`annotations.${guid}`, annotations); this.notifyPropertyChange('annotations'); } annotations.addObject(annotation); });
service(serviceName, App) { let hyjax = this; App = App || Ember.Application; App.instanceInitializer({ name: 'hyjax: ' + serviceName + '-' + Ember.guidFor({}), initialize: function(app) { app.register(`service:${serviceName}`, hyjax, {instantiate:false}); Ember.setOwner(hyjax, app); } }); return hyjax; }
layerObserver: Ember.observer('layer.layer', function () { let layer = this.get('layer.layer'); let latitude = this.get('latitude'); let longitude = this.get('longitude'); let center = SMap.Coords.fromWGS84(longitude, latitude); let guid = Ember.guidFor(this); let markerId = `s-map-marker-${guid}`; let options = {}; let marker = new SMap.Marker(center, markerId, options); layer.addMarker(marker); this.set('marker', marker); }),
function recordFactory(attr, filterValues) { filterValues = filterValues || {isNew : false}; var searchKeywords = []; for(var i in attr) { searchKeywords.push(attr[i]); } var object = Ember.Object.create(); return { columnValues: attr, objectId: attr.objectId || Ember.guidFor(object), filterValues: filterValues, searchKeywords: searchKeywords }; }
ensureVisible: function(index) { var item = this.get('selectableOptions').objectAt(index); var newIndex = this.get('groupedContent').indexOf(item); /* Should correspond with https://github.com/html-next/vertical-collection/blob/c04c9d969b43bdf990af242262bbef60c9e2e875/addon/-private/ember-internals/identity.js */ var identity; var type = typeof item; if (type === 'string' || type === 'number') { identity = item; } else { identity = Ember.guidFor(item); } this.set('highlightedIdentity', identity); },
load: function() { if (!linkedinScriptPromise) { var shareHandlerName = 'linkedin_share_' + Ember.guidFor(this); var tracking = this.tracking; window[shareHandlerName] = function(sharedUrl) { if(!tracking) { return; } if(tracking.shared) { tracking.shared('linkedin', { url: sharedUrl }); } }; linkedinScriptPromise = new Ember.RSVP.Promise(function(resolve/*, reject*/) { Ember.$.getScript("//platform.linkedin.com/in.js?async=true", function success() { IN.shareHandlerName = shareHandlerName; IN.Event.on(IN, 'systemReady', Ember.run.bind(null, resolve, IN)); IN.init(); }); }); } return linkedinScriptPromise; },
length: 0, clear() { if (this.isFrozen) { throw new Ember.Error(Ember.FROZEN_ERROR); } var len = Ember.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 = Ember.guidFor(this[i]); delete this[guid]; delete this[i]; } Ember.set(this, 'length', 0); Ember.propertyDidChange(this, 'firstObject'); Ember.propertyDidChange(this, 'lastObject'); this.enumerableContentDidChange(len, 0); return this; }, isEqual(obj) { // fail fast
textAreaElementId: Ember.computed(function () { return Ember.guidFor(this); }),
generatedInputId: Ember.computed(function() { return `${Ember.guidFor(this)}__input`; }),
generatedLabelId: Ember.computed(function() { return `${Ember.guidFor(this)}__label`; }),
}, onLabelCreate: function(label){ that.$('input.search').val(''); that.$('.addition.item b').html(''); return $(label); } }); }, didInsertElement() { this.renderDropDown(); }, _addValue(value){ try{ this.get('value').addObject(value); }catch(e){ let id = Ember.guidFor(this); Ember.Logger.warn(`component:ui-input-tags ${id} value is not Ember.A type`); Ember.Logger.error(e); } if(typeof this.attrs.update === 'function'){ this.attrs.update(this.get('value')); } }, _removeValue(value){ this.get('value').removeObject(value); if(typeof this.attrs.update === 'function'){ this.attrs.update(this.get('value')); } }, init(){ this._super(...arguments);
willDestroy: function() { $(window).off('resize.' + Ember.guidFor(this), this.get("resizeHandler")); return this._super(); }
generatedModalId: Ember.computed(function() { return `${Ember.guidFor(this)}--modal`; }),
addKey(context, key, rule) { if (!context[key]) { context[key] = {}; } context[key][Ember.guidFor(rule)] = rule; }
maxHeight: 128, minHeight: 48, transitionDistance: 16, height: 0, isSticked: false, actions: { goBack() { this.get("on").send("goBack"); } }, didInsertElement() { this._super(...arguments); let namespace = Ember.guidFor(this); $(window).on(`scroll.${namespace}`, $.proxy(this.handleScroll, this)); }, willDestroy() { $(window).off("." + Ember.guidFor(this)); this._super(...arguments); }, handleScroll() { Ember.run.scheduleOnce("render", this, this.redraw); }, redraw() { let progress = Math.min(1, $(window).scrollTop() / this.get("transitionDistance")); let min = this.get("minHeight");
layout: layout, classNames: ["infinity-loader"], classNameBindings: ["infinityModel.reachedInfinity"], guid: null, eventDebounce: 10, loadMoreAction: 'infinityLoad', loadingText: 'Loading Infinite Model...', loadedText: 'Infinite Model Entirely Loaded.', destroyOnInfinity: false, developmentMode: false, scrollable: null, didInsertElement() { this._super(...arguments); this._setupScrollable(); this.set('guid', Ember.guidFor(this)); this._bindEvent('scroll'); this._bindEvent('resize'); this._checkIfInView(); }, willDestroyElement() { this._super(...arguments); this._unbindEvent('scroll'); this._unbindEvent('resize'); }, _bindEvent(eventName) { this.get('scrollable').on(`${eventName}.${this.get('guid')}`, () => { Ember.run.debounce(this, this._checkIfInView, this.get('eventDebounce')); });
* @instance */ cancelAll() { this.spliceTaskInstances(this._activeTaskInstances, 0, this._activeTaskInstances.length); this.spliceTaskInstances(this._queuedTaskInstances, 0, this._queuedTaskInstances.length); }, spliceTaskInstances(taskInstances, index, count) { for (let i = index; i < index + count; ++i) { taskInstances[i].cancel(); } taskInstances.splice(index, count); }, toString() { return `<Task:${Ember.guidFor(this)}> of ${this._origin}`; }, _perform(...args) { let taskInstance = TaskInstance.create({ fn: this.fn, args, context: this.context, task: this, _origin: this, }); if (this.get('_performs') && !this.get('performWillSucceed')) { // tasks linked via .performs() should be immediately dropped // before they even have a chance to run if we know that // .performWillSucceed is false.
store.findRecord('person', 1).then(function(record) { assert.equal(record.toString(), '<(subclass of DS.Model):'+Ember.guidFor(record)+':1>', "reports id in toString"); });
import Ember from 'ember'; import RESTSerializer from 'ember-data/serializers/rest'; export default RESTSerializer.extend({ keyForAttribute: function(attr) { return Ember.String.camelize(attr); }, extractId(modelClass, resourceHash) { if (Ember.isEmpty(resourceHash.id)) { return Ember.guidFor(resourceHash); } return this._super(modelClass, resourceHash); } });
didInsertElement: function() { this._super(); return $(window).on('resize.' + Ember.guidFor(this), this.get("resizeHandler")); },
const setup = element => { const annotation = element.annotation; const children = element.children; const guid = Ember.guidFor(annotation); const setElements = elements => { (annotation.get('elements') || []).forEach(element => { allElements.removeObject(element); const guid = Ember.guidFor(element); const annotations = this.get(`annotations.${guid}`); if (annotations) { annotations.removeObject(annotation); if (!annotations.length) { this.set(`annotations.${guid}`, undefined); } } }); elements.forEach(element => { allElements.addObject(element); const guid = Ember.guidFor(element); let annotations = this.get(`annotations.${guid}`); if (!annotations) { annotations = []; this.set(`annotations.${guid}`, annotations); this.notifyPropertyChange('annotations'); } annotations.addObject(annotation); }); if (!annotation.get('isDeleted')) { annotation.set('elements', elements); } this.set(`elements.${guid}`, elements); this.notifyPropertyChange('elements'); }; if (children) { children.forEach(setup); let selector = null; const observer = () => { if (selector) { selectorMatcher.unRegister(selector, setElements); } selector = annotation.get('repeatedSelector') || annotation.get('selector'); if (selector) { selectorMatcher.register(selector, setElements); setElements(selectorMatcher.query(selector)); } }; let scheduledObserver = null; bindings.push({ annotation, setup() {}, teardown() { Ember.run.cancel(scheduledObserver); if (selector) { selectorMatcher.unRegister(selector, setElements); } annotation.setProperties({ elements: undefined }); }, observer() { // allow the bindings to sync first scheduledObserver = Ember.run.scheduleOnce('sync', observer); }, observerPaths: ['selector', 'repeatedSelector'] }); } else { let selector = null; const observer = () => { if (selector) { selectorMatcher.unRegister(selector, setElements); } selector = annotation.get('selector'); if (selector) { selectorMatcher.register(selector, setElements); setElements(selectorMatcher.query(selector)); } }; let scheduledObserver = null; bindings.push({ annotation, setup() {}, teardown() { Ember.run.cancel(scheduledObserver); if (selector) { selectorMatcher.unRegister(selector, setElements); } annotation.setProperties({ elements: undefined }); }, observer() { // allow the bindings to sync first scheduledObserver = Ember.run.scheduleOnce('sync', observer); }, observerPaths: ['selector'] }); } };
import Ember from 'ember'; import JSONSerializer from 'ember-data/serializers/json'; export default JSONSerializer.extend({ extractId(modelClass, resourceHash) { var id = Ember.guidFor(resourceHash); return id; }, });
Ember.A(Ember.keys(set)).forEach((ruleKey) => { var rule = set[ruleKey]; if (rule.debug && !matched[Ember.guidFor(rule)]) { console.log(`${describeRule(rule)} rejected because ${target} was`, ...value); } });