FIX: footer should also be hidden when using back/forward buttons

This commit is contained in:
Régis Hanol 2015-07-31 16:53:18 +02:00
parent d7aa4e81d6
commit fb65970530
20 changed files with 95 additions and 121 deletions

View File

@ -725,7 +725,8 @@ export default ObjectController.extend(SelectedPostsCount, BufferedContent, {
},
_showFooter: function() {
this.set("controllers.application.showFooter", this.get("model.postStream.loadedAllPosts"));
}.observes("model.postStream.loadedAllPosts")
const showFooter = this.get("model.postStream.loaded") && this.get("model.postStream.loadedAllPosts");
this.set("controllers.application.showFooter", showFooter);
}.observes("model.postStream.{loaded,loadedAllPosts}")
});

View File

@ -0,0 +1,15 @@
export default {
name: "show-footer",
initialize(container) {
const router = container.lookup("router:main");
const application = container.lookup("controller:application");
// only take care of hiding the footer here
// controllers MUST take care of displaying it
router.on("willTransition", () => {
application.set("showFooter", false);
return true;
});
}
};

View File

@ -1,5 +1,3 @@
import ShowFooter from "discourse/mixins/show-footer";
var configs = {
'faq': 'faq_url',
'tos': 'tos_url',
@ -7,7 +5,7 @@ var configs = {
};
export default function(page) {
return Discourse.Route.extend(ShowFooter, {
return Discourse.Route.extend({
renderTemplate: function() {
this.render('static');
},

View File

@ -1,15 +0,0 @@
export default Em.Mixin.create({
actions: {
didTransition() {
Em.run.schedule("afterRender", () => {
this.controllerFor("application").set("showFooter", true);
});
return true;
},
willTransition() {
this.controllerFor("application").set("showFooter", false);
return true;
}
}
});

View File

@ -1,6 +1,4 @@
import ShowFooter from "discourse/mixins/show-footer";
export default Discourse.Route.extend(ShowFooter, {
export default Discourse.Route.extend({
model: function() {
return Discourse.ajax("/about.json").then(function(result) {
return result.about;

View File

@ -1,6 +1,4 @@
import ShowFooter from "discourse/mixins/show-footer";
export default Discourse.Route.extend(ShowFooter, {
export default Discourse.Route.extend({
model: function() {
if (PreloadStore.get('badges')) {
return PreloadStore.getAndRemove('badges').then(function(json) {

View File

@ -1,6 +1,4 @@
import ShowFooter from "discourse/mixins/show-footer";
export default Discourse.Route.extend(ShowFooter, {
export default Discourse.Route.extend({
actions: {
didTransition: function() {
this.controllerFor("badges/show")._showFooter();

View File

@ -1,31 +1,29 @@
import ShowFooter from "discourse/mixins/show-footer";
export default function (filter) {
return Discourse.Route.extend(ShowFooter, {
return Discourse.Route.extend({
actions: {
didTransition: function() {
this.controllerFor('user').set('indexStream', true);
didTransition() {
this.controllerFor("user").set("indexStream", true);
this.controllerFor("user-posts")._showFooter();
return true;
}
},
model: function () {
model() {
return this.modelFor("user").get("postsStream");
},
afterModel: function () {
afterModel() {
return this.modelFor("user").get("postsStream").filterBy(filter);
},
setupController: function(controller, model) {
setupController(controller, model) {
// initialize "canLoadMore"
model.set("canLoadMore", model.get("itemsLoaded") === 60);
this.controllerFor("user-posts").set("model", model);
},
renderTemplate: function() {
renderTemplate() {
this.render("user/posts", { into: "user" });
}
});

View File

@ -1,36 +1,35 @@
import UserTopicListRoute from "discourse/routes/user-topic-list";
import ShowFooter from "discourse/mixins/show-footer";
// A helper to build a user topic list route
export default function (viewName, path) {
return UserTopicListRoute.extend(ShowFooter, {
export default (viewName, path) => {
return UserTopicListRoute.extend({
userActionType: Discourse.UserAction.TYPES.messages_received,
actions: {
didTransition: function() {
didTransition() {
this.controllerFor("user-topics-list")._showFooter();
return true;
}
},
model: function() {
return this.store.findFiltered('topicList', {filter: 'topics/' + path + '/' + this.modelFor('user').get('username_lower')});
model() {
return this.store.findFiltered("topicList", { filter: "topics/" + path + "/" + this.modelFor("user").get("username_lower") });
},
setupController: function() {
setupController() {
this._super.apply(this, arguments);
this.controllerFor('user-topics-list').setProperties({
this.controllerFor("user-topics-list").setProperties({
hideCategory: true,
showParticipants: true
});
this.controllerFor('user').set('pmView', viewName);
this.controllerFor('search').set('contextType', 'private_messages');
this.controllerFor("user").set("pmView", viewName);
this.controllerFor("search").set("contextType", "private_messages");
},
deactivate: function(){
this.controllerFor('search').set('contextType', 'user');
deactivate() {
this.controllerFor("search").set("contextType", "user");
}
});
}
};

View File

@ -1,8 +1,7 @@
import ShowFooter from 'discourse/mixins/show-footer';
import showModal from 'discourse/lib/show-modal';
import OpenComposer from "discourse/mixins/open-composer";
Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend(OpenComposer, ShowFooter, {
Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend(OpenComposer, {
renderTemplate() {
this.render('navigation/categories', { outlet: 'navigation-bar' });
this.render('discovery/categories', { outlet: 'list-container' });

View File

@ -2,14 +2,15 @@
The parent route for all discovery routes.
Handles the logic for showing the loading spinners.
**/
import ShowFooter from "discourse/mixins/show-footer";
import OpenComposer from "discourse/mixins/open-composer";
import { scrollTop } from 'discourse/mixins/scroll-top';
const DiscoveryRoute = Discourse.Route.extend(OpenComposer, ShowFooter, {
redirect: function() { return this.redirectIfLoginRequired(); },
const DiscoveryRoute = Discourse.Route.extend(OpenComposer, {
redirect() {
return this.redirectIfLoginRequired();
},
beforeModel: function(transition) {
beforeModel(transition) {
if (transition.intent.url === "/" &&
transition.targetName.indexOf("discovery.top") === -1 &&
Discourse.User.currentProp("should_be_redirected_to_top")) {
@ -19,30 +20,30 @@ const DiscoveryRoute = Discourse.Route.extend(OpenComposer, ShowFooter, {
},
actions: {
loading: function() {
loading() {
this.controllerFor('discovery').set("loading", true);
return true;
},
loadingComplete: function() {
loadingComplete() {
this.controllerFor('discovery').set('loading', false);
if (!this.session.get('topicListScrollPosition')) {
scrollTop();
}
},
didTransition: function() {
didTransition() {
this.controllerFor("discovery")._showFooter();
this.send('loadingComplete');
return true;
},
// clear a pinned topic
clearPin: function(topic) {
clearPin(topic) {
topic.clearPin();
},
createTopic: function() {
createTopic() {
this.openComposer(this.controllerFor('discovery/topics'));
}
}

View File

@ -1,7 +1,3 @@
import ShowFooter from "discourse/mixins/show-footer";
export default Discourse.Route.extend(ShowFooter, {
serialize: function() {
return "";
}
export default Discourse.Route.extend({
serialize() { return ""; }
});

View File

@ -1,18 +1,14 @@
import ShowFooter from "discourse/mixins/show-footer";
export default Discourse.Route.extend(ShowFooter, {
export default Discourse.Route.extend({
actions: {
didTransition: function() {
return true;
}
didTransition() { return true; }
},
model: function() {
return this.modelFor('group').findPosts();
model() {
return this.modelFor("group").findPosts();
},
setupController: function(controller, model) {
controller.set('model', model);
this.controllerFor('group').set('showing', 'index');
setupController(controller, model) {
controller.set("model", model);
this.controllerFor("group").set("showing", "index");
}
});

View File

@ -1,12 +1,10 @@
import ShowFooter from "discourse/mixins/show-footer";
export default Discourse.Route.extend(ShowFooter, {
export default Discourse.Route.extend({
model() {
return this.modelFor('group');
return this.modelFor("group");
},
setupController(controller, model) {
this.controllerFor('group').set('showing', 'members');
this.controllerFor("group").set("showing", "members");
controller.set("model", model);
model.findMembers();
}

View File

@ -1,8 +1,7 @@
import ShowFooter from "discourse/mixins/show-footer";
import RestrictedUserRoute from "discourse/routes/restricted-user";
import showModal from 'discourse/lib/show-modal';
export default RestrictedUserRoute.extend(ShowFooter, {
export default RestrictedUserRoute.extend({
model() {
return this.modelFor('user');
},

View File

@ -4,10 +4,9 @@ let isTransitioning = false,
const SCROLL_DELAY = 500;
import ShowFooter from "discourse/mixins/show-footer";
import showModal from 'discourse/lib/show-modal';
const TopicRoute = Discourse.Route.extend(ShowFooter, {
const TopicRoute = Discourse.Route.extend({
redirect() { return this.redirectIfLoginRequired(); },
queryParams: {

View File

@ -1,32 +1,31 @@
import ShowFooter from "discourse/mixins/show-footer";
import ViewingActionType from "discourse/mixins/viewing-action-type";
export default Discourse.Route.extend(ShowFooter, ViewingActionType, {
model: function() {
export default Discourse.Route.extend(ViewingActionType, {
model() {
return this.modelFor('user').get('stream');
},
afterModel: function() {
afterModel() {
return this.modelFor('user').get('stream').filterBy(this.get('userActionType'));
},
renderTemplate: function() {
renderTemplate() {
this.render('user_stream');
},
setupController: function(controller, model) {
setupController(controller, model) {
controller.set('model', model);
this.viewingActionType(this.get('userActionType'));
},
actions: {
didTransition: function() {
didTransition() {
this.controllerFor("user-activity")._showFooter();
return true;
},
removeBookmark: function(userAction) {
removeBookmark(userAction) {
var user = this.modelFor('user');
Discourse.Post.updateBookmark(userAction.get('post_id'), false)
.then(function() {

View File

@ -1,17 +1,16 @@
import ShowFooter from "discourse/mixins/show-footer";
import ViewingActionType from "discourse/mixins/viewing-action-type";
export default Discourse.Route.extend(ShowFooter, ViewingActionType, {
model: function() {
return Discourse.UserBadge.findByUsername(this.modelFor('user').get('username_lower'), {grouped: true});
export default Discourse.Route.extend(ViewingActionType, {
model() {
return Discourse.UserBadge.findByUsername(this.modelFor("user").get("username_lower"), { grouped: true });
},
setupController: function(controller, model) {
setupController(controller, model) {
this.viewingActionType(-1);
controller.set('model', model);
controller.set("model", model);
},
renderTemplate: function() {
this.render('user/badges', {into: 'user'});
renderTemplate() {
this.render("user/badges", {into: "user"});
}
});

View File

@ -1,33 +1,32 @@
import ShowFooter from 'discourse/mixins/show-footer';
import showModal from 'discourse/lib/show-modal';
import showModal from "discourse/lib/show-modal";
export default Discourse.Route.extend(ShowFooter, {
export default Discourse.Route.extend({
model: function(params) {
model(params) {
this.inviteFilter = params.filter;
return Discourse.Invite.findInvitedBy(this.modelFor('user'), params.filter);
return Discourse.Invite.findInvitedBy(this.modelFor("user"), params.filter);
},
afterModel: function(model) {
afterModel(model) {
if (!model.can_see_invite_details) {
this.replaceWith('userInvited.show', 'redeemed');
this.replaceWith("userInvited.show", "redeemed");
}
},
setupController(controller, model) {
controller.setProperties({
model: model,
user: this.controllerFor('user').get('model'),
user: this.controllerFor("user").get("model"),
filter: this.inviteFilter,
searchTerm: '',
searchTerm: "",
totalInvites: model.invites.length
});
},
actions: {
showInvite() {
showModal('invite', { model: this.currentUser });
this.controllerFor('invite').reset();
showModal("invite", { model: this.currentUser });
this.controllerFor("invite").reset();
},
uploadSuccess(filename) {

View File

@ -1,7 +1,6 @@
import ShowFooter from "discourse/mixins/show-footer";
import ViewingActionType from "discourse/mixins/viewing-action-type";
export default Discourse.Route.extend(ShowFooter, ViewingActionType, {
export default Discourse.Route.extend(ViewingActionType, {
actions: {
didTransition() {
this.controllerFor("user-notifications")._showFooter();
@ -10,13 +9,13 @@ export default Discourse.Route.extend(ShowFooter, ViewingActionType, {
},
model() {
var user = this.modelFor('user');
return this.store.find('notification', {username: user.get('username')});
var user = this.modelFor("user");
return this.store.find("notification", { username: user.get("username") });
},
setupController(controller, model) {
controller.set('model', model);
controller.set('user', this.modelFor('user'));
controller.set("model", model);
controller.set("user", this.modelFor("user"));
this.viewingActionType(-1);
}
});