diff --git a/README b/README index 6bb89b3..be963ad 100644 --- a/README +++ b/README @@ -49,6 +49,12 @@ Special Thanks Changelog Summary ================= +### v3.3.1 + +* Addressed issue[#30](https://github.com/applegrew/django-select2/issues/30). +* Merged pull request[#31](https://github.com/applegrew/django-select2/issues/31). +* Added `light` parameter to `import_django_select2_js`, `import_django_select2_css` and `import_django_select2_js_css` template tags. Please see doc's "Getting Started", for more details. + ### v3.3.0 * Updated Select2 to version 3.3.1. diff --git a/README.md b/README.md index 6bb89b3..be963ad 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,12 @@ Special Thanks Changelog Summary ================= +### v3.3.1 + +* Addressed issue[#30](https://github.com/applegrew/django-select2/issues/30). +* Merged pull request[#31](https://github.com/applegrew/django-select2/issues/31). +* Added `light` parameter to `import_django_select2_js`, `import_django_select2_css` and `import_django_select2_js_css` template tags. Please see doc's "Getting Started", for more details. + ### v3.3.0 * Updated Select2 to version 3.3.1. diff --git a/django_select2/__init__.py b/django_select2/__init__.py index 8c2246b..d97069f 100644 --- a/django_select2/__init__.py +++ b/django_select2/__init__.py @@ -74,7 +74,7 @@ The view - `Select2View`, exposed here is meant to be used with 'Heavy' fields a """ -__version__ = "3.3.0" +__version__ = "3.3.1" __RENDER_SELECT2_STATICS = False __ENABLE_MULTI_PROCESS_SUPPORT = False diff --git a/django_select2/static/css/extra.css b/django_select2/static/css/extra.css index c49c77e..771b130 100644 --- a/django_select2/static/css/extra.css +++ b/django_select2/static/css/extra.css @@ -6,4 +6,4 @@ } .select2-container.select2-container-multi { width: 300px; -} \ No newline at end of file +} diff --git a/django_select2/static/css/select2.min.css b/django_select2/static/css/select2.min.css new file mode 100644 index 0000000..78de953 --- /dev/null +++ b/django_select2/static/css/select2.min.css @@ -0,0 +1 @@ +.select2-container{position:relative;display:inline-block;zoom:1;*display:inline;vertical-align:top}.select2-container,.select2-drop,.select2-search,.select2-search input{-webkit-box-sizing:border-box;-khtml-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.select2-container .select2-choice{display:block;height:26px;padding:0 0 0 8px;overflow:hidden;position:relative;border:1px solid #aaa;white-space:nowrap;line-height:26px;color:#444;text-decoration:none;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-color:#fff;background-image:-webkit-gradient(linear,left bottom,left top,color-stop(0,#eee),color-stop(0.5,white));background-image:-webkit-linear-gradient(center bottom,#eee 0,white 50%);background-image:-moz-linear-gradient(center bottom,#eee 0,white 50%);background-image:-o-linear-gradient(bottom,#eee 0,#fff 50%);background-image:-ms-linear-gradient(top,#fff 0,#eee 50%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff',endColorstr = '#eeeeee',GradientType = 0);background-image:linear-gradient(top,#fff 0,#eee 50%)}.select2-container.select2-drop-above .select2-choice{border-bottom-color:#aaa;-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px;background-image:-webkit-gradient(linear,left bottom,left top,color-stop(0,#eee),color-stop(0.9,white));background-image:-webkit-linear-gradient(center bottom,#eee 0,white 90%);background-image:-moz-linear-gradient(center bottom,#eee 0,white 90%);background-image:-o-linear-gradient(bottom,#eee 0,white 90%);background-image:-ms-linear-gradient(top,#eee 0,#fff 90%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff',endColorstr='#eeeeee',GradientType=0);background-image:linear-gradient(top,#eee 0,#fff 90%)}.select2-container .select2-choice span{margin-right:26px;display:block;overflow:hidden;white-space:nowrap;-ms-text-overflow:ellipsis;-o-text-overflow:ellipsis;text-overflow:ellipsis}.select2-container .select2-choice abbr{display:block;width:12px;height:12px;position:absolute;right:26px;top:8px;font-size:1px;text-decoration:none;border:0;background:url('select2.png') right top no-repeat;cursor:pointer;outline:0}.select2-container .select2-choice abbr:hover{background-position:right -11px;cursor:pointer}.select2-drop-mask{position:absolute;left:0;top:0;z-index:9998;opacity:0}.select2-drop{width:100%;margin-top:-1px;position:absolute;z-index:9999;top:100%;background:#fff;color:#000;border:1px solid #aaa;border-top:0;-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px;-webkit-box-shadow:0 4px 5px rgba(0,0,0,.15);-moz-box-shadow:0 4px 5px rgba(0,0,0,.15);box-shadow:0 4px 5px rgba(0,0,0,.15)}.select2-drop.select2-drop-above{margin-top:1px;border-top:1px solid #aaa;border-bottom:0;-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0;-webkit-box-shadow:0 -4px 5px rgba(0,0,0,.15);-moz-box-shadow:0 -4px 5px rgba(0,0,0,.15);box-shadow:0 -4px 5px rgba(0,0,0,.15)}.select2-container .select2-choice div{display:block;width:18px;height:100%;position:absolute;right:0;top:0;border-left:1px solid #aaa;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0;-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;background:#ccc;background-image:-webkit-gradient(linear,left bottom,left top,color-stop(0,#ccc),color-stop(0.6,#eee));background-image:-webkit-linear-gradient(center bottom,#ccc 0,#eee 60%);background-image:-moz-linear-gradient(center bottom,#ccc 0,#eee 60%);background-image:-o-linear-gradient(bottom,#ccc 0,#eee 60%);background-image:-ms-linear-gradient(top,#ccc 0,#eee 60%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee',endColorstr = '#cccccc',GradientType = 0);background-image:linear-gradient(top,#ccc 0,#eee 60%)}.select2-container .select2-choice div b{display:block;width:100%;height:100%;background:url('select2.png') no-repeat 0 1px}.select2-search{display:inline-block;width:100%;min-height:26px;margin:0;padding-left:4px;padding-right:4px;position:relative;z-index:10000;white-space:nowrap}.select2-search-hidden{display:block;position:absolute;left:-10000px}.select2-search input{width:100%;height:auto!important;min-height:26px;padding:4px 20px 4px 5px;margin:0;outline:0;font-family:sans-serif;font-size:1em;border:1px solid #aaa;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;background:#fff url('select2.png') no-repeat 100% -22px;background:url('select2.png') no-repeat 100% -22px,-webkit-gradient(linear,left bottom,left top,color-stop(0.85,white),color-stop(0.99,#eee));background:url('select2.png') no-repeat 100% -22px,-webkit-linear-gradient(center bottom,white 85%,#eee 99%);background:url('select2.png') no-repeat 100% -22px,-moz-linear-gradient(center bottom,white 85%,#eee 99%);background:url('select2.png') no-repeat 100% -22px,-o-linear-gradient(bottom,white 85%,#eee 99%);background:url('select2.png') no-repeat 100% -22px,-ms-linear-gradient(top,#fff 85%,#eee 99%);background:url('select2.png') no-repeat 100% -22px,linear-gradient(top,#fff 85%,#eee 99%)}.select2-drop.select2-drop-above .select2-search input{margin-top:4px}.select2-search input.select2-active{background:#fff url('select2-spinner.gif') no-repeat 100%;background:url('select2-spinner.gif') no-repeat 100%,-webkit-gradient(linear,left bottom,left top,color-stop(0.85,white),color-stop(0.99,#eee));background:url('select2-spinner.gif') no-repeat 100%,-webkit-linear-gradient(center bottom,white 85%,#eee 99%);background:url('select2-spinner.gif') no-repeat 100%,-moz-linear-gradient(center bottom,white 85%,#eee 99%);background:url('select2-spinner.gif') no-repeat 100%,-o-linear-gradient(bottom,white 85%,#eee 99%);background:url('select2-spinner.gif') no-repeat 100%,-ms-linear-gradient(top,#fff 85%,#eee 99%);background:url('select2-spinner.gif') no-repeat 100%,linear-gradient(top,#fff 85%,#eee 99%)}.select2-container-active .select2-choice,.select2-container-active .select2-choices{border:1px solid #5897fb;outline:0;-webkit-box-shadow:0 0 5px rgba(0,0,0,.3);-moz-box-shadow:0 0 5px rgba(0,0,0,.3);box-shadow:0 0 5px rgba(0,0,0,.3)}.select2-dropdown-open .select2-choice{border-bottom-color:transparent;-webkit-box-shadow:0 1px 0 #fff inset;-moz-box-shadow:0 1px 0 #fff inset;box-shadow:0 1px 0 #fff inset;-webkit-border-bottom-left-radius:0;-moz-border-radius-bottomleft:0;border-bottom-left-radius:0;-webkit-border-bottom-right-radius:0;-moz-border-radius-bottomright:0;border-bottom-right-radius:0;background-color:#eee;background-image:-webkit-gradient(linear,left bottom,left top,color-stop(0,white),color-stop(0.5,#eee));background-image:-webkit-linear-gradient(center bottom,white 0,#eee 50%);background-image:-moz-linear-gradient(center bottom,white 0,#eee 50%);background-image:-o-linear-gradient(bottom,white 0,#eee 50%);background-image:-ms-linear-gradient(top,#fff 0,#eee 50%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee',endColorstr='#ffffff',GradientType=0);background-image:linear-gradient(top,#fff 0,#eee 50%)}.select2-dropdown-open .select2-choice div{background:transparent;border-left:none;filter:none}.select2-dropdown-open .select2-choice div b{background-position:-18px 1px}.select2-results{max-height:200px;padding:0 0 0 4px;margin:4px 4px 4px 0;position:relative;overflow-x:hidden;overflow-y:auto;-webkit-tap-highlight-color:rgba(0,0,0,0)}.select2-results ul.select2-result-sub{margin:0}.select2-results ul.select2-result-sub>li .select2-result-label{padding-left:20px}.select2-results ul.select2-result-sub ul.select2-result-sub>li .select2-result-label{padding-left:40px}.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub>li .select2-result-label{padding-left:60px}.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub>li .select2-result-label{padding-left:80px}.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub>li .select2-result-label{padding-left:100px}.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub>li .select2-result-label{padding-left:110px}.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub>li .select2-result-label{padding-left:120px}.select2-results li{list-style:none;display:list-item;background-image:none}.select2-results li.select2-result-with-children>.select2-result-label{font-weight:bold}.select2-results .select2-result-label{padding:3px 7px 4px;margin:0;cursor:pointer;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.select2-results .select2-highlighted{background:#3875d7;color:#fff}.select2-results li em{background:#feffde;font-style:normal}.select2-results .select2-highlighted em{background:transparent}.select2-results .select2-highlighted ul{background:white;color:#000}.select2-results .select2-no-results,.select2-results .select2-searching,.select2-results .select2-selection-limit{background:#f4f4f4;display:list-item}.select2-results .select2-disabled.select2-highlighted{color:#666;background:#f4f4f4;display:list-item;cursor:default}.select2-results .select2-disabled{background:#f4f4f4;display:list-item;cursor:default}.select2-results .select2-selected{display:none}.select2-more-results.select2-active{background:#f4f4f4 url('select2-spinner.gif') no-repeat 100%}.select2-more-results{background:#f4f4f4;display:list-item}.select2-container.select2-container-disabled .select2-choice{background-color:#f4f4f4;background-image:none;border:1px solid #ddd;cursor:default}.select2-container.select2-container-disabled .select2-choice div{background-color:#f4f4f4;background-image:none;border-left:0}.select2-container.select2-container-disabled .select2-choice abbr{display:none}.select2-container-multi .select2-choices{height:auto!important;height:1%;margin:0;padding:0;position:relative;border:1px solid #aaa;cursor:text;overflow:hidden;background-color:#fff;background-image:-webkit-gradient(linear,0% 0,0% 100%,color-stop(1%,#eee),color-stop(15%,#fff));background-image:-webkit-linear-gradient(top,#eee 1%,#fff 15%);background-image:-moz-linear-gradient(top,#eee 1%,#fff 15%);background-image:-o-linear-gradient(top,#eee 1%,#fff 15%);background-image:-ms-linear-gradient(top,#eee 1%,#fff 15%);background-image:linear-gradient(top,#eee 1%,#fff 15%)}.select2-locked{padding:3px 5px 3px 5px!important}.select2-container-multi .select2-choices{min-height:26px}.select2-container-multi.select2-container-active .select2-choices{border:1px solid #5897fb;outline:0;-webkit-box-shadow:0 0 5px rgba(0,0,0,.3);-moz-box-shadow:0 0 5px rgba(0,0,0,.3);box-shadow:0 0 5px rgba(0,0,0,.3)}.select2-container-multi .select2-choices li{float:left;list-style:none}.select2-container-multi .select2-choices .select2-search-field{margin:0;padding:0;white-space:nowrap}.select2-container-multi .select2-choices .select2-search-field input{padding:5px;margin:1px 0;font-family:sans-serif;font-size:100%;color:#666;outline:0;border:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;background:transparent!important}.select2-container-multi .select2-choices .select2-search-field input.select2-active{background:#fff url('select2-spinner.gif') no-repeat 100%!important}.select2-default{color:#999!important}.select2-container-multi .select2-choices .select2-search-choice{padding:3px 5px 3px 18px;margin:3px 0 3px 5px;position:relative;line-height:13px;color:#333;cursor:default;border:1px solid #aaa;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,0.05);-moz-box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,0.05);box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,0.05);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-color:#e4e4e4;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee',endColorstr='#f4f4f4',GradientType=0);background-image:-webkit-gradient(linear,0% 0,0% 100%,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),color-stop(100%,#eee));background-image:-webkit-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-moz-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-o-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-ms-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%)}.select2-container-multi .select2-choices .select2-search-choice span{cursor:default}.select2-container-multi .select2-choices .select2-search-choice-focus{background:#d4d4d4}.select2-search-choice-close{display:block;width:12px;height:13px;position:absolute;right:3px;top:4px;font-size:1px;outline:0;background:url('select2.png') right top no-repeat}.select2-container-multi .select2-search-choice-close{left:3px}.select2-container-multi .select2-choices .select2-search-choice .select2-search-choice-close:hover{background-position:right -11px}.select2-container-multi .select2-choices .select2-search-choice-focus .select2-search-choice-close{background-position:right -11px}.select2-container-multi.select2-container-disabled .select2-choices{background-color:#f4f4f4;background-image:none;border:1px solid #ddd;cursor:default}.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice{padding:3px 5px 3px 5px;border:1px solid #ddd;background-image:none;background-color:#f4f4f4}.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice .select2-search-choice-close{display:none}.select2-result-selectable .select2-match,.select2-result-unselectable .select2-match{text-decoration:underline}.select2-offscreen{position:absolute;left:-10000px}@media only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (min-resolution:144dpi){.select2-search input,.select2-search-choice-close,.select2-container .select2-choice abbr,.select2-container .select2-choice div b{background-image:url('select2x2.png')!important;background-repeat:no-repeat!important;background-size:60px 40px!important}.select2-search input{background-position:100% -21px!important}} \ No newline at end of file diff --git a/django_select2/static/js/select2.min.js b/django_select2/static/js/select2.min.js index da614fc..5facbbe 100644 --- a/django_select2/static/js/select2.min.js +++ b/django_select2/static/js/select2.min.js @@ -1 +1 @@ -(function(a){if(typeof a.fn.each2=="undefined"){a.fn.extend({each2:function(f){var d=a([0]),e=-1,b=this.length;while(++e=112&&H<=123}};D=j(document);u=(function(){var H=1;return function(){return H++}}());function b(J,K){var I=0,H=K.length;for(;I=0){I(K)}})}function r(H){if(H[0]===document.activeElement){return}window.setTimeout(function(){var J=H[0],K=H.val().length,I;H.focus();if(J.setSelectionRange){J.setSelectionRange(K,K)}else{if(J.createTextRange){I=J.createTextRange();I.collapse(true);I.moveEnd("character",K);I.moveStart("character",K);I.select()}}},0)}function d(H){H.preventDefault();H.stopPropagation()}function F(H){H.preventDefault();H.stopImmediatePropagation()}function z(I){if(!a){var H=I[0].currentStyle||window.getComputedStyle(I[0],null);a=j(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:H.fontSize,fontFamily:H.fontFamily,fontStyle:H.fontStyle,fontWeight:H.fontWeight,letterSpacing:H.letterSpacing,textTransform:H.textTransform,whiteSpace:"nowrap"});a.attr("class","select2-sizer");j("body").append(a)}a.text(I.val());return a.width()}function y(I,M,H){var K,L=[],J;K=I.attr("class");if(typeof K==="string"){j(K.split(" ")).each2(function(){if(this.indexOf("select2-")===0){L.push(this)}})}K=M.attr("class");if(typeof K==="string"){j(K.split(" ")).each2(function(){if(this.indexOf("select2-")!==0){J=H(this);if(typeof J==="string"&&J.length>0){L.push(this)}}})}I.attr("class",L.join(" "))}function i(M,L,J,H){var K=M.toUpperCase().indexOf(L.toUpperCase()),I=L.length;if(K<0){J.push(H(M));return}J.push(H(M.substring(0,K)));J.push("");J.push(H(M.substring(K,K+I)));J.push("");J.push(H(M.substring(K+I,M.length)))}function p(J){var M,I=0,K=null,N=J.quietMillis||100,L=J.url,H=this;return function(O){window.clearTimeout(M);M=window.setTimeout(function(){I+=1;var Q=I,S=J.data,P=L,U=J.transport||j.ajax,R=J.type||"GET",T={};S=S?S.call(H,O.term,O.page,O.context):null;P=(typeof P==="function")?P.call(H,O.term,O.page,O.context):P;if(null!==K){K.abort()}if(J.params){if(j.isFunction(J.params)){j.extend(T,J.params.call(H))}else{j.extend(T,J.params)}}j.extend(T,{url:P,dataType:J.dataType,data:S,type:R,cache:false,success:function(W){if(Q=0){break}}if(O<0){break}K=P.substring(0,O);P=P.substring(O+M.length);if(K.length>0){K=H.createSearchChoice(K,Q);if(K!==l&&K!==null&&H.id(K)!==l&&H.id(K)!==null){R=false;for(L=0,J=Q.length;L\|])/g,"\$1");this.container.attr("id",this.containerId);this.body=E(function(){return K.element.closest("body")});y(this.container,this.opts.element,this.opts.adaptContainerCssClass);this.container.css(t(K.containerCss));this.container.addClass(t(K.containerCssClass));this.elementTabIndex=this.opts.element.attr("tabIndex");this.opts.element.data("select2",this).addClass("select2-offscreen").bind("focus.select2",function(){j(this).select2("focus")}).attr("tabIndex","-1").before(this.container);this.container.data("select2",this);this.dropdown=this.container.find(".select2-drop");this.dropdown.addClass(t(K.dropdownCssClass));this.dropdown.data("select2",this);this.results=J=this.container.find(L);this.search=I=this.container.find("input.select2-input");I.attr("tabIndex",this.elementTabIndex);this.resultsPage=0;this.context=null;this.initContainer();v(this.results);this.dropdown.delegate(L,"mousemove-filtered touchstart touchmove touchend",this.bind(this.highlightUnderEvent));f(80,this.results);this.dropdown.delegate(L,"scroll-debounced",this.bind(this.loadMoreIfNeeded));if(j.fn.mousewheel){J.mousewheel(function(Q,R,O,N){var P=J.scrollTop(),M;if(N>0&&P-N<=0){J.scrollTop(0);d(Q)}else{if(N<0&&J.get(0).scrollHeight-J.scrollTop()+N<=J.height()){J.scrollTop(J.get(0).scrollHeight-J.height());d(Q)}}})}B(I);I.bind("keyup-change input paste",this.bind(this.updateResults));I.bind("focus",function(){I.addClass("select2-focused")});I.bind("blur",function(){I.removeClass("select2-focused")});this.dropdown.delegate(L,"mouseup",this.bind(function(M){if(j(M.target).closest(".select2-result-selectable").length>0){this.highlightUnderEvent(M);this.selectHighlighted(M)}}));this.dropdown.bind("click mouseup mousedown",function(M){M.stopPropagation()});if(j.isFunction(this.opts.initSelection)){this.initSelection();this.monitorSource()}if(K.element.is(":disabled")||K.element.is("[readonly='readonly']")){this.disable()}},destroy:function(){var H=this.opts.element.data("select2");if(this.propertyObserver){delete this.propertyObserver;this.propertyObserver=null}if(H!==l){H.container.remove();H.dropdown.remove();H.opts.element.removeClass("select2-offscreen").removeData("select2").unbind(".select2").attr({tabIndex:this.elementTabIndex}).show()}},prepareOpts:function(L){var J,I,H,K;J=L.element;if(J.get(0).tagName.toLowerCase()==="select"){this.select=I=L.element}if(I){j.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in L){throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a ",""].join(""));return H},disable:function(){if(!this.enabled){return}this.parent.disable.apply(this,arguments);this.focusser.attr("disabled","disabled")},enable:function(){if(this.enabled){return}this.parent.enable.apply(this,arguments);this.focusser.removeAttr("disabled")},opening:function(){this.parent.opening.apply(this,arguments);this.focusser.attr("disabled","disabled");this.opts.element.trigger(j.Event("open"))},close:function(){if(!this.opened()){return}this.parent.close.apply(this,arguments);this.focusser.removeAttr("disabled");r(this.focusser)},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 J,I=this.container,K=this.dropdown,H=false;this.showSearch(this.opts.minimumResultsForSearch>=0);this.selection=J=I.find(".select2-choice");this.focusser=I.find(".select2-focusser");this.search.bind("keydown",this.bind(function(L){if(!this.enabled){return}if(L.which===c.PAGE_UP||L.which===c.PAGE_DOWN){d(L);return}switch(L.which){case c.UP:case c.DOWN:this.moveHighlight((L.which===c.UP)?-1:1);d(L);return;case c.TAB:case c.ENTER:this.selectHighlighted();d(L);return;case c.ESC:this.cancel(L);d(L);return}}));this.focusser.bind("keydown",this.bind(function(L){if(!this.enabled){return}if(L.which===c.TAB||c.isControl(L)||c.isFunctionKey(L)||L.which===c.ESC){return}if(this.opts.openOnEnter===false&&L.which===c.ENTER){d(L);return}if(L.which==c.DOWN||L.which==c.UP||(L.which==c.ENTER&&this.opts.openOnEnter)){this.open();d(L);return}if(L.which==c.DELETE||L.which==c.BACKSPACE){if(this.opts.allowClear){this.clear()}d(L);return}}));B(this.focusser);this.focusser.bind("keyup-change input",this.bind(function(L){if(this.opened()){return}this.open();if(this.showSearchInput!==false){this.search.val(this.focusser.val())}this.focusser.val("");d(L)}));J.delegate("abbr","mousedown",this.bind(function(L){if(!this.enabled){return}this.clear();F(L);this.close();this.selection.focus()}));J.bind("mousedown",this.bind(function(L){H=true;if(this.opened()){this.close()}else{if(this.enabled){this.open()}}d(L);H=false}));K.bind("mousedown",this.bind(function(){this.search.focus()}));J.bind("focus",this.bind(function(L){d(L)}));this.focusser.bind("focus",this.bind(function(){this.container.addClass("select2-container-active")})).bind("blur",this.bind(function(){if(!this.opened()){this.container.removeClass("select2-container-active")}}));this.search.bind("focus",this.bind(function(){this.container.addClass("select2-container-active")}));this.initContainerWidth();this.setPlaceholder()},clear:function(){var H=this.selection.data("select2-data");this.opts.element.val("");this.selection.find("span").empty();this.selection.removeData("select2-data");this.setPlaceholder();this.opts.element.trigger({type:"removed",val:this.id(H),choice:H});this.triggerChange({removed:H})},initSelection:function(){var I;if(this.opts.element.val()===""&&this.opts.element.text()===""){this.close();this.setPlaceholder()}else{var H=this;this.opts.initSelection.call(null,this.opts.element,function(J){if(J!==l&&J!==null){H.updateSelection(J);H.close();H.setPlaceholder()}})}},prepareOpts:function(){var H=this.parent.prepareOpts.apply(this,arguments);if(H.element.get(0).tagName.toLowerCase()==="select"){H.initSelection=function(I,K){var J=I.find(":selected");if(j.isFunction(K)){K({id:J.attr("value"),text:J.text(),element:J})}}}else{if("data" in H){H.initSelection=H.initSelection||function(I,K){var J=I.val();H.query({matcher:function(L,N,M){return q(J,H.id(M))},callback:!j.isFunction(K)?j.noop:function(L){K(L.results.length?L.results[0]:null)}})}}}return H},getPlaceholder:function(){if(this.select){if(this.select.find("option").first().text()!==""){return l}}return this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var H=this.getPlaceholder();if(this.opts.element.val()===""&&H!==l){if(this.select&&this.select.find("option:first").text()!==""){return}this.selection.find("span").html(this.opts.escapeMarkup(H));this.selection.addClass("select2-default");this.selection.find("abbr").hide()}},postprocessResults:function(L,I){var K=0,H=this,M=true;this.findHighlightableChoices().each2(function(N,O){if(q(H.id(O.data("select2-data")),H.opts.element.val())){K=N;return false}});this.highlight(K);if(I===true){var J=this.opts.minimumResultsForSearch;M=J<0?false:h(L.results)>=J;this.showSearch(M)}},showSearch:function(H){this.showSearchInput=H;this.dropdown.find(".select2-search")[H?"removeClass":"addClass"]("select2-search-hidden");j(this.dropdown,this.container)[H?"addClass":"removeClass"]("select2-with-searchbox")},onSelect:function(J,I){var H=this.opts.element.val();this.opts.element.val(this.id(J));this.updateSelection(J);this.opts.element.trigger({type:"selected",val:this.id(J),choice:J});this.close();if(!I||!I.noFocus){this.selection.focus()}if(!q(H,this.id(J))){this.triggerChange()}},updateSelection:function(J){var H=this.selection.find("span"),I;this.selection.data("select2-data",J);H.empty();I=this.opts.formatSelection(J,H);if(I!==l){H.append(this.opts.escapeMarkup(I))}this.selection.removeClass("select2-default");if(this.opts.allowClear&&this.getPlaceholder()!==l){this.selection.find("abbr").show()}},val:function(){var K,I=false,J=null,H=this;if(arguments.length===0){return this.opts.element.val()}K=arguments[0];if(arguments.length>1){I=arguments[1]}if(this.select){this.select.val(K).find(":selected").each2(function(L,M){J={id:M.attr("value"),text:M.text()};return false});this.updateSelection(J);this.setPlaceholder();if(I){this.triggerChange()}}else{if(this.opts.initSelection===l){throw new Error("cannot call val() if initSelection() is not defined")}if(!K&&K!==0){this.clear();if(I){this.triggerChange()}return}this.opts.element.val(K);this.opts.initSelection(this.opts.element,function(L){H.opts.element.val(!L?"":H.id(L));H.updateSelection(L);H.setPlaceholder();if(I){H.triggerChange()}})}},clearSearch:function(){this.search.val("");this.focusser.val("")},data:function(I){var H;if(arguments.length===0){H=this.selection.data("select2-data");if(H==l){H=null}return H}else{if(!I||I===""){this.clear()}else{this.opts.element.val(!I?"":this.id(I));this.updateSelection(I)}}}});G=x(e,{createContainer:function(){var H=j(document.createElement("div")).attr({"class":"select2-container select2-container-multi"}).html(["
    ","
  • "," ","
  • ","
",""].join(""));return H},prepareOpts:function(){var H=this.parent.prepareOpts.apply(this,arguments);if(H.element.get(0).tagName.toLowerCase()==="select"){H.initSelection=function(I,K){var J=[];I.find(":selected").each2(function(L,M){J.push({id:M.attr("value"),text:M.text(),element:M[0]})});K(J)}}else{if("data" in H){H.initSelection=H.initSelection||function(I,K){var J=m(I.val(),H.separator);H.query({matcher:function(L,N,M){return j.grep(J,function(O){return q(O,H.id(M))}).length},callback:!j.isFunction(K)?j.noop:function(L){K(L.results)}})}}}return H},initContainer:function(){var H=".select2-choices",I;this.searchContainer=this.container.find(".select2-search-field");this.selection=I=this.container.find(H);this.search.bind("input paste",this.bind(function(){if(!this.enabled){return}if(!this.opened()){this.open()}}));this.search.bind("keydown",this.bind(function(K){if(!this.enabled){return}if(K.which===c.BACKSPACE&&this.search.val()===""){this.close();var L,J=I.find(".select2-search-choice-focus");if(J.length>0){this.unselect(J.first());this.search.width(10);d(K);return}L=I.find(".select2-search-choice:not(.select2-locked)");if(L.length>0){L.last().addClass("select2-search-choice-focus")}}else{I.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")}if(this.opened()){switch(K.which){case c.UP:case c.DOWN:this.moveHighlight((K.which===c.UP)?-1:1);d(K);return;case c.ENTER:case c.TAB:this.selectHighlighted();d(K);return;case c.ESC:this.cancel(K);d(K);return}}if(K.which===c.TAB||c.isControl(K)||c.isFunctionKey(K)||K.which===c.BACKSPACE||K.which===c.ESC){return}if(K.which===c.ENTER){if(this.opts.openOnEnter===false){return}else{if(K.altKey||K.ctrlKey||K.shiftKey||K.metaKey){return}}}this.open();if(K.which===c.PAGE_UP||K.which===c.PAGE_DOWN){d(K)}}));this.search.bind("keyup",this.bind(this.resizeSearch));this.search.bind("blur",this.bind(function(J){this.container.removeClass("select2-container-active");this.search.removeClass("select2-focused");if(!this.opened()){this.clearSearch()}J.stopImmediatePropagation()}));this.container.delegate(H,"mousedown",this.bind(function(J){if(!this.enabled){return}if(j(J.target).closest(".select2-search-choice").length>0){return}this.clearPlaceholder();this.open();this.focusSearch();J.preventDefault()}));this.container.delegate(H,"focus",this.bind(function(){if(!this.enabled){return}this.container.addClass("select2-container-active");this.dropdown.addClass("select2-drop-active");this.clearPlaceholder()}));this.initContainerWidth();this.clearSearch()},enable:function(){if(this.enabled){return}this.parent.enable.apply(this,arguments);this.search.removeAttr("disabled")},disable:function(){if(!this.enabled){return}this.parent.disable.apply(this,arguments);this.search.attr("disabled",true)},initSelection:function(){var I;if(this.opts.element.val()===""&&this.opts.element.text()===""){this.updateSelection([]);this.close();this.clearSearch()}if(this.select||this.opts.element.val()!==""){var H=this;this.opts.initSelection.call(null,this.opts.element,function(J){if(J!==l&&J!==null){H.updateSelection(J);H.close();H.clearSearch()}})}},clearSearch:function(){var H=this.getPlaceholder();if(H!==l&&this.getVal().length===0&&this.search.hasClass("select2-focused")===false){this.search.val(H).addClass("select2-default");this.resizeSearch()}else{this.search.val("").width(10)}},clearPlaceholder:function(){if(this.search.hasClass("select2-default")){this.search.val("").removeClass("select2-default")}},opening:function(){this.parent.opening.apply(this,arguments);this.clearPlaceholder();this.resizeSearch();this.focusSearch();this.opts.element.trigger(j.Event("open"))},close:function(){if(!this.opened()){return}this.parent.close.apply(this,arguments)},focus:function(){this.close();this.search.focus();this.opts.element.triggerHandler("focus")},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(K){var J=[],I=[],H=this;j(K).each(function(){if(b(H.id(this),J)<0){J.push(H.id(this));I.push(this)}});K=I;this.selection.find(".select2-search-choice").remove();j(K).each(function(){H.addSelectedChoice(this)});H.postprocessResults()},tokenize:function(){var H=this.search.val();H=this.opts.tokenizer(H,this.data(),this.bind(this.onSelect),this.opts);if(H!=null&&H!=l){this.search.val(H);if(H.length>0){this.open()}}},onSelect:function(I,H){this.addSelectedChoice(I);this.opts.element.trigger({type:"selected",val:this.id(I),choice:I});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.val().length>=this.getMaximumSelectionSize()){this.updateResults(true)}this.positionDropdown()}else{this.close();this.search.width(10)}}this.triggerChange({added:I});if(!H||!H.noFocus){this.focusSearch()}},cancel:function(){this.close();this.focusSearch()},addSelectedChoice:function(K){var I=!K.locked,O=j("
  • "),N=j("
  • ");var H=I?O:N,M=this.id(K),L=this.getVal(),J;J=this.opts.formatSelection(K,H.find("div"));if(J!=l){H.find("div").replaceWith("
    "+this.opts.escapeMarkup(J)+"
    ")}if(I){H.find(".select2-search-choice-close").bind("mousedown",d).bind("click dblclick",this.bind(function(P){if(!this.enabled){return}j(P.target).closest(".select2-search-choice").fadeOut("fast",this.bind(function(){this.unselect(j(P.target));this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");this.close();this.focusSearch()})).dequeue();d(P)})).bind("focus",this.bind(function(){if(!this.enabled){return}this.container.addClass("select2-container-active");this.dropdown.addClass("select2-drop-active")}))}H.data("select2-data",K);H.insertBefore(this.searchContainer);L.push(M);this.setVal(L)},unselect:function(I){var K=this.getVal(),J,H;I=I.closest(".select2-search-choice");if(I.length===0){throw"Invalid argument: "+I+". Must be .select2-search-choice"}J=I.data("select2-data");if(!J){return}H=b(this.id(J),K);if(H>=0){K.splice(H,1);this.setVal(K);if(this.select){this.postprocessResults()}}I.remove();this.opts.element.trigger({type:"removed",val:this.id(J),choice:J});this.triggerChange({removed:J})},postprocessResults:function(){var J=this.getVal(),K=this.results.find(".select2-result"),I=this.results.find(".select2-result-with-children"),H=this;K.each2(function(M,L){var N=H.id(L.data("select2-data"));if(b(N,J)>=0){L.addClass("select2-selected");L.find(".select2-result-selectable").addClass("select2-selected")}});I.each2(function(M,L){if(!L.is(".select2-result-selectable")&&L.find(".select2-result-selectable:not(.select2-selected)").length===0){L.addClass("select2-selected")}});if(this.highlight()==-1){H.highlight(0)}},resizeSearch:function(){var M,K,J,H,I,L=n(this.search);M=z(this.search)+10;K=this.search.offset().left;J=this.selection.width();H=this.selection.offset().left;I=J-(K-H)-L;if(I1){I=arguments[1]}if(!K&&K!==0){this.opts.element.val("");this.updateSelection([]);this.clearSearch();if(I){this.triggerChange()}return}this.setVal(K);if(this.select){this.opts.initSelection(this.select,this.bind(this.updateSelection));if(I){this.triggerChange()}}else{if(this.opts.initSelection===l){throw new Error("val() cannot be called if initSelection() is not defined")}this.opts.initSelection(this.opts.element,function(M){var L=j(M).map(H.id);H.setVal(L);H.updateSelection(M);H.clearSearch();if(I){H.triggerChange()}})}this.clearSearch()},onSortStart:function(){if(this.select){throw new Error("Sorting of elements is not supported when attached to instead.")}this.search.width(0);this.searchContainer.hide()},onSortEnd:function(){var I=[],H=this;this.searchContainer.show();this.searchContainer.appendTo(this.searchContainer.parent());this.resizeSearch();this.selection.find(".select2-search-choice").each(function(){I.push(H.opts.id(j(this).data("select2-data")))});this.setVal(I);this.triggerChange()},data:function(I){var H=this,J;if(arguments.length===0){return this.selection.find(".select2-search-choice").map(function(){return j(this).data("select2-data")}).get()}else{if(!I){I=[]}J=j.map(I,function(K){return H.opts.id(K)});this.setVal(J);this.updateSelection(I);this.clearSearch()}}});j.fn.select2=function(){var K=Array.prototype.slice.call(arguments,0),L,J,M,I,H=["val","destroy","opened","open","close","focus","isFocused","container","onSortStart","onSortEnd","enable","disable","positionDropdown","data"];this.each(function(){if(K.length===0||typeof(K[0])==="object"){L=K.length===0?{}:j.extend({},K[0]);L.element=j(this);if(L.element.get(0).tagName.toLowerCase()==="select"){I=L.element.attr("multiple")}else{I=L.multiple||false;if("tags" in L){L.multiple=I=true}}J=I?new G():new w();J.init(L)}else{if(typeof(K[0])==="string"){if(b(K[0],H)<0){throw"Unknown method: "+K[0]}M=l;J=j(this).data("select2");if(J===l){return}if(K[0]==="container"){M=J.container}else{M=J[K[0]].apply(J,K.slice(1))}if(M!==l){return false}}else{throw"Invalid arguments to select2 plugin: "+K}}});return(M===l)?this:M};j.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:true,openOnEnter:true,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(I,J,L,H){var K=[];i(I.text,L.term,K,H);return K.join("")},formatSelection:function(I,H){return I?I.text:l},sortResults:function(I,H,J){return I},formatResultCssClass:function(H){return l},formatNoMatches:function(){return"No matches found"},formatInputTooShort:function(H,I){var J=I-H.length;return"Please enter "+J+" more character"+(J==1?"":"s")},formatInputTooLong:function(I,H){var J=I.length-H;return"Please enter "+J+" less character"+(J==1?"":"s")},formatSelectionTooBig:function(H){return"You can only select "+H+" item"+(H==1?"":"s")},formatLoadMore:function(H){return"Loading more results..."},formatSearching:function(){return"Searching..."},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(H){return H.id},matcher:function(H,I){return I.toUpperCase().indexOf(H.toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:A,escapeMarkup:function(H){var I={"\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(H).replace(/[&<>"'/\]/g,function(J){return I[J[0]]})},blurOnChange:false,selectOnBlur:false,adaptContainerCssClass:function(H){return H},adaptDropdownCssClass:function(H){return null}};window.Select2={query:{ajax:p,local:s,tags:o},util:{debounce:g,markMatch:i},"class":{"abstract":e,single:w,multi:G}}}(jQuery)); \ No newline at end of file +(function(a){if(typeof a.fn.each2=="undefined"){a.fn.extend({each2:function(f){var d=a([0]),e=-1,b=this.length;while(++e=112&&H<=123}};D=j(document);u=(function(){var H=1;return function(){return H++}}());function b(J,K){var I=0,H=K.length;for(;I=0){I(K)}})}function r(H){if(H[0]===document.activeElement){return}window.setTimeout(function(){var J=H[0],K=H.val().length,I;H.focus();if(J.setSelectionRange){J.setSelectionRange(K,K)}else{if(J.createTextRange){I=J.createTextRange();I.collapse(true);I.moveEnd("character",K);I.moveStart("character",K);I.select()}}},0)}function d(H){H.preventDefault();H.stopPropagation()}function F(H){H.preventDefault();H.stopImmediatePropagation()}function z(I){if(!a){var H=I[0].currentStyle||window.getComputedStyle(I[0],null);a=j(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:H.fontSize,fontFamily:H.fontFamily,fontStyle:H.fontStyle,fontWeight:H.fontWeight,letterSpacing:H.letterSpacing,textTransform:H.textTransform,whiteSpace:"nowrap"});a.attr("class","select2-sizer");j("body").append(a)}a.text(I.val());return a.width()}function y(I,M,H){var K,L=[],J;K=I.attr("class");if(typeof K==="string"){j(K.split(" ")).each2(function(){if(this.indexOf("select2-")===0){L.push(this)}})}K=M.attr("class");if(typeof K==="string"){j(K.split(" ")).each2(function(){if(this.indexOf("select2-")!==0){J=H(this);if(typeof J==="string"&&J.length>0){L.push(this)}}})}I.attr("class",L.join(" "))}function i(M,L,J,H){var K=M.toUpperCase().indexOf(L.toUpperCase()),I=L.length;if(K<0){J.push(H(M));return}J.push(H(M.substring(0,K)));J.push("");J.push(H(M.substring(K,K+I)));J.push("");J.push(H(M.substring(K+I,M.length)))}function p(J){var M,I=0,K=null,N=J.quietMillis||100,L=J.url,H=this;return function(O){window.clearTimeout(M);M=window.setTimeout(function(){I+=1;var Q=I,S=J.data,P=L,U=J.transport||j.ajax,R=J.type||"GET",T={};S=S?S.call(H,O.term,O.page,O.context):null;P=(typeof P==="function")?P.call(H,O.term,O.page,O.context):P;if(null!==K){K.abort()}if(J.params){if(j.isFunction(J.params)){j.extend(T,J.params.call(H))}else{j.extend(T,J.params)}}j.extend(T,{url:P,dataType:J.dataType,data:S,type:R,cache:false,success:function(W){if(Q=0){break}}if(O<0){break}K=P.substring(0,O);P=P.substring(O+M.length);if(K.length>0){K=H.createSearchChoice(K,Q);if(K!==l&&K!==null&&H.id(K)!==l&&H.id(K)!==null){R=false;for(L=0,J=Q.length;L\|])/g,"\\$1");this.container.attr("id",this.containerId);this.body=E(function(){return K.element.closest("body")});y(this.container,this.opts.element,this.opts.adaptContainerCssClass);this.container.css(t(K.containerCss));this.container.addClass(t(K.containerCssClass));this.elementTabIndex=this.opts.element.attr("tabIndex");this.opts.element.data("select2",this).addClass("select2-offscreen").bind("focus.select2",function(){j(this).select2("focus")}).attr("tabIndex","-1").before(this.container);this.container.data("select2",this);this.dropdown=this.container.find(".select2-drop");this.dropdown.addClass(t(K.dropdownCssClass));this.dropdown.data("select2",this);this.results=J=this.container.find(L);this.search=I=this.container.find("input.select2-input");I.attr("tabIndex",this.elementTabIndex);this.resultsPage=0;this.context=null;this.initContainer();v(this.results);this.dropdown.delegate(L,"mousemove-filtered touchstart touchmove touchend",this.bind(this.highlightUnderEvent));f(80,this.results);this.dropdown.delegate(L,"scroll-debounced",this.bind(this.loadMoreIfNeeded));if(j.fn.mousewheel){J.mousewheel(function(Q,R,O,N){var P=J.scrollTop(),M;if(N>0&&P-N<=0){J.scrollTop(0);d(Q)}else{if(N<0&&J.get(0).scrollHeight-J.scrollTop()+N<=J.height()){J.scrollTop(J.get(0).scrollHeight-J.height());d(Q)}}})}B(I);I.bind("keyup-change input paste",this.bind(this.updateResults));I.bind("focus",function(){I.addClass("select2-focused")});I.bind("blur",function(){I.removeClass("select2-focused")});this.dropdown.delegate(L,"mouseup",this.bind(function(M){if(j(M.target).closest(".select2-result-selectable").length>0){this.highlightUnderEvent(M);this.selectHighlighted(M)}}));this.dropdown.bind("click mouseup mousedown",function(M){M.stopPropagation()});if(j.isFunction(this.opts.initSelection)){this.initSelection();this.monitorSource()}if(K.element.is(":disabled")||K.element.is("[readonly='readonly']")){this.disable()}},destroy:function(){var H=this.opts.element.data("select2");if(this.propertyObserver){delete this.propertyObserver;this.propertyObserver=null}if(H!==l){H.container.remove();H.dropdown.remove();H.opts.element.removeClass("select2-offscreen").removeData("select2").unbind(".select2").attr({tabIndex:this.elementTabIndex}).show()}},prepareOpts:function(L){var J,I,H,K;J=L.element;if(J.get(0).tagName.toLowerCase()==="select"){this.select=I=L.element}if(I){j.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in L){throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a ",""].join(""));return H},disable:function(){if(!this.enabled){return}this.parent.disable.apply(this,arguments);this.focusser.attr("disabled","disabled")},enable:function(){if(this.enabled){return}this.parent.enable.apply(this,arguments);this.focusser.removeAttr("disabled")},opening:function(){this.parent.opening.apply(this,arguments);this.focusser.attr("disabled","disabled");this.opts.element.trigger(j.Event("open"))},close:function(){if(!this.opened()){return}this.parent.close.apply(this,arguments);this.focusser.removeAttr("disabled");r(this.focusser)},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 J,I=this.container,K=this.dropdown,H=false;this.showSearch(this.opts.minimumResultsForSearch>=0);this.selection=J=I.find(".select2-choice");this.focusser=I.find(".select2-focusser");this.search.bind("keydown",this.bind(function(L){if(!this.enabled){return}if(L.which===c.PAGE_UP||L.which===c.PAGE_DOWN){d(L);return}switch(L.which){case c.UP:case c.DOWN:this.moveHighlight((L.which===c.UP)?-1:1);d(L);return;case c.TAB:case c.ENTER:this.selectHighlighted();d(L);return;case c.ESC:this.cancel(L);d(L);return}}));this.focusser.bind("keydown",this.bind(function(L){if(!this.enabled){return}if(L.which===c.TAB||c.isControl(L)||c.isFunctionKey(L)||L.which===c.ESC){return}if(this.opts.openOnEnter===false&&L.which===c.ENTER){d(L);return}if(L.which==c.DOWN||L.which==c.UP||(L.which==c.ENTER&&this.opts.openOnEnter)){this.open();d(L);return}if(L.which==c.DELETE||L.which==c.BACKSPACE){if(this.opts.allowClear){this.clear()}d(L);return}}));B(this.focusser);this.focusser.bind("keyup-change input",this.bind(function(L){if(this.opened()){return}this.open();if(this.showSearchInput!==false){this.search.val(this.focusser.val())}this.focusser.val("");d(L)}));J.delegate("abbr","mousedown",this.bind(function(L){if(!this.enabled){return}this.clear();F(L);this.close();this.selection.focus()}));J.bind("mousedown",this.bind(function(L){H=true;if(this.opened()){this.close()}else{if(this.enabled){this.open()}}d(L);H=false}));K.bind("mousedown",this.bind(function(){this.search.focus()}));J.bind("focus",this.bind(function(L){d(L)}));this.focusser.bind("focus",this.bind(function(){this.container.addClass("select2-container-active")})).bind("blur",this.bind(function(){if(!this.opened()){this.container.removeClass("select2-container-active")}}));this.search.bind("focus",this.bind(function(){this.container.addClass("select2-container-active")}));this.initContainerWidth();this.setPlaceholder()},clear:function(){var H=this.selection.data("select2-data");this.opts.element.val("");this.selection.find("span").empty();this.selection.removeData("select2-data");this.setPlaceholder();this.opts.element.trigger({type:"removed",val:this.id(H),choice:H});this.triggerChange({removed:H})},initSelection:function(){var I;if(this.opts.element.val()===""&&this.opts.element.text()===""){this.close();this.setPlaceholder()}else{var H=this;this.opts.initSelection.call(null,this.opts.element,function(J){if(J!==l&&J!==null){H.updateSelection(J);H.close();H.setPlaceholder()}})}},prepareOpts:function(){var H=this.parent.prepareOpts.apply(this,arguments);if(H.element.get(0).tagName.toLowerCase()==="select"){H.initSelection=function(I,K){var J=I.find(":selected");if(j.isFunction(K)){K({id:J.attr("value"),text:J.text(),element:J})}}}else{if("data" in H){H.initSelection=H.initSelection||function(I,K){var J=I.val();H.query({matcher:function(L,N,M){return q(J,H.id(M))},callback:!j.isFunction(K)?j.noop:function(L){K(L.results.length?L.results[0]:null)}})}}}return H},getPlaceholder:function(){if(this.select){if(this.select.find("option").first().text()!==""){return l}}return this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var H=this.getPlaceholder();if(this.opts.element.val()===""&&H!==l){if(this.select&&this.select.find("option:first").text()!==""){return}this.selection.find("span").html(this.opts.escapeMarkup(H));this.selection.addClass("select2-default");this.selection.find("abbr").hide()}},postprocessResults:function(L,I){var K=0,H=this,M=true;this.findHighlightableChoices().each2(function(N,O){if(q(H.id(O.data("select2-data")),H.opts.element.val())){K=N;return false}});this.highlight(K);if(I===true){var J=this.opts.minimumResultsForSearch;M=J<0?false:h(L.results)>=J;this.showSearch(M)}},showSearch:function(H){this.showSearchInput=H;this.dropdown.find(".select2-search")[H?"removeClass":"addClass"]("select2-search-hidden");j(this.dropdown,this.container)[H?"addClass":"removeClass"]("select2-with-searchbox")},onSelect:function(J,I){var H=this.opts.element.val();this.opts.element.val(this.id(J));this.updateSelection(J);this.opts.element.trigger({type:"selected",val:this.id(J),choice:J});this.close();if(!I||!I.noFocus){this.selection.focus()}if(!q(H,this.id(J))){this.triggerChange()}},updateSelection:function(J){var H=this.selection.find("span"),I;this.selection.data("select2-data",J);H.empty();I=this.opts.formatSelection(J,H);if(I!==l){H.append(this.opts.escapeMarkup(I))}this.selection.removeClass("select2-default");if(this.opts.allowClear&&this.getPlaceholder()!==l){this.selection.find("abbr").show()}},val:function(){var K,I=false,J=null,H=this;if(arguments.length===0){return this.opts.element.val()}K=arguments[0];if(arguments.length>1){I=arguments[1]}if(this.select){this.select.val(K).find(":selected").each2(function(L,M){J={id:M.attr("value"),text:M.text()};return false});this.updateSelection(J);this.setPlaceholder();if(I){this.triggerChange()}}else{if(this.opts.initSelection===l){throw new Error("cannot call val() if initSelection() is not defined")}if(!K&&K!==0){this.clear();if(I){this.triggerChange()}return}this.opts.element.val(K);this.opts.initSelection(this.opts.element,function(L){H.opts.element.val(!L?"":H.id(L));H.updateSelection(L);H.setPlaceholder();if(I){H.triggerChange()}})}},clearSearch:function(){this.search.val("");this.focusser.val("")},data:function(I){var H;if(arguments.length===0){H=this.selection.data("select2-data");if(H==l){H=null}return H}else{if(!I||I===""){this.clear()}else{this.opts.element.val(!I?"":this.id(I));this.updateSelection(I)}}}});G=x(e,{createContainer:function(){var H=j(document.createElement("div")).attr({"class":"select2-container select2-container-multi"}).html(["
      ","
    • "," ","
    • ","
    ",""].join(""));return H},prepareOpts:function(){var H=this.parent.prepareOpts.apply(this,arguments);if(H.element.get(0).tagName.toLowerCase()==="select"){H.initSelection=function(I,K){var J=[];I.find(":selected").each2(function(L,M){J.push({id:M.attr("value"),text:M.text(),element:M[0]})});K(J)}}else{if("data" in H){H.initSelection=H.initSelection||function(I,K){var J=m(I.val(),H.separator);H.query({matcher:function(L,N,M){return j.grep(J,function(O){return q(O,H.id(M))}).length},callback:!j.isFunction(K)?j.noop:function(L){K(L.results)}})}}}return H},initContainer:function(){var H=".select2-choices",I;this.searchContainer=this.container.find(".select2-search-field");this.selection=I=this.container.find(H);this.search.bind("input paste",this.bind(function(){if(!this.enabled){return}if(!this.opened()){this.open()}}));this.search.bind("keydown",this.bind(function(K){if(!this.enabled){return}if(K.which===c.BACKSPACE&&this.search.val()===""){this.close();var L,J=I.find(".select2-search-choice-focus");if(J.length>0){this.unselect(J.first());this.search.width(10);d(K);return}L=I.find(".select2-search-choice:not(.select2-locked)");if(L.length>0){L.last().addClass("select2-search-choice-focus")}}else{I.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")}if(this.opened()){switch(K.which){case c.UP:case c.DOWN:this.moveHighlight((K.which===c.UP)?-1:1);d(K);return;case c.ENTER:case c.TAB:this.selectHighlighted();d(K);return;case c.ESC:this.cancel(K);d(K);return}}if(K.which===c.TAB||c.isControl(K)||c.isFunctionKey(K)||K.which===c.BACKSPACE||K.which===c.ESC){return}if(K.which===c.ENTER){if(this.opts.openOnEnter===false){return}else{if(K.altKey||K.ctrlKey||K.shiftKey||K.metaKey){return}}}this.open();if(K.which===c.PAGE_UP||K.which===c.PAGE_DOWN){d(K)}}));this.search.bind("keyup",this.bind(this.resizeSearch));this.search.bind("blur",this.bind(function(J){this.container.removeClass("select2-container-active");this.search.removeClass("select2-focused");if(!this.opened()){this.clearSearch()}J.stopImmediatePropagation()}));this.container.delegate(H,"mousedown",this.bind(function(J){if(!this.enabled){return}if(j(J.target).closest(".select2-search-choice").length>0){return}this.clearPlaceholder();this.open();this.focusSearch();J.preventDefault()}));this.container.delegate(H,"focus",this.bind(function(){if(!this.enabled){return}this.container.addClass("select2-container-active");this.dropdown.addClass("select2-drop-active");this.clearPlaceholder()}));this.initContainerWidth();this.clearSearch()},enable:function(){if(this.enabled){return}this.parent.enable.apply(this,arguments);this.search.removeAttr("disabled")},disable:function(){if(!this.enabled){return}this.parent.disable.apply(this,arguments);this.search.attr("disabled",true)},initSelection:function(){var I;if(this.opts.element.val()===""&&this.opts.element.text()===""){this.updateSelection([]);this.close();this.clearSearch()}if(this.select||this.opts.element.val()!==""){var H=this;this.opts.initSelection.call(null,this.opts.element,function(J){if(J!==l&&J!==null){H.updateSelection(J);H.close();H.clearSearch()}})}},clearSearch:function(){var H=this.getPlaceholder();if(H!==l&&this.getVal().length===0&&this.search.hasClass("select2-focused")===false){this.search.val(H).addClass("select2-default");this.resizeSearch()}else{this.search.val("").width(10)}},clearPlaceholder:function(){if(this.search.hasClass("select2-default")){this.search.val("").removeClass("select2-default")}},opening:function(){this.parent.opening.apply(this,arguments);this.clearPlaceholder();this.resizeSearch();this.focusSearch();this.opts.element.trigger(j.Event("open"))},close:function(){if(!this.opened()){return}this.parent.close.apply(this,arguments)},focus:function(){this.close();this.search.focus();this.opts.element.triggerHandler("focus")},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(K){var J=[],I=[],H=this;j(K).each(function(){if(b(H.id(this),J)<0){J.push(H.id(this));I.push(this)}});K=I;this.selection.find(".select2-search-choice").remove();j(K).each(function(){H.addSelectedChoice(this)});H.postprocessResults()},tokenize:function(){var H=this.search.val();H=this.opts.tokenizer(H,this.data(),this.bind(this.onSelect),this.opts);if(H!=null&&H!=l){this.search.val(H);if(H.length>0){this.open()}}},onSelect:function(I,H){this.addSelectedChoice(I);this.opts.element.trigger({type:"selected",val:this.id(I),choice:I});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.val().length>=this.getMaximumSelectionSize()){this.updateResults(true)}this.positionDropdown()}else{this.close();this.search.width(10)}}this.triggerChange({added:I});if(!H||!H.noFocus){this.focusSearch()}},cancel:function(){this.close();this.focusSearch()},addSelectedChoice:function(K){var I=!K.locked,O=j("
  • "),N=j("
  • ");var H=I?O:N,M=this.id(K),L=this.getVal(),J;J=this.opts.formatSelection(K,H.find("div"));if(J!=l){H.find("div").replaceWith("
    "+this.opts.escapeMarkup(J)+"
    ")}if(I){H.find(".select2-search-choice-close").bind("mousedown",d).bind("click dblclick",this.bind(function(P){if(!this.enabled){return}j(P.target).closest(".select2-search-choice").fadeOut("fast",this.bind(function(){this.unselect(j(P.target));this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");this.close();this.focusSearch()})).dequeue();d(P)})).bind("focus",this.bind(function(){if(!this.enabled){return}this.container.addClass("select2-container-active");this.dropdown.addClass("select2-drop-active")}))}H.data("select2-data",K);H.insertBefore(this.searchContainer);L.push(M);this.setVal(L)},unselect:function(I){var K=this.getVal(),J,H;I=I.closest(".select2-search-choice");if(I.length===0){throw"Invalid argument: "+I+". Must be .select2-search-choice"}J=I.data("select2-data");if(!J){return}H=b(this.id(J),K);if(H>=0){K.splice(H,1);this.setVal(K);if(this.select){this.postprocessResults()}}I.remove();this.opts.element.trigger({type:"removed",val:this.id(J),choice:J});this.triggerChange({removed:J})},postprocessResults:function(){var J=this.getVal(),K=this.results.find(".select2-result"),I=this.results.find(".select2-result-with-children"),H=this;K.each2(function(M,L){var N=H.id(L.data("select2-data"));if(b(N,J)>=0){L.addClass("select2-selected");L.find(".select2-result-selectable").addClass("select2-selected")}});I.each2(function(M,L){if(!L.is(".select2-result-selectable")&&L.find(".select2-result-selectable:not(.select2-selected)").length===0){L.addClass("select2-selected")}});if(this.highlight()==-1){H.highlight(0)}},resizeSearch:function(){var M,K,J,H,I,L=n(this.search);M=z(this.search)+10;K=this.search.offset().left;J=this.selection.width();H=this.selection.offset().left;I=J-(K-H)-L;if(I1){I=arguments[1]}if(!K&&K!==0){this.opts.element.val("");this.updateSelection([]);this.clearSearch();if(I){this.triggerChange()}return}this.setVal(K);if(this.select){this.opts.initSelection(this.select,this.bind(this.updateSelection));if(I){this.triggerChange()}}else{if(this.opts.initSelection===l){throw new Error("val() cannot be called if initSelection() is not defined")}this.opts.initSelection(this.opts.element,function(M){var L=j(M).map(H.id);H.setVal(L);H.updateSelection(M);H.clearSearch();if(I){H.triggerChange()}})}this.clearSearch()},onSortStart:function(){if(this.select){throw new Error("Sorting of elements is not supported when attached to instead.")}this.search.width(0);this.searchContainer.hide()},onSortEnd:function(){var I=[],H=this;this.searchContainer.show();this.searchContainer.appendTo(this.searchContainer.parent());this.resizeSearch();this.selection.find(".select2-search-choice").each(function(){I.push(H.opts.id(j(this).data("select2-data")))});this.setVal(I);this.triggerChange()},data:function(I){var H=this,J;if(arguments.length===0){return this.selection.find(".select2-search-choice").map(function(){return j(this).data("select2-data")}).get()}else{if(!I){I=[]}J=j.map(I,function(K){return H.opts.id(K)});this.setVal(J);this.updateSelection(I);this.clearSearch()}}});j.fn.select2=function(){var K=Array.prototype.slice.call(arguments,0),L,J,M,I,H=["val","destroy","opened","open","close","focus","isFocused","container","onSortStart","onSortEnd","enable","disable","positionDropdown","data"];this.each(function(){if(K.length===0||typeof(K[0])==="object"){L=K.length===0?{}:j.extend({},K[0]);L.element=j(this);if(L.element.get(0).tagName.toLowerCase()==="select"){I=L.element.attr("multiple")}else{I=L.multiple||false;if("tags" in L){L.multiple=I=true}}J=I?new G():new w();J.init(L)}else{if(typeof(K[0])==="string"){if(b(K[0],H)<0){throw"Unknown method: "+K[0]}M=l;J=j(this).data("select2");if(J===l){return}if(K[0]==="container"){M=J.container}else{M=J[K[0]].apply(J,K.slice(1))}if(M!==l){return false}}else{throw"Invalid arguments to select2 plugin: "+K}}});return(M===l)?this:M};j.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:true,openOnEnter:true,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(I,J,L,H){var K=[];i(I.text,L.term,K,H);return K.join("")},formatSelection:function(I,H){return I?I.text:l},sortResults:function(I,H,J){return I},formatResultCssClass:function(H){return l},formatNoMatches:function(){return"No matches found"},formatInputTooShort:function(H,I){var J=I-H.length;return"Please enter "+J+" more character"+(J==1?"":"s")},formatInputTooLong:function(I,H){var J=I.length-H;return"Please enter "+J+" less character"+(J==1?"":"s")},formatSelectionTooBig:function(H){return"You can only select "+H+" item"+(H==1?"":"s")},formatLoadMore:function(H){return"Loading more results..."},formatSearching:function(){return"Searching..."},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(H){return H.id},matcher:function(H,I){return I.toUpperCase().indexOf(H.toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:A,escapeMarkup:function(H){var I={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(H).replace(/[&<>"'/\\]/g,function(J){return I[J[0]]})},blurOnChange:false,selectOnBlur:false,adaptContainerCssClass:function(H){return H},adaptDropdownCssClass:function(H){return null}};window.Select2={query:{ajax:p,local:s,tags:o},util:{debounce:g,markMatch:i},"class":{"abstract":e,single:w,multi:G}}}(jQuery)); \ No newline at end of file diff --git a/django_select2/templatetags/django_select2_tags.py b/django_select2/templatetags/django_select2_tags.py index bc189ec..e2fce40 100644 --- a/django_select2/templatetags/django_select2_tags.py +++ b/django_select2/templatetags/django_select2_tags.py @@ -2,21 +2,31 @@ from django import template register = template.Library() -from ..widgets import HeavySelect2Widget +from ..widgets import HeavySelect2Widget, Select2Widget __proxy_widget = HeavySelect2Widget(data_view="xyz") +__proxy_light_widget = Select2Widget() @register.simple_tag(name='import_django_select2_js') -def import_js(): - return u'\n'.join(__proxy_widget.media.render_js()) +def import_js(light=0): + if light: + return u'\n'.join(__proxy_light_widget.media.render_js()) + else: + return u'\n'.join(__proxy_widget.media.render_js()) @register.simple_tag(name='import_django_select2_css') -def import_css(): - return u'\n'.join(__proxy_widget.media.render_css()) +def import_css(light=0): + if light: + return u'\n'.join(__proxy_light_widget.media.render_css()) + else: + return u'\n'.join(__proxy_widget.media.render_css()) @register.simple_tag(name='import_django_select2_js_css') -def import_all(): - return __proxy_widget.media.render() +def import_all(light=0): + if light: + return __proxy_light_widget.media.render() + else: + return __proxy_widget.media.render() diff --git a/django_select2/widgets.py b/django_select2/widgets.py index 88955b9..a2ee0ac 100644 --- a/django_select2/widgets.py +++ b/django_select2/widgets.py @@ -35,12 +35,18 @@ def get_select2_heavy_js_libs(): else: return libs + ('js/heavy_data.min.js', ) -def get_select2_css_libs(): +def get_select2_css_libs(light=False): from django.conf import settings if settings.configured and settings.DEBUG: - return ('css/select2.css', 'css/extra.css', ) + if light: + return ('css/select2.css',) + else: + return ('css/select2.css', 'css/extra.css', ) else: - return ('css/all.min.css', ) + if light: + return ('css/select2.min.css',) + else: + return ('css/all.min.css', ) ### Light mixin and widgets ### @@ -214,7 +220,7 @@ class Select2Mixin(object): class Media: js = get_select2_js_libs() - css = {'screen': get_select2_css_libs()} + css = {'screen': get_select2_css_libs(light=True)} class Select2Widget(Select2Mixin, forms.Select): @@ -458,7 +464,7 @@ class HeavySelect2Mixin(Select2Mixin): class Media: js = get_select2_heavy_js_libs() - css = {'screen': ('css/select2.css', 'css/extra.css', )} + css = {'screen': get_select2_css_libs()} class HeavySelect2Widget(HeavySelect2Mixin, forms.TextInput): diff --git a/docs/get_started.rst b/docs/get_started.rst index 182a17d..9766ec7 100644 --- a/docs/get_started.rst +++ b/docs/get_started.rst @@ -39,7 +39,11 @@ When this settings is ``False`` then you are responsible for including the JS an * ``import_django_select2_css`` - Outputs ```` tags to include all the CSS files, required by Light and Heavy widgets. * ``import_django_select2_js_css`` - Outputs both `` {% import_django_select2_js %} {% import_django_select2_css %} - {% import_django_select2_js_css %} + + {% import_django_select2_js_css light=1 %}