Skip to content

Commit

Permalink
Update to ember-cli 2.16 and modules api
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbilling committed Oct 12, 2017
1 parent b370149 commit a27f2a0
Show file tree
Hide file tree
Showing 13 changed files with 9,467 additions and 11,728 deletions.
20 changes: 12 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ cache:
- $HOME/.npm

env:
# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-lts-2.8
- EMBER_TRY_SCENARIO=ember-lts-2.12
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default
global:
# See https://git.io/vdao3 for details.
- JOBS=1
matrix:
# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-lts-2.8
- EMBER_TRY_SCENARIO=ember-lts-2.12
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default

matrix:
fast_finish: true
Expand Down
25 changes: 14 additions & 11 deletions addon/components/cloudinary-image.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
import Ember from 'ember';
import Component from '@ember/component';
import { computed } from '@ember/object';
import { getOwner } from "@ember/application";
import { htmlSafe } from "@ember/string";
import formatter from '../utils/variable-formatter';

const CloudinaryImageComponent = Ember.Component.extend({
const CloudinaryImageComponent = Component.extend({
tagName: 'img',
attributeBindings: ['src', 'width', 'height'],

width: Ember.computed('options.width', 'options.crop', function(){
width: computed('options.width', 'options.crop', function(){
if(this.get('options.crop') === 'limit' || this.get('options.crop') === 'fit' || this.get('options.crop') === 'lfill'){
return null;
}
return this.get('options.width');
}),
height: Ember.computed('options.height', 'options.crop', function(){
height: computed('options.height', 'options.crop', function(){
if(this.get('options.crop') === 'limit' || this.get('options.crop') === 'fit' || this.get('options.crop') === 'lfill'){
return null;
}
return this.get('options.height');
}),
crop: Ember.computed.oneWay('options.crop'),
fetch_format: Ember.computed.oneWay('options.fetch_format'),
quality: Ember.computed.oneWay('options.quality'),
default_image: Ember.computed.oneWay('options.default_image'),
crop: computed.oneWay('options.crop'),
fetch_format: computed.oneWay('options.fetch_format'),
quality: computed.oneWay('options.quality'),
default_image: computed.oneWay('options.default_image'),

src: Ember.computed('publicId', 'width', 'height', 'crop', 'fetch_format', 'quality', 'default_image', function() {
const cloudName = Ember.getOwner(this).resolveRegistration('config:environment').cloudinary.cloudName;
src: computed('publicId', 'width', 'height', 'crop', 'fetch_format', 'quality', 'default_image', function() {
const cloudName = getOwner(this).resolveRegistration('config:environment').cloudinary.cloudName;
const params = formatter(this.get('options'));
const publicId = this.get('publicId');

const image = `https://res.cloudinary.com/${cloudName}/image/upload${params}/${publicId}`;
return Ember.String.htmlSafe(image);
return htmlSafe(image);
})
});

Expand Down
7 changes: 4 additions & 3 deletions addon/components/cloudinary-resource-list.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Ember from 'ember';
import Component from '@ember/component';
import { getOwner } from "@ember/application";
import layout from '../templates/components/cloudinary-resource-list';
import request from 'ember-ajax/request';

const CloudinaryResourceList = Ember.Component.extend({
const CloudinaryResourceList = Component.extend({
layout,

init() {
Expand All @@ -16,7 +17,7 @@ const CloudinaryResourceList = Ember.Component.extend({
},

buildUrl() {
const cloudName = Ember.getOwner(this).resolveRegistration(
const cloudName = getOwner(this).resolveRegistration(
'config:environment'
).cloudinary.cloudName;
const tag = this.get('cloudinaryTag');
Expand Down
37 changes: 21 additions & 16 deletions addon/components/cloudinary-video.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import Ember from 'ember';
import Component from '@ember/component';
import { computed } from '@ember/object';
import { scheduleOnce } from "@ember/runloop";
import { getOwner } from "@ember/application";
import { htmlSafe } from "@ember/string";
import $ from 'jquery';
import formatter from '../utils/variable-formatter';

const CloudinaryVideoComponent = Ember.Component.extend({
const CloudinaryVideoComponent = Component.extend({
tagName: 'source',
attributeBindings: ['src', 'width', 'height'],

Expand All @@ -10,29 +15,29 @@ const CloudinaryVideoComponent = Ember.Component.extend({
const _this = this;

this._resizeHandler = function() {
Ember.run.scheduleOnce('afterRender', this, ()=> {
if(Ember.$('.grid__item').width()){
_this.set('width', Ember.$('.grid__item').width());
scheduleOnce('afterRender', this, ()=> {
if($('.grid__item').width()){
_this.set('width', $('.grid__item').width());
}
});
}.bind(this);
Ember.$(window).on('resize', this._resizeHandler);
$(window).on('resize', this._resizeHandler);
this._resizeHandler();
},

willDestroyElement () {
Ember.$(window).off('resize', this._resizeHandler);
$(window).off('resize', this._resizeHandler);
},

width: Ember.computed.oneWay('options.width'),
height: Ember.computed.oneWay('options.height'),
crop: Ember.computed.oneWay('options.crop'),
fetch_format: Ember.computed.oneWay('options.fetch_format'),
quality: Ember.computed.oneWay('options.quality'),
radius: Ember.computed.oneWay('options.radius'),
width: computed.oneWay('options.width'),
height: computed.oneWay('options.height'),
crop: computed.oneWay('options.crop'),
fetch_format: computed.oneWay('options.fetch_format'),
quality: computed.oneWay('options.quality'),
radius: computed.oneWay('options.radius'),

src: Ember.computed('publicId', 'width', 'height', 'crop', 'fetch_format', 'quality', 'radius', function() {
const cloudName = Ember.getOwner(this).resolveRegistration('config:environment').cloudinary.cloudName;
src: computed('publicId', 'width', 'height', 'crop', 'fetch_format', 'quality', 'radius', function() {
const cloudName = getOwner(this).resolveRegistration('config:environment').cloudinary.cloudName;
let options = this.get('options');

//if matchWidth set to true then set to actual width
Expand All @@ -47,7 +52,7 @@ const CloudinaryVideoComponent = Ember.Component.extend({
const publicId = this.get('publicId');

const cloudinaryVideoTag = `https://res.cloudinary.com/${cloudName}/video/upload${params}/${publicId}`;
return Ember.String.htmlSafe(cloudinaryVideoTag);
return htmlSafe(cloudinaryVideoTag);
}),
});

Expand Down
11 changes: 6 additions & 5 deletions addon/helpers/safe-cloudinary-url.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import Ember from 'ember';
import Ember from 'ember'; //So far Ember.Handlebars.Utils.escapeExpression is not a Module
import Helper from '@ember/component/helper';
import { getOwner } from "@ember/application"
import { htmlSafe } from "@ember/string"
import formatter from '../utils/variable-formatter';

const { getOwner } = Ember;

export default Ember.Helper.extend({
export default Helper.extend({
compute(params, hash) {
const cloudName = getOwner(this).resolveRegistration('config:environment').cloudinary.cloudName;
const publicId = Ember.Handlebars.Utils.escapeExpression(params[0]);
const parameters = formatter(hash);

if (publicId) {
return Ember.String.htmlSafe(`background-image: url('https://res.cloudinary.com/${cloudName}/image/upload${parameters}/${publicId}')`);
return htmlSafe(`background-image: url('https://res.cloudinary.com/${cloudName}/image/upload${parameters}/${publicId}')`);
}
}
});
Loading

0 comments on commit a27f2a0

Please sign in to comment.