diff --git a/core/client/assets/lib/uploader.js b/core/client/assets/lib/uploader.js index b0c847df2f..6c41db7518 100644 --- a/core/client/assets/lib/uploader.js +++ b/core/client/assets/lib/uploader.js @@ -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(); }); }; diff --git a/core/client/components/gh-uploader.js b/core/client/components/gh-uploader.js index eb7282e0df..c1bbfa9cf9 100644 --- a/core/client/components/gh-uploader.js +++ b/core/client/components/gh-uploader.js @@ -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://') { diff --git a/core/client/controllers/post-settings-menu.js b/core/client/controllers/post-settings-menu.js index 7a4036c68b..59e73343f2 100644 --- a/core/client/controllers/post-settings-menu.js +++ b/core/client/controllers/post-settings-menu.js @@ -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(); + } } } }); diff --git a/core/client/routes/editor/new.js b/core/client/routes/editor/new.js index 96da4d70a6..f5e4b0494f 100644 --- a/core/client/routes/editor/new.js +++ b/core/client/routes/editor/new.js @@ -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); } }); diff --git a/core/client/templates/post-settings-menu.hbs b/core/client/templates/post-settings-menu.hbs index 34cab541fa..156224eafe 100644 --- a/core/client/templates/post-settings-menu.hbs +++ b/core/client/templates/post-settings-menu.hbs @@ -7,7 +7,7 @@
- {{gh-uploader uploaded="setCoverImage" canceled="clearCoverImage" image=image tagName="section"}} + {{gh-uploader uploaded="setCoverImage" canceled="clearCoverImage" image=image uploaderReference=uploaderReference tagName="section"}}