Ghost/ghost/admin/app/components/gh-file-input.js
Kevin Ansfield b2b66490b7 Added settings for newsletter header, title style, and feature image (#1993)
refs https://github.com/TryGhost/Team/issues/755
reqs https://github.com/TryGhost/Ghost/pull/13006

- updated settings model to match new server-side settings
- updated email customisation modal behind the dev experiments flag
  - adjusted layout to move to a fixed top bar and scrollable sidebar
  - added image upload, toggles and selections for new settings
  - updated preview to match selected settings

Co-authored-by: Sanne de Vries <sannedv@protonmail.com>
2021-06-07 16:36:21 +01:00

47 lines
1.2 KiB
JavaScript

import XFileInput from 'emberx-file-input/components/x-file-input';
// TODO: remove this override and use {{x-file-input}} directly once we've
// upgraded to emberx-file-input@1.2.0
export default XFileInput.extend({
didInsertElement() {
this.onInsert?.(this.element.querySelector('input[type="file"]'));
},
change(e) {
let action = this.action;
let files = this.files(e);
if (files.length && action) {
action(files, this.resetInput.bind(this));
}
},
/**
* Gets files from event object.
*
* @method
* @private
* @param {$.Event || Event}
*/
files(e) {
return (e.originalEvent || e).testingFiles || e.target.files;
},
/**
* Resets the value of the input so you can select the same file
* multiple times.
*
* NOTE: fixes reset in Firefox which doesn't reset like other browsers
* when doing input.value = null;
*
* @method
*/
resetInput() {
let input = this.element.querySelector('.x-file--input');
input.removeAttribute('value');
input.value = null;
input.parentNode.replaceChild(input.cloneNode(true), input);
}
});