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() {
/**
Handles routes related to users in the admin section.
Handles routes related to users.
@class AdminUserRoute
@extends Discourse.Route

View file

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

View file

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

View file

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

View file

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

View file

@ -1,41 +1,30 @@
(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({
/* 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) {
var oldError = args.error;
/* Error handler
*/
var oldError,
_this = this;
oldError = args.error;
args.error = function(xhr) {
return oldError(jQuery.parseJSON(xhr.responseText).errors);
};
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) {
var _this = this;
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;
if (typeof v === 'object' && builders && (builder = builders[k])) {
if (!_this.get(k)) {
@ -53,14 +42,9 @@
});
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) {
var retval;
retval = {};

View file

@ -1,49 +1,93 @@
/* Ways we can filter the topics list
*/
(function() {
Discourse.buildRoutes(function() {
var router = this;
// Topic routes
this.resource('topic', { path: '/t/:slug/:id' }, function() {
this.route('fromParams', { path: '/' });
this.route('fromParams', { path: '/:nearPost' });
this.route('bestOf', { path: '/best_of' });
var router;
this.resource('topic', {
path: '/t/:slug/:id'
}, function() {
this.route('fromParams', {
path: '/'
});
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) {
router.route(p, { path: "/" + p });
return router.route(p, {
path: "/" + p
});
});
this.route('faq', { path: '/faq' });
this.route('tos', { path: '/tos' });
this.route('privacy', { path: '/privacy' });
// List routes
this.resource('list', { path: '/' }, function() {
this.route('faq', {
path: '/faq'
});
this.route('tos', {
path: '/tos'
});
this.route('privacy', {
path: '/privacy'
});
this.resource('list', {
path: '/'
}, function() {
router = this;
/* Generate routes for all our filters
*/
// Generate routes for all our filters
Discourse.ListController.filters.forEach(function(r) {
router.route(r, { path: "/" + r });
router.route(r, { path: "/" + r + "/more" });
router.route(r, {
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' });
});
// User routes
this.resource('user', { path: '/users/:username' }, function() {
this.route('activity', { path: '/' });
this.resource('preferences', { path: '/preferences' }, function() {
this.route('username', { path: '/username' });
this.route('email', { path: '/email' });
return this.resource('user', {
path: '/users/:username'
}, function() {
this.route('activity', {
path: '/'
});
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() {
/**
The base admin route for all routes on Discourse. Includes global enter functionality.
window.Discourse.Route = Em.Route.extend({
/* 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) {
// Close mini profiler
jQuery('.profiler-results .profiler-result').remove();
/* Close mini profiler
*/
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('header ul.icons li').removeClass('active');
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() {
/**
Handles routes related to users.
@class UserRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.UserRoute = Discourse.Route.extend({
window.Discourse.UserRoute = Discourse.Route.extend({
model: function(params) {
return Discourse.User.find(params.username);
},
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 */
(function() {
window.Discourse.ComposerView = window.Em.View.extend({
window.Discourse.ComposerView = window.Discourse.View.extend({
templateName: 'composer',
elementId: 'reply-control',
classNameBindings: ['content.creatingPrivateMessage:private-message',

View file

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

View file

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

View file

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

View file

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

View file

@ -66,7 +66,7 @@
/* If we have a best of view
*/
if (this.get('controller.showBestOf')) {
container.pushObject(Em.View.create({
container.pushObject(Discourse.View.create({
templateName: 'topic_summary/best_of_toggle',
tagName: 'section',
classNames: ['information']
@ -76,7 +76,7 @@
*/
if (this.get('topic.isPrivateMessage')) {
return container.pushObject(Em.View.create({
return container.pushObject(Discourse.View.create({
templateName: 'topic_summary/private_message',
tagName: 'section',
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
//= require_tree ../../app/assets/javascripts/discourse/mixins
//= 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/views/modal/modal_body_view
//= require ../../app/assets/javascripts/discourse/models/model