diff --git a/assets/javascripts/wizard/components/wizard-composer-editor.js.es6 b/assets/javascripts/wizard/components/wizard-composer-editor.js.es6
index 26207c89..2b745c6f 100644
--- a/assets/javascripts/wizard/components/wizard-composer-editor.js.es6
+++ b/assets/javascripts/wizard/components/wizard-composer-editor.js.es6
@@ -54,6 +54,7 @@ export default ComposerEditor.extend({
showUploadModal() {
$(".wizard-composer-upload").trigger("click");
},
+
_setUploadPlaceholderSend() {
if (!this.composer.get("reply")) {
this.composer.set("reply", "");
@@ -64,7 +65,9 @@ export default ComposerEditor.extend({
_bindUploadTarget() {
this._super(...arguments);
const $element = $(this.element);
+
$element.off("fileuploadsubmit");
+
$element.on("fileuploadsubmit", (e, data) => {
const max = this.siteSettings.simultaneous_uploads;
@@ -116,7 +119,33 @@ export default ComposerEditor.extend({
return isUploading;
});
+
+ $element.on("fileuploadprogressall", (e, data) => {
+ this.set(
+ "uploadProgress",
+ parseInt((data.loaded / data.total) * 100, 10)
+ );
+ });
+
+ $element.on("fileuploadfail", (e, data) => {
+ this._setUploadPlaceholderDone(data);
+ this._resetUpload(true);
+
+ const userCancelled = this._xhr && this._xhr._userCancelled;
+ this._xhr = null;
+
+ if (!userCancelled) {
+ displayErrorForUpload(data, this.siteSettings);
+ }
+ });
},
+
+ click(e) {
+ if ($(e.target).hasClass('wizard-composer-hyperlink')) {
+ this.set('showHyperlinkBox', false);
+ }
+ },
+
actions: {
extraButtons(toolbar) {
if (this.allowUpload && this.uploadIcon && !this.site.mobileView) {
@@ -135,18 +164,22 @@ export default ComposerEditor.extend({
group: "insertions",
shortcut: "K",
trimLeading: true,
+ unshift: true,
sendAction: (event) => component.set("showHyperlinkBox", true),
});
},
+
previewUpdated($preview) {
highlightSyntax($preview[0], this.siteSettings, this.session);
this._super(...arguments);
},
+
addLink(linkName, linkUrl) {
let link = `[${linkName}](${linkUrl})`;
this.appEvents.trigger("composer:insert-text", link);
this.set("showHyperlinkBox", false);
},
+
hideBox() {
this.set("showHyperlinkBox", false);
},
diff --git a/assets/javascripts/wizard/components/wizard-composer-hyperlink.js.es6 b/assets/javascripts/wizard/components/wizard-composer-hyperlink.js.es6
index 6e9a36a4..5cc0357d 100644
--- a/assets/javascripts/wizard/components/wizard-composer-hyperlink.js.es6
+++ b/assets/javascripts/wizard/components/wizard-composer-hyperlink.js.es6
@@ -1,12 +1,15 @@
import Component from "@ember/component";
export default Component.extend({
+ classNames: ['wizard-composer-hyperlink'],
+
actions: {
addLink() {
this.addLink(this.linkName, this.linkUrl);
},
+
hideBox() {
this.hideBox();
- },
+ }
},
});
diff --git a/assets/javascripts/wizard/templates/components/wizard-composer-editor.hbs b/assets/javascripts/wizard/templates/components/wizard-composer-editor.hbs
index c3bfdb6e..3194186e 100644
--- a/assets/javascripts/wizard/templates/components/wizard-composer-editor.hbs
+++ b/assets/javascripts/wizard/templates/components/wizard-composer-editor.hbs
@@ -15,10 +15,21 @@
disabled=disableTextarea
outletArgs=(hash composer=composer editorType="composer")}}
- {{input class="wizard-composer-upload hidden-upload-field" disabled=uploading type="file" multiple=true }}
+{{input
+ class="wizard-composer-upload hidden-upload-field"
+ disabled=uploading
+ type="file"
+ multiple=true}}
- {{#if showHyperlinkBox}}
- {{wizard-composer-hyperlink
- addLink=(action 'addLink')
- hideBox=(action 'hideBox')}}
- {{/if}}
+{{#if showHyperlinkBox}}
+ {{wizard-composer-hyperlink
+ addLink=(action 'addLink')
+ hideBox=(action 'hideBox')}}
+{{/if}}
+
+
+ {{loading-spinner size="small"}}
{{i18n "upload_selector.uploading"}} {{uploadProgress}}%
+ {{#if isCancellable}}
+
{{d-icon "times"}}
+ {{/if}}
+
diff --git a/assets/javascripts/wizard/templates/components/wizard-composer-hyperlink.hbs b/assets/javascripts/wizard/templates/components/wizard-composer-hyperlink.hbs
index df794619..fa69a7cd 100644
--- a/assets/javascripts/wizard/templates/components/wizard-composer-hyperlink.hbs
+++ b/assets/javascripts/wizard/templates/components/wizard-composer-hyperlink.hbs
@@ -1,9 +1,21 @@
-{{i18n "wizard_composer.insert_hyperlink.heading"}}
-{{input class="composer-link-name" placeholder=(i18n 'wizard_composer.insert_hyperlink.placeholder.link_name') type="text" value=linkName}}
-{{input class="composer-link-url" placeholder=(i18n 'wizard_composer.insert_hyperlink.placeholder.link_url') type="text" value=linkUrl}}
-{{d-button label="wizard_composer.insert_hyperlink.ok"
- class="add-link"
- click=(action 'addLink')}}
-{{d-button label="wizard_composer.insert_hyperlink.cancel"
- class="hide-hyperlink-box"
- click=(action 'hideBox')}}
+
+
{{i18n "wizard_composer.insert_hyperlink.heading"}}
+ {{input
+ class="composer-link-name"
+ placeholder=(i18n 'wizard_composer.insert_hyperlink.placeholder.link_name')
+ type="text"
+ value=linkName}}
+ {{input
+ class="composer-link-url"
+ placeholder=(i18n 'wizard_composer.insert_hyperlink.placeholder.link_url')
+ type="text"
+ value=linkUrl}}
+ {{d-button
+ label="wizard_composer.insert_hyperlink.ok"
+ class="add-link btn-primary"
+ click=(action 'addLink')}}
+ {{d-button
+ label="wizard_composer.insert_hyperlink.cancel"
+ class="hide-hyperlink-box btn-danger"
+ click=(action 'hideBox')}}
+
diff --git a/assets/javascripts/wizard/templates/components/wizard-field-composer.hbs b/assets/javascripts/wizard/templates/components/wizard-field-composer.hbs
index e5ffd904..b35e432b 100644
--- a/assets/javascripts/wizard/templates/components/wizard-field-composer.hbs
+++ b/assets/javascripts/wizard/templates/components/wizard-field-composer.hbs
@@ -1,10 +1,11 @@
-{{wizard-composer-editor replyPlaceholder=field.placeholder
- composer=composer
- groupsMentioned=(action "groupsMentioned")
- cannotSeeMention=(action "cannotSeeMention")
- importQuote=(action "importQuote")
- togglePreview=(action "togglePreview")
- afterRefresh=(action "afterRefresh")}}
+{{wizard-composer-editor
+ replyPlaceholder=field.placeholder
+ composer=composer
+ groupsMentioned=(action "groupsMentioned")
+ cannotSeeMention=(action "cannotSeeMention")
+ importQuote=(action "importQuote")
+ togglePreview=(action "togglePreview")
+ afterRefresh=(action "afterRefresh")}}