mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
FEATURE: upload placeholder
This commit is contained in:
parent
b34b3293a3
commit
38cb72b329
3 changed files with 17 additions and 2 deletions
|
@ -215,6 +215,10 @@ Discourse.Utilities = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getUploadPlaceholder: function(filename) {
|
||||||
|
return "[" + I18n.t("uploading_filename", { filename: filename }) + "]() ";
|
||||||
|
},
|
||||||
|
|
||||||
isAnImage: function(path) {
|
isAnImage: function(path) {
|
||||||
return (/\.(png|jpe?g|gif|bmp|tiff?|svg|webp)$/i).test(path);
|
return (/\.(png|jpe?g|gif|bmp|tiff?|svg|webp)$/i).test(path);
|
||||||
},
|
},
|
||||||
|
|
|
@ -322,8 +322,9 @@ const ComposerView = Ember.View.extend(Ember.Evented, {
|
||||||
this.messageBus.subscribe("/uploads/composer", upload => {
|
this.messageBus.subscribe("/uploads/composer", upload => {
|
||||||
if (!cancelledByTheUser) {
|
if (!cancelledByTheUser) {
|
||||||
if (upload && upload.url) {
|
if (upload && upload.url) {
|
||||||
const markdown = Discourse.Utilities.getUploadMarkdown(upload);
|
const old = Discourse.Utilities.getUploadPlaceholder(upload.original_filename),
|
||||||
this.addMarkdown(markdown + " ");
|
markdown = Discourse.Utilities.getUploadMarkdown(upload);
|
||||||
|
this.replaceMarkdown(old, markdown);
|
||||||
} else {
|
} else {
|
||||||
Discourse.Utilities.displayErrorForUpload(upload);
|
Discourse.Utilities.displayErrorForUpload(upload);
|
||||||
}
|
}
|
||||||
|
@ -350,6 +351,10 @@ const ComposerView = Ember.View.extend(Ember.Evented, {
|
||||||
this.get("controller").send("closeModal");
|
this.get("controller").send("closeModal");
|
||||||
// deal with cancellation
|
// deal with cancellation
|
||||||
cancelledByTheUser = false;
|
cancelledByTheUser = false;
|
||||||
|
// add upload placeholder
|
||||||
|
const markdown = Discourse.Utilities.getUploadPlaceholder(data.files[0].name);
|
||||||
|
this.addMarkdown(markdown);
|
||||||
|
//
|
||||||
if (data["xhr"]) {
|
if (data["xhr"]) {
|
||||||
const jqHXR = data.xhr();
|
const jqHXR = data.xhr();
|
||||||
if (jqHXR) {
|
if (jqHXR) {
|
||||||
|
@ -502,6 +507,11 @@ const ComposerView = Ember.View.extend(Ember.Evented, {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
replaceMarkdown(old, text) {
|
||||||
|
const reply = this.get("model.reply");
|
||||||
|
this.set("model.reply", reply.replace(old, text));
|
||||||
|
},
|
||||||
|
|
||||||
// Uses javascript to get the image sizes from the preview, if present
|
// Uses javascript to get the image sizes from the preview, if present
|
||||||
imageSizes() {
|
imageSizes() {
|
||||||
const result = {};
|
const result = {};
|
||||||
|
|
|
@ -245,6 +245,7 @@ en:
|
||||||
|
|
||||||
upload: "Upload"
|
upload: "Upload"
|
||||||
uploading: "Uploading..."
|
uploading: "Uploading..."
|
||||||
|
uploading_filename: "Uploading {{filename}}..."
|
||||||
uploaded: "Uploaded!"
|
uploaded: "Uploaded!"
|
||||||
|
|
||||||
enable: "Enable"
|
enable: "Enable"
|
||||||
|
|
Loading…
Reference in a new issue