diff --git a/app/assets/javascripts/discourse/controllers/quote_button_controller.js b/app/assets/javascripts/discourse/controllers/quote-button.js.es6 similarity index 98% rename from app/assets/javascripts/discourse/controllers/quote_button_controller.js rename to app/assets/javascripts/discourse/controllers/quote-button.js.es6 index e44dc2ddd..e694e07de 100644 --- a/app/assets/javascripts/discourse/controllers/quote_button_controller.js +++ b/app/assets/javascripts/discourse/controllers/quote-button.js.es6 @@ -8,7 +8,7 @@ @namespace Discourse @module Discourse **/ -Discourse.QuoteButtonController = Discourse.Controller.extend({ +export default Discourse.Controller.extend({ needs: ['topic', 'composer'], init: function() { diff --git a/app/assets/javascripts/discourse/controllers/search_controller.js b/app/assets/javascripts/discourse/controllers/search.js.es6 similarity index 82% rename from app/assets/javascripts/discourse/controllers/search_controller.js rename to app/assets/javascripts/discourse/controllers/search.js.es6 index ccb8c4c8e..2400a67a3 100644 --- a/app/assets/javascripts/discourse/controllers/search_controller.js +++ b/app/assets/javascripts/discourse/controllers/search.js.es6 @@ -6,7 +6,7 @@ @namespace Discourse @module Discourse **/ -Discourse.SearchController = Em.ArrayController.extend(Discourse.Presence, { +export default Em.ArrayController.extend(Discourse.Presence, { // If we need to perform another search newSearchNeeded: function() { @@ -16,24 +16,19 @@ Discourse.SearchController = Em.ArrayController.extend(Discourse.Presence, { this.set('loading', true); this.searchTerm(term, this.get('typeFilter')); } else { - this.set('content', Em.A()); - this.set('resultCount', 0); - this.set('urls', []); + this.setProperties({ content: [], resultCount: 0, urls: [] }); } this.set('selectedIndex', 0); }.observes('term', 'typeFilter'), searchTerm: Discourse.debouncePromise(function(term, typeFilter) { var self = this; - self.set('resultCount', 0); - self.set('urls', []); + this.setProperties({ resultCount: 0, urls: [] }); - var searcher = Discourse.Search.forTerm(term, { + return Discourse.Search.forTerm(term, { typeFilter: typeFilter, - searchContext: self.get('searchContext') - }); - - return searcher.then(function(results) { + searchContext: this.get('searchContext') + }).then(function(results) { var urls = []; if (results) { self.set('noResults', results.length === 0); @@ -52,9 +47,7 @@ Discourse.SearchController = Em.ArrayController.extend(Discourse.Presence, { }) .value(); - self.set('resultCount', index); - self.set('content', results); - self.set('urls', urls); + self.setProperties({ resultCount: index, content: results, urls: urls }); } self.set('loading', false); diff --git a/app/assets/javascripts/discourse/controllers/share_controller.js b/app/assets/javascripts/discourse/controllers/share.js.es6 similarity index 65% rename from app/assets/javascripts/discourse/controllers/share_controller.js rename to app/assets/javascripts/discourse/controllers/share.js.es6 index 344bb0343..3954ff4eb 100644 --- a/app/assets/javascripts/discourse/controllers/share_controller.js +++ b/app/assets/javascripts/discourse/controllers/share.js.es6 @@ -6,15 +6,18 @@ @namespace Discourse @module Discourse **/ -Discourse.ShareController = Discourse.Controller.extend({ - +export default Discourse.Controller.extend({ needs: ['topic'], // Close the share controller actions: { close: function() { - this.set('link', ''); - this.set('postNumber', ''); + this.setProperties({ link: '', postNumber: '' }); + return false; + }, + + sharePopup: function(target, url) { + window.open(url, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=600,height=' + Discourse.ShareLink.popupHeight(target)); return false; } }, @@ -27,11 +30,6 @@ Discourse.ShareController = Discourse.Controller.extend({ return null; } }, this).compact(); - }.property('link'), + }.property('link') - sharePopup: function(target, url) { - window.open(url, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=600,height=' + Discourse.ShareLink.popupHeight(target)); - return false; - } - -}); \ No newline at end of file +}); diff --git a/app/assets/javascripts/discourse/controllers/site_map_category_controller.js b/app/assets/javascripts/discourse/controllers/site-map-category.js.es6 similarity index 57% rename from app/assets/javascripts/discourse/controllers/site_map_category_controller.js rename to app/assets/javascripts/discourse/controllers/site-map-category.js.es6 index 47cb886f4..ce46fa102 100644 --- a/app/assets/javascripts/discourse/controllers/site_map_category_controller.js +++ b/app/assets/javascripts/discourse/controllers/site-map-category.js.es6 @@ -1,4 +1,4 @@ -Discourse.SiteMapCategoryController = Ember.ObjectController.extend({ +export default Ember.ObjectController.extend({ showBadges: function() { return !!Discourse.User.current(); }.property().volatile() diff --git a/app/assets/javascripts/discourse/controllers/site_map_controller.js b/app/assets/javascripts/discourse/controllers/site-map.js.es6 similarity index 88% rename from app/assets/javascripts/discourse/controllers/site_map_controller.js rename to app/assets/javascripts/discourse/controllers/site-map.js.es6 index a5a5bfeb6..7a4a15889 100644 --- a/app/assets/javascripts/discourse/controllers/site_map_controller.js +++ b/app/assets/javascripts/discourse/controllers/site-map.js.es6 @@ -1,5 +1,5 @@ -Discourse.SiteMapController = Ember.ArrayController.extend(Discourse.HasCurrentUser, { - itemController: "siteMapCategory", +export default Ember.ArrayController.extend(Discourse.HasCurrentUser, { + itemController: "site-map-category", showAdminLinks: Em.computed.alias('currentUser.staff'), flaggedPostsCount: Em.computed.alias("currentUser.site_flagged_posts_count"), diff --git a/app/assets/javascripts/discourse/controllers/topic_controller.js b/app/assets/javascripts/discourse/controllers/topic_controller.js index 467956224..b721c52a2 100644 --- a/app/assets/javascripts/discourse/controllers/topic_controller.js +++ b/app/assets/javascripts/discourse/controllers/topic_controller.js @@ -8,7 +8,7 @@ **/ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.SelectedPostsCount, { multiSelect: false, - needs: ['header', 'modal', 'composer', 'quoteButton'], + needs: ['header', 'modal', 'composer', 'quote-button'], allPostsSelected: false, editingTopic: false, selectedPosts: null, @@ -424,7 +424,7 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected // Post related methods replyToPost: function(post) { var composerController = this.get('controllers.composer'); - var quoteController = this.get('controllers.quoteButton'); + var quoteController = this.get('controllers.quote-button'); var quotedText = Discourse.Quote.build(quoteController.get('post'), quoteController.get('buffer')); var topic = post ? post.get('topic') : this.get('model'); diff --git a/test/javascripts/controllers/search_controller_test.js b/test/javascripts/controllers/search_controller_test.js index c9d1f5881..2d843d9b9 100644 --- a/test/javascripts/controllers/search_controller_test.js +++ b/test/javascripts/controllers/search_controller_test.js @@ -1,6 +1,6 @@ var controller, searcherStub; -module("Discourse.SearchController", { +module("controller:search", { setup: function() { Discourse.SiteSettings.min_search_term_length = 2; @@ -10,7 +10,7 @@ module("Discourse.SearchController", { searcherStub = Ember.Deferred.create(); sinon.stub(Discourse.Search, "forTerm").returns(searcherStub); - controller = Discourse.SearchController.create(); + controller = testController('search', []); }, teardown: function() { diff --git a/test/javascripts/controllers/site_map_category_controller_test.js b/test/javascripts/controllers/site_map_category_controller_test.js index 63e5e92dc..a51c41335 100644 --- a/test/javascripts/controllers/site_map_category_controller_test.js +++ b/test/javascripts/controllers/site_map_category_controller_test.js @@ -1,8 +1,8 @@ var controller; -module("Discourse.SiteMapCategoryController", { +module("controller:site-map-category", { setup: function() { - controller = Discourse.SiteMapCategoryController.create(); + controller = testController('site-map-category'); } }); diff --git a/test/javascripts/controllers/site_map_controller_test.js b/test/javascripts/controllers/site_map_controller_test.js index b8cce189f..5dbfdb525 100644 --- a/test/javascripts/controllers/site_map_controller_test.js +++ b/test/javascripts/controllers/site_map_controller_test.js @@ -1,10 +1,10 @@ var controller, oldMobileView; -module("Discourse.SiteMapController", { +module("controller:site-map", { setup: function() { oldMobileView = Discourse.Mobile.mobileView; - controller = Discourse.SiteMapController.create(); + controller = testController('site-map'); }, teardown: function() { @@ -13,7 +13,7 @@ module("Discourse.SiteMapController", { }); test("itemController", function() { - equal(controller.get("itemController"), "siteMapCategory", "defaults to SiteMapCategoryController"); + equal(controller.get("itemController"), "site-map-category", "defaults to site-map-category"); }); test("showAdminLinks", function() {