diff --git a/app/assets/javascripts/admin/models/site_customization.js b/app/assets/javascripts/admin/models/site_customization.js index b9f0042c7f1..0e678185ccf 100644 --- a/app/assets/javascripts/admin/models/site_customization.js +++ b/app/assets/javascripts/admin/models/site_customization.js @@ -7,47 +7,38 @@ @module Discourse **/ Discourse.SiteCustomization = Discourse.Model.extend({ - trackedProperties: ['enabled', 'name', 'stylesheet', 'header', 'mobile_stylesheet', 'mobile_header', 'override_default_style'], + trackedProperties: ['enabled', 'name', 'stylesheet', 'header', 'footer', 'mobile_stylesheet', 'mobile_header', 'mobile_footer', 'override_default_style'], description: function() { return "" + this.name + (this.enabled ? ' (*)' : ''); }.property('selected', 'name'), changed: function() { + var self = this; - var _this = this; - if(!this.originals) return false; + if (!this.originals) { return false; } - var changed = _.some(this.trackedProperties,function(p) { - return _this.originals[p] !== _this.get(p); + var changed = _.some(this.trackedProperties, function (p) { + return self.originals[p] !== self.get(p); }); - if(changed){ - this.set('savingStatus',''); - } + if (changed) { this.set('savingStatus', ''); } return changed; - }.property('override_default_style', 'enabled', 'name', 'stylesheet', 'header', 'mobile_stylesheet', 'mobile_header', 'originals'), + }.property('override_default_style', 'enabled', 'name', 'stylesheet', 'header', 'footer', 'mobile_stylesheet', 'mobile_header', 'mobile_footer', 'originals'), startTrackingChanges: function() { - var _this = this; + var self = this; var originals = {}; - _.each(this.trackedProperties,function(prop) { - originals[prop] = _this.get(prop); - return true; + _.each(this.trackedProperties, function (prop) { + originals[prop] = self.get(prop); }); this.set('originals', originals); }.on('init'), - previewUrl: function() { - return "/?preview-style=" + (this.get('key')); - }.property('key'), - - disableSave: function() { - return !this.get('changed') || this.get('saving'); - }.property('changed'), - + previewUrl: function() { return "/?preview-style=" + this.get('key'); }.property('key'), + disableSave: function() { return !this.get('changed') || this.get('saving'); }.property('changed'), save: function() { this.set('savingStatus', I18n.t('saving')); @@ -57,8 +48,10 @@ Discourse.SiteCustomization = Discourse.Model.extend({ enabled: this.enabled, stylesheet: this.stylesheet, header: this.header, + footer: this.footer, mobile_stylesheet: this.mobile_stylesheet, mobile_header: this.mobile_header, + mobile_footer: this.mobile_footer, override_default_style: this.override_default_style }; @@ -75,23 +68,19 @@ Discourse.SiteCustomization = Discourse.Model.extend({ siteCustomization.set('saving',false); siteCustomization.startTrackingChanges(); }); - }, destroy: function() { - if(!this.id) return; - return Discourse.ajax("/admin/site_customizations/" + this.id, { - type: 'DELETE' - }); + if (!this.id) return; + return Discourse.ajax("/admin/site_customizations/" + this.id, { type: 'DELETE' }); } - }); var SiteCustomizations = Ember.ArrayProxy.extend({ selectedItemChanged: function() { var selected = this.get('selectedItem'); - _.each(this.get('content'),function(i) { - return i.set('selected', selected === i); + _.each(this.get('content'), function (i) { + i.set('selected', selected === i); }); }.observes('selectedItem') }); diff --git a/app/assets/javascripts/admin/templates/customize_css_html.hbs b/app/assets/javascripts/admin/templates/customize_css_html.hbs index c9c6e36d179..57bccda4992 100644 --- a/app/assets/javascripts/admin/templates/customize_css_html.hbs +++ b/app/assets/javascripts/admin/templates/customize_css_html.hbs @@ -2,71 +2,58 @@
{{i18n admin.customize.about}}
{{/if}} - diff --git a/app/assets/javascripts/admin/views/admin_customize_view.js b/app/assets/javascripts/admin/views/admin_customize_view.js index de6b7eab949..ac1b0603c01 100644 --- a/app/assets/javascripts/admin/views/admin_customize_view.js +++ b/app/assets/javascripts/admin/views/admin_customize_view.js @@ -12,15 +12,20 @@ Discourse.AdminCustomizeView = Discourse.View.extend({ templateName: 'admin/templates/customize', classNames: ['customize'], selected: 'stylesheet', + headerActive: Em.computed.equal('selected', 'header'), + footerActive: Em.computed.equal('selected', 'footer'), stylesheetActive: Em.computed.equal('selected', 'stylesheet'), mobileHeaderActive: Em.computed.equal('selected', 'mobileHeader'), + mobileFooterActive: Em.computed.equal('selected', 'mobileFooter'), mobileStylesheetActive: Em.computed.equal('selected', 'mobileStylesheet'), actions: { selectHeader: function() { this.set('selected', 'header'); }, + selectFooter: function() { this.set('selected', 'footer'); }, selectStylesheet: function() { this.set('selected', 'stylesheet'); }, selectMobileHeader: function() { this.set('selected', 'mobileHeader'); }, + selectMobileFooter: function() { this.set('selected', 'mobileFooter'); }, selectMobileStylesheet: function() { this.set('selected', 'mobileStylesheet'); } }, diff --git a/app/assets/javascripts/discourse/controllers/discovery.js.es6 b/app/assets/javascripts/discourse/controllers/discovery.js.es6 index 5d4c0f7a858..8f012b42fac 100644 --- a/app/assets/javascripts/discourse/controllers/discovery.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery.js.es6 @@ -2,7 +2,7 @@ import ObjectController from 'discourse/controllers/object'; import TopPeriod from 'discourse/models/top-period'; export default ObjectController.extend({ - needs: ['navigation/category'], + needs: ['navigation/category', 'discovery/topics'], loading: false, loadingSpinner: false, scheduledSpinner: null, @@ -10,6 +10,8 @@ export default ObjectController.extend({ category: Em.computed.alias('controllers.navigation/category.category'), noSubcategories: Em.computed.alias('controllers.navigation/category.noSubcategories'), + loadedAllItems: Em.computed.not("controllers.discovery/topics.canLoadMore"), + showMoreUrl: function(period) { var url = '', category = this.get('category'); if (category) { diff --git a/app/assets/javascripts/discourse/controllers/user-notifications.js.es6 b/app/assets/javascripts/discourse/controllers/user-notifications.js.es6 index fc511df4363..e2519e2e5c5 100644 --- a/app/assets/javascripts/discourse/controllers/user-notifications.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-notifications.js.es6 @@ -3,6 +3,7 @@ export default Ember.ArrayController.extend({ needs: ['user-notifications'], canLoadMore: true, loading: false, + showDismissButton: function() { return this.get('user').total_unread_notifications > 0; }.property('user'), @@ -26,7 +27,7 @@ export default Ember.ArrayController.extend({ var notifications = result.get('content'); self.pushObjects(notifications); // Stop trying if it's the end - if (notifications && notifications.length === 0) { + if (notifications && (notifications.length === 0 || notifications.length < 60)) { self.set('canLoadMore', false); } }).catch(function(error) { diff --git a/app/assets/javascripts/discourse/controllers/user.js.es6 b/app/assets/javascripts/discourse/controllers/user.js.es6 index 39b00bc03c7..c69d1669869 100644 --- a/app/assets/javascripts/discourse/controllers/user.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user.js.es6 @@ -2,6 +2,7 @@ import ObjectController from 'discourse/controllers/object'; import CanCheckEmails from 'discourse/mixins/can-check-emails'; export default ObjectController.extend(CanCheckEmails, { + needs: ['user-notifications', 'user_topics_list'], viewingSelf: function() { return this.get('content.username') === Discourse.User.currentProp('username'); @@ -32,15 +33,31 @@ export default ObjectController.extend(CanCheckEmails, { (this.get('userActionType') === Discourse.UserAction.TYPES.messages_received); }.property('userActionType'), - /** - Can the currently logged in user invite users to the site - - @property canInviteToForum - **/ canInviteToForum: function() { return Discourse.User.currentProp('can_invite_to_forum'); }.property(), + loadedAllItems: function() { + switch (this.get("datasource")) { + case "badges": { return true; } + case "notifications": { return !this.get("controllers.user-notifications.canLoadMore"); } + case "topic_list": { return !this.get("controllers.user_topics_list.canLoadMore"); } + case "stream": { + if (this.get("userActionType")) { + var stat = _.find(this.get("stats"), { action_type: this.get("userActionType") }); + return stat && stat.count <= this.get("stream.itemsLoaded"); + } else { + return this.get("statsCountNonPM") <= this.get("stream.itemsLoaded"); + } + } + } + + return false; + }.property("datasource", + "userActionType", "stats", "stream.itemsLoaded", + "controllers.user_topics_list.canLoadMore", + "controllers.user-notifications.canLoadMore"), + privateMessagesActive: Em.computed.equal('pmView', 'index'), privateMessagesMineActive: Em.computed.equal('pmView', 'mine'), privateMessagesUnreadActive: Em.computed.equal('pmView', 'unread') diff --git a/app/assets/javascripts/discourse/models/topic_list.js b/app/assets/javascripts/discourse/models/topic_list.js index e2e2cb8aa29..d3758dca3e3 100644 --- a/app/assets/javascripts/discourse/models/topic_list.js +++ b/app/assets/javascripts/discourse/models/topic_list.js @@ -31,6 +31,8 @@ function finderFor(filter, params) { } Discourse.TopicList = Discourse.Model.extend({ + canLoadMore: Em.computed.notEmpty("more_topics_url"), + forEachNew: function(topics, callback) { var topicIds = []; _.each(this.get('topics'),function(topic) { @@ -68,7 +70,6 @@ Discourse.TopicList = Discourse.Model.extend({ var moreUrl = this.get('more_topics_url'); if (moreUrl) { - var self = this; this.set('loadingMore', true); @@ -84,7 +85,11 @@ Discourse.TopicList = Discourse.Model.extend({ topics.pushObject(t); }); - self.setProperties({ loadingMore: false, more_topics_url: result.topic_list.more_topics_url }); + self.setProperties({ + loadingMore: false, + more_topics_url: result.topic_list.more_topics_url + }); + Discourse.Session.currentProp('topicList', self); return self.get('more_topics_url'); } diff --git a/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 b/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 index c0eacd91604..f00bd5d1777 100644 --- a/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 +++ b/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 @@ -40,14 +40,12 @@ export default function(filter, extras) { }, setupController: function(controller, model, trans) { - if (trans) { controller.setProperties(Em.getProperties(trans, _.keys(queryParams).map(function(v){ return 'queryParams.' + v; }))); } - var periods = this.controllerFor('discovery').get('periods'), periodId = model.get('for_period') || (filter.indexOf('/') > 0 ? filter.split('/')[1] : ''); diff --git a/app/assets/javascripts/discourse/routes/user-badges.js.es6 b/app/assets/javascripts/discourse/routes/user-badges.js.es6 index 8d68ae0263b..2ec062e5809 100644 --- a/app/assets/javascripts/discourse/routes/user-badges.js.es6 +++ b/app/assets/javascripts/discourse/routes/user-badges.js.es6 @@ -4,7 +4,11 @@ export default Discourse.Route.extend({ }, setupController: function(controller, model) { - this.controllerFor('user').set('indexStream', false); + this.controllerFor('user').setProperties({ + indexStream: false, + datasource: "badges", + }); + if (this.controllerFor('user_activity').get('content')) { this.controllerFor('user_activity').set('userActionType', -1); } diff --git a/app/assets/javascripts/discourse/routes/user-notifications.js.es6 b/app/assets/javascripts/discourse/routes/user-notifications.js.es6 index 91d273a04da..2c40fd8ea88 100644 --- a/app/assets/javascripts/discourse/routes/user-notifications.js.es6 +++ b/app/assets/javascripts/discourse/routes/user-notifications.js.es6 @@ -5,10 +5,15 @@ export default Discourse.Route.extend({ }, setupController: function(controller, model) { - this.controllerFor('user').set('indexStream', false); + this.controllerFor('user').setProperties({ + indexStream: false, + datasource: "notifications" + }); + if (this.controllerFor('user_activity').get('content')) { this.controllerFor('user_activity').set('userActionType', -1); } + controller.set('model', model); controller.set('user', this.modelFor('user')); }, diff --git a/app/assets/javascripts/discourse/routes/user_activity_stream_route.js b/app/assets/javascripts/discourse/routes/user_activity_stream_route.js index 069d465e797..cadcdc7359f 100644 --- a/app/assets/javascripts/discourse/routes/user_activity_stream_route.js +++ b/app/assets/javascripts/discourse/routes/user_activity_stream_route.js @@ -23,7 +23,10 @@ Discourse.UserActivityStreamRoute = Discourse.Route.extend({ controller.set('model', model); this.controllerFor('user_activity').set('userActionType', this.get('userActionType')); - this.controllerFor('user').set('indexStream', !this.get('userActionType')); + this.controllerFor('user').setProperties({ + indexStream: !this.get('userActionType'), + datasource: "stream" + }); }, actions: { diff --git a/app/assets/javascripts/discourse/routes/user_topic_list_routes.js b/app/assets/javascripts/discourse/routes/user_topic_list_routes.js index 12bb0acdb59..2f9df6fe681 100644 --- a/app/assets/javascripts/discourse/routes/user_topic_list_routes.js +++ b/app/assets/javascripts/discourse/routes/user_topic_list_routes.js @@ -4,7 +4,10 @@ Discourse.UserTopicListRoute = Discourse.Route.extend({ }, setupController: function(controller, model) { - this.controllerFor('user').set('indexStream', false); + this.controllerFor('user').setProperties({ + indexStream: false, + datasource: "topic_list" + }); this.controllerFor('user-activity').set('userActionType', this.get('userActionType')); this.controllerFor('user_topics_list').setProperties({ model: model, @@ -30,7 +33,8 @@ function createPMRoute(viewName, path) { }); this.controllerFor('user').setProperties({ pmView: viewName, - indexStream: false + indexStream: false, + datasource: "topic_list" }); } }); diff --git a/app/assets/javascripts/discourse/templates/about.hbs b/app/assets/javascripts/discourse/templates/about.hbs index 09b02a525c3..68efdd25baf 100644 --- a/app/assets/javascripts/discourse/templates/about.hbs +++ b/app/assets/javascripts/discourse/templates/about.hbs @@ -62,3 +62,7 @@