diff --git a/django_select2/__init__.py b/django_select2/__init__.py index 46e60ed..ba15720 100644 --- a/django_select2/__init__.py +++ b/django_select2/__init__.py @@ -32,8 +32,6 @@ Widgets are generally of two types :- request. When they are instantiated, they register themselves with one central view which handels Ajax requests for them. - `Read more`_ - Heavy widgets have the word 'Heavy' in their name. Light widgets are normally named, i.e. there is no 'Light' word in their names. @@ -42,6 +40,8 @@ in their names. :py:class:`.Select2Widget`, :py:class:`.Select2MultipleWidget`, :py:class:`.HeavySelect2Widget`, :py:class:`.HeavySelect2MultipleWidget`, :py:class:`.AutoHeavySelect2Widget`, :py:class:`.AutoHeavySelect2MultipleWidget` +`Read more`_ + Fields ------ @@ -62,12 +62,13 @@ your ease. Views ----- -The view - `Select2View`, exposed here is meant to be used with 'Heavy' fields and widgets. `Read more`_ +The view - `Select2View`, exposed here is meant to be used with 'Heavy' fields and widgets. **Imported:** :py:class:`.Select2View`, :py:data:`.NO_ERR_RESP` +`Read more`_ .. _Read more: http://blog.applegrew.com/2012/08/django-select2/ diff --git a/django_select2/static/css/select2.css b/django_select2/static/css/select2.css index ca1df64..4408678 100755 --- a/django_select2/static/css/select2.css +++ b/django_select2/static/css/select2.css @@ -1,5 +1,5 @@ /* -Version: 3.0 Timestamp: Tue Jul 31 21:09:16 PDT 2012 +Version: 3.1 Timestamp: Tue Aug 14 09:05:17 PDT 2012 */ .select2-container { position: relative; @@ -7,7 +7,7 @@ Version: 3.0 Timestamp: Tue Jul 31 21:09:16 PDT 2012 /* inline-block for ie7 */ zoom: 1; *display: inline; - + vertical-align: top; } .select2-container, @@ -310,11 +310,8 @@ Version: 3.0 Timestamp: Tue Jul 31 21:09:16 PDT 2012 .select2-results .select2-highlighted em { background: transparent; } -.select2-results .select2-no-results { - background: #f4f4f4; - display: list-item; -} - +.select2-results .select2-no-results, +.select2-results .select2-searching, .select2-results .select2-selection-limit { background: #f4f4f4; display: list-item; diff --git a/django_select2/static/js/select2.js b/django_select2/static/js/select2.js new file mode 100755 index 0000000..529c509 --- /dev/null +++ b/django_select2/static/js/select2.js @@ -0,0 +1,2348 @@ +/* + Copyright 2012 Igor Vaynberg + + Version: 3.1 Timestamp: Tue Aug 14 09:05:17 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 ($) { + if(typeof $.fn.each2 == "undefined"){ + $.fn.extend({ + /* + * 4-10 times faster .each replacement + * use it carefully, as it overrides jQuery context of element on each iteration + */ + each2 : function (c) { + var j = $([0]), i = -1, l = this.length; + while ( + ++i < l + && (j.context = j[0] = this[i]) + && c.call(j[0], i, j) !== false //"this"=DOM, i=index, j=jQuery object + ); + return this; + } + }); + } +})(jQuery); + +(function ($, undefined) { + "use strict"; + /*global document, window, jQuery, console */ + + if (window.Select2 !== undefined) { + return; + } + + var KEY, AbstractSelect2, SingleSelect2, MultiSelect2, nextUid, sizer; + + KEY = { + TAB: 9, + ENTER: 13, + ESC: 27, + SPACE: 32, + LEFT: 37, + UP: 38, + RIGHT: 39, + DOWN: 40, + SHIFT: 16, + CTRL: 17, + ALT: 18, + PAGE_UP: 33, + PAGE_DOWN: 34, + HOME: 36, + END: 35, + BACKSPACE: 8, + DELETE: 46, + isArrow: function (k) { + k = k.which ? k.which : k; + switch (k) { + case KEY.LEFT: + case KEY.RIGHT: + case KEY.UP: + case KEY.DOWN: + return true; + } + return false; + }, + isControl: function (e) { + var k = e.which; + switch (k) { + case KEY.SHIFT: + case KEY.CTRL: + case KEY.ALT: + return true; + } + + if (e.metaKey) return true; + + return false; + }, + isFunctionKey: function (k) { + k = k.which ? k.which : k; + return k >= 112 && k <= 123; + } + }; + + nextUid=(function() { var counter=1; return function() { return counter++; }; }()); + + function escapeMarkup(markup) { + if (markup && typeof(markup) === "string") { + return markup.replace(/&/g, "&"); + } else { + return markup; + } + } + + function indexOf(value, array) { + var i = 0, l = array.length, v; + + if (typeof value === "undefined") { + return -1; + } + + if (value.constructor === String) { + for (; i < l; i = i + 1) if (value.localeCompare(array[i]) === 0) return i; + } else { + for (; i < l; i = i + 1) { + v = array[i]; + if (v.constructor === String) { + if (v.localeCompare(value) === 0) return i; + } else { + if (v === value) return i; + } + } + } + return -1; + } + + /** + * Compares equality of a and b taking into account that a and b may be strings, in which case localeCompare is used + * @param a + * @param b + */ + function equal(a, b) { + if (a === b) return true; + if (a === undefined || b === undefined) return false; + if (a === null || b === null) return false; + if (a.constructor === String) return a.localeCompare(b) === 0; + if (b.constructor === String) return b.localeCompare(a) === 0; + return false; + } + + /** + * Splits the string into an array of values, trimming each value. An empty array is returned for nulls or empty + * strings + * @param string + * @param separator + */ + function splitVal(string, separator) { + var val, i, l; + if (string === null || string.length < 1) return []; + val = string.split(separator); + for (i = 0, l = val.length; i < l; i = i + 1) val[i] = $.trim(val[i]); + return val; + } + + function getSideBorderPadding(element) { + return element.outerWidth() - element.width(); + } + + function installKeyUpChangeEvent(element) { + var key="keyup-change-value"; + element.bind("keydown", function () { + if ($.data(element, key) === undefined) { + $.data(element, key, element.val()); + } + }); + element.bind("keyup", function () { + var val= $.data(element, key); + if (val !== undefined && element.val() !== val) { + $.removeData(element, key); + element.trigger("keyup-change"); + } + }); + } + + $(document).delegate("*", "mousemove", function (e) { + $.data(document, "select2-lastpos", {x: e.pageX, y: e.pageY}); + }); + + /** + * filters mouse events so an event is fired only if the mouse moved. + * + * filters out mouse events that occur when mouse is stationary but + * the elements under the pointer are scrolled. + */ + function installFilteredMouseMove(element) { + element.bind("mousemove", function (e) { + var lastpos = $.data(document, "select2-lastpos"); + if (lastpos === undefined || lastpos.x !== e.pageX || lastpos.y !== e.pageY) { + $(e.target).trigger("mousemove-filtered", e); + } + }); + } + + /** + * Debounces a function. Returns a function that calls the original fn function only if no invocations have been made + * within the last quietMillis milliseconds. + * + * @param quietMillis number of milliseconds to wait before invoking fn + * @param fn function to be debounced + * @return debounced version of fn + */ + function debounce(quietMillis, fn) { + var timeout; + return function () { + window.clearTimeout(timeout); + timeout = window.setTimeout(fn, quietMillis); + }; + } + + /** + * A simple implementation of a thunk + * @param formula function used to lazily initialize the thunk + * @return {Function} + */ + function thunk(formula) { + var evaluated = false, + value; + return function() { + if (evaluated === false) { value = formula(); evaluated = true; } + return value; + }; + }; + + function installDebouncedScroll(threshold, element) { + var notify = debounce(threshold, function (e) { element.trigger("scroll-debounced", e);}); + element.bind("scroll", function (e) { + if (indexOf(e.target, element.get()) >= 0) notify(e); + }); + } + + function killEvent(event) { + event.preventDefault(); + event.stopPropagation(); + } + + function measureTextWidth(e) { + if (!sizer){ + var style = e[0].currentStyle || window.getComputedStyle(e[0], null); + sizer = $("
").css({ + position: "absolute", + left: "-10000px", + top: "-10000px", + display: "none", + fontSize: style.fontSize, + fontFamily: style.fontFamily, + fontStyle: style.fontStyle, + fontWeight: style.fontWeight, + letterSpacing: style.letterSpacing, + textTransform: style.textTransform, + whiteSpace: "nowrap" + }); + $("body").append(sizer); + } + sizer.text(e.val()); + return sizer.width(); + } + + function markMatch(text, term, markup) { + var match=text.toUpperCase().indexOf(term.toUpperCase()), + tl=term.length; + + if (match<0) { + markup.push(text); + return; + } + + markup.push(text.substring(0, match)); + markup.push(""); + markup.push(text.substring(match, match + tl)); + markup.push(""); + markup.push(text.substring(match + tl, text.length)); + } + + /** + * Produces an ajax-based query function + * + * @param options object containing configuration paramters + * @param options.transport function that will be used to execute the ajax request. must be compatible with parameters supported by $.ajax + * @param options.url url for the data + * @param options.data a function(searchTerm, pageNumber, context) that should return an object containing query string parameters for the above url. + * @param options.dataType request data type: ajax, jsonp, other datatatypes supported by jQuery's $.ajax function or the transport function if specified + * @param options.traditional a boolean flag that should be true if you wish to use the traditional style of param serialization for the ajax request + * @param options.quietMillis (optional) milliseconds to wait before making the ajaxRequest, helps debounce the ajax function if invoked too often + * @param options.results a function(remoteData, pageNumber) that converts data returned form the remote request to the format expected by Select2. + * The expected format is an object containing the following keys: + * results array of objects that will be used as choices + * more (optional) boolean indicating whether there are more results available + * Example: {results:[{id:1, text:'Red'},{id:2, text:'Blue'}], more:true} + */ + function ajax(options) { + var timeout, // current scheduled but not yet executed request + requestSequence = 0, // sequence used to drop out-of-order responses + handler = null, + quietMillis = options.quietMillis || 100; + + return function (query) { + window.clearTimeout(timeout); + timeout = window.setTimeout(function () { + requestSequence += 1; // increment the sequence + var requestNumber = requestSequence, // this request's sequence number + data = options.data, // ajax data function + transport = options.transport || $.ajax, + traditional = options.traditional || false, + type = options.type || 'GET'; // set type of request (GET or POST) + + data = data.call(this, query.term, query.page, query.context); + + if( null !== handler) { handler.abort(); } + + handler = transport.call(null, { + url: options.url, + dataType: options.dataType, + data: data, + type: type, + traditional: traditional, + success: function (data) { + if (requestNumber < requestSequence) { + return; + } + // TODO 3.0 - replace query.page with query so users have access to term, page, etc. + var results = options.results(data, query.page); + query.callback(results); + } + }); + }, quietMillis); + }; + } + + /** + * Produces a query function that works with a local array + * + * @param options object containing configuration parameters. The options parameter can either be an array or an + * object. + * + * If the array form is used it is assumed that it contains objects with 'id' and 'text' keys. + * + * If the object form is used ti is assumed that it contains 'data' and 'text' keys. The 'data' key should contain + * an array of objects that will be used as choices. These objects must contain at least an 'id' key. The 'text' + * key can either be a String in which case it is expected that each element in the 'data' array has a key with the + * value of 'text' which will be used to match choices. Alternatively, text can be a function(item) that can extract + * the text. + */ + function local(options) { + var data = options, // data elements + dataText, + text = function (item) { return ""+item.text; }; // function used to retrieve the text portion of a data item that is matched against the search + + if (!$.isArray(data)) { + text = data.text; + // if text is not a function we assume it to be a key name + if (!$.isFunction(text)) { + dataText = data.text; // we need to store this in a separate variable because in the next step data gets reset and data.text is no longer available + text = function (item) { return item[dataText]; }; + } + data = data.results; + } + + return function (query) { + var t = query.term, filtered = {}; + if (t === "") { + query.callback({results: data}); + return; + } + filtered.results = $(data) + .filter(function () {return query.matcher(t, text(this));}) + .get(); + query.callback(filtered); + }; + } + + // TODO javadoc + function tags(data) { + // TODO even for a function we should probably return a wrapper that does the same object/string check as + // the function for arrays. otherwise only functions that return objects are supported. + if ($.isFunction(data)) { + return data; + } + + // if not a function we assume it to be an array + + return function (query) { + var t = query.term, filtered = {results: []}; + $(data).each(function () { + var isObject = this.text !== undefined, + text = isObject ? this.text : this; + if (t === "" || query.matcher(t, text)) { + filtered.results.push(isObject ? this : {id: this, text: this}); + } + }); + query.callback(filtered); + }; + } + + /** + * Checks if the formatter function should be used. + * + * Throws an error if it is not a function. Returns true if it should be used, + * false if no formatting should be performed. + * + * @param formatter + */ + function checkFormatter(formatter, formatterName) { + if ($.isFunction(formatter)) return true; + if (!formatter) return false; + throw new Error("formatterName must be a function or a falsy value"); + } + + function evaluate(val) { + return $.isFunction(val) ? val() : val; + } + + function countResults(results) { + var count = 0; + $.each(results, function(i, item) { + if (item.children) { + count += countResults(item.children); + } else { + count++; + } + }); + return count; + } + + /** + * Default tokenizer. This function uses breaks the input on substring match of any string from the + * opts.tokenSeparators array and uses opts.createSearchChoice to create the choice object. Both of those + * two options have to be defined in order for the tokenizer to work. + * + * @param input text user has typed so far or pasted into the search field + * @param selection currently selected choices + * @param selectCallback function(choice) callback tho add the choice to selection + * @param opts select2's opts + * @return undefined/null to leave the current input unchanged, or a string to change the input to the returned value + */ + function defaultTokenizer(input, selection, selectCallback, opts) { + var original = input, // store the original so we can compare and know if we need to tell the search to update its text + dupe = false, // check for whether a token we extracted represents a duplicate selected choice + token, // token + index, // position at which the separator was found + i, l, // looping variables + separator; // the matched separator + + if (!opts.createSearchChoice || !opts.tokenSeparators || opts.tokenSeparators.length < 1) return undefined; + + while (true) { + index = -1; + + for (i = 0, l = opts.tokenSeparators.length; i < l; i++) { + separator = opts.tokenSeparators[i]; + index = input.indexOf(separator); + if (index >= 0) break; + } + + if (index < 0) break; // did not find any token separator in the input string, bail + + token = input.substring(0, index); + input = input.substring(index + separator.length); + + if (token.length > 0) { + token = opts.createSearchChoice(token, selection); + if (token !== undefined && token !== null && opts.id(token) !== undefined && opts.id(token) !== null) { + dupe = false; + for (i = 0, l = selection.length; i < l; i++) { + if (equal(opts.id(token), opts.id(selection[i]))) { + dupe = true; break; + } + } + + if (!dupe) selectCallback(token); + } + } + } + + if (original.localeCompare(input) != 0) return input; + } + + /** + * blurs any Select2 container that has focus when an element outside them was clicked or received focus + * + * also takes care of clicks on label tags that point to the source element + */ + $(document).ready(function () { + $(document).delegate("*", "mousedown touchend", function (e) { + var target = $(e.target).closest("div.select2-container").get(0), attr; + if (target) { + $(document).find("div.select2-container-active").each(function () { + if (this !== target) $(this).data("select2").blur(); + }); + } else { + target = $(e.target).closest("div.select2-drop").get(0); + $(document).find("div.select2-drop-active").each(function () { + if (this !== target) $(this).data("select2").blur(); + }); + } + + target=$(e.target); + attr = target.attr("for"); + if ("LABEL" === e.target.tagName && attr && attr.length > 0) { + target = $("#"+attr); + target = target.data("select2"); + if (target !== undefined) { target.focus(); e.preventDefault();} + } + }); + }); + + /** + * Creates a new class + * + * @param superClass + * @param methods + */ + function clazz(SuperClass, methods) { + var constructor = function () {}; + constructor.prototype = new SuperClass; + constructor.prototype.constructor = constructor; + constructor.prototype.parent = SuperClass.prototype; + constructor.prototype = $.extend(constructor.prototype, methods); + return constructor; + } + + AbstractSelect2 = clazz(Object, { + + // abstract + bind: function (func) { + var self = this; + return function () { + func.apply(self, arguments); + }; + }, + + // abstract + init: function (opts) { + var results, search, resultsSelector = ".select2-results"; + + // prepare options + this.opts = opts = this.prepareOpts(opts); + + this.id=opts.id; + + // destroy if called on an existing component + if (opts.element.data("select2") !== undefined && + opts.element.data("select2") !== null) { + this.destroy(); + } + + this.enabled=true; + this.container = this.createContainer(); + + this.containerId="s2id"+nextUid(); + this.container.attr("id", this.containerId); + + // cache the body so future lookups are cheap + this.body = thunk(function() { return opts.element.closest("body"); }); + + if (opts.element.attr("class") !== undefined) { + this.container.addClass(opts.element.attr("class")); + } + + this.container.css(evaluate(opts.containerCss)); + this.container.addClass(evaluate(opts.containerCssClass)); + + // swap container for the element + 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(evaluate(opts.dropdownCssClass)); + this.dropdown.data("select2", this); + + this.results = results = this.container.find(resultsSelector); + this.search = search = this.container.find("input.select2-input"); + + search.attr("tabIndex", this.opts.element.attr("tabIndex")); + + this.resultsPage = 0; + this.context = null; + + // initialize the container + this.initContainer(); + this.initContainerWidth(); + + installFilteredMouseMove(this.results); + this.dropdown.delegate(resultsSelector, "mousemove-filtered", this.bind(this.highlightUnderEvent)); + + installDebouncedScroll(80, this.results); + this.dropdown.delegate(resultsSelector, "scroll-debounced", this.bind(this.loadMoreIfNeeded)); + + // if jquery.mousewheel plugin is installed we can prevent out-of-bounds scrolling of results via mousewheel + if ($.fn.mousewheel) { + results.mousewheel(function (e, delta, deltaX, deltaY) { + var top = results.scrollTop(), height; + if (deltaY > 0 && top - deltaY <= 0) { + results.scrollTop(0); + killEvent(e); + } else if (deltaY < 0 && results.get(0).scrollHeight - results.scrollTop() + deltaY <= results.height()) { + results.scrollTop(results.get(0).scrollHeight - results.height()); + killEvent(e); + } + }); + } + + installKeyUpChangeEvent(search); + search.bind("keyup-change", this.bind(this.updateResults)); + search.bind("focus", function () { search.addClass("select2-focused"); if (search.val() === " ") search.val(""); }); + search.bind("blur", function () { search.removeClass("select2-focused");}); + + this.dropdown.delegate(resultsSelector, "mouseup", this.bind(function (e) { + if ($(e.target).closest(".select2-result-selectable:not(.select2-disabled)").length > 0) { + this.highlightUnderEvent(e); + this.selectHighlighted(e); + } else { + this.focusSearch(); + } + killEvent(e); + })); + + // trap all mouse events from leaving the dropdown. sometimes there may be a modal that is listening + // for mouse events outside of itself so it can close itself. since the dropdown is now outside the select2's + // dom it will trigger the popup close, which is not what we want + this.dropdown.bind("click mouseup mousedown", function (e) { e.stopPropagation(); }); + + if ($.isFunction(this.opts.initSelection)) { + // initialize selection based on the current value of the source element + this.initSelection(); + + // if the user has provided a function that can set selection based on the value of the source element + // we monitor the change event on the element and trigger it, allowing for two way synchronization + this.monitorSource(); + } + + if (opts.element.is(":disabled") || opts.element.is("[readonly='readonly']")) this.disable(); + }, + + // abstract + destroy: function () { + var select2 = this.opts.element.data("select2"); + if (select2 !== undefined) { + select2.container.remove(); + select2.dropdown.remove(); + select2.opts.element + .removeData("select2") + .unbind(".select2") + .show(); + } + }, + + // abstract + prepareOpts: function (opts) { + var element, select, idKey, ajaxUrl; + + element = opts.element; + + if (element.get(0).tagName.toLowerCase() === "select") { + this.select = select = opts.element; + } + + if (select) { + // these options are not allowed when attached to a select because they are picked up off the element itself + $.each(["id", "multiple", "ajax", "query", "createSearchChoice", "initSelection", "data", "tags"], function () { + if (this in opts) { + throw new Error("Option '" + this + "' is not allowed for Select2 when attached to a " , + " " , + " " , + ""].join("")); + return container; + }, + + // single + opening: function () { + this.search.show(); + this.parent.opening.apply(this, arguments); + this.dropdown.removeClass("select2-offscreen"); + }, + + // single + close: function () { + if (!this.opened()) return; + this.parent.close.apply(this, arguments); + this.dropdown.removeAttr("style").addClass("select2-offscreen").insertAfter(this.selection).show(); + }, + + // single + focus: function () { + this.close(); + this.selection.focus(); + }, + + // single + isFocused: function () { + return this.selection[0] === document.activeElement; + }, + + // single + cancel: function () { + this.parent.cancel.apply(this, arguments); + this.selection.focus(); + }, + + // single + initContainer: function () { + + var selection, + container = this.container, + dropdown = this.dropdown, + clickingInside = false; + + this.selection = selection = container.find(".select2-choice"); + + this.search.bind("keydown", this.bind(function (e) { + if (!this.enabled) return; + + if (e.which === KEY.PAGE_UP || e.which === KEY.PAGE_DOWN) { + // prevent the page from scrolling + killEvent(e); + return; + } + + if (this.opened()) { + switch (e.which) { + case KEY.UP: + case KEY.DOWN: + this.moveHighlight((e.which === KEY.UP) ? -1 : 1); + killEvent(e); + return; + case KEY.TAB: + case KEY.ENTER: + this.selectHighlighted(); + killEvent(e); + return; + case KEY.ESC: + this.cancel(e); + killEvent(e); + return; + } + } else { + + if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC) { + return; + } + + if (this.opts.openOnEnter === false && e.which === KEY.ENTER) { + return; + } + + this.open(); + + if (e.which === KEY.ENTER) { + // do not propagate the event otherwise we open, and propagate enter which closes + 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); + })); + + selection.bind("mousedown", this.bind(function (e) { + clickingInside = true; + + if (this.opened()) { + this.close(); + this.selection.focus(); + } else if (this.enabled) { + this.open(); + } + + clickingInside = false; + })); + + dropdown.bind("mousedown", this.bind(function() { this.search.focus(); })); + + selection.bind("focus", this.bind(function() { + this.container.addClass("select2-container-active"); + // hide the search so the tab key does not focus on it + this.search.attr("tabIndex", "-1"); + })); + + selection.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); + })); + + selection.bind("keydown", this.bind(function(e) { + if (!this.enabled) return; + + if (e.which === KEY.PAGE_UP || e.which === KEY.PAGE_DOWN) { + // prevent the page from scrolling + killEvent(e); + return; + } + + if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) + || e.which === KEY.ESC) { + return; + } + + if (this.opts.openOnEnter === false && e.which === KEY.ENTER) { + return; + } + + if (e.which == KEY.DELETE) { + if (this.opts.allowClear) { + this.clear(); + } + return; + } + + this.open(); + + if (e.which === KEY.ENTER) { + // do not propagate the event otherwise we open, and propagate enter which closes + killEvent(e); + return; + } + + // do not set the search input value for non-alpha-numeric keys + // otherwise pressing down results in a '(' being set in the search field + if (e.which < 48 ) { // '0' == 48 + killEvent(e); + return; + } + + var keyWritten = String.fromCharCode(e.which).toLowerCase(); + + if (e.shiftKey) { + keyWritten = keyWritten.toUpperCase(); + } + + // focus the field before calling val so the cursor ends up after the value instead of before + this.search.focus(); + this.search.val(keyWritten); + + // prevent event propagation so it doesnt replay on the now focussed search field and result in double key entry + killEvent(e); + })); + + selection.delegate("abbr", "mousedown", this.bind(function (e) { + if (!this.enabled) return; + this.clear(); + killEvent(e); + this.close(); + this.triggerChange(); + this.selection.focus(); + })); + + this.setPlaceholder(); + + this.search.bind("focus", this.bind(function() { + this.container.addClass("select2-container-active"); + })); + }, + + // single + clear: function() { + this.opts.element.val(""); + this.selection.find("span").empty(); + this.selection.removeData("select2-data"); + this.setPlaceholder(); + }, + + /** + * Sets selection based on source element's value + */ + // single + initSelection: function () { + var selected; + if (this.opts.element.val() === "") { + this.close(); + this.setPlaceholder(); + } else { + var self = this; + this.opts.initSelection.call(null, this.opts.element, function(selected){ + if (selected !== undefined && selected !== null) { + self.updateSelection(selected); + self.close(); + self.setPlaceholder(); + } + }); + } + }, + + // single + prepareOpts: function () { + var opts = this.parent.prepareOpts.apply(this, arguments); + + if (opts.element.get(0).tagName.toLowerCase() === "select") { + // install the selection initializer + opts.initSelection = function (element, callback) { + var selected = element.find(":selected"); + // a single select box always has a value, no need to null check 'selected' + if ($.isFunction(callback)) + callback({id: selected.attr("value"), text: selected.text()}); + }; + } + + return opts; + }, + + // single + setPlaceholder: function () { + var placeholder = this.getPlaceholder(); + + if (this.opts.element.val() === "" && placeholder !== undefined) { + + // check for a first blank option if attached to a select + if (this.select && this.select.find("option:first").text() !== "") return; + + this.selection.find("span").html(escapeMarkup(placeholder)); + + this.selection.addClass("select2-default"); + + this.selection.find("abbr").hide(); + } + }, + + // single + postprocessResults: function (data, initial) { + var selected = 0, self = this, showSearchInput = true; + + // find the selected element in the result list + + this.results.find(".select2-result-selectable").each2(function (i, elm) { + if (equal(self.id(elm.data("select2-data")), self.opts.element.val())) { + selected = i; + return false; + } + }); + + // and highlight it + + this.highlight(selected); + + // hide the search box if this is the first we got the results and there are a few of them + + if (initial === true) { + showSearchInput = this.showSearchInput = countResults(data.results) >= this.opts.minimumResultsForSearch; + this.dropdown.find(".select2-search")[showSearchInput ? "removeClass" : "addClass"]("select2-search-hidden"); + + //add "select2-with-searchbox" to the container if search box is shown + $(this.dropdown, this.container)[showSearchInput ? "addClass" : "removeClass"]("select2-with-searchbox"); + } + + }, + + // single + onSelect: function (data) { + var old = this.opts.element.val(); + + this.opts.element.val(this.id(data)); + this.updateSelection(data); + this.close(); + this.selection.focus(); + + if (!equal(old, this.id(data))) { this.triggerChange(); } + }, + + // single + updateSelection: function (data) { + + var container=this.selection.find("span"), formatted; + + this.selection.data("select2-data", data); + + container.empty(); + formatted=this.opts.formatSelection(data, container); + if (formatted !== undefined) { + container.append(escapeMarkup(formatted)); + } + + this.selection.removeClass("select2-default"); + + if (this.opts.allowClear && this.getPlaceholder() !== undefined) { + this.selection.find("abbr").show(); + } + }, + + // single + val: function () { + var val, data = null, self = this; + + if (arguments.length === 0) { + return this.opts.element.val(); + } + + val = arguments[0]; + + if (this.select) { + this.select + .val(val) + .find(":selected").each2(function (i, elm) { + data = {id: elm.attr("value"), text: elm.text()}; + return false; + }); + this.updateSelection(data); + this.setPlaceholder(); + } else { + if (this.opts.initSelection === undefined) { + throw new Error("cannot call val() if initSelection() is not defined"); + } + // val is an id. !val is true for [undefined,null,''] + if (!val) { + this.clear(); + return; + } + this.opts.initSelection(this.opts.element, function(data){ + self.opts.element.val(!data ? "" : self.id(data)); + self.updateSelection(data); + self.setPlaceholder(); + }); + } + }, + + // single + clearSearch: function () { + this.search.val(""); + }, + + // single + data: function(value) { + var data; + + if (arguments.length === 0) { + data = this.selection.data("select2-data"); + if (data == undefined) data = null; + return data; + } else { + if (!value || value === "") { + this.clear(); + } else { + this.opts.element.val(!value ? "" : this.id(value)); + this.updateSelection(value); + } + } + } + }); + + MultiSelect2 = clazz(AbstractSelect2, { + + // multi + createContainer: function () { + var container = $("
", { + "class": "select2-container select2-container-multi" + }).html([ + " " , + ""].join("")); + return container; + }, + + // multi + prepareOpts: function () { + var opts = this.parent.prepareOpts.apply(this, arguments); + + // TODO validate placeholder is a string if specified + + if (opts.element.get(0).tagName.toLowerCase() === "select") { + // install sthe selection initializer + opts.initSelection = function (element,callback) { + + var data = []; + element.find(":selected").each2(function (i, elm) { + data.push({id: elm.attr("value"), text: elm.text()}); + }); + + if ($.isFunction(callback)) + callback(data); + }; + } + + return opts; + }, + + // multi + initContainer: function () { + + var selector = ".select2-choices", selection; + + this.searchContainer = this.container.find(".select2-search-field"); + this.selection = selection = this.container.find(selector); + + this.search.bind("keydown", this.bind(function (e) { + if (!this.enabled) return; + + if (e.which === KEY.BACKSPACE && this.search.val() === "") { + this.close(); + + var choices, + selected = selection.find(".select2-search-choice-focus"); + if (selected.length > 0) { + this.unselect(selected.first()); + this.search.width(10); + killEvent(e); + return; + } + + choices = selection.find(".select2-search-choice"); + if (choices.length > 0) { + choices.last().addClass("select2-search-choice-focus"); + } + } else { + selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus"); + } + + if (this.opened()) { + switch (e.which) { + case KEY.UP: + case KEY.DOWN: + this.moveHighlight((e.which === KEY.UP) ? -1 : 1); + killEvent(e); + return; + case KEY.ENTER: + case KEY.TAB: + this.selectHighlighted(); + killEvent(e); + return; + case KEY.ESC: + this.cancel(e); + killEvent(e); + return; + } + } + + if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) + || e.which === KEY.BACKSPACE || e.which === KEY.ESC) { + return; + } + + if (this.opts.openOnEnter === false && e.which === KEY.ENTER) { + return; + } + + this.open(); + + if (e.which === KEY.PAGE_UP || e.which === KEY.PAGE_DOWN) { + // prevent the page from scrolling + killEvent(e); + } + })); + + this.search.bind("keyup", this.bind(this.resizeSearch)); + + this.search.bind("blur", this.bind(function() { + this.container.removeClass("select2-container-active"); + })); + + this.container.delegate(selector, "mousedown", this.bind(function (e) { + if (!this.enabled) return; + this.clearPlaceholder(); + this.open(); + this.focusSearch(); + e.preventDefault(); + })); + + this.container.delegate(selector, "focus", this.bind(function () { + if (!this.enabled) return; + this.container.addClass("select2-container-active"); + this.dropdown.addClass("select2-drop-active"); + this.clearPlaceholder(); + })); + + // set the placeholder if necessary + this.clearSearch(); + }, + + // multi + enable: function() { + if (this.enabled) return; + + this.parent.enable.apply(this, arguments); + + this.search.removeAttr("disabled"); + }, + + // multi + disable: function() { + if (!this.enabled) return; + + this.parent.disable.apply(this, arguments); + + this.search.attr("disabled", true); + }, + + // multi + initSelection: function () { + var data; + if (this.opts.element.val() === "") { + this.updateSelection([]); + this.close(); + // set the placeholder if necessary + this.clearSearch(); + } + if (this.select || this.opts.element.val() !== "") { + var self = this; + this.opts.initSelection.call(null, this.opts.element, function(data){ + if (data !== undefined && data !== null) { + self.updateSelection(data); + self.close(); + // set the placeholder if necessary + self.clearSearch(); + } + }); + } + }, + + // multi + clearSearch: function () { + var placeholder = this.getPlaceholder(); + + if (placeholder !== undefined && this.getVal().length === 0 && this.search.hasClass("select2-focused") === false) { + this.search.val(placeholder).addClass("select2-default"); + // stretch the search box to full width of the container so as much of the placeholder is visible as possible + this.resizeSearch(); + } else { + // we set this to " " instead of "" and later clear it on focus() because there is a firefox bug + // that does not properly render the caret when the field starts out blank + this.search.val(" ").width(10); + } + }, + + // multi + clearPlaceholder: function () { + if (this.search.hasClass("select2-default")) { + this.search.val("").removeClass("select2-default"); + } else { + // work around for the space character we set to avoid firefox caret bug + if (this.search.val() === " ") this.search.val(""); + } + }, + + // multi + opening: function () { + this.parent.opening.apply(this, arguments); + + this.clearPlaceholder(); + this.resizeSearch(); + this.focusSearch(); + }, + + // multi + close: function () { + if (!this.opened()) return; + this.parent.close.apply(this, arguments); + }, + + // multi + focus: function () { + this.close(); + this.search.focus(); + }, + + // multi + isFocused: function () { + return this.search.hasClass("select2-focused"); + }, + + // multi + updateSelection: function (data) { + var ids = [], filtered = [], self = this; + + // filter out duplicates + $(data).each(function () { + if (indexOf(self.id(this), ids) < 0) { + ids.push(self.id(this)); + filtered.push(this); + } + }); + data = filtered; + + this.selection.find(".select2-search-choice").remove(); + $(data).each(function () { + self.addSelectedChoice(this); + }); + self.postprocessResults(); + }, + + tokenize: function() { + var input = this.search.val(); + input = this.opts.tokenizer(input, this.data(), this.bind(this.onSelect), this.opts); + if (input != null && input != undefined) { + this.search.val(input); + if (input.length > 0) { + this.open(); + } + } + + }, + + // multi + onSelect: function (data) { + this.addSelectedChoice(data); + 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 { + // if nothing left to select close + this.close(); + } + } + + // since its not possible to select an element that has already been + // added we do not need to check if this is a new element before firing change + this.triggerChange({ added: data }); + + this.focusSearch(); + }, + + // multi + cancel: function () { + this.close(); + this.focusSearch(); + }, + + // multi + addSelectedChoice: function (data) { + var choice=$( + "
  • " + + "
    " + + " " + + "
  • "), + id = this.id(data), + val = this.getVal(), + formatted; + + formatted=this.opts.formatSelection(data, choice); + choice.find("div").replaceWith("
    "+escapeMarkup(formatted)+"
    "); + choice.find(".select2-search-choice-close") + .bind("mousedown", killEvent) + .bind("click dblclick", this.bind(function (e) { + if (!this.enabled) return; + + $(e.target).closest(".select2-search-choice").fadeOut('fast').animate({width: "hide"}, 50, this.bind(function(){ + this.unselect($(e.target)); + this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus"); + this.close(); + this.focusSearch(); + })).dequeue(); + killEvent(e); + })).bind("focus", this.bind(function () { + if (!this.enabled) return; + this.container.addClass("select2-container-active"); + this.dropdown.addClass("select2-drop-active"); + })); + + choice.data("select2-data", data); + choice.insertBefore(this.searchContainer); + + val.push(id); + this.setVal(val); + }, + + // multi + unselect: function (selected) { + var val = this.getVal(), + data, + index; + + selected = selected.closest(".select2-search-choice"); + + if (selected.length === 0) { + throw "Invalid argument: " + selected + ". Must be .select2-search-choice"; + } + + data = selected.data("select2-data"); + + index = indexOf(this.id(data), val); + + if (index >= 0) { + val.splice(index, 1); + this.setVal(val); + if (this.select) this.postprocessResults(); + } + selected.remove(); + this.triggerChange({ removed: data }); + }, + + // multi + postprocessResults: function () { + var val = this.getVal(), + choices = this.results.find(".select2-result-selectable"), + compound = this.results.find(".select2-result-with-children"), + self = this; + + choices.each2(function (i, choice) { + var id = self.id(choice.data("select2-data")); + if (indexOf(id, val) >= 0) { + choice.addClass("select2-disabled").removeClass("select2-result-selectable"); + } else { + choice.removeClass("select2-disabled").addClass("select2-result-selectable"); + } + }); + + compound.each2(function(i, e) { + if (e.find(".select2-result-selectable").length==0) { + e.addClass("select2-disabled"); + } else { + e.removeClass("select2-disabled"); + } + }); + + choices.each2(function (i, choice) { + if (!choice.hasClass("select2-disabled") && choice.hasClass("select2-result-selectable")) { + self.highlight(0); + return false; + } + }); + + }, + + // multi + resizeSearch: function () { + + var minimumWidth, left, maxWidth, containerLeft, searchWidth, + sideBorderPadding = getSideBorderPadding(this.search); + + minimumWidth = measureTextWidth(this.search) + 10; + + left = this.search.offset().left; + + maxWidth = this.selection.width(); + containerLeft = this.selection.offset().left; + + searchWidth = maxWidth - (left - containerLeft) - sideBorderPadding; + if (searchWidth < minimumWidth) { + searchWidth = maxWidth - sideBorderPadding; + } + + if (searchWidth < 40) { + searchWidth = maxWidth - sideBorderPadding; + } + this.search.width(searchWidth); + }, + + // multi + getVal: function () { + var val; + if (this.select) { + val = this.select.val(); + return val === null ? [] : val; + } else { + val = this.opts.element.val(); + return splitVal(val, this.opts.separator); + } + }, + + // multi + setVal: function (val) { + var unique; + if (this.select) { + this.select.val(val); + } else { + unique = []; + // filter out duplicates + $(val).each(function () { + if (indexOf(this, unique) < 0) unique.push(this); + }); + this.opts.element.val(unique.length === 0 ? "" : unique.join(this.opts.separator)); + } + }, + + // multi + val: function () { + var val, data = [], self=this; + + if (arguments.length === 0) { + return this.getVal(); + } + + val = arguments[0]; + + if (!val) { + this.opts.element.val(""); + this.updateSelection([]); + this.clearSearch(); + return; + } + + // val is a list of ids + this.setVal(val); + + if (this.select) { + this.select.find(":selected").each(function () { + data.push({id: $(this).attr("value"), text: $(this).text()}); + }); + this.updateSelection(data); + } else { + if (this.opts.initSelection === undefined) { + throw new Error("val() cannot be called if initSelection() is not defined") + } + + this.opts.initSelection(this.opts.element, function(data){ + var ids=$(data).map(self.id); + self.setVal(ids); + self.updateSelection(data); + self.clearSearch(); + }); + } + this.clearSearch(); + }, + + // multi + onSortStart: function() { + if (this.select) { + throw new Error("Sorting of elements is not supported when attached to instead."); + } + + // collapse search field into 0 width so its container can be collapsed as well + this.search.width(0); + // hide the container + this.searchContainer.hide(); + }, + + // multi + onSortEnd:function() { + + var val=[], self=this; + + // show search and move it to the end of the list + this.searchContainer.show(); + // make sure the search container is the last item in the list + this.searchContainer.appendTo(this.searchContainer.parent()); + // since we collapsed the width in dragStarted, we resize it here + this.resizeSearch(); + + // update selection + + this.selection.find(".select2-search-choice").each(function() { + val.push(self.opts.id($(this).data("select2-data"))); + }); + this.setVal(val); + this.triggerChange(); + }, + + // multi + data: function(values) { + var self=this, ids; + if (arguments.length === 0) { + return this.selection + .find(".select2-search-choice") + .map(function() { return $(this).data("select2-data"); }) + .get(); + } else { + if (!values) { values = []; } + ids = $.map(values, function(e) { return self.opts.id(e)}); + this.setVal(ids); + this.updateSelection(values); + this.clearSearch(); + } + } + }); + + $.fn.select2 = function () { + + var args = Array.prototype.slice.call(arguments, 0), + opts, + select2, + value, multiple, allowedMethods = ["val", "destroy", "opened", "open", "close", "focus", "isFocused", "container", "onSortStart", "onSortEnd", "enable", "disable", "positionDropdown", "data"]; + + this.each(function () { + if (args.length === 0 || typeof(args[0]) === "object") { + opts = args.length === 0 ? {} : $.extend({}, args[0]); + opts.element = $(this); + + if (opts.element.get(0).tagName.toLowerCase() === "select") { + multiple = opts.element.attr("multiple"); + } else { + multiple = opts.multiple || false; + if ("tags" in opts) {opts.multiple = multiple = true;} + } + + select2 = multiple ? new MultiSelect2() : new SingleSelect2(); + select2.init(opts); + } else if (typeof(args[0]) === "string") { + + if (indexOf(args[0], allowedMethods) < 0) { + throw "Unknown method: " + args[0]; + } + + value = undefined; + select2 = $(this).data("select2"); + if (select2 === undefined) return; + if (args[0] === "container") { + value=select2.container; + } else { + value = select2[args[0]].apply(select2, args.slice(1)); + } + if (value !== undefined) {return false;} + } else { + throw "Invalid arguments to select2 plugin: " + args; + } + }); + return (value === undefined) ? this : value; + }; + + // plugin defaults, accessible to users + $.fn.select2.defaults = { + width: "copy", + closeOnSelect: true, + openOnEnter: true, + containerCss: {}, + dropdownCss: {}, + containerCssClass: "", + dropdownCssClass: "", + formatResult: function(result, container, query) { + var markup=[]; + markMatch(result.text, query.term, markup); + return markup.join(""); + }, + formatSelection: function (data, container) { + return data.text; + }, + formatResultCssClass: function(data) {return undefined;}, + formatNoMatches: function () { return "No matches found"; }, + formatInputTooShort: function (input, min) { return "Please enter " + (min - input.length) + " more characters"; }, + formatSelectionTooBig: function (limit) { return "You can only select " + limit + " items"; }, + formatLoadMore: function (pageNumber) { return "Loading more results..."; }, + formatSearching: function () { return "Searching..."; }, + minimumResultsForSearch: 0, + minimumInputLength: 0, + maximumSelectionSize: 0, + id: function (e) { return e.id; }, + matcher: function(term, text) { + return text.toUpperCase().indexOf(term.toUpperCase()) >= 0; + }, + separator: ",", + tokenSeparators: [], + tokenizer: defaultTokenizer + }; + + // exports + window.Select2 = { + query: { + ajax: ajax, + local: local, + tags: tags + }, util: { + debounce: debounce, + markMatch: markMatch + }, "class": { + "abstract": AbstractSelect2, + "single": SingleSelect2, + "multi": MultiSelect2 + } + }; + +}(jQuery)); diff --git a/django_select2/static/js/select2.min.js b/django_select2/static/js/select2.min.js index 2b890b0..9fc078f 100644 --- a/django_select2/static/js/select2.min.js +++ b/django_select2/static/js/select2.min.js @@ -1,7 +1,7 @@ /* Copyright 2012 Igor Vaynberg -Version: 3.0 Timestamp: Tue Jul 31 21:09:16 PDT 2012 +Version: 3.1 Timestamp: Tue Aug 14 09:05:17 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: @@ -12,65 +12,68 @@ Unless required by applicable law or agreed to in writing, software distributed 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(f){"undefined"==typeof f.fn.each2&&f.fn.extend({each2:function(h){for(var l=f([0]),j=-1,m=this.length;++ja.length)return[];c=a.split(b);d=0;for(g=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 B(a){var b,c=0,d=null,g=a.quietMillis||100;return function(k){window.clearTimeout(b);b=window.setTimeout(function(){var b=c+=1,g=a.data,e=a.transport||f.ajax,h=a.type||"GET",g=g.call(this,k.term,k.page,k.context);null!==d&&d.abort();d=e.call(null,{url:a.url,dataType:a.dataType,data:g,type:h,success:function(d){b=a}};f(document).delegate("*","mousemove",function(a){f.data(document,"select2-lastpos",{x:a.pageX,y:a.pageY})});f(document).ready(function(){f(document).delegate("*","mousedown touchend",function(a){var b=f(a.target).closest("div.select2-container").get(0),c;b?f(document).find("div.select2-container-active").each(function(){this!== -b&&f(this).data("select2").blur()}):(b=f(a.target).closest("div.select2-drop").get(0),f(document).find("div.select2-drop-active").each(function(){this!==b&&f(this).data("select2").blur()}));b=f(a.target);c=b.attr("for");"LABEL"===a.target.tagName&&(c&&0=c-g?(b.scrollTop(0),i(a)):0>g&&b.get(0).scrollHeight-b.scrollTop()+g<=b.height()&&(b.scrollTop(b.get(0).scrollHeight- -b.height()),i(a))});c.bind("keydown",function(){f.data(c,"keyup-change-value")===h&&f.data(c,"keyup-change-value",c.val())});c.bind("keyup",function(){var a=f.data(c,"keyup-change-value");a!==h&&c.val()!==a&&(f.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=f.extend({},{populateResults:function(b,c,d){var e,E=this.opts.id;e=function(b, -c,g){var k,i,j,p,q,n,m;k=0;for(i=b.length;k0;n=f("
  • ");n.addClass("select2-results-dept-"+g);n.addClass("select2-result");n.addClass(p?"select2-result-selectable":"select2-result-unselectable");q&&n.addClass("select2-result-with-children");p=f("
    ");p.addClass("select2-result-label");m=a.formatResult(j,p,d);m!==h&&p.html(l(m));n.append(p);if(q){q=f("
      ");q.addClass("select2-result-sub");e(j.children,q,g+1);n.append(q)}n.data("select2-data", -j);c.append(n)}};e(c,b,0)}},f.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,e,i,j;j=function(b,c){var f;if(b.is("option"))a.matcher(d,b.text(),b)&&c.push({id:b.attr("value"),text:b.text(),element:b.get()});else if(b.is("optgroup")){f={text:b.attr("label"),children:[],element:b.get()};b.children().each2(function(a,b){j(b,f.children)});f.children.length>0&&c.push(f)}};e=b.children();if(this.getPlaceholder()!== -h&&e.length>0){i=e[0];f(i).text()===""&&(e=e.not(i))}e.each2(function(a,b){j(b,c.results)});a.callback(c)}),a.id=function(a){return a.id};else if(!("query"in a))if("ajax"in a){if((c=a.element.data("ajax-url"))&&0=this.body().scrollTop(),h;this.dropdown.hasClass("select2-drop-above")?(h=!0,!e&&g&&(h=!1)):(h=!1,!g&&e&&(h=!0));h?(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"));this.dropdown.css({top:b,left:a.left, -width:c})},shouldOpen:function(){var a;if(this.opened())return!1;a=jQuery.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(){this.clearDropdownAlignmentPreference();" "===this.search.val()&&this.search.val("");this.dropdown.addClass("select2-drop-active"); -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.ensureHighlightVisible();this.positionDropdown();this.focusSearch()},close:function(){this.opened()&&(this.clearDropdownAlignmentPreference(),this.dropdown.hide(),this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active"),this.results.empty(), -this.clearSearch(),this.opts.element.trigger(jQuery.Event("close")))},clearSearch:function(){},ensureHighlightVisible:function(){var a=this.results,b,c,d,g;c=this.highlight();0>c||(0==c?a.scrollTop(0):(b=a.find(".select2-result-selectable"),d=f(b[c]),g=d.offset().top+d.outerHeight(),c===b.length-1&&(b=a.find("li.select2-more-results"),0b&&a.scrollTop(a.scrollTop()+(g-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"); -f(b[a]).addClass("select2-highlighted");this.ensureHighlightVisible()},countSelectableResults:function(){return this.results.find(".select2-result-selectable").not(".select2-disabled").length},highlightUnderEvent:function(a){a=f(a.target).closest(".select2-result-selectable");if(0=c&&(b.addClass("select2-active"),this.opts.query({term:e,page:d,context:h,matcher:this.opts.matcher,callback:this.bind(function(c){f.opts.populateResults.call(this,a,c.results,{term:e,page:d,context:h});!0===c.more?(b.detach().appendTo(a.children(":last")).text(f.opts.formatLoadMore(d+1)),window.setTimeout(function(){f.loadMoreIfNeeded()}, -10)):b.remove();f.positionDropdown();f.resultsPage=d})})))},updateResults:function(a){function b(){g.scrollTop(0);d.removeClass("select2-active");j.positionDropdown()}function c(a){g.html(l(a));b()}var d=this.search,g=this.results,e=this.opts,i,j=this;if(!(!0!==a&&(!1===this.showSearchInput||!this.opened()))){d.addClass("select2-active");if(1<=e.maximumSelectionSize&&(i=this.data(),f.isArray(i)&&i.length>=e.maximumSelectionSize&&s(e.formatSelectionTooBig,"formatSelectionTooBig"))){c("
    • "+ -e.formatSelectionTooBig(e.maximumSelectionSize)+"
    • ");return}d.val().length"+e.formatInputTooShort(d.val(),e.minimumInputLength)+""):(this.resultsPage=1,e.query({term:d.val(),page:this.resultsPage,context:null,matcher:e.matcher,callback:this.bind(function(i){var o;this.context=i.context===h?null:i.context;this.opts.createSearchChoice&&""!==d.val()&&(o=this.opts.createSearchChoice.call(null, -d.val(),i.results),o!==h&&null!==o&&j.id(o)!==h&&null!==j.id(o)&&0===f(i.results).filter(function(){return m(j.id(this),j.id(o))}).length&&i.results.unshift(o));0===i.results.length&&s(e.formatNoMatches,"formatNoMatches")?c("
    • "+e.formatNoMatches(d.val())+"
    • "):(g.empty(),j.opts.populateResults.call(this,g,i.results,{term:d.val(),page:this.resultsPage,context:null}),!0===i.more&&s(e.formatLoadMore,"formatLoadMore")&&(g.children().filter(":last").append("
    • "+ -l(e.formatLoadMore(this.resultsPage))+"
    • "),window.setTimeout(function(){j.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(){window.setTimeout(this.bind(function(){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,e;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!==h){a=a.split(";");d=0;for(e=a.length;d",{"class":"select2-container"}).html("
      ")}, +(function(e){"undefined"==typeof e.fn.each2&&e.fn.extend({each2:function(g){for(var n=e([0]),h=-1,m=this.length;++ha.length)return[];c=a.split(b);d=0;for(i=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,i=a.quietMillis||100;return function(j){window.clearTimeout(b);b=window.setTimeout(function(){var b=c+=1,i=a.data,f=a.transport||e.ajax,g=a.traditional||!1,I=a.type||"GET",i=i.call(this,j.term,j.page,j.context);null!==d&&d.abort();d=f.call(null,{url:a.url,dataType:a.dataType,data:i,type:I,traditional:g,success:function(d){bd.tokenSeparators.length)return g;for(;;){e=-1;r=0;for(o=d.tokenSeparators.length;re)break;f=a.substring(0,e);a=a.substring(e+l.length);if(0=a}};var K=1;G=function(){return K++};e(document).delegate("*","mousemove",function(a){e.data(document,"select2-lastpos",{x:a.pageX,y:a.pageY})});e(document).ready(function(){e(document).delegate("*","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=c-e?(b.scrollTop(0),k(a)):0>e&&b.get(0).scrollHeight-b.scrollTop()+ +e<=b.height()&&(b.scrollTop(b.get(0).scrollHeight-b.height()),k(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,o=this.opts.id,l=this;f=function(b,c,i){var j,k,h,m,s,p,q;j=0;for(k=b.length;j0;p=e("
    • ");p.addClass("select2-results-dept-"+i);p.addClass("select2-result");p.addClass(m?"select2-result-selectable":"select2-result-unselectable");s&&p.addClass("select2-result-with-children");p.addClass(l.opts.formatResultCssClass(h));m=e("
      ");m.addClass("select2-result-label");q=a.formatResult(h,m,d);q!==g&&m.html(n(q));p.append(m); +if(s){s=e("
        ");s.addClass("select2-result-sub");f(h.children,s,i+1);p.append(s)}p.data("select2-data",h);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,o,l;l=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){l(b,e.children)});e.children.length>0&&c.push(e)}};f=b.children();if(this.getPlaceholder()!==g&&f.length>0){o=f[0];e(o).text()===""&&(f=f.not(o))}f.each2(function(a,b){l(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(),g;this.dropdown.hasClass("select2-drop-above")?(g=!0,!f&&i&&(g=!1)):(g=!1,!i&&f&&(g=!0));g?(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"));this.dropdown.css({top:b,left:a.left,width:c})},shouldOpen:function(){var a;if(this.opened())return!1;a=jQuery.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="#"+a,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.dropdown.css(u(this.opts.dropdownCss));this.dropdown.addClass("select2-drop-active");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.ensureHighlightVisible();this.positionDropdown();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(jQuery.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.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(n(a));b()}var d=this.search,f=this.results,j=this.opts,h,k=this;if(!(!0!==a&&(!1===this.showSearchInput||!this.opened()))){d.addClass("select2-active");if(1<=j.maximumSelectionSize&&(h=this.data(),e.isArray(h)&&h.length>=j.maximumSelectionSize&&t(j.formatSelectionTooBig,"formatSelectionTooBig"))){c("
      • "+ +j.formatSelectionTooBig(j.maximumSelectionSize)+"
      • ");return}d.val().length"+j.formatInputTooShort(d.val(),j.minimumInputLength)+""):(c("
      • "+j.formatSearching()+"
      • "),h=this.tokenize(),h!=g&&null!=h&&d.val(h),this.resultsPage=1,j.query({term:d.val(),page:this.resultsPage,context:null,matcher:j.matcher,callback:this.bind(function(h){var l;this.context=h.context=== +g?null:h.context;this.opts.createSearchChoice&&""!==d.val()&&(l=this.opts.createSearchChoice.call(null,d.val(),h.results),l!==g&&null!==l&&k.id(l)!==g&&null!==k.id(l)&&0===e(h.results).filter(function(){return m(k.id(this),k.id(l))}).length&&h.results.unshift(l));0===h.results.length&&t(j.formatNoMatches,"formatNoMatches")?c("
      • "+j.formatNoMatches(d.val())+"
      • "):(f.empty(),k.opts.populateResults.call(this,f,h.results,{term:d.val(),page:this.resultsPage,context:null}), +!0===h.more&&t(j.formatLoadMore,"formatLoadMore")&&(f.append("
      • "+n(j.formatLoadMore(this.resultsPage))+"
      • "),window.setTimeout(function(){k.loadMoreIfNeeded()},10)),this.postprocessResults(h,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(){window.setTimeout(this.bind(function(){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===e.PAGE_UP||a.which===e.PAGE_DOWN)i(a);else if(this.opened())switch(a.which){case e.UP:case e.DOWN:this.moveHighlight(a.which===e.UP?-1:1);i(a);break;case e.TAB:case e.ENTER:this.selectHighlighted();i(a);break;case e.ESC:this.cancel(a),i(a)}else a.which===e.TAB||(e.isControl(a)||e.isFunctionKey(a)||a.which===e.ESC)||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(a){this.opened()?(this.close(),this.selection.focus()):this.enabled&&this.open();i(a)}));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.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===e.PAGE_UP||a.which===e.PAGE_DOWN)i(a);else if(!(a.which===e.TAB||e.isControl(a)||e.isFunctionKey(a)||a.which=== -e.ESC)){this.open();if(a.which!==e.ENTER&&!(48>a.which)){var b=String.fromCharCode(a.which).toLowerCase();a.shiftKey&&(b=b.toUpperCase());this.search.val(b)}i(a)}}));a.delegate("abbr","mousedown",this.bind(function(a){this.enabled&&(this.clear(),i(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!==h&&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");f.isFunction(c)&& -c({id:d.attr("value"),text:d.text()})});return a},setPlaceholder:function(){var a=this.getPlaceholder();""===this.opts.element.val()&&a!==h&&!(this.select&&""!==this.select.find("option:first").text())&&(this.selection.find("span").html(l(a)),this.selection.addClass("select2-default"),this.selection.find("abbr").hide())},postprocessResults:function(a,b){var c=0,d=this,e=!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&&(e=this.showSearchInput=a.results.length>=this.opts.minimumResultsForSearch,this.dropdown.find(".select2-search")[e?"removeClass":"addClass"]("select2-search-hidden"),f(this.dropdown,this.container)[e?"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!==h&&b.append(l(a));this.selection.removeClass("select2-default");this.opts.allowClear&&this.getPlaceholder()!==h&&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===h)throw Error("cannot call val() if initSelection() is not defined");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==h&&(b=null),b;!a||""===a?this.clear():(this.opts.element.val(!a?"":this.id(a)),this.updateSelection(a))}}); -x=v(u,{createContainer:function(){return f("
        ",{"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()})});f.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===e.BACKSPACE&&""===this.search.val()){this.close();var c;c=a.find(".select2-search-choice-focus");if(0j(d.id(this),b)&&(b.push(d.id(this)),c.push(this))});a=c;this.selection.find(".select2-search-choice").remove();f(a).each(function(){d.addSelectedChoice(this)}); -d.postprocessResults()},onSelect:function(a){this.addSelectedChoice(a);this.select&&this.postprocessResults();this.opts.closeOnSelect?(this.close(),this.search.width(10)):(this.search.width(10),this.resizeSearch(),0
        "), -c=this.id(a),d=this.getVal(),e;e=this.opts.formatSelection(a,b);b.find("div").replaceWith("
        "+l(e)+"
        ");b.find(".select2-search-choice-close").bind("click dblclick",this.bind(function(a){this.enabled&&(f(a.target).closest(".select2-search-choice").fadeOut("fast").animate({width:"hide"},50,this.bind(function(){this.unselect(f(a.target));this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");this.close();this.focusSearch()})).dequeue(),i(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=j(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 f=d.id(c.data("select2-data"));0<=j(f,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,e=this.search.outerWidth()-this.search.width();a=this.search;r||(c=a[0].currentStyle||window.getComputedStyle(a[0],null),r=f("
        ").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"}),f("body").append(r));r.text(a.val());a=r.width()+10;b=this.search.offset().left;c=this.selection.width();d=this.selection.offset().left;b=c-(b-d)-e;bb&&(b=c-e);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 y(a,this.opts.separator)},setVal:function(a){var b;this.select?this.select.val(a):(b=[],f(a).each(function(){0>j(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:f(this).attr("value"),text:f(this).text()})}),this.updateSelection(b);else{if(this.opts.initSelection===h)throw Error("val() cannot be called if initSelection() is not defined");this.opts.initSelection(this.opts.element,function(a){var b=f(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(f(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 f(this).data("select2-data")}).get();a||(a=[]);c=f.map(a,function(a){return b.opts.id(a)});this.setVal(c);this.updateSelection(a);this.clearSearch()}});f.fn.select2=function(){var a=Array.prototype.slice.call(arguments,0),b,c,d,e,i="val destroy 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?{}:f.extend({},a[0]),b.element=f(this),"select"===b.element.get(0).tagName.toLowerCase()?e=b.element.attr("multiple"):(e=b.multiple||!1,"tags"in b&&(b.multiple=e=!0)),c=e?new x:new w,c.init(b);else if("string"===typeof a[0]){if(0>j(a[0],i))throw"Unknown method: "+a[0];d=h;c=f(this).data("select2");if(c!==h&&(d="container"===a[0]?c.container:c[a[0]].apply(c,a.slice(1)),d!==h))return!1}else throw"Invalid arguments to select2 plugin: "+ -a;});return d===h?this:d};f.fn.select2.defaults={width:"copy",closeOnSelect:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(a,b,c){b=[];A(a.text,c.term,b);return b.join("")},formatSelection:function(a){return a.text},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+" items"},formatLoadMore:function(){return"Loading more results..."}, -minimumResultsForSearch:0,minimumInputLength:0,maximumSelectionSize:0,id:function(a){return a.id},matcher:function(a,b){return 0<=b.toUpperCase().indexOf(a.toUpperCase())}};window.Select2={query:{ajax:B,local:C,tags:D},util:{debounce:z,markMatch:A},"class":{"abstract":u,single:w,multi:x}}}})(jQuery); +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)k(a);else if(this.opened())switch(a.which){case f.UP:case f.DOWN:this.moveHighlight(a.which===f.UP?-1:1);k(a);break;case f.TAB:case f.ENTER:this.selectHighlighted();k(a);break;case f.ESC:this.cancel(a),k(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)k(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)}k(a)}}));a.delegate("abbr","mousedown",this.bind(function(a){this.enabled&&(this.clear(),k(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(n(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(n(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.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))}});y=w(v,{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(0h(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("
        "+ +n(f)+"
        ");b.find(".select2-search-choice-close").bind("mousedown",k).bind("click dblclick",this.bind(function(a){this.enabled&&(e(a.target).closest(".select2-search-choice").fadeOut("fast").animate({width:"hide"},50,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(),k(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=h(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<=h(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 z(a,this.opts.separator)},setVal:function(a){var b;this.select?this.select.val(a):(b=[],e(a).each(function(){0>h(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,j="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 y:new x,c.init(b);else if("string"===typeof a[0]){if(0>h(a[0],j))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.text},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+" items"},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:J};window.Select2={query:{ajax:C,local:D,tags:E},util:{debounce:A,markMatch:B},"class":{"abstract":v,single:x,multi:y}}}})(jQuery); diff --git a/django_select2/widgets.py b/django_select2/widgets.py index 6a8d0ac..a9bf6c1 100644 --- a/django_select2/widgets.py +++ b/django_select2/widgets.py @@ -16,6 +16,14 @@ from .util import render_js_script, convert_to_js_string_arr, JSVar, JSFunction, logger = logging.getLogger(__name__) +def get_select2_js_path(): + from django.conf import settings + if settings.configured and settings.DEBUG: + return 'js/select2.js' + else: + return 'js/select2.min.js' + + ### Light mixin and widgets ### class Select2Mixin(object): @@ -186,7 +194,7 @@ class Select2Mixin(object): return mark_safe(s) class Media: - js = ('js/select2.min.js', ) + js = (get_select2_js_path(), ) css = {'screen': ('css/select2.css', 'css/extra.css', )} @@ -412,7 +420,7 @@ class HeavySelect2Mixin(Select2Mixin): return js class Media: - js = ('js/select2.min.js', 'js/heavy_data.js', ) + js = (get_select2_js_path(), 'js/heavy_data.js', ) css = {'screen': ('css/select2.css', 'css/extra.css', )} diff --git a/docs/_build/doctrees/environment.pickle b/docs/_build/doctrees/environment.pickle index eecee89..b7f123a 100644 Binary files a/docs/_build/doctrees/environment.pickle and b/docs/_build/doctrees/environment.pickle differ diff --git a/docs/_build/doctrees/overview.doctree b/docs/_build/doctrees/overview.doctree index 2059c3b..24159b5 100644 Binary files a/docs/_build/doctrees/overview.doctree and b/docs/_build/doctrees/overview.doctree differ diff --git a/docs/_build/doctrees/ref_widgets.doctree b/docs/_build/doctrees/ref_widgets.doctree index d5f52cd..1289972 100644 Binary files a/docs/_build/doctrees/ref_widgets.doctree and b/docs/_build/doctrees/ref_widgets.doctree differ diff --git a/docs/_build/doctrees/reference.doctree b/docs/_build/doctrees/reference.doctree index 91f16db..ea12c15 100644 Binary files a/docs/_build/doctrees/reference.doctree and b/docs/_build/doctrees/reference.doctree differ diff --git a/docs/_build/html/_sources/overview.txt b/docs/_build/html/_sources/overview.txt index cad309e..de6086a 100644 --- a/docs/_build/html/_sources/overview.txt +++ b/docs/_build/html/_sources/overview.txt @@ -1,3 +1,4 @@ +======== Overview ======== diff --git a/docs/_build/html/_sources/reference.txt b/docs/_build/html/_sources/reference.txt index 404b3d1..2c376d1 100644 --- a/docs/_build/html/_sources/reference.txt +++ b/docs/_build/html/_sources/reference.txt @@ -1,3 +1,4 @@ +============= API Reference ============= diff --git a/docs/_build/html/index.html b/docs/_build/html/index.html index ce1ca1c..2344a9b 100644 --- a/docs/_build/html/index.html +++ b/docs/_build/html/index.html @@ -58,10 +58,10 @@
      • Widgets
      • Fields
      • Views
      • +
      • External Dependencies
      • +
      • Example Application
      • -
      • External Dependencies
      • -
      • Example Application
      • API Reference
        • Widgets
        • Fields
        • diff --git a/docs/_build/html/objects.inv b/docs/_build/html/objects.inv index 18a53d6..ff1552c 100644 Binary files a/docs/_build/html/objects.inv and b/docs/_build/html/objects.inv differ diff --git a/docs/_build/html/overview.html b/docs/_build/html/overview.html index e12f49d..7d5038f 100644 --- a/docs/_build/html/overview.html +++ b/docs/_build/html/overview.html @@ -78,13 +78,13 @@ create a view specifically to respond to the queries.

          Heavies have further specialized versions called – Auto Heavy. These do not require views to server Ajax request. When they are instantiated, they register themselves with one central view which handels Ajax requests for them.

          -

          Read more

          Heavy widgets have the word ‘Heavy’ in their name. Light widgets are normally named, i.e. there is no ‘Light’ word in their names.

          Available widgets:

          Select2Widget, Select2MultipleWidget, HeavySelect2Widget, HeavySelect2MultipleWidget, AutoHeavySelect2Widget, AutoHeavySelect2MultipleWidget

          +

          Read more

          Fields

          @@ -101,22 +101,23 @@ your ease.

          Views

          -

          The view - Select2View, exposed here is meant to be used with ‘Heavy’ fields and widgets. Read more

          +

          The view - Select2View, exposed here is meant to be used with ‘Heavy’ fields and widgets.

          Imported:

          Select2View, NO_ERR_RESP

          -
          +

          Read more

          -

          External Dependencies

          +

          External Dependencies

          • Django - This is obvious.
          • jQuery - This is not included in the package since it is expected that in most scenarios this would already be available.
          -

          Example Application

          +

          Example Application

          Please see testapp application. This application is used to manually test the functionalities of this package. This also serves as a good example.

          You need only Django 1.4 or above to run that. It might run on older versions but that is not tested.

          +
          @@ -131,10 +132,10 @@ your ease.

        • Widgets
        • Fields
        • Views
        • -
        -
      • External Dependencies
      • Example Application
      • + +

        Previous topic

        diff --git a/docs/_build/html/searchindex.js b/docs/_build/html/searchindex.js index 72a0c7f..e061047 100644 --- a/docs/_build/html/searchindex.js +++ b/docs/_build/html/searchindex.js @@ -1 +1 @@ -Search.setIndex({objects:{"":{django_select2:[3,0,1,""]},"django_select2.widgets.Select2Mixin":{get_options:[1,3,1,""],render:[1,3,1,""],init_options:[1,3,1,""],render_select2_options_code:[1,3,1,""],set_placeholder:[1,3,1,""],render_inner_js_code:[1,3,1,""],render_js_code:[1,3,1,""],options:[1,1,1,""],"__init__":[1,3,1,""]},django_select2:{util:[6,0,1,""],widgets:[1,0,1,""],fields:[4,0,1,""],views:[5,0,1,""]},"django_select2.fields.AutoModelSelect2Field":{widget:[4,1,1,""]},"django_select2.views":{AutoResponseView:[5,2,1,""],NO_ERR_RESP:[5,5,1,""],Select2View:[5,2,1,""],JSONResponseMixin:[5,2,1,""]},"django_select2.fields.HeavySelect2MultipleChoiceField":{widget:[4,1,1,""]},"django_select2.fields.AutoModelSelect2MultipleField":{widget:[4,1,1,""]},"django_select2.util":{render_js_script:[6,4,1,""],JSVar:[6,2,1,""],convert_py_to_js_data:[6,4,1,""],"synchronized":[6,4,1,""],is_valid_id:[6,4,1,""],convert_to_js_arr:[6,4,1,""],JSFunction:[6,2,1,""],convert_dict_to_js_map:[6,4,1,""],extract_some_key_val:[6,4,1,""],JSFunctionInContext:[6,2,1,""],get_field:[6,4,1,""],register_field:[6,4,1,""],convert_to_js_string_arr:[6,4,1,""]},"django_select2.fields.HeavyMultipleChoiceField":{hidden_widget:[4,1,1,""]},"django_select2.fields.Select2MultipleChoiceField":{widget:[4,1,1,""]},"django_select2.fields.HeavySelect2FieldBaseMixin":{"__init__":[4,3,1,""]},"django_select2.views.JSONResponseMixin":{render_to_response:[5,3,1,""],response_class:[5,1,1,""],convert_context_to_json:[5,3,1,""]},"django_select2.fields.AutoSelect2Field":{widget:[4,1,1,""]},"django_select2.fields.HeavyModelSelect2ChoiceField":{widget:[4,1,1,""]},"django_select2.widgets":{Select2Mixin:[1,2,1,""],Select2Widget:[1,2,1,""],HeavySelect2Mixin:[1,2,1,""],AutoHeavySelect2Mixin:[1,2,1,""],Select2MultipleWidget:[1,2,1,""],AutoHeavySelect2Widget:[1,2,1,""],AutoHeavySelect2MultipleWidget:[1,2,1,""],HeavySelect2Widget:[1,2,1,""],MultipleSelect2HiddenInput:[1,2,1,""],HeavySelect2MultipleWidget:[1,2,1,""]},"django_select2.views.Select2View":{check_all_permissions:[5,3,1,""],get_results:[5,3,1,""],respond_with_exception:[5,3,1,""]},"django_select2.fields.Select2ChoiceField":{widget:[4,1,1,""]},"django_select2.fields.ModelResultJsonMixin":{get_results:[4,3,1,""],label_from_instance:[4,3,1,""],prepare_qs_params:[4,3,1,""],"__init__":[4,3,1,""]},"django_select2.fields.HeavyModelSelect2MultipleChoiceField":{widget:[4,1,1,""]},"django_select2.fields.ModelSelect2Field":{widget:[4,1,1,""]},"django_select2.fields.AutoViewFieldMixin":{get_results:[4,3,1,""],security_check:[4,3,1,""],"__init__":[4,3,1,""]},"django_select2.widgets.HeavySelect2MultipleWidget":{render_texts_for_value:[1,3,1,""]},"django_select2.fields":{HeavyChoiceField:[4,2,1,""],AutoSelect2Field:[4,2,1,""],Select2MultipleChoiceField:[4,2,1,""],HeavyMultipleChoiceField:[4,2,1,""],HeavyModelSelect2ChoiceField:[4,2,1,""],UnhideableQuerysetType:[4,2,1,""],QuerysetChoiceMixin:[4,2,1,""],ModelResultJsonMixin:[4,2,1,""],AutoModelSelect2MultipleField:[4,2,1,""],ModelSelect2Field:[4,2,1,""],AutoSelect2MultipleField:[4,2,1,""],ModelSelect2MultipleField:[4,2,1,""],ChoiceMixin:[4,2,1,""],AutoModelSelect2Field:[4,2,1,""],AutoViewFieldMixin:[4,2,1,""],Select2ChoiceField:[4,2,1,""],HeavySelect2MultipleChoiceField:[4,2,1,""],HeavySelect2ChoiceField:[4,2,1,""],HeavySelect2FieldBaseMixin:[4,2,1,""],HeavyModelSelect2MultipleChoiceField:[4,2,1,""]},"django_select2.fields.HeavySelect2ChoiceField":{widget:[4,1,1,""]},"django_select2.fields.HeavyChoiceField":{coerce_value:[4,3,1,""],empty_value:[4,1,1,""],get_val_txt:[4,3,1,""],validate_value:[4,3,1,""]},"django_select2.fields.AutoSelect2MultipleField":{widget:[4,1,1,""]},"django_select2.widgets.HeavySelect2Mixin":{render_texts:[1,3,1,""],render_texts_for_value:[1,3,1,""],"__init__":[1,3,1,""]},"django_select2.fields.ModelSelect2MultipleField":{widget:[4,1,1,""]}},terms:{all:[0,1,3,4,5,6],code:[3,1,5,6],forget:4,queri:[3,1,4,5],autoselect2multiplefield:[3,4],per:4,follow:[1,6],search_term:4,id1:5,row:5,depend:[0,1,3],sensit:[4,5],send:1,cach:1,scratch:5,selectclass:5,sent:5,emploi:1,sourc:[3,1,4,5,6],string:[1,4,6],fals:[1,4,5,6],util:[0,4,6,2],extract_some_key_v:6,render_texts_for_valu:1,relev:2,allowclear:1,level:4,list:[1,4,6],iter:6,item:1,cooki:1,select2widgetnam:1,pleas:3,security_check:4,multiplehiddeninput:4,convert_to_js_arr:6,second:1,design:5,pass:[1,4,5],further:3,val1:1,compat:1,index:0,what:6,warap:6,sub:[1,4,5,6],multiplechoicefield:4,abl:[4,5],invok:6,access:[4,5],version:[3,1],"new":[1,5],method:[1,4],widget:[0,1,2,3,4,5],full:4,themselv:3,minimumresultsforsearch:1,gener:[3,1,4,5,6],never:4,here:[3,4,6],otion:1,let:4,testapp:3,process_result:1,sinc:[3,6],valu:[1,4,5,6],box:1,search:[0,1,4,5,3],convers:6,querysetchoicemixin:4,autoheavyselect2widget:[3,1,4],fetch:3,reimplement:4,implement:[3,4],extra:1,primit:6,app:3,api:[0,2],marker:6,txt:1,select:[3,1],highli:3,from:[3,1,5,6],would:[3,1,4,5,6],commun:3,regist:[3,1,4,6],first_name__icontain:4,next:5,few:1,call:[3,4,6],recommend:[3,5],suppos:1,type:[3,1,4,5,6],more:[3,1,4,5,6],attr11:4,attr12:4,peopl:[4,5],relat:3,warn:[1,4,5],flag:6,text1:5,accept:4,central:[3,1,4,5],easiest:3,must:[1,4,5,6],heavymodelselect2multiplechoicefield:[3,4],none:[1,4,5,6],word:3,err:5,alia:[4,5],prepar:4,to_field_nam:4,uniqu:4,kwarg:[1,4,5,6],can:[1,4,5,6],response_kwarg:5,purpos:[3,6],select2:[3,1,4],def:1,overrid:[1,4,5],no_err_resp:[3,5],share:[1,4],indic:0,tag:1,login_requir:5,parsabl:4,occur:4,alwai:[4,6],multipl:[1,4,6],secur:4,anoth:6,heavyselect2fieldbasemixin:4,write:[3,1],convert_py_to_js_data:6,multipleselect2hiddeninput:1,instead:[3,1,4,5,6],simpl:[4,6],label2:[1,5],css:1,map:[1,6],after:6,befor:4,wrong:1,mixin:[1,4,5],oninit:1,data:[1,4,6],coax:4,light:[3,4],your_js_funct:1,django:[3,1,4,5],inform:[4,5],allow:1,enter:4,render_select2_options_cod:1,modelmultiplechoicefield:4,help:5,failur:5,becaus:[3,4],lst:6,through:3,help_text:4,still:[1,6],dynam:3,paramet:[1,4,5,6],inner_cod:6,as_view:5,render:[3,1,5,6],window:[1,6],select2_opt:1,persist:5,hidden:1,might:[3,4],easier:6,them:[3,1],good:3,"return":[1,4,5,6],thei:[3,1,4,6],python:[4,6],auto:[3,1,4,6],initi:4,"break":1,choic:[3,1,4],term:[4,5],name:[3,1,4,6],anyth:5,drop:[3,1,4],hidden_widget:4,separ:1,jsonresponsemixin:5,found:[1,4],unicod:[1,4,6],side:[3,1],mean:[4,5,6],subset:[4,6],selected_choic:1,jsfunctionincontext:[1,6],replac:[3,1,4],realli:[4,5],heavi:[3,1,4,5],meta:1,varibl:6,expect:[3,4,5],extract:6,special:[3,1,4,6],variabl:[4,6],typedchoicefield:4,primari:1,content:[0,2],modelform:1,select2mixin:1,insid:[1,6],select2choicefield:[3,4],contain:[1,4,6],given:[5,6],standard:1,reason:[1,4],base:[1,4,5,6],dictionari:[1,4,5,6],respond_with_except:5,care:[4,6],thrown:4,render_to_respons:5,your:[3,1,4,5],wai:[1,4],where:[5,2],could:4,synchron:6,filter:4,turn:1,enforc:[1,5],place:5,convert_dict_to_js_map:6,onto:3,textinput:1,first:[1,4],notifi:1,obviou:3,arrai:[1,6],number:[3,4,5],placehold:1,restrict:1,alreadi:[3,4,6],prepare_qs_param:4,payload:5,auto_id:4,differ:[3,6],script:[1,6],select2widget:[3,1,4],select2view:[3,1,4,5],attach:1,too:[3,4,6],choos:1,john:4,store:1,heavychoicefield:4,option:[3,1],modelresultjsonmixin:4,specifi:[1,4],part:4,enclos:1,getvaltext:1,practic:6,serv:[3,1,4],provid:[1,4],remov:1,jqueri:3,initselect:1,str:[1,4,5,6],init_opt:1,browser:1,pre:3,sai:3,get_val_txt:4,comput:6,empty_valu:4,autoviewfieldmixin:[4,5,6],queryset:4,ani:[3,1,4,6],packag:3,have:[3,1,4],tabl:0,need:[3,1,4,6],notimplementederror:4,element:[1,6],heavyselect2mixin:1,self:[1,4],client:1,note:[1,4,5],also:[3,4,6,2],termn2:4,take:[4,6],which:[3,1,4,5,6],noth:1,singl:1,sure:[1,4],normal:[3,1],object:[1,4,5,6],clearer:6,most:3,said:3,heavyselect2multiplewidget:[3,1,4],"class":[1,4,5,6],minimuminputlength:1,dom:[1,6],url:[1,4,5],mymodel:1,later:1,request:[3,1,4,5],doe:4,intricaci:1,getter:4,select2multiplewidget:[3,1,4],heavy_data:[1,4,5],usergetvaltextfuncnam:1,show:1,django_select2:[1,4,5,6],text:4,random:[4,5],permiss:5,fine:5,find:4,render_js_script:6,current:[1,5],onli:[3,1,5,6],coerc:4,pretti:4,typedmultiplechoicefield:4,should:[1,4,5,6],dict:[1,4,6],get_field:6,meant:[3,1,4,5],choicemixin:4,get:[3,1,4,5,6],label1:[1,5],nasti:4,cannot:[1,4],render_text:1,requir:[3,1,4,6],stuff:4,integr:3,heavyselect2fieldbas:[],register_field:[1,4,6],term12:4,term11:4,view:[0,1,2,3,4,5,6],respond:[3,1,4,5],set:[1,4,6],datatyp:1,see:[3,4],mandatori:5,result:[1,4,5],arg:[1,4,5,6],fail:4,close:1,statu:5,detect:4,label:[1,4],won:[4,5],response_class:5,"import":3,across:5,attribut:[1,4],kei:[4,6],javascript:[3,1],isol:4,undoubt:3,addit:1,last:5,rtype:[],termx1:4,termx2:4,equal:5,against:4,etc:4,instanc:[4,6],context:[1,4,5,6],logic:1,mani:[3,1],whole:3,point:[1,6],instanti:3,overview:[0,3],dispatch:[4,5],label_from_inst:4,set_placehold:1,respect:1,assum:4,along:1,attrx2:4,attrx1:4,three:1,empti:[1,4],compon:[3,1],json:[1,4,5],valueerror:[1,4],thousand:3,concot:1,get_result:[4,5],attrn1:4,attrn2:4,understand:6,togeth:4,input:1,choicefield:4,those:3,get_opt:1,"case":1,selectmultipl:1,properti:4,act:6,defin:4,"while":[4,6],howev:6,abov:[3,1,4],error:[1,5],convert_to_js_string_arr:6,jsvar:[1,6],mxin:1,helper:3,almost:3,get_url_param:1,henc:3,site:1,worri:3,itself:[1,4],conf:4,incom:4,autoselect2field:[3,4],"__init__":[1,4],httprequest:[4,5],decor:6,termn1:4,suggest:2,make:[1,4,5,6],format:4,same:[1,4,5],complex:3,eventu:4,val2:1,complet:1,http:[4,5],nil:5,again:4,modelselect2field:[3,4],driven:3,rais:[1,4,5],user:[1,4,5],extern:[0,3],respons:[3,1,4,5],chang:5,labl:1,multisepar:1,handel:3,scenario:[3,1],older:3,markup:[3,1],automodelselect2field:[3,4],exampl:[0,1,2,3,4,5],thi:[3,1,4,5,6],convert_context_to_json:5,everyth:5,modelchoiceiter:4,last_name__icontain:4,identifi:1,when:[3,1,4,5],automodelselect2multiplefield:[3,4],has_mor:5,quietmilli:1,coerce_valu:4,render_js_cod:1,cut:6,expos:3,check_all_permiss:5,closeonselect:1,had:5,except:5,modelchoicefield:4,add:1,valid:[4,6],autoheavyselect2multiplewidget:[3,1,4],els:[1,4,5],modul:0,useless:1,applic:[0,1,3],mayb:3,read:[3,1],big:4,runincontexthelp:6,know:6,httprespons:5,recurs:6,data_view:[1,4,5],like:[4,6],specif:3,signal:[4,5],manual:3,html:[3,1,6],server:[3,1,4,5],"boolean":4,necessari:[3,1],either:[1,4],output:[4,5],page:[0,4,5,3],encount:4,revers:1,is_valid_id:6,some:[1,4,6],back:4,hacki:4,librari:[3,1],heavymultiplechoicefield:4,heavymodelselect2choicefield:[3,4],id2:5,subclass:4,heavyselect2choicefield:[3,4],larg:3,jsfunction:[1,6],refer:[0,1,6,2],id_:[1,6],run:[3,1,6],autoheavyselect2mixin:1,each:1,reqeust:[4,5],although:[3,4,5],dct:6,autoresponseview:[4,5,6],about:3,actual:4,unnecessari:6,lifecycl:5,constructor:[1,4],ajax:[3,1,4,5],render_inner_js_cod:1,block:[1,6],own:3,createsearchchoic:1,automat:3,two:3,down:6,data_url:1,wrap:6,search_field:4,myform:1,val:[1,6],support:5,transform:5,submit:1,custom:[1,4],avail:[3,1,4],start:5,includ:[3,1,4,2],suit:[3,4],"function":[3,1,6],validate_valu:4,max_result:4,form:[3,1,4,5],tupl:[1,4],modelselect2multiplefield:[3,4],eas:3,select2multiplechoicefield:[3,4],"true":[1,4,5,6],reset:5,attr:1,possibl:4,"default":[3,4],checkout:[],maximum:4,below:4,http404:5,otherwis:1,similar:1,clear:1,model:[1,4],constant:[5,6],creat:[3,5],"int":[4,5],hardcod:5,exist:[1,4],file:3,heavyselect2multiplechoicefield:[3,4],check:[1,4,5,6],unhideablequerysettyp:4,quot:6,want:[1,4,5],tip:[1,4,5,6],field:[0,1,2,3,4,5,6],other:[1,4,6],bool:[4,6],heavyselect2widget:[3,1,4],immens:5,test:3,you:[3,1,4,5],roll:3,introduc:1,consid:4,text2:5,overri:1,descript:1,variabel:4,obj:4,time:6,convert:[1,5,6],scroll:5},objtypes:{"0":"py:module","1":"py:attribute","2":"py:class","3":"py:method","4":"py:function","5":"py:data"},titles:["All Contents","Widgets","API Reference","Overview","Fields","Views","Util"],objnames:{"0":["py","module","Python module"],"1":["py","attribute","Python attribute"],"2":["py","class","Python class"],"3":["py","method","Python method"],"4":["py","function","Python function"],"5":["py","data","Python data"]},filenames:["index","ref_widgets","reference","overview","ref_fields","ref_views","ref_util"]}) \ No newline at end of file +Search.setIndex({objects:{"":{django_select2:[3,0,1,""]},"django_select2.widgets.Select2Mixin":{get_options:[1,3,1,""],render:[1,3,1,""],init_options:[1,3,1,""],render_select2_options_code:[1,3,1,""],set_placeholder:[1,3,1,""],render_inner_js_code:[1,3,1,""],render_js_code:[1,3,1,""],options:[1,1,1,""],"__init__":[1,3,1,""]},django_select2:{util:[6,0,1,""],widgets:[1,0,1,""],fields:[4,0,1,""],views:[5,0,1,""]},"django_select2.fields.HeavyModelSelect2ChoiceField":{widget:[4,1,1,""]},"django_select2.views":{AutoResponseView:[5,2,1,""],NO_ERR_RESP:[5,5,1,""],Select2View:[5,2,1,""],JSONResponseMixin:[5,2,1,""]},"django_select2.fields.HeavySelect2MultipleChoiceField":{widget:[4,1,1,""]},"django_select2.fields.AutoModelSelect2MultipleField":{widget:[4,1,1,""]},"django_select2.util":{render_js_script:[6,4,1,""],JSVar:[6,2,1,""],convert_py_to_js_data:[6,4,1,""],"synchronized":[6,4,1,""],is_valid_id:[6,4,1,""],convert_to_js_arr:[6,4,1,""],JSFunction:[6,2,1,""],convert_dict_to_js_map:[6,4,1,""],extract_some_key_val:[6,4,1,""],JSFunctionInContext:[6,2,1,""],get_field:[6,4,1,""],register_field:[6,4,1,""],convert_to_js_string_arr:[6,4,1,""]},"django_select2.fields.HeavyMultipleChoiceField":{hidden_widget:[4,1,1,""]},"django_select2.fields.Select2MultipleChoiceField":{widget:[4,1,1,""]},"django_select2.fields.HeavySelect2FieldBaseMixin":{"__init__":[4,3,1,""]},"django_select2.views.JSONResponseMixin":{render_to_response:[5,3,1,""],response_class:[5,1,1,""],convert_context_to_json:[5,3,1,""]},"django_select2.fields.AutoSelect2Field":{widget:[4,1,1,""]},"django_select2.fields.AutoModelSelect2Field":{widget:[4,1,1,""]},"django_select2.widgets":{Select2Mixin:[1,2,1,""],Select2Widget:[1,2,1,""],HeavySelect2Mixin:[1,2,1,""],AutoHeavySelect2Mixin:[1,2,1,""],Select2MultipleWidget:[1,2,1,""],AutoHeavySelect2Widget:[1,2,1,""],AutoHeavySelect2MultipleWidget:[1,2,1,""],HeavySelect2Widget:[1,2,1,""],MultipleSelect2HiddenInput:[1,2,1,""],HeavySelect2MultipleWidget:[1,2,1,""]},"django_select2.views.Select2View":{check_all_permissions:[5,3,1,""],get_results:[5,3,1,""],respond_with_exception:[5,3,1,""]},"django_select2.fields.Select2ChoiceField":{widget:[4,1,1,""]},"django_select2.fields.ModelResultJsonMixin":{get_results:[4,3,1,""],label_from_instance:[4,3,1,""],prepare_qs_params:[4,3,1,""],"__init__":[4,3,1,""]},"django_select2.fields.HeavyModelSelect2MultipleChoiceField":{widget:[4,1,1,""]},"django_select2.fields.ModelSelect2Field":{widget:[4,1,1,""]},"django_select2.fields.AutoViewFieldMixin":{get_results:[4,3,1,""],security_check:[4,3,1,""],"__init__":[4,3,1,""]},"django_select2.widgets.HeavySelect2MultipleWidget":{render_texts_for_value:[1,3,1,""]},"django_select2.fields":{HeavyChoiceField:[4,2,1,""],AutoSelect2Field:[4,2,1,""],Select2MultipleChoiceField:[4,2,1,""],HeavyMultipleChoiceField:[4,2,1,""],HeavyModelSelect2ChoiceField:[4,2,1,""],UnhideableQuerysetType:[4,2,1,""],QuerysetChoiceMixin:[4,2,1,""],ModelResultJsonMixin:[4,2,1,""],Select2ChoiceField:[4,2,1,""],ModelSelect2Field:[4,2,1,""],AutoModelSelect2MultipleField:[4,2,1,""],AutoSelect2MultipleField:[4,2,1,""],ModelSelect2MultipleField:[4,2,1,""],ChoiceMixin:[4,2,1,""],AutoModelSelect2Field:[4,2,1,""],AutoViewFieldMixin:[4,2,1,""],HeavySelect2MultipleChoiceField:[4,2,1,""],HeavySelect2ChoiceField:[4,2,1,""],HeavySelect2FieldBaseMixin:[4,2,1,""],HeavyModelSelect2MultipleChoiceField:[4,2,1,""]},"django_select2.fields.HeavySelect2ChoiceField":{widget:[4,1,1,""]},"django_select2.fields.HeavyChoiceField":{coerce_value:[4,3,1,""],empty_value:[4,1,1,""],get_val_txt:[4,3,1,""],validate_value:[4,3,1,""]},"django_select2.fields.AutoSelect2MultipleField":{widget:[4,1,1,""]},"django_select2.widgets.HeavySelect2Mixin":{render_texts:[1,3,1,""],render_texts_for_value:[1,3,1,""],"__init__":[1,3,1,""]},"django_select2.fields.ModelSelect2MultipleField":{widget:[4,1,1,""]}},terms:{all:[0,1,3,4,5,6],code:[3,1,5,6],forget:4,queri:[3,1,4,5],autoselect2multiplefield:[3,4],per:4,follow:[1,6],search_term:4,heavyselect2choicefield:[3,4],row:5,depend:[0,1,3],sensit:[4,5],send:1,cach:1,scratch:5,selectclass:5,sent:5,"case":1,sourc:[3,1,4,5,6],string:[1,4,6],fals:[1,4,5,6],util:[0,4,6,2],failur:5,relev:2,allowclear:1,level:4,list:[1,4,6],iter:6,item:1,cooki:1,pleas:3,security_check:4,multiplehiddeninput:4,convert_to_js_arr:6,second:1,init_opt:1,pass:[1,4,5],further:3,val1:1,subclass:4,compat:1,index:0,what:6,warap:6,sub:[1,4,5,6],multiplechoicefield:4,abl:[4,5],"while":[4,6],access:[4,5],version:[3,1],"new":[1,5],method:[1,4],widget:[0,1,2,3,4,5],full:4,themselv:3,minimumresultsforsearch:1,gener:[3,1,4,5,6],never:4,here:[3,4,6],otion:1,let:4,testapp:3,process_result:1,sinc:[3,6],valu:[1,4,5,6],box:1,search:[0,1,4,5,3],convers:6,querysetchoicemixin:4,reason:[1,4],fetch:3,reimplement:4,implement:[3,4],extra:1,primit:6,app:3,api:[0,2],marker:6,txt:1,select:[3,1],highli:3,from:[3,1,5,6],would:[3,1,4,5,6],commun:3,regist:[3,1,4,6],first_name__icontain:4,next:5,few:1,call:[3,4,6],recommend:[3,5],dict:[1,4,6],type:[3,1,4,5,6],more:[3,1,4,5,6],attr11:4,attr12:4,peopl:[4,5],relat:3,warn:[1,4,5],flag:6,text1:5,accept:4,actual:4,easiest:3,must:[1,4,5,6],heavymodelselect2multiplechoicefield:[3,4],none:[1,4,5,6],word:3,err:5,convert_context_to_json:5,alia:[4,5],prepar:4,to_field_nam:4,uniqu:4,itself:[1,4],can:[1,4,5,6],response_kwarg:5,purpos:[3,6],select2:[3,1,4],def:1,overrid:[1,4,5],no_err_resp:[3,5],mayb:3,share:[1,4],indic:0,tag:1,login_requir:5,parsabl:4,occur:4,alwai:[4,6],multipl:[1,4,6],secur:4,anoth:6,heavyselect2fieldbasemixin:4,write:[3,1],convert_py_to_js_data:6,multipleselect2hiddeninput:1,instead:[3,1,4,5,6],simpl:[4,6],nasti:4,css:1,map:[1,6],after:6,befor:4,wrong:1,mixin:[1,4,5],oninit:1,data:[1,4,6],practic:6,light:[3,4],your_js_funct:1,element:[1,6],inform:[4,5],allow:1,enter:4,render_select2_options_cod:1,modelmultiplechoicefield:4,help:5,extract_some_key_v:6,becaus:[3,4],lst:6,through:3,help_text:4,still:[1,6],dynam:3,paramet:[1,4,5,6],inner_cod:6,render:[3,1,5,6],window:[1,6],select2_opt:1,persist:5,hidden:1,might:[3,4],easier:6,them:[3,1],good:3,"return":[1,4,5,6],thei:[3,1,4,6],python:[4,6],auto:[3,1,4,6],initi:4,createsearchchoic:1,"break":1,choic:[3,1,4],term:[4,5],name:[3,1,4,6],anyth:5,drop:[3,1,4],hidden_widget:4,separ:1,jsonresponsemixin:5,found:[1,4],unicod:[1,4,6],side:[3,1],mean:[4,5,6],subset:[4,6],selected_choic:1,jsfunctionincontext:[1,6],replac:[3,1,4],render_texts_for_valu:1,heavi:[3,1,4,5],meta:1,varibl:6,expect:[3,4,5],select2multiplechoicefield:[3,4],extract:6,special:[3,1,4,6],variabl:[4,6],typedchoicefield:4,payload:5,content:[0,2],modelform:1,select2mixin:1,insid:[1,6],select2choicefield:[3,4],contain:[1,4,6],given:[5,6],standard:1,autoheavyselect2widget:[3,1,4],base:[1,4,5,6],dictionari:[1,4,5,6],care:[4,6],thrown:4,driven:3,val:[1,6],register_field:[1,4,6],could:4,synchron:6,filter:4,turn:1,enforc:[1,5],place:5,convert_dict_to_js_map:6,myform:1,onto:3,textinput:1,first:[1,4],notifi:1,obviou:3,arrai:[1,6],number:[3,4,5],placehold:1,restrict:1,alreadi:[3,4,6],prepare_qs_param:4,primari:1,auto_id:4,differ:[3,6],script:[1,6],select2widget:[3,1,4],select2view:[3,1,4,5],attach:1,too:[3,4,6],time:6,john:4,store:1,heavychoicefield:4,option:[3,1],modelresultjsonmixin:4,specifi:[1,4],getter:4,enclos:1,getvaltext:1,coax:4,serv:[3,1,4],provid:[1,4],remov:1,jqueri:3,initselect:1,str:[1,4,5,6],design:5,browser:1,pre:3,sai:3,comput:6,empty_valu:4,autoviewfieldmixin:[4,5,6],queryset:4,ani:[3,1,4,6],packag:3,have:[3,1,4],tabl:0,need:[3,1,4,6],notimplementederror:4,django:[3,1,4,5],heavyselect2mixin:1,self:[1,4],note:[1,4,5],also:[3,4,6,2],exampl:[0,1,2,3,4,5],take:[4,6],which:[3,1,4,5,6],noth:1,singl:1,sure:[1,4],normal:[3,1],object:[1,4,5,6],clearer:6,most:3,detect:4,heavyselect2multiplewidget:[3,1,4],"class":[1,4,5,6],minimuminputlength:1,dom:[1,6],url:[1,4,5],mymodel:1,later:1,request:[3,1,4,5],doe:4,part:4,error:[1,5],select2multiplewidget:[3,1,4],heavy_data:[1,4,5],usergetvaltextfuncnam:1,show:1,django_select2:[1,4,5,6],text:4,random:[4,5],permiss:5,fine:5,find:4,render_js_script:6,current:[1,5],onli:[3,1,5,6],coerc:4,pretti:4,typedmultiplechoicefield:4,should:[1,4,5,6],suppos:1,get_field:6,meant:[3,1,4,5],choicemixin:4,get:[3,1,4,5,6],label1:[1,5],label2:[1,5],cannot:[1,4],render_text:1,requir:[3,1,4,6],stuff:4,integr:3,heavyselect2fieldbas:[],where:[5,2],term12:4,term11:4,view:[0,1,2,3,4,5,6],respond:[3,1,4,5],set:[1,4,6],datatyp:1,see:[3,4],mandatori:5,result:[1,4,5],arg:[1,4,5,6],fail:4,close:1,statu:5,said:3,search_field:4,label:[1,4],won:[4,5],response_class:5,"import":3,across:5,attribut:[1,4],kei:[4,6],javascript:[3,1],isol:4,data_view:[1,4,5],undoubt:3,addit:1,last:5,rtype:[],termx1:4,termx2:4,equal:5,against:4,constructor:[1,4],etc:4,instanc:[4,6],context:[1,4,5,6],logic:1,mani:[3,1],whole:3,point:[1,6],instanti:3,overview:[0,3],dispatch:[4,5],label_from_inst:4,modelchoicefield:4,respect:1,assum:4,along:1,attrx2:4,attrx1:4,three:1,empti:[1,4],compon:[3,1],json:[1,4,5],valueerror:[1,4],want:[1,4,5],thousand:3,concot:1,get_result:[4,5],attrn1:4,attrn2:4,understand:6,togeth:4,convert_to_js_string_arr:6,httprequest:[4,5],choicefield:4,those:3,get_opt:1,emploi:1,selectmultipl:1,properti:4,defin:4,invok:6,abov:[3,1,4],as_view:5,howev:6,jsvar:[1,6],mxin:1,helper:3,almost:3,get_url_param:1,henc:3,site:1,worri:3,kwarg:[1,4,5,6],conf:4,incom:4,autoselect2field:[3,4],"__init__":[1,4],termn2:4,decor:6,termn1:4,suggest:2,make:[1,4,5,6],format:4,same:[1,4,5],complex:3,eventu:4,complet:1,http:[4,5],nil:5,unhideablequerysettyp:4,modelselect2field:[3,4],render_to_respons:5,rais:[1,4,5],user:[1,4,5],extern:[0,3],respons:[3,1,4,5],chang:5,labl:1,multisepar:1,els:[1,4,5],scenario:[3,1],older:3,markup:[3,1],automodelselect2field:[3,4],client:1,thi:[3,1,4,5,6],choos:1,everyth:5,modelchoiceiter:4,last_name__icontain:4,identifi:1,tip:[1,4,5,6],automodelselect2multiplefield:[3,4],has_mor:5,quietmilli:1,coerce_valu:4,render_js_cod:1,cut:6,expos:3,check_all_permiss:5,closeonselect:1,had:5,except:5,set_placehold:1,add:1,other:[1,4,6],autoheavyselect2multiplewidget:[3,1,4],input:1,modul:0,useless:1,applic:[0,1,3],intricaci:1,read:[3,1],big:4,runincontexthelp:6,know:6,httprespons:5,recurs:6,respond_with_except:5,like:[4,6],specif:3,signal:[4,5],manual:3,html:[3,1,6],server:[3,1,4,5],"boolean":4,necessari:[3,1],either:[1,4],output:[4,5],page:[0,4,5,3],encount:4,revers:1,is_valid_id:6,some:[1,4,6],back:4,hacki:4,librari:[3,1],heavymultiplechoicefield:4,heavymodelselect2choicefield:[3,4],id2:5,get_val_txt:4,id1:5,larg:3,refer:[0,1,6,2],id_:[1,6],run:[3,1,6],autoheavyselect2mixin:1,each:1,reqeust:[4,5],although:[3,4,5],dct:6,autoresponseview:[4,5,6],about:3,central:[3,1,4,5],unnecessari:6,lifecycl:5,act:6,ajax:[3,1,4,5],render_inner_js_cod:1,block:[1,6],own:3,val2:1,automat:3,two:3,down:6,data_url:1,wrap:6,your:[3,1,4,5],select2widgetnam:1,wai:[1,4],support:5,transform:5,submit:1,custom:[1,4],avail:[3,1,4],start:5,includ:[3,1,4,2],suit:[3,4],"function":[3,1,6],validate_valu:4,max_result:4,form:[3,1,4,5],tupl:[1,4],modelselect2multiplefield:[3,4],eas:3,realli:[4,5],"true":[1,4,5,6],reset:5,attr:1,possibl:4,"default":[3,4],checkout:[],maximum:4,below:4,http404:5,otherwis:1,similar:1,clear:1,model:[1,4],constant:[5,6],creat:[3,5],"int":[4,5],hardcod:5,exist:[1,4],file:3,heavyselect2multiplechoicefield:[3,4],check:[1,4,5,6],again:4,quot:6,handel:3,when:[3,1,4,5],field:[0,1,2,3,4,5,6],valid:[4,6],bool:[4,6],heavyselect2widget:[3,1,4],immens:5,test:3,you:[3,1,4,5],roll:3,introduc:1,consid:4,text2:5,overri:1,descript:1,variabel:4,obj:4,jsfunction:[1,6],convert:[1,5,6],scroll:5},objtypes:{"0":"py:module","1":"py:attribute","2":"py:class","3":"py:method","4":"py:function","5":"py:data"},titles:["All Contents","Widgets","API Reference","Overview","Fields","Views","Util"],objnames:{"0":["py","module","Python module"],"1":["py","attribute","Python attribute"],"2":["py","class","Python class"],"3":["py","method","Python method"],"4":["py","function","Python function"],"5":["py","data","Python data"]},filenames:["index","ref_widgets","reference","overview","ref_fields","ref_views","ref_util"]}) \ No newline at end of file diff --git a/docs/overview.rst b/docs/overview.rst index cad309e..de6086a 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -1,3 +1,4 @@ +======== Overview ======== diff --git a/docs/reference.rst b/docs/reference.rst index 404b3d1..2c376d1 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -1,3 +1,4 @@ +============= API Reference =============