|
|
!function(a,b,c,d){a.fn.dropdown=function(b){var e,f=a(this),g=a(c),h=a.isPlainObject(b)?a.extend(!0,{},a.fn.dropdown.settings,b):a.fn.dropdown.settings,i=h.className,j=h.metadata,k=h.namespace,l=h.selector,m=h.error,n="."+k,o="module-"+k,p=f.selector||"",q=(new Date).getTime(),r=[],s=arguments[0],t="string"==typeof s,u=[].slice.call(arguments,1);return f.each(function(){var b,e=a(this),k=e.find(l.item),v=e.find(l.text),w=e.find(l.input),x=e.children(l.menu),y="ontouchstart"in c.documentElement,z=this,A=e.data(o);b={initialize:function(){b.debug("Initializing dropdown",h),y?e.on("touchstart"+n,b.event.test.toggle):"click"==h.on?e.on("click"+n,b.event.test.toggle):"hover"==h.on?e.on("mouseenter"+n,b.delay.show).on("mouseleave"+n,b.delay.hide):e.on(h.on+n,b.toggle),"updateForm"==h.action&&b.set.selected(),k.on("mouseenter"+n,b.event.item.mouseenter).on("mouseleave"+n,b.event.item.mouseleave).on(b.get.selectEvent()+n,b.event.item.click),b.instantiate()},instantiate:function(){b.verbose("Storing instance of dropdown",b),e.data(o,b)},destroy:function(){b.verbose("Destroying previous dropdown for",e),k.off(n),e.off(n).removeData(o)},event:{stopPropagation:function(a){a.stopPropagation()},test:{toggle:function(a){b.determine.intent(a,b.toggle),a.stopImmediatePropagation()},hide:function(a){b.determine.intent(a,b.hide),a.stopPropagation()}},item:{mouseenter:function(){var c=a(this).find(l.menu),d=a(this).siblings(l.item).children(l.menu);c.size()>0&&(clearTimeout(b.itemTimer),b.itemTimer=setTimeout(function(){b.animate.hide(!1,d),b.verbose("Showing sub-menu",c),b.animate.show(!1,c)},2*h.delay.show))},mouseleave:function(){var c=a(this).find(l.menu);c.size()>0&&(clearTimeout(b.itemTimer),b.itemTimer=setTimeout(function(){b.verbose("Hiding sub-menu",c),b.animate.hide(!1,c)},h.delay.hide))},click:function(c){var d=a(this),e=d.data(j.text)||d.text(),f=d.data(j.value)||e.toLowerCase();0===d.find(l.menu).size()&&(b.verbose("Adding active state to selected item"),k.removeClass(i.active),d.addClass(i.active),b.determine.selectAction(e,f),a.proxy(h.onChange,z)(f,e),c.stopPropagation())}},resetStyle:function(){a(this).removeAttr("style")}},determine:{selectAction:function(c,d){b.verbose("Determining action",h.action),a.isFunction(b[h.action])?(b.verbose("Triggering preset action",h.action),b[h.action](c,d)):a.isFunction(h.action)?(b.verbose("Triggering user action",h.action),h.action(c,d)):b.error(m.action)},intent:function(c,d){b.debug("Determining whether event occurred in dropdown",c.target),d=d||function(){},0===a(c.target).closest(x).size()?(b.verbose("Triggering event",d),d()):b.verbose("Event occurred in dropdown, canceling callback")}},bind:{intent:function(){b.verbose("Binding hide intent event to document"),g.on(b.get.selectEvent(),b.event.test.hide)}},unbind:{intent:function(){b.verbose("Removing hide intent event from document"),g.off(b.get.selectEvent())}},nothing:function(){},changeText:function(a){b.set.text(a),b.hide()},updateForm:function(a,c){b.set.text(a),b.set.value(c),b.hide()},get:{selectEvent:function(){return y?"touchstart":"click"},text:function(){return v.text()},value:function(){return w.val()},item:function(b){var c;return b=b||w.val(),k.each(function(){a(this).data(j.value)==b&&(c=a(this))}),c||!1}},set:{text:function(a){b.debug("Changing text",a,v),v.removeClass(i.placeholder),v.text(a)},value:function(a){b.debug("Adding selected value to hidden input",a,w),w.val(a)},active:function(){e.addClass(i.active)},visible:function(){e.addClass(i.visible)},selected:function(a){var c,d=b.get.item(a);d&&(b.debug("Setting selected menu item to",d),c=d.data(j.text)||d.text(),k.removeClass(i.active),d.addClass(i.active),b.set.text(c))}},remove:{active:function(){e.removeClass(i.active)},visible:function(){e.removeClass(i.visible)}},is:{visible:function(a){return a?a.is(":animated, :visible"):x.is(":animated, :visible")},hidden:function(a){return a?a.is(":not(:animated, :visible)"):x.is(":not(:animated, :visible)")}},can:{click:function(){return y||"click"==h.on},show:function(){return!e.hasClass(i.disabled)}},animate:{sho
|