From 1aedde99d6318dbcf8d8b6b4ae77fa5d99a16585 Mon Sep 17 00:00:00 2001 From: "AppleGrew (applegrew)" Date: Sun, 13 Jan 2013 23:25:47 +0530 Subject: [PATCH] Now minifying CSS and JS files. During production they will be used intead. The minification process has been automated too. When sdist command is given to setup.py then it will use web-service to minify the js n css files. --- django_select2/static/css/all.min.css | 1 + django_select2/static/js/heavy_data.min.js | 1 + django_select2/static/js/select2.min.js | 83 +--------------------- django_select2/widgets.py | 9 ++- setup.py | 47 ++++++++++++ testapp/testapp/templates/500.html | 7 ++ 6 files changed, 65 insertions(+), 83 deletions(-) create mode 100644 django_select2/static/css/all.min.css create mode 100644 django_select2/static/js/heavy_data.min.js mode change 100755 => 100644 django_select2/static/js/select2.min.js create mode 100644 testapp/testapp/templates/500.html diff --git a/django_select2/static/css/all.min.css b/django_select2/static/css/all.min.css new file mode 100644 index 0000000..14dc0ce --- /dev/null +++ b/django_select2/static/css/all.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{-moz-box-sizing:border-box;-ms-box-sizing:border-box;-webkit-box-sizing:border-box;-khtml-box-sizing:border-box;box-sizing:border-box}.select2-container .select2-choice{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,#eee 0,#fff 50%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee',endColorstr = '#ffffff',GradientType = 0);background-image:linear-gradient(top,#eee 0,#fff 50%);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-moz-background-clip:padding;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #aaa;display:block;overflow:hidden;white-space:nowrap;position:relative;height:26px;line-height:26px;padding:0 0 0 8px;color:#444;text-decoration:none}.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='#eeeeee',endColorstr='#ffffff',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;-o-text-overflow:ellipsis;-ms-text-overflow:ellipsis;text-overflow:ellipsis}.select2-container .select2-choice abbr{display:block;position:absolute;right:26px;top:8px;width:12px;height:12px;font-size:1px;background:url('select2.png') right top no-repeat;cursor:pointer;text-decoration:none;border:0;outline:0}.select2-container .select2-choice abbr:hover{background-position:right -11px;cursor:pointer}.select2-drop{background:#fff;color:#000;border:1px solid #aaa;border-top:0;position:absolute;top:100%;-webkit-box-shadow:0 4px 5px rgba(0,0,0,.15);-moz-box-shadow:0 4px 5px rgba(0,0,0,.15);-o-box-shadow:0 4px 5px rgba(0,0,0,.15);box-shadow:0 4px 5px rgba(0,0,0,.15);z-index:9999;width:100%;margin-top:-1px;-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px}.select2-drop.select2-drop-above{-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0;margin-top:1px;border-top:1px solid #aaa;border-bottom:0;-webkit-box-shadow:0 -4px 5px rgba(0,0,0,.15);-moz-box-shadow:0 -4px 5px rgba(0,0,0,.15);-o-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{-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0;-moz-background-clip:padding;-webkit-background-clip:padding-box;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 = '#cccccc',endColorstr = '#eeeeee',GradientType = 0);background-image:linear-gradient(top,#ccc 0,#eee 60%);border-left:1px solid #aaa;position:absolute;right:0;top:0;display:block;height:100%;width:18px}.select2-container .select2-choice div b{background:url('select2.png') no-repeat 0 1px;display:block;width:100%;height:100%}.select2-search{display:inline-block;white-space:nowrap;z-index:10000;min-height:26px;width:100%;margin:0;padding-left:4px;padding-right:4px}.select2-search-hidden{display:block;position:absolute;left:-10000px}.select2-search input{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%);padding:4px 20px 4px 5px;outline:0;border:1px solid #aaa;font-family:sans-serif;font-size:1em;width:100%;margin:0;height:auto!important;min-height:26px;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;border-radius:0;-moz-border-radius:0;-webkit-border-radius:0}.select2-drop.select2-drop-above .select2-search input{margin-top:4px}.select2-search input.select2-active{background:#fff url('spinner.gif') no-repeat 100%;background:url('spinner.gif') no-repeat 100%,-webkit-gradient(linear,left bottom,left top,color-stop(0.85,white),color-stop(0.99,#eee));background:url('spinner.gif') no-repeat 100%,-webkit-linear-gradient(center bottom,white 85%,#eee 99%);background:url('spinner.gif') no-repeat 100%,-moz-linear-gradient(center bottom,white 85%,#eee 99%);background:url('spinner.gif') no-repeat 100%,-o-linear-gradient(bottom,white 85%,#eee 99%);background:url('spinner.gif') no-repeat 100%,-ms-linear-gradient(top,#fff 85%,#eee 99%);background:url('spinner.gif') no-repeat 100%,linear-gradient(top,#fff 85%,#eee 99%)}.select2-container-active .select2-choice,.select2-container-active .select2-choices{-webkit-box-shadow:0 0 5px rgba(0,0,0,.3);-moz-box-shadow:0 0 5px rgba(0,0,0,.3);-o-box-shadow:0 0 5px rgba(0,0,0,.3);box-shadow:0 0 5px rgba(0,0,0,.3);border:1px solid #5897fb;outline:0}.select2-dropdown-open .select2-choice{border:1px solid #aaa;border-bottom-color:transparent;-webkit-box-shadow:0 1px 0 #fff inset;-moz-box-shadow:0 1px 0 #fff inset;-o-box-shadow:0 1px 0 #fff inset;box-shadow:0 1px 0 #fff inset;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='#ffffff',endColorstr='#eeeeee',GradientType=0);background-image:linear-gradient(top,#fff 0,#eee 50%);-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;-moz-border-radius-bottomright:0;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-dropdown-open .select2-choice div{background:transparent;border-left:none}.select2-dropdown-open .select2-choice div b{background-position:-18px 1px}.select2-results{margin:4px 4px 4px 0;padding:0 0 0 4px;position:relative;overflow-x:hidden;overflow-y:auto;max-height:200px}.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}.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}.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-no-results,.select2-results .select2-searching,.select2-results .select2-selection-limit{background:#f4f4f4;display:list-item}.select2-results .select2-disabled{display:none}.select2-more-results.select2-active{background:#f4f4f4 url('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-multi .select2-choices{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%);border:1px solid #aaa;margin:0;padding:0;cursor:text;overflow:hidden;height:auto!important;height:1%;position:relative}.select2-container-multi .select2-choices{min-height:26px}.select2-container-multi.select2-container-active .select2-choices{-webkit-box-shadow:0 0 5px rgba(0,0,0,.3);-moz-box-shadow:0 0 5px rgba(0,0,0,.3);-o-box-shadow:0 0 5px rgba(0,0,0,.3);box-shadow:0 0 5px rgba(0,0,0,.3);border:1px solid #5897fb;outline:0}.select2-container-multi .select2-choices li{float:left;list-style:none}.select2-container-multi .select2-choices .select2-search-field{white-space:nowrap;margin:0;padding:0}.select2-container-multi .select2-choices .select2-search-field input{color:#666;background:transparent!important;font-family:sans-serif;font-size:100%;height:15px;padding:5px;margin:1px 0;outline:0;border:0;-webkit-box-shadow:none;-moz-box-shadow:none;-o-box-shadow:none;box-shadow:none}.select2-container-multi .select2-choices .select2-search-field input.select2-active{background:#fff url('spinner.gif') no-repeat 100%!important}.select2-default{color:#999!important}.select2-container-multi .select2-choices .select2-search-choice{-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;-moz-background-clip:padding;-webkit-background-clip:padding-box;background-clip:padding-box;background-color:#e4e4e4;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f4f4f4',endColorstr='#eeeeee',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%);-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);color:#333;border:1px solid #aaa;line-height:13px;padding:3px 5px 3px 18px;margin:3px 0 3px 5px;position:relative;cursor:default}.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;position:absolute;right:3px;top:4px;width:12px;height:13px;font-size:1px;background:url('select2.png') right top no-repeat;outline:0}.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{background-image:none;background-color:#f4f4f4;border:1px solid #ddd;padding:3px 5px 3px 5px}.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-result-selectable .select2-match{text-decoration:underline}.select2-result-unselectable .select2-match{text-decoration:none}.select2-offscreen{position:absolute;left:-10000px}@media only screen and (-webkit-min-device-pixel-ratio:1.5){.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}}.error a.select2-choice{border:1px solid #b94a48}.select2-container{min-width:150px}.select2-container.select2-container-multi{width:300px} \ No newline at end of file diff --git a/django_select2/static/js/heavy_data.min.js b/django_select2/static/js/heavy_data.min.js new file mode 100644 index 0000000..7bc84cb --- /dev/null +++ b/django_select2/static/js/heavy_data.min.js @@ -0,0 +1 @@ +if(!window.django_select2){var django_select2={MULTISEPARATOR:String.fromCharCode(0),get_url_params:function(c,e,b){var d=$(this).data("field_id"),a={term:c,page:e,context:b};if(d){a.field_id=d}return a},process_results:function(d,c,b){var a;if(d.err&&d.err.toLowerCase()==="nil"){a={results:d.results};if(b){a.context=b}if(d.more===true||d.more===false){a.more=d.more}}else{a={results:[]}}if(a.results){$(this).data("results",a.results)}else{$(this).removeData("results")}return a},onValChange:function(){django_select2.updateText($(this))},prepareValText:function(d,a,c){var b=[];$(d).each(function(e){b.push({id:this,text:a[e]})});if(c){return b}else{if(b.length>0){return b[0]}else{return null}}},updateText:function(b){var f=b.select2("val"),d=b.select2("data"),a=b.txt(),c=!!b.attr("multiple"),e;if(f||f===0){if(c){if(f.length!==a.length){a=[];$(f).each(function(g){var h,j=this,k;for(h in d){k=d[h].id;if(k instanceof String){k=k.valueOf()}if(k==j){a.push(d[h].text)}}})}}else{a=d.text}b.txt(a)}else{b.txt("")}},getValText:function(b){var g=b.select2("val"),c=b.data("results"),a=b.txt(),e=!!b.attr("multiple"),d,h=b.attr("id");if(g||g===0){if(!e){g=[g];if(a||a===0){a=[a]}}if(a===0||(a&&g.length===a.length)){return[g,a]}d=b.data("userGetValText");if(d){a=d(b,g,e);if(a||a===0){return[g,a]}}if(c){a=[];$(g).each(function(f){var j,k=this;for(j in c){if(c[j].id==k){g[f]=c[j].id;a.push(c[j].text)}}});if(a||a===0){return[g,a]}}}return null},onInit:function(b,f){b=$(b);var d=b.attr("id"),a=null,c=b.select2("val");if(!c&&c!==0){c=b.data("initVal")}if(c||c===0){a=django_select2.getValText(b);if(a&&a[0]){a=django_select2.prepareValText(a[0],a[1],!!b.attr("multiple"))}}if(!a){b.val(null)}f(a);django_select2.updateText(b)},onMultipleHiddenChange:function(){var b=$(this),d=b.data("valContainer"),a=b.data("name"),c=b.val();d.empty();if(c){c=c.split(django_select2.MULTISEPARATOR);$(c).each(function(){var e=$('').appendTo(d);e.attr("name",a);e.val(this)})}},initMultipleHidden:function(a){var b;a.data("name",a.attr("name"));a.attr("name","");b=$("
").insertAfter(a).css({display:"none"});a.data("valContainer",b);a.change(django_select2.onMultipleHiddenChange);if(a.val()){a.change()}},convertArrToStr:function(a){return a.join(django_select2.MULTISEPARATOR)},runInContextHelper:function(a,b){return function(){var c=Array.prototype.slice.call(arguments);return a.apply($("#"+b).get(0),c)}},logErr:function(){if(console&&console.error){args=Array.prototype.slice.call(arguments);console.error.apply(console,args)}},};(function(a){a.fn.txt=function(b){if(typeof(b)!=="undefined"){if(b){if(b instanceof Array){if(this.attr("multiple")){b=django_select2.convertArrToStr(b)}else{b=b[0]}}this.attr("txt",b)}else{this.removeAttr("txt")}return this}else{b=this.attr("txt");if(this.attr("multiple")){if(b){b=b.split(django_select2.MULTISEPARATOR)}else{b=[]}}return b}}})(jQuery)}; \ No newline at end of file diff --git a/django_select2/static/js/select2.min.js b/django_select2/static/js/select2.min.js old mode 100755 new mode 100644 index 1523735..02877fe --- a/django_select2/static/js/select2.min.js +++ b/django_select2/static/js/select2.min.js @@ -1,82 +1 @@ -/* -Copyright 2012 Igor Vaynberg - -Version: 3.2 Timestamp: Mon Sep 10 10:38:04 PDT 2012 - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in -compliance with the License. You may obtain a copy of the License in the LICENSE file, or at: - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed under the License is -distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and limitations under the License. -*/ -(function(e){"undefined"==typeof e.fn.each2&&e.fn.extend({each2:function(g){for(var i=e([0]),m=-1,s=this.length;++ma.length)return[]; -c=a.split(b);d=0;for(j=c.length;dd?c.push(a):(c.push(a.substring(0,d)),c.push(""),c.push(a.substring(d,d+b)),c.push(""),c.push(a.substring(d+b,a.length)))}function C(a){var b, -c=0,d=null,j=a.quietMillis||100;return function(h){window.clearTimeout(b);b=window.setTimeout(function(){var b=c+=1,j=a.data,n=a.transport||e.ajax,f=a.traditional||!1,g=a.type||"GET",j=j.call(this,h.term,h.page,h.context);null!==d&&d.abort();d=n.call(null,{url:a.url,dataType:a.dataType,data:j,type:g,traditional:f,success:function(d){bd.tokenSeparators.length)return g;for(;;){h=-1;k=0; -for(n=d.tokenSeparators.length;kh)break;f=a.substring(0,h);a=a.substring(h+o.length);if(0=a}};var I=1;G=function(){return I++}; -e(document).delegate("body","mousemove",function(a){e.data(document,"select2-lastpos",{x:a.pageX,y:a.pageY})});e(document).ready(function(){e(document).delegate("body","mousedown touchend",function(a){var b=e(a.target).closest("div.select2-container").get(0),c;b?e(document).find("div.select2-container-active").each(function(){this!==b&&e(this).data("select2").blur()}):(b=e(a.target).closest("div.select2-drop").get(0),e(document).find("div.select2-drop-active").each(function(){this!==b&&e(this).data("select2").blur()})); -b=e(a.target);c=b.attr("for");"LABEL"===a.target.tagName&&(c&&0\|])/g,"\\$1");this.container.attr("id",this.containerId);var d=!1,j;this.body=function(){!1===d&&(j=a.element.closest("body"),d=!0);return j};a.element.attr("class")!==g&&this.container.addClass(a.element.attr("class").replace(/validate\[[\S ]+] ?/,""));this.container.css(v(a.containerCss));this.container.addClass(v(a.containerCssClass));this.opts.element.data("select2",this).hide().before(this.container);this.container.data("select2", -this);this.dropdown=this.container.find(".select2-drop");this.dropdown.addClass(v(a.dropdownCssClass));this.dropdown.data("select2",this);this.results=b=this.container.find(".select2-results");this.search=c=this.container.find("input.select2-input");c.attr("tabIndex",this.opts.element.attr("tabIndex"));this.resultsPage=0;this.context=null;this.initContainer();this.initContainerWidth();this.results.bind("mousemove",function(a){var b=e.data(document,"select2-lastpos");(b===g||b.x!==a.pageX||b.y!==a.pageY)&& -e(a.target).trigger("mousemove-filtered",a)});this.dropdown.delegate(".select2-results","mousemove-filtered",this.bind(this.highlightUnderEvent));var h=this.results,f=A(80,function(a){h.trigger("scroll-debounced",a)});h.bind("scroll",function(a){0<=i(a.target,h.get())&&f(a)});this.dropdown.delegate(".select2-results","scroll-debounced",this.bind(this.loadMoreIfNeeded));e.fn.mousewheel&&b.mousewheel(function(a,c,d,e){c=b.scrollTop();0=c-e?(b.scrollTop(0),l(a)):0>e&&b.get(0).scrollHeight-b.scrollTop()+ -e<=b.height()&&(b.scrollTop(b.get(0).scrollHeight-b.height()),l(a))});c.bind("keydown",function(){e.data(c,"keyup-change-value")===g&&e.data(c,"keyup-change-value",c.val())});c.bind("keyup",function(){var a=e.data(c,"keyup-change-value");a!==g&&c.val()!==a&&(e.removeData(c,"keyup-change-value"),c.trigger("keyup-change"))});c.bind("keyup-change",this.bind(this.updateResults));c.bind("focus",function(){c.addClass("select2-focused");" "===c.val()&&c.val("")});c.bind("blur",function(){c.removeClass("select2-focused")}); -this.dropdown.delegate(".select2-results","mouseup",this.bind(function(a){0 element.");});a=e.extend({},{populateResults:function(b, -c,d){var f,n=this.opts.id,o=this;f=function(b,c,j){var h,l,i,m,r,p,q;h=0;for(l=b.length;h0;p=e("
  • ");p.addClass("select2-results-dept-"+j);p.addClass("select2-result");p.addClass(m?"select2-result-selectable":"select2-result-unselectable");r&&p.addClass("select2-result-with-children");p.addClass(o.opts.formatResultCssClass(i));m=e("
    ");m.addClass("select2-result-label");q=a.formatResult(i,m,d);q!==g&&m.html(o.opts.escapeMarkup(q)); -p.append(m);if(r){r=e("
      ");r.addClass("select2-result-sub");f(i.children,r,j+1);p.append(r)}p.data("select2-data",i);c.append(p)}};f(c,b,0)}},e.fn.select2.defaults,a);"function"!==typeof a.id&&(d=a.id,a.id=function(a){return a[d]});if(c)a.query=this.bind(function(a){var c={results:[],more:false},d=a.term,f,n,o;o=function(b,c){var e;if(b.is("option"))a.matcher(d,b.text(),b)&&c.push({id:b.attr("value"),text:b.text(),element:b.get(),css:b.attr("class")});else if(b.is("optgroup")){e={text:b.attr("label"), -children:[],element:b.get(),css:b.attr("class")};b.children().each2(function(a,b){o(b,e.children)});e.children.length>0&&c.push(e)}};f=b.children();if(this.getPlaceholder()!==g&&f.length>0){n=f[0];e(n).text()===""&&(f=f.not(n))}f.each2(function(a,b){o(b,c.results)});a.callback(c)}),a.id=function(a){return a.id},a.formatResultCssClass=function(a){return a.css};else if(!("query"in a))if("ajax"in a){if((c=a.element.data("ajax-url"))&&0=this.body().scrollTop(),k=this.dropdown.hasClass("select2-drop-above"),n;"static"!==this.body().css("position")&& -(n=this.body().offset(),b-=n.top,f-=n.left);k?(k=!0,!g&&j&&(k=!1)):(k=!1,!j&&g&&(k=!0));k?(b=a.top-d,this.container.addClass("select2-drop-above"),this.dropdown.addClass("select2-drop-above")):(this.container.removeClass("select2-drop-above"),this.dropdown.removeClass("select2-drop-above"));a=e.extend({top:b,left:f,width:c},v(this.opts.dropdownCss));this.dropdown.css(a)},shouldOpen:function(){var a;if(this.opened())return!1;a=e.Event("open");this.opts.element.trigger(a);return!a.isDefaultPrevented()}, -clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above");this.dropdown.removeClass("select2-drop-above")},open:function(){if(!this.shouldOpen())return!1;window.setTimeout(this.bind(this.opening),1);return!0},opening:function(){var a=this.containerId,b=this.containerSelector,c="scroll."+a,d="resize."+a;this.container.parents().each(function(){e(this).bind(c,function(){var a=e(b);0==a.length&&e(this).unbind(c);a.select2("close")})});e(window).bind(d,function(){var a= -e(b);0==a.length&&e(window).unbind(d);a.select2("close")});this.clearDropdownAlignmentPreference();" "===this.search.val()&&this.search.val("");this.container.addClass("select2-dropdown-open").addClass("select2-container-active");this.updateResults(!0);this.dropdown[0]!==this.body().children().last()[0]&&this.dropdown.detach().appendTo(this.body());this.dropdown.show();this.positionDropdown();this.dropdown.addClass("select2-drop-active");this.ensureHighlightVisible();this.focusSearch()},close:function(){if(this.opened()){var a= -this;this.container.parents().each(function(){e(this).unbind("scroll."+a.containerId)});e(window).unbind("resize."+this.containerId);this.clearDropdownAlignmentPreference();this.dropdown.hide();this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active");this.results.empty();this.clearSearch();this.opts.element.trigger(e.Event("close"))}},clearSearch:function(){},ensureHighlightVisible:function(){var a=this.results,b,c,d,f;c=this.highlight();0>c||(0==c?a.scrollTop(0): -(b=a.find(".select2-result-selectable"),d=e(b[c]),f=d.offset().top+d.outerHeight(),c===b.length-1&&(b=a.find("li.select2-more-results"),0b&&a.scrollTop(a.scrollTop()+(f-b)),d=d.offset().top-a.offset().top,0>d&&a.scrollTop(a.scrollTop()+d)))},moveHighlight:function(a){for(var b=this.results.find(".select2-result-selectable"),c=this.highlight();-1=b.length&&(a=b.length-1);0>a&&(a=0);b.removeClass("select2-highlighted");e(b[a]).addClass("select2-highlighted");this.ensureHighlightVisible()},countSelectableResults:function(){return this.results.find(".select2-result-selectable").not(".select2-disabled").length}, -highlightUnderEvent:function(a){a=e(a.target).closest(".select2-result-selectable");if(0=c&&(b.addClass("select2-active"),this.opts.query({term:f,page:d,context:g,matcher:this.opts.matcher,callback:this.bind(function(c){e.opened()&&(e.opts.populateResults.call(this,a,c.results,{term:f,page:d,context:g}),!0===c.more?(b.detach().appendTo(a).text(e.opts.formatLoadMore(d+1)),window.setTimeout(function(){e.loadMoreIfNeeded()},10)):b.remove(),e.positionDropdown(),e.resultsPage=d)})})))},tokenize:function(){},updateResults:function(a){function b(){f.scrollTop(0);d.removeClass("select2-active"); -k.positionDropdown()}function c(a){f.html(k.opts.escapeMarkup(a));b()}var d=this.search,f=this.results,h=this.opts,i,k=this;if(!(!0!==a&&(!1===this.showSearchInput||!this.opened()))){d.addClass("select2-active");if(1<=h.maximumSelectionSize&&(i=this.data(),e.isArray(i)&&i.length>=h.maximumSelectionSize&&u(h.formatSelectionTooBig,"formatSelectionTooBig"))){c("
    • "+h.formatSelectionTooBig(h.maximumSelectionSize)+"
    • ");return}d.val().length"+h.formatInputTooShort(d.val(),h.minimumInputLength)+""):(c("
    • "+h.formatSearching()+"
    • "),i=this.tokenize(),i!=g&&null!=i&&d.val(i),this.resultsPage=1,h.query({term:d.val(),page:this.resultsPage,context:null,matcher:h.matcher,callback:this.bind(function(i){var l;this.opened()&&((this.context=i.context===g?null:i.context,this.opts.createSearchChoice&&""!==d.val()&&(l=this.opts.createSearchChoice.call(null, -d.val(),i.results),l!==g&&null!==l&&k.id(l)!==g&&null!==k.id(l)&&0===e(i.results).filter(function(){return m(k.id(this),k.id(l))}).length&&i.results.unshift(l)),0===i.results.length&&u(h.formatNoMatches,"formatNoMatches"))?c("
    • "+h.formatNoMatches(d.val())+"
    • "):(f.empty(),k.opts.populateResults.call(this,f,i.results,{term:d.val(),page:this.resultsPage,context:null}),!0===i.more&&u(h.formatLoadMore,"formatLoadMore")&&(f.append("
    • "+k.opts.escapeMarkup(h.formatLoadMore(this.resultsPage))+ -"
    • "),window.setTimeout(function(){k.loadMoreIfNeeded()},10)),this.postprocessResults(i,a),b()))})}))}},cancel:function(){this.close()},blur:function(){this.close();this.container.removeClass("select2-container-active");this.dropdown.removeClass("select2-drop-active");this.search[0]===document.activeElement&&this.search.blur();this.clearSearch();this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){this.search.show();this.search.focus(); -window.setTimeout(this.bind(function(){this.search.show();this.search.focus();this.search.val(this.search.val())}),10)},selectHighlighted:function(){var a=this.highlight(),b=this.results.find(".select2-highlighted").not(".select2-disabled"),c=b.closest(".select2-result-selectable").data("select2-data");c&&(b.addClass("select2-disabled"),this.highlight(a),this.onSelect(c))},getPlaceholder:function(){return this.opts.element.attr("placeholder")||this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")|| -this.opts.placeholder},initContainerWidth:function(){var a=function(){var a,c,d,f;if("off"===this.opts.width)return null;if("element"===this.opts.width)return 0===this.opts.element.outerWidth()?"auto":this.opts.element.outerWidth()+"px";if("copy"===this.opts.width||"resolve"===this.opts.width){a=this.opts.element.attr("style");if(a!==g){a=a.split(";");d=0;for(f=a.length;d
      ",{"class":"select2-container"}).html("
      ")}, -opening:function(){this.search.show();this.parent.opening.apply(this,arguments);this.dropdown.removeClass("select2-offscreen")},close:function(){this.opened()&&(this.parent.close.apply(this,arguments),this.dropdown.removeAttr("style").addClass("select2-offscreen").insertAfter(this.selection).show())},focus:function(){this.close();this.selection.focus()},isFocused:function(){return this.selection[0]===document.activeElement},cancel:function(){this.parent.cancel.apply(this,arguments);this.selection.focus()}, -initContainer:function(){var a,b=this.dropdown;this.selection=a=this.container.find(".select2-choice");this.search.bind("keydown",this.bind(function(a){if(this.enabled)if(a.which===f.PAGE_UP||a.which===f.PAGE_DOWN)l(a);else if(this.opened())switch(a.which){case f.UP:case f.DOWN:this.moveHighlight(a.which===f.UP?-1:1);l(a);break;case f.TAB:case f.ENTER:this.selectHighlighted();l(a);break;case f.ESC:this.cancel(a),l(a)}else a.which===f.TAB||f.isControl(a)||f.isFunctionKey(a)||a.which===f.ESC||!1=== -this.opts.openOnEnter&&a.which===f.ENTER||this.open()}));this.search.bind("focus",this.bind(function(){this.selection.attr("tabIndex","-1")}));this.search.bind("blur",this.bind(function(){this.opened()||this.container.removeClass("select2-container-active");window.setTimeout(this.bind(function(){this.selection.attr("tabIndex",this.opts.element.attr("tabIndex"))}),10)}));a.bind("mousedown",this.bind(function(){this.opened()?(this.close(),this.selection.focus()):this.enabled&&this.open()}));b.bind("mousedown", -this.bind(function(){this.search.focus()}));a.bind("focus",this.bind(function(){this.container.addClass("select2-container-active");this.search.attr("tabIndex","-1")}));a.bind("blur",this.bind(function(){this.opened()||this.container.removeClass("select2-container-active");window.setTimeout(this.bind(function(){this.search.attr("tabIndex",this.opts.element.attr("tabIndex"))}),10)}));a.bind("keydown",this.bind(function(a){if(this.enabled)if(a.which===f.PAGE_UP||a.which===f.PAGE_DOWN)l(a);else if(!(a.which=== -f.TAB||f.isControl(a)||f.isFunctionKey(a)||a.which===f.ESC)&&!(!1===this.opts.openOnEnter&&a.which===f.ENTER))if(a.which==f.DELETE)this.opts.allowClear&&this.clear();else{this.open();if(a.which!==f.ENTER&&!(48>a.which)){var b=String.fromCharCode(a.which).toLowerCase();a.shiftKey&&(b=b.toUpperCase());this.search.focus();this.search.val(b)}l(a)}}));a.delegate("abbr","mousedown",this.bind(function(a){this.enabled&&(this.clear(),l(a),this.close(),this.triggerChange(),this.selection.focus())}));this.setPlaceholder(); -this.search.bind("focus",this.bind(function(){this.container.addClass("select2-container-active")}))},clear:function(){this.opts.element.val("");this.selection.find("span").empty();this.selection.removeData("select2-data");this.setPlaceholder()},initSelection:function(){if(""===this.opts.element.val())this.close(),this.setPlaceholder();else{var a=this;this.opts.initSelection.call(null,this.opts.element,function(b){b!==g&&null!==b&&(a.updateSelection(b),a.close(),a.setPlaceholder())})}},prepareOpts:function(){var a= -this.parent.prepareOpts.apply(this,arguments);"select"===a.element.get(0).tagName.toLowerCase()&&(a.initSelection=function(a,c){var d=a.find(":selected");e.isFunction(c)&&c({id:d.attr("value"),text:d.text()})});return a},setPlaceholder:function(){var a=this.getPlaceholder();""===this.opts.element.val()&&a!==g&&!(this.select&&""!==this.select.find("option:first").text())&&(this.selection.find("span").html(this.opts.escapeMarkup(a)),this.selection.addClass("select2-default"),this.selection.find("abbr").hide())}, -postprocessResults:function(a,b){var c=0,d=this,f=!0;this.results.find(".select2-result-selectable").each2(function(a,b){if(m(d.id(b.data("select2-data")),d.opts.element.val()))return c=a,!1});this.highlight(c);!0===b&&(f=this.showSearchInput=F(a.results)>=this.opts.minimumResultsForSearch,this.dropdown.find(".select2-search")[f?"removeClass":"addClass"]("select2-search-hidden"),e(this.dropdown,this.container)[f?"addClass":"removeClass"]("select2-with-searchbox"))},onSelect:function(a){var b=this.opts.element.val(); -this.opts.element.val(this.id(a));this.updateSelection(a);this.close();this.selection.focus();m(b,this.id(a))||this.triggerChange()},updateSelection:function(a){var b=this.selection.find("span");this.selection.data("select2-data",a);b.empty();a=this.opts.formatSelection(a,b);a!==g&&b.append(this.opts.escapeMarkup(a));this.selection.removeClass("select2-default");this.opts.allowClear&&this.getPlaceholder()!==g&&this.selection.find("abbr").show()},val:function(){var a,b=null,c=this;if(0===arguments.length)return this.opts.element.val(); -a=arguments[0];if(this.select)this.select.val(a).find(":selected").each2(function(a,c){b={id:c.attr("value"),text:c.text()};return!1}),this.updateSelection(b),this.setPlaceholder();else{if(this.opts.initSelection===g)throw Error("cannot call val() if initSelection() is not defined");a?(this.opts.element.val(a),this.opts.initSelection(this.opts.element,function(a){c.opts.element.val(!a?"":c.id(a));c.updateSelection(a);c.setPlaceholder()})):this.clear()}},clearSearch:function(){this.search.val("")}, -data:function(a){var b;if(0===arguments.length)return b=this.selection.data("select2-data"),b==g&&(b=null),b;!a||""===a?this.clear():(this.opts.element.val(!a?"":this.id(a)),this.updateSelection(a))}});z=x(w,{createContainer:function(){return e("
      ",{"class":"select2-container select2-container-multi"}).html(" ")}, -prepareOpts:function(){var a=this.parent.prepareOpts.apply(this,arguments);"select"===a.element.get(0).tagName.toLowerCase()&&(a.initSelection=function(a,c){var d=[];a.find(":selected").each2(function(a,b){d.push({id:b.attr("value"),text:b.text()})});e.isFunction(c)&&c(d)});return a},initContainer:function(){var a;this.searchContainer=this.container.find(".select2-search-field");this.selection=a=this.container.find(".select2-choices");this.search.bind("keydown",this.bind(function(b){if(this.enabled){if(b.which=== -f.BACKSPACE&&""===this.search.val()){this.close();var c;c=a.find(".select2-search-choice-focus");if(0i(d.id(this),b)&&(b.push(d.id(this)),c.push(this))});a=c;this.selection.find(".select2-search-choice").remove();e(a).each(function(){d.addSelectedChoice(this)});d.postprocessResults()},tokenize:function(){var a=this.search.val(),a=this.opts.tokenizer(a,this.data(),this.bind(this.onSelect), -this.opts);null!=a&&a!=g&&(this.search.val(a),0
      "), -c=this.id(a),d=this.getVal(),f;f=this.opts.formatSelection(a,b);b.find("div").replaceWith("
      "+this.opts.escapeMarkup(f)+"
      ");b.find(".select2-search-choice-close").bind("mousedown",l).bind("click dblclick",this.bind(function(a){this.enabled&&(e(a.target).closest(".select2-search-choice").fadeOut("fast",this.bind(function(){this.unselect(e(a.target));this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");this.close();this.focusSearch()})).dequeue(), -l(a))})).bind("focus",this.bind(function(){this.enabled&&(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"))}));b.data("select2-data",a);b.insertBefore(this.searchContainer);d.push(c);this.setVal(d)},unselect:function(a){var b=this.getVal(),c,d,a=a.closest(".select2-search-choice");if(0===a.length)throw"Invalid argument: "+a+". Must be .select2-search-choice";c=a.data("select2-data");d=i(this.id(c),b);0<=d&&(b.splice(d,1),this.setVal(b),this.select&& -this.postprocessResults());a.remove();this.triggerChange({removed:c})},postprocessResults:function(){var a=this.getVal(),b=this.results.find(".select2-result-selectable"),c=this.results.find(".select2-result-with-children"),d=this;b.each2(function(b,c){var e=d.id(c.data("select2-data"));0<=i(e,a)?c.addClass("select2-disabled").removeClass("select2-result-selectable"):c.removeClass("select2-disabled").addClass("select2-result-selectable")});c.each2(function(a,b){0==b.find(".select2-result-selectable").length? -b.addClass("select2-disabled"):b.removeClass("select2-disabled")});b.each2(function(a,b){if(!b.hasClass("select2-disabled")&&b.hasClass("select2-result-selectable"))return d.highlight(0),!1})},resizeSearch:function(){var a,b,c,d,f=this.search.outerWidth()-this.search.width();a=this.search;q||(c=a[0].currentStyle||window.getComputedStyle(a[0],null),q=e("
      ").css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:c.fontSize,fontFamily:c.fontFamily,fontStyle:c.fontStyle, -fontWeight:c.fontWeight,letterSpacing:c.letterSpacing,textTransform:c.textTransform,whiteSpace:"nowrap"}),e("body").append(q));q.text(a.val());a=q.width()+10;b=this.search.offset().left;c=this.selection.width();d=this.selection.offset().left;b=c-(b-d)-f;bb&&(b=c-f);this.search.width(b)},getVal:function(){var a;if(this.select)return a=this.select.val(),null===a?[]:a;a=this.opts.element.val();return s(a,this.opts.separator)},setVal:function(a){var b;this.select?this.select.val(a):(b= -[],e(a).each(function(){0>i(this,b)&&b.push(this)}),this.opts.element.val(0===b.length?"":b.join(this.opts.separator)))},val:function(){var a,b=[],c=this;if(0===arguments.length)return this.getVal();if(a=arguments[0])if(this.setVal(a),this.select)this.select.find(":selected").each(function(){b.push({id:e(this).attr("value"),text:e(this).text()})}),this.updateSelection(b);else{if(this.opts.initSelection===g)throw Error("val() cannot be called if initSelection() is not defined");this.opts.initSelection(this.opts.element, -function(a){var b=e(a).map(c.id);c.setVal(b);c.updateSelection(a);c.clearSearch()})}else this.opts.element.val(""),this.updateSelection([]);this.clearSearch()},onSortStart:function(){if(this.select)throw Error("Sorting of elements is not supported when attached to instead.");this.search.width(0);this.searchContainer.hide()},onSortEnd:function(){var a=[],b=this;this.searchContainer.show();this.searchContainer.appendTo(this.searchContainer.parent());this.resizeSearch(); -this.selection.find(".select2-search-choice").each(function(){a.push(b.opts.id(e(this).data("select2-data")))});this.setVal(a);this.triggerChange()},data:function(a){var b=this,c;if(0===arguments.length)return this.selection.find(".select2-search-choice").map(function(){return e(this).data("select2-data")}).get();a||(a=[]);c=e.map(a,function(a){return b.opts.id(a)});this.setVal(c);this.updateSelection(a);this.clearSearch()}});e.fn.select2=function(){var a=Array.prototype.slice.call(arguments,0),b, -c,d,f,h="val destroy opened open close focus isFocused container onSortStart onSortEnd enable disable positionDropdown data".split(" ");this.each(function(){if(0===a.length||"object"===typeof a[0])b=0===a.length?{}:e.extend({},a[0]),b.element=e(this),"select"===b.element.get(0).tagName.toLowerCase()?f=b.element.attr("multiple"):(f=b.multiple||!1,"tags"in b&&(b.multiple=f=!0)),c=f?new z:new y,c.init(b);else if("string"===typeof a[0]){if(0>i(a[0],h))throw"Unknown method: "+a[0];d=g;c=e(this).data("select2"); -if(c!==g&&(d="container"===a[0]?c.container:c[a[0]].apply(c,a.slice(1)),d!==g))return!1}else throw"Invalid arguments to select2 plugin: "+a;});return d===g?this:d};e.fn.select2.defaults={width:"copy",closeOnSelect:!0,openOnEnter:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(a,b,c){b=[];B(a.text,c.term,b);return b.join("")},formatSelection:function(a){return a?a.text:g},formatResultCssClass:function(){return g},formatNoMatches:function(){return"No matches found"}, -formatInputTooShort:function(a,b){return"Please enter "+(b-a.length)+" more characters"},formatSelectionTooBig:function(a){return"You can only select "+a+" item"+(1==a?"":"s")},formatLoadMore:function(){return"Loading more results..."},formatSearching:function(){return"Searching..."},minimumResultsForSearch:0,minimumInputLength:0,maximumSelectionSize:0,id:function(a){return a.id},matcher:function(a,b){return 0<=b.toUpperCase().indexOf(a.toUpperCase())},separator:",",tokenSeparators:[],tokenizer:H, -escapeMarkup:function(a){return a&&"string"===typeof a?a.replace(/&/g,"&"):a},blurOnChange:!1};window.Select2={query:{ajax:C,local:D,tags:E},util:{debounce:A,markMatch:B},"class":{"abstract":w,single:y,multi:z}}}})(jQuery); +(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&&C<=123}};t=(function(){var C=1;return function(){return C++}}());function b(F,G){var E=0,C=G.length,D;if(typeof F==="undefined"){return -1}if(F.constructor===String){for(;E=0){D(F)}})}function d(C){C.preventDefault();C.stopPropagation()}function x(D){if(!a){var C=D[0].currentStyle||window.getComputedStyle(D[0],null);a=j("
      ").css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:C.fontSize,fontFamily:C.fontFamily,fontStyle:C.fontStyle,fontWeight:C.fontWeight,letterSpacing:C.letterSpacing,textTransform:C.textTransform,whiteSpace:"nowrap"});j("body").append(a)}a.text(D.val());return a.width()}function i(G,F,D){var E=G.toUpperCase().indexOf(F.toUpperCase()),C=F.length;if(E<0){D.push(G);return}D.push(G.substring(0,E));D.push("");D.push(G.substring(E,E+C));D.push("");D.push(G.substring(E+C,G.length))}function p(D){var F,C=0,E=null,G=D.quietMillis||100;return function(H){window.clearTimeout(F);F=window.setTimeout(function(){C+=1;var I=C,L=D.data,M=D.transport||j.ajax,K=D.traditional||false,J=D.type||"GET";L=L.call(this,H.term,H.page,H.context);if(null!==E){E.abort()}E=M.call(null,{url:D.url,dataType:D.dataType,data:L,type:J,traditional:K,success:function(O){if(I=0){break}}if(J<0){break}F=K.substring(0,J);K=K.substring(J+H.length);if(F.length>0){F=C.createSearchChoice(F,L);if(F!==l&&F!==null&&C.id(F)!==l&&C.id(F)!==null){M=false;for(G=0,E=L.length;G0){D=j("#"+C);D=D.data("select2");if(D!==l){D.focus();E.preventDefault()}}})});function w(C,D){var E=function(){};E.prototype=new C;E.prototype.constructor=E;E.prototype.parent=C.prototype;E.prototype=j.extend(E.prototype,D);return E}e=w(Object,{bind:function(D){var C=this;return function(){D.apply(C,arguments)}},init:function(E){var D,C,F=".select2-results";this.opts=E=this.prepareOpts(E);this.id=E.id;if(E.element.data("select2")!==l&&E.element.data("select2")!==null){this.destroy()}this.enabled=true;this.container=this.createContainer();this.containerId="s2id_"+(E.element.attr("id")||"autogen"+t());this.containerSelector="#"+this.containerId.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\$1");this.container.attr("id",this.containerId);this.body=A(function(){return E.element.closest("body")});if(E.element.attr("class")!==l){this.container.addClass(E.element.attr("class").replace(/validate\[[\S ]+] ?/,""))}this.container.css(s(E.containerCss));this.container.addClass(s(E.containerCssClass));this.opts.element.data("select2",this).hide().before(this.container);this.container.data("select2",this);this.dropdown=this.container.find(".select2-drop");this.dropdown.addClass(s(E.dropdownCssClass));this.dropdown.data("select2",this);this.results=D=this.container.find(F);this.search=C=this.container.find("input.select2-input");C.attr("tabIndex",this.opts.element.attr("tabIndex"));this.resultsPage=0;this.context=null;this.initContainer();this.initContainerWidth();u(this.results);this.dropdown.delegate(F,"mousemove-filtered",this.bind(this.highlightUnderEvent));g(80,this.results);this.dropdown.delegate(F,"scroll-debounced",this.bind(this.loadMoreIfNeeded));if(j.fn.mousewheel){D.mousewheel(function(K,L,I,H){var J=D.scrollTop(),G;if(H>0&&J-H<=0){D.scrollTop(0);d(K)}else{if(H<0&&D.get(0).scrollHeight-D.scrollTop()+H<=D.height()){D.scrollTop(D.get(0).scrollHeight-D.height());d(K)}}})}z(C);C.bind("keyup-change",this.bind(this.updateResults));C.bind("focus",function(){C.addClass("select2-focused");if(C.val()===" "){C.val("")}});C.bind("blur",function(){C.removeClass("select2-focused")});this.dropdown.delegate(F,"mouseup",this.bind(function(G){if(j(G.target).closest(".select2-result-selectable:not(.select2-disabled)").length>0){this.highlightUnderEvent(G);this.selectHighlighted(G)}else{this.focusSearch()}d(G)}));this.dropdown.bind("click mouseup mousedown",function(G){G.stopPropagation()});if(j.isFunction(this.opts.initSelection)){this.initSelection();this.monitorSource()}if(E.element.is(":disabled")||E.element.is("[readonly='readonly']")){this.disable()}},destroy:function(){var C=this.opts.element.data("select2");if(C!==l){C.container.remove();C.dropdown.remove();C.opts.element.removeData("select2").unbind(".select2").show()}},prepareOpts:function(G){var E,D,C,F;E=G.element;if(E.get(0).tagName.toLowerCase()==="select"){this.select=D=G.element}if(D){j.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in G){throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a "," ","
        ","
      ",""].join(""));return C},opening:function(){this.search.show();this.parent.opening.apply(this,arguments);this.dropdown.removeClass("select2-offscreen")},close:function(){if(!this.opened()){return}this.parent.close.apply(this,arguments);this.dropdown.removeAttr("style").addClass("select2-offscreen").insertAfter(this.selection).show()},focus:function(){this.close();this.selection.focus()},isFocused:function(){return this.selection[0]===document.activeElement},cancel:function(){this.parent.cancel.apply(this,arguments);this.selection.focus()},initContainer:function(){var E,D=this.container,F=this.dropdown,C=false;this.selection=E=D.find(".select2-choice");this.search.bind("keydown",this.bind(function(G){if(!this.enabled){return}if(G.which===c.PAGE_UP||G.which===c.PAGE_DOWN){d(G);return}if(this.opened()){switch(G.which){case c.UP:case c.DOWN:this.moveHighlight((G.which===c.UP)?-1:1);d(G);return;case c.TAB:case c.ENTER:this.selectHighlighted();d(G);return;case c.ESC:this.cancel(G);d(G);return}}else{if(G.which===c.TAB||c.isControl(G)||c.isFunctionKey(G)||G.which===c.ESC){return}if(this.opts.openOnEnter===false&&G.which===c.ENTER){return}this.open();if(G.which===c.ENTER){return}}}));this.search.bind("focus",this.bind(function(){this.selection.attr("tabIndex","-1")}));this.search.bind("blur",this.bind(function(){if(!this.opened()){this.container.removeClass("select2-container-active")}window.setTimeout(this.bind(function(){this.selection.attr("tabIndex",this.opts.element.attr("tabIndex"))}),10)}));E.bind("mousedown",this.bind(function(G){C=true;if(this.opened()){this.close();this.selection.focus()}else{if(this.enabled){this.open()}}C=false}));F.bind("mousedown",this.bind(function(){this.search.focus()}));E.bind("focus",this.bind(function(){this.container.addClass("select2-container-active");this.search.attr("tabIndex","-1")}));E.bind("blur",this.bind(function(){if(!this.opened()){this.container.removeClass("select2-container-active")}window.setTimeout(this.bind(function(){this.search.attr("tabIndex",this.opts.element.attr("tabIndex"))}),10)}));E.bind("keydown",this.bind(function(H){if(!this.enabled){return}if(H.which===c.PAGE_UP||H.which===c.PAGE_DOWN){d(H);return}if(H.which===c.TAB||c.isControl(H)||c.isFunctionKey(H)||H.which===c.ESC){return}if(this.opts.openOnEnter===false&&H.which===c.ENTER){return}if(H.which==c.DELETE){if(this.opts.allowClear){this.clear()}return}this.open();if(H.which===c.ENTER){d(H);return}if(H.which<48){d(H);return}var G=String.fromCharCode(H.which).toLowerCase();if(H.shiftKey){G=G.toUpperCase()}this.search.focus();this.search.val(G);d(H)}));E.delegate("abbr","mousedown",this.bind(function(G){if(!this.enabled){return}this.clear();d(G);this.close();this.triggerChange();this.selection.focus()}));this.setPlaceholder();this.search.bind("focus",this.bind(function(){this.container.addClass("select2-container-active")}))},clear:function(){this.opts.element.val("");this.selection.find("span").empty();this.selection.removeData("select2-data");this.setPlaceholder()},initSelection:function(){var D;if(this.opts.element.val()===""){this.close();this.setPlaceholder()}else{var C=this;this.opts.initSelection.call(null,this.opts.element,function(E){if(E!==l&&E!==null){C.updateSelection(E);C.close();C.setPlaceholder()}})}},prepareOpts:function(){var C=this.parent.prepareOpts.apply(this,arguments);if(C.element.get(0).tagName.toLowerCase()==="select"){C.initSelection=function(D,F){var E=D.find(":selected");if(j.isFunction(F)){F({id:E.attr("value"),text:E.text()})}}}return C},setPlaceholder:function(){var C=this.getPlaceholder();if(this.opts.element.val()===""&&C!==l){if(this.select&&this.select.find("option:first").text()!==""){return}this.selection.find("span").html(this.opts.escapeMarkup(C));this.selection.addClass("select2-default");this.selection.find("abbr").hide()}},postprocessResults:function(F,D){var E=0,C=this,G=true;this.results.find(".select2-result-selectable").each2(function(H,I){if(q(C.id(I.data("select2-data")),C.opts.element.val())){E=H;return false}});this.highlight(E);if(D===true){G=this.showSearchInput=h(F.results)>=this.opts.minimumResultsForSearch;this.dropdown.find(".select2-search")[G?"removeClass":"addClass"]("select2-search-hidden");j(this.dropdown,this.container)[G?"addClass":"removeClass"]("select2-with-searchbox")}},onSelect:function(D){var C=this.opts.element.val();this.opts.element.val(this.id(D));this.updateSelection(D);this.close();this.selection.focus();if(!q(C,this.id(D))){this.triggerChange()}},updateSelection:function(E){var C=this.selection.find("span"),D;this.selection.data("select2-data",E);C.empty();D=this.opts.formatSelection(E,C);if(D!==l){C.append(this.opts.escapeMarkup(D))}this.selection.removeClass("select2-default");if(this.opts.allowClear&&this.getPlaceholder()!==l){this.selection.find("abbr").show()}},val:function(){var E,D=null,C=this;if(arguments.length===0){return this.opts.element.val()}E=arguments[0];if(this.select){this.select.val(E).find(":selected").each2(function(F,G){D={id:G.attr("value"),text:G.text()};return false});this.updateSelection(D);this.setPlaceholder()}else{if(this.opts.initSelection===l){throw new Error("cannot call val() if initSelection() is not defined")}if(!E){this.clear();return}this.opts.element.val(E);this.opts.initSelection(this.opts.element,function(F){C.opts.element.val(!F?"":C.id(F));C.updateSelection(F);C.setPlaceholder()})}},clearSearch:function(){this.search.val("")},data:function(D){var C;if(arguments.length===0){C=this.selection.data("select2-data");if(C==l){C=null}return C}else{if(!D||D===""){this.clear()}else{this.opts.element.val(!D?"":this.id(D));this.updateSelection(D)}}}});B=w(e,{createContainer:function(){var C=j("
      ",{"class":"select2-container select2-container-multi"}).html(["
        ","
      • "," ","
      • ","
      ",""].join(""));return C},prepareOpts:function(){var C=this.parent.prepareOpts.apply(this,arguments);if(C.element.get(0).tagName.toLowerCase()==="select"){C.initSelection=function(D,F){var E=[];D.find(":selected").each2(function(G,H){E.push({id:H.attr("value"),text:H.text()})});if(j.isFunction(F)){F(E)}}}return C},initContainer:function(){var C=".select2-choices",D;this.searchContainer=this.container.find(".select2-search-field");this.selection=D=this.container.find(C);this.search.bind("keydown",this.bind(function(F){if(!this.enabled){return}if(F.which===c.BACKSPACE&&this.search.val()===""){this.close();var G,E=D.find(".select2-search-choice-focus");if(E.length>0){this.unselect(E.first());this.search.width(10);d(F);return}G=D.find(".select2-search-choice");if(G.length>0){G.last().addClass("select2-search-choice-focus")}}else{D.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")}if(this.opened()){switch(F.which){case c.UP:case c.DOWN:this.moveHighlight((F.which===c.UP)?-1:1);d(F);return;case c.ENTER:case c.TAB:this.selectHighlighted();d(F);return;case c.ESC:this.cancel(F);d(F);return}}if(F.which===c.TAB||c.isControl(F)||c.isFunctionKey(F)||F.which===c.BACKSPACE||F.which===c.ESC){return}if(this.opts.openOnEnter===false&&F.which===c.ENTER){return}this.open();if(F.which===c.PAGE_UP||F.which===c.PAGE_DOWN){d(F)}}));this.search.bind("keyup",this.bind(this.resizeSearch));this.search.bind("blur",this.bind(function(E){this.container.removeClass("select2-container-active");this.search.removeClass("select2-focused");this.clearSearch();E.stopImmediatePropagation()}));this.container.delegate(C,"mousedown",this.bind(function(E){if(!this.enabled){return}if(j(E.target).closest(".select2-search-choice").length>0){return}this.clearPlaceholder();this.open();this.focusSearch();E.preventDefault()}));this.container.delegate(C,"focus",this.bind(function(){if(!this.enabled){return}this.container.addClass("select2-container-active");this.dropdown.addClass("select2-drop-active");this.clearPlaceholder()}));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 D;if(this.opts.element.val()===""){this.updateSelection([]);this.close();this.clearSearch()}if(this.select||this.opts.element.val()!==""){var C=this;this.opts.initSelection.call(null,this.opts.element,function(E){if(E!==l&&E!==null){C.updateSelection(E);C.close();C.clearSearch()}})}},clearSearch:function(){var C=this.getPlaceholder();if(C!==l&&this.getVal().length===0&&this.search.hasClass("select2-focused")===false){this.search.val(C).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")}else{if(this.search.val()===" "){this.search.val("")}}},opening:function(){this.parent.opening.apply(this,arguments);this.clearPlaceholder();this.resizeSearch();this.focusSearch()},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(F){var E=[],D=[],C=this;j(F).each(function(){if(b(C.id(this),E)<0){E.push(C.id(this));D.push(this)}});F=D;this.selection.find(".select2-search-choice").remove();j(F).each(function(){C.addSelectedChoice(this)});C.postprocessResults()},tokenize:function(){var C=this.search.val();C=this.opts.tokenizer(C,this.data(),this.bind(this.onSelect),this.opts);if(C!=null&&C!=l){this.search.val(C);if(C.length>0){this.open()}}},onSelect:function(C){this.addSelectedChoice(C);if(this.select){this.postprocessResults()}if(this.opts.closeOnSelect){this.close();this.search.width(10)}else{if(this.countSelectableResults()>0){this.search.width(10);this.resizeSearch();this.positionDropdown()}else{this.close()}}this.triggerChange({added:C});this.focusSearch()},cancel:function(){this.close();this.focusSearch()},addSelectedChoice:function(E){var C=j("
    • "),G=this.id(E),F=this.getVal(),D;D=this.opts.formatSelection(E,C);C.find("div").replaceWith("
      "+this.opts.escapeMarkup(D)+"
      ");C.find(".select2-search-choice-close").bind("mousedown",d).bind("click dblclick",this.bind(function(H){if(!this.enabled){return}j(H.target).closest(".select2-search-choice").fadeOut("fast",this.bind(function(){this.unselect(j(H.target));this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");this.close();this.focusSearch()})).dequeue();d(H)})).bind("focus",this.bind(function(){if(!this.enabled){return}this.container.addClass("select2-container-active");this.dropdown.addClass("select2-drop-active")}));C.data("select2-data",E);C.insertBefore(this.searchContainer);F.push(G);this.setVal(F)},unselect:function(D){var F=this.getVal(),E,C;D=D.closest(".select2-search-choice");if(D.length===0){throw"Invalid argument: "+D+". Must be .select2-search-choice"}E=D.data("select2-data");C=b(this.id(E),F);if(C>=0){F.splice(C,1);this.setVal(F);if(this.select){this.postprocessResults()}}D.remove();this.triggerChange({removed:E})},postprocessResults:function(){var E=this.getVal(),F=this.results.find(".select2-result-selectable"),D=this.results.find(".select2-result-with-children"),C=this;F.each2(function(H,G){var I=C.id(G.data("select2-data"));if(b(I,E)>=0){G.addClass("select2-disabled").removeClass("select2-result-selectable")}else{G.removeClass("select2-disabled").addClass("select2-result-selectable")}});D.each2(function(G,H){if(H.find(".select2-result-selectable").length==0){H.addClass("select2-disabled")}else{H.removeClass("select2-disabled")}});F.each2(function(H,G){if(!G.hasClass("select2-disabled")&&G.hasClass("select2-result-selectable")){C.highlight(0);return false}})},resizeSearch:function(){var H,F,E,C,D,G=n(this.search);H=x(this.search)+10;F=this.search.offset().left;E=this.selection.width();C=this.selection.offset().left;D=E-(F-C)-G;if(D. Attach to instead.")}this.search.width(0);this.searchContainer.hide()},onSortEnd:function(){var D=[],C=this;this.searchContainer.show();this.searchContainer.appendTo(this.searchContainer.parent());this.resizeSearch();this.selection.find(".select2-search-choice").each(function(){D.push(C.opts.id(j(this).data("select2-data")))});this.setVal(D);this.triggerChange()},data:function(D){var C=this,E;if(arguments.length===0){return this.selection.find(".select2-search-choice").map(function(){return j(this).data("select2-data")}).get()}else{if(!D){D=[]}E=j.map(D,function(F){return C.opts.id(F)});this.setVal(E);this.updateSelection(D);this.clearSearch()}}});j.fn.select2=function(){var F=Array.prototype.slice.call(arguments,0),G,E,H,D,C=["val","destroy","opened","open","close","focus","isFocused","container","onSortStart","onSortEnd","enable","disable","positionDropdown","data"];this.each(function(){if(F.length===0||typeof(F[0])==="object"){G=F.length===0?{}:j.extend({},F[0]);G.element=j(this);if(G.element.get(0).tagName.toLowerCase()==="select"){D=G.element.attr("multiple")}else{D=G.multiple||false;if("tags" in G){G.multiple=D=true}}E=D?new B():new v();E.init(G)}else{if(typeof(F[0])==="string"){if(b(F[0],C)<0){throw"Unknown method: "+F[0]}H=l;E=j(this).data("select2");if(E===l){return}if(F[0]==="container"){H=E.container}else{H=E[F[0]].apply(E,F.slice(1))}if(H!==l){return false}}else{throw"Invalid arguments to select2 plugin: "+F}}});return(H===l)?this:H};j.fn.select2.defaults={width:"copy",closeOnSelect:true,openOnEnter:true,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(C,D,F){var E=[];i(C.text,F.term,E);return E.join("")},formatSelection:function(D,C){return D?D.text:l},formatResultCssClass:function(C){return l},formatNoMatches:function(){return"No matches found"},formatInputTooShort:function(C,D){return"Please enter "+(D-C.length)+" more characters"},formatSelectionTooBig:function(C){return"You can only select "+C+" item"+(C==1?"":"s")},formatLoadMore:function(C){return"Loading more results..."},formatSearching:function(){return"Searching..."},minimumResultsForSearch:0,minimumInputLength:0,maximumSelectionSize:0,id:function(C){return C.id},matcher:function(C,D){return D.toUpperCase().indexOf(C.toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:y,escapeMarkup:function(C){if(C&&typeof(C)==="string"){return C.replace(/&/g,"&")}return C},blurOnChange:false};window.Select2={query:{ajax:p,local:r,tags:o},util:{debounce:f,markMatch:i},"class":{"abstract":e,single:v,multi:B}}}(jQuery)); \ No newline at end of file diff --git a/django_select2/widgets.py b/django_select2/widgets.py index 74ec503..d46fd08 100644 --- a/django_select2/widgets.py +++ b/django_select2/widgets.py @@ -35,6 +35,13 @@ def get_select2_heavy_js_libs(): else: return libs + ('js/heavy_data.min.js', ) +def get_select2_css_libs(): + from django.conf import settings + if settings.configured and settings.DEBUG: + return ('css/select2.css', 'css/extra.css', ) + else: + return ('css/all.min.js', ) + ### Light mixin and widgets ### class Select2Mixin(object): @@ -207,7 +214,7 @@ class Select2Mixin(object): class Media: js = get_select2_js_libs() - css = {'screen': ('css/select2.css', 'css/extra.css', )} + css = {'screen': get_select2_css_libs()} class Select2Widget(Select2Mixin, forms.Select): diff --git a/setup.py b/setup.py index 935effa..e1f312d 100644 --- a/setup.py +++ b/setup.py @@ -110,6 +110,53 @@ AUTHOR_EMAIL = "admin@applegrew.com" URL = "https://github.com/applegrew/django-select2" VERSION = __import__(PACKAGE).__version__ +def getPkgPath(): + return __import__(PACKAGE).__path__[0] + '/' + +def minify(files, outfile, ftype): + import urllib, json + + content = u'' + for filename in files: + with open(getPkgPath() + filename) as f: + for line in f.xreadlines(): + content = content + line + + data = urllib.urlencode([ + ('code', content), + ('type', ftype), + ]) + data.encode('utf-8') + + f = urllib.urlopen('http://api.applegrew.com/minify', data) + data = u'' + while 1: + line = f.readline() + if line: + data = data + unicode(line) + else: + break + f.close() + + data = json.loads(data) + for key in data: + value = data[key] + if isinstance(value, str) or isinstance(value, unicode): + data[key] = unicode(value).decode("string-escape").replace(r'\/', '/') + + if data['success']: + with open(getPkgPath() + outfile, 'w') as f: + f.write(data['compiled_code']) + else: + print data['error_code'] + print data['error'] + raise Exception('Could not minify.') + + +if 'sdist' == sys.argv[1]: + minify(['static/js/select2.js'], 'static/js/select2.min.js', 'js') + minify(['static/js/heavy_data.js'], 'static/js/heavy_data.min.js', 'js') + minify(['static/css/select2.css', 'static/css/extra.css'], 'static/css/all.min.css', 'css') setup( name=NAME, diff --git a/testapp/testapp/templates/500.html b/testapp/testapp/templates/500.html new file mode 100644 index 0000000..ce50a2a --- /dev/null +++ b/testapp/testapp/templates/500.html @@ -0,0 +1,7 @@ + + + + + + Error 500 +