|
|
!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.namespace,j="module-"+h.namespace,k=f.selector||"",l=(new Date).getTime(),m=[],n=arguments[0],o="string"==typeof n,p=[].slice.call(arguments,1);return f.each(function(){var b,q=a(this),r=a(this).find(h.selector.menu),s=a(this).find(h.selector.item),t=a(this).find(h.selector.text),u=a(this).find(h.selector.input),v="ontouchstart"in c.documentElement,w=(q.selector||"",this),x=q.data("module-"+h.namespace),y=h.className,z=h.metadata,A=h.namespace,B=h.animation,C=h.errors;b={initialize:function(){b.verbose("Initializing dropdown with bound events",q),v?q.on("touchstart"+i,b.event.test.toggle):"click"==h.on?q.on("click"+i,b.event.test.toggle):"hover"==h.on?q.on("mouseenter"+i,b.delay.show).on("mouseleave"+i,b.delay.hide):q.on(h.on+i,b.toggle),"form"==h.action&&b.set.selected(),s.on(b.get.selectEvent()+i,b.event.item.click),q.data(j,b)},destroy:function(){b.verbose("Destroying previous module for",q),q.off(A)},event:{stopPropagation:function(a){a.stopPropagation()},test:{toggle:function(a){b.intent.test(a,b.toggle),a.stopPropagation()},hide:function(a){b.intent.test(a,b.hide),a.stopPropagation()}},item:{click:function(c){var d=a(this),e=d.data(z.text)||d.text(),f=d.data(z.value)||e;b.verbose("Adding active state to selected item"),s.removeClass(y.active),d.addClass(y.active),b.action.determine(e,f),a.proxy(h.onChange,q.get())(f,e),c.stopPropagation()}},resetStyle:function(){a(this).removeAttr("style")}},intent:{test:function(c,d){b.debug("Determining whether event occurred in dropdown",c.target),d=d||function(){},0===a(c.target).closest(r).size()?(b.verbose("Triggering event",d),d()):b.verbose("Event occurred in dropdown, canceling callback")},bind:function(){b.verbose("Binding hide intent event to document"),g.on(b.get.selectEvent(),b.event.test.hide)},unbind:function(){b.verbose("Removing hide intent event from document"),g.off(b.get.selectEvent())}},action:{determine:function(c,d){a.isFunction(b.action[h.action])?(b.verbose("Triggering preset action",h.action),b.action[h.action](c,d)):a.isFunction(h.action)?(b.verbose("Triggering user action",h.action),h.action(c,d)):b.error(C.action)},none:function(){},hide:function(){b.hide()},changeText:function(a){b.set.text(a),b.hide()},form:function(a,c){b.set.text(a),b.set.value(c),b.hide()}},get:{selectEvent:function(){return v?"touchstart":"click"},text:function(){return t.text()},value:function(){return u.val()},item:function(b){var c;return b=b||u.val(),s.each(function(){a(this).data(z.value)==b&&(c=a(this))}),c||!1}},set:{text:function(a){b.debug("Changing text",a,t),t.removeClass(y.placeholder),t.text(a)},value:function(a){b.debug("Adding selected value to hidden input",a,u),u.val(a)},selected:function(a){var c,d=(a||u.val(),b.get.item(a));d&&(b.debug("Setting selected menu item to",d),c=d.data(z.text)||d.text(),s.removeClass(y.active),d.addClass(y.active),b.set.text(c))}},is:{visible:function(){return r.is(":visible")},hidden:function(){return r.is(":not(:visible)")}},can:{click:function(){return v||"click"==h.on},show:function(){return!q.hasClass(y.disabled)}},animate:{show:function(){b.verbose("Doing menu showing animation"),"none"==B.show?r.show():"fade"==B.show?r.hide().clearQueue().fadeIn(150,b.event.resetStyle):"slide"==B.show?r.hide().clearQueue().children().clearQueue().css("opacity",0).delay(50).animate({opacity:1},200,"easeOutQuad",b.event.resetStyle).end().slideDown(100,"easeOutQuad",b.event.resetStyle):b.error(C.animation)},hide:function(){b.verbose("Doing menu hiding animation"),"none"==B.hide?r.hide():"fade"==B.hide?r.show().clearQueue().fadeOut(150,b.event.resetStyle):"slide"==B.hide?r.show().clearQueue().children().clearQueue().css("opacity",1).animate({opacity:0},100,"easeOutQuad",b.event.resetStyle).end().delay(50).slideUp(100,"easeOutQuad",b.event.resetStyle):b.error(C.animation)}},show:function(){b.debug("Checking if dropdown can show"),b.is.visible()||(b.hideOthers(),q.addClass(y.visible),b.animat
|