|
@@ -150,6 +150,25 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ $(window).bind("resize", function(e) {
|
|
|
|
+ var dropdown=$("#select2-drop");
|
|
|
|
+ if (dropdown.length>0) {
|
|
|
|
+ // there is an open dropdown
|
|
|
|
+
|
|
|
|
+ // adjust dropdown positioning so it sizes with the content
|
|
|
|
+ dropdown.data("select2").positionDropdown();
|
|
|
|
+ }
|
|
|
|
+ }).delegate("*", "scroll", function(e) {
|
|
|
|
+ var dropdown=$("#select2-drop");
|
|
|
|
+ if (dropdown.length>0) {
|
|
|
|
+ // there is an open dropdown
|
|
|
|
+
|
|
|
|
+ // adjust dropdown positioning so it scrolls with the content
|
|
|
|
+ dropdown.data("select2").positionDropdown();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
$document.bind("mousemove", function (e) {
|
|
$document.bind("mousemove", function (e) {
|
|
lastMousePosition = {x: e.pageX, y: e.pageY};
|
|
lastMousePosition = {x: e.pageX, y: e.pageY};
|
|
});
|
|
});
|
|
@@ -236,6 +255,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
textTransform: style.textTransform,
|
|
textTransform: style.textTransform,
|
|
whiteSpace: "nowrap"
|
|
whiteSpace: "nowrap"
|
|
});
|
|
});
|
|
|
|
+ sizer.attr("class","select2-sizer");
|
|
$("body").append(sizer);
|
|
$("body").append(sizer);
|
|
}
|
|
}
|
|
sizer.text(e.val());
|
|
sizer.text(e.val());
|
|
@@ -966,31 +986,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
*/
|
|
*/
|
|
// abstract
|
|
// abstract
|
|
opening: function() {
|
|
opening: function() {
|
|
- var cid = this.containerId, selector = this.containerSelector,
|
|
|
|
- scroll = "scroll." + cid, resize = "resize." + cid;
|
|
|
|
-
|
|
|
|
- this.container.parents().each(function() {
|
|
|
|
- $(this).bind(scroll, function() {
|
|
|
|
- var s2 = $(selector);
|
|
|
|
- if (s2.length == 0) {
|
|
|
|
- $(this).unbind(scroll);
|
|
|
|
- }
|
|
|
|
- s2.select2("close");
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- window.setTimeout(function() {
|
|
|
|
- // this is done inside a timeout because IE will sometimes fire a resize event while opening
|
|
|
|
- // the dropdown and that causes this handler to immediately close it. this way the dropdown
|
|
|
|
- // has a chance to fully open before we start listening to resize events
|
|
|
|
- $(window).bind(resize, function() {
|
|
|
|
- var s2 = $(selector);
|
|
|
|
- if (s2.length == 0) {
|
|
|
|
- $(window).unbind(resize);
|
|
|
|
- }
|
|
|
|
- s2.select2("close");
|
|
|
|
- })
|
|
|
|
- }, 10);
|
|
|
|
|
|
+ var cid = this.containerId, selector = this.containerSelector;
|
|
|
|
|
|
this.clearDropdownAlignmentPreference();
|
|
this.clearDropdownAlignmentPreference();
|
|
|
|
|
|
@@ -1004,13 +1000,16 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
this.dropdown.detach().appendTo(this.body());
|
|
this.dropdown.detach().appendTo(this.body());
|
|
}
|
|
}
|
|
|
|
|
|
- this.dropdown.show();
|
|
|
|
|
|
+ // move the global id to the correct dropdown
|
|
|
|
+ $("#select2-drop").removeAttr("id");
|
|
|
|
+ this.dropdown.attr("id", "select2-drop");
|
|
|
|
|
|
|
|
+ // show the elements
|
|
|
|
+ this.dropdown.show();
|
|
this.positionDropdown();
|
|
this.positionDropdown();
|
|
- this.dropdown.addClass("select2-drop-active");
|
|
|
|
|
|
|
|
|
|
+ this.dropdown.addClass("select2-drop-active");
|
|
this.ensureHighlightVisible();
|
|
this.ensureHighlightVisible();
|
|
-
|
|
|
|
this.focusSearch();
|
|
this.focusSearch();
|
|
},
|
|
},
|
|
|
|
|
|
@@ -1020,13 +1019,9 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
|
|
|
|
var self = this;
|
|
var self = this;
|
|
|
|
|
|
- this.container.parents().each(function() {
|
|
|
|
- $(this).unbind("scroll." + self.containerId);
|
|
|
|
- });
|
|
|
|
- $(window).unbind("resize." + this.containerId);
|
|
|
|
-
|
|
|
|
this.clearDropdownAlignmentPreference();
|
|
this.clearDropdownAlignmentPreference();
|
|
|
|
|
|
|
|
+ this.dropdown.removeAttr("id"); // only the active dropdown has the select2-drop id
|
|
this.dropdown.hide();
|
|
this.dropdown.hide();
|
|
this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active");
|
|
this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active");
|
|
this.results.empty();
|
|
this.results.empty();
|