Revert "Remove old unused code."

This reverts commit 6a617348e5.
This commit is contained in:
Sam Saffron 2013-02-22 10:57:11 +11:00
parent 21cc9ab1ff
commit 2b5be29d3c
17 changed files with 162 additions and 108 deletions

View File

@ -1,7 +1,7 @@
(function() { (function() {
/** /**
Handles routes related to users in the admin section. Handles routes related to users.
@class AdminUserRoute @class AdminUserRoute
@extends Discourse.Route @extends Discourse.Route

View File

@ -5,11 +5,11 @@
A view that wraps the ACE editor (http://ace.ajax.org/) A view that wraps the ACE editor (http://ace.ajax.org/)
@class AceEditorView @class AceEditorView
@extends Em.View @extends Discourse.View
@namespace Discourse @namespace Discourse
@module Discourse @module Discourse
**/ **/
Discourse.AceEditorView = window.Em.View.extend({ Discourse.AceEditorView = window.Discourse.View.extend({
mode: 'css', mode: 'css',
classNames: ['ace-wrapper'], classNames: ['ace-wrapper'],

View File

@ -5,11 +5,11 @@
A view to handle site customizations A view to handle site customizations
@class AdminCustomizeView @class AdminCustomizeView
@extends Em.View @extends Discourse.View
@namespace Discourse @namespace Discourse
@module Discourse @module Discourse
**/ **/
Discourse.AdminCustomizeView = window.Em.View.extend({ Discourse.AdminCustomizeView = window.Discourse.View.extend({
templateName: 'admin/templates/customize', templateName: 'admin/templates/customize',
classNames: ['customize'], classNames: ['customize'],

View File

@ -4,11 +4,11 @@
The default view in the admin section The default view in the admin section
@class AdminDashboardView @class AdminDashboardView
@extends Em.View @extends Discourse.View
@namespace Discourse @namespace Discourse
@module Discourse @module Discourse
**/ **/
Discourse.AdminDashboardView = window.Em.View.extend({ Discourse.AdminDashboardView = window.Discourse.View.extend({
templateName: 'admin/templates/dashboard', templateName: 'admin/templates/dashboard',
updateIconClasses: function() { updateIconClasses: function() {

View File

@ -29,6 +29,7 @@
// Stuff we need to load first // Stuff we need to load first
//= require_tree ./discourse/mixins //= require_tree ./discourse/mixins
//= require ./discourse/components/debounce //= require ./discourse/components/debounce
//= require ./discourse/views/view
//= require ./discourse/controllers/controller //= require ./discourse/controllers/controller
//= require ./discourse/views/modal/modal_body_view //= require ./discourse/views/modal/modal_body_view
//= require ./discourse/models/model //= require ./discourse/models/model

View File

@ -1,41 +1,30 @@
(function() { (function() {
/**
A base object we can use to handle models in the Discourse client application.
@class Model
@extends Ember.Object
@namespace Discourse
@module Discourse
**/
window.Discourse.Model = Ember.Object.extend({ window.Discourse.Model = Ember.Object.extend({
/* Our own AJAX handler that handles erronous responses
*/
/**
Our own AJAX handler that handles erronous responses
@method ajax
@param {String} url The url to contact
@param {Object} args The arguments to pass to jQuery.ajax
**/
ajax: function(url, args) { ajax: function(url, args) {
var oldError = args.error; /* Error handler
*/
var oldError,
_this = this;
oldError = args.error;
args.error = function(xhr) { args.error = function(xhr) {
return oldError(jQuery.parseJSON(xhr.responseText).errors); return oldError(jQuery.parseJSON(xhr.responseText).errors);
}; };
return jQuery.ajax(url, args); return jQuery.ajax(url, args);
}, },
/* Update our object from another object
*/
/**
Update our object from another object
@method mergeAttributes
@param {Object} attrs The attributes we want to merge with
@param {Object} builders Optional builders to use when merging attributes
**/
mergeAttributes: function(attrs, builders) { mergeAttributes: function(attrs, builders) {
var _this = this; var _this = this;
return Object.keys(attrs, function(k, v) { return Object.keys(attrs, function(k, v) {
// If they're in a builder we use that /* If they're in a builder we use that
*/
var builder, col; var builder, col;
if (typeof v === 'object' && builders && (builder = builders[k])) { if (typeof v === 'object' && builders && (builder = builders[k])) {
if (!_this.get(k)) { if (!_this.get(k)) {
@ -53,14 +42,9 @@
}); });
window.Discourse.Model.reopenClass({ window.Discourse.Model.reopenClass({
/* Given an array of values, return them in a hash
*/
/**
Given an array of values, return them in a hash
@method extractByKey
@param {Object} collection The collection of values
@param {Object} klass Optional The class to instantiate
**/
extractByKey: function(collection, klass) { extractByKey: function(collection, klass) {
var retval; var retval;
retval = {}; retval = {};

View File

@ -1,49 +1,93 @@
/* Ways we can filter the topics list
*/
(function() { (function() {
Discourse.buildRoutes(function() { Discourse.buildRoutes(function() {
var router = this; var router;
this.resource('topic', {
// Topic routes path: '/t/:slug/:id'
this.resource('topic', { path: '/t/:slug/:id' }, function() { }, function() {
this.route('fromParams', { path: '/' }); this.route('fromParams', {
this.route('fromParams', { path: '/:nearPost' }); path: '/'
this.route('bestOf', { path: '/best_of' }); });
this.route('fromParams', {
path: '/:nearPost'
});
return this.route('bestOf', {
path: '/best_of'
});
}); });
/* Generate static page routes
*/
// Generate static page routes router = this;
Discourse.StaticController.pages.forEach(function(p) { Discourse.StaticController.pages.forEach(function(p) {
router.route(p, { path: "/" + p }); return router.route(p, {
path: "/" + p
});
}); });
this.route('faq', {
this.route('faq', { path: '/faq' }); path: '/faq'
this.route('tos', { path: '/tos' }); });
this.route('privacy', { path: '/privacy' }); this.route('tos', {
path: '/tos'
// List routes });
this.resource('list', { path: '/' }, function() { this.route('privacy', {
path: '/privacy'
});
this.resource('list', {
path: '/'
}, function() {
router = this; router = this;
/* Generate routes for all our filters
*/
// Generate routes for all our filters
Discourse.ListController.filters.forEach(function(r) { Discourse.ListController.filters.forEach(function(r) {
router.route(r, { path: "/" + r }); router.route(r, {
router.route(r, { path: "/" + r + "/more" }); path: "/" + r
});
return router.route(r, {
path: "/" + r + "/more"
});
});
router.route('popular', {
path: '/'
});
router.route('categories', {
path: '/categories'
});
router.route('category', {
path: '/category/:slug/more'
});
return router.route('category', {
path: '/category/:slug'
}); });
this.route('popular', { path: '/' });
this.route('categories', { path: '/categories' });
this.route('category', { path: '/category/:slug/more' });
this.route('category', { path: '/category/:slug' });
}); });
return this.resource('user', {
// User routes path: '/users/:username'
this.resource('user', { path: '/users/:username' }, function() { }, function() {
this.route('activity', { path: '/' }); this.route('activity', {
this.resource('preferences', { path: '/preferences' }, function() { path: '/'
this.route('username', { path: '/username' }); });
this.route('email', { path: '/email' }); this.resource('preferences', {
path: '/preferences'
}, function() {
this.route('username', {
path: '/username'
});
return this.route('email', {
path: '/email'
});
});
this.route('privateMessages', {
path: '/private-messages'
});
return this.route('invited', {
path: 'invited'
}); });
this.route('privateMessages', { path: '/private-messages' });
this.route('invited', { path: 'invited' });
}); });
}); });

View File

@ -1,31 +1,49 @@
(function() { (function() {
/** window.Discourse.Route = Em.Route.extend({
The base admin route for all routes on Discourse. Includes global enter functionality. /* Called every time we enter a route
*/
@class Route
@extends Em.Route
@namespace Discourse
@module Discourse
**/
Discourse.Route = Em.Route.extend({
/**
Called every time we enter a route on Discourse.
@method enter
**/
enter: function(router, context) { enter: function(router, context) {
// Close mini profiler /* Close mini profiler
jQuery('.profiler-results .profiler-result').remove(); */
var composerController, f, search, shareController;
jQuery('.profiler-results .profiler-result').remove();
/* Close stuff that may be open
*/
// Close some elements that may be open
jQuery('.d-dropdown').hide(); jQuery('.d-dropdown').hide();
jQuery('header ul.icons li').removeClass('active'); jQuery('header ul.icons li').removeClass('active');
jQuery('[data-toggle="dropdown"]').parent().removeClass('open'); jQuery('[data-toggle="dropdown"]').parent().removeClass('open');
/* TODO: need to adjust these
*/
if (false) {
if (shareController = router.get('shareController')) {
shareController.close();
}
/* Hide any searches
*/
if (search = router.get('searchController')) {
search.close();
}
/* get rid of "save as draft stuff"
*/
composerController = Discourse.get('router.composerController');
if (composerController) {
composerController.closeIfCollapsed();
}
}
f = jQuery('html').data('hide-dropdown');
if (f) {
return f();
}
/*return @_super(router, context)
*/
var hideDropDownFunction = jQuery('html').data('hide-dropdown');
if (hideDropDownFunction) return hideDropDownFunction();
} }
}); });

View File

@ -1,20 +1,13 @@
(function() { (function() {
/** window.Discourse.UserRoute = Discourse.Route.extend({
Handles routes related to users.
@class UserRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.UserRoute = Discourse.Route.extend({
model: function(params) { model: function(params) {
return Discourse.User.find(params.username); return Discourse.User.find(params.username);
}, },
serialize: function(params) { serialize: function(params) {
return { username: Em.get(params, 'username').toLowerCase() }; return {
username: Em.get(params, 'username').toLowerCase()
};
} }
}); });

View File

@ -1,7 +1,7 @@
/*global Markdown:true assetPath:true */ /*global Markdown:true assetPath:true */
(function() { (function() {
window.Discourse.ComposerView = window.Em.View.extend({ window.Discourse.ComposerView = window.Discourse.View.extend({
templateName: 'composer', templateName: 'composer',
elementId: 'reply-control', elementId: 'reply-control',
classNameBindings: ['content.creatingPrivateMessage:private-message', classNameBindings: ['content.creatingPrivateMessage:private-message',

View File

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.ModalBodyView = window.Em.View.extend({ window.Discourse.ModalBodyView = window.Discourse.View.extend({
// Focus on first element // Focus on first element
didInsertElement: function() { didInsertElement: function() {
var _this = this; var _this = this;

View File

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.QuoteButtonView = Em.View.extend({ window.Discourse.QuoteButtonView = Discourse.View.extend({
classNames: ['quote-button'], classNames: ['quote-button'],
classNameBindings: ['hasBuffer'], classNameBindings: ['hasBuffer'],
render: function(buffer) { render: function(buffer) {

View File

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.ShareView = Em.View.extend({ window.Discourse.ShareView = Discourse.View.extend({
templateName: 'share', templateName: 'share',
elementId: 'share-link', elementId: 'share-link',
classNameBindings: ['hasLink'], classNameBindings: ['hasLink'],

View File

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.TopicStatusView = Em.View.extend({ window.Discourse.TopicStatusView = Discourse.View.extend({
classNames: ['topic-statuses'], classNames: ['topic-statuses'],
hasDisplayableStatus: (function() { hasDisplayableStatus: (function() {
if (this.get('topic.closed')) { if (this.get('topic.closed')) {

View File

@ -66,7 +66,7 @@
/* If we have a best of view /* If we have a best of view
*/ */
if (this.get('controller.showBestOf')) { if (this.get('controller.showBestOf')) {
container.pushObject(Em.View.create({ container.pushObject(Discourse.View.create({
templateName: 'topic_summary/best_of_toggle', templateName: 'topic_summary/best_of_toggle',
tagName: 'section', tagName: 'section',
classNames: ['information'] classNames: ['information']
@ -76,7 +76,7 @@
*/ */
if (this.get('topic.isPrivateMessage')) { if (this.get('topic.isPrivateMessage')) {
return container.pushObject(Em.View.create({ return container.pushObject(Discourse.View.create({
templateName: 'topic_summary/private_message', templateName: 'topic_summary/private_message',
tagName: 'section', tagName: 'section',
classNames: ['information'] classNames: ['information']

View File

@ -0,0 +1,13 @@
(function() {
window.Discourse.View = Ember.View.extend(Discourse.Presence, {
/* Overwrite this to do a different display
*/
displayErrors: function(errors, callback) {
alert(errors.join("\n"));
return typeof callback === "function" ? callback() : void 0;
}
});
}).call(this);

View File

@ -26,6 +26,7 @@
// Stuff we need to load first // Stuff we need to load first
//= require_tree ../../app/assets/javascripts/discourse/mixins //= require_tree ../../app/assets/javascripts/discourse/mixins
//= require ../../app/assets/javascripts/discourse/components/debounce //= require ../../app/assets/javascripts/discourse/components/debounce
//= require ../../app/assets/javascripts/discourse/views/view
//= require ../../app/assets/javascripts/discourse/controllers/controller //= require ../../app/assets/javascripts/discourse/controllers/controller
//= require ../../app/assets/javascripts/discourse/views/modal/modal_body_view //= require ../../app/assets/javascripts/discourse/views/modal/modal_body_view
//= require ../../app/assets/javascripts/discourse/models/model //= require ../../app/assets/javascripts/discourse/models/model