BUGFIX: change the image upload icon when only images are authorized (fixes #2359)
This commit is contained in:
@@ -279,7 +279,7 @@ Discourse.Utilities = {
|
||||
**/
|
||||
allowsAttachments: function() {
|
||||
return Discourse.Utilities.authorizesAllExtensions() ||
|
||||
(/(png|jpg|jpeg|gif|bmp|tif|tiff)/i).test(Discourse.SiteSettings.authorized_extensions);
|
||||
!(/((png|jpg|jpeg|gif|bmp|tif|tiff)(,\s)?)+$/i).test(Discourse.Utilities.authorizedExtensions());
|
||||
},
|
||||
|
||||
displayErrorForUpload: function(data) {
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary" {{action upload target="view"}}>
|
||||
<span class='add-upload'><i {{bind-attr class="view.uploadIcon"}}></i><i class='fa fa-plus'></i></span>
|
||||
<span class='add-upload'><i {{bind-attr class=":fa view.uploadIcon"}}></i><i class='fa fa-plus'></i></span>
|
||||
{{i18n upload}}
|
||||
</button>
|
||||
<a {{action closeModal}}>{{i18n cancel}}</a>
|
||||
|
||||
@@ -202,6 +202,13 @@ Discourse.ComposerView = Discourse.View.extend(Ember.Evented, {
|
||||
}
|
||||
});
|
||||
|
||||
// HACK to change the upload icon of the composer's toolbar
|
||||
Em.run.scheduleOnce("afterRender", function() {
|
||||
if (!Discourse.Utilities.allowsAttachments()) {
|
||||
$("#wmd-image-button").addClass("image-only");
|
||||
}
|
||||
});
|
||||
|
||||
this.editor.hooks.insertImageDialog = function(callback) {
|
||||
callback(null);
|
||||
self.get('controller').send('showUploadSelector', self);
|
||||
|
||||
@@ -18,7 +18,7 @@ Discourse.UploadSelectorView = Discourse.ModalBodyView.extend({
|
||||
classNames: ['upload-selector'],
|
||||
|
||||
title: function() { return uploadTranslate("title"); }.property(),
|
||||
uploadIcon: function() { return Discourse.Utilities.allowsAttachments() ? "fa-file-o" : "fa-picture-o"; }.property(),
|
||||
uploadIcon: function() { return Discourse.Utilities.allowsAttachments() ? "fa-upload" : "fa-picture-o"; }.property(),
|
||||
|
||||
tip: function() {
|
||||
var source = this.get("controller.local") ? "local" : "remote";
|
||||
|
||||
Reference in New Issue
Block a user