mirror of
https://github.com/vale981/Vulcan
synced 2025-03-08 19:11:38 -05:00
Making module system more flexible to accept wrapping divs
This commit is contained in:
parent
36e2d063ce
commit
7770c21d3a
14 changed files with 72 additions and 58 deletions
|
@ -1,5 +1,13 @@
|
|||
<template name="modules">
|
||||
{{#each getModules}}
|
||||
{{> Template.dynamic template=template data=../..}}
|
||||
{{/each}}
|
||||
{{#if hasWrapper}}
|
||||
{{#each getModules}}
|
||||
<div class="{{wrapperClass}}">
|
||||
{{> Template.dynamic template=template data=../..}}
|
||||
</div>
|
||||
{{/each}}
|
||||
{{else}}
|
||||
{{#each getModules}}
|
||||
{{> Template.dynamic template=template data=../..}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
</template>
|
|
@ -1,6 +1,15 @@
|
|||
Template.modules.helpers({
|
||||
hasWrapper: function () {
|
||||
return !!this.moduleClass; // only add a wrapper if a class has been specified
|
||||
},
|
||||
wrapperClass: function () {
|
||||
var zone = Template.parentData(1);
|
||||
var module = this;
|
||||
return Telescope.utils.camelToDash(module.template) + " " + zone.moduleClass;
|
||||
},
|
||||
getModules: function () {
|
||||
var zone = this.toString();
|
||||
// look for the zone name in either the zone variable, or the data context itself
|
||||
var zone = this.zone || this.toString();
|
||||
return Telescope.modules.get(zone);
|
||||
}
|
||||
});
|
|
@ -2,11 +2,9 @@
|
|||
<div class="mobile-nav">
|
||||
<div class="mobile-nav-inner">
|
||||
<ul class="mobile-menu">
|
||||
{{#each mobileNav}}
|
||||
<li>
|
||||
{{> Template.dynamic template=template data=mobileContext}}
|
||||
</li>
|
||||
{{/each}}
|
||||
{{#with mobileContext}}
|
||||
{{> modules zone="mobileNav" moduleClass="mobile-menu-item"}}
|
||||
{{/with}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
Template.mobile_nav.helpers({
|
||||
mobileNav: function () {
|
||||
return _.sortBy(Telescope.config.mobileNav, 'order');
|
||||
},
|
||||
mobileContext: function () {
|
||||
return {mobile: true};
|
||||
}
|
||||
|
|
|
@ -7,21 +7,17 @@
|
|||
|
||||
{{> logo}}
|
||||
|
||||
{{#with primaryNav}}
|
||||
{{#if hasPrimaryNav}}
|
||||
<div class="nav primary-nav desktop-nav header-module desktop-only">
|
||||
{{#each this}}
|
||||
{{> Template.dynamic template=template}}
|
||||
{{/each}}
|
||||
{{> modules "primaryNav"}}
|
||||
</div>
|
||||
{{/with}}
|
||||
{{/if}}
|
||||
|
||||
{{#with secondaryNav}}
|
||||
{{#if hasSecondaryNav}}
|
||||
<div class="nav secondary-nav desktop-nav header-module desktop-only">
|
||||
{{#each this}}
|
||||
{{> Template.dynamic template=template}}
|
||||
{{/each}}
|
||||
{{> modules "secondaryNav"}}
|
||||
</div>
|
||||
{{/with}}
|
||||
{{/if}}
|
||||
|
||||
</header>
|
||||
</template>
|
||||
|
|
|
@ -15,17 +15,11 @@ Template.nav.helpers({
|
|||
}
|
||||
return headerClass;
|
||||
},
|
||||
primaryNav: function () {
|
||||
return _.sortBy(Telescope.config.primaryNav, 'order');
|
||||
},
|
||||
hasPrimaryNav: function () {
|
||||
return !!Telescope.config.primaryNav.length;
|
||||
},
|
||||
secondaryNav: function () {
|
||||
return _.sortBy(Telescope.config.secondaryNav, 'order');
|
||||
return !!Telescope.modules.get("primaryNav").length;
|
||||
},
|
||||
hasSecondaryNav: function () {
|
||||
return !!Telescope.config.secondaryNav.length;
|
||||
return !!Telescope.modules.get("secondaryNav").length;
|
||||
},
|
||||
dropdownClass: function () {
|
||||
var dropdownClass = "";
|
||||
|
|
31
packages/telescope-core/lib/modules.js
Normal file
31
packages/telescope-core/lib/modules.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
// array containing nav items;
|
||||
|
||||
Telescope.modules.register("secondaryNav", [
|
||||
{
|
||||
template: 'userMenu',
|
||||
order: 10
|
||||
},
|
||||
{
|
||||
template:'notificationsMenu',
|
||||
order: 20
|
||||
},
|
||||
{
|
||||
template: 'submitButton',
|
||||
order: 30
|
||||
}
|
||||
]);
|
||||
|
||||
Telescope.modules.register("mobileNav", [
|
||||
{
|
||||
template: 'userMenu',
|
||||
order: 10
|
||||
},
|
||||
{
|
||||
template:'notificationsMenu',
|
||||
order: 20
|
||||
},
|
||||
{
|
||||
template: 'submitButton',
|
||||
order: 30
|
||||
}
|
||||
]);
|
|
@ -38,8 +38,9 @@ Package.onUse(function(api) {
|
|||
'lib/router/filters.js',
|
||||
'lib/router/admin.js',
|
||||
'lib/router/server.js',
|
||||
'lib/vote.js',
|
||||
'lib/config.js'
|
||||
'lib/config.js',
|
||||
'lib/modules.js',
|
||||
'lib/vote.js'
|
||||
], ['client', 'server']);
|
||||
|
||||
api.addFiles([
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
<template name="post_item">
|
||||
<div class="post {{#if sticky}}sticky{{/if}} {{inactiveClass}} {{postClass}}" id="{{_id}}">
|
||||
{{#each postComponents}}
|
||||
<div class="{{moduleClass}}">
|
||||
{{> Template.dynamic template=template data=..}}
|
||||
</div>
|
||||
{{/each}}
|
||||
{{> modules zone="postComponents" moduleClass="post-module"}}
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -5,25 +5,16 @@ Template.post_item.created = function () {
|
|||
};
|
||||
|
||||
Template.post_item.helpers({
|
||||
postComponents: function () {
|
||||
return Telescope.modules.get("postComponents");
|
||||
},
|
||||
moduleContext: function () { // not used for now
|
||||
var module = this;
|
||||
module.templateClass = Telescope.utils.camelToDash(this.template) + ' ' + this.position + ' cell';
|
||||
module.post = post;
|
||||
return module;
|
||||
},
|
||||
moduleClass: function () {
|
||||
return Telescope.utils.camelToDash(this.template) + ' post-module';
|
||||
},
|
||||
postClass: function () {
|
||||
var post = this;
|
||||
var postAuthorClass = "author-"+post.author;
|
||||
|
||||
|
||||
var postClass = Telescope.callbacks.run("postClass", postAuthorClass);
|
||||
|
||||
return postClass;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
// push "search" template to primaryNav
|
||||
Telescope.config.primaryNav.push({
|
||||
Telescope.modules.register("primaryNav", {
|
||||
template: 'search',
|
||||
order: 100
|
||||
});
|
||||
|
||||
Telescope.config.mobileNav.push({
|
||||
Telescope.modules.register("mobileNav", {
|
||||
template: 'search',
|
||||
order: 1
|
||||
});
|
||||
|
||||
Telescope.config.adminMenu.push({
|
||||
Telescope.modules.register("adminMenu", {
|
||||
route: 'searchLogs',
|
||||
label: 'search_logs',
|
||||
description: 'see_what_people_are_searching_for'
|
||||
|
|
|
@ -83,7 +83,7 @@ $mobile-nav-width: 200px;
|
|||
display: block;
|
||||
margin-right: 0px;
|
||||
}
|
||||
>li{
|
||||
.mobile-menu-item{
|
||||
margin-bottom: 0;
|
||||
border-bottom:1px white(0.2) solid;
|
||||
&:last-child{
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<template name="user_edit">
|
||||
{{#with user}}
|
||||
{{#each userProfileEdit}}
|
||||
{{> Template.dynamic template=template data=..}}
|
||||
{{/each}}
|
||||
{{> modules "profileEdit"}}
|
||||
{{/with}}
|
||||
</template>
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
Template.user_edit.helpers({
|
||||
userProfileEdit: function () {
|
||||
return userProfileEdit;
|
||||
}
|
||||
});
|
Loading…
Add table
Reference in a new issue