From f155488f382d0774c42e61dfa9b580a0fc86ad5b Mon Sep 17 00:00:00 2001 From: Jack Lukic Date: Tue, 30 Jun 2015 22:17:59 -0400 Subject: [PATCH] Build dist --- dist/components/api.js | 5 +++-- dist/components/api.min.js | 2 +- dist/components/dropdown.js | 25 ++++++++++++++----------- dist/components/dropdown.min.js | 4 ++-- dist/components/embed.css | 6 ------ dist/components/menu.css | 12 ++++-------- dist/components/menu.min.css | 2 +- dist/components/rating.css | 2 +- dist/components/rating.min.css | 2 +- dist/semantic.css | 18 +++++------------- dist/semantic.js | 30 +++++++++++++++++------------- dist/semantic.min.css | 2 +- dist/semantic.min.js | 14 +++++++------- 13 files changed, 57 insertions(+), 67 deletions(-) diff --git a/dist/components/api.js b/dist/components/api.js index 2c42af075..63556d5ec 100644 --- a/dist/components/api.js +++ b/dist/components/api.js @@ -527,7 +527,6 @@ $.api = $.fn.api = function(parameters) { if(status == 'aborted') { module.debug('XHR Aborted (Most likely caused by page navigation or CORS Policy)', status, httpMessage); settings.onAbort.call(context, status, $module); - return; } else if(status == 'invalid') { module.debug('JSON did not pass success test. A server-side error has most likely occurred', response); @@ -543,7 +542,9 @@ $.api = $.fn.api = function(parameters) { settings.onError.call(context, errorMessage, $module); } } - if(settings.errorDuration) { + + if(settings.errorDuration && status !== 'aborted') { + module.debug('Adding error state'); module.set.error(); setTimeout(module.remove.error, settings.errorDuration); } diff --git a/dist/components/api.min.js b/dist/components/api.min.js index d0093209c..5ba868934 100644 --- a/dist/components/api.min.js +++ b/dist/components/api.min.js @@ -8,4 +8,4 @@ * http://opensource.org/licenses/MIT * */ -!function(e,t,r,n){"use strict";e.api=e.fn.api=function(r){var o,s=e(e.isFunction(this)?t:this),a=s.selector||"",i=(new Date).getTime(),u=[],c=arguments[0],d="string"==typeof c,l=[].slice.call(arguments,1);return s.each(function(){var s,g,f,m,p,b,v=e.isPlainObject(r)?e.extend(!0,{},e.fn.api.settings,r):e.extend({},e.fn.api.settings),h=v.namespace,y=v.metadata,q=v.selector,R=v.error,x=v.className,k="."+h,S="module-"+h,A=e(this),T=A.closest(q.form),P=v.stateContext?e(v.stateContext):A,w=this,j=P[0],D=A.data(S);b={initialize:function(){d||b.bind.events(),b.instantiate()},instantiate:function(){b.verbose("Storing instance of module",b),D=b,A.data(S,D)},destroy:function(){b.verbose("Destroying previous module for",w),A.removeData(S).off(k)},bind:{events:function(){var e=b.get.event();e?(b.verbose("Attaching API events to element",e),A.on(e+k,b.event.trigger)):"now"==v.on&&(b.debug("Querying API now",e),b.query())}},read:{cachedResponse:function(e){var r;if(t.Storage===n)return void b.error(R.noStorage);if(r=sessionStorage.getItem(e),b.debug("Using cached response",e,r),r!==n){try{r=JSON.parse(r)}catch(o){}return r}return!1}},write:{cachedResponse:function(r,o){return o&&""===o?void b.debug("Response empty, not caching",o):t.Storage===n?void b.error(R.noStorage):(e.isPlainObject(o)&&(o=JSON.stringify(o)),sessionStorage.setItem(r,o),void b.verbose("Storing cached response for url",r,o))}},query:function(){if(b.is.disabled())return void b.debug("Element is disabled API request aborted");if(b.is.loading()){if(!v.interruptRequests)return void b.debug("Cancelling request, previous request is still pending");b.debug("Interrupting previous request"),b.abort()}return v.defaultData&&e.extend(!0,v.urlData,b.get.defaultData()),v.serializeForm&&(v.data=b.add.formData(v.data)),g=b.get.settings(),g===!1?(b.cancelled=!0,void b.error(R.beforeSend)):(b.cancelled=!1,f=b.get.templatedURL(),f||b.is.mocked()?(f=b.add.urlData(f),f||b.is.mocked()?(s=e.extend(!0,{},v,{type:v.method||v.type,data:m,url:v.base+f,beforeSend:v.beforeXHR,success:function(){},failure:function(){},complete:function(){}}),b.debug("Querying URL",s.url),b.verbose("Using AJAX settings",s),"local"===v.cache&&b.read.cachedResponse(f)?(b.debug("Response returned from local cache"),b.request=b.create.request(),void b.request.resolveWith(j,[b.read.cachedResponse(f)])):void(v.throttle?v.throttleFirstRequest||b.timer?(b.debug("Throttling request",v.throttle),clearTimeout(b.timer),b.timer=setTimeout(function(){b.timer&&delete b.timer,b.debug("Sending throttled request",m,s.method),b.send.request()},v.throttle)):(b.debug("Sending request",m,s.method),b.send.request(),b.timer=setTimeout(function(){},v.throttle)):(b.debug("Sending request",m,s.method),b.send.request()))):void 0):void b.error(R.missingURL))},is:{disabled:function(){return A.filter(q.disabled).length>0},form:function(){return A.is("form")},mocked:function(){return v.mockResponse||v.mockResponseAsync},input:function(){return A.is("input")},loading:function(){return b.request&&"pending"==b.request.state()},abortedRequest:function(e){return e&&e.readyState!==n&&0===e.readyState?(b.verbose("XHR request determined to be aborted"),!0):(b.verbose("XHR request was not aborted"),!1)},validResponse:function(t){return"json"===v.dataType&&e.isFunction(v.successTest)?(b.debug("Checking JSON returned success",v.successTest,t),v.successTest(t)?(b.debug("Response passed success test",t),!0):(b.debug("Response failed success test",t),!1)):(b.verbose("Response is not JSON, skipping validation",v.successTest,t),!0)}},was:{cancelled:function(){return b.cancelled||!1},succesful:function(){return b.request&&"resolved"==b.request.state()},failure:function(){return b.request&&"rejected"==b.request.state()},complete:function(){return b.request&&("resolved"==b.request.state()||"rejected"==b.request.state())}},add:{urlData:function(t,r){var o,s;return t&&(o=t.match(v.regExp.required),s=t.match(v.regExp.optional),r=r||v.urlData,o&&(b.debug("Looking for required URL variables",o),e.each(o,function(o,s){var a=-1!==s.indexOf("$")?s.substr(2,s.length-3):s.substr(1,s.length-2),i=e.isPlainObject(r)&&r[a]!==n?r[a]:A.data(a)!==n?A.data(a):P.data(a)!==n?P.data(a):r[a];return i===n?(b.error(R.requiredParameter,a,t),t=!1,!1):(b.verbose("Found required variable",a,i),void(t=t.replace(s,i)))})),s&&(b.debug("Looking for optional URL variables",o),e.each(s,function(o,s){var a=-1!==s.indexOf("$")?s.substr(3,s.length-4):s.substr(2,s.length-3),i=e.isPlainObject(r)&&r[a]!==n?r[a]:A.data(a)!==n?A.data(a):P.data(a)!==n?P.data(a):r[a];i!==n?(b.verbose("Optional variable Found",a,i),t=t.replace(s,i)):(b.verbose("Optional variable not found",a),t=-1!==t.indexOf("/"+s)?t.replace("/"+s,""):t.replace(s,""))}))),t},formData:function(t){var r,o=e.fn.serializeObject!==n,s=o?T.serializeObject():T.serialize();return t=t||v.data,r=e.isPlainObject(t),r?o?(b.debug("Extending existing data with form data",t,s),t=e.extend(!0,{},t,s)):(b.error(R.missingSerialize),b.debug("Cant extend data. Replacing data with form data",t,s),t=s):(b.debug("Adding form data",s),t=s),t}},send:{request:function(){b.set.loading(),b.request=b.create.request(),b.is.mocked()?b.mockedXHR=b.create.mockedXHR():b.xhr=b.create.xhr(),v.onRequest.call(j,b.request,b.xhr)}},event:{trigger:function(e){b.query(),("submit"==e.type||"click"==e.type)&&e.preventDefault()},xhr:{always:function(){},done:function(t,r,n){var o=this,s=(new Date).getTime()-p,a=v.loadingDuration-s,i=e.isFunction(v.onResponse)?v.onResponse.call(o,e.extend(!0,{},t)):!1;a=a>0?a:0,i&&(b.debug("Modified API response in onResponse callback",v.onResponse,i,t),t=i),a>0&&b.debug("Response completed early delaying state change by",a),setTimeout(function(){b.is.validResponse(t)?b.request.resolveWith(o,[t]):b.request.rejectWith(o,[n,"invalid"])},a)},fail:function(e,t,r){var n=this,o=(new Date).getTime()-p,s=v.loadingDuration-o;s=s>0?s:0,s>0&&b.debug("Response completed early delaying state change by",s),setTimeout(function(){b.is.abortedRequest(e)?b.request.rejectWith(n,[e,"aborted",r]):b.request.rejectWith(n,[e,"error",t,r])},s)}},request:{complete:function(e){b.remove.loading(),v.onComplete.call(j,e,A)},done:function(e){b.debug("Successful API Response",e),"local"===v.cache&&f&&(b.write.cachedResponse(f,e),b.debug("Saving server response locally",b.cache)),v.onSuccess.call(j,e,A)},fail:function(t,r,o){var a=e.isPlainObject(t)?t.responseText:!1,i=e.isPlainObject(a)&&a.error!==n?a.error:v.error[r]!==n?v.error[r]:o;return"aborted"==r?(b.debug("XHR Aborted (Most likely caused by page navigation or CORS Policy)",r,o),void v.onAbort.call(j,r,A)):("invalid"==r?b.debug("JSON did not pass success test. A server-side error has most likely occurred",a):"error"==r&&t!==n&&(b.debug("XHR produced a server error",r,o),200!=t.status&&o!==n&&""!==o&&b.error(R.statusMessage+o,s.url),v.onError.call(j,i,A)),v.errorDuration&&(b.set.error(),setTimeout(b.remove.error,v.errorDuration)),b.debug("API Request failed",i,t),void v.onFailure.call(j,a,A))}}},create:{request:function(){return e.Deferred().always(b.event.request.complete).done(b.event.request.done).fail(b.event.request.fail)},mockedXHR:function(){var t,r,n,o=!1,s=!1,a=!1;return n=e.Deferred().always(b.event.xhr.complete).done(b.event.xhr.done).fail(b.event.xhr.fail),v.mockResponse?(e.isFunction(v.mockResponse)?(b.debug("Using mocked callback returning response",v.mockResponse),r=v.mockResponse.call(j,v)):(b.debug("Using specified response",v.mockResponse),r=v.mockResponse),n.resolveWith(j,[r,o,{responseText:r}])):e.isFunction(v.mockResponseAsync)&&(t=function(e){b.debug("Async callback returned response",e),e?n.resolveWith(j,[e,o,{responseText:e}]):n.rejectWith(j,[{responseText:e},s,a])},b.debug("Using async mocked response",v.mockResponseAsync),v.mockResponseAsync.call(j,v,t)),n},xhr:function(){var t;return t=e.ajax(s).always(b.event.xhr.always).done(b.event.xhr.done).fail(b.event.xhr.fail),b.verbose("Created server request",t),t}},set:{error:function(){b.verbose("Adding error state to element",P),P.addClass(x.error)},loading:function(){b.verbose("Adding loading state to element",P),P.addClass(x.loading),p=(new Date).getTime()}},remove:{error:function(){b.verbose("Removing error state from element",P),P.removeClass(x.error)},loading:function(){b.verbose("Removing loading state from element",P),P.removeClass(x.loading)}},get:{request:function(){return b.request||!1},xhr:function(){return b.xhr||!1},settings:function(){var e;return e=v.beforeSend.call(j,v),e&&(e.success!==n&&(b.debug("Legacy success callback detected",e),b.error(R.legacyParameters,e.success),e.onSuccess=e.success),e.failure!==n&&(b.debug("Legacy failure callback detected",e),b.error(R.legacyParameters,e.failure),e.onFailure=e.failure),e.complete!==n&&(b.debug("Legacy complete callback detected",e),b.error(R.legacyParameters,e.complete),e.onComplete=e.complete)),e===n&&b.error(R.noReturnedValue),e!==n?e:v},defaultData:function(){var t={};return e.isWindow(w)||(b.is.input()?t.value=A.val():b.is.form()&&(t.text=A.text())),t},event:function(){return e.isWindow(w)||"now"==v.on?(b.debug("API called without element, no events attached"),!1):"auto"==v.on?A.is("input")?w.oninput!==n?"input":w.onpropertychange!==n?"propertychange":"keyup":A.is("form")?"submit":"click":v.on},templatedURL:function(e){if(e=e||A.data(y.action)||v.action||!1,f=A.data(y.url)||v.url||!1)return b.debug("Using specified url",f),f;if(e){if(b.debug("Looking up url for action",e,v.api),v.api[e]===n&&!b.is.mocked())return void b.error(R.missingAction,v.action,v.api);f=v.api[e]}else b.is.form()&&(f=A.attr("action")||!1,b.debug("No url or action specified, defaulting to form action",f));return f}},abort:function(){var e=b.get.xhr();e&&"resolved"!==e.state()&&(b.debug("Cancelling API request"),e.abort())},reset:function(){b.remove.error(),b.remove.loading()},setting:function(t,r){if(b.debug("Changing setting",t,r),e.isPlainObject(t))e.extend(!0,v,t);else{if(r===n)return v[t];v[t]=r}},internal:function(t,r){if(e.isPlainObject(t))e.extend(!0,b,t);else{if(r===n)return b[t];b[t]=r}},debug:function(){v.debug&&(v.performance?b.performance.log(arguments):(b.debug=Function.prototype.bind.call(console.info,console,v.name+":"),b.debug.apply(console,arguments)))},verbose:function(){v.verbose&&v.debug&&(v.performance?b.performance.log(arguments):(b.verbose=Function.prototype.bind.call(console.info,console,v.name+":"),b.verbose.apply(console,arguments)))},error:function(){b.error=Function.prototype.bind.call(console.error,console,v.name+":"),b.error.apply(console,arguments)},performance:{log:function(e){var t,r,n;v.performance&&(t=(new Date).getTime(),n=i||t,r=t-n,i=t,u.push({Name:e[0],Arguments:[].slice.call(e,1)||"","Execution Time":r})),clearTimeout(b.performance.timer),b.performance.timer=setTimeout(b.performance.display,500)},display:function(){var t=v.name+":",r=0;i=!1,clearTimeout(b.performance.timer),e.each(u,function(e,t){r+=t["Execution Time"]}),t+=" "+r+"ms",a&&(t+=" '"+a+"'"),(console.group!==n||console.table!==n)&&u.length>0&&(console.groupCollapsed(t),console.table?console.table(u):e.each(u,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),u=[]}},invoke:function(t,r,s){var a,i,u,c=D;return r=r||l,s=w||s,"string"==typeof t&&c!==n&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(r,o){var s=r!=a?o+t[r+1].charAt(0).toUpperCase()+t[r+1].slice(1):t;if(e.isPlainObject(c[s])&&r!=a)c=c[s];else{if(c[s]!==n)return i=c[s],!1;if(!e.isPlainObject(c[o])||r==a)return c[o]!==n?(i=c[o],!1):(b.error(R.method,t),!1);c=c[o]}})),e.isFunction(i)?u=i.apply(s,r):i!==n&&(u=i),e.isArray(o)?o.push(u):o!==n?o=[o,u]:u!==n&&(o=u),i}},d?(D===n&&b.initialize(),b.invoke(c)):(D!==n&&D.invoke("destroy"),b.initialize())}),o!==n?o:this},e.api.settings={name:"API",namespace:"api",debug:!0,verbose:!1,performance:!0,api:{},cache:!0,interruptRequests:!0,on:"auto",stateContext:!1,loadingDuration:0,errorDuration:2e3,action:!1,url:!1,base:"",urlData:{},defaultData:!0,serializeForm:!1,throttle:0,throttleFirstRequest:!0,method:"get",data:{},dataType:"json",mockResponse:!1,mockResponseAsync:!1,beforeSend:function(e){return e},beforeXHR:function(e){},onRequest:function(e,t){},onResponse:!1,onSuccess:function(e,t){},onComplete:function(e,t){},onFailure:function(e,t){},onError:function(e,t){},onAbort:function(e,t){},successTest:!1,error:{beforeSend:"The before send function has aborted the request",error:"There was an error with your request",exitConditions:"API Request Aborted. Exit conditions met",JSONParse:"JSON could not be parsed during error handling",legacyParameters:"You are using legacy API success callback names",method:"The method you called is not defined",missingAction:"API action used but no url was defined",missingSerialize:"jquery-serialize-object is required to add form data to an existing data object",missingURL:"No URL specified for api event",noReturnedValue:"The beforeSend callback must return a settings object, beforeSend ignored.",noStorage:"Caching respopnses locally requires session storage",parseError:"There was an error parsing your request",requiredParameter:"Missing a required URL parameter: ",statusMessage:"Server gave an error: ",timeout:"Your request timed out"},regExp:{required:/\{\$*[A-z0-9]+\}/g,optional:/\{\/\$*[A-z0-9]+\}/g},className:{loading:"loading",error:"error"},selector:{disabled:".disabled",form:"form"},metadata:{action:"action",url:"url"}}}(jQuery,window,document); \ No newline at end of file +!function(e,t,r,n){"use strict";e.api=e.fn.api=function(r){var o,s=e(e.isFunction(this)?t:this),a=s.selector||"",i=(new Date).getTime(),u=[],c=arguments[0],d="string"==typeof c,l=[].slice.call(arguments,1);return s.each(function(){var s,g,f,m,p,b,v=e.isPlainObject(r)?e.extend(!0,{},e.fn.api.settings,r):e.extend({},e.fn.api.settings),h=v.namespace,y=v.metadata,q=v.selector,R=v.error,x=v.className,k="."+h,A="module-"+h,S=e(this),T=S.closest(q.form),P=v.stateContext?e(v.stateContext):S,w=this,j=P[0],D=S.data(A);b={initialize:function(){d||b.bind.events(),b.instantiate()},instantiate:function(){b.verbose("Storing instance of module",b),D=b,S.data(A,D)},destroy:function(){b.verbose("Destroying previous module for",w),S.removeData(A).off(k)},bind:{events:function(){var e=b.get.event();e?(b.verbose("Attaching API events to element",e),S.on(e+k,b.event.trigger)):"now"==v.on&&(b.debug("Querying API now",e),b.query())}},read:{cachedResponse:function(e){var r;if(t.Storage===n)return void b.error(R.noStorage);if(r=sessionStorage.getItem(e),b.debug("Using cached response",e,r),r!==n){try{r=JSON.parse(r)}catch(o){}return r}return!1}},write:{cachedResponse:function(r,o){return o&&""===o?void b.debug("Response empty, not caching",o):t.Storage===n?void b.error(R.noStorage):(e.isPlainObject(o)&&(o=JSON.stringify(o)),sessionStorage.setItem(r,o),void b.verbose("Storing cached response for url",r,o))}},query:function(){if(b.is.disabled())return void b.debug("Element is disabled API request aborted");if(b.is.loading()){if(!v.interruptRequests)return void b.debug("Cancelling request, previous request is still pending");b.debug("Interrupting previous request"),b.abort()}return v.defaultData&&e.extend(!0,v.urlData,b.get.defaultData()),v.serializeForm&&(v.data=b.add.formData(v.data)),g=b.get.settings(),g===!1?(b.cancelled=!0,void b.error(R.beforeSend)):(b.cancelled=!1,f=b.get.templatedURL(),f||b.is.mocked()?(f=b.add.urlData(f),f||b.is.mocked()?(s=e.extend(!0,{},v,{type:v.method||v.type,data:m,url:v.base+f,beforeSend:v.beforeXHR,success:function(){},failure:function(){},complete:function(){}}),b.debug("Querying URL",s.url),b.verbose("Using AJAX settings",s),"local"===v.cache&&b.read.cachedResponse(f)?(b.debug("Response returned from local cache"),b.request=b.create.request(),void b.request.resolveWith(j,[b.read.cachedResponse(f)])):void(v.throttle?v.throttleFirstRequest||b.timer?(b.debug("Throttling request",v.throttle),clearTimeout(b.timer),b.timer=setTimeout(function(){b.timer&&delete b.timer,b.debug("Sending throttled request",m,s.method),b.send.request()},v.throttle)):(b.debug("Sending request",m,s.method),b.send.request(),b.timer=setTimeout(function(){},v.throttle)):(b.debug("Sending request",m,s.method),b.send.request()))):void 0):void b.error(R.missingURL))},is:{disabled:function(){return S.filter(q.disabled).length>0},form:function(){return S.is("form")},mocked:function(){return v.mockResponse||v.mockResponseAsync},input:function(){return S.is("input")},loading:function(){return b.request&&"pending"==b.request.state()},abortedRequest:function(e){return e&&e.readyState!==n&&0===e.readyState?(b.verbose("XHR request determined to be aborted"),!0):(b.verbose("XHR request was not aborted"),!1)},validResponse:function(t){return"json"===v.dataType&&e.isFunction(v.successTest)?(b.debug("Checking JSON returned success",v.successTest,t),v.successTest(t)?(b.debug("Response passed success test",t),!0):(b.debug("Response failed success test",t),!1)):(b.verbose("Response is not JSON, skipping validation",v.successTest,t),!0)}},was:{cancelled:function(){return b.cancelled||!1},succesful:function(){return b.request&&"resolved"==b.request.state()},failure:function(){return b.request&&"rejected"==b.request.state()},complete:function(){return b.request&&("resolved"==b.request.state()||"rejected"==b.request.state())}},add:{urlData:function(t,r){var o,s;return t&&(o=t.match(v.regExp.required),s=t.match(v.regExp.optional),r=r||v.urlData,o&&(b.debug("Looking for required URL variables",o),e.each(o,function(o,s){var a=-1!==s.indexOf("$")?s.substr(2,s.length-3):s.substr(1,s.length-2),i=e.isPlainObject(r)&&r[a]!==n?r[a]:S.data(a)!==n?S.data(a):P.data(a)!==n?P.data(a):r[a];return i===n?(b.error(R.requiredParameter,a,t),t=!1,!1):(b.verbose("Found required variable",a,i),void(t=t.replace(s,i)))})),s&&(b.debug("Looking for optional URL variables",o),e.each(s,function(o,s){var a=-1!==s.indexOf("$")?s.substr(3,s.length-4):s.substr(2,s.length-3),i=e.isPlainObject(r)&&r[a]!==n?r[a]:S.data(a)!==n?S.data(a):P.data(a)!==n?P.data(a):r[a];i!==n?(b.verbose("Optional variable Found",a,i),t=t.replace(s,i)):(b.verbose("Optional variable not found",a),t=-1!==t.indexOf("/"+s)?t.replace("/"+s,""):t.replace(s,""))}))),t},formData:function(t){var r,o=e.fn.serializeObject!==n,s=o?T.serializeObject():T.serialize();return t=t||v.data,r=e.isPlainObject(t),r?o?(b.debug("Extending existing data with form data",t,s),t=e.extend(!0,{},t,s)):(b.error(R.missingSerialize),b.debug("Cant extend data. Replacing data with form data",t,s),t=s):(b.debug("Adding form data",s),t=s),t}},send:{request:function(){b.set.loading(),b.request=b.create.request(),b.is.mocked()?b.mockedXHR=b.create.mockedXHR():b.xhr=b.create.xhr(),v.onRequest.call(j,b.request,b.xhr)}},event:{trigger:function(e){b.query(),("submit"==e.type||"click"==e.type)&&e.preventDefault()},xhr:{always:function(){},done:function(t,r,n){var o=this,s=(new Date).getTime()-p,a=v.loadingDuration-s,i=e.isFunction(v.onResponse)?v.onResponse.call(o,e.extend(!0,{},t)):!1;a=a>0?a:0,i&&(b.debug("Modified API response in onResponse callback",v.onResponse,i,t),t=i),a>0&&b.debug("Response completed early delaying state change by",a),setTimeout(function(){b.is.validResponse(t)?b.request.resolveWith(o,[t]):b.request.rejectWith(o,[n,"invalid"])},a)},fail:function(e,t,r){var n=this,o=(new Date).getTime()-p,s=v.loadingDuration-o;s=s>0?s:0,s>0&&b.debug("Response completed early delaying state change by",s),setTimeout(function(){b.is.abortedRequest(e)?b.request.rejectWith(n,[e,"aborted",r]):b.request.rejectWith(n,[e,"error",t,r])},s)}},request:{complete:function(e){b.remove.loading(),v.onComplete.call(j,e,S)},done:function(e){b.debug("Successful API Response",e),"local"===v.cache&&f&&(b.write.cachedResponse(f,e),b.debug("Saving server response locally",b.cache)),v.onSuccess.call(j,e,S)},fail:function(t,r,o){var a=e.isPlainObject(t)?t.responseText:!1,i=e.isPlainObject(a)&&a.error!==n?a.error:v.error[r]!==n?v.error[r]:o;"aborted"==r?(b.debug("XHR Aborted (Most likely caused by page navigation or CORS Policy)",r,o),v.onAbort.call(j,r,S)):"invalid"==r?b.debug("JSON did not pass success test. A server-side error has most likely occurred",a):"error"==r&&t!==n&&(b.debug("XHR produced a server error",r,o),200!=t.status&&o!==n&&""!==o&&b.error(R.statusMessage+o,s.url),v.onError.call(j,i,S)),v.errorDuration&&"aborted"!==r&&(b.debug("Adding error state"),b.set.error(),setTimeout(b.remove.error,v.errorDuration)),b.debug("API Request failed",i,t),v.onFailure.call(j,a,S)}}},create:{request:function(){return e.Deferred().always(b.event.request.complete).done(b.event.request.done).fail(b.event.request.fail)},mockedXHR:function(){var t,r,n,o=!1,s=!1,a=!1;return n=e.Deferred().always(b.event.xhr.complete).done(b.event.xhr.done).fail(b.event.xhr.fail),v.mockResponse?(e.isFunction(v.mockResponse)?(b.debug("Using mocked callback returning response",v.mockResponse),r=v.mockResponse.call(j,v)):(b.debug("Using specified response",v.mockResponse),r=v.mockResponse),n.resolveWith(j,[r,o,{responseText:r}])):e.isFunction(v.mockResponseAsync)&&(t=function(e){b.debug("Async callback returned response",e),e?n.resolveWith(j,[e,o,{responseText:e}]):n.rejectWith(j,[{responseText:e},s,a])},b.debug("Using async mocked response",v.mockResponseAsync),v.mockResponseAsync.call(j,v,t)),n},xhr:function(){var t;return t=e.ajax(s).always(b.event.xhr.always).done(b.event.xhr.done).fail(b.event.xhr.fail),b.verbose("Created server request",t),t}},set:{error:function(){b.verbose("Adding error state to element",P),P.addClass(x.error)},loading:function(){b.verbose("Adding loading state to element",P),P.addClass(x.loading),p=(new Date).getTime()}},remove:{error:function(){b.verbose("Removing error state from element",P),P.removeClass(x.error)},loading:function(){b.verbose("Removing loading state from element",P),P.removeClass(x.loading)}},get:{request:function(){return b.request||!1},xhr:function(){return b.xhr||!1},settings:function(){var e;return e=v.beforeSend.call(j,v),e&&(e.success!==n&&(b.debug("Legacy success callback detected",e),b.error(R.legacyParameters,e.success),e.onSuccess=e.success),e.failure!==n&&(b.debug("Legacy failure callback detected",e),b.error(R.legacyParameters,e.failure),e.onFailure=e.failure),e.complete!==n&&(b.debug("Legacy complete callback detected",e),b.error(R.legacyParameters,e.complete),e.onComplete=e.complete)),e===n&&b.error(R.noReturnedValue),e!==n?e:v},defaultData:function(){var t={};return e.isWindow(w)||(b.is.input()?t.value=S.val():b.is.form()&&(t.text=S.text())),t},event:function(){return e.isWindow(w)||"now"==v.on?(b.debug("API called without element, no events attached"),!1):"auto"==v.on?S.is("input")?w.oninput!==n?"input":w.onpropertychange!==n?"propertychange":"keyup":S.is("form")?"submit":"click":v.on},templatedURL:function(e){if(e=e||S.data(y.action)||v.action||!1,f=S.data(y.url)||v.url||!1)return b.debug("Using specified url",f),f;if(e){if(b.debug("Looking up url for action",e,v.api),v.api[e]===n&&!b.is.mocked())return void b.error(R.missingAction,v.action,v.api);f=v.api[e]}else b.is.form()&&(f=S.attr("action")||!1,b.debug("No url or action specified, defaulting to form action",f));return f}},abort:function(){var e=b.get.xhr();e&&"resolved"!==e.state()&&(b.debug("Cancelling API request"),e.abort())},reset:function(){b.remove.error(),b.remove.loading()},setting:function(t,r){if(b.debug("Changing setting",t,r),e.isPlainObject(t))e.extend(!0,v,t);else{if(r===n)return v[t];v[t]=r}},internal:function(t,r){if(e.isPlainObject(t))e.extend(!0,b,t);else{if(r===n)return b[t];b[t]=r}},debug:function(){v.debug&&(v.performance?b.performance.log(arguments):(b.debug=Function.prototype.bind.call(console.info,console,v.name+":"),b.debug.apply(console,arguments)))},verbose:function(){v.verbose&&v.debug&&(v.performance?b.performance.log(arguments):(b.verbose=Function.prototype.bind.call(console.info,console,v.name+":"),b.verbose.apply(console,arguments)))},error:function(){b.error=Function.prototype.bind.call(console.error,console,v.name+":"),b.error.apply(console,arguments)},performance:{log:function(e){var t,r,n;v.performance&&(t=(new Date).getTime(),n=i||t,r=t-n,i=t,u.push({Name:e[0],Arguments:[].slice.call(e,1)||"","Execution Time":r})),clearTimeout(b.performance.timer),b.performance.timer=setTimeout(b.performance.display,500)},display:function(){var t=v.name+":",r=0;i=!1,clearTimeout(b.performance.timer),e.each(u,function(e,t){r+=t["Execution Time"]}),t+=" "+r+"ms",a&&(t+=" '"+a+"'"),(console.group!==n||console.table!==n)&&u.length>0&&(console.groupCollapsed(t),console.table?console.table(u):e.each(u,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),u=[]}},invoke:function(t,r,s){var a,i,u,c=D;return r=r||l,s=w||s,"string"==typeof t&&c!==n&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(r,o){var s=r!=a?o+t[r+1].charAt(0).toUpperCase()+t[r+1].slice(1):t;if(e.isPlainObject(c[s])&&r!=a)c=c[s];else{if(c[s]!==n)return i=c[s],!1;if(!e.isPlainObject(c[o])||r==a)return c[o]!==n?(i=c[o],!1):(b.error(R.method,t),!1);c=c[o]}})),e.isFunction(i)?u=i.apply(s,r):i!==n&&(u=i),e.isArray(o)?o.push(u):o!==n?o=[o,u]:u!==n&&(o=u),i}},d?(D===n&&b.initialize(),b.invoke(c)):(D!==n&&D.invoke("destroy"),b.initialize())}),o!==n?o:this},e.api.settings={name:"API",namespace:"api",debug:!0,verbose:!1,performance:!0,api:{},cache:!0,interruptRequests:!0,on:"auto",stateContext:!1,loadingDuration:0,errorDuration:2e3,action:!1,url:!1,base:"",urlData:{},defaultData:!0,serializeForm:!1,throttle:0,throttleFirstRequest:!0,method:"get",data:{},dataType:"json",mockResponse:!1,mockResponseAsync:!1,beforeSend:function(e){return e},beforeXHR:function(e){},onRequest:function(e,t){},onResponse:!1,onSuccess:function(e,t){},onComplete:function(e,t){},onFailure:function(e,t){},onError:function(e,t){},onAbort:function(e,t){},successTest:!1,error:{beforeSend:"The before send function has aborted the request",error:"There was an error with your request",exitConditions:"API Request Aborted. Exit conditions met",JSONParse:"JSON could not be parsed during error handling",legacyParameters:"You are using legacy API success callback names",method:"The method you called is not defined",missingAction:"API action used but no url was defined",missingSerialize:"jquery-serialize-object is required to add form data to an existing data object",missingURL:"No URL specified for api event",noReturnedValue:"The beforeSend callback must return a settings object, beforeSend ignored.",noStorage:"Caching respopnses locally requires session storage",parseError:"There was an error parsing your request",requiredParameter:"Missing a required URL parameter: ",statusMessage:"Server gave an error: ",timeout:"Your request timed out"},regExp:{required:/\{\$*[A-z0-9]+\}/g,optional:/\{\/\$*[A-z0-9]+\}/g},className:{loading:"loading",error:"error"},selector:{disabled:".disabled",form:"form"},metadata:{action:"action",url:"url"}}}(jQuery,window,document); \ No newline at end of file diff --git a/dist/components/dropdown.js b/dist/components/dropdown.js index 1abc05c6f..282d84416 100644 --- a/dist/components/dropdown.js +++ b/dist/components/dropdown.js @@ -31,7 +31,7 @@ $.fn.dropdown = function(parameters) { ; $allModules - .each(function() { + .each(function(elementIndex) { var settings = ( $.isPlainObject(parameters) ) ? $.extend(true, {}, $.fn.dropdown.settings, parameters) @@ -266,6 +266,8 @@ $.fn.dropdown = function(parameters) { layout: function() { if( $module.is('select') ) { module.setup.select(); + module.setup.returnedObject(); + console.log($module); } if( module.is.search() && !module.has.search() ) { module.verbose('Adding search input'); @@ -313,6 +315,7 @@ $.fn.dropdown = function(parameters) { .detach() .prependTo($module) ; + console.log($module); } if($input.is('[multiple]')) { module.set.multiple(); @@ -324,24 +327,24 @@ $.fn.dropdown = function(parameters) { $item = $menu.find(selector.item); }, reference: function() { - var - index = $allModules.index($module), - $firstModules, - $lastModules - ; module.debug('Dropdown behavior was called on select, replacing with closest dropdown'); // replace module reference $module = $module.parent(selector.dropdown); module.refresh(); - // adjust all modules to compensate - $firstModules = $allModules.slice(0, index); - $lastModules = $allModules.slice(index + 1); - $allModules = $firstModules.add($module).add($lastModules); + module.setup.returnedObject(); // invoke method in context of current instance if(methodInvoked) { instance = module; module.invoke(query); } + }, + returnedObject: function() { + var + $firstModules = $allModules.slice(0, elementIndex), + $lastModules = $allModules.slice(elementIndex + 1) + ; + // adjust all modules to use correct reference + $allModules = $firstModules.add($module).add($lastModules); } }, @@ -2108,7 +2111,7 @@ $.fn.dropdown = function(parameters) { : $selectedItem || module.get.item(value) ; if(!$selectedItem) { - return false; + return; } module.debug('Setting selected menu item to', $selectedItem); if(module.is.single()) { diff --git a/dist/components/dropdown.min.js b/dist/components/dropdown.min.js index 9bdc8e49a..55817fb22 100644 --- a/dist/components/dropdown.min.js +++ b/dist/components/dropdown.min.js @@ -8,6 +8,6 @@ * http://opensource.org/licenses/MIT * */ -!function(e,t,n,i){"use strict";e.fn.dropdown=function(a){var o,r=e(this),s=e(n),l=r.selector||"",c="ontouchstart"in n.documentElement,u=(new Date).getTime(),d=[],v=arguments[0],m="string"==typeof v,f=[].slice.call(arguments,1);return r.each(function(){var h,g,b,p,w,x,C,S=e.isPlainObject(a)?e.extend(!0,{},e.fn.dropdown.settings,a):e.extend({},e.fn.dropdown.settings),y=S.className,A=S.message,T=S.metadata,k=S.namespace,L=S.regExp,D=S.selector,I=S.error,R=S.templates,q="."+k,V="module-"+k,E=e(this),O=e(S.context),F=E.find(D.text),P=E.find(D.search),M=E.find(D.input),z=E.find(D.icon),H=E.prev().find(D.text).length>0?E.prev().find(D.text):E.prev(),j=E.children(D.menu),U=j.find(D.item),N=!1,K=!1,W=this,B=E.data(V);C={initialize:function(){C.debug("Initializing dropdown",S),C.is.alreadySetup()?C.setup.reference():(C.setup.layout(),C.refreshData(),C.save.defaults(),C.restore.selected(),C.create.id(),c&&C.bind.touchEvents(),C.bind.mouseEvents(),C.bind.keyboardEvents(),C.observeChanges(),C.instantiate())},instantiate:function(){C.verbose("Storing instance of dropdown",C),B=C,E.data(V,C)},destroy:function(){C.verbose("Destroying previous dropdown",E),C.remove.tabbable(),E.off(q).removeData(V),j.off(q),s.off(b),w&&w.disconnect(),x&&x.disconnect()},observeChanges:function(){"MutationObserver"in t&&(w=new MutationObserver(function(e){C.debug("").addClass(y.search).insertBefore(F)),S.allowTab&&C.set.tabbable(),0===j.length&&(j=e("
").addClass(y.menu).appendTo(E))},select:function(){var t=C.get.selectValues();C.debug("Dropdown initialized on a select",t),E.is("select")&&(M=E),M.parent(D.dropdown).length>0?(C.debug("UI dropdown already exists. Creating dropdown menu only"),E=M.closest(D.dropdown),j=E.children(D.menu),C.setup.menu(t)):(C.debug("Creating entire dropdown from select"),E=e("
").attr("class",M.attr("class")).addClass(y.selection).addClass(y.dropdown).html(R.dropdown(t)).insertBefore(M),M.removeAttr("class").detach().prependTo(E)),M.is("[multiple]")&&C.set.multiple(),C.refresh()},menu:function(e){j.html(R.menu(e)),U=j.find(D.item)},reference:function(){var e,t,n=r.index(E);C.debug("Dropdown behavior was called on select, replacing with closest dropdown"),E=E.parent(D.dropdown),C.refresh(),e=r.slice(0,n),t=r.slice(n+1),r=e.add(E).add(t),m&&(B=C,C.invoke(v))}},refresh:function(){C.refreshSelectors(),C.refreshData()},refreshSelectors:function(){C.verbose("Refreshing selector cache"),F=E.find(D.text),P=E.find(D.search),M=E.find(D.input),z=E.find(D.icon),H=E.prev().find(D.text).length>0?E.prev().find(D.text):E.prev(),j=E.children(D.menu),U=j.find(D.item)},refreshData:function(){C.verbose("Refreshing cached metadata"),U.removeData(T.text).removeData(T.value),E.removeData(T.defaultText).removeData(T.defaultValue).removeData(T.placeholderText)},toggle:function(){C.verbose("Toggling menu visibility"),C.is.active()?C.hide():C.show()},show:function(t){if(t=e.isFunction(t)?t:function(){},C.can.show()&&!C.is.active()){if(C.debug("Showing dropdown"),C.is.multiple()&&!C.has.search()&&C.is.allFiltered())return!0;C.animate.show(function(){C.can.click()&&C.bind.intent(),C.set.visible(),t.call(W)}),S.onShow.call(W)}},hide:function(t){t=e.isFunction(t)?t:function(){},C.is.active()&&(C.debug("Hiding dropdown"),C.animate.hide(function(){C.remove.visible(),t.call(W)}),S.onHide.call(W))},hideOthers:function(){C.verbose("Finding other dropdowns to hide"),r.not(E).has(D.menu+"."+y.visible).dropdown("hide")},hideMenu:function(){C.verbose("Hiding menu instantaneously"),C.remove.active(),C.remove.visible(),j.transition("hide")},hideSubMenus:function(){var e=j.children(D.item).find(D.menu);C.verbose("Hiding sub menus",e),e.transition("hide")},bind:{keyboardEvents:function(){C.debug("Binding keyboard events"),E.on("keydown"+q,C.event.keydown),C.has.search()&&E.on(C.get.inputEvent()+q,D.search,C.event.input),C.is.multiple()&&s.on("keydown"+b,C.event.document.keydown)},touchEvents:function(){C.debug("Touch device detected binding additional touch events"),C.is.searchSelection()||E.on("touchstart"+q,C.event.test.toggle),j.on("touchstart"+q,D.item,C.event.item.mouseenter)},mouseEvents:function(){C.debug("Mouse detected binding mouse events"),C.is.multiple()&&E.on("click"+q,D.label,C.event.label.click).on("click"+q,D.remove,C.event.remove.click),C.is.searchSelection()?(E.on("mousedown"+q,D.menu,C.event.menu.mousedown).on("mouseup"+q,D.menu,C.event.menu.mouseup).on("click"+q,D.search,C.show).on("focus"+q,D.search,C.event.search.focus).on("blur"+q,D.search,C.event.search.blur).on("click"+q,D.text,C.event.text.focus),C.is.multiple()&&E.on("click"+q,C.event.click)):("click"==S.on?E.on("click"+q,C.event.test.toggle):"hover"==S.on?E.on("mouseenter"+q,C.delay.show).on("mouseleave"+q,C.delay.hide):E.on(S.on+q,C.toggle),E.on("mousedown"+q,C.event.mousedown).on("mouseup"+q,C.event.mouseup).on("focus"+q,C.event.focus).on("blur"+q,C.event.blur)),j.on("mouseenter"+q,D.item,C.event.item.mouseenter).on("mouseleave"+q,D.item,C.event.item.mouseleave).on("click"+q,D.item,C.event.item.click)},intent:function(){C.verbose("Binding hide intent event to document"),c&&s.on("touchstart"+b,C.event.test.touch).on("touchmove"+b,C.event.test.touch),s.on("click"+b,C.event.test.hide)}},unbind:{intent:function(){C.verbose("Removing hide intent event from document"),c&&s.off("touchstart"+b).off("touchmove"+b),s.off("click"+b)}},filter:function(e){var t=e!==i?e:C.get.query(),n=function(){C.is.multiple()&&C.filterActive(),C.select.firstUnfiltered(),C.has.allResultsFiltered()?S.onNoResults.call(W,t)?S.allowAdditions||(C.verbose("All items filtered, showing message",t),C.add.message(A.noResults)):(C.verbose("All items filtered, hiding dropdown",t),C.hideMenu()):C.remove.message(),S.allowAdditions&&C.add.userSuggestion(e),C.is.searchSelection()&&C.can.show()&&C.is.focusedOnSearch()&&C.show()};C.has.maxSelections()||(S.apiSettings?C.can.useAPI()?C.queryRemote(t,function(){n()}):C.error(I.noAPI):(C.filterItems(t),n()))},queryRemote:function(t,n){var i={errorDuration:!1,throttle:S.throttle,cache:"local",urlData:{query:t},onError:function(){C.add.message(A.serverError),n()},onFailure:function(){C.add.message(A.serverError),n()},onSuccess:function(e){C.remove.message(),C.setup.menu({values:e.results}),n()}};E.api("get request")||C.setup.api(),i=e.extend(!0,{},i,S.apiSettings),E.api("setting",i).api("query")},filterItems:function(t){var n=t!==i?t:C.get.query(),a=e(),o=C.escape.regExp(n),r=new RegExp("^"+o,"igm");""===n?a=U:(C.verbose("Searching for matching values",n),U.each(function(){var t,i,o=e(this);if("both"==S.match||"text"==S.match){if(t=String(C.get.choiceText(o,!1)),-1!==t.search(r))return a=a.add(o),!0;if(S.fullTextSearch&&C.fuzzySearch(n,t))return a=a.add(o),!0}if("both"==S.match||"value"==S.match){if(i=String(C.get.choiceValue(o,t)),-1!==i.search(r))return a=a.add(o),!0;if(S.fullTextSearch&&C.fuzzySearch(n,i))return a=a.add(o),!0}})),C.debug("Showing only matched items",n),C.remove.filteredItem(),U.not(a).addClass(y.filtered)},fuzzySearch:function(e,t){var n=t.length,i=e.length;if(e=e.toLowerCase(),t=t.toLowerCase(),i>n)return!1;if(i===n)return e===t;e:for(var a=0,o=0;i>a;a++){for(var r=e.charCodeAt(a);n>o;)if(t.charCodeAt(o++)===r)continue e;return!1}return!0},filterActive:function(){S.useLabels&&U.filter("."+y.active).addClass(y.filtered)},focusSearch:function(){C.is.search()&&!C.is.focusedOnSearch()&&P[0].focus()},forceSelection:function(){var e=U.not(y.filtered).filter("."+y.selected).eq(0),t=U.not(y.filtered).filter("."+y.active).eq(0),n=e.length>0?e:t,i=n.size()>0;i?(C.debug("Forcing partial selection to selected item",n),C.event.item.click.call(n)):C.hide()},event:{focus:function(){S.showOnFocus&&!N&&C.is.hidden()&&!g&&C.show()},click:function(t){var n=e(t.target);!n.is(E)&&!n.is(z)||C.is.focusedOnSearch()||C.focusSearch()},blur:function(e){g=n.activeElement===this,N||g||(C.remove.activeLabel(),C.hide())},mousedown:function(){N=!0},mouseup:function(){N=!1},search:{focus:function(){N=!0,C.is.multiple()&&C.remove.activeLabel(),S.showOnFocus&&C.show()},blur:function(e){g=n.activeElement===this,K||g||(C.is.multiple()?(C.remove.activeLabel(),C.hide()):S.forceSelection?C.forceSelection():C.hide())}},text:{focus:function(e){N=!0,C.focusSearch()}},input:function(e){(C.is.multiple()||C.is.searchSelection())&&C.set.filtered(),clearTimeout(C.timer),C.timer=setTimeout(C.search,S.delay.search)},label:{click:function(t){var n=e(this),i=E.find(D.label),a=i.filter("."+y.active),o=n.nextAll("."+y.active),r=n.prevAll("."+y.active),s=o.length>0?n.nextUntil(o).add(a).add(n):n.prevUntil(r).add(a).add(n);t.shiftKey?(a.removeClass(y.active),s.addClass(y.active)):t.ctrlKey?n.toggleClass(y.active):(a.removeClass(y.active),n.addClass(y.active)),S.onLabelSelect.apply(this,i.filter("."+y.active))}},remove:{click:function(){var t=e(this).parent();t.hasClass(y.active)?C.remove.activeLabels():C.remove.activeLabels(t)}},test:{toggle:function(e){var t=C.is.multiple()?C.show:C.toggle;C.determine.eventOnElement(e,t)&&e.preventDefault()},touch:function(e){C.determine.eventOnElement(e,function(){"touchstart"==e.type?C.timer=setTimeout(C.hide,S.delay.touch):"touchmove"==e.type&&clearTimeout(C.timer)}),e.stopPropagation()},hide:function(e){C.determine.eventInModule(e,C.hide)}},menu:{mousedown:function(){K=!0},mouseup:function(){K=!1}},item:{mouseenter:function(t){var n=e(this).children(D.menu),i=e(this).siblings(D.item).children(D.menu);n.length>0&&(clearTimeout(C.itemTimer),C.itemTimer=setTimeout(function(){C.verbose("Showing sub-menu",n),e.each(i,function(){C.animate.hide(!1,e(this))}),C.animate.show(!1,n)},S.delay.show),t.preventDefault())},mouseleave:function(t){var n=e(this).children(D.menu);n.length>0&&(clearTimeout(C.itemTimer),C.itemTimer=setTimeout(function(){C.verbose("Hiding sub-menu",n),C.animate.hide(!1,n)},S.delay.hide))},click:function(t){var n=e(this),i=e(t?t.target:""),a=n.find(D.menu),o=C.get.choiceText(n),r=C.get.choiceValue(n,o),s=a.length>0,l=a.find(i).length>0;l||s&&!S.allowCategorySelection||(S.useLabels||C.remove.searchTerm(),C.determine.selectAction.call(this,o,r))}},document:{keydown:function(e){var t=e.which,n=C.get.shortcutKeys(),i=C.is.inObject(t,n);if(i){var a=E.find(D.label),o=a.filter("."+y.active),r=(o.data("value"),a.index(o)),s=a.length,l=o.length>0,c=o.length>1,u=0===r,d=r+1==s,v=C.is.searchSelection(),m=C.is.focusedOnSearch(),f=C.is.focused(),h=m&&0===C.get.caretPosition();if(v&&!l&&!m)return;t==n.leftArrow?!f&&!h||l?l&&(e.shiftKey?C.verbose("Adding previous label to selection"):(C.verbose("Selecting previous label"),a.removeClass(y.active)),u&&!c?o.addClass(y.active):o.prev(D.siblingLabel).addClass(y.active).end(),e.preventDefault()):(C.verbose("Selecting previous label"),a.last().addClass(y.active)):t==n.rightArrow?(f&&!l&&a.first().addClass(y.active),l&&(e.shiftKey?C.verbose("Adding next label to selection"):(C.verbose("Selecting next label"),a.removeClass(y.active)),d?v?m?a.removeClass(y.active):C.focusSearch():c?o.next(D.siblingLabel).addClass(y.active):o.addClass(y.active):o.next(D.siblingLabel).addClass(y.active),e.preventDefault())):t==n.deleteKey||t==n.backspace?l?(C.verbose("Removing active labels"),d&&v&&!m&&C.focusSearch(),o.last().next(D.siblingLabel).addClass(y.active),C.remove.activeLabels(o),e.preventDefault()):h&&!l&&t==n.backspace&&(C.verbose("Removing last label on input backspace"),o=a.last().addClass(y.active),C.remove.activeLabels(o)):o.removeClass(y.active)}}},keydown:function(e){var t=e.which,n=C.get.shortcutKeys(),i=C.is.inObject(t,n);if(i){var a,o,r=U.not(D.unselectable).filter("."+y.selected).eq(0),s=j.children("."+y.active).eq(0),l=r.length>0?r:s,c=l.length>0?l.siblings(":not(."+y.filtered+")").andSelf():j.children(":not(."+y.filtered+")"),u=l.children(D.menu),d=l.closest(D.menu),v=d.hasClass(y.visible)||d.hasClass(y.animating)||d.parent(D.menu).length>0,m=u.length>0,f=l.length>0,h=l.not(D.unselectable).length>0;if(C.is.visible()){if((t==n.enter||t==n.delimiter)&&(t==n.enter&&f&&m&&!S.allowCategorySelection?(C.verbose("Pressed enter on unselectable category, opening sub menu"),t=n.rightArrow):h&&(C.verbose("Selecting item from keyboard shortcut",l),C.event.item.click.call(l,e),S.useLabels&&C.is.searchSelection()?C.hideAndClear():C.remove.searchTerm()),e.preventDefault()),t==n.leftArrow&&(o=d[0]!==j[0],o&&(C.verbose("Left key pressed, closing sub-menu"),C.animate.hide(!1,d),l.removeClass(y.selected),d.closest(D.item).addClass(y.selected),e.preventDefault())),t==n.rightArrow&&m&&(C.verbose("Right key pressed, opening sub-menu"),C.animate.show(!1,u),l.removeClass(y.selected),u.find(D.item).eq(0).addClass(y.selected),e.preventDefault()),t==n.upArrow){if(a=f&&v?l.prevAll(D.item+":not("+D.unselectable+")").eq(0):U.eq(0),c.index(a)<0)return C.verbose("Up key pressed but reached top of current menu"),void e.preventDefault();C.verbose("Up key pressed, changing active item"),l.removeClass(y.selected),a.addClass(y.selected),C.set.scrollPosition(a),e.preventDefault()}if(t==n.downArrow){if(a=f&&v?a=l.nextAll(D.item+":not("+D.unselectable+")").eq(0):U.eq(0),0===a.length)return C.verbose("Down key pressed but reached bottom of current menu"),void e.preventDefault();C.verbose("Down key pressed, changing active item"),U.removeClass(y.selected),a.addClass(y.selected),C.set.scrollPosition(a),e.preventDefault()}t==n.pageUp&&(C.scrollPage("up"),e.preventDefault()),t==n.pageDown&&(C.scrollPage("down"),e.preventDefault()),t==n.escape&&(C.verbose("Escape key pressed, closing dropdown"),C.hide())}else t==n.delimiter&&e.preventDefault(),t==n.downArrow&&(C.verbose("Down key pressed, showing dropdown"),C.show(),e.preventDefault())}else C.is.selection()&&!C.is.search()&&C.set.selectedLetter(String.fromCharCode(t))}},determine:{selectAction:function(t,n){C.verbose("Determining action",S.action),e.isFunction(C.action[S.action])?(C.verbose("Triggering preset action",S.action,t,n),C.action[S.action].call(this,t,n)):e.isFunction(S.action)?(C.verbose("Triggering user action",S.action,t,n),S.action.call(this,t,n)):C.error(I.action,S.action)},eventInModule:function(t,n){return n=e.isFunction(n)?n:function(){},0===e(t.target).closest(E).length?(C.verbose("Triggering event",n),n(),!0):(C.verbose("Event occurred in dropdown, canceling callback"),!1)},eventOnElement:function(t,n){var i=e(t.target);return n=e.isFunction(n)?n:function(){},0===i.closest(j).length?(C.verbose("Triggering event",n),n(),!0):(C.verbose("Event occurred in dropdown menu, canceling callback"),!1)}},action:{nothing:function(){},activate:function(t,n){n=n!==i?n:t,C.set.selected(n,e(this)),(!C.is.multiple()||C.is.allFiltered())&&C.hideAndClear()},select:function(e,t){C.action.activate.call(this)},combo:function(t,n){n=n!==i?n:t,C.set.selected(n,e(this)),C.hideAndClear()},hide:function(){C.hideAndClear()}},get:{id:function(){return p},text:function(){return F.text()},query:function(){return e.trim(P.val())},searchWidth:function(e){return e*S.glyphWidth+"em"},selectionCount:function(){var t=C.get.values();return C.is.multiple()?e.isArray(t)?t.length:0:""!==C.get.value()?1:0},transition:function(e){return"auto"==S.transition?C.is.upward(e)?"slide up":"slide down":S.transition},userValues:function(){var t=C.get.values();return t?(t=e.isArray(t)?t:[t],e.grep(t,function(e){return C.get.item(e)===!1})):!1},uniqueArray:function(t){return e.grep(t,function(n,i){return e.inArray(n,t)===i})},caretPosition:function(){var e,t,i=P.get(0);return"selectionStart"in i?i.selectionStart:n.selection?(i.focus(),e=n.selection.createRange(),t=e.text.length,e.moveStart("character",-i.value.length),e.text.length-t):void 0},shortcutKeys:function(){return{backspace:8,delimiter:188,deleteKey:46,enter:13,escape:27,pageUp:33,pageDown:34,leftArrow:37,upArrow:38,rightArrow:39,downArrow:40}},value:function(){return M.length>0?M.val():E.data(T.value)},values:function(){var e=C.get.value();return""===e?"":!M.is("select")&&C.is.multiple()?"string"==typeof e?e.split(S.delimiter):"":e},remoteValues:function(){var t=C.get.values(),n=!1;return t&&("string"==typeof t&&(t=[t]),n={},e.each(t,function(e,t){var i=C.read.remoteData(t);C.verbose("Restoring value from session data",i,t),n[t]=i?i:t})),n},choiceText:function(e,t){return t=t!==i?t:S.preserveHTML,e?(e.find(D.menu).length>0&&(C.verbose("Retreiving text of element with sub-menu"),e=e.clone(),e.find(D.menu).remove(),e.find(D.menuIcon).remove()),e.data(T.text)!==i?e.data(T.text):t?e.html().trim():e.text().trim()):void 0},choiceValue:function(e,t){return t=t||C.get.choiceText(e),e?e.data(T.value)!==i?e.data(T.value):"string"==typeof t?t.toLowerCase().trim():t:!1},inputEvent:function(){var e=P[0];return e?e.oninput!==i?"input":e.onpropertychange!==i?"propertychange":"keyup":!1},selectValues:function(){var t={};return t.values=[],E.find("option").each(function(){var n=e(this),a=n.html(),o=n.attr("disabled"),r=n.attr("value")!==i?n.attr("value"):a;"auto"===S.placeholder&&""===r?t.placeholder=a:t.values.push({name:a,value:r,disabled:o})}),S.placeholder&&"auto"!==S.placeholder&&(C.debug("Setting placeholder value to",S.placeholder),t.placeholder=S.placeholder),S.sortSelect?(t.values.sort(function(e,t){return e.name>t.name?1:-1}),C.debug("Retrieved and sorted values from select",t)):C.debug("Retreived values from select",t),t},activeItem:function(){return U.filter("."+y.active)},selectedItem:function(){var e=U.not(D.unselectable).filter("."+y.selected);return e.length>0?e:U.eq(0)},itemWithAdditions:function(e){var t=C.get.item(e),n=C.create.userChoice(e),i=n&&n.length>0;return i&&(t=t.length>0?t.add(n):n),t},item:function(t,n){var a,o,r=!1;return t=t!==i?t:C.get.values()!==i?C.get.values():C.get.text(),a=o?t.length>0:t!==i&&""!==t&&null!==t,o=C.is.multiple()&&e.isArray(t),n=""===t||0===t?!0:n||!1,a&&U.each(function(){var a=e(this),s=C.get.choiceText(a),l=C.get.choiceValue(a,s);if(null!==l&&l!==i)if(o)(-1!==e.inArray(l.toString(),t)||-1!==e.inArray(s,t))&&(r=r?r.add(a):a);else if(n){if(C.verbose("Ambiguous dropdown value using strict type check",a,t),l===t||s===t)return r=a,!0}else if(l.toString()==t.toString()||s==t)return C.verbose("Found select item by value",l,t),r=a,!0}),r}},check:{maxSelections:function(e){return S.maxSelections?(e=e!==i?e:C.get.selectionCount(),e>=S.maxSelections?(C.debug("Maximum selection count reached"),U.addClass(y.filtered),C.add.message(A.maxSelections),!0):(C.verbose("No longer at maximum selection count"),C.remove.message(),C.remove.filteredItem(),C.is.searchSelection()&&C.filterItems(),!1)):!0}},restore:{defaults:function(){C.restore.defaultText(),C.restore.defaultValue()},defaultText:function(){var e=E.data(T.defaultText);C.debug("Restoring default text",e),C.set.text(e),F.addClass(y.placeholder)},defaultValue:function(){var e=E.data(T.defaultValue);e!==i&&(C.debug("Restoring default value",e),""!==e?(C.set.value(e),C.set.selected()):(C.remove.activeItem(),C.remove.selectedItem()))},labels:function(){S.allowAdditions&&(S.useLabels||(C.error(I.labels),S.useLabels=!0),C.debug("Restoring selected values"),C.create.userLabels()),C.check.maxSelections()},selected:function(){C.restore.values(),C.is.multiple()?(C.debug("Restoring previously selected values and labels"),C.restore.labels()):C.debug("Restoring previously selected values")},values:function(){C.set.initialLoad(),S.apiSettings?S.saveRemoteData?C.restore.remoteValues():C.clearValue():C.set.selected(),C.remove.initialLoad()},remoteValues:function(){var t=C.get.remoteValues();C.debug("Recreating selected from session data",t),t&&(C.is.single()?e.each(t,function(e,t){C.set.text(t)}):e.each(t,function(e,t){C.add.label(e,t)}))}},read:{remoteData:function(e){var n;return t.Storage===i?void C.error(I.noStorage):(n=sessionStorage.getItem(e),n!==i?n:!1)}},save:{defaults:function(){C.save.defaultText(),C.save.placeholderText(),C.save.defaultValue()},defaultValue:function(){var e=C.get.value();C.verbose("Saving default value as",e),E.data(T.defaultValue,e)},defaultText:function(){var e=C.get.text();C.verbose("Saving default text as",e),E.data(T.defaultText,e)},placeholderText:function(){var e;F.hasClass(y.placeholder)&&(e=C.get.text(),C.verbose("Saving placeholder text as",e),E.data(T.placeholderText,e))},remoteData:function(e,n){return t.Storage===i?void C.error(I.noStorage):(C.verbose("Saving remote data to session storage",n,e),void sessionStorage.setItem(n,e))}},clear:function(){C.is.multiple()?C.remove.labels():(C.remove.activeItem(),C.remove.selectedItem()),C.set.placeholderText(),C.clearValue()},clearValue:function(){C.set.value("")},scrollPage:function(e,t){var n,i,a,t=t||C.get.selectedItem(),o=t.closest(D.menu),r=o.outerHeight(),s=o.scrollTop(),l=U.eq(0).outerHeight(),c=Math.floor(r/l),u=(o.prop("scrollHeight"),"up"==e?s-l*c:s+l*c),d=U.not(D.unselectable);a="up"==e?d.index(t)-c:d.index(t)+c,n="up"==e?a>=0:a0&&(C.debug("Scrolling page",e,i),t.removeClass(y.selected),i.addClass(y.selected),o.scrollTop(u))},set:{filtered:function(){var e=C.is.multiple(),t=C.is.searchSelection(),n=e&&t,i=t?C.get.query():"",a="string"==typeof i&&i.length>0,o=C.get.searchWidth(i.length),r=""!==i;e&&a&&(C.verbose("Adjusting input width",o,S.glyphWidth),P.css("width",o)),a||n&&r?(C.verbose("Hiding placeholder text"),F.addClass(y.filtered)):(!e||n&&!r)&&(C.verbose("Showing placeholder text"),F.removeClass(y.filtered))},loading:function(){E.addClass(y.loading)},placeholderText:function(e){e=e||E.data(T.placeholderText),e&&(C.debug("Restoring placeholder text"),C.set.text(e),F.addClass(y.placeholder))},tabbable:function(){C.has.search()?(C.debug("Added tabindex to searchable dropdown"),P.val("").attr("tabindex",0),j.attr("tabindex",-1)):(C.debug("Added tabindex to dropdown"),E.attr("tabindex")||(E.attr("tabindex",0),j.attr("tabindex",-1)))},initialLoad:function(){C.verbose("Setting initial load"),h=!0},scrollPosition:function(e,t){var n,a,o,r,s,l,c,u,d,v=5;e=e||C.get.selectedItem(),n=e.closest(D.menu),a=e&&e.length>0,t=t!==i?t:!1,e&&n.length>0&&a&&(r=e.position().top,n.addClass(y.loading),l=n.scrollTop(),s=n.offset().top,r=e.offset().top,o=l-s+r,t||(c=n.height(),d=o+v>l+c,u=l>o-v),C.debug("Scrolling to active item",o),(t||u||d)&&n.scrollTop(o),n.removeClass(y.loading))},text:function(e){"select"!==S.action&&("combo"==S.action?(C.debug("Changing combo button text",e,H),S.preserveHTML?H.html(e):H.text(e)):(C.debug("Changing text",e,F),F.removeClass(y.filtered).removeClass(y.placeholder),S.preserveHTML?F.html(e):F.text(e)))},selectedLetter:function(t){var n=U.filter("."+y.selected),i=!1;U.each(function(){var n=e(this),a=C.get.choiceText(n,!1),o=String(a).charAt(0).toLowerCase(),r=t.toLowerCase();return o==r?(i=n,!1):void 0}),i&&(C.verbose("Scrolling to next value with letter",t),C.set.scrollPosition(i),n.removeClass(y.selected),i.addClass(y.selected))},direction:function(e){"auto"==S.direction?C.is.onScreen(e)?C.remove.upward(e):C.set.upward(e):"upward"==S.direction&&C.set.upward(e)},upward:function(e){var t=e||E;t.addClass(y.upward)},value:function(e,t,n){var i=M.length>0,a=(!C.has.value(e),C.get.values()),o="number"==typeof e?e.toString():e;if(i){if(o==a&&(C.verbose("Skipping value update already same value",e,a),!C.is.initialLoad()))return;C.debug("Updating input value",e,a),M.val(e).trigger("change")}else C.verbose("Storing value in metadata",e,M),e!==a&&E.data(T.value,e);S.fireOnInit===!1&&C.is.initialLoad()?C.verbose("No callback on initial load",S.onChange):S.onChange.call(W,e,t,n)},active:function(){E.addClass(y.active)},multiple:function(){E.addClass(y.multiple)},visible:function(){E.addClass(y.visible)},selected:function(t,n){var i=C.is.multiple();return(n=S.allowAdditions?n||C.get.itemWithAdditions(t):n||C.get.item(t))?(C.debug("Setting selected menu item to",n),C.is.single()?(C.remove.activeItem(),C.remove.selectedItem()):S.useLabels&&C.remove.selectedItem(),void n.each(function(){var t=e(this),a=C.get.choiceText(t),o=C.get.choiceValue(t,a),r=t.hasClass(y.filtered),s=t.hasClass(y.active),l=t.hasClass(y.addition),c=i&&1==n.length;i?!s||l?(S.apiSettings&&S.saveRemoteData&&C.save.remoteData(a,o),S.useLabels?(C.add.value(o,a,t),C.add.label(o,a,c),t.addClass(y.active),C.filterActive(),C.select.nextAvailable(n)):(C.add.value(o,a,t),C.set.text(C.add.variables(A.count)),t.addClass(y.active))):r||(C.debug("Selected active value, removing label"),C.remove.selected(o)):(S.apiSettings&&S.saveRemoteData&&C.save.remoteData(a,o),C.set.value(o,a,t),C.set.text(a),t.addClass(y.active).addClass(y.selected))})):!1}},add:{label:function(t,n,i){var a,o=C.is.searchSelection()?P:F;return a=e("").addClass(y.label).attr("data-value",t).html(R.label(t,n)),a=S.onLabelCreate.call(a,t,n),C.has.label(t)?void C.debug("Label already exists, skipping",t):(S.label.variation&&a.addClass(S.label.variation),void(i===!0?(C.debug("Animating in label",a),a.addClass(y.hidden).insertBefore(o).transition(S.label.transition,S.label.duration)):(C.debug("Adding selection label",a),a.insertBefore(o))))},message:function(t){var n=j.children(D.message),i=S.templates.message(C.add.variables(t));n.length>0?n.html(i):n=e("
").html(i).addClass(y.message).appendTo(j)},optionValue:function(t){var n=M.find('option[value="'+t+'"]'),i=n.length>0;i||(w&&(w.disconnect(),C.verbose("Temporarily disconnecting mutation observer",t)),e("
").html(o).data(k.value,r).addClass(A.addition).addClass(A.item),n=n===i?a:n.add(a),S.verbose("Creating user choices for value",r,a))}),n):!1},userLabels:function(t){var n=S.get.userValues();n&&(S.debug("Adding user labels",n),e.each(n,function(e,t){S.verbose("Adding custom user value"),S.add.label(t,t)}))}},search:function(e){e=e!==i?e:S.get.query(),S.verbose("Searching for query",e),S.filter(e)},select:{firstUnfiltered:function(){S.verbose("Selecting first non-filtered element"),S.remove.selectedItem(),N.not(I.unselectable).eq(0).addClass(A.selected)},nextAvailable:function(e){e=e.eq(0);var t=e.nextAll(I.item).not(I.unselectable).eq(0),n=e.prevAll(I.item).not(I.unselectable).eq(0),i=t.length>0;i?(S.verbose("Moving selection to",t),t.addClass(A.selected)):(S.verbose("Moving selection to",n),n.addClass(A.selected))}},setup:{api:function(){var e={debug:y.debug,on:!1};S.verbose("First request, initializing API"),E.api(e)},layout:function(){E.is("select")&&(S.setup.select(),S.setup.returnedObject(),console.log(E)),S.is.search()&&!S.has.search()&&(S.verbose("Adding search input"),M=e("").addClass(A.search).insertBefore(P)),y.allowTab&&S.set.tabbable(),0===U.length&&(U=e("
").addClass(A.menu).appendTo(E))},select:function(){var t=S.get.selectValues();S.debug("Dropdown initialized on a select",t),E.is("select")&&(z=E),z.parent(I.dropdown).length>0?(S.debug("UI dropdown already exists. Creating dropdown menu only"),E=z.closest(I.dropdown),U=E.children(I.menu),S.setup.menu(t)):(S.debug("Creating entire dropdown from select"),E=e("
").attr("class",z.attr("class")).addClass(A.selection).addClass(A.dropdown).html(q.dropdown(t)).insertBefore(z),z.removeAttr("class").detach().prependTo(E),console.log(E)),z.is("[multiple]")&&S.set.multiple(),S.refresh()},menu:function(e){U.html(q.menu(e)),N=U.find(I.item)},reference:function(){S.debug("Dropdown behavior was called on select, replacing with closest dropdown"),E=E.parent(I.dropdown),S.refresh(),S.setup.returnedObject(),m&&($=S,S.invoke(v))},returnedObject:function(){var e=r.slice(0,h),t=r.slice(h+1);r=e.add(E).add(t)}},refresh:function(){S.refreshSelectors(),S.refreshData()},refreshSelectors:function(){S.verbose("Refreshing selector cache"),P=E.find(I.text),M=E.find(I.search),z=E.find(I.input),H=E.find(I.icon),j=E.prev().find(I.text).length>0?E.prev().find(I.text):E.prev(),U=E.children(I.menu),N=U.find(I.item)},refreshData:function(){S.verbose("Refreshing cached metadata"),N.removeData(k.text).removeData(k.value),E.removeData(k.defaultText).removeData(k.defaultValue).removeData(k.placeholderText)},toggle:function(){S.verbose("Toggling menu visibility"),S.is.active()?S.hide():S.show()},show:function(t){if(t=e.isFunction(t)?t:function(){},S.can.show()&&!S.is.active()){if(S.debug("Showing dropdown"),S.is.multiple()&&!S.has.search()&&S.is.allFiltered())return!0;S.animate.show(function(){S.can.click()&&S.bind.intent(),S.set.visible(),t.call(B)}),y.onShow.call(B)}},hide:function(t){t=e.isFunction(t)?t:function(){},S.is.active()&&(S.debug("Hiding dropdown"),S.animate.hide(function(){S.remove.visible(),t.call(B)}),y.onHide.call(B))},hideOthers:function(){S.verbose("Finding other dropdowns to hide"),r.not(E).has(I.menu+"."+A.visible).dropdown("hide")},hideMenu:function(){S.verbose("Hiding menu instantaneously"),S.remove.active(),S.remove.visible(),U.transition("hide")},hideSubMenus:function(){var e=U.children(I.item).find(I.menu);S.verbose("Hiding sub menus",e),e.transition("hide")},bind:{keyboardEvents:function(){S.debug("Binding keyboard events"),E.on("keydown"+O,S.event.keydown),S.has.search()&&E.on(S.get.inputEvent()+O,I.search,S.event.input),S.is.multiple()&&s.on("keydown"+p,S.event.document.keydown)},touchEvents:function(){S.debug("Touch device detected binding additional touch events"),S.is.searchSelection()||E.on("touchstart"+O,S.event.test.toggle),U.on("touchstart"+O,I.item,S.event.item.mouseenter)},mouseEvents:function(){S.debug("Mouse detected binding mouse events"),S.is.multiple()&&E.on("click"+O,I.label,S.event.label.click).on("click"+O,I.remove,S.event.remove.click),S.is.searchSelection()?(E.on("mousedown"+O,I.menu,S.event.menu.mousedown).on("mouseup"+O,I.menu,S.event.menu.mouseup).on("click"+O,I.search,S.show).on("focus"+O,I.search,S.event.search.focus).on("blur"+O,I.search,S.event.search.blur).on("click"+O,I.text,S.event.text.focus),S.is.multiple()&&E.on("click"+O,S.event.click)):("click"==y.on?E.on("click"+O,S.event.test.toggle):"hover"==y.on?E.on("mouseenter"+O,S.delay.show).on("mouseleave"+O,S.delay.hide):E.on(y.on+O,S.toggle),E.on("mousedown"+O,S.event.mousedown).on("mouseup"+O,S.event.mouseup).on("focus"+O,S.event.focus).on("blur"+O,S.event.blur)),U.on("mouseenter"+O,I.item,S.event.item.mouseenter).on("mouseleave"+O,I.item,S.event.item.mouseleave).on("click"+O,I.item,S.event.item.click)},intent:function(){S.verbose("Binding hide intent event to document"),c&&s.on("touchstart"+p,S.event.test.touch).on("touchmove"+p,S.event.test.touch),s.on("click"+p,S.event.test.hide)}},unbind:{intent:function(){S.verbose("Removing hide intent event from document"),c&&s.off("touchstart"+p).off("touchmove"+p),s.off("click"+p)}},filter:function(e){var t=e!==i?e:S.get.query(),n=function(){S.is.multiple()&&S.filterActive(),S.select.firstUnfiltered(),S.has.allResultsFiltered()?y.onNoResults.call(B,t)?y.allowAdditions||(S.verbose("All items filtered, showing message",t),S.add.message(T.noResults)):(S.verbose("All items filtered, hiding dropdown",t),S.hideMenu()):S.remove.message(),y.allowAdditions&&S.add.userSuggestion(e),S.is.searchSelection()&&S.can.show()&&S.is.focusedOnSearch()&&S.show()};S.has.maxSelections()||(y.apiSettings?S.can.useAPI()?S.queryRemote(t,function(){n()}):S.error(R.noAPI):(S.filterItems(t),n()))},queryRemote:function(t,n){var i={errorDuration:!1,throttle:y.throttle,cache:"local",urlData:{query:t},onError:function(){S.add.message(T.serverError),n()},onFailure:function(){S.add.message(T.serverError),n()},onSuccess:function(e){S.remove.message(),S.setup.menu({values:e.results}),n()}};E.api("get request")||S.setup.api(),i=e.extend(!0,{},i,y.apiSettings),E.api("setting",i).api("query")},filterItems:function(t){var n=t!==i?t:S.get.query(),a=e(),o=S.escape.regExp(n),r=new RegExp("^"+o,"igm");""===n?a=N:(S.verbose("Searching for matching values",n),N.each(function(){var t,i,o=e(this);if("both"==y.match||"text"==y.match){if(t=String(S.get.choiceText(o,!1)),-1!==t.search(r))return a=a.add(o),!0;if(y.fullTextSearch&&S.fuzzySearch(n,t))return a=a.add(o),!0}if("both"==y.match||"value"==y.match){if(i=String(S.get.choiceValue(o,t)),-1!==i.search(r))return a=a.add(o),!0;if(y.fullTextSearch&&S.fuzzySearch(n,i))return a=a.add(o),!0}})),S.debug("Showing only matched items",n),S.remove.filteredItem(),N.not(a).addClass(A.filtered)},fuzzySearch:function(e,t){var n=t.length,i=e.length;if(e=e.toLowerCase(),t=t.toLowerCase(),i>n)return!1;if(i===n)return e===t;e:for(var a=0,o=0;i>a;a++){for(var r=e.charCodeAt(a);n>o;)if(t.charCodeAt(o++)===r)continue e;return!1}return!0},filterActive:function(){y.useLabels&&N.filter("."+A.active).addClass(A.filtered)},focusSearch:function(){S.is.search()&&!S.is.focusedOnSearch()&&M[0].focus()},forceSelection:function(){var e=N.not(A.filtered).filter("."+A.selected).eq(0),t=N.not(A.filtered).filter("."+A.active).eq(0),n=e.length>0?e:t,i=n.size()>0;i?(S.debug("Forcing partial selection to selected item",n),S.event.item.click.call(n)):S.hide()},event:{focus:function(){y.showOnFocus&&!K&&S.is.hidden()&&!b&&S.show()},click:function(t){var n=e(t.target);!n.is(E)&&!n.is(H)||S.is.focusedOnSearch()||S.focusSearch()},blur:function(e){b=n.activeElement===this,K||b||(S.remove.activeLabel(),S.hide())},mousedown:function(){K=!0},mouseup:function(){K=!1},search:{focus:function(){K=!0,S.is.multiple()&&S.remove.activeLabel(),y.showOnFocus&&S.show()},blur:function(e){b=n.activeElement===this,W||b||(S.is.multiple()?(S.remove.activeLabel(),S.hide()):y.forceSelection?S.forceSelection():S.hide())}},text:{focus:function(e){K=!0,S.focusSearch()}},input:function(e){(S.is.multiple()||S.is.searchSelection())&&S.set.filtered(),clearTimeout(S.timer),S.timer=setTimeout(S.search,y.delay.search)},label:{click:function(t){var n=e(this),i=E.find(I.label),a=i.filter("."+A.active),o=n.nextAll("."+A.active),r=n.prevAll("."+A.active),s=o.length>0?n.nextUntil(o).add(a).add(n):n.prevUntil(r).add(a).add(n);t.shiftKey?(a.removeClass(A.active),s.addClass(A.active)):t.ctrlKey?n.toggleClass(A.active):(a.removeClass(A.active),n.addClass(A.active)),y.onLabelSelect.apply(this,i.filter("."+A.active))}},remove:{click:function(){var t=e(this).parent();t.hasClass(A.active)?S.remove.activeLabels():S.remove.activeLabels(t)}},test:{toggle:function(e){var t=S.is.multiple()?S.show:S.toggle;S.determine.eventOnElement(e,t)&&e.preventDefault()},touch:function(e){S.determine.eventOnElement(e,function(){"touchstart"==e.type?S.timer=setTimeout(S.hide,y.delay.touch):"touchmove"==e.type&&clearTimeout(S.timer)}),e.stopPropagation()},hide:function(e){S.determine.eventInModule(e,S.hide)}},menu:{mousedown:function(){W=!0},mouseup:function(){W=!1}},item:{mouseenter:function(t){var n=e(this).children(I.menu),i=e(this).siblings(I.item).children(I.menu);n.length>0&&(clearTimeout(S.itemTimer),S.itemTimer=setTimeout(function(){S.verbose("Showing sub-menu",n),e.each(i,function(){S.animate.hide(!1,e(this))}),S.animate.show(!1,n)},y.delay.show),t.preventDefault())},mouseleave:function(t){var n=e(this).children(I.menu);n.length>0&&(clearTimeout(S.itemTimer),S.itemTimer=setTimeout(function(){S.verbose("Hiding sub-menu",n),S.animate.hide(!1,n)},y.delay.hide))},click:function(t){var n=e(this),i=e(t?t.target:""),a=n.find(I.menu),o=S.get.choiceText(n),r=S.get.choiceValue(n,o),s=a.length>0,l=a.find(i).length>0;l||s&&!y.allowCategorySelection||(y.useLabels||S.remove.searchTerm(),S.determine.selectAction.call(this,o,r))}},document:{keydown:function(e){var t=e.which,n=S.get.shortcutKeys(),i=S.is.inObject(t,n);if(i){var a=E.find(I.label),o=a.filter("."+A.active),r=(o.data("value"),a.index(o)),s=a.length,l=o.length>0,c=o.length>1,u=0===r,d=r+1==s,v=S.is.searchSelection(),m=S.is.focusedOnSearch(),f=S.is.focused(),h=m&&0===S.get.caretPosition();if(v&&!l&&!m)return;t==n.leftArrow?!f&&!h||l?l&&(e.shiftKey?S.verbose("Adding previous label to selection"):(S.verbose("Selecting previous label"),a.removeClass(A.active)),u&&!c?o.addClass(A.active):o.prev(I.siblingLabel).addClass(A.active).end(),e.preventDefault()):(S.verbose("Selecting previous label"),a.last().addClass(A.active)):t==n.rightArrow?(f&&!l&&a.first().addClass(A.active),l&&(e.shiftKey?S.verbose("Adding next label to selection"):(S.verbose("Selecting next label"),a.removeClass(A.active)),d?v?m?a.removeClass(A.active):S.focusSearch():c?o.next(I.siblingLabel).addClass(A.active):o.addClass(A.active):o.next(I.siblingLabel).addClass(A.active),e.preventDefault())):t==n.deleteKey||t==n.backspace?l?(S.verbose("Removing active labels"),d&&v&&!m&&S.focusSearch(),o.last().next(I.siblingLabel).addClass(A.active),S.remove.activeLabels(o),e.preventDefault()):h&&!l&&t==n.backspace&&(S.verbose("Removing last label on input backspace"),o=a.last().addClass(A.active),S.remove.activeLabels(o)):o.removeClass(A.active)}}},keydown:function(e){var t=e.which,n=S.get.shortcutKeys(),i=S.is.inObject(t,n);if(i){var a,o,r=N.not(I.unselectable).filter("."+A.selected).eq(0),s=U.children("."+A.active).eq(0),l=r.length>0?r:s,c=l.length>0?l.siblings(":not(."+A.filtered+")").andSelf():U.children(":not(."+A.filtered+")"),u=l.children(I.menu),d=l.closest(I.menu),v=d.hasClass(A.visible)||d.hasClass(A.animating)||d.parent(I.menu).length>0,m=u.length>0,f=l.length>0,h=l.not(I.unselectable).length>0;if(S.is.visible()){if((t==n.enter||t==n.delimiter)&&(t==n.enter&&f&&m&&!y.allowCategorySelection?(S.verbose("Pressed enter on unselectable category, opening sub menu"),t=n.rightArrow):h&&(S.verbose("Selecting item from keyboard shortcut",l),S.event.item.click.call(l,e),y.useLabels&&S.is.searchSelection()?S.hideAndClear():S.remove.searchTerm()),e.preventDefault()),t==n.leftArrow&&(o=d[0]!==U[0],o&&(S.verbose("Left key pressed, closing sub-menu"),S.animate.hide(!1,d),l.removeClass(A.selected),d.closest(I.item).addClass(A.selected),e.preventDefault())),t==n.rightArrow&&m&&(S.verbose("Right key pressed, opening sub-menu"),S.animate.show(!1,u),l.removeClass(A.selected),u.find(I.item).eq(0).addClass(A.selected),e.preventDefault()),t==n.upArrow){if(a=f&&v?l.prevAll(I.item+":not("+I.unselectable+")").eq(0):N.eq(0),c.index(a)<0)return S.verbose("Up key pressed but reached top of current menu"),void e.preventDefault();S.verbose("Up key pressed, changing active item"),l.removeClass(A.selected),a.addClass(A.selected),S.set.scrollPosition(a),e.preventDefault()}if(t==n.downArrow){if(a=f&&v?a=l.nextAll(I.item+":not("+I.unselectable+")").eq(0):N.eq(0),0===a.length)return S.verbose("Down key pressed but reached bottom of current menu"),void e.preventDefault();S.verbose("Down key pressed, changing active item"),N.removeClass(A.selected),a.addClass(A.selected),S.set.scrollPosition(a),e.preventDefault()}t==n.pageUp&&(S.scrollPage("up"),e.preventDefault()),t==n.pageDown&&(S.scrollPage("down"),e.preventDefault()),t==n.escape&&(S.verbose("Escape key pressed, closing dropdown"),S.hide())}else t==n.delimiter&&e.preventDefault(),t==n.downArrow&&(S.verbose("Down key pressed, showing dropdown"),S.show(),e.preventDefault())}else S.is.selection()&&!S.is.search()&&S.set.selectedLetter(String.fromCharCode(t))}},determine:{selectAction:function(t,n){S.verbose("Determining action",y.action),e.isFunction(S.action[y.action])?(S.verbose("Triggering preset action",y.action,t,n),S.action[y.action].call(this,t,n)):e.isFunction(y.action)?(S.verbose("Triggering user action",y.action,t,n),y.action.call(this,t,n)):S.error(R.action,y.action)},eventInModule:function(t,n){return n=e.isFunction(n)?n:function(){},0===e(t.target).closest(E).length?(S.verbose("Triggering event",n),n(),!0):(S.verbose("Event occurred in dropdown, canceling callback"),!1)},eventOnElement:function(t,n){var i=e(t.target);return n=e.isFunction(n)?n:function(){},0===i.closest(U).length?(S.verbose("Triggering event",n),n(),!0):(S.verbose("Event occurred in dropdown menu, canceling callback"),!1)}},action:{nothing:function(){},activate:function(t,n){n=n!==i?n:t,S.set.selected(n,e(this)),(!S.is.multiple()||S.is.allFiltered())&&S.hideAndClear()},select:function(e,t){S.action.activate.call(this)},combo:function(t,n){n=n!==i?n:t,S.set.selected(n,e(this)),S.hideAndClear()},hide:function(){S.hideAndClear()}},get:{id:function(){return w},text:function(){return P.text()},query:function(){return e.trim(M.val())},searchWidth:function(e){return e*y.glyphWidth+"em"},selectionCount:function(){var t=S.get.values();return S.is.multiple()?e.isArray(t)?t.length:0:""!==S.get.value()?1:0},transition:function(e){return"auto"==y.transition?S.is.upward(e)?"slide up":"slide down":y.transition},userValues:function(){var t=S.get.values();return t?(t=e.isArray(t)?t:[t],e.grep(t,function(e){return S.get.item(e)===!1})):!1},uniqueArray:function(t){return e.grep(t,function(n,i){return e.inArray(n,t)===i})},caretPosition:function(){var e,t,i=M.get(0);return"selectionStart"in i?i.selectionStart:n.selection?(i.focus(),e=n.selection.createRange(),t=e.text.length,e.moveStart("character",-i.value.length),e.text.length-t):void 0},shortcutKeys:function(){return{backspace:8,delimiter:188,deleteKey:46,enter:13,escape:27,pageUp:33,pageDown:34,leftArrow:37,upArrow:38,rightArrow:39,downArrow:40}},value:function(){return z.length>0?z.val():E.data(k.value)},values:function(){var e=S.get.value();return""===e?"":!z.is("select")&&S.is.multiple()?"string"==typeof e?e.split(y.delimiter):"":e},remoteValues:function(){var t=S.get.values(),n=!1;return t&&("string"==typeof t&&(t=[t]),n={},e.each(t,function(e,t){var i=S.read.remoteData(t);S.verbose("Restoring value from session data",i,t),n[t]=i?i:t})),n},choiceText:function(e,t){return t=t!==i?t:y.preserveHTML,e?(e.find(I.menu).length>0&&(S.verbose("Retreiving text of element with sub-menu"),e=e.clone(),e.find(I.menu).remove(),e.find(I.menuIcon).remove()),e.data(k.text)!==i?e.data(k.text):t?e.html().trim():e.text().trim()):void 0},choiceValue:function(e,t){return t=t||S.get.choiceText(e),e?e.data(k.value)!==i?e.data(k.value):"string"==typeof t?t.toLowerCase().trim():t:!1},inputEvent:function(){var e=M[0];return e?e.oninput!==i?"input":e.onpropertychange!==i?"propertychange":"keyup":!1},selectValues:function(){var t={};return t.values=[],E.find("option").each(function(){var n=e(this),a=n.html(),o=n.attr("disabled"),r=n.attr("value")!==i?n.attr("value"):a;"auto"===y.placeholder&&""===r?t.placeholder=a:t.values.push({name:a,value:r,disabled:o})}),y.placeholder&&"auto"!==y.placeholder&&(S.debug("Setting placeholder value to",y.placeholder),t.placeholder=y.placeholder),y.sortSelect?(t.values.sort(function(e,t){return e.name>t.name?1:-1}),S.debug("Retrieved and sorted values from select",t)):S.debug("Retreived values from select",t),t},activeItem:function(){return N.filter("."+A.active)},selectedItem:function(){var e=N.not(I.unselectable).filter("."+A.selected);return e.length>0?e:N.eq(0)},itemWithAdditions:function(e){var t=S.get.item(e),n=S.create.userChoice(e),i=n&&n.length>0;return i&&(t=t.length>0?t.add(n):n),t},item:function(t,n){var a,o,r=!1;return t=t!==i?t:S.get.values()!==i?S.get.values():S.get.text(),a=o?t.length>0:t!==i&&""!==t&&null!==t,o=S.is.multiple()&&e.isArray(t),n=""===t||0===t?!0:n||!1,a&&N.each(function(){var a=e(this),s=S.get.choiceText(a),l=S.get.choiceValue(a,s);if(null!==l&&l!==i)if(o)(-1!==e.inArray(l.toString(),t)||-1!==e.inArray(s,t))&&(r=r?r.add(a):a);else if(n){if(S.verbose("Ambiguous dropdown value using strict type check",a,t),l===t||s===t)return r=a,!0}else if(l.toString()==t.toString()||s==t)return S.verbose("Found select item by value",l,t),r=a,!0}),r}},check:{maxSelections:function(e){return y.maxSelections?(e=e!==i?e:S.get.selectionCount(),e>=y.maxSelections?(S.debug("Maximum selection count reached"),N.addClass(A.filtered),S.add.message(T.maxSelections),!0):(S.verbose("No longer at maximum selection count"),S.remove.message(),S.remove.filteredItem(),S.is.searchSelection()&&S.filterItems(),!1)):!0}},restore:{defaults:function(){S.restore.defaultText(),S.restore.defaultValue()},defaultText:function(){var e=E.data(k.defaultText);S.debug("Restoring default text",e),S.set.text(e),P.addClass(A.placeholder)},defaultValue:function(){var e=E.data(k.defaultValue);e!==i&&(S.debug("Restoring default value",e),""!==e?(S.set.value(e),S.set.selected()):(S.remove.activeItem(),S.remove.selectedItem()))},labels:function(){y.allowAdditions&&(y.useLabels||(S.error(R.labels),y.useLabels=!0),S.debug("Restoring selected values"),S.create.userLabels()),S.check.maxSelections()},selected:function(){S.restore.values(),S.is.multiple()?(S.debug("Restoring previously selected values and labels"),S.restore.labels()):S.debug("Restoring previously selected values")},values:function(){S.set.initialLoad(),y.apiSettings?y.saveRemoteData?S.restore.remoteValues():S.clearValue():S.set.selected(),S.remove.initialLoad()},remoteValues:function(){var t=S.get.remoteValues();S.debug("Recreating selected from session data",t),t&&(S.is.single()?e.each(t,function(e,t){S.set.text(t)}):e.each(t,function(e,t){S.add.label(e,t)}))}},read:{remoteData:function(e){var n;return t.Storage===i?void S.error(R.noStorage):(n=sessionStorage.getItem(e),n!==i?n:!1)}},save:{defaults:function(){S.save.defaultText(),S.save.placeholderText(),S.save.defaultValue()},defaultValue:function(){var e=S.get.value();S.verbose("Saving default value as",e),E.data(k.defaultValue,e)},defaultText:function(){var e=S.get.text();S.verbose("Saving default text as",e),E.data(k.defaultText,e)},placeholderText:function(){var e;P.hasClass(A.placeholder)&&(e=S.get.text(),S.verbose("Saving placeholder text as",e),E.data(k.placeholderText,e))},remoteData:function(e,n){return t.Storage===i?void S.error(R.noStorage):(S.verbose("Saving remote data to session storage",n,e),void sessionStorage.setItem(n,e))}},clear:function(){S.is.multiple()?S.remove.labels():(S.remove.activeItem(),S.remove.selectedItem()),S.set.placeholderText(),S.clearValue()},clearValue:function(){S.set.value("")},scrollPage:function(e,t){var n,i,a,t=t||S.get.selectedItem(),o=t.closest(I.menu),r=o.outerHeight(),s=o.scrollTop(),l=N.eq(0).outerHeight(),c=Math.floor(r/l),u=(o.prop("scrollHeight"),"up"==e?s-l*c:s+l*c),d=N.not(I.unselectable);a="up"==e?d.index(t)-c:d.index(t)+c,n="up"==e?a>=0:a0&&(S.debug("Scrolling page",e,i),t.removeClass(A.selected),i.addClass(A.selected),o.scrollTop(u))},set:{filtered:function(){var e=S.is.multiple(),t=S.is.searchSelection(),n=e&&t,i=t?S.get.query():"",a="string"==typeof i&&i.length>0,o=S.get.searchWidth(i.length),r=""!==i;e&&a&&(S.verbose("Adjusting input width",o,y.glyphWidth),M.css("width",o)),a||n&&r?(S.verbose("Hiding placeholder text"),P.addClass(A.filtered)):(!e||n&&!r)&&(S.verbose("Showing placeholder text"),P.removeClass(A.filtered))},loading:function(){E.addClass(A.loading)},placeholderText:function(e){e=e||E.data(k.placeholderText),e&&(S.debug("Restoring placeholder text"),S.set.text(e),P.addClass(A.placeholder))},tabbable:function(){S.has.search()?(S.debug("Added tabindex to searchable dropdown"),M.val("").attr("tabindex",0),U.attr("tabindex",-1)):(S.debug("Added tabindex to dropdown"),E.attr("tabindex")||(E.attr("tabindex",0),U.attr("tabindex",-1)))},initialLoad:function(){S.verbose("Setting initial load"),g=!0},scrollPosition:function(e,t){var n,a,o,r,s,l,c,u,d,v=5;e=e||S.get.selectedItem(),n=e.closest(I.menu),a=e&&e.length>0,t=t!==i?t:!1,e&&n.length>0&&a&&(r=e.position().top,n.addClass(A.loading),l=n.scrollTop(),s=n.offset().top,r=e.offset().top,o=l-s+r,t||(c=n.height(),d=o+v>l+c,u=l>o-v),S.debug("Scrolling to active item",o),(t||u||d)&&n.scrollTop(o),n.removeClass(A.loading))},text:function(e){"select"!==y.action&&("combo"==y.action?(S.debug("Changing combo button text",e,j),y.preserveHTML?j.html(e):j.text(e)):(S.debug("Changing text",e,P),P.removeClass(A.filtered).removeClass(A.placeholder),y.preserveHTML?P.html(e):P.text(e)))},selectedLetter:function(t){var n=N.filter("."+A.selected),i=!1;N.each(function(){var n=e(this),a=S.get.choiceText(n,!1),o=String(a).charAt(0).toLowerCase(),r=t.toLowerCase();return o==r?(i=n,!1):void 0}),i&&(S.verbose("Scrolling to next value with letter",t),S.set.scrollPosition(i),n.removeClass(A.selected),i.addClass(A.selected))},direction:function(e){"auto"==y.direction?S.is.onScreen(e)?S.remove.upward(e):S.set.upward(e):"upward"==y.direction&&S.set.upward(e)},upward:function(e){var t=e||E;t.addClass(A.upward)},value:function(e,t,n){var i=z.length>0,a=(!S.has.value(e),S.get.values()),o="number"==typeof e?e.toString():e;if(i){if(o==a&&(S.verbose("Skipping value update already same value",e,a),!S.is.initialLoad()))return;S.debug("Updating input value",e,a),z.val(e).trigger("change")}else S.verbose("Storing value in metadata",e,z),e!==a&&E.data(k.value,e);y.fireOnInit===!1&&S.is.initialLoad()?S.verbose("No callback on initial load",y.onChange):y.onChange.call(B,e,t,n)},active:function(){E.addClass(A.active)},multiple:function(){E.addClass(A.multiple)},visible:function(){E.addClass(A.visible)},selected:function(t,n){var i=S.is.multiple();n=y.allowAdditions?n||S.get.itemWithAdditions(t):n||S.get.item(t),n&&(S.debug("Setting selected menu item to",n),S.is.single()?(S.remove.activeItem(),S.remove.selectedItem()):y.useLabels&&S.remove.selectedItem(),n.each(function(){var t=e(this),a=S.get.choiceText(t),o=S.get.choiceValue(t,a),r=t.hasClass(A.filtered),s=t.hasClass(A.active),l=t.hasClass(A.addition),c=i&&1==n.length;i?!s||l?(y.apiSettings&&y.saveRemoteData&&S.save.remoteData(a,o),y.useLabels?(S.add.value(o,a,t),S.add.label(o,a,c),t.addClass(A.active),S.filterActive(),S.select.nextAvailable(n)):(S.add.value(o,a,t),S.set.text(S.add.variables(T.count)),t.addClass(A.active))):r||(S.debug("Selected active value, removing label"),S.remove.selected(o)):(y.apiSettings&&y.saveRemoteData&&S.save.remoteData(a,o),S.set.value(o,a,t),S.set.text(a),t.addClass(A.active).addClass(A.selected))}))}},add:{label:function(t,n,i){var a,o=S.is.searchSelection()?M:P;return a=e("").addClass(A.label).attr("data-value",t).html(q.label(t,n)),a=y.onLabelCreate.call(a,t,n),S.has.label(t)?void S.debug("Label already exists, skipping",t):(y.label.variation&&a.addClass(y.label.variation),void(i===!0?(S.debug("Animating in label",a),a.addClass(A.hidden).insertBefore(o).transition(y.label.transition,y.label.duration)):(S.debug("Adding selection label",a),a.insertBefore(o))))},message:function(t){var n=U.children(I.message),i=y.templates.message(S.add.variables(t));n.length>0?n.html(i):n=e("
").html(i).addClass(A.message).appendTo(U)},optionValue:function(t){var n=z.find('option[value="'+t+'"]'),i=n.length>0;i||(x&&(x.disconnect(),S.verbose("Temporarily disconnecting mutation observer",t)),e("
").addClass("ui red pointing prompt label").html(t[0])}},rules:{checked:function(){return e(this).filter(":checked").length>0},contains:function(t,n){return n=n.replace(e.fn.form.settings.regExp.escape,"\\$&"),-1!==t.search(new RegExp(n,"i"))},containsExactly:function(t,n){return n=n.replace(e.fn.form.settings.regExp.escape,"\\$&"),-1!==t.search(new RegExp(n))},email:function(t){var n=new RegExp(e.fn.form.settings.regExp.email,"i");return n.test(t)},empty:function(t){return!(t===i||""===t||e.isArray(t)&&0===t.length)},integer:function(t,n){var o,a,r,s=e.fn.form.settings.regExp.integer;return n===i||""===n||".."===n||(-1==n.indexOf("..")?s.test(n)&&(o=a=n-0):(r=n.split("..",2),s.test(r[0])&&(o=r[0]-0),s.test(r[1])&&(a=r[1]-0))),s.test(t)&&(o===i||t>=o)&&(a===i||a>=t)},is:function(e,t){return t="string"==typeof t?t.toLowerCase():t,e="string"==typeof e?e.toLowerCase():e,e==t},isExactly:function(e,t){return e==t},length:function(e,t){return e!==i?e.length>=t:!1},different:function(t,n){{var o;e(this)}return e('[data-validate="'+n+'"]').length>0?o=e('[data-validate="'+n+'"]').val():e("#"+n).length>0?o=e("#"+n).val():e('[name="'+n+'"]').length>0?o=e('[name="'+n+'"]').val():e('[name="'+n+'[]"]').length>0&&(o=e('[name="'+n+'[]"]')),o!==i?t.toString()!==o.toString():!1},match:function(t,n){{var o;e(this)}return e('[data-validate="'+n+'"]').length>0?o=e('[data-validate="'+n+'"]').val():e("#"+n).length>0?o=e("#"+n).val():e('[name="'+n+'"]').length>0?o=e('[name="'+n+'"]').val():e('[name="'+n+'[]"]').length>0&&(o=e('[name="'+n+'[]"]')),o!==i?t.toString()==o.toString():!1},maxCount:function(t,n){return t=t.split(","),e.isArray(t)&&t.length<=n},exactCount:function(t,n){return t=t.split(","),e.isArray(t)&&t.length==n},minCount:function(t,n){return t=t.split(","),e.isArray(t)&&t.length>=n},regExp:function(t,n){var i,o=n.match(e.fn.form.settings.regExp.flags);return o&&(n=o.length>=2?o[1]:n,i=o.length>=3?o[2]:""),t.match(new RegExp(n,i))},maxLength:function(e,t){return e!==i?e.length<=t:!1},not:function(e,t){return e="string"==typeof e?e.toLowerCase():e,t="string"==typeof t?t.toLowerCase():t,e!=t},notExactly:function(e,t){return e!=t},url:function(t){return e.fn.form.settings.regExp.url.match(t)}}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.accordion=function(n){{var o,a=e(this),r=(new Date).getTime(),s=[],c=arguments[0],l="string"==typeof c,u=[].slice.call(arguments,1);t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)}}return a.each(function(){var d,m,f=e.isPlainObject(n)?e.extend(!0,{},e.fn.accordion.settings,n):e.extend({},e.fn.accordion.settings),g=f.className,p=f.namespace,v=f.selector,h=f.error,b="."+p,y="module-"+p,x=a.selector||"",C=e(this),w=C.find(v.title),k=C.find(v.content),S=this,T=C.data(y);m={initialize:function(){m.debug("Initializing",C),m.bind.events(),m.observeChanges(),m.instantiate()},instantiate:function(){T=m,C.data(y,m)},destroy:function(){m.debug("Destroying previous instance",C),C.off(b).removeData(y)},refresh:function(){w=C.find(v.title),k=C.find(v.content)},observeChanges:function(){"MutationObserver"in t&&(d=new MutationObserver(function(e){m.debug("DOM tree modified, updating selector cache"),m.refresh()}),d.observe(S,{childList:!0,subtree:!0}),m.debug("Setting up mutation observer",d))},bind:{events:function(){m.debug("Binding delegated events"),C.on(f.on+b,v.trigger,m.event.click)}},event:{click:function(){m.toggle.call(this)}},toggle:function(t){var n=t!==i?"number"==typeof t?w.eq(t):e(t).closest(v.title):e(this).closest(v.title),o=n.next(k),a=o.hasClass(g.animating),r=o.hasClass(g.active),s=r&&!a,c=!r&&a;m.debug("Toggling visibility of content",n),s||c?f.collapsible?m.close.call(n):m.debug("Cannot close accordion content collapsing is disabled"):m.open.call(n)},open:function(t){var n=t!==i?"number"==typeof t?w.eq(t):e(t).closest(v.title):e(this).closest(v.title),o=n.next(k),a=o.hasClass(g.animating),r=o.hasClass(g.active),s=r||a;return s?void m.debug("Accordion already open, skipping",o):(m.debug("Opening accordion content",n),f.onOpening.call(o),f.exclusive&&m.closeOthers.call(n),n.addClass(g.active),o.stop(!0,!0).addClass(g.animating),f.animateChildren&&(e.fn.transition!==i&&C.transition("is supported")?o.children().transition({animation:"fade in",queue:!1,useFailSafe:!0,debug:f.debug,verbose:f.verbose,duration:f.duration}):o.children().stop(!0,!0).animate({opacity:1},f.duration,m.resetOpacity)),void o.slideDown(f.duration,f.easing,function(){o.removeClass(g.animating).addClass(g.active),m.reset.display.call(this),f.onOpen.call(this),f.onChange.call(this)}))},close:function(t){var n=t!==i?"number"==typeof t?w.eq(t):e(t).closest(v.title):e(this).closest(v.title),o=n.next(k),a=o.hasClass(g.animating),r=o.hasClass(g.active),s=!r&&a,c=r&&a;!r&&!s||c||(m.debug("Closing accordion content",o),f.onClosing.call(o),n.removeClass(g.active),o.stop(!0,!0).addClass(g.animating),f.animateChildren&&(e.fn.transition!==i&&C.transition("is supported")?o.children().transition({animation:"fade out",queue:!1,useFailSafe:!0,debug:f.debug,verbose:f.verbose,duration:f.duration}):o.children().stop(!0,!0).animate({opacity:0},f.duration,m.resetOpacity)),o.slideUp(f.duration,f.easing,function(){o.removeClass(g.animating).removeClass(g.active),m.reset.display.call(this),f.onClose.call(this),f.onChange.call(this)}))},closeOthers:function(t){var n,o,a,r=t!==i?w.eq(t):e(this).closest(v.title),s=r.parents(v.content).prev(v.title),c=r.closest(v.accordion),l=v.title+"."+g.active+":visible",u=v.content+"."+g.active+":visible";f.closeNested?(n=c.find(l).not(s),a=n.next(k)):(n=c.find(l).not(s),o=c.find(u).find(l).not(s),n=n.not(o),a=n.next(k)),n.length>0&&(m.debug("Exclusive enabled, closing other content",n),n.removeClass(g.active),a.removeClass(g.animating).stop(!0,!0),f.animateChildren&&(e.fn.transition!==i&&C.transition("is supported")?a.children().transition({animation:"fade out",useFailSafe:!0,debug:f.debug,verbose:f.verbose,duration:f.duration}):a.children().stop(!0,!0).animate({opacity:0},f.duration,m.resetOpacity)),a.slideUp(f.duration,f.easing,function(){e(this).removeClass(g.active),m.reset.display.call(this)}))},reset:{display:function(){m.verbose("Removing inline display from element",this),e(this).css("display",""),""===e(this).attr("style")&&e(this).attr("style","").removeAttr("style")},opacity:function(){m.verbose("Removing inline opacity from element",this),e(this).css("opacity",""),""===e(this).attr("style")&&e(this).attr("style","").removeAttr("style")}},setting:function(t,n){if(m.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,f,t);else{if(n===i)return f[t];f[t]=n}},internal:function(t,n){return m.debug("Changing internal",t,n),n===i?m[t]:void(e.isPlainObject(t)?e.extend(!0,m,t):m[t]=n)},debug:function(){f.debug&&(f.performance?m.performance.log(arguments):(m.debug=Function.prototype.bind.call(console.info,console,f.name+":"),m.debug.apply(console,arguments)))},verbose:function(){f.verbose&&f.debug&&(f.performance?m.performance.log(arguments):(m.verbose=Function.prototype.bind.call(console.info,console,f.name+":"),m.verbose.apply(console,arguments)))},error:function(){m.error=Function.prototype.bind.call(console.error,console,f.name+":"),m.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;f.performance&&(t=(new Date).getTime(),i=r||t,n=t-i,r=t,s.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:S,"Execution Time":n})),clearTimeout(m.performance.timer),m.performance.timer=setTimeout(m.performance.display,500)},display:function(){var t=f.name+":",n=0;r=!1,clearTimeout(m.performance.timer),e.each(s,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",x&&(t+=" '"+x+"'"),(console.group!==i||console.table!==i)&&s.length>0&&(console.groupCollapsed(t),console.table?console.table(s):e.each(s,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),s=[]}},invoke:function(t,n,a){var r,s,c,l=T;return n=n||u,a=S||a,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):(m.error(h.method,t),!1);l=l[o]}})),e.isFunction(s)?c=s.apply(a,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},l?(T===i&&m.initialize(),m.invoke(c)):(T!==i&&T.invoke("destroy"),m.initialize())}),o!==i?o:this},e.fn.accordion.settings={name:"Accordion",namespace:"accordion",debug:!1,verbose:!1,performance:!0,on:"click",exclusive:!0,collapsible:!0,closeNested:!1,animateChildren:!0,duration:350,easing:"easeOutQuad",onOpening:function(){},onOpen:function(){},onClosing:function(){},onClose:function(){},onChange:function(){},error:{method:"The method you called is not defined"},className:{active:"active",animating:"animating"},selector:{accordion:".accordion",title:".title",trigger:".title",content:".content"}},e.extend(e.easing,{easeOutQuad:function(e,t,n,i,o){return-i*(t/=o)*(t-2)+n}})}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.checkbox=function(n){var o,a=e(this),r=a.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1);return a.each(function(){var a,m,f=e.extend(!0,{},e.fn.checkbox.settings,n),g=f.className,p=f.namespace,v=f.selector,h=f.error,b="."+p,y="module-"+p,x=e(this),C=e(this).children(v.label),w=e(this).children(v.input),k=x.data(y),S=this;m={initialize:function(){m.verbose("Initializing checkbox",f),m.create.label(),m.bind.events(),m.set.tabbable(),m.hide.input(),m.observeChanges(),m.instantiate(),m.setup()},instantiate:function(){m.verbose("Storing instance of module",m),k=m,x.data(y,m)},destroy:function(){m.verbose("Destroying module"),m.unbind.events(),m.show.input(),x.removeData(y)},fix:{reference:function(){x.is(v.input)&&(m.debug("Behavior called on adjusting invoked element"),x=x.closest(v.checkbox),m.refresh())}},setup:function(){m.is.indeterminate()?(m.debug("Initial value is indeterminate"),m.set.indeterminate(),f.fireOnInit&&(f.onIndeterminate.call(w[0]),f.onChange.call(w[0]))):m.is.checked()?(m.debug("Initial value is checked"),m.set.checked(),f.fireOnInit&&(f.onChecked.call(w[0]),f.onChange.call(w[0]))):(m.debug("Initial value is unchecked"),m.set.unchecked(),f.fireOnInit&&(f.onUnchecked.call(w[0]),f.onChange.call(w[0])))},refresh:function(){C=x.children(v.label),w=x.children(v.input)},hide:{input:function(){m.verbose("Modfying z-index to be unselectable"),w.addClass(g.hidden)}},show:{input:function(){m.verbose("Modfying z-index to be selectable"),w.removeClass(g.hidden)}},observeChanges:function(){"MutationObserver"in t&&(a=new MutationObserver(function(e){m.debug("DOM tree modified, updating selector cache"),m.refresh()}),a.observe(S,{childList:!0,subtree:!0}),m.debug("Setting up mutation observer",a))},attachEvents:function(t,n){var i=e(t);n=e.isFunction(m[n])?m[n]:m.toggle,i.length>0?(m.debug("Attaching checkbox events to element",t,n),i.on("click"+b,n)):m.error(h.notFound)},event:{click:function(t){return e(t.target).is(v.input)?void m.verbose("Using default check action on initialized checkbox"):void m.toggle()},keydown:function(e){var t=e.which,n={enter:13,space:32,escape:27};t==n.escape&&(m.verbose("Escape key pressed blurring field"),w.blur(),e.preventDefault()),e.ctrlKey||t!=n.enter&&t!=n.space||(m.verbose("Enter key pressed, toggling checkbox"),m.toggle(),e.preventDefault())}},check:function(){return!m.is.indeterminate()&&m.is.checked()?void m.debug("Checkbox is already checked"):(m.debug("Checking checkbox",w),m.set.checked(),f.onChecked.call(w[0]),void f.onChange.call(w[0]))},uncheck:function(){return!m.is.indeterminate()&&m.is.unchecked()?void m.debug("Checkbox is already unchecked"):(m.debug("Unchecking checkbox"),m.set.unchecked(),f.onUnchecked.call(w[0]),void f.onChange.call(w[0]))},indeterminate:function(){return m.is.indeterminate()?void m.debug("Checkbox is already indeterminate"):(m.debug("Making checkbox indeterminate"),m.set.indeterminate(),f.onIndeterminate.call(w[0]),void f.onChange.call(w[0]))},determinate:function(){return m.is.determinate()?void m.debug("Checkbox is already determinate"):(m.debug("Making checkbox determinate"),m.set.determinate(),f.onDeterminate.call(w[0]),void f.onChange.call(w[0]))},enable:function(){return m.is.enabled()?void m.debug("Checkbox is already enabled"):(m.debug("Enabling checkbox"),m.set.enabled(),void f.onEnable.call(w[0]))},disable:function(){return m.is.disabled()?void m.debug("Checkbox is already disabled"):(m.debug("Disabling checkbox"),m.set.disabled(),void f.onDisable.call(w[0]))},get:{radios:function(){var t=m.get.name();return e('input[name="'+t+'"]').closest(v.checkbox)},name:function(){return w.attr("name")}},is:{radio:function(){return w.hasClass(g.radio)||"radio"==w.attr("type")},indeterminate:function(){return w.prop("indeterminate")!==i&&w.prop("indeterminate")},checked:function(){return w.prop("checked")!==i&&w.prop("checked")},disabled:function(){return w.prop("disabled")!==i&&w.prop("disabled")},enabled:function(){return!m.is.disabled()},determinate:function(){return!m.is.indeterminate()},unchecked:function(){return!m.is.checked()}},can:{change:function(){return!(x.hasClass(g.disabled)||x.hasClass(g.readOnly)||w.prop("disabled")||w.prop("readonly"))},uncheck:function(){return"boolean"==typeof f.uncheckable?f.uncheckable:!m.is.radio()}},set:{checked:function(){return!m.is.indeterminate()&&m.is.checked()?void m.debug("Input is already checked"):(m.verbose("Setting state to checked",w[0]),m.is.radio()&&m.uncheckOthers(),w.prop("indeterminate",!1).prop("checked",!0), -x.removeClass(g.indeterminate).addClass(g.checked),void m.trigger.change())},unchecked:function(){return!m.is.indeterminate()&&m.is.unchecked()?void m.debug("Input is already unchecked"):(m.debug("Setting state to unchecked"),w.prop("indeterminate",!1).prop("checked",!1),x.removeClass(g.indeterminate).removeClass(g.checked),void m.trigger.change())},indeterminate:function(){return m.is.indeterminate()?void m.debug("Input is already indeterminate"):(m.debug("Setting state to indeterminate"),w.prop("indeterminate",!0),x.addClass(g.indeterminate),void m.trigger.change())},determinate:function(){return m.is.determinate()?void m.debug("Input is already determinate"):(m.debug("Setting state to determinate"),w.prop("indeterminate",!1),void x.removeClass(g.indeterminate))},disabled:function(){return m.is.disabled()?void m.debug("Input is already disabled"):(m.debug("Setting state to disabled"),w.prop("disabled","disabled"),x.addClass(g.disabled),void m.trigger.change())},enabled:function(){return m.is.enabled()?void m.debug("Input is already enabled"):(m.debug("Setting state to enabled"),w.prop("disabled",!1),x.removeClass(g.disabled),void m.trigger.change())},tabbable:function(){m.verbose("Adding tabindex to checkbox"),w.attr("tabindex")===i&&w.attr("tabindex",0)}},trigger:{change:function(){m.verbose("Triggering change event from programmatic change"),w.trigger("change")}},create:{label:function(){w.prevAll(v.label).length>0?(w.prev(v.label).detach().insertAfter(w),m.debug("Moving existing label",C)):m.has.label()||(C=e("
").attr("class","ui dimmer")}}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.dropdown=function(o){var a,r=e(this),s=e(n),c=r.selector||"",l="ontouchstart"in n.documentElement,u=(new Date).getTime(),d=[],m=arguments[0],f="string"==typeof m,g=[].slice.call(arguments,1);return r.each(function(){var p,v,h,b,y,x,C,w=e.isPlainObject(o)?e.extend(!0,{},e.fn.dropdown.settings,o):e.extend({},e.fn.dropdown.settings),k=w.className,S=w.message,T=w.metadata,A=w.namespace,R=w.regExp,P=w.selector,E=w.error,F=w.templates,D="."+A,O="module-"+A,q=e(this),j=e(w.context),z=q.find(P.text),I=q.find(P.search),N=q.find(P.input),L=q.find(P.icon),H=q.prev().find(P.text).length>0?q.prev().find(P.text):q.prev(),V=q.children(P.menu),M=V.find(P.item),U=!1,W=!1,B=this,Q=q.data(O);C={initialize:function(){C.debug("Initializing dropdown",w),C.is.alreadySetup()?C.setup.reference():(C.setup.layout(),C.refreshData(),C.save.defaults(),C.restore.selected(),C.create.id(),l&&C.bind.touchEvents(),C.bind.mouseEvents(),C.bind.keyboardEvents(),C.observeChanges(),C.instantiate())},instantiate:function(){C.verbose("Storing instance of dropdown",C),Q=C,q.data(O,C)},destroy:function(){C.verbose("Destroying previous dropdown",q),C.remove.tabbable(),q.off(D).removeData(O),V.off(D),s.off(h),y&&y.disconnect(),x&&x.disconnect()},observeChanges:function(){"MutationObserver"in t&&(y=new MutationObserver(function(e){C.debug("").addClass(k.search).insertBefore(z)),w.allowTab&&C.set.tabbable(),0===V.length&&(V=e("
").addClass(k.menu).appendTo(q))},select:function(){var t=C.get.selectValues();C.debug("Dropdown initialized on a select",t),q.is("select")&&(N=q),N.parent(P.dropdown).length>0?(C.debug("UI dropdown already exists. Creating dropdown menu only"),q=N.closest(P.dropdown),V=q.children(P.menu),C.setup.menu(t)):(C.debug("Creating entire dropdown from select"),q=e("
").attr("class",N.attr("class")).addClass(k.selection).addClass(k.dropdown).html(F.dropdown(t)).insertBefore(N),N.removeAttr("class").detach().prependTo(q)),N.is("[multiple]")&&C.set.multiple(),C.refresh()},menu:function(e){V.html(F.menu(e)),M=V.find(P.item)},reference:function(){var e,t,n=r.index(q);C.debug("Dropdown behavior was called on select, replacing with closest dropdown"),q=q.parent(P.dropdown),C.refresh(),e=r.slice(0,n),t=r.slice(n+1),r=e.add(q).add(t),f&&(Q=C,C.invoke(m))}},refresh:function(){C.refreshSelectors(),C.refreshData()},refreshSelectors:function(){C.verbose("Refreshing selector cache"),z=q.find(P.text),I=q.find(P.search),N=q.find(P.input),L=q.find(P.icon),H=q.prev().find(P.text).length>0?q.prev().find(P.text):q.prev(),V=q.children(P.menu),M=V.find(P.item)},refreshData:function(){C.verbose("Refreshing cached metadata"),M.removeData(T.text).removeData(T.value),q.removeData(T.defaultText).removeData(T.defaultValue).removeData(T.placeholderText)},toggle:function(){C.verbose("Toggling menu visibility"),C.is.active()?C.hide():C.show()},show:function(t){if(t=e.isFunction(t)?t:function(){},C.can.show()&&!C.is.active()){if(C.debug("Showing dropdown"),C.is.multiple()&&!C.has.search()&&C.is.allFiltered())return!0;C.animate.show(function(){C.can.click()&&C.bind.intent(),C.set.visible(),t.call(B)}),w.onShow.call(B)}},hide:function(t){t=e.isFunction(t)?t:function(){},C.is.active()&&(C.debug("Hiding dropdown"),C.animate.hide(function(){C.remove.visible(),t.call(B)}),w.onHide.call(B))},hideOthers:function(){C.verbose("Finding other dropdowns to hide"),r.not(q).has(P.menu+"."+k.visible).dropdown("hide")},hideMenu:function(){C.verbose("Hiding menu instantaneously"),C.remove.active(),C.remove.visible(),V.transition("hide")},hideSubMenus:function(){var e=V.children(P.item).find(P.menu);C.verbose("Hiding sub menus",e),e.transition("hide")},bind:{keyboardEvents:function(){C.debug("Binding keyboard events"),q.on("keydown"+D,C.event.keydown),C.has.search()&&q.on(C.get.inputEvent()+D,P.search,C.event.input),C.is.multiple()&&s.on("keydown"+h,C.event.document.keydown)},touchEvents:function(){C.debug("Touch device detected binding additional touch events"),C.is.searchSelection()||q.on("touchstart"+D,C.event.test.toggle),V.on("touchstart"+D,P.item,C.event.item.mouseenter)},mouseEvents:function(){C.debug("Mouse detected binding mouse events"),C.is.multiple()&&q.on("click"+D,P.label,C.event.label.click).on("click"+D,P.remove,C.event.remove.click),C.is.searchSelection()?(q.on("mousedown"+D,P.menu,C.event.menu.mousedown).on("mouseup"+D,P.menu,C.event.menu.mouseup).on("click"+D,P.search,C.show).on("focus"+D,P.search,C.event.search.focus).on("blur"+D,P.search,C.event.search.blur).on("click"+D,P.text,C.event.text.focus),C.is.multiple()&&q.on("click"+D,C.event.click)):("click"==w.on?q.on("click"+D,C.event.test.toggle):"hover"==w.on?q.on("mouseenter"+D,C.delay.show).on("mouseleave"+D,C.delay.hide):q.on(w.on+D,C.toggle),q.on("mousedown"+D,C.event.mousedown).on("mouseup"+D,C.event.mouseup).on("focus"+D,C.event.focus).on("blur"+D,C.event.blur)),V.on("mouseenter"+D,P.item,C.event.item.mouseenter).on("mouseleave"+D,P.item,C.event.item.mouseleave).on("click"+D,P.item,C.event.item.click)},intent:function(){C.verbose("Binding hide intent event to document"),l&&s.on("touchstart"+h,C.event.test.touch).on("touchmove"+h,C.event.test.touch),s.on("click"+h,C.event.test.hide)}},unbind:{intent:function(){C.verbose("Removing hide intent event from document"),l&&s.off("touchstart"+h).off("touchmove"+h),s.off("click"+h)}},filter:function(e){var t=e!==i?e:C.get.query(),n=function(){C.is.multiple()&&C.filterActive(),C.select.firstUnfiltered(),C.has.allResultsFiltered()?w.onNoResults.call(B,t)?w.allowAdditions||(C.verbose("All items filtered, showing message",t),C.add.message(S.noResults)):(C.verbose("All items filtered, hiding dropdown",t),C.hideMenu()):C.remove.message(),w.allowAdditions&&C.add.userSuggestion(e),C.is.searchSelection()&&C.can.show()&&C.is.focusedOnSearch()&&C.show()};C.has.maxSelections()||(w.apiSettings?C.can.useAPI()?C.queryRemote(t,function(){n()}):C.error(E.noAPI):(C.filterItems(t),n()))},queryRemote:function(t,n){var i={errorDuration:!1,throttle:w.throttle,cache:"local",urlData:{query:t},onError:function(){C.add.message(S.serverError),n()},onFailure:function(){C.add.message(S.serverError),n()},onSuccess:function(e){C.remove.message(),C.setup.menu({values:e.results}),n()}};q.api("get request")||C.setup.api(),i=e.extend(!0,{},i,w.apiSettings),q.api("setting",i).api("query")},filterItems:function(t){var n=t!==i?t:C.get.query(),o=e(),a=C.escape.regExp(n),r=new RegExp("^"+a,"igm");""===n?o=M:(C.verbose("Searching for matching values",n),M.each(function(){var t,i,a=e(this);if("both"==w.match||"text"==w.match){if(t=String(C.get.choiceText(a,!1)),-1!==t.search(r))return o=o.add(a),!0;if(w.fullTextSearch&&C.fuzzySearch(n,t))return o=o.add(a),!0}if("both"==w.match||"value"==w.match){if(i=String(C.get.choiceValue(a,t)),-1!==i.search(r))return o=o.add(a),!0;if(w.fullTextSearch&&C.fuzzySearch(n,i))return o=o.add(a),!0}})),C.debug("Showing only matched items",n),C.remove.filteredItem(),M.not(o).addClass(k.filtered)},fuzzySearch:function(e,t){var n=t.length,i=e.length;if(e=e.toLowerCase(),t=t.toLowerCase(),i>n)return!1;if(i===n)return e===t;e:for(var o=0,a=0;i>o;o++){for(var r=e.charCodeAt(o);n>a;)if(t.charCodeAt(a++)===r)continue e;return!1}return!0},filterActive:function(){w.useLabels&&M.filter("."+k.active).addClass(k.filtered)},focusSearch:function(){C.is.search()&&!C.is.focusedOnSearch()&&I[0].focus()},forceSelection:function(){var e=M.not(k.filtered).filter("."+k.selected).eq(0),t=M.not(k.filtered).filter("."+k.active).eq(0),n=e.length>0?e:t,i=n.size()>0;i?(C.debug("Forcing partial selection to selected item",n),C.event.item.click.call(n)):C.hide()},event:{focus:function(){w.showOnFocus&&!U&&C.is.hidden()&&!v&&C.show()},click:function(t){var n=e(t.target);!n.is(q)&&!n.is(L)||C.is.focusedOnSearch()||C.focusSearch()},blur:function(e){v=n.activeElement===this,U||v||(C.remove.activeLabel(),C.hide())},mousedown:function(){U=!0},mouseup:function(){U=!1},search:{focus:function(){U=!0,C.is.multiple()&&C.remove.activeLabel(),w.showOnFocus&&C.show()},blur:function(e){v=n.activeElement===this,W||v||(C.is.multiple()?(C.remove.activeLabel(),C.hide()):w.forceSelection?C.forceSelection():C.hide())}},text:{focus:function(e){U=!0,C.focusSearch()}},input:function(e){(C.is.multiple()||C.is.searchSelection())&&C.set.filtered(),clearTimeout(C.timer),C.timer=setTimeout(C.search,w.delay.search)},label:{click:function(t){var n=e(this),i=q.find(P.label),o=i.filter("."+k.active),a=n.nextAll("."+k.active),r=n.prevAll("."+k.active),s=a.length>0?n.nextUntil(a).add(o).add(n):n.prevUntil(r).add(o).add(n);t.shiftKey?(o.removeClass(k.active),s.addClass(k.active)):t.ctrlKey?n.toggleClass(k.active):(o.removeClass(k.active),n.addClass(k.active)),w.onLabelSelect.apply(this,i.filter("."+k.active))}},remove:{click:function(){var t=e(this).parent();t.hasClass(k.active)?C.remove.activeLabels():C.remove.activeLabels(t)}},test:{toggle:function(e){var t=C.is.multiple()?C.show:C.toggle;C.determine.eventOnElement(e,t)&&e.preventDefault()},touch:function(e){C.determine.eventOnElement(e,function(){"touchstart"==e.type?C.timer=setTimeout(C.hide,w.delay.touch):"touchmove"==e.type&&clearTimeout(C.timer)}),e.stopPropagation()},hide:function(e){C.determine.eventInModule(e,C.hide)}},menu:{mousedown:function(){W=!0},mouseup:function(){W=!1}},item:{mouseenter:function(t){var n=e(this).children(P.menu),i=e(this).siblings(P.item).children(P.menu);n.length>0&&(clearTimeout(C.itemTimer),C.itemTimer=setTimeout(function(){C.verbose("Showing sub-menu",n),e.each(i,function(){C.animate.hide(!1,e(this))}),C.animate.show(!1,n)},w.delay.show),t.preventDefault())},mouseleave:function(t){var n=e(this).children(P.menu);n.length>0&&(clearTimeout(C.itemTimer),C.itemTimer=setTimeout(function(){C.verbose("Hiding sub-menu",n),C.animate.hide(!1,n)},w.delay.hide))},click:function(t){var n=e(this),i=e(t?t.target:""),o=n.find(P.menu),a=C.get.choiceText(n),r=C.get.choiceValue(n,a),s=o.length>0,c=o.find(i).length>0;c||s&&!w.allowCategorySelection||(w.useLabels||C.remove.searchTerm(),C.determine.selectAction.call(this,a,r))}},document:{keydown:function(e){var t=e.which,n=C.get.shortcutKeys(),i=C.is.inObject(t,n);if(i){var o=q.find(P.label),a=o.filter("."+k.active),r=(a.data("value"),o.index(a)),s=o.length,c=a.length>0,l=a.length>1,u=0===r,d=r+1==s,m=C.is.searchSelection(),f=C.is.focusedOnSearch(),g=C.is.focused(),p=f&&0===C.get.caretPosition();if(m&&!c&&!f)return;t==n.leftArrow?!g&&!p||c?c&&(e.shiftKey?C.verbose("Adding previous label to selection"):(C.verbose("Selecting previous label"),o.removeClass(k.active)),u&&!l?a.addClass(k.active):a.prev(P.siblingLabel).addClass(k.active).end(),e.preventDefault()):(C.verbose("Selecting previous label"),o.last().addClass(k.active)):t==n.rightArrow?(g&&!c&&o.first().addClass(k.active),c&&(e.shiftKey?C.verbose("Adding next label to selection"):(C.verbose("Selecting next label"),o.removeClass(k.active)),d?m?f?o.removeClass(k.active):C.focusSearch():l?a.next(P.siblingLabel).addClass(k.active):a.addClass(k.active):a.next(P.siblingLabel).addClass(k.active),e.preventDefault())):t==n.deleteKey||t==n.backspace?c?(C.verbose("Removing active labels"),d&&m&&!f&&C.focusSearch(),a.last().next(P.siblingLabel).addClass(k.active),C.remove.activeLabels(a),e.preventDefault()):p&&!c&&t==n.backspace&&(C.verbose("Removing last label on input backspace"),a=o.last().addClass(k.active),C.remove.activeLabels(a)):a.removeClass(k.active)}}},keydown:function(e){var t=e.which,n=C.get.shortcutKeys(),i=C.is.inObject(t,n);if(i){var o,a,r=M.not(P.unselectable).filter("."+k.selected).eq(0),s=V.children("."+k.active).eq(0),c=r.length>0?r:s,l=c.length>0?c.siblings(":not(."+k.filtered+")").andSelf():V.children(":not(."+k.filtered+")"),u=c.children(P.menu),d=c.closest(P.menu),m=d.hasClass(k.visible)||d.hasClass(k.animating)||d.parent(P.menu).length>0,f=u.length>0,g=c.length>0,p=c.not(P.unselectable).length>0;if(C.is.visible()){if((t==n.enter||t==n.delimiter)&&(t==n.enter&&g&&f&&!w.allowCategorySelection?(C.verbose("Pressed enter on unselectable category, opening sub menu"),t=n.rightArrow):p&&(C.verbose("Selecting item from keyboard shortcut",c),C.event.item.click.call(c,e),w.useLabels&&C.is.searchSelection()?C.hideAndClear():C.remove.searchTerm()),e.preventDefault()),t==n.leftArrow&&(a=d[0]!==V[0],a&&(C.verbose("Left key pressed, closing sub-menu"),C.animate.hide(!1,d),c.removeClass(k.selected),d.closest(P.item).addClass(k.selected),e.preventDefault())),t==n.rightArrow&&f&&(C.verbose("Right key pressed, opening sub-menu"),C.animate.show(!1,u),c.removeClass(k.selected),u.find(P.item).eq(0).addClass(k.selected),e.preventDefault()),t==n.upArrow){if(o=g&&m?c.prevAll(P.item+":not("+P.unselectable+")").eq(0):M.eq(0),l.index(o)<0)return C.verbose("Up key pressed but reached top of current menu"),void e.preventDefault();C.verbose("Up key pressed, changing active item"),c.removeClass(k.selected),o.addClass(k.selected),C.set.scrollPosition(o),e.preventDefault()}if(t==n.downArrow){if(o=g&&m?o=c.nextAll(P.item+":not("+P.unselectable+")").eq(0):M.eq(0),0===o.length)return C.verbose("Down key pressed but reached bottom of current menu"),void e.preventDefault();C.verbose("Down key pressed, changing active item"),M.removeClass(k.selected),o.addClass(k.selected),C.set.scrollPosition(o),e.preventDefault()}t==n.pageUp&&(C.scrollPage("up"),e.preventDefault()),t==n.pageDown&&(C.scrollPage("down"),e.preventDefault()),t==n.escape&&(C.verbose("Escape key pressed, closing dropdown"),C.hide())}else t==n.delimiter&&e.preventDefault(),t==n.downArrow&&(C.verbose("Down key pressed, showing dropdown"),C.show(),e.preventDefault())}else C.is.selection()&&!C.is.search()&&C.set.selectedLetter(String.fromCharCode(t))}},determine:{selectAction:function(t,n){C.verbose("Determining action",w.action),e.isFunction(C.action[w.action])?(C.verbose("Triggering preset action",w.action,t,n),C.action[w.action].call(this,t,n)):e.isFunction(w.action)?(C.verbose("Triggering user action",w.action,t,n),w.action.call(this,t,n)):C.error(E.action,w.action)},eventInModule:function(t,n){return n=e.isFunction(n)?n:function(){},0===e(t.target).closest(q).length?(C.verbose("Triggering event",n),n(),!0):(C.verbose("Event occurred in dropdown, canceling callback"),!1)},eventOnElement:function(t,n){var i=e(t.target);return n=e.isFunction(n)?n:function(){},0===i.closest(V).length?(C.verbose("Triggering event",n),n(),!0):(C.verbose("Event occurred in dropdown menu, canceling callback"),!1)}},action:{nothing:function(){},activate:function(t,n){n=n!==i?n:t,C.set.selected(n,e(this)),(!C.is.multiple()||C.is.allFiltered())&&C.hideAndClear()},select:function(e,t){C.action.activate.call(this)},combo:function(t,n){n=n!==i?n:t,C.set.selected(n,e(this)),C.hideAndClear()},hide:function(){C.hideAndClear()}},get:{id:function(){return b},text:function(){return z.text()},query:function(){return e.trim(I.val())},searchWidth:function(e){return e*w.glyphWidth+"em"},selectionCount:function(){var t=C.get.values();return C.is.multiple()?e.isArray(t)?t.length:0:""!==C.get.value()?1:0},transition:function(e){return"auto"==w.transition?C.is.upward(e)?"slide up":"slide down":w.transition},userValues:function(){var t=C.get.values();return t?(t=e.isArray(t)?t:[t],e.grep(t,function(e){return C.get.item(e)===!1})):!1},uniqueArray:function(t){return e.grep(t,function(n,i){return e.inArray(n,t)===i})},caretPosition:function(){var e,t,i=I.get(0);return"selectionStart"in i?i.selectionStart:n.selection?(i.focus(),e=n.selection.createRange(),t=e.text.length,e.moveStart("character",-i.value.length),e.text.length-t):void 0},shortcutKeys:function(){return{backspace:8,delimiter:188,deleteKey:46,enter:13,escape:27,pageUp:33,pageDown:34,leftArrow:37,upArrow:38,rightArrow:39,downArrow:40}},value:function(){return N.length>0?N.val():q.data(T.value)},values:function(){var e=C.get.value();return""===e?"":!N.is("select")&&C.is.multiple()?"string"==typeof e?e.split(w.delimiter):"":e},remoteValues:function(){var t=C.get.values(),n=!1;return t&&("string"==typeof t&&(t=[t]),n={},e.each(t,function(e,t){var i=C.read.remoteData(t);C.verbose("Restoring value from session data",i,t),n[t]=i?i:t})),n},choiceText:function(e,t){return t=t!==i?t:w.preserveHTML,e?(e.find(P.menu).length>0&&(C.verbose("Retreiving text of element with sub-menu"),e=e.clone(),e.find(P.menu).remove(),e.find(P.menuIcon).remove()),e.data(T.text)!==i?e.data(T.text):t?e.html().trim():e.text().trim()):void 0},choiceValue:function(e,t){return t=t||C.get.choiceText(e),e?e.data(T.value)!==i?e.data(T.value):"string"==typeof t?t.toLowerCase().trim():t:!1},inputEvent:function(){var e=I[0];return e?e.oninput!==i?"input":e.onpropertychange!==i?"propertychange":"keyup":!1},selectValues:function(){var t={};return t.values=[],q.find("option").each(function(){var n=e(this),o=n.html(),a=n.attr("disabled"),r=n.attr("value")!==i?n.attr("value"):o;"auto"===w.placeholder&&""===r?t.placeholder=o:t.values.push({name:o,value:r,disabled:a})}),w.placeholder&&"auto"!==w.placeholder&&(C.debug("Setting placeholder value to",w.placeholder),t.placeholder=w.placeholder),w.sortSelect?(t.values.sort(function(e,t){return e.name>t.name?1:-1}),C.debug("Retrieved and sorted values from select",t)):C.debug("Retreived values from select",t),t},activeItem:function(){return M.filter("."+k.active)},selectedItem:function(){var e=M.not(P.unselectable).filter("."+k.selected);return e.length>0?e:M.eq(0)},itemWithAdditions:function(e){var t=C.get.item(e),n=C.create.userChoice(e),i=n&&n.length>0;return i&&(t=t.length>0?t.add(n):n),t},item:function(t,n){var o,a,r=!1;return t=t!==i?t:C.get.values()!==i?C.get.values():C.get.text(),o=a?t.length>0:t!==i&&""!==t&&null!==t,a=C.is.multiple()&&e.isArray(t),n=""===t||0===t?!0:n||!1,o&&M.each(function(){var o=e(this),s=C.get.choiceText(o),c=C.get.choiceValue(o,s);if(null!==c&&c!==i)if(a)(-1!==e.inArray(c.toString(),t)||-1!==e.inArray(s,t))&&(r=r?r.add(o):o);else if(n){if(C.verbose("Ambiguous dropdown value using strict type check",o,t),c===t||s===t)return r=o,!0}else if(c.toString()==t.toString()||s==t)return C.verbose("Found select item by value",c,t),r=o,!0}),r}},check:{ -maxSelections:function(e){return w.maxSelections?(e=e!==i?e:C.get.selectionCount(),e>=w.maxSelections?(C.debug("Maximum selection count reached"),M.addClass(k.filtered),C.add.message(S.maxSelections),!0):(C.verbose("No longer at maximum selection count"),C.remove.message(),C.remove.filteredItem(),C.is.searchSelection()&&C.filterItems(),!1)):!0}},restore:{defaults:function(){C.restore.defaultText(),C.restore.defaultValue()},defaultText:function(){var e=q.data(T.defaultText);C.debug("Restoring default text",e),C.set.text(e),z.addClass(k.placeholder)},defaultValue:function(){var e=q.data(T.defaultValue);e!==i&&(C.debug("Restoring default value",e),""!==e?(C.set.value(e),C.set.selected()):(C.remove.activeItem(),C.remove.selectedItem()))},labels:function(){w.allowAdditions&&(w.useLabels||(C.error(E.labels),w.useLabels=!0),C.debug("Restoring selected values"),C.create.userLabels()),C.check.maxSelections()},selected:function(){C.restore.values(),C.is.multiple()?(C.debug("Restoring previously selected values and labels"),C.restore.labels()):C.debug("Restoring previously selected values")},values:function(){C.set.initialLoad(),w.apiSettings?w.saveRemoteData?C.restore.remoteValues():C.clearValue():C.set.selected(),C.remove.initialLoad()},remoteValues:function(){var t=C.get.remoteValues();C.debug("Recreating selected from session data",t),t&&(C.is.single()?e.each(t,function(e,t){C.set.text(t)}):e.each(t,function(e,t){C.add.label(e,t)}))}},read:{remoteData:function(e){var n;return t.Storage===i?void C.error(E.noStorage):(n=sessionStorage.getItem(e),n!==i?n:!1)}},save:{defaults:function(){C.save.defaultText(),C.save.placeholderText(),C.save.defaultValue()},defaultValue:function(){var e=C.get.value();C.verbose("Saving default value as",e),q.data(T.defaultValue,e)},defaultText:function(){var e=C.get.text();C.verbose("Saving default text as",e),q.data(T.defaultText,e)},placeholderText:function(){var e;z.hasClass(k.placeholder)&&(e=C.get.text(),C.verbose("Saving placeholder text as",e),q.data(T.placeholderText,e))},remoteData:function(e,n){return t.Storage===i?void C.error(E.noStorage):(C.verbose("Saving remote data to session storage",n,e),void sessionStorage.setItem(n,e))}},clear:function(){C.is.multiple()?C.remove.labels():(C.remove.activeItem(),C.remove.selectedItem()),C.set.placeholderText(),C.clearValue()},clearValue:function(){C.set.value("")},scrollPage:function(e,t){var n,i,o,t=t||C.get.selectedItem(),a=t.closest(P.menu),r=a.outerHeight(),s=a.scrollTop(),c=M.eq(0).outerHeight(),l=Math.floor(r/c),u=(a.prop("scrollHeight"),"up"==e?s-c*l:s+c*l),d=M.not(P.unselectable);o="up"==e?d.index(t)-l:d.index(t)+l,n="up"==e?o>=0:o0&&(C.debug("Scrolling page",e,i),t.removeClass(k.selected),i.addClass(k.selected),a.scrollTop(u))},set:{filtered:function(){var e=C.is.multiple(),t=C.is.searchSelection(),n=e&&t,i=t?C.get.query():"",o="string"==typeof i&&i.length>0,a=C.get.searchWidth(i.length),r=""!==i;e&&o&&(C.verbose("Adjusting input width",a,w.glyphWidth),I.css("width",a)),o||n&&r?(C.verbose("Hiding placeholder text"),z.addClass(k.filtered)):(!e||n&&!r)&&(C.verbose("Showing placeholder text"),z.removeClass(k.filtered))},loading:function(){q.addClass(k.loading)},placeholderText:function(e){e=e||q.data(T.placeholderText),e&&(C.debug("Restoring placeholder text"),C.set.text(e),z.addClass(k.placeholder))},tabbable:function(){C.has.search()?(C.debug("Added tabindex to searchable dropdown"),I.val("").attr("tabindex",0),V.attr("tabindex",-1)):(C.debug("Added tabindex to dropdown"),q.attr("tabindex")||(q.attr("tabindex",0),V.attr("tabindex",-1)))},initialLoad:function(){C.verbose("Setting initial load"),p=!0},scrollPosition:function(e,t){var n,o,a,r,s,c,l,u,d,m=5;e=e||C.get.selectedItem(),n=e.closest(P.menu),o=e&&e.length>0,t=t!==i?t:!1,e&&n.length>0&&o&&(r=e.position().top,n.addClass(k.loading),c=n.scrollTop(),s=n.offset().top,r=e.offset().top,a=c-s+r,t||(l=n.height(),d=a+m>c+l,u=c>a-m),C.debug("Scrolling to active item",a),(t||u||d)&&n.scrollTop(a),n.removeClass(k.loading))},text:function(e){"select"!==w.action&&("combo"==w.action?(C.debug("Changing combo button text",e,H),w.preserveHTML?H.html(e):H.text(e)):(C.debug("Changing text",e,z),z.removeClass(k.filtered).removeClass(k.placeholder),w.preserveHTML?z.html(e):z.text(e)))},selectedLetter:function(t){var n=M.filter("."+k.selected),i=!1;M.each(function(){var n=e(this),o=C.get.choiceText(n,!1),a=String(o).charAt(0).toLowerCase(),r=t.toLowerCase();return a==r?(i=n,!1):void 0}),i&&(C.verbose("Scrolling to next value with letter",t),C.set.scrollPosition(i),n.removeClass(k.selected),i.addClass(k.selected))},direction:function(e){"auto"==w.direction?C.is.onScreen(e)?C.remove.upward(e):C.set.upward(e):"upward"==w.direction&&C.set.upward(e)},upward:function(e){var t=e||q;t.addClass(k.upward)},value:function(e,t,n){var i=N.length>0,o=(!C.has.value(e),C.get.values()),a="number"==typeof e?e.toString():e;if(i){if(a==o&&(C.verbose("Skipping value update already same value",e,o),!C.is.initialLoad()))return;C.debug("Updating input value",e,o),N.val(e).trigger("change")}else C.verbose("Storing value in metadata",e,N),e!==o&&q.data(T.value,e);w.fireOnInit===!1&&C.is.initialLoad()?C.verbose("No callback on initial load",w.onChange):w.onChange.call(B,e,t,n)},active:function(){q.addClass(k.active)},multiple:function(){q.addClass(k.multiple)},visible:function(){q.addClass(k.visible)},selected:function(t,n){var i=C.is.multiple();return(n=w.allowAdditions?n||C.get.itemWithAdditions(t):n||C.get.item(t))?(C.debug("Setting selected menu item to",n),C.is.single()?(C.remove.activeItem(),C.remove.selectedItem()):w.useLabels&&C.remove.selectedItem(),void n.each(function(){var t=e(this),o=C.get.choiceText(t),a=C.get.choiceValue(t,o),r=t.hasClass(k.filtered),s=t.hasClass(k.active),c=t.hasClass(k.addition),l=i&&1==n.length;i?!s||c?(w.apiSettings&&w.saveRemoteData&&C.save.remoteData(o,a),w.useLabels?(C.add.value(a,o,t),C.add.label(a,o,l),t.addClass(k.active),C.filterActive(),C.select.nextAvailable(n)):(C.add.value(a,o,t),C.set.text(C.add.variables(S.count)),t.addClass(k.active))):r||(C.debug("Selected active value, removing label"),C.remove.selected(a)):(w.apiSettings&&w.saveRemoteData&&C.save.remoteData(o,a),C.set.value(a,o,t),C.set.text(o),t.addClass(k.active).addClass(k.selected))})):!1}},add:{label:function(t,n,i){var o,a=C.is.searchSelection()?I:z;return o=e("").addClass(k.label).attr("data-value",t).html(F.label(t,n)),o=w.onLabelCreate.call(o,t,n),C.has.label(t)?void C.debug("Label already exists, skipping",t):(w.label.variation&&o.addClass(w.label.variation),void(i===!0?(C.debug("Animating in label",o),o.addClass(k.hidden).insertBefore(a).transition(w.label.transition,w.label.duration)):(C.debug("Adding selection label",o),o.insertBefore(a))))},message:function(t){var n=V.children(P.message),i=w.templates.message(C.add.variables(t));n.length>0?n.html(i):n=e("
").html(i).addClass(k.message).appendTo(V)},optionValue:function(t){var n=N.find('option[value="'+t+'"]'),i=n.length>0;i||(y&&(y.disconnect(),C.verbose("Temporarily disconnecting mutation observer",t)),e("
").addClass("ui red pointing prompt label").html(t[0])}},rules:{checked:function(){return e(this).filter(":checked").length>0},contains:function(t,n){return n=n.replace(e.fn.form.settings.regExp.escape,"\\$&"),-1!==t.search(new RegExp(n,"i"))},containsExactly:function(t,n){return n=n.replace(e.fn.form.settings.regExp.escape,"\\$&"),-1!==t.search(new RegExp(n))},email:function(t){var n=new RegExp(e.fn.form.settings.regExp.email,"i");return n.test(t)},empty:function(t){return!(t===i||""===t||e.isArray(t)&&0===t.length)},integer:function(t,n){var o,a,r,s=e.fn.form.settings.regExp.integer;return n===i||""===n||".."===n||(-1==n.indexOf("..")?s.test(n)&&(o=a=n-0):(r=n.split("..",2),s.test(r[0])&&(o=r[0]-0),s.test(r[1])&&(a=r[1]-0))),s.test(t)&&(o===i||t>=o)&&(a===i||a>=t)},is:function(e,t){return t="string"==typeof t?t.toLowerCase():t,e="string"==typeof e?e.toLowerCase():e,e==t},isExactly:function(e,t){return e==t},length:function(e,t){return e!==i?e.length>=t:!1},different:function(t,n){{var o;e(this)}return e('[data-validate="'+n+'"]').length>0?o=e('[data-validate="'+n+'"]').val():e("#"+n).length>0?o=e("#"+n).val():e('[name="'+n+'"]').length>0?o=e('[name="'+n+'"]').val():e('[name="'+n+'[]"]').length>0&&(o=e('[name="'+n+'[]"]')),o!==i?t.toString()!==o.toString():!1},match:function(t,n){{var o;e(this)}return e('[data-validate="'+n+'"]').length>0?o=e('[data-validate="'+n+'"]').val():e("#"+n).length>0?o=e("#"+n).val():e('[name="'+n+'"]').length>0?o=e('[name="'+n+'"]').val():e('[name="'+n+'[]"]').length>0&&(o=e('[name="'+n+'[]"]')),o!==i?t.toString()==o.toString():!1},maxCount:function(t,n){return t=t.split(","),e.isArray(t)&&t.length<=n},exactCount:function(t,n){return t=t.split(","),e.isArray(t)&&t.length==n},minCount:function(t,n){return t=t.split(","),e.isArray(t)&&t.length>=n},regExp:function(t,n){var i,o=n.match(e.fn.form.settings.regExp.flags);return o&&(n=o.length>=2?o[1]:n,i=o.length>=3?o[2]:""),t.match(new RegExp(n,i))},maxLength:function(e,t){return e!==i?e.length<=t:!1},not:function(e,t){return e="string"==typeof e?e.toLowerCase():e,t="string"==typeof t?t.toLowerCase():t,e!=t},notExactly:function(e,t){return e!=t},url:function(t){return e.fn.form.settings.regExp.url.match(t)}}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.accordion=function(n){{var o,a=e(this),r=(new Date).getTime(),s=[],c=arguments[0],l="string"==typeof c,u=[].slice.call(arguments,1);t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)}}return a.each(function(){var d,m,f=e.isPlainObject(n)?e.extend(!0,{},e.fn.accordion.settings,n):e.extend({},e.fn.accordion.settings),g=f.className,p=f.namespace,v=f.selector,h=f.error,b="."+p,y="module-"+p,x=a.selector||"",C=e(this),w=C.find(v.title),k=C.find(v.content),S=this,T=C.data(y);m={initialize:function(){m.debug("Initializing",C),m.bind.events(),m.observeChanges(),m.instantiate()},instantiate:function(){T=m,C.data(y,m)},destroy:function(){m.debug("Destroying previous instance",C),C.off(b).removeData(y)},refresh:function(){w=C.find(v.title),k=C.find(v.content)},observeChanges:function(){"MutationObserver"in t&&(d=new MutationObserver(function(e){m.debug("DOM tree modified, updating selector cache"),m.refresh()}),d.observe(S,{childList:!0,subtree:!0}),m.debug("Setting up mutation observer",d))},bind:{events:function(){m.debug("Binding delegated events"),C.on(f.on+b,v.trigger,m.event.click)}},event:{click:function(){m.toggle.call(this)}},toggle:function(t){var n=t!==i?"number"==typeof t?w.eq(t):e(t).closest(v.title):e(this).closest(v.title),o=n.next(k),a=o.hasClass(g.animating),r=o.hasClass(g.active),s=r&&!a,c=!r&&a;m.debug("Toggling visibility of content",n),s||c?f.collapsible?m.close.call(n):m.debug("Cannot close accordion content collapsing is disabled"):m.open.call(n)},open:function(t){var n=t!==i?"number"==typeof t?w.eq(t):e(t).closest(v.title):e(this).closest(v.title),o=n.next(k),a=o.hasClass(g.animating),r=o.hasClass(g.active),s=r||a;return s?void m.debug("Accordion already open, skipping",o):(m.debug("Opening accordion content",n),f.onOpening.call(o),f.exclusive&&m.closeOthers.call(n),n.addClass(g.active),o.stop(!0,!0).addClass(g.animating),f.animateChildren&&(e.fn.transition!==i&&C.transition("is supported")?o.children().transition({animation:"fade in",queue:!1,useFailSafe:!0,debug:f.debug,verbose:f.verbose,duration:f.duration}):o.children().stop(!0,!0).animate({opacity:1},f.duration,m.resetOpacity)),void o.slideDown(f.duration,f.easing,function(){o.removeClass(g.animating).addClass(g.active),m.reset.display.call(this),f.onOpen.call(this),f.onChange.call(this)}))},close:function(t){var n=t!==i?"number"==typeof t?w.eq(t):e(t).closest(v.title):e(this).closest(v.title),o=n.next(k),a=o.hasClass(g.animating),r=o.hasClass(g.active),s=!r&&a,c=r&&a;!r&&!s||c||(m.debug("Closing accordion content",o),f.onClosing.call(o),n.removeClass(g.active),o.stop(!0,!0).addClass(g.animating),f.animateChildren&&(e.fn.transition!==i&&C.transition("is supported")?o.children().transition({animation:"fade out",queue:!1,useFailSafe:!0,debug:f.debug,verbose:f.verbose,duration:f.duration}):o.children().stop(!0,!0).animate({opacity:0},f.duration,m.resetOpacity)),o.slideUp(f.duration,f.easing,function(){o.removeClass(g.animating).removeClass(g.active),m.reset.display.call(this),f.onClose.call(this),f.onChange.call(this)}))},closeOthers:function(t){var n,o,a,r=t!==i?w.eq(t):e(this).closest(v.title),s=r.parents(v.content).prev(v.title),c=r.closest(v.accordion),l=v.title+"."+g.active+":visible",u=v.content+"."+g.active+":visible";f.closeNested?(n=c.find(l).not(s),a=n.next(k)):(n=c.find(l).not(s),o=c.find(u).find(l).not(s),n=n.not(o),a=n.next(k)),n.length>0&&(m.debug("Exclusive enabled, closing other content",n),n.removeClass(g.active),a.removeClass(g.animating).stop(!0,!0),f.animateChildren&&(e.fn.transition!==i&&C.transition("is supported")?a.children().transition({animation:"fade out",useFailSafe:!0,debug:f.debug,verbose:f.verbose,duration:f.duration}):a.children().stop(!0,!0).animate({opacity:0},f.duration,m.resetOpacity)),a.slideUp(f.duration,f.easing,function(){e(this).removeClass(g.active),m.reset.display.call(this)}))},reset:{display:function(){m.verbose("Removing inline display from element",this),e(this).css("display",""),""===e(this).attr("style")&&e(this).attr("style","").removeAttr("style")},opacity:function(){m.verbose("Removing inline opacity from element",this),e(this).css("opacity",""),""===e(this).attr("style")&&e(this).attr("style","").removeAttr("style")}},setting:function(t,n){if(m.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,f,t);else{if(n===i)return f[t];f[t]=n}},internal:function(t,n){return m.debug("Changing internal",t,n),n===i?m[t]:void(e.isPlainObject(t)?e.extend(!0,m,t):m[t]=n)},debug:function(){f.debug&&(f.performance?m.performance.log(arguments):(m.debug=Function.prototype.bind.call(console.info,console,f.name+":"),m.debug.apply(console,arguments)))},verbose:function(){f.verbose&&f.debug&&(f.performance?m.performance.log(arguments):(m.verbose=Function.prototype.bind.call(console.info,console,f.name+":"),m.verbose.apply(console,arguments)))},error:function(){m.error=Function.prototype.bind.call(console.error,console,f.name+":"),m.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;f.performance&&(t=(new Date).getTime(),i=r||t,n=t-i,r=t,s.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:S,"Execution Time":n})),clearTimeout(m.performance.timer),m.performance.timer=setTimeout(m.performance.display,500)},display:function(){var t=f.name+":",n=0;r=!1,clearTimeout(m.performance.timer),e.each(s,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",x&&(t+=" '"+x+"'"),(console.group!==i||console.table!==i)&&s.length>0&&(console.groupCollapsed(t),console.table?console.table(s):e.each(s,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),s=[]}},invoke:function(t,n,a){var r,s,c,l=T;return n=n||u,a=S||a,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):(m.error(h.method,t),!1);l=l[o]}})),e.isFunction(s)?c=s.apply(a,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},l?(T===i&&m.initialize(),m.invoke(c)):(T!==i&&T.invoke("destroy"),m.initialize())}),o!==i?o:this},e.fn.accordion.settings={name:"Accordion",namespace:"accordion",debug:!1,verbose:!1,performance:!0,on:"click",exclusive:!0,collapsible:!0,closeNested:!1,animateChildren:!0,duration:350,easing:"easeOutQuad",onOpening:function(){},onOpen:function(){},onClosing:function(){},onClose:function(){},onChange:function(){},error:{method:"The method you called is not defined"},className:{active:"active",animating:"animating"},selector:{accordion:".accordion",title:".title",trigger:".title",content:".content"}},e.extend(e.easing,{easeOutQuad:function(e,t,n,i,o){return-i*(t/=o)*(t-2)+n}})}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.checkbox=function(n){var o,a=e(this),r=a.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1);return a.each(function(){var a,m,f=e.extend(!0,{},e.fn.checkbox.settings,n),g=f.className,p=f.namespace,v=f.selector,h=f.error,b="."+p,y="module-"+p,x=e(this),C=e(this).children(v.label),w=e(this).children(v.input),k=x.data(y),S=this;m={initialize:function(){m.verbose("Initializing checkbox",f),m.create.label(),m.bind.events(),m.set.tabbable(),m.hide.input(),m.observeChanges(),m.instantiate(),m.setup()},instantiate:function(){m.verbose("Storing instance of module",m),k=m,x.data(y,m)},destroy:function(){m.verbose("Destroying module"),m.unbind.events(),m.show.input(),x.removeData(y)},fix:{reference:function(){x.is(v.input)&&(m.debug("Behavior called on adjusting invoked element"),x=x.closest(v.checkbox),m.refresh())}},setup:function(){m.is.indeterminate()?(m.debug("Initial value is indeterminate"),m.set.indeterminate(),f.fireOnInit&&(f.onIndeterminate.call(w[0]),f.onChange.call(w[0]))):m.is.checked()?(m.debug("Initial value is checked"),m.set.checked(),f.fireOnInit&&(f.onChecked.call(w[0]),f.onChange.call(w[0]))):(m.debug("Initial value is unchecked"),m.set.unchecked(),f.fireOnInit&&(f.onUnchecked.call(w[0]),f.onChange.call(w[0])))},refresh:function(){C=x.children(v.label),w=x.children(v.input)},hide:{input:function(){m.verbose("Modfying z-index to be unselectable"),w.addClass(g.hidden)}},show:{input:function(){m.verbose("Modfying z-index to be selectable"),w.removeClass(g.hidden)}},observeChanges:function(){"MutationObserver"in t&&(a=new MutationObserver(function(e){m.debug("DOM tree modified, updating selector cache"),m.refresh()}),a.observe(S,{childList:!0,subtree:!0}),m.debug("Setting up mutation observer",a))},attachEvents:function(t,n){var i=e(t);n=e.isFunction(m[n])?m[n]:m.toggle,i.length>0?(m.debug("Attaching checkbox events to element",t,n),i.on("click"+b,n)):m.error(h.notFound)},event:{click:function(t){return e(t.target).is(v.input)?void m.verbose("Using default check action on initialized checkbox"):void m.toggle()},keydown:function(e){var t=e.which,n={enter:13,space:32,escape:27};t==n.escape&&(m.verbose("Escape key pressed blurring field"),w.blur(),e.preventDefault()),e.ctrlKey||t!=n.enter&&t!=n.space||(m.verbose("Enter key pressed, toggling checkbox"),m.toggle(),e.preventDefault())}},check:function(){return!m.is.indeterminate()&&m.is.checked()?void m.debug("Checkbox is already checked"):(m.debug("Checking checkbox",w),m.set.checked(),f.onChecked.call(w[0]),void f.onChange.call(w[0]))},uncheck:function(){return!m.is.indeterminate()&&m.is.unchecked()?void m.debug("Checkbox is already unchecked"):(m.debug("Unchecking checkbox"),m.set.unchecked(),f.onUnchecked.call(w[0]),void f.onChange.call(w[0]))},indeterminate:function(){return m.is.indeterminate()?void m.debug("Checkbox is already indeterminate"):(m.debug("Making checkbox indeterminate"),m.set.indeterminate(),f.onIndeterminate.call(w[0]),void f.onChange.call(w[0]))},determinate:function(){return m.is.determinate()?void m.debug("Checkbox is already determinate"):(m.debug("Making checkbox determinate"),m.set.determinate(),f.onDeterminate.call(w[0]),void f.onChange.call(w[0]))},enable:function(){return m.is.enabled()?void m.debug("Checkbox is already enabled"):(m.debug("Enabling checkbox"),m.set.enabled(),void f.onEnable.call(w[0]))},disable:function(){return m.is.disabled()?void m.debug("Checkbox is already disabled"):(m.debug("Disabling checkbox"),m.set.disabled(),void f.onDisable.call(w[0]))},get:{radios:function(){var t=m.get.name();return e('input[name="'+t+'"]').closest(v.checkbox)},name:function(){return w.attr("name")}},is:{radio:function(){return w.hasClass(g.radio)||"radio"==w.attr("type")},indeterminate:function(){return w.prop("indeterminate")!==i&&w.prop("indeterminate")},checked:function(){return w.prop("checked")!==i&&w.prop("checked")},disabled:function(){return w.prop("disabled")!==i&&w.prop("disabled")},enabled:function(){return!m.is.disabled()},determinate:function(){return!m.is.indeterminate()},unchecked:function(){return!m.is.checked()}},can:{change:function(){return!(x.hasClass(g.disabled)||x.hasClass(g.readOnly)||w.prop("disabled")||w.prop("readonly"))},uncheck:function(){return"boolean"==typeof f.uncheckable?f.uncheckable:!m.is.radio()}},set:{checked:function(){return!m.is.indeterminate()&&m.is.checked()?void m.debug("Input is already checked"):(m.verbose("Setting state to checked",w[0]),m.is.radio()&&m.uncheckOthers(),w.prop("indeterminate",!1).prop("checked",!0), +x.removeClass(g.indeterminate).addClass(g.checked),void m.trigger.change())},unchecked:function(){return!m.is.indeterminate()&&m.is.unchecked()?void m.debug("Input is already unchecked"):(m.debug("Setting state to unchecked"),w.prop("indeterminate",!1).prop("checked",!1),x.removeClass(g.indeterminate).removeClass(g.checked),void m.trigger.change())},indeterminate:function(){return m.is.indeterminate()?void m.debug("Input is already indeterminate"):(m.debug("Setting state to indeterminate"),w.prop("indeterminate",!0),x.addClass(g.indeterminate),void m.trigger.change())},determinate:function(){return m.is.determinate()?void m.debug("Input is already determinate"):(m.debug("Setting state to determinate"),w.prop("indeterminate",!1),void x.removeClass(g.indeterminate))},disabled:function(){return m.is.disabled()?void m.debug("Input is already disabled"):(m.debug("Setting state to disabled"),w.prop("disabled","disabled"),x.addClass(g.disabled),void m.trigger.change())},enabled:function(){return m.is.enabled()?void m.debug("Input is already enabled"):(m.debug("Setting state to enabled"),w.prop("disabled",!1),x.removeClass(g.disabled),void m.trigger.change())},tabbable:function(){m.verbose("Adding tabindex to checkbox"),w.attr("tabindex")===i&&w.attr("tabindex",0)}},trigger:{change:function(){m.verbose("Triggering change event from programmatic change"),w.trigger("change")}},create:{label:function(){w.prevAll(v.label).length>0?(w.prev(v.label).detach().insertAfter(w),m.debug("Moving existing label",C)):m.has.label()||(C=e("
").attr("class","ui dimmer")}}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.dropdown=function(o){var a,r=e(this),s=e(n),c=r.selector||"",l="ontouchstart"in n.documentElement,u=(new Date).getTime(),d=[],m=arguments[0],f="string"==typeof m,g=[].slice.call(arguments,1);return r.each(function(p){var v,h,b,y,x,C,w,k=e.isPlainObject(o)?e.extend(!0,{},e.fn.dropdown.settings,o):e.extend({},e.fn.dropdown.settings),S=k.className,T=k.message,A=k.metadata,R=k.namespace,P=k.regExp,E=k.selector,O=k.error,F=k.templates,D="."+R,q="module-"+R,j=e(this),z=e(k.context),I=j.find(E.text),N=j.find(E.search),L=j.find(E.input),H=j.find(E.icon),V=j.prev().find(E.text).length>0?j.prev().find(E.text):j.prev(),M=j.children(E.menu),U=M.find(E.item),W=!1,B=!1,Q=this,X=j.data(q);w={initialize:function(){w.debug("Initializing dropdown",k),w.is.alreadySetup()?w.setup.reference():(w.setup.layout(),w.refreshData(),w.save.defaults(),w.restore.selected(),w.create.id(),l&&w.bind.touchEvents(),w.bind.mouseEvents(),w.bind.keyboardEvents(),w.observeChanges(),w.instantiate())},instantiate:function(){w.verbose("Storing instance of dropdown",w),X=w,j.data(q,w)},destroy:function(){w.verbose("Destroying previous dropdown",j),w.remove.tabbable(),j.off(D).removeData(q),M.off(D),s.off(b),x&&x.disconnect(),C&&C.disconnect()},observeChanges:function(){"MutationObserver"in t&&(x=new MutationObserver(function(e){w.debug("").addClass(S.search).insertBefore(I)),k.allowTab&&w.set.tabbable(),0===M.length&&(M=e("
").addClass(S.menu).appendTo(j))},select:function(){var t=w.get.selectValues();w.debug("Dropdown initialized on a select",t),j.is("select")&&(L=j),L.parent(E.dropdown).length>0?(w.debug("UI dropdown already exists. Creating dropdown menu only"),j=L.closest(E.dropdown),M=j.children(E.menu),w.setup.menu(t)):(w.debug("Creating entire dropdown from select"),j=e("
").attr("class",L.attr("class")).addClass(S.selection).addClass(S.dropdown).html(F.dropdown(t)).insertBefore(L),L.removeAttr("class").detach().prependTo(j),console.log(j)),L.is("[multiple]")&&w.set.multiple(),w.refresh()},menu:function(e){M.html(F.menu(e)),U=M.find(E.item)},reference:function(){w.debug("Dropdown behavior was called on select, replacing with closest dropdown"),j=j.parent(E.dropdown),w.refresh(),w.setup.returnedObject(),f&&(X=w,w.invoke(m))},returnedObject:function(){var e=r.slice(0,p),t=r.slice(p+1);r=e.add(j).add(t)}},refresh:function(){w.refreshSelectors(),w.refreshData()},refreshSelectors:function(){w.verbose("Refreshing selector cache"),I=j.find(E.text),N=j.find(E.search),L=j.find(E.input),H=j.find(E.icon),V=j.prev().find(E.text).length>0?j.prev().find(E.text):j.prev(),M=j.children(E.menu),U=M.find(E.item)},refreshData:function(){w.verbose("Refreshing cached metadata"),U.removeData(A.text).removeData(A.value),j.removeData(A.defaultText).removeData(A.defaultValue).removeData(A.placeholderText)},toggle:function(){w.verbose("Toggling menu visibility"),w.is.active()?w.hide():w.show()},show:function(t){if(t=e.isFunction(t)?t:function(){},w.can.show()&&!w.is.active()){if(w.debug("Showing dropdown"),w.is.multiple()&&!w.has.search()&&w.is.allFiltered())return!0;w.animate.show(function(){w.can.click()&&w.bind.intent(),w.set.visible(),t.call(Q)}),k.onShow.call(Q)}},hide:function(t){t=e.isFunction(t)?t:function(){},w.is.active()&&(w.debug("Hiding dropdown"),w.animate.hide(function(){w.remove.visible(),t.call(Q)}),k.onHide.call(Q))},hideOthers:function(){w.verbose("Finding other dropdowns to hide"),r.not(j).has(E.menu+"."+S.visible).dropdown("hide")},hideMenu:function(){w.verbose("Hiding menu instantaneously"),w.remove.active(),w.remove.visible(),M.transition("hide")},hideSubMenus:function(){var e=M.children(E.item).find(E.menu);w.verbose("Hiding sub menus",e),e.transition("hide")},bind:{keyboardEvents:function(){w.debug("Binding keyboard events"),j.on("keydown"+D,w.event.keydown),w.has.search()&&j.on(w.get.inputEvent()+D,E.search,w.event.input),w.is.multiple()&&s.on("keydown"+b,w.event.document.keydown)},touchEvents:function(){w.debug("Touch device detected binding additional touch events"),w.is.searchSelection()||j.on("touchstart"+D,w.event.test.toggle),M.on("touchstart"+D,E.item,w.event.item.mouseenter)},mouseEvents:function(){w.debug("Mouse detected binding mouse events"),w.is.multiple()&&j.on("click"+D,E.label,w.event.label.click).on("click"+D,E.remove,w.event.remove.click),w.is.searchSelection()?(j.on("mousedown"+D,E.menu,w.event.menu.mousedown).on("mouseup"+D,E.menu,w.event.menu.mouseup).on("click"+D,E.search,w.show).on("focus"+D,E.search,w.event.search.focus).on("blur"+D,E.search,w.event.search.blur).on("click"+D,E.text,w.event.text.focus),w.is.multiple()&&j.on("click"+D,w.event.click)):("click"==k.on?j.on("click"+D,w.event.test.toggle):"hover"==k.on?j.on("mouseenter"+D,w.delay.show).on("mouseleave"+D,w.delay.hide):j.on(k.on+D,w.toggle),j.on("mousedown"+D,w.event.mousedown).on("mouseup"+D,w.event.mouseup).on("focus"+D,w.event.focus).on("blur"+D,w.event.blur)),M.on("mouseenter"+D,E.item,w.event.item.mouseenter).on("mouseleave"+D,E.item,w.event.item.mouseleave).on("click"+D,E.item,w.event.item.click)},intent:function(){w.verbose("Binding hide intent event to document"),l&&s.on("touchstart"+b,w.event.test.touch).on("touchmove"+b,w.event.test.touch),s.on("click"+b,w.event.test.hide)}},unbind:{intent:function(){w.verbose("Removing hide intent event from document"),l&&s.off("touchstart"+b).off("touchmove"+b),s.off("click"+b)}},filter:function(e){var t=e!==i?e:w.get.query(),n=function(){w.is.multiple()&&w.filterActive(),w.select.firstUnfiltered(),w.has.allResultsFiltered()?k.onNoResults.call(Q,t)?k.allowAdditions||(w.verbose("All items filtered, showing message",t),w.add.message(T.noResults)):(w.verbose("All items filtered, hiding dropdown",t),w.hideMenu()):w.remove.message(),k.allowAdditions&&w.add.userSuggestion(e),w.is.searchSelection()&&w.can.show()&&w.is.focusedOnSearch()&&w.show()};w.has.maxSelections()||(k.apiSettings?w.can.useAPI()?w.queryRemote(t,function(){n()}):w.error(O.noAPI):(w.filterItems(t),n()))},queryRemote:function(t,n){var i={errorDuration:!1,throttle:k.throttle,cache:"local",urlData:{query:t},onError:function(){w.add.message(T.serverError),n()},onFailure:function(){w.add.message(T.serverError),n()},onSuccess:function(e){w.remove.message(),w.setup.menu({values:e.results}),n()}};j.api("get request")||w.setup.api(),i=e.extend(!0,{},i,k.apiSettings),j.api("setting",i).api("query")},filterItems:function(t){var n=t!==i?t:w.get.query(),o=e(),a=w.escape.regExp(n),r=new RegExp("^"+a,"igm");""===n?o=U:(w.verbose("Searching for matching values",n),U.each(function(){var t,i,a=e(this);if("both"==k.match||"text"==k.match){if(t=String(w.get.choiceText(a,!1)),-1!==t.search(r))return o=o.add(a),!0;if(k.fullTextSearch&&w.fuzzySearch(n,t))return o=o.add(a),!0}if("both"==k.match||"value"==k.match){if(i=String(w.get.choiceValue(a,t)),-1!==i.search(r))return o=o.add(a),!0;if(k.fullTextSearch&&w.fuzzySearch(n,i))return o=o.add(a),!0}})),w.debug("Showing only matched items",n),w.remove.filteredItem(),U.not(o).addClass(S.filtered)},fuzzySearch:function(e,t){var n=t.length,i=e.length;if(e=e.toLowerCase(),t=t.toLowerCase(),i>n)return!1;if(i===n)return e===t;e:for(var o=0,a=0;i>o;o++){for(var r=e.charCodeAt(o);n>a;)if(t.charCodeAt(a++)===r)continue e;return!1}return!0},filterActive:function(){k.useLabels&&U.filter("."+S.active).addClass(S.filtered)},focusSearch:function(){w.is.search()&&!w.is.focusedOnSearch()&&N[0].focus()},forceSelection:function(){var e=U.not(S.filtered).filter("."+S.selected).eq(0),t=U.not(S.filtered).filter("."+S.active).eq(0),n=e.length>0?e:t,i=n.size()>0;i?(w.debug("Forcing partial selection to selected item",n),w.event.item.click.call(n)):w.hide()},event:{focus:function(){k.showOnFocus&&!W&&w.is.hidden()&&!h&&w.show()},click:function(t){var n=e(t.target);!n.is(j)&&!n.is(H)||w.is.focusedOnSearch()||w.focusSearch()},blur:function(e){h=n.activeElement===this,W||h||(w.remove.activeLabel(),w.hide())},mousedown:function(){W=!0},mouseup:function(){W=!1},search:{focus:function(){W=!0,w.is.multiple()&&w.remove.activeLabel(),k.showOnFocus&&w.show()},blur:function(e){h=n.activeElement===this,B||h||(w.is.multiple()?(w.remove.activeLabel(),w.hide()):k.forceSelection?w.forceSelection():w.hide())}},text:{focus:function(e){W=!0,w.focusSearch()}},input:function(e){(w.is.multiple()||w.is.searchSelection())&&w.set.filtered(),clearTimeout(w.timer),w.timer=setTimeout(w.search,k.delay.search)},label:{click:function(t){var n=e(this),i=j.find(E.label),o=i.filter("."+S.active),a=n.nextAll("."+S.active),r=n.prevAll("."+S.active),s=a.length>0?n.nextUntil(a).add(o).add(n):n.prevUntil(r).add(o).add(n);t.shiftKey?(o.removeClass(S.active),s.addClass(S.active)):t.ctrlKey?n.toggleClass(S.active):(o.removeClass(S.active),n.addClass(S.active)),k.onLabelSelect.apply(this,i.filter("."+S.active))}},remove:{click:function(){var t=e(this).parent();t.hasClass(S.active)?w.remove.activeLabels():w.remove.activeLabels(t)}},test:{toggle:function(e){var t=w.is.multiple()?w.show:w.toggle;w.determine.eventOnElement(e,t)&&e.preventDefault()},touch:function(e){w.determine.eventOnElement(e,function(){"touchstart"==e.type?w.timer=setTimeout(w.hide,k.delay.touch):"touchmove"==e.type&&clearTimeout(w.timer)}),e.stopPropagation()},hide:function(e){w.determine.eventInModule(e,w.hide)}},menu:{mousedown:function(){B=!0},mouseup:function(){B=!1}},item:{mouseenter:function(t){var n=e(this).children(E.menu),i=e(this).siblings(E.item).children(E.menu);n.length>0&&(clearTimeout(w.itemTimer),w.itemTimer=setTimeout(function(){w.verbose("Showing sub-menu",n),e.each(i,function(){w.animate.hide(!1,e(this))}),w.animate.show(!1,n)},k.delay.show),t.preventDefault())},mouseleave:function(t){var n=e(this).children(E.menu);n.length>0&&(clearTimeout(w.itemTimer),w.itemTimer=setTimeout(function(){w.verbose("Hiding sub-menu",n),w.animate.hide(!1,n)},k.delay.hide))},click:function(t){var n=e(this),i=e(t?t.target:""),o=n.find(E.menu),a=w.get.choiceText(n),r=w.get.choiceValue(n,a),s=o.length>0,c=o.find(i).length>0;c||s&&!k.allowCategorySelection||(k.useLabels||w.remove.searchTerm(),w.determine.selectAction.call(this,a,r))}},document:{keydown:function(e){var t=e.which,n=w.get.shortcutKeys(),i=w.is.inObject(t,n);if(i){var o=j.find(E.label),a=o.filter("."+S.active),r=(a.data("value"),o.index(a)),s=o.length,c=a.length>0,l=a.length>1,u=0===r,d=r+1==s,m=w.is.searchSelection(),f=w.is.focusedOnSearch(),g=w.is.focused(),p=f&&0===w.get.caretPosition();if(m&&!c&&!f)return;t==n.leftArrow?!g&&!p||c?c&&(e.shiftKey?w.verbose("Adding previous label to selection"):(w.verbose("Selecting previous label"),o.removeClass(S.active)),u&&!l?a.addClass(S.active):a.prev(E.siblingLabel).addClass(S.active).end(),e.preventDefault()):(w.verbose("Selecting previous label"),o.last().addClass(S.active)):t==n.rightArrow?(g&&!c&&o.first().addClass(S.active),c&&(e.shiftKey?w.verbose("Adding next label to selection"):(w.verbose("Selecting next label"),o.removeClass(S.active)),d?m?f?o.removeClass(S.active):w.focusSearch():l?a.next(E.siblingLabel).addClass(S.active):a.addClass(S.active):a.next(E.siblingLabel).addClass(S.active),e.preventDefault())):t==n.deleteKey||t==n.backspace?c?(w.verbose("Removing active labels"),d&&m&&!f&&w.focusSearch(),a.last().next(E.siblingLabel).addClass(S.active),w.remove.activeLabels(a),e.preventDefault()):p&&!c&&t==n.backspace&&(w.verbose("Removing last label on input backspace"),a=o.last().addClass(S.active),w.remove.activeLabels(a)):a.removeClass(S.active)}}},keydown:function(e){var t=e.which,n=w.get.shortcutKeys(),i=w.is.inObject(t,n);if(i){var o,a,r=U.not(E.unselectable).filter("."+S.selected).eq(0),s=M.children("."+S.active).eq(0),c=r.length>0?r:s,l=c.length>0?c.siblings(":not(."+S.filtered+")").andSelf():M.children(":not(."+S.filtered+")"),u=c.children(E.menu),d=c.closest(E.menu),m=d.hasClass(S.visible)||d.hasClass(S.animating)||d.parent(E.menu).length>0,f=u.length>0,g=c.length>0,p=c.not(E.unselectable).length>0;if(w.is.visible()){if((t==n.enter||t==n.delimiter)&&(t==n.enter&&g&&f&&!k.allowCategorySelection?(w.verbose("Pressed enter on unselectable category, opening sub menu"),t=n.rightArrow):p&&(w.verbose("Selecting item from keyboard shortcut",c),w.event.item.click.call(c,e),k.useLabels&&w.is.searchSelection()?w.hideAndClear():w.remove.searchTerm()),e.preventDefault()),t==n.leftArrow&&(a=d[0]!==M[0],a&&(w.verbose("Left key pressed, closing sub-menu"),w.animate.hide(!1,d),c.removeClass(S.selected),d.closest(E.item).addClass(S.selected),e.preventDefault())),t==n.rightArrow&&f&&(w.verbose("Right key pressed, opening sub-menu"),w.animate.show(!1,u),c.removeClass(S.selected),u.find(E.item).eq(0).addClass(S.selected),e.preventDefault()),t==n.upArrow){if(o=g&&m?c.prevAll(E.item+":not("+E.unselectable+")").eq(0):U.eq(0),l.index(o)<0)return w.verbose("Up key pressed but reached top of current menu"),void e.preventDefault();w.verbose("Up key pressed, changing active item"),c.removeClass(S.selected),o.addClass(S.selected),w.set.scrollPosition(o),e.preventDefault()}if(t==n.downArrow){if(o=g&&m?o=c.nextAll(E.item+":not("+E.unselectable+")").eq(0):U.eq(0),0===o.length)return w.verbose("Down key pressed but reached bottom of current menu"),void e.preventDefault();w.verbose("Down key pressed, changing active item"),U.removeClass(S.selected),o.addClass(S.selected),w.set.scrollPosition(o),e.preventDefault()}t==n.pageUp&&(w.scrollPage("up"),e.preventDefault()),t==n.pageDown&&(w.scrollPage("down"),e.preventDefault()),t==n.escape&&(w.verbose("Escape key pressed, closing dropdown"),w.hide())}else t==n.delimiter&&e.preventDefault(),t==n.downArrow&&(w.verbose("Down key pressed, showing dropdown"),w.show(),e.preventDefault())}else w.is.selection()&&!w.is.search()&&w.set.selectedLetter(String.fromCharCode(t))}},determine:{selectAction:function(t,n){w.verbose("Determining action",k.action),e.isFunction(w.action[k.action])?(w.verbose("Triggering preset action",k.action,t,n),w.action[k.action].call(this,t,n)):e.isFunction(k.action)?(w.verbose("Triggering user action",k.action,t,n),k.action.call(this,t,n)):w.error(O.action,k.action)},eventInModule:function(t,n){return n=e.isFunction(n)?n:function(){},0===e(t.target).closest(j).length?(w.verbose("Triggering event",n),n(),!0):(w.verbose("Event occurred in dropdown, canceling callback"),!1)},eventOnElement:function(t,n){var i=e(t.target);return n=e.isFunction(n)?n:function(){},0===i.closest(M).length?(w.verbose("Triggering event",n),n(),!0):(w.verbose("Event occurred in dropdown menu, canceling callback"),!1)}},action:{nothing:function(){},activate:function(t,n){n=n!==i?n:t,w.set.selected(n,e(this)),(!w.is.multiple()||w.is.allFiltered())&&w.hideAndClear()},select:function(e,t){w.action.activate.call(this)},combo:function(t,n){n=n!==i?n:t,w.set.selected(n,e(this)),w.hideAndClear()},hide:function(){w.hideAndClear()}},get:{id:function(){return y},text:function(){return I.text()},query:function(){return e.trim(N.val())},searchWidth:function(e){return e*k.glyphWidth+"em"},selectionCount:function(){var t=w.get.values();return w.is.multiple()?e.isArray(t)?t.length:0:""!==w.get.value()?1:0},transition:function(e){return"auto"==k.transition?w.is.upward(e)?"slide up":"slide down":k.transition},userValues:function(){var t=w.get.values();return t?(t=e.isArray(t)?t:[t],e.grep(t,function(e){return w.get.item(e)===!1})):!1},uniqueArray:function(t){return e.grep(t,function(n,i){return e.inArray(n,t)===i})},caretPosition:function(){var e,t,i=N.get(0);return"selectionStart"in i?i.selectionStart:n.selection?(i.focus(),e=n.selection.createRange(),t=e.text.length,e.moveStart("character",-i.value.length),e.text.length-t):void 0},shortcutKeys:function(){return{backspace:8,delimiter:188,deleteKey:46,enter:13,escape:27,pageUp:33,pageDown:34,leftArrow:37,upArrow:38,rightArrow:39,downArrow:40}},value:function(){return L.length>0?L.val():j.data(A.value)},values:function(){var e=w.get.value();return""===e?"":!L.is("select")&&w.is.multiple()?"string"==typeof e?e.split(k.delimiter):"":e},remoteValues:function(){var t=w.get.values(),n=!1;return t&&("string"==typeof t&&(t=[t]),n={},e.each(t,function(e,t){var i=w.read.remoteData(t);w.verbose("Restoring value from session data",i,t),n[t]=i?i:t})),n},choiceText:function(e,t){return t=t!==i?t:k.preserveHTML,e?(e.find(E.menu).length>0&&(w.verbose("Retreiving text of element with sub-menu"),e=e.clone(),e.find(E.menu).remove(),e.find(E.menuIcon).remove()),e.data(A.text)!==i?e.data(A.text):t?e.html().trim():e.text().trim()):void 0},choiceValue:function(e,t){return t=t||w.get.choiceText(e),e?e.data(A.value)!==i?e.data(A.value):"string"==typeof t?t.toLowerCase().trim():t:!1},inputEvent:function(){var e=N[0];return e?e.oninput!==i?"input":e.onpropertychange!==i?"propertychange":"keyup":!1},selectValues:function(){var t={};return t.values=[],j.find("option").each(function(){var n=e(this),o=n.html(),a=n.attr("disabled"),r=n.attr("value")!==i?n.attr("value"):o;"auto"===k.placeholder&&""===r?t.placeholder=o:t.values.push({name:o,value:r,disabled:a})}),k.placeholder&&"auto"!==k.placeholder&&(w.debug("Setting placeholder value to",k.placeholder),t.placeholder=k.placeholder),k.sortSelect?(t.values.sort(function(e,t){return e.name>t.name?1:-1}),w.debug("Retrieved and sorted values from select",t)):w.debug("Retreived values from select",t),t},activeItem:function(){return U.filter("."+S.active)},selectedItem:function(){var e=U.not(E.unselectable).filter("."+S.selected);return e.length>0?e:U.eq(0)},itemWithAdditions:function(e){var t=w.get.item(e),n=w.create.userChoice(e),i=n&&n.length>0;return i&&(t=t.length>0?t.add(n):n),t},item:function(t,n){var o,a,r=!1;return t=t!==i?t:w.get.values()!==i?w.get.values():w.get.text(),o=a?t.length>0:t!==i&&""!==t&&null!==t,a=w.is.multiple()&&e.isArray(t),n=""===t||0===t?!0:n||!1,o&&U.each(function(){var o=e(this),s=w.get.choiceText(o),c=w.get.choiceValue(o,s);if(null!==c&&c!==i)if(a)(-1!==e.inArray(c.toString(),t)||-1!==e.inArray(s,t))&&(r=r?r.add(o):o);else if(n){if(w.verbose("Ambiguous dropdown value using strict type check",o,t),c===t||s===t)return r=o,!0}else if(c.toString()==t.toString()||s==t)return w.verbose("Found select item by value",c,t), +r=o,!0}),r}},check:{maxSelections:function(e){return k.maxSelections?(e=e!==i?e:w.get.selectionCount(),e>=k.maxSelections?(w.debug("Maximum selection count reached"),U.addClass(S.filtered),w.add.message(T.maxSelections),!0):(w.verbose("No longer at maximum selection count"),w.remove.message(),w.remove.filteredItem(),w.is.searchSelection()&&w.filterItems(),!1)):!0}},restore:{defaults:function(){w.restore.defaultText(),w.restore.defaultValue()},defaultText:function(){var e=j.data(A.defaultText);w.debug("Restoring default text",e),w.set.text(e),I.addClass(S.placeholder)},defaultValue:function(){var e=j.data(A.defaultValue);e!==i&&(w.debug("Restoring default value",e),""!==e?(w.set.value(e),w.set.selected()):(w.remove.activeItem(),w.remove.selectedItem()))},labels:function(){k.allowAdditions&&(k.useLabels||(w.error(O.labels),k.useLabels=!0),w.debug("Restoring selected values"),w.create.userLabels()),w.check.maxSelections()},selected:function(){w.restore.values(),w.is.multiple()?(w.debug("Restoring previously selected values and labels"),w.restore.labels()):w.debug("Restoring previously selected values")},values:function(){w.set.initialLoad(),k.apiSettings?k.saveRemoteData?w.restore.remoteValues():w.clearValue():w.set.selected(),w.remove.initialLoad()},remoteValues:function(){var t=w.get.remoteValues();w.debug("Recreating selected from session data",t),t&&(w.is.single()?e.each(t,function(e,t){w.set.text(t)}):e.each(t,function(e,t){w.add.label(e,t)}))}},read:{remoteData:function(e){var n;return t.Storage===i?void w.error(O.noStorage):(n=sessionStorage.getItem(e),n!==i?n:!1)}},save:{defaults:function(){w.save.defaultText(),w.save.placeholderText(),w.save.defaultValue()},defaultValue:function(){var e=w.get.value();w.verbose("Saving default value as",e),j.data(A.defaultValue,e)},defaultText:function(){var e=w.get.text();w.verbose("Saving default text as",e),j.data(A.defaultText,e)},placeholderText:function(){var e;I.hasClass(S.placeholder)&&(e=w.get.text(),w.verbose("Saving placeholder text as",e),j.data(A.placeholderText,e))},remoteData:function(e,n){return t.Storage===i?void w.error(O.noStorage):(w.verbose("Saving remote data to session storage",n,e),void sessionStorage.setItem(n,e))}},clear:function(){w.is.multiple()?w.remove.labels():(w.remove.activeItem(),w.remove.selectedItem()),w.set.placeholderText(),w.clearValue()},clearValue:function(){w.set.value("")},scrollPage:function(e,t){var n,i,o,t=t||w.get.selectedItem(),a=t.closest(E.menu),r=a.outerHeight(),s=a.scrollTop(),c=U.eq(0).outerHeight(),l=Math.floor(r/c),u=(a.prop("scrollHeight"),"up"==e?s-c*l:s+c*l),d=U.not(E.unselectable);o="up"==e?d.index(t)-l:d.index(t)+l,n="up"==e?o>=0:o0&&(w.debug("Scrolling page",e,i),t.removeClass(S.selected),i.addClass(S.selected),a.scrollTop(u))},set:{filtered:function(){var e=w.is.multiple(),t=w.is.searchSelection(),n=e&&t,i=t?w.get.query():"",o="string"==typeof i&&i.length>0,a=w.get.searchWidth(i.length),r=""!==i;e&&o&&(w.verbose("Adjusting input width",a,k.glyphWidth),N.css("width",a)),o||n&&r?(w.verbose("Hiding placeholder text"),I.addClass(S.filtered)):(!e||n&&!r)&&(w.verbose("Showing placeholder text"),I.removeClass(S.filtered))},loading:function(){j.addClass(S.loading)},placeholderText:function(e){e=e||j.data(A.placeholderText),e&&(w.debug("Restoring placeholder text"),w.set.text(e),I.addClass(S.placeholder))},tabbable:function(){w.has.search()?(w.debug("Added tabindex to searchable dropdown"),N.val("").attr("tabindex",0),M.attr("tabindex",-1)):(w.debug("Added tabindex to dropdown"),j.attr("tabindex")||(j.attr("tabindex",0),M.attr("tabindex",-1)))},initialLoad:function(){w.verbose("Setting initial load"),v=!0},scrollPosition:function(e,t){var n,o,a,r,s,c,l,u,d,m=5;e=e||w.get.selectedItem(),n=e.closest(E.menu),o=e&&e.length>0,t=t!==i?t:!1,e&&n.length>0&&o&&(r=e.position().top,n.addClass(S.loading),c=n.scrollTop(),s=n.offset().top,r=e.offset().top,a=c-s+r,t||(l=n.height(),d=a+m>c+l,u=c>a-m),w.debug("Scrolling to active item",a),(t||u||d)&&n.scrollTop(a),n.removeClass(S.loading))},text:function(e){"select"!==k.action&&("combo"==k.action?(w.debug("Changing combo button text",e,V),k.preserveHTML?V.html(e):V.text(e)):(w.debug("Changing text",e,I),I.removeClass(S.filtered).removeClass(S.placeholder),k.preserveHTML?I.html(e):I.text(e)))},selectedLetter:function(t){var n=U.filter("."+S.selected),i=!1;U.each(function(){var n=e(this),o=w.get.choiceText(n,!1),a=String(o).charAt(0).toLowerCase(),r=t.toLowerCase();return a==r?(i=n,!1):void 0}),i&&(w.verbose("Scrolling to next value with letter",t),w.set.scrollPosition(i),n.removeClass(S.selected),i.addClass(S.selected))},direction:function(e){"auto"==k.direction?w.is.onScreen(e)?w.remove.upward(e):w.set.upward(e):"upward"==k.direction&&w.set.upward(e)},upward:function(e){var t=e||j;t.addClass(S.upward)},value:function(e,t,n){var i=L.length>0,o=(!w.has.value(e),w.get.values()),a="number"==typeof e?e.toString():e;if(i){if(a==o&&(w.verbose("Skipping value update already same value",e,o),!w.is.initialLoad()))return;w.debug("Updating input value",e,o),L.val(e).trigger("change")}else w.verbose("Storing value in metadata",e,L),e!==o&&j.data(A.value,e);k.fireOnInit===!1&&w.is.initialLoad()?w.verbose("No callback on initial load",k.onChange):k.onChange.call(Q,e,t,n)},active:function(){j.addClass(S.active)},multiple:function(){j.addClass(S.multiple)},visible:function(){j.addClass(S.visible)},selected:function(t,n){var i=w.is.multiple();n=k.allowAdditions?n||w.get.itemWithAdditions(t):n||w.get.item(t),n&&(w.debug("Setting selected menu item to",n),w.is.single()?(w.remove.activeItem(),w.remove.selectedItem()):k.useLabels&&w.remove.selectedItem(),n.each(function(){var t=e(this),o=w.get.choiceText(t),a=w.get.choiceValue(t,o),r=t.hasClass(S.filtered),s=t.hasClass(S.active),c=t.hasClass(S.addition),l=i&&1==n.length;i?!s||c?(k.apiSettings&&k.saveRemoteData&&w.save.remoteData(o,a),k.useLabels?(w.add.value(a,o,t),w.add.label(a,o,l),t.addClass(S.active),w.filterActive(),w.select.nextAvailable(n)):(w.add.value(a,o,t),w.set.text(w.add.variables(T.count)),t.addClass(S.active))):r||(w.debug("Selected active value, removing label"),w.remove.selected(a)):(k.apiSettings&&k.saveRemoteData&&w.save.remoteData(o,a),w.set.value(a,o,t),w.set.text(o),t.addClass(S.active).addClass(S.selected))}))}},add:{label:function(t,n,i){var o,a=w.is.searchSelection()?N:I;return o=e("").addClass(S.label).attr("data-value",t).html(F.label(t,n)),o=k.onLabelCreate.call(o,t,n),w.has.label(t)?void w.debug("Label already exists, skipping",t):(k.label.variation&&o.addClass(k.label.variation),void(i===!0?(w.debug("Animating in label",o),o.addClass(S.hidden).insertBefore(a).transition(k.label.transition,k.label.duration)):(w.debug("Adding selection label",o),o.insertBefore(a))))},message:function(t){var n=M.children(E.message),i=k.templates.message(w.add.variables(t));n.length>0?n.html(i):n=e("
").html(i).addClass(S.message).appendTo(M)},optionValue:function(t){var n=L.find('option[value="'+t+'"]'),i=n.length>0;i||(x&&(x.disconnect(),w.verbose("Temporarily disconnecting mutation observer",t)),e("