2015-03-20 18:31:49 +09:00
|
|
|
Template[getTemplate('dropdownComponent')].helpers({
|
|
|
|
dropdownClass: function () {
|
2015-03-23 10:32:56 +09:00
|
|
|
|
|
|
|
var classes = [this.dropdownName+"-menu"];
|
2015-03-23 11:28:36 +09:00
|
|
|
var mode = this.dropdownMode == "undefined" ? "list" : this.dropdownMode;
|
|
|
|
var count = this.dropdownItems.length;
|
|
|
|
|
|
|
|
classes.push("dropdown-"+mode);
|
2015-03-23 10:32:56 +09:00
|
|
|
|
|
|
|
if(!!this.dropdownClass) {
|
|
|
|
classes.push(this.dropdownClass)
|
|
|
|
}
|
|
|
|
|
2015-03-22 12:27:05 +09:00
|
|
|
// enable dropdown if top-nav layout is enabled, if themes supports dropdowns, and if dropdown isn't empty
|
2015-03-23 11:28:36 +09:00
|
|
|
if (count) {
|
|
|
|
classes.push("dropdown-has-items");
|
|
|
|
if (count > 3) {
|
|
|
|
classes.push("dropdown-long");
|
|
|
|
}
|
2015-03-20 18:31:49 +09:00
|
|
|
} else {
|
2015-03-23 11:28:36 +09:00
|
|
|
classes.push("dropdown-no-items");
|
2015-03-20 18:31:49 +09:00
|
|
|
}
|
2015-03-23 11:28:36 +09:00
|
|
|
|
2015-03-23 10:32:56 +09:00
|
|
|
return classes.join(" ");
|
2015-03-20 18:31:49 +09:00
|
|
|
},
|
|
|
|
dropdownLabel: function () {
|
|
|
|
// if label is defined, use this. Else default to dropdown name
|
|
|
|
return !!this.dropdownLabel ? this.dropdownLabel : i18n.t(this.dropdownName);
|
|
|
|
},
|
2015-03-21 17:52:15 +09:00
|
|
|
showDropdownItem: function () {
|
|
|
|
// if this is an admin item, only show it if current user is admin
|
|
|
|
return this.adminOnly ? isAdmin(Meteor.user()) : true;
|
2015-03-20 18:31:49 +09:00
|
|
|
},
|
2015-03-22 12:27:05 +09:00
|
|
|
hasTemplate: function () {
|
|
|
|
return !!this.template;
|
|
|
|
},
|
2015-03-21 17:52:15 +09:00
|
|
|
itemClass: function () {
|
|
|
|
var itemClass = "";
|
|
|
|
if (this.adminOnly) {
|
|
|
|
itemClass += " admin-item";
|
2015-03-20 18:31:49 +09:00
|
|
|
}
|
2015-03-21 17:52:15 +09:00
|
|
|
return itemClass;
|
|
|
|
},
|
|
|
|
itemLabel: function () {
|
|
|
|
// if label is a Function return its result, else return i18n'd version of label
|
|
|
|
return typeof this.label == "function" ? this.label() : i18n.t(this.label);
|
|
|
|
},
|
|
|
|
itemRoute: function () {
|
|
|
|
// if route is a Function return its result, else apply Router.path() to it
|
|
|
|
return typeof this.route == "function" ? this.route() : Router.path(this.route);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Template[getTemplate('dropdownComponent')].events({
|
|
|
|
'click .show-more': function (e, t) {
|
|
|
|
e.preventDefault();
|
|
|
|
$dropdown = t.$('.dropdown');
|
|
|
|
$dropdown.toggleClass('dropdown-open');
|
2015-03-20 18:31:49 +09:00
|
|
|
}
|
|
|
|
});
|