1
0
mirror of synced 2024-11-25 14:26:03 +03:00

Undo rebase indentation changes.

This commit is contained in:
Justin DuJardin 2012-03-29 13:51:48 -07:00
parent de51a5dbdd
commit 576607c46f

View File

@ -301,36 +301,36 @@
} else { } else {
if (!("query" in opts)) { if (!("query" in opts)) {
if ("ajax" in opts) { if ("ajax" in opts) {
opts.query = (function () { opts.query = (function () {
var timeout, // current scheduled but not yet executed request var timeout, // current scheduled but not yet executed request
requestSequence = 0, // sequence used to drop out-of-order responses requestSequence = 0, // sequence used to drop out-of-order responses
quietMillis = opts.ajax.quietMillis || 100; quietMillis = opts.ajax.quietMillis || 100;
return function (query) { return function (query) {
window.clearTimeout(timeout); window.clearTimeout(timeout);
timeout = window.setTimeout(function () { timeout = window.setTimeout(function () {
requestSequence += 1; // increment the sequence requestSequence += 1; // increment the sequence
var requestNumber = requestSequence, // this request's sequence number var requestNumber = requestSequence, // this request's sequence number
options = opts.ajax, // ajax parameters options = opts.ajax, // ajax parameters
data = options.data; // ajax data function data = options.data; // ajax data function
data = data.call(this, query.term, query.page); data = data.call(this, query.term, query.page);
$.ajax({ $.ajax({
url: options.url, url: options.url,
dataType: options.dataType, dataType: options.dataType,
data: data data: data
}).success( }).success(
function (data) { function (data) {
if (requestNumber < requestSequence) { if (requestNumber < requestSequence) {
return; return;
}
query.callback(options.results(data, query.page));
} }
query.callback(options.results(data, query.page)); );
} }, quietMillis);
); };
}, quietMillis); }());
};
}());
} else if ("data" in opts) { } else if ("data" in opts) {
opts.query = (function () { opts.query = (function () {
var data = opts.data, // data elements var data = opts.data, // data elements
@ -341,23 +341,23 @@
// if text is not a function we assume it to be a key name // if text is not a function we assume it to be a key name
if (!$.isFunction(text)) text = function (item) { return item[data.text]; }; if (!$.isFunction(text)) text = function (item) { return item[data.text]; };
data = data.results; data = data.results;
} }
return function (query) { return function (query) {
var t = query.term.toUpperCase(), filtered = {}; var t = query.term.toUpperCase(), filtered = {};
if (t === "") { if (t === "") {
query.callback({results: data}); query.callback({results: data});
return; return;
} }
filtered.result = $(data) filtered.result = $(data)
.filter(function () {return text(this).toUpperCase().indexOf(t) >= 0;}) .filter(function () {return text(this).toUpperCase().indexOf(t) >= 0;})
.get(); .get();
query.callback(filtered); query.callback(filtered);
}; };
}()); }());
}
} }
} }
}
if (typeof(opts.query) !== "function") { if (typeof(opts.query) !== "function") {
throw "query function not defined for Select2 " + opts.element.attr("id"); throw "query function not defined for Select2 " + opts.element.attr("id");
} }
@ -391,7 +391,7 @@
this.dropdown.hide(); this.dropdown.hide();
this.container.removeClass("select2-dropdown-open"); this.container.removeClass("select2-dropdown-open");
this.results.empty(); this.results.empty();
this.clearSearch(); this.clearSearch();
}; };
@ -808,9 +808,9 @@
this.select this.select
.val(val) .val(val)
.find(":selected").each(function () { .find(":selected").each(function () {
data = {id: $(this).attr("value"), text: $(this).text()}; data = {id: $(this).attr("value"), text: $(this).text()};
return false; return false;
}); });
this.updateSelection(data); this.updateSelection(data);
} else { } else {
// val is an object // val is an object