Skip to content

Commit fa8a84f

Browse files
committed
removed sugar.js, port functionality to moment and underscore.js
bring in latest ace from local so we don't mess up with https
1 parent eed5875 commit fa8a84f

211 files changed

Lines changed: 1773 additions & 8914 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/assets/javascripts/admin/controllers/admin_dashboard_controller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Discourse.AdminDashboardController = Ember.Controller.extend({
1010
loading: true,
1111
versionCheck: null,
12-
problemsCheckInterval: '1 minute ago',
12+
problemsCheckMinutes: 1,
1313

1414
foundProblems: function() {
1515
return(Discourse.User.current('admin') && this.get('problems') && this.get('problems').length > 0);
@@ -33,9 +33,9 @@ Discourse.AdminDashboardController = Ember.Controller.extend({
3333
c.set('problems', d.problems);
3434
c.set('loadingProblems', false);
3535
if( d.problems && d.problems.length > 0 ) {
36-
c.problemsCheckInterval = '1 minute ago';
36+
c.problemsCheckInterval = 1;
3737
} else {
38-
c.problemsCheckInterval = '10 minutes ago';
38+
c.problemsCheckInterval = 10;
3939
}
4040
});
4141
},

app/assets/javascripts/admin/controllers/admin_users_list_controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Discourse.AdminUsersListController = Ember.ArrayController.extend(Discourse.Pres
2020
**/
2121
selectAllChanged: function() {
2222
var _this = this;
23-
this.get('content').each(function(user) {
23+
_.each(this.get('content'),function(user) {
2424
user.set('selected', _this.get('selectAll'));
2525
});
2626
}.observes('selectAll'),

app/assets/javascripts/admin/models/admin_user.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ Discourse.AdminUser = Discourse.User.extend({
7676
}).property('admin', 'moderator'),
7777

7878
banDuration: (function() {
79-
var banned_at = Date.create(this.banned_at);
80-
var banned_till = Date.create(this.banned_till);
81-
return banned_at.short() + " - " + banned_till.short();
79+
var banned_at = moment(this.banned_at);
80+
var banned_till = moment(this.banned_till);
81+
return banned_at.format('L') + " - " + banned_till.format('L');
8282
}).property('banned_till', 'banned_at'),
8383

8484
ban: function() {

app/assets/javascripts/admin/models/email_log.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Discourse.EmailLog.reopenClass({
2121
Discourse.ajax("/admin/email/logs.json", {
2222
data: { filter: filter }
2323
}).then(function(logs) {
24-
logs.each(function(log) {
24+
_.each(logs,function(log) {
2525
result.pushObject(Discourse.EmailLog.create(log));
2626
});
2727
});

app/assets/javascripts/admin/models/flagged_post.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Discourse.FlaggedPost = Discourse.Post.extend({
1212
var r,
1313
_this = this;
1414
r = [];
15-
this.post_actions.each(function(a) {
16-
return r.push(_this.userLookup[a.user_id]);
15+
_.each(this.post_actions, function(action) {
16+
r.push(_this.userLookup[action.user_id]);
1717
});
1818
return r;
1919
}.property(),
@@ -22,12 +22,12 @@ Discourse.FlaggedPost = Discourse.Post.extend({
2222
var r,
2323
_this = this;
2424
r = [];
25-
this.post_actions.each(function(a) {
26-
if (a.message) {
27-
return r.push({
28-
user: _this.userLookup[a.user_id],
29-
message: a.message,
30-
permalink: a.permalink
25+
_.each(this.post_actions,function(action) {
26+
if (action.message) {
27+
r.push({
28+
user: _this.userLookup[action.user_id],
29+
message: action.message,
30+
permalink: action.permalink
3131
});
3232
}
3333
});
@@ -69,11 +69,11 @@ Discourse.FlaggedPost.reopenClass({
6969
result.set('loading', true);
7070
Discourse.ajax("/admin/flags/" + filter + ".json").then(function(data) {
7171
var userLookup = {};
72-
data.users.each(function(u) {
73-
userLookup[u.id] = Discourse.User.create(u);
72+
_.each(data.users,function(user) {
73+
userLookup[user.id] = Discourse.User.create(user);
7474
});
75-
data.posts.each(function(p) {
76-
var f = Discourse.FlaggedPost.create(p);
75+
_.each(data.posts,function(post) {
76+
var f = Discourse.FlaggedPost.create(post);
7777
f.userLookup = userLookup;
7878
result.pushObject(f);
7979
});

app/assets/javascripts/admin/models/github_commit.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Discourse.GithubCommit = Discourse.Model.extend({
2020
}.property("sha"),
2121

2222
timeAgo: function() {
23-
return Date.create(this.get('commit.committer.date')).relative();
23+
return Discourse.Formatter.relativeAge(new Date(this.get('commit.committer.date'), {format: 'medium', leaveAgo: true}));
2424
}.property("commit.committer.date")
2525
});
2626

@@ -32,10 +32,10 @@ Discourse.GithubCommit.reopenClass({
3232
type: 'get',
3333
data: { per_page: 40 }
3434
}).then(function (response) {
35-
response.data.each(function(commit) {
35+
_.each(response.data,function(commit) {
3636
result.pushObject( Discourse.GithubCommit.create(commit) );
3737
});
3838
});
3939
return result;
4040
}
41-
});
41+
});

app/assets/javascripts/admin/models/group.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Discourse.Group = Discourse.Model.extend({
1515
var group = this;
1616
Discourse.ajax('/admin/groups/' + this.get('id') + '/users').then(function(payload){
1717
var users = Em.A()
18-
payload.each(function(user){
18+
_.each(payload,function(user){
1919
users.addObject(Discourse.User.create(user));
2020
});
2121
group.set('users', users)
@@ -28,7 +28,7 @@ Discourse.Group = Discourse.Model.extend({
2828
var users = this.get('users');
2929
var usernames = "";
3030
if(users) {
31-
usernames = $.map(users, function(user){
31+
usernames = _.map(users, function(user){
3232
return user.get('username');
3333
}).join(',')
3434
}
@@ -82,7 +82,7 @@ Discourse.Group.reopenClass({
8282
var list = Discourse.SelectableArray.create();
8383

8484
Discourse.ajax("/admin/groups.json").then(function(groups){
85-
groups.each(function(group){
85+
_.each(groups,function(group){
8686
list.addObject(Discourse.Group.create(group));
8787
});
8888
});

app/assets/javascripts/admin/models/report.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Discourse.Report = Discourse.Model.extend({
55

66
valueAt: function(numDaysAgo) {
77
if (this.data) {
8-
var wantedDate = Date.create(numDaysAgo + ' days ago', 'en').format('{yyyy}-{MM}-{dd}');
8+
var wantedDate = moment().subtract('days', numDaysAgo).format('YYYY-MM-DD');
99
var item = this.data.find( function(d, i, arr) { return d.x === wantedDate; } );
1010
if (item) {
1111
return item.y;
@@ -16,11 +16,11 @@ Discourse.Report = Discourse.Model.extend({
1616

1717
sumDays: function(startDaysAgo, endDaysAgo) {
1818
if (this.data) {
19-
var earliestDate = Date.create(endDaysAgo + ' days ago', 'en').beginningOfDay();
20-
var latestDate = Date.create(startDaysAgo + ' days ago', 'en').beginningOfDay();
19+
var earliestDate = moment().subtract('days', endDaysAgo).startOf('day');
20+
var latestDate = moment().subtract('days',startDaysAgo).startOf('day');
2121
var d, sum = 0;
22-
this.data.each(function(datum){
23-
d = Date.create(datum.x);
22+
_.each(this.data,function(datum){
23+
d = moment(datum.x);
2424
if(d >= earliestDate && d <= latestDate) {
2525
sum += datum.y;
2626
}

app/assets/javascripts/admin/models/site_customization.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Discourse.SiteCustomization = Discourse.Model.extend({
2323
var _this = this;
2424
if(!this.originals) return false;
2525

26-
var changed = this.trackedProperties.any(function(p) {
26+
var changed = _.some(this.trackedProperties,function(p) {
2727
return _this.originals[p] !== _this.get(p);
2828
});
2929

@@ -38,8 +38,8 @@ Discourse.SiteCustomization = Discourse.Model.extend({
3838
startTrackingChanges: function() {
3939
var _this = this;
4040
var originals = {};
41-
this.trackedProperties.each(function(p) {
42-
originals[p] = _this.get(p);
41+
_.each(this.trackedProperties,function(prop) {
42+
originals[prop] = _this.get(prop);
4343
return true;
4444
});
4545
this.set('originals', originals);
@@ -90,7 +90,7 @@ Discourse.SiteCustomization = Discourse.Model.extend({
9090
var SiteCustomizations = Ember.ArrayProxy.extend({
9191
selectedItemChanged: function() {
9292
var selected = this.get('selectedItem');
93-
return this.get('content').each(function(i) {
93+
_.each(this.get('content'),function(i) {
9494
return i.set('selected', selected === i);
9595
});
9696
}.observes('selectedItem')
@@ -101,7 +101,7 @@ Discourse.SiteCustomization.reopenClass({
101101
var customizations = SiteCustomizations.create({ content: [], loading: true });
102102
Discourse.ajax("/admin/site_customizations").then(function (data) {
103103
if (data) {
104-
data.site_customizations.each(function(c) {
104+
_.each(data.site_customizations,function(c) {
105105
customizations.pushObject(Discourse.SiteCustomization.create(c.site_customizations));
106106
});
107107
}

app/assets/javascripts/admin/models/site_setting.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Discourse.SiteSetting.reopenClass({
9191
findAll: function() {
9292
var result = Em.A();
9393
Discourse.ajax("/admin/site_settings").then(function (settings) {
94-
settings.site_settings.each(function(s) {
94+
_.each(settings.site_settings,function(s) {
9595
s.originalValue = s.value;
9696
result.pushObject(Discourse.SiteSetting.create(s));
9797
});

0 commit comments

Comments
 (0)