Lines Matching defs:element

26             * use it carefully, as it overrides jQuery context of element on each iteration
108 function reinsertElement(element) {
111 element.before(placeholder);
112 placeholder.before(element);
180 function getSideBorderPadding(element) {
181 return element.outerWidth(false) - element.width();
184 function installKeyUpChangeEvent(element) {
186 element.on("keydown", function () {
187 if ($.data(element, key) === undefined) {
188 $.data(element, key, element.val());
191 element.on("keyup", function () {
192 var val= $.data(element, key);
193 if (val !== undefined && element.val() !== val) {
194 $.removeData(element, key);
195 element.trigger("keyup-change");
211 function installFilteredMouseMove(element) {
212 element.on("mousemove", function (e) {
255 function installDebouncedScroll(threshold, element) {
256 var notify = debounce(threshold, function (e) { element.trigger("scroll-debounced", e);});
257 element.on("scroll", function (e) {
258 if (indexOf(e.target, element.get()) >= 0) notify(e);
478 * key can either be a String in which case it is expected that each element in the 'data' array has a key with the
679 if (opts.element.data("select2") !== undefined &&
680 opts.element.data("select2") !== null) {
681 opts.element.data("select2").destroy();
693 this.containerId="s2id_"+(opts.element.attr("id") || "autogen"+nextUid()).replace(/([;&,\-\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1');
698 this.body = thunk(function() { return opts.element.closest("body"); });
700 syncCssClasses(this.container, this.opts.element, this.opts.adaptContainerCssClass);
702 this.container.attr("style", opts.element.attr("style"));
706 this.elementTabIndex = this.opts.element.attr("tabindex");
708 // swap container for the element
709 this.opts.element
719 syncCssClasses(this.dropdown, this.opts.element, this.opts.adaptDropdownCssClass);
785 // initialize selection based on the current value of the source element
788 // if the user has provided a function that can set selection based on the value of the source element
789 // we monitor the change event on the element and trigger it, allowing for two way synchronization
797 var disabled = opts.element.prop("disabled");
801 var readonly = opts.element.prop("readonly");
808 this.autofocus = opts.element.prop("autofocus");
809 opts.element.prop("autofocus", false);
817 var element=this.opts.element, select2 = element.data("select2");
827 element
833 element.attr({tabindex: this.elementTabIndex});
835 element.removeAttr("tabindex");
837 element.show();
842 optionToData: function(element) {
843 if (element.is("option")) {
845 id:element.prop("value"),
846 text:element.text(),
847 element: element.get(),
848 css: element.attr("class"),
849 disabled: element.prop("disabled"),
850 locked: equal(element.attr("locked"), "locked") || equal(element.data("locked"), true)
852 } else if (element.is("optgroup")) {
854 text:element.attr("label"),
856 element: element.get(),
857 css: element.attr("class")
864 var element, select, idKey, ajaxUrl, self = this;
866 element = opts.element;
868 if (element.get(0).tagName.toLowerCase() === "select") {
869 this.select = select = opts.element;
873 // these options are not allowed when attached to a select because they are picked up off the element itself
876 throw new Error("Option '" + this + "' is not allowed for Select2 when attached to a <select> element.");
945 if ($.isArray(opts.element.data("select2Tags"))) {
947 throw "tags specified as both an attribute 'data-select2-tags' and in options of Select2 " + opts.element.attr("id");
949 opts.tags=opts.element.data("select2Tags");
958 process=function(element, collection) {
960 if (element.is("option")) {
961 if (query.matcher(term, element.text(), element)) {
962 collection.push(self.optionToData(element));
964 } else if (element.is("optgroup")) {
965 group=self.optionToData(element);
966 element.children().each2(function(i, elm) { process(elm, group.children); });
973 children=element.children();
993 ajaxUrl = opts.element.data("ajax-url");
997 opts.query = ajax.call(opts.element, opts.ajax);
1006 opts.initSelection = function (element, callback) {
1008 $(splitVal(element.val(), opts.separator)).each(function () {
1023 throw "query function not defined for Select2 " + opts.element.attr("id");
1040 * Monitor the original element for changes and update select2 accordingly
1044 var el = this.opts.element, sync, observer;
1047 if (this.opts.element.data("select2-change-triggered") !== true) {
1063 syncCssClasses(this.container, this.opts.element, this.opts.adaptContainerCssClass);
1066 syncCssClasses(this.dropdown, this.opts.element, this.opts.adaptDropdownCssClass);
1093 this.opts.element.trigger(evt);
1098 * Triggers the change event on the source element
1106 this.opts.element.data("select2-change-triggered", true);
1107 this.opts.element.trigger(details);
1108 this.opts.element.data("select2-change-triggered", false);
1112 this.opts.element.click();
1117 this.opts.element.blur();
1146 this.opts.element.prop("disabled", !enabled);
1161 this.opts.element.prop("readonly", enabled);
1284 this.opts.element.trigger(event);
1299 * the dropdown is already open, or if the 'open' event listener on the element called preventDefault().
1407 this.opts.element.trigger($.Event("select2-close"));
1440 // if the first element is highlighted scroll all the way to the top,
1468 // make sure the top of the element is visible
1521 this.opts.element.trigger({ type: "select2-highlight", val: this.id(data), choice: data });
1558 below, // pixels the element is below the scroll fold, below==0 is when the element is starting to be visible
1570 element: this.opts.element,
1593 this.opts.element.trigger({ type: "select2-loaded", items: data });
1694 element: opts.element,
1745 this.opts.element.trigger({ type: "select2-loaded", items: data });
1794 return this.opts.element.attr("placeholder") ||
1795 this.opts.element.attr("data-placeholder") || // jquery 1.4 compat
1796 this.opts.element.data("placeholder") ||
1817 * Get the desired width for the container element. This is
1819 * the inline 'style' on the original element, and finally
1820 * falls back to the jQuery calculated element width.
1829 } else if (this.opts.width === "element"){
1830 return this.opts.element.outerWidth(false) === 0 ? 'auto' : this.opts.element.outerWidth(false) + 'px';
1832 // check if there is inline style on the element that contains width
1833 style = this.opts.element.attr('style');
1847 style = this.opts.element.css('width');
1850 // finally, fallback on the calculated width of the element
1851 return (this.opts.element.outerWidth(false) === 0 ? 'auto' : this.opts.element.outerWidth(false) + 'px');
1942 this.opts.element.trigger($.Event("select2-open"));
1987 .attr('for', this.opts.element.attr("id"));
2016 // rewrite labels from original element to focusser
2019 elementLabel = $("label[for='" + this.opts.element.attr("id") + "']");
2025 // Ensure the original element retains an accessible name
2026 var originalTitle = this.opts.element.attr("title");
2027 this.opts.element.attr("title", (originalTitle || elementLabel.text()));
2031 // write label for search field using the label from the focusser element
2133 this.opts.element.trigger($.Event("select2-focus"));
2153 this.opts.element.trigger($.Event("select2-focus"));
2159 this.opts.element.trigger($.Event("select2-blur"));
2164 this.opts.element.trigger($.Event("select2-focus"));
2170 this.opts.element.addClass("select2-offscreen");
2180 this.opts.element.trigger(evt);
2185 this.opts.element.val(placeholderOption ? placeholderOption.val() : "");
2191 this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
2198 * Sets selection based on source element's value
2209 this.opts.initSelection.call(null, this.opts.element, function(selected){
2224 || (this.opts.element.val() === "")
2225 || (this.opts.element.val() === undefined)
2226 || (this.opts.element.val() === null);
2234 if (opts.element.get(0).tagName.toLowerCase() === "select") {
2236 opts.initSelection = function (element, callback) {
2237 var selected = element.find("option").filter(function() { return this.selected && !this.disabled });
2243 opts.initSelection = opts.initSelection || function (element, callback) {
2244 var id = element.val();
2298 // find the selected element in the result list
2301 if (equal(self.id(elm.data("select2-data")), self.opts.element.val())) {
2343 var old = this.opts.element.val(),
2346 this.opts.element.val(this.id(data));
2349 this.opts.element.trigger({ type: "select2-selected", val: this.id(data), choice: data });
2398 return this.opts.element.val();
2428 this.opts.element.val(val);
2429 this.opts.initSelection(this.opts.element, function(data){
2430 self.opts.element.val(!data ? "" : self.id(data));
2463 this.opts.element.val(!value ? "" : this.id(value));
2500 if (opts.element.get(0).tagName.toLowerCase() === "select") {
2502 opts.initSelection = function (element, callback) {
2506 element.find("option").filter(function() { return this.selected && !this.disabled }).each2(function (i, elm) {
2513 opts.initSelection = opts.initSelection || function (element, callback) {
2514 var ids = splitVal(element.val(), opts.separator);
2559 this.opts.element.trigger("choice-deselected", selected);
2565 this.opts.element.trigger("choice-selected", choice);
2573 .attr('for', this.opts.element.attr("id"));
2592 // rewrite labels from original element to focusser
2596 .text($("label[for='" + this.opts.element.attr("id") + "']").text())
2718 this.opts.element.trigger($.Event("select2-blur"));
2730 this.opts.element.trigger($.Event("select2-focus"));
2740 this.opts.element.trigger($.Event("select2-focus"));
2748 this.opts.element.addClass("select2-offscreen");
2764 if (this.opts.element.val() === "" && this.opts.element.text() === "") {
2770 if (this.select || this.opts.element.val() !== "") {
2772 this.opts.initSelection.call(null, this.opts.element, function(data){
2825 this.opts.element.trigger($.Event("select2-open"));
2885 this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data });
2922 // since its not possible to select an element that has already been
2923 // added we do not need to check if this is a new element before firing change
3002 // and invoked on an element already removed
3009 this.opts.element.trigger(evt);
3023 this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
3109 val = this.opts.element.val();
3125 this.opts.element.val(unique.length === 0 ? "" : unique.join(this.opts.separator));
3165 this.opts.element.val("");
3187 this.opts.initSelection(this.opts.element, function(data){
3268 opts.element = $(this);
3270 if (opts.element.get(0).tagName.toLowerCase() === "select") {
3271 multiple = opts.element.prop("multiple");