diff --git a/ghost/admin/components/gh-upload-modal.js b/ghost/admin/components/gh-upload-modal.js index a93a85507d..d5a6775290 100644 --- a/ghost/admin/components/gh-upload-modal.js +++ b/ghost/admin/components/gh-upload-modal.js @@ -1,17 +1,36 @@ -/*global console */ - import ModalDialog from 'ghost/components/gh-modal-dialog'; +import upload from 'ghost/assets/lib/uploader'; var UploadModal = ModalDialog.extend({ layoutName: 'components/gh-modal-dialog', didInsertElement: function () { this._super(); + var filestorage = $('#general').data('filestorage'); + upload.call(this.$('.js-drop-zone'), {fileStorage: filestorage}); + }, + confirm: { + reject: { + func: function () { // The function called on rejection + return true; + }, + buttonClass: true, + text: 'Cancel' // The reject button text + }, + accept: { + buttonClass: 'button-save right', + text: 'Save', // The accept button texttext: 'Save' + func: function () { + var imageType = 'model.' + this.get('imageType'); - // @TODO: get this real - console.log('UploadController:afterRender'); - // var filestorage = $('#' + this.options.model.id).data('filestorage'); - // this.$('.js-drop-zone').upload({fileStorage: filestorage}); + if (this.$('.js-upload-url').val()) { + this.set(imageType, this.$('.js-upload-url').val()); + } else { + this.set(imageType, this.$('.js-upload-target').attr('src')); + } + return true; + } + } }, actions: { @@ -21,12 +40,11 @@ var UploadModal = ModalDialog.extend({ confirm: function (type) { var func = this.get('confirm.' + type + '.func'); if (typeof func === 'function') { - func(); + func.apply(this); } this.sendAction(); } - }, - + } }); export default UploadModal; diff --git a/ghost/admin/controllers/modals/upload.js b/ghost/admin/controllers/modals/upload.js index c224440eea..953dfe2bb7 100644 --- a/ghost/admin/controllers/modals/upload.js +++ b/ghost/admin/controllers/modals/upload.js @@ -1,5 +1,6 @@ var UploadController = Ember.Controller.extend({ + acceptEncoding: 'image/*', actions: { confirmReject: function () { return true; diff --git a/ghost/admin/fixtures/settings.js b/ghost/admin/fixtures/settings.js index 2339c5485b..7aa4642a49 100644 --- a/ghost/admin/fixtures/settings.js +++ b/ghost/admin/fixtures/settings.js @@ -3,8 +3,8 @@ var settings = { "title": "Ghost", "description": "Just a blogging platform.", "email": "ghost@tryghost.org", - "logo": "", - "cover": "", + "logo": "http://media-cache-ec0.pinimg.com/236x/be/35/06/be35065e6f9a613d4a7661a6f45d0831.jpg", + "cover": "http://i906.photobucket.com/albums/ac267/df853/bring_me_a_shrubbery_cat.jpg", "defaultLang": "en_US", "postsPerPage": "6", "forceI18n": "true", @@ -23,4 +23,4 @@ var settings = { }; export default settings; -/* jshint ignore:end */ \ No newline at end of file +/* jshint ignore:end */ diff --git a/ghost/admin/routes/application.js b/ghost/admin/routes/application.js index 0e4c7a5a7e..5afffb2aab 100644 --- a/ghost/admin/routes/application.js +++ b/ghost/admin/routes/application.js @@ -24,12 +24,14 @@ var ApplicationRoute = Ember.Route.extend({ this.set('controller.user', null); }, - openModal: function (modalName, model) { + openModal: function (modalName, model, type) { modalName = 'modals/' + modalName; // We don't always require a modal to have a controller // so we're skipping asserting if one exists if (this.controllerFor(modalName, true)) { this.controllerFor(modalName).set('model', model); + this.controllerFor(modalName).set('imageType', type); + this.controllerFor(modalName).set('src', model.get(type)); } return this.render(modalName, { into: 'application', @@ -58,4 +60,4 @@ var ApplicationRoute = Ember.Route.extend({ } }); -export default ApplicationRoute; \ No newline at end of file +export default ApplicationRoute; diff --git a/ghost/admin/templates/components/gh-file-upload.hbs b/ghost/admin/templates/components/gh-file-upload.hbs index 8388128d2c..9aa605e4ca 100644 --- a/ghost/admin/templates/components/gh-file-upload.hbs +++ b/ghost/admin/templates/components/gh-file-upload.hbs @@ -1,2 +1,4 @@ - - +
+ logo + +
diff --git a/ghost/admin/templates/modals/upload.hbs b/ghost/admin/templates/modals/upload.hbs index e1e3d23076..8530707a40 100644 --- a/ghost/admin/templates/modals/upload.hbs +++ b/ghost/admin/templates/modals/upload.hbs @@ -1,9 +1,8 @@ -{{#gh-upload-modal action="closeModal" close=true type="action" style="wide" +{{#gh-upload-modal action="closeModal" close=true type="action" style="wide" model=model imageType=imageType animation="fade"}} -
logo - +
{{/gh-upload-modal}} diff --git a/ghost/admin/templates/settings/general.hbs b/ghost/admin/templates/settings/general.hbs index d2b779e620..db488de400 100644 --- a/ghost/admin/templates/settings/general.hbs +++ b/ghost/admin/templates/settings/general.hbs @@ -29,9 +29,9 @@
{{#if logo}} - + {{else}} - + {{/if}}

Display a sexy logo for your publication

@@ -39,9 +39,9 @@
{{#if cover}} - cover photo + cover photo {{else}} - Upload Image + Upload Image {{/if}}

Display a cover image on your site

diff --git a/ghost/admin/templates/settings/user.hbs b/ghost/admin/templates/settings/user.hbs index a5dc8a63c0..57f22b1449 100644 --- a/ghost/admin/templates/settings/user.hbs +++ b/ghost/admin/templates/settings/user.hbs @@ -11,7 +11,7 @@
- Change Cover + Change Cover
@@ -20,7 +20,7 @@
- Edit Picture + Edit Picture