Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrating cropper-modal to ES6 #3682

Merged
merged 9 commits into from
Dec 25, 2019
39 changes: 20 additions & 19 deletions app/components/modals/cropper-modal.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ModalBase from 'open-event-frontend/components/modals/modal-base';

export default ModalBase.extend({
import { action } from '@ember/object';
export default class extends ModalBase {
onVisible() {
let viewport = {};
let factor = 150;
let factor = 750;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert

const aspectRatio = this.getWithDefault('aspectRatio', [2, 1]);
viewport.width = aspectRatio[0] * factor;
viewport.height = aspectRatio[1] * factor;
Expand All @@ -16,27 +16,28 @@ export default ModalBase.extend({
height: 250
}
});
},
}

onHide() {
this.$('img').croppie('destroy');
const $img = this.$('img');
if ($img.parent().is('div.croppie')) {
$img.unwrap();
}
},

actions: {
resetImage() {
this.onHide();
this.onVisible();
},
cropImage() {
this.$('img').croppie('result', 'base64', 'original', 'jpeg').then(result => {
if (this.onImageCrop) {
this.onImageCrop(result);
}
});
}
}
});

@action
resetImage() {
this.onHide();
this.onVisible();
}
@action
cropImage() {
this.$('img').croppie('result', 'base64', 'original', 'jpeg', 1).then(result => {
if (this.onImageCrop) {
kushthedude marked this conversation as resolved.
Show resolved Hide resolved
this.onImageCrop(result);
}
});
}
}