diff --git a/dist/zeynep.css b/dist/zeynep.css index 3a62783..a493695 100644 --- a/dist/zeynep.css +++ b/dist/zeynep.css @@ -1,5 +1,5 @@ /*! -* zeynepjs v2.1.3 +* zeynepjs v2.1.4 * A light-weight multi-level jQuery side menu plugin. * It's fully customizable and is compatible with modern browsers such as Google Chrome, Mozilla Firefox, Safari, Edge and Internet Explorer * MIT License diff --git a/dist/zeynep.js b/dist/zeynep.js index 9d55ed4..df8b205 100644 --- a/dist/zeynep.js +++ b/dist/zeynep.js @@ -1,26 +1,21 @@ /*! -* zeynepjs v2.1.3 +* zeynepjs v2.1.4 * A light-weight multi-level jQuery side menu plugin. * It's fully customizable and is compatible with modern browsers such as Google Chrome, Mozilla Firefox, Safari, Edge and Internet Explorer * MIT License * by Huseyin ELMAS */ (function ($, pluginName) { - // plugin defaults var defaults = { htmlClass: true } - // plugin constructor function Plugin (element, options) { this.element = element this.eventController = eventController - - // merge defaults with options this.options = $.extend({}, defaults, options) this.options.initialized = false - // initialize the plugin this.init() } @@ -155,7 +150,6 @@ } var eventController = function (type, details) { - // validations if (!this.options[type]) return if (typeof this.options[type] !== 'function') throw Error('event handler must be a function: ' + type) @@ -182,7 +176,6 @@ } var eventBinder = function (name, handler) { - // validations if (typeof name !== 'string') throw Error('event name is expected to be a string but got: ' + typeof name) if (typeof handler !== 'function') throw Error('event handler is not a function for: ' + name) @@ -196,7 +189,6 @@ // get a zeynepjs instance var instance = getInstance($(this[0]), options) - // return the instance return instance } })(window.jQuery, 'zeynep') diff --git a/dist/zeynep.min.css b/dist/zeynep.min.css index 2408208..c60d373 100644 --- a/dist/zeynep.min.css +++ b/dist/zeynep.min.css @@ -1,2 +1,8 @@ -.zeynep{bottom:0;overflow:hidden;-webkit-overflow-scrolling:touch;overflow-y:auto;pointer-events:none;position:fixed;top:0;transform:translateX(-100%);z-index:1011}.zeynep .submenu:not(.no-transition),.zeynep:not(.no-transition){transition:all 250ms}.zeynep-overlay{background-color:rgba(0,0,0,.42);bottom:0;display:none;left:0;position:fixed;right:0;top:0;z-index:1010}.zeynep-opened .zeynep-overlay{display:block}.zeynep.opened{pointer-events:auto;transform:translateX(0)}.zeynep.submenu-opened{overflow:hidden}.zeynep .submenu{bottom:0;min-height:100%;overflow:hidden;-webkit-overflow-scrolling:touch;overflow-y:auto;pointer-events:none;position:fixed;top:0;width:100%}.zeynep .submenu.opened{left:0;pointer-events:auto}.zeynep .submenu.opened:not(.current){overflow:hidden} +/*! +* zeynepjs v2.1.4 +* A light-weight multi-level jQuery side menu plugin. +* It's fully customizable and is compatible with modern browsers such as Google Chrome, Mozilla Firefox, Safari, Edge and Internet Explorer +* MIT License +* by Huseyin ELMAS +*/.zeynep{bottom:0;overflow:hidden;-webkit-overflow-scrolling:touch;overflow-y:auto;pointer-events:none;position:fixed;top:0;transform:translateX(-100%);z-index:1011}.zeynep .submenu:not(.no-transition),.zeynep:not(.no-transition){transition:all 250ms}.zeynep-overlay{background-color:rgba(0,0,0,.42);bottom:0;display:none;left:0;position:fixed;right:0;top:0;z-index:1010}.zeynep-opened .zeynep-overlay{display:block}.zeynep.opened{pointer-events:auto;transform:translateX(0)}.zeynep.submenu-opened{overflow:hidden}.zeynep .submenu{bottom:0;min-height:100%;overflow:hidden;-webkit-overflow-scrolling:touch;overflow-y:auto;pointer-events:none;position:fixed;top:0;width:100%}.zeynep .submenu.opened{left:0;pointer-events:auto}.zeynep .submenu.opened:not(.current){overflow:hidden} /*# sourceMappingURL=zeynep.min.css.map */ diff --git a/dist/zeynep.min.css.map b/dist/zeynep.min.css.map index fb6cde3..0b45fe9 100644 --- a/dist/zeynep.min.css.map +++ b/dist/zeynep.min.css.map @@ -1 +1 @@ -{"version":3,"sources":["zeynep.css"],"names":[],"mappings":"AAAA,QAEA,OAAA,EAEA,SAAA,OAKA,2BAAA,MAJA,WAAA,KAEA,eAAA,KAJA,SAAA,MAFA,IAAA,EAOA,UAAA,kBAFA,QAAA,KAcA,qCARA,4BAGA,WAAA,IAAA,MAGA,gBAQA,iBAAA,gBAJA,OAAA,EACA,QAAA,KAHA,KAAA,EAIA,SAAA,MAHA,MAAA,EAFA,IAAA,EAMA,QAAA,KAIA,+BACA,QAAA,MAGA,eACA,eAAA,KACA,UAAA,cAGA,uBACA,SAAA,OAGA,iBAEA,OAAA,EACA,WAAA,KACA,SAAA,OAKA,2BAAA,MAJA,WAAA,KAGA,eAAA,KAFA,SAAA,MALA,IAAA,EAMA,MAAA,KAKA,wBACA,KAAA,EACA,eAAA,KAGA,sCACA,SAAA","file":"zeynep.min.css","sourcesContent":[".zeynep {\r\n top: 0;\r\n bottom: 0;\r\n position: fixed;\r\n overflow: hidden;\r\n overflow-y: auto;\r\n z-index: 1011;\r\n pointer-events: none;\r\n transform: translateX(-100%);\r\n -webkit-overflow-scrolling: touch;\r\n}\r\n\r\n.zeynep:not(.no-transition),\r\n.zeynep .submenu:not(.no-transition) {\r\n /* if transitions are not disabled */\r\n transition: all 250ms;\r\n}\r\n\r\n.zeynep-overlay {\r\n top: 0;\r\n left: 0;\r\n right: 0;\r\n bottom: 0;\r\n display: none;\r\n position: fixed;\r\n z-index: 1010;\r\n background-color: rgba(0, 0, 0, .42);\r\n}\r\n\r\n.zeynep-opened .zeynep-overlay {\r\n display: block;\r\n}\r\n\r\n.zeynep.opened {\r\n pointer-events: auto;\r\n transform: translateX(0px);\r\n}\r\n\r\n.zeynep.submenu-opened {\r\n overflow: hidden;\r\n}\r\n\r\n.zeynep .submenu {\r\n top: 0;\r\n bottom: 0;\r\n min-height: 100%;\r\n overflow: hidden;\r\n overflow-y: auto;\r\n position: fixed;\r\n width: 100%;\r\n pointer-events: none;\r\n -webkit-overflow-scrolling: touch;\r\n}\r\n\r\n.zeynep .submenu.opened {\r\n left: 0;\r\n pointer-events: auto;\r\n}\r\n\r\n.zeynep .submenu.opened:not(.current) {\r\n overflow: hidden;\r\n}\r\n"]} \ No newline at end of file +{"version":3,"sources":["zeynep.css"],"names":[],"mappings":"AAAA;;;;;;AAAA,QAEA,OAAA,EAEA,SAAA,OAKA,2BAAA,MAJA,WAAA,KAEA,eAAA,KAJA,SAAA,MAFA,IAAA,EAOA,UAAA,kBAFA,QAAA,KAcA,qCARA,4BAGA,WAAA,IAAA,MAGA,gBAQA,iBAAA,gBAJA,OAAA,EACA,QAAA,KAHA,KAAA,EAIA,SAAA,MAHA,MAAA,EAFA,IAAA,EAMA,QAAA,KAIA,+BACA,QAAA,MAGA,eACA,eAAA,KACA,UAAA,cAGA,uBACA,SAAA,OAGA,iBAEA,OAAA,EACA,WAAA,KACA,SAAA,OAKA,2BAAA,MAJA,WAAA,KAGA,eAAA,KAFA,SAAA,MALA,IAAA,EAMA,MAAA,KAKA,wBACA,KAAA,EACA,eAAA,KAGA,sCACA,SAAA","file":"zeynep.min.css","sourcesContent":[".zeynep {\n top: 0;\n bottom: 0;\n position: fixed;\n overflow: hidden;\n overflow-y: auto;\n z-index: 1011;\n pointer-events: none;\n transform: translateX(-100%);\n -webkit-overflow-scrolling: touch;\n}\n\n.zeynep:not(.no-transition),\n.zeynep .submenu:not(.no-transition) {\n /* if transitions are not disabled */\n transition: all 250ms;\n}\n\n.zeynep-overlay {\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: none;\n position: fixed;\n z-index: 1010;\n background-color: rgba(0, 0, 0, .42);\n}\n\n.zeynep-opened .zeynep-overlay {\n display: block;\n}\n\n.zeynep.opened {\n pointer-events: auto;\n transform: translateX(0px);\n}\n\n.zeynep.submenu-opened {\n overflow: hidden;\n}\n\n.zeynep .submenu {\n top: 0;\n bottom: 0;\n min-height: 100%;\n overflow: hidden;\n overflow-y: auto;\n position: fixed;\n width: 100%;\n pointer-events: none;\n -webkit-overflow-scrolling: touch;\n}\n\n.zeynep .submenu.opened {\n left: 0;\n pointer-events: auto;\n}\n\n.zeynep .submenu.opened:not(.current) {\n overflow: hidden;\n}\n"]} \ No newline at end of file diff --git a/dist/zeynep.min.js b/dist/zeynep.min.js index 19a82de..de69745 100644 --- a/dist/zeynep.min.js +++ b/dist/zeynep.min.js @@ -1,5 +1,5 @@ /*! -* zeynepjs v2.1.3 +* zeynepjs v2.1.4 * A light-weight multi-level jQuery side menu plugin. * It's fully customizable and is compatible with modern browsers such as Google Chrome, Mozilla Firefox, Safari, Edge and Internet Explorer * MIT License diff --git a/dist/zeynep.min.js.map b/dist/zeynep.min.js.map index e5a0400..033c20b 100644 --- a/dist/zeynep.min.js.map +++ b/dist/zeynep.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["zeynep.js"],"names":["$","pluginName","defaults","htmlClass","Plugin","element","options","this","eventController","extend","initialized","init","prototype","zeynep","bind","find","on","event","preventDefault","eventDetails","subMenuId","attr","subMenuEl","length","subMenu","menuId","removeClass","addClass","hasClass","scrollTop","open","close","disableEvent","destroy","removeData","name","handler","eventBinder","call","type","details","Error","fn","instance","data","window","jQuery"],"mappings":";;;;;;;CAAA,SAAAA,EAAAC,GAEA,IAAAC,EAAA,CACAC,WAAA,GAHA,SAAAC,EAAAC,EAAAC,GACAC,KAAAF,QAAAA,EACAE,KAAAC,gBAAAA,EAGAD,KAAAD,QAAAN,EAAAS,OAAA,GAAAP,EAAAI,GACAC,KAAAD,QAAAI,aAAA,EAGAH,KAAAI,OAGAP,EAAAQ,UAAAD,KAAA,WACA,IAAAE,EAAAN,KAAAF,QACAC,EAAAC,KAAAD,QACAE,EAAAD,KAAAC,gBAAAM,KAAAP,OAGA,IAAAD,EAAAI,cAEAF,EAAA,WAGAK,EAAAE,KAAA,kBAAAC,GAAA,QAAA,SAAAC,GACAA,EAAAC,iBAEA,IAOAC,EANAC,EADApB,EAAAO,MACAc,KAAA,gBACAC,EAAAtB,EAAA,IAAAoB,GAGAE,EAAAC,SAOAf,EAAA,UALAW,EAAA,CACAK,SAAA,EACAC,OAAAL,IAMAP,EAAAE,KAAA,oBAAAW,YAAA,WACAJ,EAAAK,SAAA,kBACAd,EAAAe,SAAA,mBAAAf,EAAAc,SAAA,kBAGAd,EAAAgB,UAAA,GAEArB,EAAA,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,KAAA4B,EAAAC,IAGA,IAAA5B,EAAA,SAAA+B,EAAAC,GAEA,GAAAjC,KAAAD,QAAAiC,GAAA,CACA,GAAA,mBAAAhC,KAAAD,QAAAiC,GAAA,MAAAE,MAAA,qCAAAF,GAGAhC,KAAAD,QAAAiC,GAAAD,KAAA/B,KAAAA,KAAAF,QAAAE,KAAAD,QAAAkC,KAqBAH,EAAA,SAAAF,EAAAC,GAEA,GAAA,iBAAAD,EAAA,MAAAM,MAAA,yDAAAN,GACA,GAAA,mBAAAC,EAAA,MAAAK,MAAA,wCAAAN,GAGA5B,KAAAD,QAAA6B,GAAAC,GAKApC,EAAA0C,GAAAzC,GAAA,SAAAK,GAEA,IA/BAD,EAAAC,EACAqC,EAiCA,OAlCAtC,EA+BAL,EAAAO,KAAA,IA/BAD,EA+BAA,EA9BAqC,EAAA,KAEAtC,EAAAuC,KAAA3C,GASA0C,EAAAtC,EAAAuC,KAAA3C,IANA0C,EAAA,IAAAvC,EAAAC,EAAAC,GAAA,IAGAD,EAAAuC,KAAA3C,EAAA0C,IAMAA,GAtKA,CA2LAE,OAAAC,OAAA","file":"zeynep.min.js","sourcesContent":["(function ($, pluginName) {\r\n // plugin defaults\r\n var defaults = {\r\n htmlClass: true\r\n }\r\n\r\n // plugin constructor\r\n function Plugin (element, options) {\r\n this.element = element\r\n this.eventController = eventController\r\n\r\n // merge defaults with options\r\n this.options = $.extend({}, defaults, options)\r\n this.options.initialized = false\r\n\r\n // initialize the plugin\r\n this.init()\r\n }\r\n\r\n Plugin.prototype.init = function () {\r\n var zeynep = this.element\r\n var options = this.options\r\n var eventController = this.eventController.bind(this)\r\n\r\n // exit if already initialized\r\n if (options.initialized === true) return\r\n\r\n eventController('loading')\r\n\r\n // handle subMenu links/triggers click events\r\n zeynep.find('[data-submenu]').on('click', function (event) {\r\n event.preventDefault()\r\n\r\n var self = $(this)\r\n var subMenuId = self.attr('data-submenu')\r\n var subMenuEl = $('#' + subMenuId)\r\n\r\n // if subMenu not found, do nothing\r\n if (!subMenuEl.length) return\r\n\r\n var eventDetails = {\r\n subMenu: true,\r\n menuId: subMenuId\r\n }\r\n\r\n eventController('opening', eventDetails)\r\n\r\n // open the subMenu\r\n zeynep.find('.submenu.current').removeClass('current')\r\n subMenuEl.addClass('opened current')\r\n !zeynep.hasClass('submenu-opened') && zeynep.addClass('submenu-opened')\r\n\r\n // scroll to top before submenu transition\r\n zeynep.scrollTop(0)\r\n\r\n eventController('opened', eventDetails)\r\n })\r\n\r\n // handle subMenu closers click events\r\n zeynep.find('[data-submenu-close]').on('click', function (event) {\r\n event.preventDefault()\r\n\r\n var self = $(this)\r\n var subMenuId = self.attr('data-submenu-close')\r\n var subMenuEl = $('#' + subMenuId)\r\n\r\n // if subMenu not found, do nothing\r\n if (!subMenuEl.length) return\r\n\r\n var eventDetails = {\r\n subMenu: true,\r\n menuId: subMenuId\r\n }\r\n\r\n eventController('closing', eventDetails)\r\n\r\n // close subMenu\r\n subMenuEl.removeClass('opened current')\r\n zeynep.find('.submenu.opened:last').addClass('current')\r\n !zeynep.find('.submenu.opened').length && zeynep.removeClass('submenu-opened')\r\n\r\n // scroll to top between submenu transitions\r\n subMenuEl.scrollTop(0)\r\n\r\n eventController('closed', eventDetails)\r\n })\r\n\r\n eventController('load')\r\n\r\n // zeynepjs successfully initialized\r\n this.options.htmlClass && !$('html').hasClass('zeynep-initialized') && $('html').addClass('zeynep-initialized')\r\n\r\n options.initialized = true\r\n }\r\n\r\n Plugin.prototype.open = function () {\r\n this.eventController(\r\n 'opening',\r\n { subMenu: false }\r\n )\r\n\r\n // zeynepjs menu is opened\r\n this.element.addClass('opened')\r\n this.options.htmlClass && $('html').addClass('zeynep-opened')\r\n\r\n this.eventController(\r\n 'opened',\r\n { subMenu: false }\r\n )\r\n }\r\n\r\n Plugin.prototype.close = function (disableEvent) {\r\n !disableEvent && this.eventController('closing', { subMenu: false })\r\n\r\n // zeynepjs menu is opened\r\n this.element.removeClass('opened')\r\n this.options.htmlClass && $('html').removeClass('zeynep-opened')\r\n\r\n !disableEvent && this.eventController('closed', { subMenu: false })\r\n }\r\n\r\n Plugin.prototype.destroy = function () {\r\n this.eventController('destroying')\r\n\r\n // close the menu without firing any event\r\n this.close(true)\r\n\r\n // close submenus\r\n this.element.find('.submenu.opened').removeClass('opened')\r\n\r\n // clear/remove the instance on the element\r\n this.element.removeData(pluginName)\r\n\r\n this.eventController('destroyed')\r\n\r\n // reset options\r\n this.options = defaults\r\n\r\n this.options.htmlClass && $('html').removeClass('zeynep-initialized')\r\n\r\n delete this.element\r\n delete this.options\r\n delete this.eventController\r\n }\r\n\r\n Plugin.prototype.on = function (name, handler) {\r\n eventBinder.call(this, name, handler)\r\n }\r\n\r\n var eventController = function (type, details) {\r\n // validations\r\n if (!this.options[type]) return\r\n if (typeof this.options[type] !== 'function') throw Error('event handler must be a function: ' + type)\r\n\r\n // call the event\r\n this.options[type].call(this, this.element, this.options, details)\r\n }\r\n\r\n var getInstance = function (element, options) {\r\n var instance = null\r\n\r\n if (!element.data(pluginName)) {\r\n // zeynepjs is not initialized for the element\r\n // crceate a new instance\r\n instance = new Plugin(element, options || {})\r\n\r\n // put the instance on element\r\n element.data(pluginName, instance)\r\n } else {\r\n // return the already initialized instance\r\n instance = element.data(pluginName)\r\n }\r\n\r\n return instance\r\n }\r\n\r\n var eventBinder = function (name, handler) {\r\n // validations\r\n if (typeof name !== 'string') throw Error('event name is expected to be a string but got: ' + typeof name)\r\n if (typeof handler !== 'function') throw Error('event handler is not a function for: ' + name)\r\n\r\n // update options\r\n this.options[name] = handler\r\n }\r\n\r\n // a really lightweight plugin wrapper around the constructor\r\n // preventing against multiple instantiations\r\n $.fn[pluginName] = function (options) {\r\n // get a zeynepjs instance\r\n var instance = getInstance($(this[0]), options)\r\n\r\n // return the instance\r\n return instance\r\n }\r\n})(window.jQuery, 'zeynep')\r\n"]} \ No newline at end of file +{"version":3,"sources":["zeynep.js"],"names":["$","pluginName","defaults","htmlClass","Plugin","element","options","this","eventController","extend","initialized","init","prototype","zeynep","bind","find","on","event","preventDefault","eventDetails","subMenuId","attr","subMenuEl","length","subMenu","menuId","removeClass","addClass","hasClass","scrollTop","open","close","disableEvent","destroy","removeData","name","handler","eventBinder","call","type","details","Error","fn","instance","data","window","jQuery"],"mappings":";;;;;;;CAAA,SAAAA,EAAAC,GACA,IAAAC,EAAA,CACAC,WAAA,GAGA,SAAAC,EAAAC,EAAAC,GACAC,KAAAF,QAAAA,EANAE,KAAAC,gBAAAA,EACAD,KAAAD,QAAAN,EAAAS,OAAA,GAAAP,EAAAI,GACAC,KAAAD,QAAAI,aAAA,EAEAH,KAAAI,OAGAP,EAAAQ,UAAAD,KAAA,WACA,IAAAE,EAAAN,KAAAF,QACAC,EAAAC,KAAAD,QACAE,EAAAD,KAAAC,gBAAAM,KAAAP,OAGA,IAAAD,EAAAI,cAEAF,EAAA,WAGAK,EAAAE,KAAA,kBAAAC,GAAA,QAAA,SAAAC,GACAA,EAAAC,iBAEA,IAOAC,EANAC,EADApB,EAAAO,MACAc,KAAA,gBACAC,EAAAtB,EAAA,IAAAoB,GAGAE,EAAAC,SAOAf,EAAA,UALAW,EAAA,CACAK,SAAA,EACAC,OAAAL,IAMAP,EAAAE,KAAA,oBAAAW,YAAA,WACAJ,EAAAK,SAAA,kBACAd,EAAAe,SAAA,mBAAAf,EAAAc,SAAA,kBAGAd,EAAAgB,UAAA,GAEArB,EAAA,SAAAW,MAIAN,EAAAE,KAAA,wBAAAC,GAAA,QAAA,SAAAC,GACAA,EAAAC,iBAEA,IAOAC,EANAC,EADApB,EAAAO,MACAc,KAAA,sBACAC,EAAAtB,EAAA,IAAAoB,GAGAE,EAAAC,SAOAf,EAAA,UALAW,EAAA,CACAK,SAAA,EACAC,OAAAL,IAMAE,EAAAI,YAAA,kBACAb,EAAAE,KAAA,wBAAAY,SAAA,WACAd,EAAAE,KAAA,mBAAAQ,QAAAV,EAAAa,YAAA,kBAGAJ,EAAAO,UAAA,GAEArB,EAAA,SAAAW,MA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KAAAD,QAAA6B,GAAAC,GAKApC,EAAA0C,GAAAzC,GAAA,SAAAK,GAEA,IA9BAD,EAAAC,EACAqC,EA+BA,OAhCAtC,EA8BAL,EAAAO,KAAA,IA9BAD,EA8BAA,EA7BAqC,EAAA,KAEAtC,EAAAuC,KAAA3C,GASA0C,EAAAtC,EAAAuC,KAAA3C,IANA0C,EAAA,IAAAvC,EAAAC,EAAAC,GAAA,IAGAD,EAAAuC,KAAA3C,EAAA0C,IAMAA,GAhKA,CAmLAE,OAAAC,OAAA","file":"zeynep.min.js","sourcesContent":["(function ($, pluginName) {\n var defaults = {\n htmlClass: true\n }\n\n function Plugin (element, options) {\n this.element = element\n this.eventController = eventController\n this.options = $.extend({}, defaults, options)\n this.options.initialized = false\n\n this.init()\n }\n\n Plugin.prototype.init = function () {\n var zeynep = this.element\n var options = this.options\n var eventController = this.eventController.bind(this)\n\n // exit if already initialized\n if (options.initialized === true) return\n\n eventController('loading')\n\n // handle subMenu links/triggers click events\n zeynep.find('[data-submenu]').on('click', function (event) {\n event.preventDefault()\n\n var self = $(this)\n var subMenuId = self.attr('data-submenu')\n var subMenuEl = $('#' + subMenuId)\n\n // if subMenu not found, do nothing\n if (!subMenuEl.length) return\n\n var eventDetails = {\n subMenu: true,\n menuId: subMenuId\n }\n\n eventController('opening', eventDetails)\n\n // open the subMenu\n zeynep.find('.submenu.current').removeClass('current')\n subMenuEl.addClass('opened current')\n !zeynep.hasClass('submenu-opened') && zeynep.addClass('submenu-opened')\n\n // scroll to top before submenu transition\n zeynep.scrollTop(0)\n\n eventController('opened', eventDetails)\n })\n\n // handle subMenu closers click events\n zeynep.find('[data-submenu-close]').on('click', function (event) {\n event.preventDefault()\n\n var self = $(this)\n var subMenuId = self.attr('data-submenu-close')\n var subMenuEl = $('#' + subMenuId)\n\n // if subMenu not found, do nothing\n if (!subMenuEl.length) return\n\n var eventDetails = {\n subMenu: true,\n menuId: subMenuId\n }\n\n eventController('closing', eventDetails)\n\n // close subMenu\n subMenuEl.removeClass('opened current')\n zeynep.find('.submenu.opened:last').addClass('current')\n !zeynep.find('.submenu.opened').length && zeynep.removeClass('submenu-opened')\n\n // scroll to top between submenu transitions\n subMenuEl.scrollTop(0)\n\n eventController('closed', eventDetails)\n })\n\n eventController('load')\n\n // zeynepjs successfully initialized\n this.options.htmlClass && !$('html').hasClass('zeynep-initialized') && $('html').addClass('zeynep-initialized')\n\n options.initialized = true\n }\n\n Plugin.prototype.open = function () {\n this.eventController(\n 'opening',\n { subMenu: false }\n )\n\n // zeynepjs menu is opened\n this.element.addClass('opened')\n this.options.htmlClass && $('html').addClass('zeynep-opened')\n\n this.eventController(\n 'opened',\n { subMenu: false }\n )\n }\n\n Plugin.prototype.close = function (disableEvent) {\n !disableEvent && this.eventController('closing', { subMenu: false })\n\n // zeynepjs menu is opened\n this.element.removeClass('opened')\n this.options.htmlClass && $('html').removeClass('zeynep-opened')\n\n !disableEvent && this.eventController('closed', { subMenu: false })\n }\n\n Plugin.prototype.destroy = function () {\n this.eventController('destroying')\n\n // close the menu without firing any event\n this.close(true)\n\n // close submenus\n this.element.find('.submenu.opened').removeClass('opened')\n\n // clear/remove the instance on the element\n this.element.removeData(pluginName)\n\n this.eventController('destroyed')\n\n // reset options\n this.options = defaults\n\n this.options.htmlClass && $('html').removeClass('zeynep-initialized')\n\n delete this.element\n delete this.options\n delete this.eventController\n }\n\n Plugin.prototype.on = function (name, handler) {\n eventBinder.call(this, name, handler)\n }\n\n var eventController = function (type, details) {\n if (!this.options[type]) return\n if (typeof this.options[type] !== 'function') throw Error('event handler must be a function: ' + type)\n\n // call the event\n this.options[type].call(this, this.element, this.options, details)\n }\n\n var getInstance = function (element, options) {\n var instance = null\n\n if (!element.data(pluginName)) {\n // zeynepjs is not initialized for the element\n // crceate a new instance\n instance = new Plugin(element, options || {})\n\n // put the instance on element\n element.data(pluginName, instance)\n } else {\n // return the already initialized instance\n instance = element.data(pluginName)\n }\n\n return instance\n }\n\n var eventBinder = function (name, handler) {\n if (typeof name !== 'string') throw Error('event name is expected to be a string but got: ' + typeof name)\n if (typeof handler !== 'function') throw Error('event handler is not a function for: ' + name)\n\n // update options\n this.options[name] = handler\n }\n\n // a really lightweight plugin wrapper around the constructor\n // preventing against multiple instantiations\n $.fn[pluginName] = function (options) {\n // get a zeynepjs instance\n var instance = getInstance($(this[0]), options)\n\n return instance\n }\n})(window.jQuery, 'zeynep')\n"]} \ No newline at end of file diff --git a/package.json b/package.json index 409c4c5..713f6c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zeynepjs", - "version": "2.1.3", + "version": "2.1.4", "description": "a lightweight, multi-level jQuery side menu plugin", "main": "./dist/zeynep.js", "style": "./dist/zeynep.css",