mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
/**
|
|
The parent route for all discovery routes. Handles the logic for showing
|
|
the loading spinners.
|
|
|
|
@class DiscoveryRoute
|
|
@extends Discourse.Route
|
|
@namespace Discourse
|
|
@module Discourse
|
|
**/
|
|
Discourse.DiscoveryRoute = Discourse.Route.extend(Discourse.OpenComposer, {
|
|
actions: {
|
|
loading: function() {
|
|
var controller = this.controllerFor('discovery');
|
|
|
|
// If we're already loading don't do anything
|
|
if (controller.get('loading')) { return; }
|
|
|
|
controller.set('loading', true);
|
|
controller.set('scheduledSpinner', Ember.run.later(controller, function() {
|
|
this.set('loadingSpinner', true);
|
|
},500));
|
|
},
|
|
|
|
loadingComplete: function() {
|
|
var controller = this.controllerFor('discovery');
|
|
Ember.run.cancel(controller.get('scheduledSpinner'));
|
|
controller.setProperties({ loading: false, loadingSpinner: false });
|
|
},
|
|
|
|
didTransition: function() {
|
|
this.send('loadingComplete');
|
|
},
|
|
|
|
// clear a pinned topic
|
|
clearPin: function(topic) {
|
|
topic.clearPin();
|
|
},
|
|
|
|
createTopic: function() {
|
|
this.openComposer(this.controllerFor('discoveryTopics'));
|
|
},
|
|
|
|
changeBulkTemplate: function(w) {
|
|
var controllerName = w.replace('modal/', ''),
|
|
factory = this.container.lookupFactory('controller:' + controllerName);
|
|
|
|
this.render(w, {into: 'topicBulkActions', outlet: 'bulkOutlet', controller: factory ? controllerName : 'topicBulkActions'});
|
|
},
|
|
|
|
showBulkActions: function() {
|
|
var selected = this.controllerFor('discoveryTopics').get('selected');
|
|
Discourse.Route.showModal(this, 'topicBulkActions', selected);
|
|
this.send('changeBulkTemplate', 'modal/bulk_actions_buttons');
|
|
}
|
|
}
|
|
|
|
});
|
|
|