From 7e33834afeb930d910bd62f014a597ef9a6f3cfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Mon, 31 Mar 2014 18:18:39 +0200 Subject: [PATCH] FEATURE: create hyperlinked images from the image insertion dialog --- .../controllers/upload_selector_controller.js | 11 ++++++++--- .../templates/modal/upload_selector.js.handlebars | 11 ++++++++++- .../discourse/views/modal/upload_selector_view.js | 9 ++++++++- app/assets/stylesheets/desktop/upload.scss | 7 +++++-- config/locales/client.en.yml | 1 + 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/upload_selector_controller.js b/app/assets/javascripts/discourse/controllers/upload_selector_controller.js index c9da0d601a0..c24a6251395 100644 --- a/app/assets/javascripts/discourse/controllers/upload_selector_controller.js +++ b/app/assets/javascripts/discourse/controllers/upload_selector_controller.js @@ -10,10 +10,14 @@ Discourse.UploadSelectorController = Discourse.Controller.extend(Discourse.ModalFunctionality, { remote: Em.computed.not("local"), local: false, + showMore: false, init: function() { this._super(); - this.set("local", this.get("allowLocal")); + this.setProperties({ + local: this.get("allowLocal"), + showMore: false + }); }, allowLocal: function() { @@ -21,8 +25,9 @@ Discourse.UploadSelectorController = Discourse.Controller.extend(Discourse.Modal }.property(), actions: { - useLocal: function() { this.set("local", true); }, - useRemote: function() { this.set("local", false); } + useLocal: function() { this.setProperties({ local: true, showMore: false}); }, + useRemote: function() { this.set("local", false); }, + toggleShowMore: function() { this.toggleProperty("showMore"); } } }); diff --git a/app/assets/javascripts/discourse/templates/modal/upload_selector.js.handlebars b/app/assets/javascripts/discourse/templates/modal/upload_selector.js.handlebars index 91ea5227e8c..df8e01d87d7 100644 --- a/app/assets/javascripts/discourse/templates/modal/upload_selector.js.handlebars +++ b/app/assets/javascripts/discourse/templates/modal/upload_selector.js.handlebars @@ -16,11 +16,19 @@ {{#if remote}}
-
+
{{unbound view.tip}}
{{/if}} + {{#if showMore}} +
+
+
+ {{i18n upload_selector.image_link}} +
+
+ {{/if}}

{{unbound view.hint}}

@@ -34,4 +42,5 @@ {{i18n upload}} {{i18n cancel}} + {{#if remote}}{{i18n show_more}}{{/if}}
diff --git a/app/assets/javascripts/discourse/views/modal/upload_selector_view.js b/app/assets/javascripts/discourse/views/modal/upload_selector_view.js index 7d16998230b..52e2b8fe66c 100644 --- a/app/assets/javascripts/discourse/views/modal/upload_selector_view.js +++ b/app/assets/javascripts/discourse/views/modal/upload_selector_view.js @@ -47,7 +47,14 @@ Discourse.UploadSelectorView = Discourse.ModalBodyView.extend({ if (this.get("controller.local")) { $('#reply-control').fileupload('add', { fileInput: $('#filename-input') }); } else { - this.get('controller.composerView').addMarkdown($('#fileurl-input').val()); + var imageUrl = $('#fileurl-input').val(); + var imageLink = $('#link-input').val(); + var composerView = this.get('controller.composerView'); + if (this.get("controller.showMore") && imageLink.length > 3) { + composerView.addMarkdown("\n \n"); + } else { + composerView.addMarkdown(imageUrl); + } this.get('controller').send('closeModal'); } } diff --git a/app/assets/stylesheets/desktop/upload.scss b/app/assets/stylesheets/desktop/upload.scss index 68b328e964f..ab6391c3eac 100644 --- a/app/assets/stylesheets/desktop/upload.scss +++ b/app/assets/stylesheets/desktop/upload.scss @@ -6,7 +6,7 @@ position: relative; left: -5px; bottom: -5px; - text-shadow: + text-shadow: -1px -1px 0 $btn-primary-background-color, 1px 1px 0 $btn-primary-background-color, 1px -1px 0 $btn-primary-background-color, @@ -19,7 +19,7 @@ padding-left: 10px; } .radios { - margin: 0 0 25px 0; + height: 60px; .inputs { float: right; width: 75%; @@ -40,4 +40,7 @@ } } } + .radios:last-child { + height: 20px; + } } diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 94e8a724cf0..2f3731d00ce 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -611,6 +611,7 @@ en: hint: "(you can also drag & drop into the editor to upload them)" hint_for_chrome: "(you can also drag and drop or paste images into the editor to upload them)" uploading: "Uploading" + image_link: "enter the link you want your image to point to" search: title: "search for topics, posts, users, or categories"