/*! * jQuery UI Widget 1.8.21 * * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Widget */ (function(e,t){if(e.cleanData){var n=e.cleanData;e.cleanData=function(t){for(var r=0,i;(i=t[r])!=null;r++)try{e(i).triggerHandler("remove")}catch(s){}n(t)}}else{var r=e.fn.remove;e.fn.remove=function(t,n){return this.each(function(){return n||(!t||e.filter(t,[this]).length)&&e("*",this).add([this]).each(function(){try{e(this).triggerHandler("remove")}catch(t){}}),r.call(e(this),t,n)})}}e.widget=function(t,n,r){var i=t.split(".")[0],s;t=t.split(".")[1],s=i+"-"+t,r||(r=n,n=e.Widget),e.expr[":"][s]=function(n){return!!e.data(n,t)},e[i]=e[i]||{},e[i][t]=function(e,t){arguments.length&&this._createWidget(e,t)};var o=new n;o.options=e.extend(!0,{},o.options),e[i][t].prototype=e.extend(!0,o,{namespace:i,widgetName:t,widgetEventPrefix:e[i][t].prototype.widgetEventPrefix||t,widgetBaseClass:s},r),e.widget.bridge(t,e[i][t])},e.widget.bridge=function(n,r){e.fn[n]=function(i){var s=typeof i=="string",o=Array.prototype.slice.call(arguments,1),u=this;return i=!s&&o.length?e.extend.apply(null,[!0,i].concat(o)):i,s&&i.charAt(0)==="_"?u:(s?this.each(function(){var r=e.data(this,n),s=r&&e.isFunction(r[i])?r[i].apply(r,o):r;if(s!==r&&s!==t)return u=s,!1}):this.each(function(){var t=e.data(this,n);t?t.option(i||{})._init():e.data(this,n,new r(i,this))}),u)}},e.Widget=function(e,t){arguments.length&&this._createWidget(e,t)},e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:!1},_createWidget:function(t,n){e.data(n,this.widgetName,this),this.element=e(n),this.options=e.extend(!0,{},this.options,this._getCreateOptions(),t);var r=this;this.element.bind("remove."+this.widgetName,function(){r.destroy()}),this._create(),this._trigger("create"),this._init()},_getCreateOptions:function(){return e.metadata&&e.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName),this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled "+"ui-state-disabled")},widget:function(){return this.element},option:function(n,r){var i=n;if(arguments.length===0)return e.extend({},this.options);if(typeof n=="string"){if(r===t)return this.options[n];i={},i[n]=r}return this._setOptions(i),this},_setOptions:function(t){var n=this;return e.each(t,function(e,t){n._setOption(e,t)}),this},_setOption:function(e,t){return this.options[e]=t,e==="disabled"&&this.widget()[t?"addClass":"removeClass"](this.widgetBaseClass+"-disabled"+" "+"ui-state-disabled").attr("aria-disabled",t),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_trigger:function(t,n,r){var i,s,o=this.options[t];r=r||{},n=e.Event(n),n.type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),n.target=this.element[0],s=n.originalEvent;if(s)for(i in s)i in n||(n[i]=s[i]);return this.element.trigger(n,r),!(e.isFunction(o)&&o.call(this.element[0],n,r)===!1||n.isDefaultPrevented())}}})(jQuery); /*! * Marco Polo v1.8.0 * * A jQuery autocomplete plugin for the discerning developer. * * https://github.com/jstayton/jquery-marcopolo * * Copyright 2013 by Justin Stayton * Licensed MIT */ (function(e){"use strict";typeof define=="function"&&define.amd?define(["jquery"],e):e(jQuery)})(function(e,t){"use strict";var n={};e.widget("mp.marcoPolo",{options:{cache:!0,compare:!1,data:{},delay:250,formatData:null,formatError:function(){return"<em>Your search could not be completed at this time.</em>"},formatItem:function(e){return e.title||e.name},formatMinChars:function(e){return"<em>Your search must be at least <strong>"+e+"</strong> characters.</em>"},formatNoResults:function(e){return"<em>No results for <strong>"+e+"</strong>.</em>"},hideOnSelect:!0,highlight:!0,label:null,minChars:1,onBlur:null,onChange:null,onError:null,onFocus:null,onMinChars:null,onNoResults:null,onRequestBefore:null,onRequestAfter:null,onResults:null,onSelect:function(e){this.val(e.title||e.name)},param:"q",required:!1,selectable:"*",selected:null,submitOnEnter:!1,url:null},keys:{DOWN:40,END:35,ENTER:13,ESC:27,HOME:36,TAB:9,UP:38},_create:function(){var t=this,n;t.$input=n=t.element.addClass("mp_input"),t.inputName="mp_"+(n.attr("name")||e.now()),t.$list=e('<ol class="mp_list" />').attr({"aria-atomic":"true","aria-busy":"false","aria-live":"polite",id:t.inputName+"_list",role:"listbox"}).hide().insertAfter(t.$input),t.inputOriginals={"aria-activedescendant":n.attr("aria-activedescendant"),"aria-autocomplete":n.attr("aria-autocomplete"),"aria-expanded":n.attr("aria-expanded"),"aria-labelledby":n.attr("aria-labelledby"),"aria-owns":n.attr("aria-owns"),"aria-required":n.attr("aria-required"),autocomplete:n.attr("autocomplete"),role:n.attr("role")},n.attr({"aria-autocomplete":"list","aria-owns":t.$list.attr("id"),autocomplete:"off",role:"combobox"}),t.ajax=null,t.ajaxAborted=!1,t.documentMouseup=null,t.focusPseudo=!1,t.focusReal=!1,t.mousedown=!1,t.selectedData=null,t.selectedMouseup=!1,t.timer=null,t.value=t.$input.val(),t._bindInput()._bindList()._bindDocument(),t._initSelected()._initOptions()},_setOption:function(t,n){e.Widget.prototype._setOption.apply(this,arguments),this._initOptions(t,n)},_initOptions:function(n,r){var i=this,s=n===t,o={};return s?o=i.options:o[n]=r,e.each(o,function(t,n){switch(t){case"label":i.options.label=e(n).addClass("mp_label"),i.options.label.attr("id")?i.removeLabelId=!1:(i.removeLabelId=!0,i.options.label.attr("id",i.inputName+"_label")),i._toggleLabel(),i.$input.attr("aria-labelledby",i.options.label.attr("id"));break;case"required":i.$input.attr("aria-required",n);break;case"selected":s&&n&&i.select(n,null,!0);break;case"url":n||(i.options.url=i.$input.closest("form").attr("action"))}}),i},change:function(e,t){var n=this;if(e===n.value)return;e!==n.$input.val()&&n.$input.val(e),n.selectedData=null,n.value=e,n._trigger("change",[e]),t!==!0&&(n.focusPseudo?n._cancelPendingRequest()._hideAndEmptyList():n._toggleLabel())},search:function(e){var n=this.$input;e!==t&&n.val(e),n.focus()},select:function(e,t,n){var r=this,i=r.$input,s=r.options.hideOnSelect;s&&r._hideList();if(!e)return r.change("");r.selectedData=e,r._trigger("select",[e,t,!!n]),i.val()!==r.value&&(r.value=i.val(),r.focusPseudo||r._toggleLabel(),r._hideAndEmptyList())},_initSelected:function(){var e=this,t=e.$input,n=t.data("selected"),r=t.val();return n?e.select(n,null,!0):r&&e.select(r,null,!0),e},selected:function(){return this.selectedData},destroy:function(){var n=this,r=n.options,i=n.$input;n.$list.remove(),e.each(n.inputOriginals,function(e,n){n===t?i.removeAttr(e):i.attr(e,n)}),i.removeClass("mp_input"),r.label&&(r.label.removeClass("mp_label"),n.removeLabelId&&r.label.removeAttr("id")),e(document).unbind("mouseup.marcoPolo",n.documentMouseup),e.Widget.prototype.destroy.apply(n,arguments)},list:function(){return this.$list},_bindInput:function(){var t=this,n=t.$input,r=t.$list;return n.bind("focus.marcoPolo",function(){if(t.focusReal)return;t.focusPseudo=!0,t.focusReal=!0,t._toggleLabel(),t.selectedMouseup?t.selectedMouseup=!1:(t._trigger("focus"),t._request(n.val()))}).bind("keydown.marcoPolo",function(n){var i=e();switch(n.which){case t.keys.UP:n.preventDefault(),t._showList()._highlightPrev();break;case t.keys.DOWN:n.preventDefault(),t._showList()._highlightNext();break;case t.keys.HOME:n.preventDefault(),t._showList()._highlightFirst();break;case t.keys.END:n.preventDefault(),t._showList()._highlightLast();break;case t.keys.ENTER:if(!r.is(":visible")){t.options.submitOnEnter||n.preventDefault();return}i=t._highlighted(),i.length&&t.select(i.data("marcoPolo"),i),(!t.options.submitOnEnter||i.length)&&n.preventDefault();break;case t.keys.TAB:if(!r.is(":visible"))return;i=t._highlighted(),i.length&&t.select(i.data("marcoPolo"),i);break;case t.keys.ESC:t._cancelPendingRequest()._hideList()}}).bind("keyup.marcoPolo",function(){n.val()!==t.value&&t._request(n.val())}).bind("blur.marcoPolo",function(){t.focusReal=!1,setTimeout(function(){t.mousedown||t._dismiss()},1)}),t},_bindList:function(){var t=this;return t.$list.bind("mousedown.marcoPolo",function(){t.mousedown=!0}).delegate("li.mp_selectable","mouseover",function(){t._addHighlight(e(this))}).delegate("li.mp_selectable","mouseout",function(){t._removeHighlight(e(this))}).delegate("li.mp_selectable","mouseup",function(){var n=e(this);t.select(n.data("marcoPolo"),n),t.selectedMouseup=!0,t.$input.focus()}),t},_bindDocument:function(){var t=this;return e(document).bind("mouseup.marcoPolo",t.documentMouseup=function(){t.mousedown=!1,!t.focusReal&&t.$list.is(":visible")&&t._dismiss()}),t},_toggleLabel:function(){var e=this,t=e.options.label;return t&&t.length&&(e.focusPseudo||e.$input.val()?t.hide():t.show()),e},_firstSelectableItem:function(){return this.$list.children("li.mp_selectable:visible:first")},_lastSelectableItem:function(){return this.$list.children("li.mp_selectable:visible:last")},_highlighted:function(){return this.$list.children("li.mp_highlighted")},_removeHighlight:function(e){return e.removeClass("mp_highlighted").attr("aria-selected","false").removeAttr("id"),this.$input.removeAttr("aria-activedescendant"),this},_addHighlight:function(e){return this._removeHighlight(this._highlighted()),e.addClass("mp_highlighted").attr({"aria-selected":"true",id:this.inputName+"_highlighted"}),this.$input.attr("aria-activedescendant",e.attr("id")),this},_highlightFirst:function(){return this._addHighlight(this._firstSelectableItem()),this},_highlightLast:function(){return this._addHighlight(this._lastSelectableItem()),this},_highlightPrev:function(){var e=this._highlighted(),t=e.prevAll("li.mp_selectable:visible:first");return t.length||(t=this._lastSelectableItem()),this._addHighlight(t),this},_highlightNext:function(){var e=this._highlighted(),t=e.nextAll("li.mp_selectable:visible:first");return t.length||(t=this._firstSelectableItem()),this._addHighlight(t),this},_showList:function(){return this.$list.children().length&&(this.$list.show(),this.$input.attr("aria-expanded","true")),this},_hideList:function(){return this.$list.hide(),this.$input.removeAttr("aria-activedescendant").removeAttr("aria-expanded"),this},_emptyList:function(){return this.$list.empty(),this.$input.removeAttr("aria-activedescendant"),this},_hideAndEmptyList:function(){return this.$list.hide().empty(),this.$input.removeAttr("aria-activedescendant").removeAttr("aria-expanded"),this},_buildNoResultsList:function(t){var n=this,r=n.$input,i=n.$list,s=n.options,o=e('<li class="mp_no_results" role="alert" />'),u;return u=s.formatNoResults&&s.formatNoResults.call(r,t,o),u&&o.html(u),n._trigger("noResults",[t,o]),u?(o.appendTo(i),n._showList()):n._hideList(),n},_buildResultsList:function(t,n){var r=this,i=r.$input,s=r.$list,o=r.options,u=r.selectedData,a=o.compare&&u,f,l,c=!1,h,p=e(),d;for(var v=0,m=n.length;v<m;v++)h=n[v],p=e('<li class="mp_item" />'),d=o.formatItem.call(i,h,p),p.data("marcoPolo",h),p.html(d).appendTo(s),a&&o.highlight&&(o.compare===!0?(f=h,l=u):(f=h[o.compare],l=u[o.compare]),f===l&&(r._addHighlight(p),a=!1,c=!0));return s.children(o.selectable).addClass("mp_selectable").attr({"aria-selected":"false",role:"option"}),r._trigger("results",[n]),r._showList(),!c&&o.highlight&&r._highlightFirst(),r},_buildSuccessList:function(t,n){var r=this,i=r.$input,s=r.options;return r._emptyList(),s.formatData&&(n=s.formatData.call(i,n)),!n||n.length===0||e.isEmptyObject(n)?r._buildNoResultsList(t):r._buildResultsList(t,n),r},_buildErrorList:function(t,n,r){var i=this,s=i.$input,o=i.$list,u=i.options,a=e('<li class="mp_error" role="alert" />'),f;return i._emptyList(),f=u.formatError&&u.formatError.call(s,a,t,n,r),f&&a.html(f),i._trigger("error",[a,t,n,r]),f?(a.appendTo(o),i._showList()):i._hideList(),i},_buildMinCharsList:function(t){var n=this,r=n.$input,i=n.$list,s=n.options,o=e('<li class="mp_min_chars" role="alert" />'),u;return t.length?(n._emptyList(),u=s.formatMinChars&&s.formatMinChars.call(r,s.minChars,o),u&&o.html(u),n._trigger("minChars",[s.minChars,o]),u?(o.appendTo(i),n._showList()):n._hideList(),n):(n._hideAndEmptyList(),n)},_cancelPendingRequest:function(){var e=this;return e.ajax?(e.ajaxAborted=!0,e.ajax.abort()):e.ajaxAborted=!1,clearTimeout(e.timer),e},_request:function(t){var r=this,i=r.$input,s=r.$list,o=r.options;return r._cancelPendingRequest(),r.change(t,!0),r.timer=setTimeout(function(){var u={},a={},f={},l,c=e();if(t.length<o.minChars)return r._buildMinCharsList(t),r;u=e.isFunction(o.data)?o.data.call(r.$input,t):o.data,a[o.param]=t,f=e.extend({},u,a),l=o.url+(o.url.indexOf("?")===-1?"?":"&")+e.param(f),o.cache&&n[l]?r._buildSuccessList(t,n[l]):(r._trigger("requestBefore"),c=i.parent().addClass("mp_busy"),s.attr("aria-busy","true"),r.ajax=e.ajax({url:o.url,dataType:"json",data:f,success:function(e){r._buildSuccessList(t,e),o.cache&&(n[l]=e)},error:function(e,t,n){r.ajaxAborted||r._buildErrorList(e,t,n)},complete:function(e,t){r.ajax=null,r.ajaxAborted=!1,c.removeClass("mp_busy"),s.attr("aria-busy","false"),r._trigger("requestAfter",[e,t])}}))},o.delay),r},_dismiss:function(){var e=this,t=e.options;return e.focusPseudo=!1,e._cancelPendingRequest()._hideAndEmptyList(),t.required&&!e.selectedData&&e.change("",!0),e._toggleLabel()._trigger("blur"),e},_trigger:function(t,n){var r=this,i="on"+t.charAt(0).toUpperCase()+t.slice(1),s=r.widgetEventPrefix.toLowerCase()+t.toLowerCase(),o=e.isArray(n)?n:[],u=r.options[i];return r.element.trigger(s,o),u&&u.apply(r.element,o)}})}); /*! * Manifest v1.3.6 * * A jQuery plugin that adds delight to selecting multiple values for an input. * * https://github.com/jstayton/jquery-manifest * * Copyright 2013 by Justin Stayton * Licensed MIT */ (function(e){"use strict";typeof define=="function"&&define.amd?define(["jquery"],e):e(jQuery)})(function(e,t){"use strict";e.widget("mf.manifest",{options:{formatDisplay:function(e,t,n){return n?n.html():e},formatRemove:function(){return"X"},formatValue:function(e,t,n,r){return r?r.text():e},marcoPolo:!1,onAdd:null,onChange:null,onHighlight:null,onHighlightRemove:null,onRemove:null,onSelect:null,onSelectRemove:null,required:!1,separator:",",values:null,valuesName:null},_marcoPoloOptions:function(){var e=this,t=e.options;return{onFocus:function(){t.marcoPolo.onFocus&&t.marcoPolo.onFocus.call(this),e._resizeInput()},onRequestAfter:function(){e.$container.parent().removeClass("mf_busy"),t.marcoPolo.onRequestAfter&&t.marcoPolo.onRequestAfter.call(this)},onRequestBefore:function(){e.$container.parent().addClass("mf_busy"),t.marcoPolo.onRequestBefore&&t.marcoPolo.onRequestBefore.call(this)},onSelect:function(n,r){var i=!0;t.marcoPolo.onSelect&&(i=t.marcoPolo.onSelect.call(this,n,r)),i!==!1&&e.add(n,r,!0,!1)},required:t.required}},keys:{BACKSPACE:8,DELETE:46,DOWN:40,END:35,ENTER:13,HOME:36,LEFT:37,RIGHT:39,UP:38},_create:function(){var t=this,n=t.options,r,i;t.$input=i=t.element.addClass("mf_input"),t.inputName="mf_"+(i.attr("name")||e.now()),t.$container=e('<div class="mf_container" />'),t.$list=e('<ol class="mf_list" />').attr({"aria-atomic":"false","aria-live":"polite","aria-multiselectable":"true",id:t.inputName+"_list",role:"listbox"}),t.$measure=e('<span class="mf_measure" />'),t.mousedown=!1,t.mpMousedown=!1,t.inputOriginals={"aria-owns":i.attr("aria-owns"),role:i.attr("role"),width:i.css("width")},n.marcoPolo?(r=i.val(),i.val(""),t._bindMarcoPolo(),i.attr("aria-owns",i.attr("aria-owns")+" "+t.$list.attr("id")),i.val(r)):i.attr({"aria-owns":t.$list.attr("id"),role:"combobox"}),t._bindInput()._bindList()._bindContainer()._bindDocument(),i.wrap(t.$container).before(t.$list).after(t.$measure),t.$container=i.parent(),n.values&&t.add(n.values,null,!1,!0),t._addInputValues()._styleMeasure()._resizeInput()},_setOption:function(t,n){var r=this,i=r.$input;switch(t){case"marcoPolo":r.options.marcoPolo?n?i.marcoPolo("option",e.extend({},n,r._marcoPoloOptions())):i.marcoPolo("destroy"):n&&(r._bindMarcoPolo(e.extend({},n,r._marcoPoloOptions())),i.marcoPolo("list").insertAfter(i.parent()));break;case"required":r.options.marcoPolo&&i.marcoPolo("option","required",n);break;case"values":r.add(n,null,!1,!1);break;case"valuesName":r.$list.find("input:hidden.mf_value").attr("name",n+"[]")}e.Widget.prototype._setOption.apply(r,arguments)},_bindMarcoPolo:function(n){var r=this,i=r.$input,s=r.options;return n===t&&(n=e.extend({},s.marcoPolo,r._marcoPoloOptions())),i.marcoPolo(n),i.marcoPolo("list").bind("mousedown.manifest",function(){r.mpMousedown=!0}),r},_bindInput:function(){var t=this,n=t.$input,r=t.options,i=r.marcoPolo&&r.marcoPolo.minChars===0,s=[t.keys.UP,t.keys.DOWN,t.keys.HOME,t.keys.END];return n.bind("keydown.manifest",function(o){t._resizeInput();if(!r.required&&t._isSeparator(o.which)){o.preventDefault(),n.val()&&t.add(n.val(),null,!0,!1);return}if(o.which===t.keys.ENTER){o.preventDefault();return}if(n.val())return;if(i&&e.inArray(o.which,s)!==-1)return;switch(o.which){case t.keys.BACKSPACE:case t.keys.DELETE:var u=t._selected();u.length?t.remove(u):t._selectPrev();break;case t.keys.LEFT:case t.keys.UP:t._selectPrev();break;case t.keys.RIGHT:case t.keys.DOWN:t._selectNext();break;case t.keys.HOME:t._selectFirst();break;case t.keys.END:t._selectLast();break;default:t._removeSelected()}}).bind("keypress.manifest",function(e){!r.required&&t._isSeparator(String.fromCharCode(e.which))&&(e.preventDefault(),n.val()&&t.add(n.val(),null,!0,!1))}).bind("keyup.manifest",function(){t._resizeInput()}).bind("paste.manifest",function(){setTimeout(function(){t._resizeInput(),!r.required&&n.val()&&t.add(t._splitBySeparator(n.val()),null,!0,!1)},1)}).bind("blur.manifest",function(){setTimeout(function(){t.mousedown||t._removeSelected(),t.mpMousedown||(r.marcoPolo&&r.required?t._resizeInput():n.val()&&t.add(n.val(),null,!0,!1))},1)}),t},_bindList:function(){var t=this;return t.$list.delegate("li","mouseover",function(){t._addHighlight(e(this))}).delegate("li","mouseout",function(){t._removeHighlight(e(this))}).delegate("li","mousedown",function(){t.mousedown=!0}).delegate("li","click",function(n){e(n.target).is("a.mf_remove")?(t._removeSelected(),t.remove(e(this)),n.preventDefault()):t._toggleSelect(e(this))}),t},_bindContainer:function(){var e=this;return e.$container.bind("click.manifest",function(){e.$input.focus()}),e},_bindDocument:function(){var t=this,n=t.$input;return e(document).bind("mouseup.manifest",function(r){t.mousedown&&(t.mousedown=!1,e(r.target).is("li.mf_item, li.mf_item *")||t._removeSelected()),t.mpMousedown&&(t.mpMousedown=!1,t.options.required?t._resizeInput():n.val()&&t.add(n.val(),null,!0,!1))}),t},container:function(){return this.$container},list:function(){return this.$list},add:function(t,n,r,i){var s=this,o=s.$input,u=s.options,a=e.isArray(t)?t:[t],f,l=e(),c=e(),h=e(),p=function(t,n,r){l.html(t),c.html(n),h.val(r),l.append(c,h),e.when(s._trigger("add",[f,l,!!i])).then(function(e){e!==!1&&(l.appendTo(s.$list),i||s._trigger("change",["add",f,l]))})};for(var d=0,v=a.length;d<v;d++){f=a[d],typeof f=="string"&&(f=e.trim(f));if(!f||e.isPlainObject(f)&&e.isEmptyObject(f))continue;l=e('<li class="mf_item" role="option" aria-selected="false" />'),c=e('<a href="#" class="mf_remove" title="Remove" />'),h=e('<input type="hidden" class="mf_value" />'),u.valuesName?h.attr("name",u.valuesName+"[]"):h.attr("name",o.attr("name")+"_values[]"),l.data("manifest",f),e.when(u.formatDisplay.call(o,f,l,n),u.formatRemove.call(o,c,l),u.formatValue.call(o,f,h,l,n)).then(p)}r&&s._clearInputValue()},_addInputValues:function(){var t=this,n=t.$input,r=n.data("values"),i=n.val(),s=[];return r?s=e.isArray(r)?r:[r]:i&&(s=t._splitBySeparator(i)),s.length&&t.add(s,null,!0,!0),t},remove:function(t){var n=this,r=e();t instanceof jQuery?r=t:r=n.$list.children(t),r.each(function(){var t=e(this),r=t.data("manifest");e.when(n._trigger("remove",[r,t])).then(function(e){e!==!1&&(n._isSelected(t)&&n._removeSelect(t),t.remove(),n._trigger("change",["remove",r,t]))})})},values:function(){var t=this,n=t.$list,r=[];return n.find("input:hidden.mf_value").each(function(){r.push(e(this).val())}),r},destroy:function(){var n=this,r=n.$input;n.options.marcoPolo&&r.marcoPolo("destroy"),n.$list.remove(),n.$measure.remove(),r.unwrap().removeClass("mf_input").val(n._joinWithSeparator(n.values())),e.each(n.inputOriginals,function(e,n){n===t?r.removeAttr(e):r.attr(e,n)}),e(document).unbind(".manifest"),e.Widget.prototype.destroy.apply(n,arguments)},_styleMeasure:function(){var e=this,t=e.$input;return e.$measure.css({"font-family":t.css("font-family"),"font-size":t.css("font-size"),"font-style":t.css("font-style"),"font-variant":t.css("font-variant"),"font-weight":t.css("font-weight"),left:-9999,"letter-spacing":t.css("letter-spacing"),position:"absolute","text-transform":t.css("text-transform"),top:-9999,"white-space":"nowrap",width:"auto","word-spacing":t.css("word-spacing")}),e},_measureText:function(e){var t=this.$measure,n;return n=e.replace(/&/g,"&").replace(/\s/g," ").replace(/</g,"<").replace(/>/g,">"),t.html(n),t.width()},_maxInputWidth:function(){var e=this,t=e.$container,n=e.$input;return t.width()-(n.outerWidth(!0)-n.width())},_resizeInput:function(){var e=this,t=e.$input,n;return n=e._measureText(t.val()+"---"),t.width(Math.min(n,e._maxInputWidth())),e},_clearInputValue:function(){var e=this,t=e.$input;return e.options.marcoPolo?t.marcoPolo("change",null):t.val(""),e._resizeInput(),e},_isSeparator:function(t){var n=this.options.separator;return e.isArray(n)?e.inArray(t,n)!==-1:t===n},_separators:function(t){var n=this.options.separator,r=e.isArray(n)?n:[n];return t&&(r=e.grep(r,function(e){return typeof e=="string"})),r},_firstSeparator:function(e){return this._separators(e).shift()},_splitBySeparator:function(t){var n=this._separators(!0),r=t;return n.length&&(r=t.split(new RegExp("[\\"+n.join("\\")+"]")),r=e.map(r,e.trim)),r},_joinWithSeparator:function(e){var t=this._firstSeparator(!0)||"";return e.join(t+" ")},_firstItem:function(){return this.$list.children("li:first")},_lastItem:function(){return this.$list.children("li:last")},_highlighted:function(){return this.$list.children("li.mf_highlighted")},_addHighlight:function(e){var t=this;return e.length?(t._removeHighlighted(),e.addClass("mf_highlighted"),t._trigger("highlight",[e.data("marcoPolo"),e]),t):t},_removeHighlight:function(e){var t=this;return e.length?(e.removeClass("mf_highlighted"),t._trigger("highlightRemove",[e.data("marcoPolo"),e]),t):t},_removeHighlighted:function(){return this._removeHighlight(this._highlighted())},_selected:function(){return this.$list.children("li.mf_selected")},_isSelected:function(e){return e.hasClass("mf_selected")},_addSelect:function(e){var t=this;return e.length?(t._removeSelected(),e.addClass("mf_selected").attr({"aria-selected":"true",id:t.inputName+"_selected"}),t.$list.attr("aria-activedescendant",e.attr("id")),t._trigger("select",[e.data("marcoPolo"),e]),t):t},_removeSelect:function(e){var t=this;return e.length?(e.removeClass("mf_selected").attr("aria-selected","false").removeAttr("id"),t.$list.removeAttr("aria-activedescendant"),t._trigger("selectRemove",[e.data("marcoPolo"),e]),t):t},_removeSelected:function(){return this._removeSelect(this._selected())},_toggleSelect:function(e){return this._isSelected(e)?this._removeSelect(e):this._addSelect(e)},_selectPrev:function(){var t=this,n=t._selected(),r=e();return n.length?r=n.prev():r=t._lastItem(),r.length&&t._addSelect(r),t},_selectNext:function(){var e=this,t=e._selected(),n=t.next();return n.length?e._addSelect(n):e._removeSelect(t)},_selectFirst:function(){return this._addSelect(this._firstItem())},_selectLast:function(){return this._addSelect(this._lastItem())},_trigger:function(e,t){var n=this,r="on"+e.charAt(0).toUpperCase()+e.slice(1),i=n.widgetEventPrefix.toLowerCase()+e.toLowerCase(),s=n.options[r];return n.element.trigger(i,t),s&&s.apply(n.element,t)}})});