mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Merge pull request #1225 from ZogStriP/upload-selector-handles-attachments
uploads selector texts is now different when attachments are enabled
This commit is contained in:
@@ -257,6 +257,15 @@ Discourse.Utilities = {
|
||||
isUploadForbidden: function(path) {
|
||||
if (Discourse.User.current('trust_level') > 0) { return false; }
|
||||
return Discourse.Utilities.isAnImage(path) ? Discourse.SiteSettings.newuser_max_images === 0 : Discourse.SiteSettings.newuser_max_attachments === 0;
|
||||
},
|
||||
|
||||
/**
|
||||
Determines whether we allow attachments or not
|
||||
|
||||
@method allowsAttachments
|
||||
**/
|
||||
allowsAttachments: function() {
|
||||
return _.difference(Discourse.SiteSettings.authorized_extensions.split("|"), [".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tif", ".tiff"]).length > 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -12,6 +12,20 @@ Discourse.UploadSelectorController = Discourse.Controller.extend(Discourse.Modal
|
||||
remoteSelected: Em.computed.not('localSelected'),
|
||||
|
||||
selectLocal: function() { this.set('localSelected', true); },
|
||||
selectRemote: function() { this.set('localSelected', false); }
|
||||
selectRemote: function() { this.set('localSelected', false); },
|
||||
|
||||
localTitle: function() { return Discourse.UploadSelectorController.translate("local_title") }.property(),
|
||||
remoteTitle: function() { return Discourse.UploadSelectorController.translate("remote_title") }.property(),
|
||||
localTip: function() { return Discourse.UploadSelectorController.translate("local_tip") }.property(),
|
||||
remoteTip: function() { return Discourse.UploadSelectorController.translate("remote_tip") }.property(),
|
||||
uploadTitle: function() { return Discourse.UploadSelectorController.translate("upload_title") }.property(),
|
||||
addTitle: function() { return Discourse.UploadSelectorController.translate("add_title") }.property()
|
||||
|
||||
});
|
||||
|
||||
Discourse.UploadSelectorController.reopenClass({
|
||||
translate: function(key) {
|
||||
if (Discourse.Utilities.allowsAttachments()) key += "_with_attachments";
|
||||
return I18n.t("upload_selector." + key);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
<div id='draft-status'></div>
|
||||
{{#if view.isUploading}}
|
||||
<div id="file-uploading">
|
||||
{{i18n upload_selector.upload_file}} {{view.uploadProgress}}% <a id="cancel-file-upload">{{i18n cancel}}</a>
|
||||
{{i18n upload_selector.uploading}} {{view.uploadProgress}}% <a id="cancel-file-upload">{{i18n cancel}}</a>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<ul class="nav nav-pills">
|
||||
<li title="{{i18n upload_selector.local_title}}" {{bindAttr class="localSelected:active"}}>
|
||||
<li {{bindAttr title="localTitle" class="localSelected:active"}}>
|
||||
<a href="#" {{action selectLocal}}>{{i18n upload_selector.from_my_computer}}</a>
|
||||
</li>
|
||||
<li title="{{i18n upload_selector.remote_title}}" {{bindAttr class="remoteSelected:active"}}>
|
||||
<li {{bindAttr title="remoteTitle" class="remoteSelected:active"}}>
|
||||
<a href="#" {{action selectRemote}}>{{i18n upload_selector.from_the_web}}</a>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -11,26 +11,26 @@
|
||||
<div class='modal-body'>
|
||||
<form>
|
||||
<input type="file" name="file" id="filename-input" value="browse"><br>
|
||||
<span class='description'>{{i18n upload_selector.local_tip}}</span> <br>
|
||||
<span class='description'>{{localTip}}</span> <br>
|
||||
</form>
|
||||
</div>
|
||||
<div class='modal-footer'>
|
||||
<button class='btn btn-large btn-primary' {{action upload target="view"}}>
|
||||
<span class='add-upload'><i class='icon-file-alt'></i><i class='icon-plus'></i></span>
|
||||
{{i18n upload_selector.upload}}
|
||||
{{uploadTitle}}
|
||||
</button>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class='modal-body'>
|
||||
<form>
|
||||
<input type="text" name="text" id="fileurl-input" autofocus><br>
|
||||
<span class='description'>{{i18n upload_selector.remote_tip}}</span> <br>
|
||||
<span class='description'>{{remoteTip}}</span> <br>
|
||||
</form>
|
||||
</div>
|
||||
<div class='modal-footer'>
|
||||
<button class='btn btn-large btn-primary' {{action add target="view"}}>
|
||||
<span class='add-upload'><i class='icon-file-alt'></i><i class='icon-plus'></i></span>
|
||||
{{i18n upload_selector.add_image}}
|
||||
{{addTitle}}
|
||||
</button>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
Discourse.UploadSelectorView = Discourse.ModalBodyView.extend({
|
||||
templateName: 'modal/upload_selector',
|
||||
classNames: ['upload-selector'],
|
||||
title: I18n.t('upload_selector.title'),
|
||||
|
||||
title: function() { return Discourse.UploadSelectorController.translate("title"); }.property(),
|
||||
|
||||
upload: function() {
|
||||
$('#reply-control').fileupload('add', { fileInput: $('#filename-input') });
|
||||
|
||||
Reference in New Issue
Block a user