added new Telescope.modules.addRoute function

This commit is contained in:
Sacha Greif 2015-08-26 10:44:14 +09:00
parent 5aa1c320b2
commit 2ac2bf2396
4 changed files with 16 additions and 3 deletions

View file

@ -24,6 +24,8 @@
* Now publishing all public user data all the time to work around nested fields subscriptions bug.
* Categories with same name now get different, unique slugs.
* Now getting link source name and URL from Embedly if available.
* [BREAKING] Renamed `posts_views_nav` to `views_menu`.
* Added `Telescope.modules.addRoute` to add new routes to existing modules.
## v0.23 “SubScope”

View file

@ -6,4 +6,4 @@ Telescope.menuItems.add("viewsMenu", {
description: 'day_by_day_view'
});
_.findWhere(Telescope.modules.top,{template: "posts_views_nav"}).only.push("postsDaily");
Telescope.modules.addRoute("top", "views_menu", "postsDaily");

View file

@ -15,7 +15,8 @@ Telescope.modules = {};
* @example
* Telescope.modules.add("hero", {
* template: "newsletterBanner",
* order: 10
* order: 10,
* only: ["posts_default"]
* });
*/
Telescope.modules.add = function (zone, module) {
@ -66,3 +67,13 @@ Telescope.modules.removeAll = function (zone) {
Telescope.modules.get = function (zone) {
return _.sortBy(Telescope.modules[zone], "order");
};
/**
* Add a route to the list of routes a module should be displayed on
* @param {string} zone - The name of the zone
* @param {string} template - The name of the module
* @param {string} route - The name of the route on which to display the module
*/
Telescope.modules.addRoute = function (zone, template, route) {
_.findWhere(Telescope.modules[zone], {template: template}).only.push(route);
};

View file

@ -18,4 +18,4 @@ Posts.views.add("singleday", function (terms) {
};
});
_.findWhere(Telescope.modules.top,{template: "posts_views_nav"}).only.push("postsSingleDay");
Telescope.modules.addRoute("top", "views_menu", "postsSingleDay");