Merge pull request #4502 from felixrieseberg/iss4431

Ensure Post Image Uploader Reset
This commit is contained in:
Hannah Wolfe 2014-11-25 19:07:32 +00:00
commit a1ab6b4a13
5 changed files with 22 additions and 3 deletions

View File

@ -237,6 +237,13 @@ UploadUi = function ($dropzone, settings) {
} else {
this.initWithImage();
}
},
reset: function () {
$dropzone.find('.js-url').remove();
$dropzone.find('.js-fileupload').removeClass('right');
this.removeExtras();
this.initWithDropzone();
}
});
};
@ -253,6 +260,7 @@ upload = function (options) {
ui;
ui = new UploadUi($dropzone, settings);
this.uploaderUi = ui;
ui.init();
});
};

View File

@ -7,10 +7,10 @@ var PostImageUploader = Ember.Component.extend({
var $this = this.$(),
self = this;
uploader.call($this, {
this.set('uploaderReference', uploader.call($this, {
editor: true,
fileStorage: this.get('config.fileStorage')
});
}));
$this.on('uploadsuccess', function (event, result) {
if (result && result !== '' && result !== 'http://') {

View File

@ -451,6 +451,14 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
closeSubview: function () {
this.set('isViewingSubview', false);
},
resetUploader: function () {
var uploader = this.get('uploaderReference');
if (uploader && uploader[0]) {
uploader[0].uploaderUi.reset();
}
}
}
});

View File

@ -18,6 +18,9 @@ var EditorNewRoute = AuthenticatedRoute.extend(base, {
// from previous posts
psm.removeObserver('titleScratch', psm, 'titleObserver');
// Ensure that the PSM Image Uploader resets
psm.send('resetUploader');
this._super(controller, model);
}
});

View File

@ -7,7 +7,7 @@
<button class="close icon-x settings-menu-header-action" {{action "closeSettingsMenu"}}><span class="hidden">Close</span></button>
</div>
<div class="settings-menu-content">
{{gh-uploader uploaded="setCoverImage" canceled="clearCoverImage" image=image tagName="section"}}
{{gh-uploader uploaded="setCoverImage" canceled="clearCoverImage" image=image uploaderReference=uploaderReference tagName="section"}}
<form>
<div class="form-group">
<label for="url">Post URL</label>