mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 23:54:16 +08:00
FIX: Javascript error when uploading backup
This commit is contained in:
parent
f0dda91364
commit
7069ee16e2
|
@ -9,13 +9,8 @@
|
|||
error="errorAction"
|
||||
uploadText="UPLOAD"
|
||||
}}
|
||||
|
||||
@class ResumableUploadComponent
|
||||
@extends Ember.Component
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.ResumableUploadComponent = Ember.Component.extend({
|
||||
Discourse.ResumableUploadComponent = Ember.Component.extend(Discourse.StringBuffer, {
|
||||
tagName: "button",
|
||||
classNames: ["btn", "ru"],
|
||||
classNameBindings: ["isUploading"],
|
||||
|
@ -25,7 +20,7 @@ Discourse.ResumableUploadComponent = Ember.Component.extend({
|
|||
isUploading: false,
|
||||
progress: 0,
|
||||
|
||||
shouldRerender: Discourse.View.renderIfChanged("isUploading", "progress"),
|
||||
rerenderTriggers: ['isUploading', 'progress'],
|
||||
|
||||
text: function() {
|
||||
if (this.get("isUploading")) {
|
||||
|
@ -35,7 +30,7 @@ Discourse.ResumableUploadComponent = Ember.Component.extend({
|
|||
}
|
||||
}.property("isUploading", "progress"),
|
||||
|
||||
render: function(buffer) {
|
||||
renderString: function(buffer) {
|
||||
var icon = this.get("isUploading") ? "times" : "upload";
|
||||
buffer.push("<i class='fa fa-" + icon + "'></i>");
|
||||
buffer.push("<span class='ru-label'>" + this.get("text") + "</span>");
|
||||
|
|
27
app/assets/javascripts/discourse/mixins/string-buffer.js.es6
Normal file
27
app/assets/javascripts/discourse/mixins/string-buffer.js.es6
Normal file
|
@ -0,0 +1,27 @@
|
|||
export default Ember.Mixin.create({
|
||||
|
||||
_watchProps: function() {
|
||||
var args = this.get('rerenderTriggers');
|
||||
if (!Ember.isNone(args)) {
|
||||
var self = this;
|
||||
args.forEach(function(k) {
|
||||
self.addObserver(k, self.rerenderString);
|
||||
});
|
||||
}
|
||||
}.on('init'),
|
||||
|
||||
render: function(buffer) {
|
||||
this.renderString(buffer);
|
||||
},
|
||||
|
||||
_rerenderString: function() {
|
||||
var buffer = [];
|
||||
this.renderString(buffer);
|
||||
this.$().html(buffer.join(''));
|
||||
},
|
||||
|
||||
rerenderString: function() {
|
||||
Ember.run.once(this, '_rerenderString');
|
||||
}
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user