Creating header package and dropdown component
This commit is contained in:
1 parent
04e9a85def
commit
2d52c9ef0a
17 files changed
+243
-49
No files matched your search
@@ -1,8 +1,29 @@
|
||||
<template name="dropdownForm">
|
||||
{{#form class='dropdown' api=this.api hideValidationBox=true}}
|
||||
{{#form (extend this mixins='dropdown' class='dropdown' hideValidationBox=true)}}
|
||||
{{>dropdownBackdrop}}
|
||||
<ul class="dropdown-menu">
|
||||
{{>UI.contentBlock}}
|
||||
<ul class="dropdown-menu {{this.options.menuClasses}}">
|
||||
{{#if UI.contentBlock}}
|
||||
{{>UI.contentBlock}}
|
||||
{{else}}
|
||||
{{#each item in this.items}}
|
||||
{{#if item.separatorBefore}}
|
||||
<li role="separator" class="divider"></li>
|
||||
{{/if}}
|
||||
<li class="{{#if item.disabled}}disabled{{/if}}">
|
||||
{{#link item}}
|
||||
{{#if item.iconClasses}}
|
||||
<i class="{{item.iconClasses}}"></i>
|
||||
{{/if}}
|
||||
{{#if item.text}}
|
||||
<span>{{item.text}}</span>
|
||||
{{/if}}
|
||||
{{/link}}
|
||||
</li>
|
||||
{{#if item.separatorAfter}}
|
||||
<li role="separator" class="divider"></li>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
</ul>
|
||||
{{/form}}
|
||||
</template>
|
||||
@@ -1,34 +0,0 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
import { Blaze } from 'meteor/blaze';
|
||||
import { $ } from 'meteor/jquery';
|
||||
import { _ } from 'meteor/underscore';
|
||||
|
||||
Template.dropdownForm.onRendered(() => {
|
||||
const instance = Template.instance();
|
||||
const dropdown = instance.$('.dropdown');
|
||||
|
||||
// Show the dropdown
|
||||
dropdown.addClass('open');
|
||||
dropdown.find('ul.dropdown-menu li a').addClass('noselect');
|
||||
|
||||
// Destroy the Blaze created view (either created with template calls or with renderWithData)
|
||||
instance.destroyView = () => {
|
||||
if (_.isFunction(instance.data.destroyView)) {
|
||||
instance.data.destroyView();
|
||||
} else {
|
||||
Blaze.remove(instance.view);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
Template.dropdownForm.events({
|
||||
'click .dropdown'(event, instance) {
|
||||
let target = $(event.target);
|
||||
if (target.hasClass('disabled')) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
} else {
|
||||
instance.destroyView();
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user