FIX: Javascript error when uploading backup

This commit is contained in:
Robin Ward 2014-12-08 12:38:12 -05:00
parent f0dda91364
commit 7069ee16e2
2 changed files with 30 additions and 8 deletions

View File

@ -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>");

View 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');
}
});