JS refactoring that fixes presence errors in earlier reverted commit.

This commit is contained in:
Robin Ward 2013-02-22 10:20:23 -05:00
parent 6347cbe275
commit 45ab3ab892
74 changed files with 207 additions and 221 deletions

@ -8,7 +8,7 @@
@namespace Discourse @namespace Discourse
@module Discourse @module Discourse
**/ **/
window.Discourse.SiteSetting = Discourse.Model.extend(Discourse.Presence, { window.Discourse.SiteSetting = Discourse.Model.extend({
// Whether a property is short. // Whether a property is short.
short: (function() { short: (function() {

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

@ -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 Discourse.View @extends Em.View
@namespace Discourse @namespace Discourse
@module Discourse @module Discourse
**/ **/
Discourse.AceEditorView = window.Discourse.View.extend({ Discourse.AceEditorView = Discourse.View.extend({
mode: 'css', mode: 'css',
classNames: ['ace-wrapper'], classNames: ['ace-wrapper'],

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

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

@ -28,8 +28,8 @@
// 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/views/view //= require ./discourse/views/view
//= require ./discourse/components/debounce
//= 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

@ -27,7 +27,7 @@
Ember.Handlebars.registerHelper('countI18n', function(key, options) { Ember.Handlebars.registerHelper('countI18n', function(key, options) {
var view; var view;
view = Em.View.extend({ view = Discourse.View.extend({
tagName: 'span', tagName: 'span',
render: function(buffer) { render: function(buffer) {
return buffer.push(Ember.String.i18n(key, { return buffer.push(Ember.String.i18n(key, {

@ -1,15 +1,29 @@
(function() { (function() {
window.Discourse.Presence = Em.Mixin.create({ /**
/* Is a property blank? This mixin provides `blank` and `present` to determine whether properties are
*/ there, accounting for more cases than just null and undefined.
@class Discourse.Presence
@extends Ember.Mixin
@namespace Discourse
@module Discourse
**/
window.Discourse.Presence = Em.Mixin.create({
/**
Returns whether a property is blank. It considers empty arrays, string, objects, undefined and null
to be blank, otherwise true.
@method blank
@param {String} name the name of the property we want to check
@return {Boolean}
*/
blank: function(name) { blank: function(name) {
var prop; var prop;
prop = this.get(name); prop = this.get(name);
if (!prop) { if (!prop) return true;
return true;
}
switch (typeof prop) { switch (typeof prop) {
case "string": case "string":
return prop.trim().isBlank(); return prop.trim().isBlank();
@ -18,6 +32,14 @@
} }
return false; return false;
}, },
/**
Returns whether a property is present. A present property is the opposite of a `blank` one.
@method present
@param {String} name the name of the property we want to check
@return {Boolean}
*/
present: function(name) { present: function(name) {
return !this.blank(name); return !this.blank(name);
} }

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.ActionSummary = Em.Object.extend(Discourse.Presence, { window.Discourse.ActionSummary = Discourse.Model.extend({
/* Description for the action /* Description for the action
*/ */

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.InviteList = Discourse.Model.extend(Discourse.Presence, { window.Discourse.InviteList = Discourse.Model.extend({
empty: (function() { empty: (function() {
return this.blank('pending') && this.blank('redeemed'); return this.blank('pending') && this.blank('redeemed');
}).property('pending.@each', 'redeemed.@each') }).property('pending.@each', 'redeemed.@each')

@ -1,30 +1,42 @@
(function() { (function() {
window.Discourse.Model = Ember.Object.extend({ /**
/* Our own AJAX handler that handles erronous responses A base object we can use to handle models in the Discourse client application.
*/
@class Model
@extends Ember.Object
@uses Discourse.Presence
@namespace Discourse
@module Discourse
**/
window.Discourse.Model = Ember.Object.extend(Discourse.Presence, {
/**
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) {
/* Error handler var oldError = args.error;
*/
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)) {
@ -42,9 +54,14 @@
}); });
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 = {};

@ -10,7 +10,7 @@
validAnon = ['popular', 'category', 'categories']; validAnon = ['popular', 'category', 'categories'];
window.Discourse.NavItem = Em.Object.extend({ window.Discourse.NavItem = Discourse.Model.extend({
categoryName: (function() { categoryName: (function() {
var split; var split;
split = this.get('name').split('/'); split = this.get('name').split('/');

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.Notification = Discourse.Model.extend(Discourse.Presence, { window.Discourse.Notification = Discourse.Model.extend({
readClass: (function() { readClass: (function() {
if (this.read) { if (this.read) {
return 'read'; return 'read';

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.Post = Ember.Object.extend(Discourse.Presence, { window.Discourse.Post = Discourse.Model.extend({
/* Url to this post /* Url to this post
*/ */

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.PostActionType = Em.Object.extend({ window.Discourse.PostActionType = Discourse.Model.extend({
alsoName: (function() { alsoName: (function() {
if (this.get('is_flag')) { if (this.get('is_flag')) {
return Em.String.i18n('post.actions.flag'); return Em.String.i18n('post.actions.flag');

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.Site = Ember.Object.extend({ window.Discourse.Site = Discourse.Model.extend({
notificationLookup: (function() { notificationLookup: (function() {
var result; var result;
result = []; result = [];

@ -1,6 +1,6 @@
(function() { (function() {
Discourse.Topic = Discourse.Model.extend(Discourse.Presence, { Discourse.Topic = Discourse.Model.extend({
categoriesBinding: 'Discourse.site.categories', categoriesBinding: 'Discourse.site.categories',
fewParticipants: (function() { fewParticipants: (function() {
if (!this.present('participants')) { if (!this.present('participants')) {

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.User = Discourse.Model.extend(Discourse.Presence, { window.Discourse.User = Discourse.Model.extend({
avatarLarge: (function() { avatarLarge: (function() {
return Discourse.Utilities.avatarUrl(this.get('username'), 'large', this.get('avatar_template')); return Discourse.Utilities.avatarUrl(this.get('username'), 'large', this.get('avatar_template'));
}).property('username'), }).property('username'),

@ -1,93 +1,49 @@
/* Ways we can filter the topics list
*/
(function() { (function() {
Discourse.buildRoutes(function() { Discourse.buildRoutes(function() {
var router; var router = this;
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
*/
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' });
});
// Generate static page routes
Discourse.StaticController.pages.forEach(function(p) { Discourse.StaticController.pages.forEach(function(p) {
return router.route(p, { router.route(p, { path: "/" + p });
path: "/" + p
});
}); });
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
*/
this.route('faq', { path: '/faq' });
this.route('tos', { path: '/tos' });
this.route('privacy', { path: '/privacy' });
// List routes
this.resource('list', { path: '/' }, function() {
router = this;
// Generate routes for all our filters
Discourse.ListController.filters.forEach(function(r) { Discourse.ListController.filters.forEach(function(r) {
router.route(r, { router.route(r, { path: "/" + r });
path: "/" + r router.route(r, { path: "/" + r + "/more" });
});
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', {
path: '/users/:username' // User routes
}, function() { this.resource('user', { path: '/users/:username' }, function() {
this.route('activity', { this.route('activity', { path: '/' });
path: '/' this.resource('preferences', { path: '/preferences' }, function() {
}); this.route('username', { path: '/username' });
this.resource('preferences', { this.route('email', { path: '/email' });
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' });
}); });
}); });

@ -1,49 +1,31 @@
(function() { (function() {
window.Discourse.Route = Em.Route.extend({ /**
/* Called every time we enter a route The base admin route for all routes on Discourse. Includes global enter functionality.
*/
@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
*/
var composerController, f, search, shareController;
jQuery('.profiler-results .profiler-result').remove(); 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();
} }
}); });

@ -1,13 +1,20 @@
(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 { return { username: Em.get(params, 'username').toLowerCase() };
username: Em.get(params, 'username').toLowerCase()
};
} }
}); });

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.ActionsHistoryView = Em.View.extend(Discourse.Presence, { window.Discourse.ActionsHistoryView = Discourse.View.extend({
tagName: 'section', tagName: 'section',
classNameBindings: [':post-actions', 'hidden'], classNameBindings: [':post-actions', 'hidden'],
hidden: (function() { hidden: (function() {

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.ApplicationView = Ember.View.extend({ window.Discourse.ApplicationView = Discourse.View.extend({
templateName: 'application' templateName: 'application'
}); });

@ -1,6 +1,6 @@
(function() { (function() {
Discourse.AutoSizedTextView = Ember.View.extend({ Discourse.AutoSizedTextView = Discourse.View.extend({
render: function(buffer) { render: function(buffer) {
return null; return null;
}, },

@ -1,6 +1,6 @@
(function() { (function() {
Discourse.ButtonView = Ember.View.extend(Discourse.Presence, { Discourse.ButtonView = Discourse.View.extend({
tagName: 'button', tagName: 'button',
classNameBindings: [':btn', ':standard', 'dropDownToggle'], classNameBindings: [':btn', ':standard', 'dropDownToggle'],
attributeBindings: ['data-not-implemented', 'title', 'data-toggle', 'data-share-url'], attributeBindings: ['data-not-implemented', 'title', 'data-toggle', 'data-share-url'],

@ -1,6 +1,6 @@
(function() { (function() {
Discourse.ComboboxView = window.Ember.View.extend({ Discourse.ComboboxView = Discourse.View.extend({
tagName: 'select', tagName: 'select',
classNames: ['combobox'], classNames: ['combobox'],
valueAttribute: 'id', valueAttribute: 'id',

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

@ -1,6 +1,6 @@
(function() { (function() {
Discourse.DropdownButtonView = Ember.View.extend(Discourse.Presence, { Discourse.DropdownButtonView = Discourse.View.extend({
classNames: ['btn-group'], classNames: ['btn-group'],
attributeBindings: ['data-not-implemented'], attributeBindings: ['data-not-implemented'],
didInsertElement: function(e) { didInsertElement: function(e) {

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.EmbeddedPostView = Ember.View.extend({ window.Discourse.EmbeddedPostView = Discourse.View.extend({
templateName: 'embedded_post', templateName: 'embedded_post',
classNames: ['reply'], classNames: ['reply'],
didInsertElement: function() { didInsertElement: function() {

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.ExcerptCategoryView = Ember.View.extend({ window.Discourse.ExcerptCategoryView = Discourse.View.extend({
editCategory: function() { editCategory: function() {
var cat, _ref; var cat, _ref;
this.get('parentView').close(); this.get('parentView').close();

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.ExcerptPostView = Ember.View.extend({ window.Discourse.ExcerptPostView = Discourse.View.extend({
mute: function() { mute: function() {
return this.update(true); return this.update(true);
}, },

@ -1,10 +1,10 @@
(function() { (function() {
window.Discourse.ExcerptUserView = Ember.View.extend({ window.Discourse.ExcerptUserView = Discourse.View.extend({
privateMessage: function(e) { privateMessage: function(e) {
var $target, composerController, post, postView, url, username; var $target, composerController, post, postView, url, username;
$target = this.get("link"); $target = this.get("link");
postView = Ember.View.views[$target.closest('.ember-view')[0].id]; postView = Discourse.View.views[$target.closest('.ember-view')[0].id];
post = postView.get("post"); post = postView.get("post");
url = post.get("url"); url = post.get("url");
username = post.get("username"); username = post.get("username");

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.FeaturedTopicsView = Ember.View.extend({ window.Discourse.FeaturedTopicsView = Discourse.View.extend({
templateName: 'featured_topics', templateName: 'featured_topics',
classNames: ['category-list-item'], classNames: ['category-list-item'],
init: function() { init: function() {

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.FeaturedTopicsView = Ember.View.extend({ window.Discourse.FeaturedTopicsView = Discourse.View.extend({
templateName: 'featured_topics', templateName: 'featured_topics',
classNames: ['category-list-item'] classNames: ['category-list-item']
}); });

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.HeaderView = Ember.View.extend({ window.Discourse.HeaderView = Discourse.View.extend({
tagName: 'header', tagName: 'header',
classNames: ['d-header', 'clearfix'], classNames: ['d-header', 'clearfix'],
classNameBindings: ['editingTopic'], classNameBindings: ['editingTopic'],

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.HistoryView = Ember.View.extend({ window.Discourse.HistoryView = Discourse.View.extend({
templateName: 'history', templateName: 'history',
title: 'History', title: 'History',
modalClass: 'history-modal', modalClass: 'history-modal',

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.ImageSelectorView = Ember.View.extend({ window.Discourse.ImageSelectorView = Discourse.View.extend({
templateName: 'image_selector', templateName: 'image_selector',
classNames: ['image-selector'], classNames: ['image-selector'],
title: 'Insert Image', title: 'Insert Image',

@ -1,6 +1,6 @@
(function() { (function() {
Discourse.InputTipView = Ember.View.extend(Discourse.Presence, { Discourse.InputTipView = Discourse.View.extend({
templateName: 'input_tip', templateName: 'input_tip',
classNameBindings: [':tip', 'good', 'bad'], classNameBindings: [':tip', 'good', 'bad'],
good: (function() { good: (function() {

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.ListCategoriesView = Ember.View.extend({ window.Discourse.ListCategoriesView = Discourse.View.extend({
templateName: 'list/categories', templateName: 'list/categories',
didInsertElement: function() { didInsertElement: function() {
return Discourse.set('title', Em.String.i18n("category.list")); return Discourse.set('title', Em.String.i18n("category.list"));

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.ListTopicsView = Ember.View.extend(Discourse.Scrolling, Discourse.Presence, { window.Discourse.ListTopicsView = Discourse.View.extend(Discourse.Scrolling, {
templateName: 'list/topics', templateName: 'list/topics',
categoryBinding: 'Discourse.router.listController.category', categoryBinding: 'Discourse.router.listController.category',
filterModeBinding: 'Discourse.router.listController.filterMode', filterModeBinding: 'Discourse.router.listController.filterMode',

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.ListView = Ember.View.extend({ window.Discourse.ListView = Discourse.View.extend({
templateName: 'list/list', templateName: 'list/list',
composeViewBinding: Ember.Binding.oneWay('Discourse.composeView'), composeViewBinding: Ember.Binding.oneWay('Discourse.composeView'),
categoriesBinding: 'Discourse.site.categories', categoriesBinding: 'Discourse.site.categories',

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.TopicListItemView = Ember.View.extend({ window.Discourse.TopicListItemView = Discourse.View.extend({
tagName: 'tr', tagName: 'tr',
templateName: 'list/topic_list_item', templateName: 'list/topic_list_item',
classNameBindings: ['content.archived', ':topic-list-item'], classNameBindings: ['content.archived', ':topic-list-item'],

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.CreateAccountView = window.Discourse.ModalBodyView.extend(Discourse.Presence, { window.Discourse.CreateAccountView = Discourse.ModalBodyView.extend({
templateName: 'modal/create_account', templateName: 'modal/create_account',
title: Em.String.i18n('create_account.title'), title: Em.String.i18n('create_account.title'),
uniqueUsernameValidation: null, uniqueUsernameValidation: null,

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.ForgotPasswordView = window.Discourse.ModalBodyView.extend(Discourse.Presence, { window.Discourse.ForgotPasswordView = Discourse.ModalBodyView.extend({
templateName: 'modal/forgot_password', templateName: 'modal/forgot_password',
title: Em.String.i18n('forgot_password.title'), title: Em.String.i18n('forgot_password.title'),
/* You need a value in the field to submit it. /* You need a value in the field to submit it.

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.InviteModalView = window.Discourse.ModalBodyView.extend(Discourse.Presence, { window.Discourse.InviteModalView = Discourse.ModalBodyView.extend({
templateName: 'modal/invite', templateName: 'modal/invite',
title: Em.String.i18n('topic.invite_reply.title'), title: Em.String.i18n('topic.invite_reply.title'),
email: null, email: null,

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.InvitePrivateModalView = window.Discourse.ModalBodyView.extend(Discourse.Presence, { window.Discourse.InvitePrivateModalView = Discourse.ModalBodyView.extend({
templateName: 'modal/invite_private', templateName: 'modal/invite_private',
title: Em.String.i18n('topic.invite_private.title'), title: Em.String.i18n('topic.invite_private.title'),
email: null, email: null,

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.LoginView = window.Discourse.ModalBodyView.extend(Discourse.Presence, { window.Discourse.LoginView = Discourse.ModalBodyView.extend({
templateName: 'modal/login', templateName: 'modal/login',
siteBinding: 'Discourse.site', siteBinding: 'Discourse.site',
title: Em.String.i18n('login.title'), title: Em.String.i18n('login.title'),

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

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.MoveSelectedView = window.Discourse.ModalBodyView.extend(Discourse.Presence, { window.Discourse.MoveSelectedView = Discourse.ModalBodyView.extend({
templateName: 'modal/move_selected', templateName: 'modal/move_selected',
title: Em.String.i18n('topic.move_selected.title'), title: Em.String.i18n('topic.move_selected.title'),
saving: false, saving: false,

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.OptionBooleanView = Em.View.extend({ window.Discourse.OptionBooleanView = Discourse.View.extend({
classNames: ['archetype-option'], classNames: ['archetype-option'],
composerControllerBinding: 'Discourse.router.composerController', composerControllerBinding: 'Discourse.router.composerController',
templateName: "modal/option_boolean", templateName: "modal/option_boolean",

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.NavItemView = Ember.View.extend({ window.Discourse.NavItemView = Discourse.View.extend({
tagName: 'li', tagName: 'li',
classNameBindings: ['isActive', 'content.hasIcon:has-icon'], classNameBindings: ['isActive', 'content.hasIcon:has-icon'],
attributeBindings: ['title'], attributeBindings: ['title'],

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.NotificationsView = Ember.View.extend({ window.Discourse.NotificationsView = Discourse.View.extend({
classNameBindings: ['content.read', ':notifications'], classNameBindings: ['content.read', ':notifications'],
templateName: 'notifications' templateName: 'notifications'
}); });

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.ParticipantView = Ember.View.extend({ window.Discourse.ParticipantView = Discourse.View.extend({
templateName: 'participant', templateName: 'participant',
toggled: (function() { toggled: (function() {
return this.get('controller.userFilters').contains(this.get('participant.username')); return this.get('controller.userFilters').contains(this.get('participant.username'));

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.PostLinkView = Ember.View.extend({ window.Discourse.PostLinkView = Discourse.View.extend({
tagName: 'li', tagName: 'li',
classNameBindings: ['direction'], classNameBindings: ['direction'],
direction: (function() { direction: (function() {

@ -13,7 +13,7 @@
(function() { (function() {
window.Discourse.PostMenuView = Ember.View.extend(Discourse.Presence, { window.Discourse.PostMenuView = Discourse.View.extend({
tagName: 'section', tagName: 'section',
classNames: ['post-menu-area', 'clearfix'], classNames: ['post-menu-area', 'clearfix'],
/* Delegate to render#{button} /* Delegate to render#{button}

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.PostView = Ember.View.extend({ window.Discourse.PostView = Discourse.View.extend({
classNames: ['topic-post', 'clearfix'], classNames: ['topic-post', 'clearfix'],
templateName: 'post', templateName: 'post',
classNameBindings: ['lastPostClass', 'postTypeClass', 'selectedClass', 'post.hidden:hidden', 'isDeleted:deleted', 'parentPost:replies-above'], classNameBindings: ['lastPostClass', 'postTypeClass', 'selectedClass', 'post.hidden:hidden', 'isDeleted:deleted', 'parentPost:replies-above'],

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.SearchView = Ember.View.extend(Discourse.Presence, { window.Discourse.SearchView = Discourse.View.extend({
tagName: 'div', tagName: 'div',
classNames: ['d-dropdown'], classNames: ['d-dropdown'],
elementId: 'search-dropdown', elementId: 'search-dropdown',

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.SelectedPostsView = Ember.View.extend({ window.Discourse.SelectedPostsView = Discourse.View.extend({
elementId: 'selected-posts', elementId: 'selected-posts',
templateName: 'selected_posts', templateName: 'selected_posts',
topicBinding: 'controller.content', topicBinding: 'controller.content',

@ -1,6 +1,6 @@
(function() { (function() {
Discourse.SuggestedTopicView = Ember.View.extend({ Discourse.SuggestedTopicView = Discourse.View.extend({
templateName: 'suggested_topic' templateName: 'suggested_topic'
}); });

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.TopicAdminMenuView = Em.View.extend({ window.Discourse.TopicAdminMenuView = Discourse.View.extend({
willDestroyElement: function() { willDestroyElement: function() {
return jQuery('html').off('mouseup.discourse-topic-admin-menu'); return jQuery('html').off('mouseup.discourse-topic-admin-menu');
}, },

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.TopicLinksView = Ember.View.extend({ window.Discourse.TopicLinksView = Discourse.View.extend({
templateName: 'topic_summary/links' templateName: 'topic_summary/links'
}); });

@ -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(Discourse.View.create({ container.pushObject(Em.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(Discourse.View.create({ return container.pushObject(Em.View.create({
templateName: 'topic_summary/private_message', templateName: 'topic_summary/private_message',
tagName: 'section', tagName: 'section',
classNames: ['information'] classNames: ['information']

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.TopicView = Ember.View.extend(Discourse.Scrolling, { window.Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
templateName: 'topic', templateName: 'topic',
topicBinding: 'controller.content', topicBinding: 'controller.content',
userFiltersBinding: 'controller.userFilters', userFiltersBinding: 'controller.userFilters',

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.ActivityFilterView = Em.View.extend(Discourse.Presence, { window.Discourse.ActivityFilterView = Discourse.View.extend({
tagName: 'li', tagName: 'li',
classNameBindings: ['active'], classNameBindings: ['active'],
active: (function() { active: (function() {

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

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.PreferencesUsernameView = Ember.View.extend({ window.Discourse.PreferencesUsernameView = Discourse.View.extend({
templateName: 'user/username', templateName: 'user/username',
classNames: ['user-preferences'], classNames: ['user-preferences'],
didInsertElement: function() { didInsertElement: function() {

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.PreferencesView = Ember.View.extend({ window.Discourse.PreferencesView = Discourse.View.extend({
templateName: 'user/preferences', templateName: 'user/preferences',
classNames: ['user-preferences'] classNames: ['user-preferences']
}); });

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.UserActivityView = Ember.View.extend({ window.Discourse.UserActivityView = Discourse.View.extend({
templateName: 'user/activity', templateName: 'user/activity',
currentUserBinding: 'Discourse.currentUser', currentUserBinding: 'Discourse.currentUser',
userBinding: 'controller.content', userBinding: 'controller.content',

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.UserInvitedView = Ember.View.extend({ window.Discourse.UserInvitedView = Discourse.View.extend({
templateName: 'user/invited' templateName: 'user/invited'
}); });

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.UserPrivateMessagesView = Ember.View.extend({ window.Discourse.UserPrivateMessagesView = Discourse.View.extend({
templateName: 'user/private_messages', templateName: 'user/private_messages',
selectCurrent: function(evt) { selectCurrent: function(evt) {
var t; var t;

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.UserStreamView = Ember.View.extend(Discourse.Scrolling, { window.Discourse.UserStreamView = Discourse.View.extend(Discourse.Scrolling, {
templateName: 'user/stream', templateName: 'user/stream',
currentUserBinding: 'Discourse.currentUser', currentUserBinding: 'Discourse.currentUser',
userBinding: 'controller.content', userBinding: 'controller.content',

@ -1,6 +1,6 @@
(function() { (function() {
window.Discourse.UserView = Ember.View.extend({ window.Discourse.UserView = Discourse.View.extend({
templateName: 'user/user', templateName: 'user/user',
userBinding: 'controller.content', userBinding: 'controller.content',
updateTitle: (function() { updateTitle: (function() {

@ -1,13 +1,16 @@
(function() { (function() {
window.Discourse.View = Ember.View.extend(Discourse.Presence, { /**
/* Overwrite this to do a different display A base view that gives us common functionality, for example `present` and `blank`
*/
displayErrors: function(errors, callback) { @class View
alert(errors.join("\n")); @extends Ember.View
return typeof callback === "function" ? callback() : void 0; @uses Discourse.Presence
} @namespace Discourse
@module Discourse
**/
window.Discourse.View = Ember.View.extend(Discourse.Presence, {
}); });
}).call(this); }).call(this);

@ -26,7 +26,6 @@
// 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