From 3d95bac3fbaf11cb3e17fb4314eb7342dc3aabf8 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 30 Aug 2017 15:29:51 -0400 Subject: [PATCH] Migrate away from `#discourse-modal` to `.d-modal` --- .../discourse/components/d-modal-body.js.es6 | 2 +- .../discourse/components/hide-modal-trigger.js.es6 | 2 +- .../javascripts/discourse/routes/application.js.es6 | 4 ++-- app/assets/stylesheets/common/printer-friendly.scss | 2 +- .../javascripts/acceptance/category-edit-test.js.es6 | 8 ++++---- test/javascripts/acceptance/composer-test.js.es6 | 8 ++++---- test/javascripts/acceptance/modal-test.js.es6 | 12 ++++++------ 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/assets/javascripts/discourse/components/d-modal-body.js.es6 b/app/assets/javascripts/discourse/components/d-modal-body.js.es6 index 42c797ddf96..6eac9a34c68 100644 --- a/app/assets/javascripts/discourse/components/d-modal-body.js.es6 +++ b/app/assets/javascripts/discourse/components/d-modal-body.js.es6 @@ -4,7 +4,7 @@ export default Ember.Component.extend({ didInsertElement() { this._super(); $('#modal-alert').hide(); - $('#discourse-modal').modal('show'); + $('.d-modal').modal('show'); Ember.run.scheduleOnce('afterRender', this, this._afterFirstRender); this.appEvents.on('modal-body:flash', msg => this._flash(msg)); }, diff --git a/app/assets/javascripts/discourse/components/hide-modal-trigger.js.es6 b/app/assets/javascripts/discourse/components/hide-modal-trigger.js.es6 index b077ab7048d..d5f9bac4aae 100644 --- a/app/assets/javascripts/discourse/components/hide-modal-trigger.js.es6 +++ b/app/assets/javascripts/discourse/components/hide-modal-trigger.js.es6 @@ -1,6 +1,6 @@ export default Ember.Component.extend({ didInsertElement() { this._super(); - $('#discourse-modal').modal('hide').addClass('hidden'); + $('.d-modal').modal('hide').addClass('hidden'); } }); diff --git a/app/assets/javascripts/discourse/routes/application.js.es6 b/app/assets/javascripts/discourse/routes/application.js.es6 index 5fe33977bf2..ee7c22ed80c 100644 --- a/app/assets/javascripts/discourse/routes/application.js.es6 +++ b/app/assets/javascripts/discourse/routes/application.js.es6 @@ -121,11 +121,11 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, { user clicks "No", reopenModal. If user clicks "Yes", be sure to call closeModal. **/ hideModal() { - $('#discourse-modal').modal('hide'); + $('.d-modal').modal('hide'); }, reopenModal() { - $('#discourse-modal').modal('show'); + $('.d-modal').modal('show'); }, editCategory(category) { diff --git a/app/assets/stylesheets/common/printer-friendly.scss b/app/assets/stylesheets/common/printer-friendly.scss index d640737b47e..dc7ad0e4958 100644 --- a/app/assets/stylesheets/common/printer-friendly.scss +++ b/app/assets/stylesheets/common/printer-friendly.scss @@ -22,7 +22,7 @@ .post-action, .saving-text, .draft-text, - #discourse-modal, + .discourse-modal, div.read-state, div.read-state.read, .edit-topic, diff --git a/test/javascripts/acceptance/category-edit-test.js.es6 b/test/javascripts/acceptance/category-edit-test.js.es6 index 38a547feeaf..fe7568a4982 100644 --- a/test/javascripts/acceptance/category-edit-test.js.es6 +++ b/test/javascripts/acceptance/category-edit-test.js.es6 @@ -11,12 +11,12 @@ QUnit.test("Can open the category modal", assert => { click('.edit-category'); andThen(() => { - assert.ok(visible('#discourse-modal'), 'it pops up a modal'); + assert.ok(visible('.d-modal'), 'it pops up a modal'); }); click('a.close'); andThen(() => { - assert.ok(!visible('#discourse-modal'), 'it closes the modal'); + assert.ok(!visible('.d-modal'), 'it closes the modal'); }); }); @@ -27,7 +27,7 @@ QUnit.test("Change the category color", assert => { fillIn('#edit-text-color', '#ff0000'); click('#save-category'); andThen(() => { - assert.ok(!visible('#discourse-modal'), 'it closes the modal'); + assert.ok(!visible('.d-modal'), 'it closes the modal'); assert.equal(DiscourseURL.redirectedTo, '/c/bug', 'it does one of the rare full page redirects'); }); }); @@ -40,7 +40,7 @@ QUnit.test("Change the topic template", assert => { fillIn('.d-editor-input', 'this is the new topic template'); click('#save-category'); andThen(() => { - assert.ok(!visible('#discourse-modal'), 'it closes the modal'); + assert.ok(!visible('.d-modal'), 'it closes the modal'); assert.equal(DiscourseURL.redirectedTo, '/c/bug', 'it does one of the rare full page redirects'); }); }); diff --git a/test/javascripts/acceptance/composer-test.js.es6 b/test/javascripts/acceptance/composer-test.js.es6 index fcbd971f230..48afc43867d 100644 --- a/test/javascripts/acceptance/composer-test.js.es6 +++ b/test/javascripts/acceptance/composer-test.js.es6 @@ -115,13 +115,13 @@ QUnit.test("Create an enqueued Topic", assert => { fillIn('.d-editor-input', "enqueue this content please"); click('#reply-control button.create'); andThen(() => { - assert.ok(visible('#discourse-modal'), 'it pops up a modal'); + assert.ok(visible('.d-modal'), 'it pops up a modal'); assert.equal(currentURL(), "/", "it doesn't change routes"); }); click('.modal-footer button'); andThen(() => { - assert.ok(invisible('#discourse-modal'), 'the modal can be dismissed'); + assert.ok(invisible('.d-modal'), 'the modal can be dismissed'); }); }); @@ -183,12 +183,12 @@ QUnit.test("Create an enqueued Reply", assert => { }); andThen(() => { - assert.ok(visible('#discourse-modal'), 'it pops up a modal'); + assert.ok(visible('.d-modal'), 'it pops up a modal'); }); click('.modal-footer button'); andThen(() => { - assert.ok(invisible('#discourse-modal'), 'the modal can be dismissed'); + assert.ok(invisible('.d-modal'), 'the modal can be dismissed'); }); }); diff --git a/test/javascripts/acceptance/modal-test.js.es6 b/test/javascripts/acceptance/modal-test.js.es6 index 1a570f222d7..7907c12b215 100644 --- a/test/javascripts/acceptance/modal-test.js.es6 +++ b/test/javascripts/acceptance/modal-test.js.es6 @@ -5,26 +5,26 @@ QUnit.test("modal", assert => { visit('/'); andThen(() => { - assert.ok(find('#discourse-modal:visible').length === 0, 'there is no modal at first'); + assert.ok(find('.d-modal:visible').length === 0, 'there is no modal at first'); }); click('.login-button'); andThen(() => { - assert.ok(find('#discourse-modal:visible').length === 1, 'modal should appear'); + assert.ok(find('.d-modal:visible').length === 1, 'modal should appear'); }); click('.modal-outer-container'); andThen(() => { - assert.ok(find('#discourse-modal:visible').length === 0, 'modal should disappear when you click outside'); + assert.ok(find('.d-modal:visible').length === 0, 'modal should disappear when you click outside'); }); click('.login-button'); andThen(() => { - assert.ok(find('#discourse-modal:visible').length === 1, 'modal should reappear'); + assert.ok(find('.d-modal:visible').length === 1, 'modal should reappear'); }); keyEvent('#main-outlet', 'keydown', 27); andThen(() => { - assert.ok(find('#discourse-modal:visible').length === 0, 'ESC should close the modal'); + assert.ok(find('.d-modal:visible').length === 0, 'ESC should close the modal'); }); -}); \ No newline at end of file +});