HSMETU-jQuery插件*@version:1.0(Sun,2017年2月26日)*@requires:jQueryv1.6或/***创建特大菜单*#@constructor*@param{HTMLELQQQERY}元素-创建特大菜单元素++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++MegaMenu=service函数MegaMenu/***当前元素*#@public*/element=$/***当前选项由调用者设置包括默认值*#@public*/this.options=$.extend/***集合菜单元素*#@private*/messions=$Object.defineProperties(This, {/***内含菜单项选择器*#@public*/项选择器:{获取函数{返回自.ops.squalmap.hasSubMenu++++.oclemap.hasMegaMenu}},/***包含活动项链*#@private*/_tempchain:{value:Null,可写字性: true}/***包含当前行为状态*#@public*/state:{value:Null,可写: true}this.initialize()!返回MegaMenu}()!/***特大菜单默认选项* * @public */ MegaMenu.defaults = { event: 'hover', direction: 'horizontal', breakpoint: 991, animationIn: false, animationOut: false, rtl: false, hideTimeOut: 300, // For 'vertical' direction only sideBarRatio: 1 / 4, pageContainer: $('body'), classMap: { initialized: '.hs-menu-initialized', mobileState: '.hs-mobile-state', subMenu: '.hs-sub-menu', hasSubMenu: '.hs-has-sub-menu', hasSubMenuActive: '.hs-sub-menu-opened', megaMenu: '.hs-mega-menu', hasMegaMenu: '.hs-has-mega-menu', hasMegaMenuActive: '.hs-mega-menu-opened' }, mobileSpeed: 400, mobileEasing: 'linear', beforeOpen: function () {}, beforeClose: function () {}, afterOpen: function () {}, afterClose: function () {} }!/***插件初始化served*/Menu.prototyif (this.options.rtl) this.$element.addClass('hs-rtl')!adclisss-s-s-s-s-s/独立事件$w.on.HSMENU函数e重定义TimeOutId=setTimeout(函数){if(Window.innerWidth+#self.options.brackpoint+Qif.instopBehavior自.refresh,50)})!$(documents).on(clock.HSMEGAMENUiself.closeAll($parents.add($(e.target)))!})!$won('keyup.HSMENU',函数(e){manu开关=假} })!if (window.innerWidth <= this.options.breakpoint) this.initMobileBehavior()!if.innerWidth > this.options.breakpoint)this.smartPositions()!交还这个}!megaMenu.prototype.smartpoties=函数 (){varselfs=$submenus.each})!}!/***绑定事件菜单元素/MegaMenu.proto类型.bindEvents=函数// Hover case if (this.options.event === 'hover' && !_isTouch()) { this.$element .on( 'mouseenter.HSMegaMenu', this.options.classMap.hasMegaMenu + ':not([data-event="click"]),' + this.options.classMap.hasSubMenu + ':not([data-event="click"])', function (e) { var $this = $(this), $chain = $this.parents(self.itemsSelector)!/Lazy初始化$链=$链.addself.closeAll($chain)!excleformssvr HSMENUTETs=$.el.dataif (HSMenuItem.hideTimeOutId) clearTimeout(HSMenuItem.hideTimeOutId)!HSMenuItem.desktopShow()!})!自.ijects = 自.ijects.notempchain=$链e.preventDefault()!e.stopPropagation()!} ) .on( 'mouseleave.HSMegaMenu', this.options.classMap.hasMegaMenu + ':not([data-event="click"]),' + this.options.classMap.hasSubMenu + ':not([data-event="click"])', function (e) { var $this = $(this), HSMenuItem = $this.data('HSMenuItem'), $chain = $(e.relatedTarget).parents(self.itemsSelector)!HSMenuTrole.himeOutid=setimout自我选择时间流出self._items = self._items.add(self._tempChain)!empchain=ne.preventDefault()!e.stopPropagation()!} ) .on( 'click.HSMegaMenu', this.options.classMap.hasMegaMenu + '[data-event="click"] > a, ' + this.options.classMap.hasSubMenu + '[data-event="click"] > a', function (e) { var $this = $(this).parent('[data-event="click"]'), HSMenuItem!/Lazy初始化自.closeAll($xy.addHSMENU项目=$this.datahsmenuTroot.destopHide{HSMENUTUe.defaulte.stopPropagation()!} )!//blackcase else{c.$lement.on(点击.HSMENU)this.options.classMap.hasMegaMenu + ' > a, ' + this.options.classMap.hasSubMenu + ' > a' : this.options.classMap.hasMegaMenu + ':not([data-event="hover"]) > a,' + this.options.classMap.hasSubMenu + ':not([data-event="hover"]) > a'), function (e) { var $this = $(this).parent(), HSMenuItem, $parents = $this.parents(self.itemsSelector)!/Lazy初始化自.closeAll($xy.addhsenu项目=$this.addclasshsmenuTroot.destopHide{HSMENUTUe.defaulte.stopPropagation()!} )!if (!_isTouch()) { this.$element .on( 'mouseenter.HSMegaMenu', this.options.classMap.hasMegaMenu + '[data-event="hover"],' + this.options.classMap.hasSubMenu + '[data-event="hover"]', function (e) { var $this = $(this), $parents = $this.parents(self.itemsSelector)!/Lazy初始化自.closeAll$courts.add($this).each(函数i,el){varHSMenuTroleif (HSMenuItem.hideTimeOutId) clearTimeout(HSMenuItem.hideTimeOutId)!HSMenuItem.desktopShow()!})!e.preventDefault()!e.stopPropagation()!} ) .on( 'mouseleave.HSMegaMenu', this.options.classMap.hasMegaMenu + '[data-event="hover"],' + this.options.classMap.hasSubMenu + '[data-event="hover"]', function (e) { var $this = $(this), HSMenuItem = $this.data('HSMenuItem')!HSMENUTLOT.HIDYOTLED=setimout(函数){self.closeAll自我选择时间流出e.preventDefault()!e.stopPropagation()!a.options.hasMenu+ 'a.+thops.map.hasSubMenu+'a/Lazy初始化HSMENUTUETUifthis.is('s:焦点') {fif(e.keyCode##e.keyCode###40)HSMenuItem.desktopShow()!manu开关=真{HSMENUTUTUmanu开关=假{HSMENUTUmanu开关=真wr}$This.on('聚焦',函数(){menopened=伪!})!HSMENUTLET.Emenu.finddmanu开关=假} })!})!}) }!/***初始化某些菜单项/Menu.prototype.initMenuTrojects=函数(元素类型){varself=megaMenu:subMenu],$.extendelement.data('HSMenuItem', Item)!._项目=._项目.add(元素)}!/***销毁桌面行为并初始化移动行为/MegaMenu.proto类型.iitMobileBehavior=函数状态=移动expects.off.off./Lazy初始化自我.closeAll($xy.projects.add菜单项目动向 =$this.data{菜单项 instance.mobileHide{菜单项 instance.mobileshowe.defaulte.stopPropagation()!findd(Tems选择器).not(options.squlmap.hasSubMenuApive+++th.options.squalmap.hasMegaMenua}!/** * 破坏移动行为并初始化桌面行为iitdesktopBehavior=函数expects.map.hasSubmeathis.bindEvents()!}!/***隐藏所有打开子菜单/megamenus*#@param{jQuery}除外-集合元素,这些元素不应关闭{varself返回._项目.notexcept:$(i,el){.reveclasss/'hs-event预防'移动隐藏 桌面隐藏})!}!/***返回子菜单类型基于指定的菜单项{jQuery}项目*@regive{String{null}*#mpublic*/MegaMenu.prototype.getType=函数jjjjjjjjjreturn item.hasClass(this.options.classMap.hasSubMenu.slice(1)) ?子菜单 : (it.hasclass(this.options.map.hasMegaMenu.slice(1))mega-menu:Null)}!/***返回当前菜单状态sproto类型.getstate=函数}!/***更新所有菜单项的界限service{jQuery}*#public*/Menu.pretroy.refresh=函数})!}!/***创建特大菜单元素{jQuery}选项*/***当前菜单项元素*#@public*//***当前特大菜单元素*#@public*/ this.menu=菜单/***项目选项*#@public*/i.options=options/***MegaMenu容器*#@public*/ this.$tainer=容器Object.defineProperties(This, {/***内含cs类菜单项元素*#@public*/littleClass:{获取函数{返回自.options.自选方案.map.hasMea}}, /** * 包含cs主动级菜单项元素*#@public*/主动TrojectClass:{获取:函数{返回自.options.自选方法.map.hasMegaMenuAbjective自选方法.sqmap.hasSubMealive}}, /*** 包含cs类菜单元素*#@public*/mecliss:{获取函数{返回自.options.自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选自选}}开关 : {获取函数 {返回此.ementle.hasClasss/} } })!.menu.addclasss.on.})!if (this.$element.data('max-width')) this.menu.css('max-width', this.$element.data('max-width'))!if (this.$element.data('position')) this.menu.addClass('hs-position-' + this.$element.data('position'))!if.webkitAntiationEndmationEnd Oimanationend',函数(e){form.menu.hasclasssself.options.afterClose.call(self, self.$element, self.menu)!if.menu.hasClasss(self.options.animationIn)e.stoppagatione.preventDefault()!})!/***显示超菜单项*#@public*@regive{MenuTroject}*/MenuTroject.protothis.$element.addClass(this.activeItemClass.slice(1))!this._updateMenuBounds()!this.menu.show()!smartPostition(This.menu, this.options)if.objects.animationOpt{此.options.fteropen.callif.options.animation in/***隐藏特大菜单项public*@regive{MenuTroject}*/MenuTroject.proto类型.topHide=函数if(!本.menu.this.$element.removeClass(this.activeItemClass.slice(1))!this.menu.hide()!if.objects.animation in{.menu.addclasss/this.options.animationout){此.options.fterClose.call交还这个/***显示超菜单项*#@public*@reture{MenuTroject}*/MenuTroject.proto类型.mobleshow=函数if(!本.menu..eveClasss.reveClasss.reveClass.objects.animationOpt.slideDown} })!this.$element.addClass(this.activeItemClass.slice(1))!交还这个}!/***隐藏特大菜单项public*@regive{MenuTroject}*/MenuTroject.proto类型.mobileHide=函数if(!本.menu.slideUp({{自选s.mobileSpeed,自定义.objects.mobleEasing/complete} })!this.$element.removeClass(this.activeItemClass.slice(1))!交还这个}!/***检查元素是否在视图港smartpotition=函数(元素、选项){菜单I}!/***检查元素是否在视图港smartpotition=函数(元素,选项){ifVar $w=$element.removeClass('hs-reversed')!if.objects.rtl/{ddclass/wrds/***更新当前打开菜单的界限ivar宽度=autiif.objectives.gentives.glips.宽度=此.objects.pleater.outerWidth{宽度=auto.menu.cssssif.menu.outerH8() > this.$contrace.outerH8()sxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.menu.csss} }!/***jQuery插件MegaMenupublic*/$.fn.HSMENU=函数 (){var_formsssil!++/ets=_#.MegaMenu返回ret返回_}!/***帮助检测环境触摸事件函数stoch () {fluntstart+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}(jQuery);
Baidu
map