Small changes in preparation for more adapters
This commit is contained in:
parent
d57f8b2203
commit
3e05e32eda
29
dist/js/select2.amd.full.js
vendored
29
dist/js/select2.amd.full.js
vendored
@ -245,10 +245,17 @@ define('select2/data/select',[
|
||||
};
|
||||
|
||||
SelectAdapter.prototype.item = function ($option) {
|
||||
var data = {
|
||||
id: $option.val(),
|
||||
text: $option.html()
|
||||
};
|
||||
var data = $option.data("data");
|
||||
|
||||
// If the data has already be generated, use it
|
||||
if (data == null) {
|
||||
data = {
|
||||
id: $option.val(),
|
||||
text: $option.html()
|
||||
};
|
||||
|
||||
$option.data("data", data);
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
@ -356,7 +363,7 @@ define('select2/results',[
|
||||
self.setClasses();
|
||||
})
|
||||
|
||||
this.$results.on("click", ".option", function (evt) {
|
||||
this.$results.on("mouseup", ".option", function (evt) {
|
||||
var $this = $(this);
|
||||
|
||||
var data = $this.data("data");
|
||||
@ -441,7 +448,7 @@ define('select2/selection/single',[
|
||||
SingleSelection.prototype.bind = function (container, $container) {
|
||||
var self = this;
|
||||
|
||||
this.$selection.on('click', function (evt) {
|
||||
this.$selection.on('mousedown', function (evt) {
|
||||
self.trigger("toggle", {
|
||||
originalEvent: evt
|
||||
});
|
||||
@ -561,7 +568,7 @@ define('select2/options',[
|
||||
function Options (options) {
|
||||
this.options = options;
|
||||
|
||||
this.dataAdapter = SelectData;
|
||||
this.dataAdapter = options.dataAdapter || SelectData;
|
||||
this.resultsAdapter = ResultsList;
|
||||
this.dropdownAdapter = options.dropdownAdapter || Dropdown;
|
||||
this.selectionAdapter = options.selectionAdapter;
|
||||
@ -660,12 +667,18 @@ define('select2/core',[
|
||||
// Set the initial state
|
||||
|
||||
this.data.current(function (initialData) {
|
||||
self.selection.update(initialData);
|
||||
self.trigger("selection:update", {
|
||||
data: initialData
|
||||
});
|
||||
});
|
||||
|
||||
this.data.query({}, function (data) {
|
||||
self.results.trigger("results:all", data);
|
||||
});
|
||||
|
||||
// Hide the original select
|
||||
|
||||
$element.hide();
|
||||
};
|
||||
|
||||
Utils.Extend(Select2, Utils.Observable);
|
||||
|
29
dist/js/select2.amd.js
vendored
29
dist/js/select2.amd.js
vendored
@ -245,10 +245,17 @@ define('select2/data/select',[
|
||||
};
|
||||
|
||||
SelectAdapter.prototype.item = function ($option) {
|
||||
var data = {
|
||||
id: $option.val(),
|
||||
text: $option.html()
|
||||
};
|
||||
var data = $option.data("data");
|
||||
|
||||
// If the data has already be generated, use it
|
||||
if (data == null) {
|
||||
data = {
|
||||
id: $option.val(),
|
||||
text: $option.html()
|
||||
};
|
||||
|
||||
$option.data("data", data);
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
@ -356,7 +363,7 @@ define('select2/results',[
|
||||
self.setClasses();
|
||||
})
|
||||
|
||||
this.$results.on("click", ".option", function (evt) {
|
||||
this.$results.on("mouseup", ".option", function (evt) {
|
||||
var $this = $(this);
|
||||
|
||||
var data = $this.data("data");
|
||||
@ -441,7 +448,7 @@ define('select2/selection/single',[
|
||||
SingleSelection.prototype.bind = function (container, $container) {
|
||||
var self = this;
|
||||
|
||||
this.$selection.on('click', function (evt) {
|
||||
this.$selection.on('mousedown', function (evt) {
|
||||
self.trigger("toggle", {
|
||||
originalEvent: evt
|
||||
});
|
||||
@ -561,7 +568,7 @@ define('select2/options',[
|
||||
function Options (options) {
|
||||
this.options = options;
|
||||
|
||||
this.dataAdapter = SelectData;
|
||||
this.dataAdapter = options.dataAdapter || SelectData;
|
||||
this.resultsAdapter = ResultsList;
|
||||
this.dropdownAdapter = options.dropdownAdapter || Dropdown;
|
||||
this.selectionAdapter = options.selectionAdapter;
|
||||
@ -660,12 +667,18 @@ define('select2/core',[
|
||||
// Set the initial state
|
||||
|
||||
this.data.current(function (initialData) {
|
||||
self.selection.update(initialData);
|
||||
self.trigger("selection:update", {
|
||||
data: initialData
|
||||
});
|
||||
});
|
||||
|
||||
this.data.query({}, function (data) {
|
||||
self.results.trigger("results:all", data);
|
||||
});
|
||||
|
||||
// Hide the original select
|
||||
|
||||
$element.hide();
|
||||
};
|
||||
|
||||
Utils.Extend(Select2, Utils.Observable);
|
||||
|
29
dist/js/select2.full.js
vendored
29
dist/js/select2.full.js
vendored
@ -9782,10 +9782,17 @@ define('select2/data/select',[
|
||||
};
|
||||
|
||||
SelectAdapter.prototype.item = function ($option) {
|
||||
var data = {
|
||||
id: $option.val(),
|
||||
text: $option.html()
|
||||
};
|
||||
var data = $option.data("data");
|
||||
|
||||
// If the data has already be generated, use it
|
||||
if (data == null) {
|
||||
data = {
|
||||
id: $option.val(),
|
||||
text: $option.html()
|
||||
};
|
||||
|
||||
$option.data("data", data);
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
@ -9893,7 +9900,7 @@ define('select2/results',[
|
||||
self.setClasses();
|
||||
})
|
||||
|
||||
this.$results.on("click", ".option", function (evt) {
|
||||
this.$results.on("mouseup", ".option", function (evt) {
|
||||
var $this = $(this);
|
||||
|
||||
var data = $this.data("data");
|
||||
@ -9978,7 +9985,7 @@ define('select2/selection/single',[
|
||||
SingleSelection.prototype.bind = function (container, $container) {
|
||||
var self = this;
|
||||
|
||||
this.$selection.on('click', function (evt) {
|
||||
this.$selection.on('mousedown', function (evt) {
|
||||
self.trigger("toggle", {
|
||||
originalEvent: evt
|
||||
});
|
||||
@ -10098,7 +10105,7 @@ define('select2/options',[
|
||||
function Options (options) {
|
||||
this.options = options;
|
||||
|
||||
this.dataAdapter = SelectData;
|
||||
this.dataAdapter = options.dataAdapter || SelectData;
|
||||
this.resultsAdapter = ResultsList;
|
||||
this.dropdownAdapter = options.dropdownAdapter || Dropdown;
|
||||
this.selectionAdapter = options.selectionAdapter;
|
||||
@ -10197,12 +10204,18 @@ define('select2/core',[
|
||||
// Set the initial state
|
||||
|
||||
this.data.current(function (initialData) {
|
||||
self.selection.update(initialData);
|
||||
self.trigger("selection:update", {
|
||||
data: initialData
|
||||
});
|
||||
});
|
||||
|
||||
this.data.query({}, function (data) {
|
||||
self.results.trigger("results:all", data);
|
||||
});
|
||||
|
||||
// Hide the original select
|
||||
|
||||
$element.hide();
|
||||
};
|
||||
|
||||
Utils.Extend(Select2, Utils.Observable);
|
||||
|
29
dist/js/select2.js
vendored
29
dist/js/select2.js
vendored
@ -673,10 +673,17 @@ define('select2/data/select',[
|
||||
};
|
||||
|
||||
SelectAdapter.prototype.item = function ($option) {
|
||||
var data = {
|
||||
id: $option.val(),
|
||||
text: $option.html()
|
||||
};
|
||||
var data = $option.data("data");
|
||||
|
||||
// If the data has already be generated, use it
|
||||
if (data == null) {
|
||||
data = {
|
||||
id: $option.val(),
|
||||
text: $option.html()
|
||||
};
|
||||
|
||||
$option.data("data", data);
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
@ -784,7 +791,7 @@ define('select2/results',[
|
||||
self.setClasses();
|
||||
})
|
||||
|
||||
this.$results.on("click", ".option", function (evt) {
|
||||
this.$results.on("mouseup", ".option", function (evt) {
|
||||
var $this = $(this);
|
||||
|
||||
var data = $this.data("data");
|
||||
@ -869,7 +876,7 @@ define('select2/selection/single',[
|
||||
SingleSelection.prototype.bind = function (container, $container) {
|
||||
var self = this;
|
||||
|
||||
this.$selection.on('click', function (evt) {
|
||||
this.$selection.on('mousedown', function (evt) {
|
||||
self.trigger("toggle", {
|
||||
originalEvent: evt
|
||||
});
|
||||
@ -989,7 +996,7 @@ define('select2/options',[
|
||||
function Options (options) {
|
||||
this.options = options;
|
||||
|
||||
this.dataAdapter = SelectData;
|
||||
this.dataAdapter = options.dataAdapter || SelectData;
|
||||
this.resultsAdapter = ResultsList;
|
||||
this.dropdownAdapter = options.dropdownAdapter || Dropdown;
|
||||
this.selectionAdapter = options.selectionAdapter;
|
||||
@ -1088,12 +1095,18 @@ define('select2/core',[
|
||||
// Set the initial state
|
||||
|
||||
this.data.current(function (initialData) {
|
||||
self.selection.update(initialData);
|
||||
self.trigger("selection:update", {
|
||||
data: initialData
|
||||
});
|
||||
});
|
||||
|
||||
this.data.query({}, function (data) {
|
||||
self.results.trigger("results:all", data);
|
||||
});
|
||||
|
||||
// Hide the original select
|
||||
|
||||
$element.hide();
|
||||
};
|
||||
|
||||
Utils.Extend(Select2, Utils.Observable);
|
||||
|
8
src/js/select2/core.js
vendored
8
src/js/select2/core.js
vendored
@ -80,12 +80,18 @@ define([
|
||||
// Set the initial state
|
||||
|
||||
this.data.current(function (initialData) {
|
||||
self.selection.update(initialData);
|
||||
self.trigger("selection:update", {
|
||||
data: initialData
|
||||
});
|
||||
});
|
||||
|
||||
this.data.query({}, function (data) {
|
||||
self.results.trigger("results:all", data);
|
||||
});
|
||||
|
||||
// Hide the original select
|
||||
|
||||
$element.hide();
|
||||
};
|
||||
|
||||
Utils.Extend(Select2, Utils.Observable);
|
||||
|
15
src/js/select2/data/select.js
vendored
15
src/js/select2/data/select.js
vendored
@ -107,10 +107,17 @@ define([
|
||||
};
|
||||
|
||||
SelectAdapter.prototype.item = function ($option) {
|
||||
var data = {
|
||||
id: $option.val(),
|
||||
text: $option.html()
|
||||
};
|
||||
var data = $option.data("data");
|
||||
|
||||
// If the data has already be generated, use it
|
||||
if (data == null) {
|
||||
data = {
|
||||
id: $option.val(),
|
||||
text: $option.html()
|
||||
};
|
||||
|
||||
$option.data("data", data);
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
|
2
src/js/select2/options.js
vendored
2
src/js/select2/options.js
vendored
@ -9,7 +9,7 @@ define([
|
||||
function Options (options) {
|
||||
this.options = options;
|
||||
|
||||
this.dataAdapter = SelectData;
|
||||
this.dataAdapter = options.dataAdapter || SelectData;
|
||||
this.resultsAdapter = ResultsList;
|
||||
this.dropdownAdapter = options.dropdownAdapter || Dropdown;
|
||||
this.selectionAdapter = options.selectionAdapter;
|
||||
|
2
src/js/select2/results.js
vendored
2
src/js/select2/results.js
vendored
@ -86,7 +86,7 @@ define([
|
||||
self.setClasses();
|
||||
})
|
||||
|
||||
this.$results.on("click", ".option", function (evt) {
|
||||
this.$results.on("mouseup", ".option", function (evt) {
|
||||
var $this = $(this);
|
||||
|
||||
var data = $this.data("data");
|
||||
|
2
src/js/select2/selection/single.js
vendored
2
src/js/select2/selection/single.js
vendored
@ -25,7 +25,7 @@ define([
|
||||
SingleSelection.prototype.bind = function (container, $container) {
|
||||
var self = this;
|
||||
|
||||
this.$selection.on('click', function (evt) {
|
||||
this.$selection.on('mousedown', function (evt) {
|
||||
self.trigger("toggle", {
|
||||
originalEvent: evt
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user