From aada925b21afe2936eba54547b19f1aaca889004 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 14 Nov 2016 12:57:01 -0500 Subject: [PATCH] Start converting modal views to components --- .../discourse/components/d-modal-body.js.es6 | 29 +++++++++++++++++++ .../discourse/routes/unknown.js.es6 | 3 +- .../templates/modal/edit-topic-auto-close.hbs | 4 +-- .../discourse/templates/modal/raw-email.hbs | 4 +-- .../templates/{ => modal}/rename-tag.hbs | 4 +-- .../discourse/templates/modal/split-topic.hbs | 5 ++-- .../templates/modal/upload-customization.hbs | 4 +-- .../discourse/templates/unknown.hbs | 3 ++ .../views/edit-topic-auto-close.js.es6 | 7 ----- .../javascripts/discourse/views/modal.js.es6 | 4 +++ .../javascripts/discourse/views/raw-email.es6 | 11 ------- .../discourse/views/rename-tag.js.es6 | 5 ---- .../discourse/views/split-topic.js.es6 | 7 ----- .../discourse/views/unknown.js.es6 | 9 ------ .../views/upload-customization.js.es6 | 6 ---- 15 files changed, 48 insertions(+), 57 deletions(-) create mode 100644 app/assets/javascripts/discourse/components/d-modal-body.js.es6 rename app/assets/javascripts/discourse/templates/{ => modal}/rename-tag.hbs (83%) create mode 100644 app/assets/javascripts/discourse/templates/unknown.hbs delete mode 100644 app/assets/javascripts/discourse/views/edit-topic-auto-close.js.es6 delete mode 100644 app/assets/javascripts/discourse/views/raw-email.es6 delete mode 100644 app/assets/javascripts/discourse/views/rename-tag.js.es6 delete mode 100644 app/assets/javascripts/discourse/views/split-topic.js.es6 delete mode 100644 app/assets/javascripts/discourse/views/unknown.js.es6 delete mode 100644 app/assets/javascripts/discourse/views/upload-customization.js.es6 diff --git a/app/assets/javascripts/discourse/components/d-modal-body.js.es6 b/app/assets/javascripts/discourse/components/d-modal-body.js.es6 new file mode 100644 index 00000000000..0753cf4fef7 --- /dev/null +++ b/app/assets/javascripts/discourse/components/d-modal-body.js.es6 @@ -0,0 +1,29 @@ +export default Ember.Component.extend({ + classNames: ['modal-body'], + + didInsertElement() { + this._super(); + $('#modal-alert').hide(); + $('#discourse-modal').modal('show'); + Ember.run.scheduleOnce('afterRender', this, this._afterFirstRender); + }, + + _afterFirstRender() { + if (!this.site.mobileView && this.get('autoFocus') !== 'false') { + this.$('input:first').focus(); + } + + const maxHeight = this.get('maxHeight'); + if (maxHeight) { + const maxHeightFloat = parseFloat(maxHeight) / 100.0; + if (maxHeightFloat > 0) { + const viewPortHeight = $(window).height(); + this.$().css("max-height", Math.floor(maxHeightFloat * viewPortHeight) + "px"); + } + } + + this.appEvents.trigger('modal:body-shown', { + title: this.get('title') + }); + } +}); diff --git a/app/assets/javascripts/discourse/routes/unknown.js.es6 b/app/assets/javascripts/discourse/routes/unknown.js.es6 index 7e01606f3be..40c8a301395 100644 --- a/app/assets/javascripts/discourse/routes/unknown.js.es6 +++ b/app/assets/javascripts/discourse/routes/unknown.js.es6 @@ -1,6 +1,7 @@ import { ajax } from 'discourse/lib/ajax'; + export default Discourse.Route.extend({ - model: function() { + model() { return ajax("/404-body", { dataType: 'html' }); } }); diff --git a/app/assets/javascripts/discourse/templates/modal/edit-topic-auto-close.hbs b/app/assets/javascripts/discourse/templates/modal/edit-topic-auto-close.hbs index cc1f423cc0e..d5dcb92fa69 100644 --- a/app/assets/javascripts/discourse/templates/modal/edit-topic-auto-close.hbs +++ b/app/assets/javascripts/discourse/templates/modal/edit-topic-auto-close.hbs @@ -1,5 +1,5 @@
- {{/if}} - + {{/d-modal-body}}