From 1b3a2dde2fc2b7381838b9d35f6f8e7a80c4a8d3 Mon Sep 17 00:00:00 2001 From: Tony Barnes Date: Tue, 7 Oct 2014 13:41:44 +0100 Subject: [PATCH] direct child trigger selector --- js/barekit.js | 2 +- js/barekit.min.js | 2 +- src/modules/accordion.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/barekit.js b/js/barekit.js index 3374d1d..f82a30e 100644 --- a/js/barekit.js +++ b/js/barekit.js @@ -22,7 +22,7 @@ Accordion.defaults = { className: 'accordion', multiExpand: false, panelSelector: 'dd', - triggerSelector: 'dt a', + triggerSelector: 'dt > a', activeTrigger: 'accordion-trigger--open', activePanel: 'accordion-panel--open' }; diff --git a/js/barekit.min.js b/js/barekit.min.js index f9fa86b..dc46be6 100644 --- a/js/barekit.min.js +++ b/js/barekit.min.js @@ -1 +1 @@ -!function(a){var b;window.Barekit=b={autoInitialize:!0};var c=function(){this.init.apply(this,arguments)};c.defaults={className:"accordion",multiExpand:!1,panelSelector:"dd",triggerSelector:"dt a",activeTrigger:"accordion-trigger--open",activePanel:"accordion-panel--open"},c.prototype.init=function(b,d){this.$el=a(b),this.options=a.extend({},c.defaults,d,this.$el.data("options")),this.$el.addClass(this.options.className),this.$el.on("click.bk.accordion",a.proxy(this.onClick,this))},c.prototype.onClick=function(b){var c=a(b.target);if(c.is("a")){b.preventDefault();var d=c.parent().next("dd");this.processOptions(c,d)}},c.prototype.processOptions=function(a,b){var c=this.$el.find(this.options.panelSelector),d=this.$el.find(this.options.triggerSelector),e=this.options.activeTrigger,f=this.options.activePanel;this.options.multiExpand===!0?(a.parent().toggleClass(e),b.toggleClass(f)):(d.parent().removeClass(e),a.parent().addClass(e),b.hasClass(f)||c.removeClass(f),b.toggleClass(f))},c.prototype.destroy=function(){this.$el.off(".accordion")},b.Accordion=c,a.fn.bkAccordion=function(b){return this.each(function(){var d=a(this);d.data("bkAccordion")||d.data("bkAccordion",new c(this,b))})},a.fn.bkAccordion.defaults=c.defaults,jQuery(function(a){b.autoInitialize&&a("."+c.defaults.className).bkAccordion()});var d=function(){this.init.apply(this,arguments)};d.defaults={className:"dropdown-nav",click:!1,clickClass:"click-setting",activeTrigger:"dropdown-trigger--open",activeClass:"dropdown--open"},d.prototype.init=function(b,c){this.$el=a(b);var e=this.$el.find("li:has(ul) > a");this.options=a.extend({},d.defaults,c,this.$el.data("options")),this.$el.addClass(this.options.className),1==this.options.click&&(e.on("mouseover.bk.dropdown",a.proxy(this.add,this)),e.on("click.bk.dropdown",a.proxy(this.remove,this)))},d.prototype.add=function(b){var c=a(b.target);c.parent().addClass(this.options.clickClass)},d.prototype.remove=function(b){var c=a(b.target),d=c.siblings("ul");b.preventDefault(),c.parent().removeClass(this.options.className),this.doDropdown(c,d)},d.prototype.doDropdown=function(a,b){a.parent().toggleClass(this.options.activeTrigger),b.toggleClass(this.options.activeClass),a.parent().addClass(this.options.clickClass)},d.prototype.destroy=function(){this.$el.off(".dropdown")},b.Dropdown=d,a.fn.bkDropdown=function(b){return this.each(function(){var c=a(this);c.data("bkDropdown")||c.data("bkDropdown",new d(this,b))})},a.fn.bkDropdown.defaults=d.defaults,jQuery(function(a){b.autoInitialize&&a("."+d.defaults.className).bkDropdown()});var e=function(){this.init.apply(this,arguments)};e.defaults={className:"modal-trigger",modal:".modal",close:".modal-close",bg:"modal-bg",openClass:"modal-open"},e.prototype.init=function(b,c){var d=this;this.$el=a(b),this.options=a.extend({},e.defaults,c,this.$el.data("options")),this.$el.addClass(this.options.className),a(document).on("click.bk.modal",function(){d.closeModal()}).on("click.bk.modal","."+this.options.className,function(b){b.stopPropagation(),b.preventDefault(),a(b.target).data("options").modalId===d.options.modalId&&d.onClick()}).on("click.bk.modal",this.options.modal,function(a){a.stopPropagation(),a.preventDefault()}).on("keyup.bk.modal",function(a){27===a.keyCode&&d.closeModal()}),a(this.options.close).on("click.bk.modal",function(){d.closeModal()})},e.prototype.onClick=function(){var b=a("#"+this.options.modalId);this.openModal(b)},e.prototype.openModal=function(b){a("body").addClass(this.options.bg),b.addClass(this.options.openClass)},e.prototype.closeModal=function(){a("body").removeClass(this.options.bg),a(this.options.modal).removeClass(this.options.openClass)},e.prototype.destroy=function(){a(document).off(".modal"),a(this.options.close).off(".modal")},b.Modal=e,a.fn.bkModal=function(b){return this.each(function(){var c=a(this);c.data("bkModal")||c.data("bkModal",new e(this,b))})},a.fn.bkModal.defaults=e.defaults,jQuery(function(a){b.autoInitialize&&a("."+e.defaults.className).bkModal()});var f=function(){this.init.apply(this,arguments)};f.defaults={className:"off-canvas-contain",trigger:'[class^="off-canvas-trigger"]',leftOpenClass:"off-canvas--open-left",rightOpenClass:"off-canvas--open-right"},f.prototype.init=function(b,c){var d=this;this.$el=a(b);var c=this.options=a.extend({},f.defaults,c,this.$el.data("options"));this.$el.addClass(c.className),a(document).on("click.bk.offcanvas",function(){d.closeOffCanvas()}).on("click.bk.offcanvas",c.trigger,function(b){var e=a(this),f=e.parents(".off-canvas-contain");b.stopPropagation(),b.preventDefault(),f.hasClass(c.leftOpenClass)||f.hasClass(c.rightOpenClass)?d.closeOffCanvas(c):d.openOffCanvas(c,e,f)}).on("click.bk.offcanvas",".off-canvas-left",function(a){a.stopPropagation()}).on("click.bk.offcanvas",".off-canvas-right",function(a){a.stopPropagation()})},f.prototype.closeOffCanvas=function(){this.$el.removeClass("off-canvas--open-right").removeClass("off-canvas--open-left")},f.prototype.openOffCanvas=function(a,b,c){b.hasClass("off-canvas-trigger-left")?c.addClass(a.leftOpenClass):b.hasClass("off-canvas-trigger-right")&&c.addClass(a.rightOpenClass)},f.prototype.destroy=function(){a(document).off(".offcanvas")},b.OffCanvas=f,a.fn.bkOffCanvas=function(b){return this.each(function(){var c=a(this);c.data("bkOffCanvas")||c.data("bkOffCanvas",new f(this,b))})},a.fn.bkOffCanvas.defaults=f.defaults,jQuery(function(a){b.autoInitialize&&a("."+f.defaults.className).bkOffCanvas()});var g=function(){this.init.apply(this,arguments)};g.defaults={className:"tabs",panelClass:"tabs-panels",activeTrigger:"tab-trigger--open",activePanel:"tab-panel--open"},g.prototype.init=function(b,c){var d=this;this.$el=a(b),this.options=a.extend({},g.defaults,c,this.$el.data("options")),this.$el.addClass(this.options.className),this.$trigger=this.$el.find("li a"),this.$trigger.on("click.bk.tabs",function(b){var c=a(this);b.preventDefault(),d.doTabs(c)})},g.prototype.doTabs=function(a){var b=a.parent().parent().next("."+this.options.panelClass),c=b.children("li"),d=a.parent().index(),e=c.eq(d);this.$trigger.parent().removeClass(this.options.activeTrigger),a.parent().addClass(this.options.activeTrigger),c.removeClass(this.options.activePanel),e.addClass(this.options.activePanel)},g.prototype.destroy=function(){this.$trigger.off(".tabs")},b.Tabs=g,a.fn.bkTabs=function(b){return this.each(function(){var c=a(this);c.data("bkTabs")||c.data("bkTabs",new g(this,b))})},a.fn.bkTabs.defaults=g.defaults,jQuery(function(a){b.autoInitialize&&a("."+g.defaults.className).bkTabs()});var h=function(){this.init.apply(this,arguments)};h.defaults={className:"toggle-trigger",toggle:"",activeTriggerClass:"toggle-trigger-shown",activeClass:"toggle-shown",closeOnClick:!1},h.prototype.init=function(b,c){var d=this;this.$el=a(b),this.options=a.extend({},h.defaults,c,this.$el.data("options")),this.$el.addClass(this.options.className),1==this.options.closeOnClick&&(a(document).on("click",function(){a("#"+d.options.toggle).removeClass(d.options.activeClass)}),a("#"+this.options.toggle).on("click",function(a){a.stopPropagation()})),this.$el.on("click.bk.toggle",function(b){a(this);b.preventDefault(),b.stopPropagation(),d.doToggle()})},h.prototype.doToggle=function(){var b=this,c=a("#"+this.options.toggle);b.$el.toggleClass(this.options.activeTriggerClass),c.toggleClass(this.options.activeClass)},h.prototype.unToggle=function(){var b=a("#"+this.options.toggle);b.removeClass(this.options.activeClass)},h.prototype.destroy=function(){this.$el.off(".toggle")},b.Toggle=h,a.fn.bkToggle=function(b){return this.each(function(){var c=a(this);c.data("bkToggle")||c.data("bkToggle",new h(this,b))})},a.fn.bkToggle.defaults=h.defaults,jQuery(function(a){b.autoInitialize&&a("."+h.defaults.className).bkToggle()})}(jQuery); \ No newline at end of file +!function(a){var b;window.Barekit=b={autoInitialize:!0};var c=function(){this.init.apply(this,arguments)};c.defaults={className:"accordion",multiExpand:!1,panelSelector:"dd",triggerSelector:"dt > a",activeTrigger:"accordion-trigger--open",activePanel:"accordion-panel--open"},c.prototype.init=function(b,d){this.$el=a(b),this.options=a.extend({},c.defaults,d,this.$el.data("options")),this.$el.addClass(this.options.className),this.$el.on("click.bk.accordion",a.proxy(this.onClick,this))},c.prototype.onClick=function(b){var c=a(b.target);if(c.is("a")){b.preventDefault();var d=c.parent().next("dd");this.processOptions(c,d)}},c.prototype.processOptions=function(a,b){var c=this.$el.find(this.options.panelSelector),d=this.$el.find(this.options.triggerSelector),e=this.options.activeTrigger,f=this.options.activePanel;this.options.multiExpand===!0?(a.parent().toggleClass(e),b.toggleClass(f)):(d.parent().removeClass(e),a.parent().addClass(e),b.hasClass(f)||c.removeClass(f),b.toggleClass(f))},c.prototype.destroy=function(){this.$el.off(".accordion")},b.Accordion=c,a.fn.bkAccordion=function(b){return this.each(function(){var d=a(this);d.data("bkAccordion")||d.data("bkAccordion",new c(this,b))})},a.fn.bkAccordion.defaults=c.defaults,jQuery(function(a){b.autoInitialize&&a("."+c.defaults.className).bkAccordion()});var d=function(){this.init.apply(this,arguments)};d.defaults={className:"dropdown-nav",click:!1,clickClass:"click-setting",activeTrigger:"dropdown-trigger--open",activeClass:"dropdown--open"},d.prototype.init=function(b,c){this.$el=a(b);var e=this.$el.find("li:has(ul) > a");this.options=a.extend({},d.defaults,c,this.$el.data("options")),this.$el.addClass(this.options.className),1==this.options.click&&(e.on("mouseover.bk.dropdown",a.proxy(this.add,this)),e.on("click.bk.dropdown",a.proxy(this.remove,this)))},d.prototype.add=function(b){var c=a(b.target);c.parent().addClass(this.options.clickClass)},d.prototype.remove=function(b){var c=a(b.target),d=c.siblings("ul");b.preventDefault(),c.parent().removeClass(this.options.className),this.doDropdown(c,d)},d.prototype.doDropdown=function(a,b){a.parent().toggleClass(this.options.activeTrigger),b.toggleClass(this.options.activeClass),a.parent().addClass(this.options.clickClass)},d.prototype.destroy=function(){this.$el.off(".dropdown")},b.Dropdown=d,a.fn.bkDropdown=function(b){return this.each(function(){var c=a(this);c.data("bkDropdown")||c.data("bkDropdown",new d(this,b))})},a.fn.bkDropdown.defaults=d.defaults,jQuery(function(a){b.autoInitialize&&a("."+d.defaults.className).bkDropdown()});var e=function(){this.init.apply(this,arguments)};e.defaults={className:"modal-trigger",modal:".modal",close:".modal-close",bg:"modal-bg",openClass:"modal-open"},e.prototype.init=function(b,c){var d=this;this.$el=a(b),this.options=a.extend({},e.defaults,c,this.$el.data("options")),this.$el.addClass(this.options.className),a(document).on("click.bk.modal",function(){d.closeModal()}).on("click.bk.modal","."+this.options.className,function(b){b.stopPropagation(),b.preventDefault(),a(b.target).data("options").modalId===d.options.modalId&&d.onClick()}).on("click.bk.modal",this.options.modal,function(a){a.stopPropagation(),a.preventDefault()}).on("keyup.bk.modal",function(a){27===a.keyCode&&d.closeModal()}),a(this.options.close).on("click.bk.modal",function(){d.closeModal()})},e.prototype.onClick=function(){var b=a("#"+this.options.modalId);this.openModal(b)},e.prototype.openModal=function(b){a("body").addClass(this.options.bg),b.addClass(this.options.openClass)},e.prototype.closeModal=function(){a("body").removeClass(this.options.bg),a(this.options.modal).removeClass(this.options.openClass)},e.prototype.destroy=function(){a(document).off(".modal"),a(this.options.close).off(".modal")},b.Modal=e,a.fn.bkModal=function(b){return this.each(function(){var c=a(this);c.data("bkModal")||c.data("bkModal",new e(this,b))})},a.fn.bkModal.defaults=e.defaults,jQuery(function(a){b.autoInitialize&&a("."+e.defaults.className).bkModal()});var f=function(){this.init.apply(this,arguments)};f.defaults={className:"off-canvas-contain",trigger:'[class^="off-canvas-trigger"]',leftOpenClass:"off-canvas--open-left",rightOpenClass:"off-canvas--open-right"},f.prototype.init=function(b,c){var d=this;this.$el=a(b);var c=this.options=a.extend({},f.defaults,c,this.$el.data("options"));this.$el.addClass(c.className),a(document).on("click.bk.offcanvas",function(){d.closeOffCanvas()}).on("click.bk.offcanvas",c.trigger,function(b){var e=a(this),f=e.parents(".off-canvas-contain");b.stopPropagation(),b.preventDefault(),f.hasClass(c.leftOpenClass)||f.hasClass(c.rightOpenClass)?d.closeOffCanvas(c):d.openOffCanvas(c,e,f)}).on("click.bk.offcanvas",".off-canvas-left",function(a){a.stopPropagation()}).on("click.bk.offcanvas",".off-canvas-right",function(a){a.stopPropagation()})},f.prototype.closeOffCanvas=function(){this.$el.removeClass("off-canvas--open-right").removeClass("off-canvas--open-left")},f.prototype.openOffCanvas=function(a,b,c){b.hasClass("off-canvas-trigger-left")?c.addClass(a.leftOpenClass):b.hasClass("off-canvas-trigger-right")&&c.addClass(a.rightOpenClass)},f.prototype.destroy=function(){a(document).off(".offcanvas")},b.OffCanvas=f,a.fn.bkOffCanvas=function(b){return this.each(function(){var c=a(this);c.data("bkOffCanvas")||c.data("bkOffCanvas",new f(this,b))})},a.fn.bkOffCanvas.defaults=f.defaults,jQuery(function(a){b.autoInitialize&&a("."+f.defaults.className).bkOffCanvas()});var g=function(){this.init.apply(this,arguments)};g.defaults={className:"tabs",panelClass:"tabs-panels",activeTrigger:"tab-trigger--open",activePanel:"tab-panel--open"},g.prototype.init=function(b,c){var d=this;this.$el=a(b),this.options=a.extend({},g.defaults,c,this.$el.data("options")),this.$el.addClass(this.options.className),this.$trigger=this.$el.find("li a"),this.$trigger.on("click.bk.tabs",function(b){var c=a(this);b.preventDefault(),d.doTabs(c)})},g.prototype.doTabs=function(a){var b=a.parent().parent().next("."+this.options.panelClass),c=b.children("li"),d=a.parent().index(),e=c.eq(d);this.$trigger.parent().removeClass(this.options.activeTrigger),a.parent().addClass(this.options.activeTrigger),c.removeClass(this.options.activePanel),e.addClass(this.options.activePanel)},g.prototype.destroy=function(){this.$trigger.off(".tabs")},b.Tabs=g,a.fn.bkTabs=function(b){return this.each(function(){var c=a(this);c.data("bkTabs")||c.data("bkTabs",new g(this,b))})},a.fn.bkTabs.defaults=g.defaults,jQuery(function(a){b.autoInitialize&&a("."+g.defaults.className).bkTabs()});var h=function(){this.init.apply(this,arguments)};h.defaults={className:"toggle-trigger",toggle:"",activeTriggerClass:"toggle-trigger-shown",activeClass:"toggle-shown",closeOnClick:!1},h.prototype.init=function(b,c){var d=this;this.$el=a(b),this.options=a.extend({},h.defaults,c,this.$el.data("options")),this.$el.addClass(this.options.className),1==this.options.closeOnClick&&(a(document).on("click",function(){a("#"+d.options.toggle).removeClass(d.options.activeClass)}),a("#"+this.options.toggle).on("click",function(a){a.stopPropagation()})),this.$el.on("click.bk.toggle",function(b){a(this);b.preventDefault(),b.stopPropagation(),d.doToggle()})},h.prototype.doToggle=function(){var b=this,c=a("#"+this.options.toggle);b.$el.toggleClass(this.options.activeTriggerClass),c.toggleClass(this.options.activeClass)},h.prototype.unToggle=function(){var b=a("#"+this.options.toggle);b.removeClass(this.options.activeClass)},h.prototype.destroy=function(){this.$el.off(".toggle")},b.Toggle=h,a.fn.bkToggle=function(b){return this.each(function(){var c=a(this);c.data("bkToggle")||c.data("bkToggle",new h(this,b))})},a.fn.bkToggle.defaults=h.defaults,jQuery(function(a){b.autoInitialize&&a("."+h.defaults.className).bkToggle()})}(jQuery); \ No newline at end of file diff --git a/src/modules/accordion.js b/src/modules/accordion.js index 4a95339..bea2621 100644 --- a/src/modules/accordion.js +++ b/src/modules/accordion.js @@ -6,7 +6,7 @@ Accordion.defaults = { className: 'accordion', multiExpand: false, panelSelector: 'dd', - triggerSelector: 'dt a', + triggerSelector: 'dt > a', activeTrigger: 'accordion-trigger--open', activePanel: 'accordion-panel--open' };