byPathDidChange: observer('byPath', 'value', function () { var byPath = get(this, 'byPath'); var value = get(this, 'value'); if (isEmpty(byPath)) { defineProperty(this, 'content', []); return; } var filterFn = undefined; if (isPresent(value)) { if (typeof value === 'function') { filterFn = function (item) { return !value(get(item, byPath)); }; } else { filterFn = function (item) { return get(item, byPath) !== value; }; } } else { filterFn = function (item) { return isEmpty(get(item, byPath)); }; } var cp = filter('array.@each.' + byPath, filterFn); defineProperty(this, 'content', cp); }),
byPathDidChange: observer('byPath', 'value', function() { let byPath = get(this, 'byPath'); let value = get(this, 'value'); if (isEmpty(byPath)) { defineProperty(this, 'content', []); return; } let filterFn; if (isPresent(value)) { if (typeof value === 'function') { filterFn = (item) => value(get(item, byPath)); } else { filterFn = (item) => isEqual(get(item, byPath), value); } } else { filterFn = (item) => !!get(item, byPath); } let cp = filter(`array.@each.${byPath}`, filterFn); defineProperty(this, 'content', cp); }),
run(() => { let expiresAt = this._absolutizeExpirationTime(response.expires_in); this._scheduleAccessTokenRefresh(response.expires_in, expiresAt, response.refresh_token); if (!isEmpty(expiresAt)) { response = assign(response, {'expires_at': expiresAt}); } resolve(response); });
byPathDidChange: observer('byPath', function () { var byPath = get(this, 'byPath'); if (isEmpty(byPath)) { defineProperty(this, 'content', []); return; } defineProperty(this, 'content', mapBy('array', byPath)); }),
byPathDidChange: observer('callback', function() { let callback = get(this, 'callback'); if (isEmpty(callback)) { defineProperty(this, 'content', []); return; } defineProperty(this, 'content', map('array', callback)); }),
callbackDidChange: observer('callback', function() { let callback = get(this, 'callback'); if (isEmpty(callback)) { defineProperty(this, 'content', []); return; } let cp = filter('array', callback); defineProperty(this, 'content', cp); }),
export function inc([step, val]) { if (isEmpty(val)) { val = step; step = undefined; } if (step === undefined) { step = 1; } return val + step; }
groupedContent: computed('posts', 'pages', 'users', 'tags', function () { let groups = []; if (!isEmpty(this.get('posts'))) { groups.pushObject({groupName: 'Posts', options: this.get('posts')}); } if (!isEmpty(this.get('pages'))) { groups.pushObject({groupName: 'Pages', options: this.get('pages')}); } if (!isEmpty(this.get('users'))) { groups.pushObject({groupName: 'Users', options: this.get('users')}); } if (!isEmpty(this.get('tags'))) { groups.pushObject({groupName: 'Tags', options: this.get('tags')}); } return groups; }),
valuesDidChange: observer('arrays.[]', function() { this._recomputeArrayKeys(); let arrays = get(this, 'arrays'); let arrayKeys = get(this, 'arrayKeys'); if (isEmpty(arrays)) { defineProperty(this, 'content', []); return; } defineProperty(this, 'content', multiArrayComputed(...arrayKeys)); }),
byPathDidChange: observer('byPath', function() { let byPath = get(this, 'byPath'); if (isEmpty(byPath)) { defineProperty(this, 'content', []); return; } defineProperty(this, 'content', computed(`array.@each.${byPath}`, function() { let array = get(this, 'array'); let value = get(this, 'value'); return array.findBy(byPath, value); })); }),
byPathDidChange: observer('byPath', function () { var byPath = get(this, 'byPath'); if (isEmpty(byPath)) { defineProperty(this, 'content', []); return; } defineProperty(this, 'content', computed('array.@each.' + byPath, 'value', function () { var array = get(this, 'array'); var value = get(this, 'value'); return emberArray(array).findBy(byPath, value); })); }),
callbackDidChange: observer('callback', 'initialValue', function() { let callback = get(this, 'callback'); let initialValue = get(this, 'initialValue'); if (isEmpty(callback)) { defineProperty(this, 'content', []); return; } let cp = computed('array.[]', () => { let array = get(this, 'array'); return array.reduce(callback, initialValue); }); defineProperty(this, 'content', cp); }),
export function inc([step, val]) { if (isEmpty(val)) { val = step; step = undefined; } val = parseInt(val); if (isNaN(val)) { return; } if (step === undefined) { step = 1; } return val + step; }
export function dec([step, val]) { if (isEmpty(val)) { val = step; step = undefined; } val = Number(val); if (isNaN(val)) { return; } if (step === undefined) { step = 1; } return val - step; }
test('unsubscribe', function (assert) { let service = this.subject({ init: this.stub(), subscribers: A() }); let scrollTop = 1234; let elem = { scrollTop() { return scrollTop; } }; let target = { elem }; service.subscribe(target, elem); target.foo = 'foo'; // simulate a change to the target object over time service.unsubscribe(target); assert.ok(isEmpty(service.get('subscribers')), 'subscriber removed'); });
return new RSVP.Promise((resolve, reject) => { // const data = { 'grant_type': 'password', username: identification, password }; let data = identification; let serverTokenEndpoint = this.get('serverTokenEndpoint'); let scopesString = wrap(scope).join(' '); if (!isEmpty(scopesString)) { data.scope = scopesString; } this.makeRequest(serverTokenEndpoint, data).then((response) => { run(() => { let expiresAt = this._absolutizeExpirationTime(response.expires_in); this._scheduleAccessTokenRefresh(response.expires_in, expiresAt, response.refresh_token); if (!isEmpty(expiresAt)) { response = assign(response, {'expires_at': expiresAt}); } resolve(response); }); }, (xhr) => { run(null, reject, xhr.responseJSON || xhr.responseText); }); });
hasError: computed('errors.[]', 'property', 'hasValidated.[]', function () { let property = this.get('property'); let errors = this.get('errors'); let hasValidated = this.get('hasValidated'); // if we aren't looking at a specific property we always want an error class if (!property && !isEmpty(errors)) { return true; } // If we haven't yet validated this field, there is no validation class needed if (!hasValidated || !hasValidated.contains(property)) { return false; } if (errors) { return errors.get(property); } return false; })
arraysDidChange: observer('arrays.[]', function() { let arrays = get(this, 'arrays'); let oldArrayKeys = get(this, 'arrayKeys') || []; let newArrayKeys = arrays.map(idForArray); let keysToRemove = oldArrayKeys.filter((key) => { return newArrayKeys.indexOf(key) === -1; }); keysToRemove.forEach((key) => set(this, key, null)); arrays.forEach((array) => set(this, idForArray(array), emberArray(array))); set(this, 'arrayKeys', newArrayKeys); if (isEmpty(arrays)) { defineProperty(this, 'content', []); return; } defineProperty(this, 'content', union(...newArrayKeys)); }),
function dec(_ref) { var _ref2 = _slicedToArray(_ref, 2); var step = _ref2[0]; var val = _ref2[1]; if (isEmpty(val)) { val = step; step = undefined; } val = parseInt(val); if (isNaN(val)) { return; } if (step === undefined) { step = 1; } return val - step; }
init() { this._super(...arguments); let shortcuts = this.get('shortcuts'); shortcuts[`${ctrlOrCmd}+shift+i`] = {action: 'openImageFileDialog'}; shortcuts['ctrl+alt+h'] = {action: 'toggleHemmingway'}; }, // extract markdown content from single markdown card didReceiveAttrs() { this._super(...arguments); let mobiledoc = this.get('mobiledoc') || copy(BLANK_DOC, true); let uploadedImageUrls = this.get('uploadedImageUrls'); if (!isEmpty(uploadedImageUrls) && uploadedImageUrls !== this._uploadedImageUrls) { this._uploadedImageUrls = uploadedImageUrls; // must be done afterRender to avoid double modify of mobiledoc in // a single render run.scheduleOnce('afterRender', this, () => { this._insertImages(uploadedImageUrls); // reset the file input so the same file can be selected again this.$('input[type=file]').val(''); }); } // eslint-disable-next-line ember-suave/prefer-destructuring let markdown = mobiledoc.cards[0][1].markdown; this.set('markdown', markdown);
filterFn = function (item) { return isEmpty(get(item, byPath)); };
// - file uploads should always result in valid urls so it should only // affect the url input form keyDown() { this._setErrorState(false); }, _setErrorState(state) { if (state) { this.$('.url').addClass('error'); } else { this.$('.url').removeClass('error'); } }, _validateUrl(url) { if (!isEmpty(url) && !cajaSanitizers.url(url)) { this._setErrorState(true); return {message: 'Image URI is not valid'}; } return true; }, // end validation uploadImage: task(function* () { let model = this.get('model.model'); let newUrl = this.get('newUrl'); let result = this._validateUrl(newUrl); let notifications = this.get('notifications'); if (result === true) {
publishedAtBlogDate(model) { let publishedAtBlogDate = model.get('publishedAtBlogDate'); let publishedAtBlogTime = model.get('publishedAtBlogTime'); if (!this._shouldValidatePublishedAtBlog(model)) { return; } // we have a time string but no date string if (validator.empty(publishedAtBlogDate) && !validator.empty(publishedAtBlogTime)) { model.get('errors').add('publishedAtBlogDate', 'Can\'t be blank'); return this.invalidate(); } // don't validate the date if the time format is incorrect if (isEmpty(model.get('errors').errorsFor('publishedAtBlogTime'))) { let status = model.get('statusScratch') || model.get('status'); let now = moment(); let publishedAtUTC = model.get('publishedAtUTC'); let publishedAtBlogTZ = model.get('publishedAtBlogTZ'); let matchesExisting = publishedAtUTC && publishedAtBlogTZ.isSame(publishedAtUTC); let isInFuture = publishedAtBlogTZ.isSameOrAfter(now.add(2, 'minutes')); // draft/published must be in past if ((status === 'draft' || status === 'published') && publishedAtBlogTZ.isSameOrAfter(now)) { model.get('errors').add('publishedAtBlogDate', 'Must be in the past'); this.invalidate(); // scheduled must be at least 2 mins in the future // ignore if it matches publishedAtUTC as that is likely an update of a scheduled post } else if (status === 'scheduled' && !matchesExisting && !isInFuture) {
return theme.activate().then((theme) => { if (!isEmpty(theme.get('warnings'))) { this.set('themeWarnings', theme.get('warnings')); this.set('showThemeWarningsModal', true); } }).catch((error) => {