source: main/trunk/model-interfaces-dev/whakatohea/iframe/Tīpuna-WMTB_files/commerce-core.js@ 33835

Last change on this file since 33835 was 33835, checked in by davidb, 4 years ago

Supporting iframe files now located within interface area

File size: 61.4 KB
Line 
1publishedWBJP([16],{0:function(e,t,i){e.exports=i(101)},101:function(e,t,i){var s,n;!(s=[i(1),i(3),i(5),i(50),i(51),i(40),i(249),i(175),i(42),i(242),i(244),i(246),i(245),i(232)],n=function(){}.apply(t,s),n!==undefined&&(e.exports=n))},175:function(e,t,i){(function(e){(function(e){function t(e){for(var t=1;t<arguments.length;t++){e=e.replace("%"+(t-1),arguments[t])}return e}function i(i,s){var n=e("img:first",i);var a=n;var o;var r;var l=null;var c=null;var h=null;var u=null;var f=null;var d=null;var p;var g=0;var m=0;var v,w;var b=0;var C=0;var y=0;var S=0;var x=0;var E,T;var k=this,I;setTimeout(function(){if(c===null){var e=i.width();i.parent().append(t('<div style="width:%0px;position:absolute;top:75%;left:%1px;text-align:center" class="cloud-zoom-loading" >Loading...</div>',e/3,e/2-e/6)).find(":last").css("opacity",.5)}},200);var O=function(){if(d!==null){d.remove();d=null}};this.removeBits=function(){if(h){h.remove();h=null}if(u){u.remove();u=null}if(f){f.remove();f=null}O();e(".cloud-zoom-loading",i.parent()).remove()};this.destroy=function(){i.data("zoom",null);if(c){c.unbind();c.remove();c=null}if(l){l.remove();l=null}this.removeBits()};this.fadedOut=function(){if(l){l.remove();l=null}this.removeBits()};this.controlLoop=function(){if(h){var e=E-a.offset().left-v*.5>>0;var t=T-a.offset().top-w*.5>>0;if(e<0){e=0}else if(e>a.outerWidth()-v){e=a.outerWidth()-v}if(t<0){t=0}else if(t>a.outerHeight()-w){t=a.outerHeight()-w}h.css({left:e,top:t});h.css("background-position",-e+"px "+-t+"px");b=e/a.outerWidth()*p.width>>0;C=t/a.outerHeight()*p.height>>0;S+=(b-S)/s.smoothMove;y+=(C-y)/s.smoothMove;l.css("background-position",-(S>>0)+"px "+(-(y>>0)+"px"))}g=setTimeout(function(){k.controlLoop()},30)};this.init2=function(e,t){x++;if(t===1){p=e}if(x===2){this.init()}};this.init=function(){e(".cloud-zoom-loading",i.parent()).remove();c=e(".mousetrap",i.parent());if(c){c.unbind();c.remove()}c=i.parent().append(t("<div class='mousetrap' style='background-image:url(\"//"+ASSETS_BASE+"/images/blank.gif\");z-index:2;position:absolute;width:%0px;height:%1px;left:%2px;top:%3px;'></div>",a.outerWidth(),a.outerHeight(),0,0)).find(":last");c.bind("mousemove",this,function(e){E=e.pageX;T=e.pageY});c.bind("mouseleave",this,function(e){clearTimeout(g);clearTimeout(m);if(h){h.fadeOut(299)}if(u){u.fadeOut(299)}if(f){f.fadeOut(299)}if(l){l.fadeOut(300,function(){k.fadedOut()})}return false});var o=i.attr("href");var r=i.find("img").attr("src");if(o!=r){c.bind("mouseenter",this,function(o){m=setTimeout(function(){I=o.data;if(l){l.stop(true,false);l.remove()}var r=s.adjustX,g=s.adjustY;var m=a.outerWidth();var b=a.outerHeight();var C=s.zoomWidth;var y=s.zoomHeight;if(s.zoomWidth=="auto"){C=m}if(s.zoomHeight=="auto"){y=b}var S=i.parent();switch(s.position){case"top":g-=y;break;case"right":r+=m;break;case"bottom":g+=b;break;case"left":r-=C;break;case"inside":C=m;y=b;break;default:S=e("#"+s.position);if(!S.length){S=i;r+=m;g+=b}else{C=S.innerWidth();y=S.innerHeight()}}l=S.append(t('<div id="cloud-zoom-big" class="cloud-zoom-big" style="display:none;position:absolute;left:%0px;top:%1px;width:%2px;height:%3px;background-image:url(\'%4\');z-index:1;"></div>',r,g,C,y,p.src)).find(":last");if(n.attr("title")&&s.showTitle){l.append(t('<div class="cloud-zoom-title">%0</div>',n.attr("title"))).find(":last").css("opacity",s.titleOpacity)}if(e.browser.msie&&e.browser.version<7){d=e('<iframe frameborder="0" src="#"></iframe>').css({position:"absolute",left:r,top:g,zIndex:1,width:C,height:y}).insertBefore(l)}l.fadeIn(500);if(h){h.remove();h=null}v=a.outerWidth()/p.width*l.width();w=a.outerHeight()/p.height*l.height();h=i.append(t("<div class = 'cloud-zoom-lens' style='display:none;z-index:98;position:absolute;width:%0px;height:%1px;'></div>",v,w)).find(":last");c.css("cursor",h.css("cursor"));var x=false;if(s.tint){h.css("background",'url("'+n.attr("src")+'")');u=i.append(t('<div style="display:none;position:absolute; left:0px; top:0px; width:%0px; height:%1px; background-color:%2;" />',a.outerWidth(),a.outerHeight(),s.tint)).find(":last");u.css("opacity",s.tintOpacity);x=true;u.fadeIn(500)}if(s.softFocus){h.css("background",'url("'+n.attr("src")+'")');f=i.append(t('<div style="position:absolute;display:none;top:2px; left:2px; width:%0px; height:%1px;" />',a.outerWidth()-2,a.outerHeight()-2,s.tint)).find(":last");f.css("background",'url("'+n.attr("src")+'")');f.css("opacity",.5);x=true;f.fadeIn(500)}if(!x){h.css("opacity",s.lensOpacity)}if(s.position!=="inside"){h.fadeIn(500)}I.controlLoop()},250);return})}};o=new Image;e(o).load(function(){k.init2(this,0)});o.src=n.attr("src");r=new Image;e(r).load(function(){k.init2(this,1)});r.src=i.attr("href")}e.fn.CloudZoom=function(t){try{document.execCommand("BackgroundImageCache",false,true)}catch(e){}this.each(function(){var s,n=e(this);if(n.is(".cloud-zoom")){n.css({position:"relative",display:"block"});e("img",n).css({display:"block"});if(e(this).parent().attr("id")!="cloudzoom-wrap"){e(this).wrap('<div id="cloudzoom-wrap" style="top:0px;position:relative;"></div>')}s=e.extend({},e.fn.CloudZoom.defaults,t);var a={adjustX:"int",adjustY:"int",zoomWidth:"int",zoomHeight:"int",position:"string",tint:"string",tintOpacity:"float",lensOpacity:"float",softFocus:"bool",smoothMove:"int",showTitle:"bool",titleOpacity:"float"};for(var o in a){var r=e(this).attr("data-"+o);if(r){switch(a[o]){case"int":case"float":s[o]=Number(r);break;case"bool":s[o]=Boolean(r);break;case"string":default:s[o]=r;break}}}e(this).data("zoom",new i(e(this),s))}else if(e(this).is(".cloud-zoom-gallery")){s=e.extend({},{useZoom:e(this).attr("data-zoom-id"),smallImage:e(this).attr("data-small-image")},t);e(this).data("relOpts",s);e(this).bind("click",e(this),function(t){var i=t.data;var n=i.data("relOpts");var a=e("#"+n.useZoom+" div.wsite-show").add("#"+n.useZoom+" div.wsite-show-init");e("#"+n.useZoom).data("zoom").destroy();e("#"+n.useZoom).attr("href",i.attr("href"));e("#"+n.useZoom+" img").attr("src",n.smallImage);e("#"+n.useZoom).CloudZoom(s);return false})}});return this};e.fn.CloudZoom.defaults={zoomWidth:"auto",zoomHeight:"auto",position:"right",tint:false,tintOpacity:.5,lensOpacity:.5,softFocus:false,smoothMove:3,showTitle:true,titleOpacity:.5,adjustX:0,adjustY:0}})(e)}).call(t,i(1))},232:function(e,t,i){var s,n;!(s=[i(2),i(42)],n=function(e){e.Commerce=e.Commerce||{};e.Commerce.Site=e.Commerce.Site||{};if(window.initCommerceModels){window.initCommerceModels()}}.apply(t,s),n!==undefined&&(e.exports=n))},242:function(e,t,i){var s,n;!(s=[i(3),i(2),i(7),i(56)],n=function(e,t,i,s){e.extend(i.Validation.validators,{in:function(){return i.Validation.validators.oneOf.apply(this,arguments)},email:function(e,i,n){if(!s.isValidEmail(e)){return this.format(t.stl("javascript.util.backbone-validators_1"),this.formatLabel(i,n))}},maxlength:i.Validation.validators.maxLength,minlength:i.Validation.validators.minLength});e.extend(i.Validation.messages,{required:t.stl("javascript.validation.required"),acceptance:t.stl("javascript.validation.accepted"),min:t.stl("javascript.validation.min"),max:t.stl("javascript.validation.max"),range:t.stl("javascript.validation.range"),length:t.stl("javascript.validation.length"),minLength:t.stl("javascript.validation.charMin"),maxLength:t.stl("javascript.validation.charMax"),rangeLength:t.stl("javascript.validation.charRange"),oneOf:t.stl("javascript.validation.oneOf"),equalTo:t.stl("javascript.validation.equal"),digits:t.stl("javascript.validation.digits"),number:t.stl("javascript.validation.number"),int:t.stl("javascript.validation.int"),email:t.stl("javascript.validation.email"),url:t.stl("javascript.validation.url"),domain:t.stl("javascript.validation.domain"),inlinePattern:t.stl("javascript.validation.inline")})}.apply(t,s),n!==undefined&&(e.exports=n))},244:function(e,t){(function(e){e.Event.prototype.stop=function(){this.preventDefault();this.stopPropagation()};e.fn.extend({getValue:function(){var e=this;if(e.attr("type")==="checkbox"||e.attr("type")==="radio")return e.prop("checked");if(!e.is(":input"))return e.html();return e.val()},setValue:function(e){var t=this;if(t.attr("type")==="checkbox"||t.attr("type")==="radio")t.prop("checked",!!e);else if(!t.is(":input"))t.html(typeof e=="string"?e:"");else t.val(e==null||e==undefined?"":e);return t},getValues:function(t){t=t||"";var i={};this.find(":input,.input").each(function(){var s=e(this),n=s.attr("name")||s.attr("id");if(n&&n.indexOf(t)===0){n=n.substring(t.length);i[n]=s.getValue()}});return i},setValues:function(t,i){i=i||"";var s,n;this.find(":input,.input").each(function(){var s=e(this),n=s.attr("name")||s.attr("id");if(n&&n.indexOf(i)===0){n=n.substring(i.length);s.setValue(t[n])}});return this},equals:function(e){return this.data()===e.data()},padInput:function(t){var i,s="auto",n="auto";t=t||"all";this.each(function(a,o){i=e(o);if(t==="ns"||t==="all"){s=Math.floor((i.parent().height()-i.height())/2)}if(t==="ew"||t==="all"){n=Math.floor((i.parent().width()-i.width())/2)}i.css({"padding-top":s,"padding-right":n,"padding-bottom":s,"padding-left":n})});return this}})})(window.jQuery);if(typeof JSON=="undefined"){window.JSON={stringify:Object.toJSON,parse:function(e){return(e||"").evalJSON()}}}Function.prototype.bind||(Function.prototype.bind=function(e){var t=this;var i=Array.prototype.slice.call(arguments,1);return function(){var s=Array.prototype.slice.call(arguments);return t.apply(e,i.concat(s))}});Array.prototype.forEach||(Array.prototype.forEach=function(e,t){for(var i=0,s=this.length;i<s;++i){if(i in this){e.call(t,this[i],i,this)}}});Array.prototype.find||(Array.prototype.find=function(e,t){for(var i=0,s=this.length;i<s;++i){var n=this[i];if(e.call(t,n))return n}return null});Array.prototype.push||(Array.prototype.push=function(e){this[this.length]=e});Object.defineProperty(Array.prototype,"remove",{value:function(e,t){var i=this.slice((t||e)+1||this.length);this.length=e<0?this.length+e:e;return this.push.apply(this,i)},enumerable:false,configurable:true});String.prototype.format=function(){var e=arguments;return this.replace(/{(\d+)}/g,function(t,i){return typeof e[i]!="undefined"?e[i]:t})}},245:function(e,t,i){(function(e){(function(e){if(typeof e.fn.each2=="undefined"){e.fn.extend({each2:function(t){var i=e([0]),s=-1,n=this.length;while(++s<n&&(i.context=i[0]=this[s])&&t.call(i[0],s,i)!==false);return this}})}})(e);(function(e,t){"use strict";if(window.Select2!==t){return}var i,s,n,a,o,r,l={x:0,y:0},c,h,i={TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,isArrow:function(e){e=e.which?e.which:e;switch(e){case i.LEFT:case i.RIGHT:case i.UP:case i.DOWN:return true}return false},isControl:function(e){var t=e.which;switch(t){case i.SHIFT:case i.CTRL:case i.ALT:return true}if(e.metaKey)return true;return false},isFunctionKey:function(e){e=e.which?e.which:e;return e>=112&&e<=123}},u="<div class='select2-measure-scrollbar'></div>";c=e(document);o=function(){var e=1;return function(){return e++}}();function f(e,t){var i=0,s=t.length;for(;i<s;i=i+1){if(p(e,t[i]))return i}return-1}function d(){var t=e(u);t.appendTo("body");var i={width:t.width()-t[0].clientWidth,height:t.height()-t[0].clientHeight};t.remove();return i}function p(e,i){if(e===i)return true;if(e===t||i===t)return false;if(e===null||i===null)return false;if(e.constructor===String)return e+""===i+"";if(i.constructor===String)return i+""===e+"";return false}function g(t,i){var s,n,a;if(t===null||t.length<1)return[];s=t.split(i);for(n=0,a=s.length;n<a;n=n+1)s[n]=e.trim(s[n]);return s}function m(e){return e.outerWidth(false)-e.width()}function v(i){var s="keyup-change-value";i.on("keydown",function(){if(e.data(i,s)===t){e.data(i,s,i.val())}});i.on("keyup",function(){var n=e.data(i,s);if(n!==t&&i.val()!==n){e.removeData(i,s);i.trigger("keyup-change")}})}c.on("mousemove",function(e){l.x=e.pageX;l.y=e.pageY});function w(i){i.on("mousemove",function(i){var s=l;if(s===t||s.x!==i.pageX||s.y!==i.pageY){e(i.target).trigger("mousemove-filtered",i)}})}function b(e,i,s){s=s||t;var n;return function(){var t=arguments;window.clearTimeout(n);n=window.setTimeout(function(){i.apply(s,t)},e)}}function C(e){var t=false,i;return function(){if(t===false){i=e();t=true}return i}}function y(e,t){var i=b(e,function(e){t.trigger("scroll-debounced",e)});t.on("scroll",function(e){if(f(e.target,t.get())>=0)i(e)})}function S(e){if(e[0]===document.activeElement)return;window.setTimeout(function(){var t=e[0],i=e.val().length,s;e.focus();if(e.is(":visible")&&t===document.activeElement){if(t.setSelectionRange){t.setSelectionRange(i,i)}else if(t.createTextRange){s=t.createTextRange();s.collapse(false);s.select()}}},0)}function x(t){t=e(t)[0];var i=0;var s=0;if("selectionStart"in t){i=t.selectionStart;s=t.selectionEnd-i}else if("selection"in document){t.focus();var n=document.selection.createRange();s=document.selection.createRange().text.length;n.moveStart("character",-t.value.length);i=n.text.length-s}return{offset:i,length:s}}function E(e){e.preventDefault();e.stopPropagation()}function T(e){e.preventDefault();e.stopImmediatePropagation()}function k(t){if(!r){var i=t[0].currentStyle||window.getComputedStyle(t[0],null);r=e(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:i.fontSize,fontFamily:i.fontFamily,fontStyle:i.fontStyle,fontWeight:i.fontWeight,letterSpacing:i.letterSpacing,textTransform:i.textTransform,whiteSpace:"nowrap"});r.attr("class","select2-sizer");e("body").append(r)}r.text(t.val());return r.width()}function I(t,i,s){var n,a=[],o;n=t.attr("class");if(n){n=""+n;e(n.split(" ")).each2(function(){if(this.indexOf("select2-")===0){a.push(this)}})}n=i.attr("class");if(n){n=""+n;e(n.split(" ")).each2(function(){if(this.indexOf("select2-")!==0){o=s(this);if(o){a.push(this)}}})}t.attr("class",a.join(" "))}function O(e,t,i,s){var n=e.toUpperCase().indexOf(t.toUpperCase()),a=t.length;if(n<0){i.push(s(e));return}i.push(s(e.substring(0,n)));i.push("<span class='select2-match'>");i.push(s(e.substring(n,n+a)));i.push("</span>");i.push(s(e.substring(n+a,e.length)))}function P(e){var t={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})}function A(i){var s,n=0,a=null,o=i.quietMillis||100,r=i.url,l=this;return function(c){window.clearTimeout(s);s=window.setTimeout(function(){n+=1;var s=n,o=i.data,h=r,u=i.transport||e.fn.select2.ajaxDefaults.transport,f={type:i.type||"GET",cache:i.cache||false,jsonpCallback:i.jsonpCallback||t,dataType:i.dataType||"json"},d=e.extend({},e.fn.select2.ajaxDefaults.params,f);o=o?o.call(l,c.term,c.page,c.context):null;h=typeof h==="function"?h.call(l,c.term,c.page,c.context):h;if(a){a.abort()}if(i.params){if(e.isFunction(i.params)){e.extend(d,i.params.call(l))}else{e.extend(d,i.params)}}e.extend(d,{url:h,dataType:i.dataType,data:o,success:function(e){if(s<n){return}var t=i.results(e,c.page);c.callback(t)}});a=u.call(l,d)},o)}}function R(t){var i=t,s,n,a=function(e){return""+e.text};if(e.isArray(i)){n=i;i={results:n}}if(e.isFunction(i)===false){n=i;i=function(){return n}}var o=i();if(o.text){a=o.text;if(!e.isFunction(a)){s=o.text;a=function(e){return e[s]}}}return function(t){var s=t.term,n={results:[]},o;if(s===""){t.callback(i());return}o=function(i,n){var r,l;i=i[0];if(i.children){r={};for(l in i){if(i.hasOwnProperty(l))r[l]=i[l]}r.children=[];e(i.children).each2(function(e,t){o(t,r.children)});if(r.children.length||t.matcher(s,a(r),i)){n.push(r)}}else{if(t.matcher(s,a(i),i)){n.push(i)}}};e(i().results).each2(function(e,t){o(t,n.results)});t.callback(n)}}function D(i){var s=e.isFunction(i);return function(n){var a=n.term,o={results:[]};e(s?i():i).each(function(){var e=this.text!==t,i=e?this.text:this;if(a===""||n.matcher(a,i)){o.results.push(e?this:{id:this,text:this})}});n.callback(o)}}function M(t,i){if(e.isFunction(t))return true;if(!t)return false;throw new Error(i+" must be a function or a falsy value")}function N(t){return e.isFunction(t)?t():t}function j(t){var i=0;e.each(t,function(e,t){if(t.children){i+=j(t.children)}else{i++}});return i}function H(e,i,s,n){var a=e,o=false,r,l,c,h,u;if(!n.createSearchChoice||!n.tokenSeparators||n.tokenSeparators.length<1)return t;while(true){l=-1;for(c=0,h=n.tokenSeparators.length;c<h;c++){u=n.tokenSeparators[c];l=e.indexOf(u);if(l>=0)break}if(l<0)break;r=e.substring(0,l);e=e.substring(l+u.length);if(r.length>0){r=n.createSearchChoice.call(this,r,i);if(r!==t&&r!==null&&n.id(r)!==t&&n.id(r)!==null){o=false;for(c=0,h=i.length;c<h;c++){if(p(n.id(r),n.id(i[c]))){o=true;break}}if(!o)s(r)}}}if(a!==e)return e}function z(t,i){var s=function(){};s.prototype=new t;s.prototype.constructor=s;s.prototype.parent=t.prototype;s.prototype=e.extend(s.prototype,i);return s}s=z(Object,{bind:function(e){var t=this;return function(){e.apply(t,arguments)}},init:function(i){var s,n,a=".select2-results",r,l;this.opts=i=this.prepareOpts(i);this.id=i.id;if(i.element.data("select2")!==t&&i.element.data("select2")!==null){i.element.data("select2").destroy()}this.container=this.createContainer();this.containerId="s2id_"+(i.element.attr("id")||"autogen"+o());this.containerSelector="#"+this.containerId.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1");this.container.attr("id",this.containerId);this.body=C(function(){return i.element.closest("body")});I(this.container,this.opts.element,this.opts.adaptContainerCssClass);this.container.css(N(i.containerCss));this.container.addClass(N(i.containerCssClass));this.elementTabIndex=this.opts.element.attr("tabindex");this.opts.element.data("select2",this).attr("tabindex","-1").before(this.container);this.container.data("select2",this);this.dropdown=this.container.find(".select2-drop");this.dropdown.addClass(N(i.dropdownCssClass));this.dropdown.data("select2",this);this.results=s=this.container.find(a);this.search=n=this.container.find("input.select2-input");this.resultsPage=0;this.context=null;this.initContainer();w(this.results);this.dropdown.on("mousemove-filtered touchstart touchmove touchend",a,this.bind(this.highlightUnderEvent));y(80,this.results);this.dropdown.on("scroll-debounced",a,this.bind(this.loadMoreIfNeeded));e(this.container).on("change",".select2-input",function(e){e.stopPropagation()});e(this.dropdown).on("change",".select2-input",function(e){e.stopPropagation()});if(e.fn.mousewheel){s.mousewheel(function(e,t,i,n){var a=s.scrollTop(),o;if(n>0&&a-n<=0){s.scrollTop(0);E(e)}else if(n<0&&s.get(0).scrollHeight-s.scrollTop()+n<=s.height()){s.scrollTop(s.get(0).scrollHeight-s.height());E(e)}})}v(n);n.on("keyup-change input paste",this.bind(this.updateResults));n.on("focus",function(){n.addClass("select2-focused")});n.on("blur",function(){n.removeClass("select2-focused")});this.dropdown.on("mouseup",a,this.bind(function(t){if(e(t.target).closest(".select2-result-selectable").length>0){this.highlightUnderEvent(t);this.selectHighlighted(t)}}));this.dropdown.on("click mouseup mousedown",function(e){e.stopPropagation()});if(e.isFunction(this.opts.initSelection)){this.initSelection();this.monitorSource()}if(i.maximumInputLength!==null){this.search.attr("maxlength",i.maximumInputLength)}var r=i.element.prop("disabled");if(r===t)r=false;this.enable(!r);var l=i.element.prop("readonly");if(l===t)l=false;this.readonly(l);h=h||d();this.autofocus=i.element.prop("autofocus");i.element.prop("autofocus",false);if(this.autofocus)this.focus()},destroy:function(){var e=this.opts.element,i=e.data("select2");if(this.propertyObserver){delete this.propertyObserver;this.propertyObserver=null}if(i!==t){i.container.remove();i.dropdown.remove();e.removeClass("select2-offscreen").removeData("select2").off(".select2").prop("autofocus",this.autofocus||false);if(this.elementTabIndex){e.attr({tabindex:this.elementTabIndex})}else{e.removeAttr("tabindex")}e.show()}},optionToData:function(e){if(e.is("option")){return{id:e.prop("value"),text:e.text(),element:e.get(),css:e.attr("class"),disabled:e.prop("disabled"),locked:p(e.attr("locked"),"locked")||p(e.data("locked"),true)}}else if(e.is("optgroup")){return{text:e.attr("label"),children:[],element:e.get(),css:e.attr("class")}}},prepareOpts:function(i){var s,n,a,o,r=this;s=i.element;if(s.get(0).tagName.toLowerCase()==="select"){this.select=n=i.element}if(n){e.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in i){throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a <select> element.")}})}i=e.extend({},{populateResults:function(s,n,a){var o,l,c,h,u=this.opts.id;o=function(s,n,l){var c,h,f,d,p,g,m,v,w,b;s=i.sortResults(s,n,a);for(c=0,h=s.length;c<h;c=c+1){f=s[c];p=f.disabled===true;d=!p&&u(f)!==t;g=f.children&&f.children.length>0;m=e("<li></li>");m.addClass("select2-results-dept-"+l);m.addClass("select2-result");m.addClass(d?"select2-result-selectable":"select2-result-unselectable");if(p){m.addClass("select2-disabled")}if(g){m.addClass("select2-result-with-children")}m.addClass(r.opts.formatResultCssClass(f));v=e(document.createElement("div"));v.addClass("select2-result-label");b=i.formatResult(f,v,a,r.opts.escapeMarkup);if(b!==t){v.html(b)}m.append(v);if(g){w=e("<ul></ul>");w.addClass("select2-result-sub");o(f.children,w,l+1);m.append(w)}m.data("select2-data",f);n.append(m)}};o(n,s,0)}},e.fn.select2.defaults,i);if(typeof i.id!=="function"){a=i.id;i.id=function(e){return e[a]}}if(e.isArray(i.element.data("select2Tags"))){if("tags"in i){throw"tags specified as both an attribute 'data-select2-tags' and in options of Select2 "+i.element.attr("id")}i.tags=i.element.data("select2Tags")}if(n){i.query=this.bind(function(e){var i={results:[],more:false},n=e.term,a,o,l;l=function(t,i){var s;if(t.is("option")){if(e.matcher(n,t.text(),t)){i.push(r.optionToData(t))}}else if(t.is("optgroup")){s=r.optionToData(t);t.children().each2(function(e,t){l(t,s.children)});if(s.children.length>0){i.push(s)}}};a=s.children();if(this.getPlaceholder()!==t&&a.length>0){o=this.getPlaceholderOption();if(o){a=a.not(o)}}a.each2(function(e,t){l(t,i.results)});e.callback(i)});i.id=function(e){return e.id};i.formatResultCssClass=function(e){return e.css}}else{if(!("query"in i)){if("ajax"in i){o=i.element.data("ajax-url");if(o&&o.length>0){i.ajax.url=o}i.query=A.call(i.element,i.ajax)}else if("data"in i){i.query=R(i.data)}else if("tags"in i){i.query=D(i.tags);if(i.createSearchChoice===t){i.createSearchChoice=function(e){return{id:e,text:e}}}if(i.initSelection===t){i.initSelection=function(t,s){var n=[];e(g(t.val(),i.separator)).each(function(){var t=this,s=this,a=i.tags;if(e.isFunction(a))a=a();e(a).each(function(){if(p(this.id,t)){s=this.text;return false}});n.push({id:t,text:s})});s(n)}}}}}if(typeof i.query!=="function"){throw"query function not defined for Select2 "+i.element.attr("id")}return i},monitorSource:function(){var e=this.opts.element,i;e.on("change.select2",this.bind(function(e){if(this.opts.element.data("select2-change-triggered")!==true){this.initSelection()}}));i=this.bind(function(){var i,s,n=this;var a=e.prop("disabled");if(a===t)a=false;this.enable(!a);var s=e.prop("readonly");if(s===t)s=false;this.readonly(s);I(this.container,this.opts.element,this.opts.adaptContainerCssClass);this.container.addClass(N(this.opts.containerCssClass));I(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass);this.dropdown.addClass(N(this.opts.dropdownCssClass))});e.on("propertychange.select2 DOMAttrModified.select2",i);if(this.mutationCallback===t){this.mutationCallback=function(e){e.forEach(i)}}if(typeof WebKitMutationObserver!=="undefined"){if(this.propertyObserver){delete this.propertyObserver;this.propertyObserver=null}this.propertyObserver=new window.WebKitMutationObserver(this.mutationCallback);this.propertyObserver.observe(e.get(0),{attributes:true,subtree:false})}},triggerSelect:function(t){var i=e.Event("select2-selecting",{val:this.id(t),object:t});this.opts.element.trigger(i);return!i.isDefaultPrevented()},triggerChange:function(t){t=t||{};t=e.extend({},t,{type:"change",val:this.val()});this.opts.element.data("select2-change-triggered",true);this.opts.element.trigger(t);this.opts.element.data("select2-change-triggered",false);this.opts.element.click();if(this.opts.blurOnChange)this.opts.element.blur()},isInterfaceEnabled:function(){return this.enabledInterface===true},enableInterface:function(){var e=this._enabled&&!this._readonly,t=!e;if(e===this.enabledInterface)return false;this.container.toggleClass("select2-container-disabled",t);this.close();this.enabledInterface=e;return true},enable:function(e){if(e===t)e=true;if(this._enabled===e)return false;this._enabled=e;this.opts.element.prop("disabled",!e);this.enableInterface();return true},readonly:function(e){if(e===t)e=false;if(this._readonly===e)return false;this._readonly=e;this.opts.element.prop("readonly",e);this.enableInterface();return true},opened:function(){return this.container.hasClass("select2-dropdown-open")},positionDropdown:function(){var t=this.dropdown,i=this.container.offset(),s=this.container.outerHeight(false),n=this.container.outerWidth(false),a=t.outerHeight(false),o=e(window).scrollLeft()+e(window).width(),r=e(window).scrollTop()+e(window).height(),l=i.top+s,c=i.left,u=l+a<=r,f=i.top-a>=this.body().scrollTop(),d=t.outerWidth(false),p=c+d<=o,g=t.hasClass("select2-drop-above"),m,v,w,b;if(this.opts.dropdownAutoWidth){b=e(".select2-results",t)[0];t.addClass("select2-drop-auto-width");t.css("width","");d=t.outerWidth(false)+(b.scrollHeight===b.clientHeight?0:h.width);d>n?n=d:d=n;p=c+d<=o}else{this.container.removeClass("select2-drop-auto-width")}if(this.body().css("position")!=="static"){m=this.body().offset();l-=m.top;c-=m.left}if(g){v=true;if(!f&&u)v=false}else{v=false;if(!u&&f)v=true}if(!p){c=i.left+n-d}if(v){l=i.top-a;this.container.addClass("select2-drop-above");t.addClass("select2-drop-above")}else{this.container.removeClass("select2-drop-above");t.removeClass("select2-drop-above")}w=e.extend({top:l,left:c,width:n},N(this.opts.dropdownCss));t.css(w)},shouldOpen:function(){var t;if(this.opened())return false;if(this._enabled===false||this._readonly===true)return false;t=e.Event("select2-opening");this.opts.element.trigger(t);return!t.isDefaultPrevented()},clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above");this.dropdown.removeClass("select2-drop-above")},open:function(){if(!this.shouldOpen())return false;this.opening();return true},opening:function(){var t=this.containerId,i="scroll."+t,s="resize."+t,n="orientationchange."+t,a,o;this.container.addClass("select2-dropdown-open").addClass("select2-container-active");this.clearDropdownAlignmentPreference();if(this.dropdown[0]!==this.body().children().last()[0]){this.dropdown.detach().appendTo(this.body())}a=e("#select2-drop-mask");if(a.length==0){a=e(document.createElement("div"));a.attr("id","select2-drop-mask").attr("class","select2-drop-mask");a.hide();a.appendTo(this.body());a.on("mousedown touchstart click",function(t){var i=e("#select2-drop"),s;if(i.length>0){s=i.data("select2");if(s.opts.selectOnBlur){s.selectHighlighted({noFocus:true})}s.close();t.preventDefault();t.stopPropagation()}})}if(this.dropdown.prev()[0]!==a[0]){this.dropdown.before(a)}e("#select2-drop").removeAttr("id");this.dropdown.attr("id","select2-drop");o=l();a.css(o).show();this.dropdown.show();this.positionDropdown();this.dropdown.addClass("select2-drop-active");var r=this;this.container.parents().add(window).each(function(){e(this).on(s+" "+i+" "+n,function(t){var i=l();e("#select2-drop-mask").css(i);r.positionDropdown()})});function l(){return{width:Math.max(document.documentElement.scrollWidth,e(window).width()),height:Math.max(document.documentElement.scrollHeight,e(window).height())}}},close:function(){if(!this.opened())return;var t=this.containerId,i="scroll."+t,s="resize."+t,n="orientationchange."+t;this.container.parents().add(window).each(function(){e(this).off(i).off(s).off(n)});this.clearDropdownAlignmentPreference();e("#select2-drop-mask").hide();this.dropdown.removeAttr("id");this.dropdown.hide();this.container.removeClass("select2-dropdown-open");this.results.empty();this.clearSearch();this.search.removeClass("select2-active");this.opts.element.trigger(e.Event("select2-close"))},externalSearch:function(e){this.open();this.search.val(e);this.updateResults(false)},clearSearch:function(){},getMaximumSelectionSize:function(){return N(this.opts.maximumSelectionSize)},ensureHighlightVisible:function(){var t=this.results,i,s,n,a,o,r,l;s=this.highlight();if(s<0)return;if(s==0){t.scrollTop(0);return}i=this.findHighlightableChoices().find(".select2-result-label");n=e(i[s]);a=n.offset().top+n.outerHeight(true);if(s===i.length-1){l=t.find("li.select2-more-results");if(l.length>0){a=l.offset().top+l.outerHeight(true)}}o=t.offset().top+t.outerHeight(true);if(a>o){t.scrollTop(t.scrollTop()+(a-o))}r=n.offset().top-t.offset().top;if(r<0&&n.css("display")!="none"){t.scrollTop(t.scrollTop()+r)}},findHighlightableChoices:function(){return this.results.find(".select2-result-selectable:not(.select2-selected):not(.select2-disabled)")},moveHighlight:function(t){var i=this.findHighlightableChoices(),s=this.highlight();while(s>-1&&s<i.length){s+=t;var n=e(i[s]);if(n.hasClass("select2-result-selectable")&&!n.hasClass("select2-disabled")&&!n.hasClass("select2-selected")){this.highlight(s);break}}},highlight:function(t){var i=this.findHighlightableChoices(),s,n;if(arguments.length===0){return f(i.filter(".select2-highlighted")[0],i.get())}if(t>=i.length)t=i.length-1;if(t<0)t=0;this.results.find(".select2-highlighted").removeClass("select2-highlighted");s=e(i[t]);s.addClass("select2-highlighted");this.ensureHighlightVisible();n=s.data("select2-data");if(n){this.opts.element.trigger({type:"select2-highlight",val:this.id(n),choice:n})}},countSelectableResults:function(){return this.findHighlightableChoices().length},highlightUnderEvent:function(t){var i=e(t.target).closest(".select2-result-selectable");if(i.length>0&&!i.is(".select2-highlighted")){var s=this.findHighlightableChoices();this.highlight(s.index(i))}else if(i.length==0){this.results.find(".select2-highlighted").removeClass("select2-highlighted")}},loadMoreIfNeeded:function(){var e=this.results,t=e.find("li.select2-more-results"),i,s=-1,n=this.resultsPage+1,a=this,o=this.search.val(),r=this.context;if(t.length===0)return;i=t.offset().top-e.offset().top-e.height();if(i<=this.opts.loadMorePadding){t.addClass("select2-active");this.opts.query({element:this.opts.element,term:o,page:n,context:r,matcher:this.opts.matcher,callback:this.bind(function(i){if(!a.opened())return;a.opts.populateResults.call(this,e,i.results,{term:o,page:n,context:r});a.postprocessResults(i,false,false);if(i.more===true){t.detach().appendTo(e).text(a.opts.formatLoadMore(n+1));window.setTimeout(function(){a.loadMoreIfNeeded()},10)}else{t.remove()}a.positionDropdown();a.resultsPage=n;a.context=i.context})})}},tokenize:function(){},updateResults:function(i){var s=this.search,n=this.results,a=this.opts,o,r=this,l,c=s.val(),h=e.data(this.container,"select2-last-term");if(i!==true&&h&&p(c,h))return;e.data(this.container,"select2-last-term",c);if(i!==true&&(this.showSearchInput===false||!this.opened())){return}function u(){s.removeClass("select2-active");r.positionDropdown()}function f(e){n.html(e);u()}var d=this.getMaximumSelectionSize();if(d>=1){o=this.data();if(e.isArray(o)&&o.length>=d&&M(a.formatSelectionTooBig,"formatSelectionTooBig")){f("<li class='select2-selection-limit'>"+a.formatSelectionTooBig(d)+"</li>");return}}if(s.val().length<a.minimumInputLength){if(M(a.formatInputTooShort,"formatInputTooShort")){f("<li class='select2-no-results'>"+a.formatInputTooShort(s.val(),a.minimumInputLength)+"</li>")}else{f("")}if(i&&this.showSearch)this.showSearch(true);return}if(a.maximumInputLength&&s.val().length>a.maximumInputLength){
2if(M(a.formatInputTooLong,"formatInputTooLong")){f("<li class='select2-no-results'>"+a.formatInputTooLong(s.val(),a.maximumInputLength)+"</li>")}else{f("")}return}if(a.formatSearching&&this.findHighlightableChoices().length===0){f("<li class='select2-searching'>"+a.formatSearching()+"</li>")}s.addClass("select2-active");l=this.tokenize();if(l!=t&&l!=null){s.val(l)}this.resultsPage=1;a.query({element:a.element,term:s.val(),page:this.resultsPage,context:null,matcher:a.matcher,callback:this.bind(function(o){var l;if(!this.opened()){this.search.removeClass("select2-active");return}this.context=o.context===t?null:o.context;if(this.opts.createSearchChoice&&s.val()!==""){l=this.opts.createSearchChoice.call(r,s.val(),o.results);if(l!==t&&l!==null&&r.id(l)!==t&&r.id(l)!==null){if(e(o.results).filter(function(){return p(r.id(this),r.id(l))}).length===0){o.results.unshift(l)}}}if(o.results.length===0&&M(a.formatNoMatches,"formatNoMatches")){f("<li class='select2-no-results'>"+a.formatNoMatches(s.val())+"</li>");return}n.empty();r.opts.populateResults.call(this,n,o.results,{term:s.val(),page:this.resultsPage,context:null});if(o.more===true&&M(a.formatLoadMore,"formatLoadMore")){n.append("<li class='select2-more-results'>"+r.opts.escapeMarkup(a.formatLoadMore(this.resultsPage))+"</li>");window.setTimeout(function(){r.loadMoreIfNeeded()},10)}this.postprocessResults(o,i);u();this.opts.element.trigger({type:"select2-loaded",items:o})})})},cancel:function(){this.close()},blur:function(){if(this.opts.selectOnBlur)this.selectHighlighted({noFocus:true});this.close();this.container.removeClass("select2-container-active");if(this.search[0]===document.activeElement){this.search.blur()}this.clearSearch();this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){S(this.search)},selectHighlighted:function(e){var t=this.highlight(),i=this.results.find(".select2-highlighted"),s=i.closest(".select2-result").data("select2-data");if(s){this.highlight(t);this.onSelect(s,e)}else if(e&&e.noFocus){this.close()}},getPlaceholder:function(){var e;return this.opts.element.attr("placeholder")||this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")||this.opts.placeholder||((e=this.getPlaceholderOption())!==t?e.text():t)},getPlaceholderOption:function(){if(this.select){var e=this.select.children().first();if(this.opts.placeholderOption!==t){return this.opts.placeholderOption==="first"&&e||typeof this.opts.placeholderOption==="function"&&this.opts.placeholderOption(this.select)}else if(e.text()===""&&e.val()===""){return e}}},initContainerWidth:function(){function i(){var i,s,n,a,o;if(this.opts.width==="off"){return null}else if(this.opts.width==="element"){return this.opts.element.outerWidth(false)===0?"auto":this.opts.element.outerWidth(false)+"px"}else if(this.opts.width==="copy"||this.opts.width==="resolve"){i=this.opts.element.attr("style");if(i!==t){s=i.split(";");for(a=0,o=s.length;a<o;a=a+1){n=s[a].replace(/\s/g,"").match(/width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i);if(n!==null&&n.length>=1)return n[1]}}if(this.opts.width==="resolve"){i=this.opts.element.css("width");if(i.indexOf("%")>0)return i;return this.opts.element.outerWidth(false)===0?"auto":this.opts.element.outerWidth(false)+"px"}return null}else if(e.isFunction(this.opts.width)){return this.opts.width()}else{return this.opts.width}}var s=i.call(this);if(s!==null){this.container.css("width",s)}}});n=z(s,{createContainer:function(){var t=e(document.createElement("div")).attr({class:"select2-container"}).html(["<a href='javascript:void(0)' onclick='return false;' class='select2-choice' tabindex='-1'>"," <span class='select2-chosen'>&nbsp;</span><abbr class='select2-search-choice-close'></abbr>"," <span class='icon'>downarrowsmall<b></b></span>","</a>","<input class='select2-focusser select2-offscreen' type='text'/>","<div class='select2-drop select2-display-none'>"," <div class='select2-search'>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'/>"," </div>"," <ul class='select2-results'>"," </ul>","</div>"].join(""));return t},enableInterface:function(){if(this.parent.enableInterface.apply(this,arguments)){this.focusser.prop("disabled",!this.isInterfaceEnabled())}},opening:function(){var t,i,s;if(this.opts.minimumResultsForSearch>=0){this.showSearch(true)}this.parent.opening.apply(this,arguments);if(this.showSearchInput!==false){this.search.val(this.focusser.val())}this.search.focus();t=this.search.get(0);if(t.createTextRange){i=t.createTextRange();i.collapse(false);i.select()}else if(t.setSelectionRange){s=this.search.val().length;t.setSelectionRange(s,s)}this.focusser.prop("disabled",true).val("");this.updateResults(true);this.opts.element.trigger(e.Event("select2-open"))},close:function(){if(!this.opened())return;this.parent.close.apply(this,arguments);this.focusser.removeAttr("disabled");this.focusser.focus()},focus:function(){if(this.opened()){this.close()}else{this.focusser.removeAttr("disabled");this.focusser.focus()}},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments);this.focusser.removeAttr("disabled");this.focusser.focus()},initContainer:function(){var t,s=this.container,n=this.dropdown;if(this.opts.minimumResultsForSearch<0){this.showSearch(false)}else{this.showSearch(true)}this.selection=t=s.find(".select2-choice");this.focusser=s.find(".select2-focusser");this.focusser.attr("id","s2id_autogen"+o());e("label[for='"+this.opts.element.attr("id")+"']").attr("for",this.focusser.attr("id"));this.focusser.attr("tabindex",this.elementTabIndex);this.search.on("keydown",this.bind(function(e){if(!this.isInterfaceEnabled())return;if(e.which===i.PAGE_UP||e.which===i.PAGE_DOWN){E(e);return}switch(e.which){case i.UP:case i.DOWN:this.moveHighlight(e.which===i.UP?-1:1);E(e);return;case i.ENTER:this.selectHighlighted();E(e);return;case i.TAB:this.selectHighlighted({noFocus:true});return;case i.ESC:this.cancel(e);E(e);return}}));this.search.on("blur",this.bind(function(e){if(document.activeElement===this.body().get(0)){window.setTimeout(this.bind(function(){this.search.focus()}),0)}}));this.focusser.on("keydown",this.bind(function(e){if(!this.isInterfaceEnabled())return;if(e.which===i.TAB||i.isControl(e)||i.isFunctionKey(e)||e.which===i.ESC){return}if(this.opts.openOnEnter===false&&e.which===i.ENTER){E(e);return}if(e.which==i.DOWN||e.which==i.UP||e.which==i.ENTER&&this.opts.openOnEnter){if(e.altKey||e.ctrlKey||e.shiftKey||e.metaKey)return;this.open();E(e);return}if(e.which==i.DELETE||e.which==i.BACKSPACE){if(this.opts.allowClear){this.clear()}E(e);return}}));v(this.focusser);this.focusser.on("keyup-change input",this.bind(function(e){if(this.opts.minimumResultsForSearch>=0){e.stopPropagation();if(this.opened())return;this.open()}}));t.on("mousedown","abbr",this.bind(function(e){if(!this.isInterfaceEnabled())return;this.clear();T(e);this.close();this.selection.focus()}));t.on("mousedown",this.bind(function(t){if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(e.Event("select2-focus"))}if(this.opened()){this.close()}else if(this.isInterfaceEnabled()){this.open()}E(t)}));n.on("mousedown",this.bind(function(){this.search.focus()}));t.on("focus",this.bind(function(e){E(e)}));this.focusser.on("focus",this.bind(function(){if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(e.Event("select2-focus"))}this.container.addClass("select2-container-active")})).on("blur",this.bind(function(){if(!this.opened()){this.container.removeClass("select2-container-active");this.opts.element.trigger(e.Event("select2-blur"))}}));this.search.on("focus",this.bind(function(){if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(e.Event("select2-focus"))}this.container.addClass("select2-container-active")}));this.initContainerWidth();this.opts.element.addClass("select2-offscreen");this.setPlaceholder()},clear:function(e){var t=this.selection.data("select2-data");if(t){var i=this.getPlaceholderOption();this.opts.element.val(i?i.val():"");this.selection.find(".select2-chosen").empty();this.selection.removeData("select2-data");this.setPlaceholder();if(e!==false){this.opts.element.trigger({type:"select2-removed",val:this.id(t),choice:t});this.triggerChange({removed:t})}}},initSelection:function(){var e;if(this.isPlaceholderOptionSelected()){this.updateSelection([]);this.close();this.setPlaceholder()}else{var i=this;this.opts.initSelection.call(null,this.opts.element,function(e){if(e!==t&&e!==null){i.updateSelection(e);i.close();i.setPlaceholder()}})}},isPlaceholderOptionSelected:function(){var e;return(e=this.getPlaceholderOption())!==t&&e.is(":selected")||this.opts.element.val()===""||this.opts.element.val()===t||this.opts.element.val()===null},prepareOpts:function(){var t=this.parent.prepareOpts.apply(this,arguments),i=this;if(t.element.get(0).tagName.toLowerCase()==="select"){t.initSelection=function(e,t){var s=e.find(":selected");t(i.optionToData(s))}}else if("data"in t){t.initSelection=t.initSelection||function(i,s){var n=i.val();var a=null;t.query({matcher:function(e,i,s){var o=p(n,t.id(s));if(o){a=s}return o},callback:!e.isFunction(s)?e.noop:function(){s(a)}})}}return t},getPlaceholder:function(){if(this.select){if(this.getPlaceholderOption()===t){return t}}return this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var e=this.getPlaceholder();if(this.isPlaceholderOptionSelected()&&e!==t){if(this.select&&this.getPlaceholderOption()===t)return;this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(e));this.selection.addClass("select2-default");this.container.removeClass("select2-allowclear")}},postprocessResults:function(e,t,i){var s=0,n=this,a=true;this.findHighlightableChoices().each2(function(e,t){if(p(n.id(t.data("select2-data")),n.opts.element.val())){s=e;return false}});if(i!==false){if(t===true&&s>=0){this.highlight(s)}else{this.highlight(0)}}if(t===true){var o=this.opts.minimumResultsForSearch;if(o>=0){this.showSearch(j(e.results)>=o)}}},showSearch:function(t){if(this.showSearchInput===t)return;this.showSearchInput=t;this.dropdown.find(".select2-search").toggleClass("select2-search-hidden",!t);this.dropdown.find(".select2-search").toggleClass("select2-offscreen",!t);e(this.dropdown,this.container).toggleClass("select2-with-searchbox",t)},onSelect:function(e,t){if(!this.triggerSelect(e)){return}var i=this.opts.element.val(),s=this.data();this.opts.element.val(this.id(e));this.updateSelection(e);this.opts.element.trigger({type:"select2-selected",val:this.id(e),choice:e});this.close();if(!t||!t.noFocus)this.selection.focus();if(!p(i,this.id(e))){this.triggerChange({added:e,removed:s})}},updateSelection:function(e){var i=this.selection.find(".select2-chosen"),s,n;this.selection.data("select2-data",e);i.empty();s=this.opts.formatSelection(e,i,this.opts.escapeMarkup);if(s!==t){i.append(s)}n=this.opts.formatSelectionCssClass(e,i);if(n!==t){i.addClass(n)}this.selection.removeClass("select2-default");if(this.opts.allowClear&&this.getPlaceholder()!==t){this.container.addClass("select2-allowclear")}},val:function(){var e,i=false,s=null,n=this,a=this.data();if(arguments.length===0){return this.opts.element.val()}e=arguments[0];if(arguments.length>1){i=arguments[1]}if(this.select){this.select.val(e).find(":selected").each2(function(e,t){s=n.optionToData(t);return false});this.updateSelection(s);this.setPlaceholder();if(i){this.triggerChange({added:s,removed:a})}}else{if(!e&&e!==0){this.clear(i);return}if(this.opts.initSelection===t){throw new Error("cannot call val() if initSelection() is not defined")}this.opts.element.val(e);this.opts.initSelection(this.opts.element,function(e){n.opts.element.val(!e?"":n.id(e));n.updateSelection(e);n.setPlaceholder();if(i){n.triggerChange({added:e,removed:a})}})}},clearSearch:function(){this.search.val("");this.focusser.val("")},data:function(e,i){var s;if(arguments.length===0){s=this.selection.data("select2-data");if(s==t)s=null;return s}else{if(!e||e===""){this.clear(i)}else{s=this.data();this.opts.element.val(!e?"":this.id(e));this.updateSelection(e);if(i){this.triggerChange({added:e,removed:s})}}}}});a=z(s,{createContainer:function(){var t=e(document.createElement("div")).attr({class:"select2-container select2-container-multi"}).html(["<ul class='select2-choices'>"," <li class='select2-search-field'>"," <input type='text' autocomplete='off' autocorrect='off' autocapitilize='off' spellcheck='false' class='select2-input'>"," </li>","</ul>","<div class='select2-drop select2-drop-multi select2-display-none'>"," <ul class='select2-results'>"," </ul>","</div>"].join(""));return t},prepareOpts:function(){var t=this.parent.prepareOpts.apply(this,arguments),i=this;if(t.element.get(0).tagName.toLowerCase()==="select"){t.initSelection=function(e,t){var s=[];e.find(":selected").each2(function(e,t){s.push(i.optionToData(t))});t(s)}}else if("data"in t){t.initSelection=t.initSelection||function(i,s){var n=g(i.val(),t.separator);var a=[];t.query({matcher:function(i,s,o){var r=e.grep(n,function(e){return p(e,t.id(o))}).length;if(r){a.push(o)}return r},callback:!e.isFunction(s)?e.noop:function(){var e=[];for(var i=0;i<n.length;i++){var o=n[i];for(var r=0;r<a.length;r++){var l=a[r];if(p(o,t.id(l))){e.push(l);a.splice(r,1);break}}}s(e)}})}}return t},selectChoice:function(e){var t=this.container.find(".select2-search-choice-focus");if(t.length&&e&&e[0]==t[0]){}else{if(t.length){this.opts.element.trigger("choice-deselected",t)}t.removeClass("select2-search-choice-focus");if(e&&e.length){this.close();e.addClass("select2-search-choice-focus");this.opts.element.trigger("choice-selected",e)}}},initContainer:function(){var t=".select2-choices",s;this.searchContainer=this.container.find(".select2-search-field");this.selection=s=this.container.find(t);var n=this;this.selection.on("mousedown",".select2-search-choice",function(t){n.search[0].focus();n.selectChoice(e(this))});this.search.attr("id","s2id_autogen"+o());e("label[for='"+this.opts.element.attr("id")+"']").attr("for",this.search.attr("id"));this.search.on("input paste",this.bind(function(){if(!this.isInterfaceEnabled())return;if(!this.opened()){this.open()}}));this.search.attr("tabindex",this.elementTabIndex);this.keydowns=0;this.search.on("keydown",this.bind(function(e){if(!this.isInterfaceEnabled())return;++this.keydowns;var t=s.find(".select2-search-choice-focus");var n=t.prev(".select2-search-choice:not(.select2-locked)");var a=t.next(".select2-search-choice:not(.select2-locked)");var o=x(this.search);if(t.length&&(e.which==i.LEFT||e.which==i.RIGHT||e.which==i.BACKSPACE||e.which==i.DELETE||e.which==i.ENTER)){var r=t;if(e.which==i.LEFT&&n.length){r=n}else if(e.which==i.RIGHT){r=a.length?a:null}else if(e.which===i.BACKSPACE){this.unselect(t.first());this.search.width(10);r=n.length?n:a}else if(e.which==i.DELETE){this.unselect(t.first());this.search.width(10);r=a.length?a:null}else if(e.which==i.ENTER){r=null}this.selectChoice(r);E(e);if(!r||!r.length){this.open()}return}else if((e.which===i.BACKSPACE&&this.keydowns==1||e.which==i.LEFT)&&(o.offset==0&&!o.length)){this.selectChoice(s.find(".select2-search-choice:not(.select2-locked)").last());E(e);return}else{this.selectChoice(null)}if(this.opened()){switch(e.which){case i.UP:case i.DOWN:this.moveHighlight(e.which===i.UP?-1:1);E(e);return;case i.ENTER:this.selectHighlighted();E(e);return;case i.TAB:this.selectHighlighted({noFocus:true});this.close();return;case i.ESC:this.cancel(e);E(e);return}}if(e.which===i.TAB||i.isControl(e)||i.isFunctionKey(e)||e.which===i.BACKSPACE||e.which===i.ESC){return}if(e.which===i.ENTER){if(this.opts.openOnEnter===false){return}else if(e.altKey||e.ctrlKey||e.shiftKey||e.metaKey){return}}this.open();if(e.which===i.PAGE_UP||e.which===i.PAGE_DOWN){E(e)}if(e.which===i.ENTER){E(e)}}));this.search.on("keyup",this.bind(function(e){this.keydowns=0;this.resizeSearch()}));this.search.on("blur",this.bind(function(t){this.container.removeClass("select2-container-active");this.search.removeClass("select2-focused");this.selectChoice(null);if(!this.opened())this.clearSearch();t.stopImmediatePropagation();this.opts.element.trigger(e.Event("select2-blur"))}));this.container.on("click",t,this.bind(function(t){if(!this.isInterfaceEnabled())return;if(e(t.target).closest(".select2-search-choice").length>0){return}this.selectChoice(null);this.clearPlaceholder();if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(e.Event("select2-focus"))}this.open();this.focusSearch();t.preventDefault()}));this.container.on("focus",t,this.bind(function(){if(!this.isInterfaceEnabled())return;if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(e.Event("select2-focus"))}this.container.addClass("select2-container-active");this.dropdown.addClass("select2-drop-active");this.clearPlaceholder()}));this.initContainerWidth();this.opts.element.addClass("select2-offscreen");this.clearSearch()},enableInterface:function(){if(this.parent.enableInterface.apply(this,arguments)){this.search.prop("disabled",!this.isInterfaceEnabled())}},initSelection:function(){var e;if(this.opts.element.val()===""&&this.opts.element.text()===""){this.updateSelection([]);this.close();this.clearSearch()}if(this.select||this.opts.element.val()!==""){var i=this;this.opts.initSelection.call(null,this.opts.element,function(e){if(e!==t&&e!==null){i.updateSelection(e);i.close();i.clearSearch()}})}},clearSearch:function(){var e=this.getPlaceholder(),i=this.getMaxSearchWidth();if(e!==t&&this.getVal().length===0&&this.search.hasClass("select2-focused")===false){this.search.val(e).addClass("select2-default");this.search.width(i>0?i:this.container.css("width"))}else{this.search.val("").width(10)}},clearPlaceholder:function(){if(this.search.hasClass("select2-default")){this.search.val("").removeClass("select2-default")}},opening:function(){this.clearPlaceholder();this.resizeSearch();this.parent.opening.apply(this,arguments);this.focusSearch();this.updateResults(true);this.search.focus();this.opts.element.trigger(e.Event("select2-open"))},close:function(){if(!this.opened())return;this.parent.close.apply(this,arguments)},focus:function(){this.close();this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(t){var i=[],s=[],n=this;e(t).each(function(){if(f(n.id(this),i)<0){i.push(n.id(this));s.push(this)}});t=s;this.selection.find(".select2-search-choice").remove();e(t).each(function(){n.addSelectedChoice(this)});n.postprocessResults()},tokenize:function(){var e=this.search.val();e=this.opts.tokenizer.call(this,e,this.data(),this.bind(this.onSelect),this.opts);if(e!=null&&e!=t){this.search.val(e);if(e.length>0){this.open()}}},onSelect:function(e,t){if(!this.triggerSelect(e)){return}this.addSelectedChoice(e);this.opts.element.trigger({type:"selected",val:this.id(e),choice:e});if(this.select||!this.opts.closeOnSelect)this.postprocessResults();if(this.opts.closeOnSelect){this.close();this.search.width(10)}else{if(this.countSelectableResults()>0){this.search.width(10);this.resizeSearch();if(this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()){this.updateResults(true)}this.positionDropdown()}else{this.close();this.search.width(10)}}this.triggerChange({added:e});if(!t||!t.noFocus)this.focusSearch()},cancel:function(){this.close();this.focusSearch()},addSelectedChoice:function(i){var s=!i.locked,n=e("<li class='select2-search-choice'>"+" <div></div>"+" <a href='#' onclick='return false;' class='select2-search-choice-close' tabindex='-1'></a>"+"</li>"),a=e("<li class='select2-search-choice select2-locked'>"+"<div></div>"+"</li>");var o=s?n:a,r=this.id(i),l=this.getVal(),c,h;c=this.opts.formatSelection(i,o.find("div"),this.opts.escapeMarkup);if(c!=t){o.find("div").replaceWith("<div>"+c+"</div>")}h=this.opts.formatSelectionCssClass(i,o.find("div"));if(h!=t){o.addClass(h)}if(s){o.find(".select2-search-choice-close").on("mousedown",E).on("click dblclick",this.bind(function(t){if(!this.isInterfaceEnabled())return;e(t.target).closest(".select2-search-choice").fadeOut("fast",this.bind(function(){this.unselect(e(t.target));this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");this.close();this.focusSearch()})).dequeue();E(t)})).on("focus",this.bind(function(){if(!this.isInterfaceEnabled())return;this.container.addClass("select2-container-active");this.dropdown.addClass("select2-drop-active")}))}o.data("select2-data",i);o.insertBefore(this.searchContainer);l.push(r);this.setVal(l)},unselect:function(e){var t=this.getVal(),i,s;e=e.closest(".select2-search-choice");if(e.length===0){throw"Invalid argument: "+e+". Must be .select2-search-choice"}i=e.data("select2-data");if(!i){return}s=f(this.id(i),t);if(s>=0){t.splice(s,1);this.setVal(t);if(this.select)this.postprocessResults()}e.remove();this.opts.element.trigger({type:"removed",val:this.id(i),choice:i});this.triggerChange({removed:i})},postprocessResults:function(e,t,i){var s=this.getVal(),n=this.results.find(".select2-result"),a=this.results.find(".select2-result-with-children"),o=this;n.each2(function(e,t){var i=o.id(t.data("select2-data"));if(f(i,s)>=0){t.addClass("select2-selected");t.find(".select2-result-selectable").addClass("select2-selected")}});a.each2(function(e,t){if(!t.is(".select2-result-selectable")&&t.find(".select2-result-selectable:not(.select2-selected)").length===0){t.addClass("select2-selected")}});if(this.highlight()==-1&&i!==false){o.highlight(0)}if(!this.opts.createSearchChoice&&!n.filter(".select2-result:not(.select2-selected)").length>0){if(!e||e&&!e.more&&this.results.find(".select2-no-results").length===0){if(M(o.opts.formatNoMatches,"formatNoMatches")){this.results.append("<li class='select2-no-results'>"+o.opts.formatNoMatches(o.search.val())+"</li>")}}}},getMaxSearchWidth:function(){return this.selection.width()-m(this.search)},resizeSearch:function(){var e,t,i,s,n,a=m(this.search);e=k(this.search)+10;t=this.search.offset().left;i=this.selection.width();s=this.selection.offset().left;n=i-(t-s)-a;if(n<e){n=i-a}if(n<40){n=i-a}if(n<=0){n=e}this.search.width(n)},getVal:function(){var e;if(this.select){e=this.select.val();return e===null?[]:e}else{e=this.opts.element.val();return g(e,this.opts.separator)}},setVal:function(t){var i;if(this.select){this.select.val(t)}else{i=[];e(t).each(function(){if(f(this,i)<0)i.push(this)});this.opts.element.val(i.length===0?"":i.join(this.opts.separator))}},buildChangeDetails:function(e,t){var t=t.slice(0),e=e.slice(0);for(var i=0;i<t.length;i++){for(var s=0;s<e.length;s++){if(p(this.opts.id(t[i]),this.opts.id(e[s]))){t.splice(i,1);i--;e.splice(s,1);s--}}}return{added:t,removed:e}},val:function(i,s){var n,a=this,o;if(arguments.length===0){return this.getVal()}n=this.data();if(!n.length)n=[];if(!i&&i!==0){this.opts.element.val("");this.updateSelection([]);this.clearSearch();if(s){this.triggerChange({added:this.data(),removed:n})}return}this.setVal(i);if(this.select){this.opts.initSelection(this.select,this.bind(this.updateSelection));if(s){this.triggerChange(this.buildChangeDetails(n,this.data()))}}else{if(this.opts.initSelection===t){throw new Error("val() cannot be called if initSelection() is not defined")}this.opts.initSelection(this.opts.element,function(t){var i=e.map(t,a.id);a.setVal(i);a.updateSelection(t);a.clearSearch();if(s){a.triggerChange(this.buildChangeDetails(n,this.data()))}})}this.clearSearch()},onSortStart:function(){if(this.select){throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.")}this.search.width(0);this.searchContainer.hide()},onSortEnd:function(){var t=[],i=this;this.searchContainer.show();this.searchContainer.appendTo(this.searchContainer.parent());this.resizeSearch();this.selection.find(".select2-search-choice").each(function(){t.push(i.opts.id(e(this).data("select2-data")))});this.setVal(t);this.triggerChange()},data:function(t,i){var s=this,n,a;if(arguments.length===0){return this.selection.find(".select2-search-choice").map(function(){return e(this).data("select2-data")}).get()}else{a=this.data();if(!t){t=[]}n=e.map(t,function(e){return s.opts.id(e)});this.setVal(n);this.updateSelection(t);this.clearSearch();if(i){this.triggerChange(this.buildChangeDetails(a,this.data()))}}}});e.fn.select2=function(){var i=Array.prototype.slice.call(arguments,0),s,o,r,l,c,h=["val","destroy","opened","open","close","focus","isFocused","container","dropdown","onSortStart","onSortEnd","enable","readonly","positionDropdown","data","search"],u=["val","opened","isFocused","container","data"],d={search:"externalSearch"};this.each(function(){if(i.length===0||typeof i[0]==="object"){s=i.length===0?{}:e.extend({},i[0]);s.element=e(this);if(s.element.get(0).tagName.toLowerCase()==="select"){c=s.element.prop("multiple")}else{c=s.multiple||false;if("tags"in s){s.multiple=c=true}}o=c?new a:new n;o.init(s)}else if(typeof i[0]==="string"){if(f(i[0],h)<0){throw"Unknown method: "+i[0]}l=t;o=e(this).data("select2");if(o===t)return;r=i[0];if(r==="container"){l=o.container}else if(r==="dropdown"){l=o.dropdown}else{if(d[r])r=d[r];l=o[r].apply(o,i.slice(1))}if(f(i[0],u)>=0){return false}}else{throw"Invalid arguments to select2 plugin: "+i}});return l===t?this:l};e.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:true,openOnEnter:true,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(e,t,i,s){var n=[];O(e.text,i.term,n,s);return n.join("")},formatSelection:function(e,i,s){return e?s(e.text):t},sortResults:function(e,t,i){return e},formatResultCssClass:function(e){return t},formatSelectionCssClass:function(e,i){return t},formatNoMatches:function(){return"No matches found"},formatInputTooShort:function(e,t){var i=t-e.length;return"Please enter "+i+" more character"+(i==1?"":"s")},formatInputTooLong:function(e,t){var i=e.length-t;return"Please delete "+i+" character"+(i==1?"":"s")},formatSelectionTooBig:function(e){return"You can only select "+e+" item"+(e==1?"":"s")},formatLoadMore:function(e){return"Loading more results..."},formatSearching:function(){return"Searching..."},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(e){return e.id},matcher:function(e,t){return(""+t).toUpperCase().indexOf((""+e).toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:H,escapeMarkup:P,blurOnChange:false,selectOnBlur:false,adaptContainerCssClass:function(e){return e},adaptDropdownCssClass:function(e){return null}};e.fn.select2.ajaxDefaults={transport:e.ajax,params:{type:"GET",cache:false,dataType:"json"}};window.Select2={query:{ajax:A,local:R,tags:D},util:{debounce:b,markMatch:O,escapeMarkup:P},class:{abstract:s,single:n,multi:a}}})(e)}).call(t,i(1))},246:function(e,t,i){var s,n,a;(function(o){if(true){!(n=[i(1)],s=o,a=typeof s==="function"?s.apply(t,n):s,a!==undefined&&(e.exports=a))}else{o(window.jQuery)}})(function(e){if(typeof e.fn.wSpinner==="undefined"){e.fn.extend({wSpinner:function(t){var i;var s,n,a,o;var r;var l={className:"wsite-spinner",height:undefined,min:1,max:Infinity,theme:"light",interval:1};t=e.extend(l,t);this.each(function(t,s){i=e(s);if(s.nodeName==="INPUT"){c()}});function c(){if(t.incrementElement||t.decrementElement){a=e(t.incrementElement);o=e(t.decrementElement)}else{s=e('<div class="'+t.className+'" />').addClass(t.theme);n=e('<div class="'+t.className+'-controls" />');a=e('<a class="'+t.className+'-up" />');o=e('<a class="'+t.className+'-down" />');n.append(a,o);i.wrap(s).addClass(t.className+"-input").parent().append(n).css({height:t.height||"auto"})}i.on({keypress:function(e){var t=e.keyCode||e.which;if(t>47&&t<58||t===8||t===9||t===37||t===39||e.metaKey){return true}return false},keydown:function(t){var i=e(t.currentTarget);if(t.which===38){u(i)}else if(t.which===40){f(i)}},blur:function(e){var t=e.currentTarget;if(t.getAttribute("data-max")&&parseInt(t.value)>parseInt(t.getAttribute("data-max"))){t.value=t.getAttribute("data-max")}else if(t.value===""){t.value=1}},change:function(t){var i=e(t.currentTarget);if(p(i)){d()}}});a.on({click:function(e){clearInterval(r);u(i)},mousedown:function(t){e(t.currentTarget).addClass("wsite-active");r=setInterval(function(){u(i)},250);t.preventDefault()},mouseup:function(e){h(e.currentTarget)},mouseout:function(e){h(e.currentTarget)}});o.on({click:function(e){clearInterval(r);f(i)},mousedown:function(t){e(t.currentTarget).addClass("wsite-active");r=setInterval(function(){f(i)},250);t.preventDefault()},mouseup:function(e){h(e.currentTarget)},mouseout:function(e){h(e.currentTarget)}})}function h(t){e(t).removeClass("wsite-active");clearInterval(r)}function u(e){if(!e.is(":disabled")){var i=parseInt(e.val());if(isNaN(i)&&t.defaultVal){i=t.defaultVal}var s=i+t.interval;e.val(Math.min(s,parseInt(e.attr("data-max"))||t.max)).focus();d()}}function f(e){if(!e.is(":disabled")){var i=parseInt(e.val());if(isNaN(i)&&t.defaultVal){i=t.defaultVal}var s=i-t.interval;e.val(Math.max(s,parseInt(e.data("data-min"))||t.min)).focus();d()}}function d(){if(t.onChange){t.onChange.call(i[0])}}function p(e){if(e.is(":disabled")){return false}var i=parseInt(e.val());if(isNaN(i)){if(t.defaultVal!=undefined){i=t.defaultVal}else{i=t.min}e.val(i)}else if(i<parseInt(e.attr("data-min")||t.min)){e.val(t.min)}else if(i>parseInt(e.attr("data-max")||t.max)){e.val(t.max)}return true}return this},wControlSpinner:function(t){t=t||{};this.each(function(){var i=e(this);var s=e.extend({},t);s.incrementElement=i.parent().find(".spinner-inc");s.decrementElement=i.parent().find(".spinner-dec");s.defaultVal=14;i.wSpinner(s)})}})}})},249:function(e,t,i){var s=i(1);(function(e){var t;e.event.fix=function(e){return function(t){t=e.apply(this,arguments);if(t.type.indexOf("copy")===0||t.type.indexOf("paste")===0){t.clipboardData=t.originalEvent.clipboardData}return t}}(e.event.fix);t={callback:e.noop,matchType:/image.*/};return e.fn.pasteImageReader=function(i){if(typeof i==="function"){i={callback:i}}i=e.extend({},t,i);return this.each(function(){var t,s;s=this;t=e(this);return t.bind("paste",function(e){var t,n;n=false;t=e.clipboardData?e.clipboardData:false;if(t===false){return}return Array.prototype.forEach.call(t.types,function(e,a){var o,r;if(n){return}if(e.match(i.matchType)||t.items[a].type.match(i.matchType)){o=t.items[a].getAsFile();r=new FileReader;r.onload=function(e){return i.callback.call(s,{dataURL:e.target.result,event:e,file:o,name:o.name})};r.readAsDataURL(o);return n=true}})})})}})(s)}});
Note: See TracBrowser for help on using the repository browser.