mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Convert a lot of Globals to ES6 modules
This commit is contained in:
@@ -4,15 +4,8 @@
|
||||
@param hexValue is a reference to the color's hex value.
|
||||
@param brightnessValue is a number from 0 to 255 representing the brightness of the color. See ColorSchemeColor.
|
||||
@params valid is a boolean indicating if the input field is a valid color.
|
||||
|
||||
@class Discourse.ColorInputComponent
|
||||
@extends Ember.Component
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.ColorInputComponent = Ember.Component.extend({
|
||||
layoutName: 'components/color-input',
|
||||
|
||||
**/
|
||||
export default Ember.Component.extend({
|
||||
hexValueChanged: function() {
|
||||
var hex = this.get('hexValue');
|
||||
if (this.get('valid')) {
|
||||
@@ -22,11 +15,10 @@ Discourse.ColorInputComponent = Ember.Component.extend({
|
||||
}
|
||||
}.observes('hexValue', 'brightnessValue', 'valid'),
|
||||
|
||||
didInsertElement: function() {
|
||||
_triggerHexChanged: function() {
|
||||
var self = this;
|
||||
this._super();
|
||||
Em.run.schedule('afterRender', function() {
|
||||
self.hexValueChanged();
|
||||
});
|
||||
}
|
||||
}.on('didInsertElement')
|
||||
});
|
||||
@@ -3,16 +3,8 @@
|
||||
|
||||
@param settingValue is a reference to SiteSetting.value.
|
||||
@param choices is a reference to SiteSetting.choices
|
||||
|
||||
@class Discourse.ListSettingComponent
|
||||
@extends Ember.Component
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
|
||||
Discourse.ListSettingComponent = Ember.Component.extend({
|
||||
tagName: 'div',
|
||||
|
||||
**/
|
||||
export default Ember.Component.extend({
|
||||
|
||||
_select2FormatSelection: function(selectedObject, jqueryWrapper, htmlEscaper) {
|
||||
var text = selectedObject.text;
|
||||
@@ -22,9 +14,8 @@ Discourse.ListSettingComponent = Ember.Component.extend({
|
||||
return htmlEscaper(text);
|
||||
},
|
||||
|
||||
didInsertElement: function(){
|
||||
|
||||
var select2_options = {
|
||||
_initializeSelect2: function(){
|
||||
var options = {
|
||||
multiple: false,
|
||||
separator: "|",
|
||||
tokenSeparators: ["|"],
|
||||
@@ -35,24 +26,27 @@ Discourse.ListSettingComponent = Ember.Component.extend({
|
||||
|
||||
var settingName = this.get('settingName');
|
||||
if (typeof settingName === 'string' && settingName.indexOf('colors') > -1) {
|
||||
select2_options.formatSelection = this._select2FormatSelection;
|
||||
options.formatSelection = this._select2FormatSelection;
|
||||
}
|
||||
this.$("input").select2(select2_options).on("change", function(obj) {
|
||||
this.set("settingValue", obj.val.join("|"));
|
||||
this.refreshSortables();
|
||||
}.bind(this));
|
||||
|
||||
var self = this;
|
||||
this.$("input").select2(options).on("change", function(obj) {
|
||||
self.set("settingValue", obj.val.join("|"));
|
||||
self.refreshSortables();
|
||||
});
|
||||
|
||||
this.refreshSortables();
|
||||
},
|
||||
}.on('didInsertElement'),
|
||||
|
||||
refreshOnReset: function() {
|
||||
this.$("input").select2("val", this.get("settingValue").split("|"));
|
||||
}.observes("settingValue"),
|
||||
|
||||
refreshSortables: function() {
|
||||
var self = this;
|
||||
this.$("ul.select2-choices").sortable().on('sortupdate', function() {
|
||||
this.$("input").select2("onSortEnd");
|
||||
}.bind(this));
|
||||
self.$("input").select2("onSortEnd");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -53,12 +53,13 @@ export default Ember.ArrayController.extend({
|
||||
},
|
||||
|
||||
rejectUsers: function() {
|
||||
var maxPostAge = this.siteSettings.delete_user_max_post_age;
|
||||
var controller = this;
|
||||
Discourse.AdminUser.bulkReject(this.get('model').filterProperty('selected')).then(function(result){
|
||||
var message = I18n.t("admin.users.reject_successful", {count: result.success});
|
||||
if (result.failed > 0) {
|
||||
message += ' ' + I18n.t("admin.users.reject_failures", {count: result.failed});
|
||||
message += ' ' + I18n.t("admin.user.delete_forbidden", {count: Discourse.SiteSettings.delete_user_max_post_age});
|
||||
message += ' ' + I18n.t("admin.user.delete_forbidden", {count: maxPostAge});
|
||||
}
|
||||
bootbox.alert(message);
|
||||
controller._refreshUsers();
|
||||
|
||||
@@ -2,6 +2,6 @@ import DiscourseController from 'discourse/controllers/controller';
|
||||
|
||||
export default DiscourseController.extend({
|
||||
showBadges: function() {
|
||||
return this.get('currentUser.admin') && Discourse.SiteSettings.enable_badges;
|
||||
return this.get('currentUser.admin') && this.siteSettings.enable_badges;
|
||||
}.property()
|
||||
});
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
/**
|
||||
Handles the default admin route
|
||||
|
||||
@class AdminDashboardRoute
|
||||
@extends Discourse.Route
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
|
||||
export default Discourse.Route.extend({
|
||||
|
||||
setupController: function(c) {
|
||||
@@ -16,8 +7,9 @@ export default Discourse.Route.extend({
|
||||
fetchDashboardData: function(c) {
|
||||
if( !c.get('dashboardFetchedAt') || moment().subtract(30, 'minutes').toDate() > c.get('dashboardFetchedAt') ) {
|
||||
c.set('dashboardFetchedAt', new Date());
|
||||
var versionChecks = this.siteSettings.version_checks;
|
||||
Discourse.AdminDashboard.find().then(function(d) {
|
||||
if( Discourse.SiteSettings.version_checks ){
|
||||
if (versionChecks) {
|
||||
c.set('versionCheck', Discourse.VersionCheck.create(d.version_check));
|
||||
}
|
||||
_.each(d.reports,function(report){
|
||||
|
||||
Reference in New Issue
Block a user