Some javascript refactoring: Move markdown functions into their own classs, remove extraneous window. calls.

This commit is contained in:
Robin Ward 2013-03-05 14:52:35 -05:00
parent e2ead81818
commit 1416bc7475
18 changed files with 32 additions and 36 deletions

View file

@ -1,13 +1,13 @@
/**
Our data model for dealing with users from the admin section.
@class AdminUser
@class AdminUser
@extends Discourse.Model
@namespace Discourse
@module Discourse
**/
**/
Discourse.AdminUser = Discourse.Model.extend({
deleteAllPosts: function() {
this.set('can_delete_all_posts', false);
jQuery.ajax("/admin/users/" + (this.get('id')) + "/delete_all_posts", {type: 'PUT'});
@ -137,7 +137,7 @@ Discourse.AdminUser = Discourse.Model.extend({
});
window.Discourse.AdminUser.reopenClass({
Discourse.AdminUser.reopenClass({
bulkApprove: function(users) {
users.each(function(user) {

View file

@ -34,7 +34,7 @@ _getTransitionEndEventName = function() {
};
transitionEnd = _getTransitionEndEventName();
window.Discourse.TransitionHelper = {
Discourse.TransitionHelper = {
after: function(element, callback) {
return $(element).on(transitionEnd, callback);
}

View file

@ -6,9 +6,9 @@
@namespace Discourse
@module Discourse
**/
window.Discourse.CategoryList = Discourse.Model.extend({});
Discourse.CategoryList = Discourse.Model.extend({});
window.Discourse.CategoryList.reopenClass({
Discourse.CategoryList.reopenClass({
categoriesFrom: function(result) {
var categories, users;

View file

@ -6,6 +6,6 @@
@namespace Discourse
@module Discourse
**/
window.Discourse.InputValidation = Discourse.Model.extend({});
Discourse.InputValidation = Discourse.Model.extend({});

View file

@ -260,7 +260,7 @@ Discourse.Post = Discourse.Model.extend({
}).property('reply_count')
});
window.Discourse.Post.reopenClass({
Discourse.Post.reopenClass({
createActionSummary: function(result) {
var lookup;

View file

@ -343,7 +343,7 @@ Discourse.Topic = Discourse.Model.extend({
}
});
window.Discourse.Topic.reopenClass({
Discourse.Topic.reopenClass({
NotificationLevel: {
WATCHING: 3,
TRACKING: 2,

View file

@ -138,7 +138,7 @@ Discourse.UserAction.reopenClass({
GOT_PRIVATE_MESSAGE: 13
});
window.Discourse.UserAction.reopenClass({
Discourse.UserAction.reopenClass({
statGroups: (function() {
var g;
g = {};

View file

@ -6,7 +6,7 @@
@namespace Discourse
@module Discourse
**/
window.Discourse.ApplicationView = Discourse.View.extend({
Discourse.ApplicationView = Discourse.View.extend({
templateName: 'application'
});

View file

@ -6,7 +6,7 @@
@namespace Discourse
@module Discourse
**/
window.Discourse.FeaturedTopicsView = Discourse.View.extend({
Discourse.FeaturedTopicsView = Discourse.View.extend({
templateName: 'featured_topics',
classNames: ['category-list-item']
});

View file

@ -6,7 +6,7 @@
@namespace Discourse
@module Discourse
**/
window.Discourse.ListCategoriesView = Discourse.View.extend({
Discourse.ListCategoriesView = Discourse.View.extend({
templateName: 'list/categories',

View file

@ -6,7 +6,7 @@
@namespace Discourse
@module Discourse
**/
window.Discourse.ArchetypeOptionsModalView = window.Discourse.ModalBodyView.extend({
Discourse.ArchetypeOptionsModalView = Discourse.ModalBodyView.extend({
templateName: 'modal/archetype_options',
title: Em.String.i18n('topic.options')
});

View file

@ -6,7 +6,7 @@
@namespace Discourse
@module Discourse
**/
window.Discourse.SearchView = Discourse.View.extend({
Discourse.SearchView = Discourse.View.extend({
tagName: 'div',
classNames: ['d-dropdown'],
elementId: 'search-dropdown',

View file

@ -6,7 +6,7 @@
@namespace Discourse
@module Discourse
**/
window.Discourse.TopicAdminMenuView = Discourse.View.extend({
Discourse.TopicAdminMenuView = Discourse.View.extend({
willDestroyElement: function() {
$('html').off('mouseup.discourse-topic-admin-menu');

View file

@ -489,7 +489,7 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
}
});
window.Discourse.TopicView.reopenClass({
Discourse.TopicView.reopenClass({
// Scroll to a given post, if in the DOM. Returns whether it was in the DOM or not.
scrollTo: function(topicId, postNumber, callback) {
@ -504,11 +504,11 @@ window.Discourse.TopicView.reopenClass({
header = $('header');
title = $('#topic-title');
expectedOffset = title.height() - header.find('.contents').height();
if (expectedOffset < 0) {
expectedOffset = 0;
}
$('html, body').scrollTop(existing.offset().top - (header.outerHeight(true) + expectedOffset));
}
return true;

View file

@ -6,7 +6,7 @@
@namespace Discourse
@module Discourse
**/
window.Discourse.PreferencesEmailView = Discourse.View.extend({
Discourse.PreferencesEmailView = Discourse.View.extend({
templateName: 'user/email',
classNames: ['user-preferences'],
didInsertElement: function() {

View file

@ -7,4 +7,4 @@
@namespace Discourse
@module Discourse
**/
window.Discourse.View = Ember.View.extend(Discourse.Presence, {});
Discourse.View = Ember.View.extend(Discourse.Presence, {});

View file

@ -1,16 +1,12 @@
/* These will help us migrate up to the new ember's default behavior
*/
window.ENV = {
CP_DEFAULT_CACHEABLE: true,
VIEW_PRESERVES_CONTEXT: true,
MANDATORY_SETTER: false
};
window.Discourse = {};
window.Discourse.SiteSettings = {};
// These will help us migrate up to the new ember's default behavior
window.ENV = {
CP_DEFAULT_CACHEABLE: true,
VIEW_PRESERVES_CONTEXT: true,
MANDATORY_SETTER: false
};
window.Discourse = {};
Discourse.SiteSettings = {};

View file

@ -36,7 +36,7 @@
Discourse.CDN = '<%= Rails.configuration.action_controller.asset_host %>';
Discourse.BaseUrl = '<%= RailsMultisite::ConnectionManagement.current_hostname %>';
Discourse.Environment = '<%= Rails.env %>';
window.Discourse.Router.map(function() {
Discourse.Router.map(function() {
return Discourse.routeBuilder.call(this);
});
Discourse.start()