diff --git a/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 b/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 index 0a1306e2124..bd9528495ae 100644 --- a/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 @@ -5,10 +5,6 @@ export default Discourse.DiscoveryController.extend({ showPostsColumn: Em.computed.empty('withLogo'), actions: { - toggleOrdering: function(){ - this.set("ordering",!this.get("ordering")); - }, - refresh: function() { var self = this; @@ -27,13 +23,6 @@ export default Discourse.DiscoveryController.extend({ return Discourse.User.currentProp('staff'); }.property(), - fixedCategoryPositions: Discourse.computed.setting('fixed_category_positions'), - canOrder: Em.computed.and('fixedCategoryPositions', 'canEdit'), - - moveCategory: function(categoryId, position){ - this.get('model.categories').moveCategory(categoryId, position); - }, - latestTopicOnly: function() { return this.get('categories').find(function(c) { return c.get('featuredTopics.length') > 1; }) === undefined; }.property('categories.@each.featuredTopics.length') diff --git a/app/assets/javascripts/discourse/models/category_list.js b/app/assets/javascripts/discourse/models/category_list.js index d60c41e978a..c0478499d33 100644 --- a/app/assets/javascripts/discourse/models/category_list.js +++ b/app/assets/javascripts/discourse/models/category_list.js @@ -10,13 +10,6 @@ Discourse.CategoryList = Ember.ArrayProxy.extend({ init: function() { this.content = []; this._super(); - }, - - moveCategory: function(categoryId, position){ - Discourse.ajax("/category/" + categoryId + "/move", { - type: 'POST', - data: { position: position } - }); } }); diff --git a/app/assets/javascripts/discourse/templates/discovery/categories.js.handlebars b/app/assets/javascripts/discourse/templates/discovery/categories.js.handlebars index 9ed0f8d0114..0e7e2eeabd1 100644 --- a/app/assets/javascripts/discourse/templates/discovery/categories.js.handlebars +++ b/app/assets/javascripts/discourse/templates/discovery/categories.js.handlebars @@ -7,9 +7,7 @@ {{i18n categories.latest}} {{i18n categories.topics}} {{#if showPostsColumn}} - {{i18n categories.posts}} - {{#if canOrder}}{{/if}} - + {{i18n categories.posts}} {{/if}} @@ -19,7 +17,6 @@
- {{#if controller.ordering}}{{/if}} {{category-title-link category=this}} {{#if unreadTopics}} {{i18n filters.unread.lower_title_with_count count="unreadTopics"}} diff --git a/app/assets/javascripts/discourse/views/discovery-categories.js.es6 b/app/assets/javascripts/discourse/views/discovery-categories.js.es6 index d16f6321967..8571185e21a 100644 --- a/app/assets/javascripts/discourse/views/discovery-categories.js.es6 +++ b/app/assets/javascripts/discourse/views/discovery-categories.js.es6 @@ -1,43 +1,3 @@ import UrlRefresh from 'discourse/mixins/url-refresh'; -export default Discourse.View.extend(UrlRefresh, { - - orderingChanged: function(){ - if (this.get("controller.ordering")) { - this.enableOrdering(); - } else { - this.disableOrdering(); - } - }.observes("controller.ordering"), - - rows: function() { - return $('.topic-list tbody'); - }, - - enableOrdering: function(){ - var self = this; - Em.run.next(function(){ - self.rows().sortable({handle: '.fa-bars'}).on('sortupdate',function(evt, data){ - var tr = $(data.item); - var categoryId = tr.data('category_id'); - var position = self.rows().find('tr').index(tr[0]); - self.get('controller').moveCategory(categoryId, position); - }); - }); - }, - - _scrollTop: function() { - Em.run.schedule('afterRender', function() { - $(document).scrollTop(0); - }); - }.on('didInsertElement'), - - disableOrdering: function(){ - this.rows().sortable("destroy").off('sortupdate'); - }, - - willDestroyElement: function(){ - this.disableOrdering(); - } - -}); +export default Discourse.View.extend(UrlRefresh, Discourse.ScrollTop);