瀏覽代碼

Merge remote-tracking branch 'upstream/master'

Alan Ho 13 年之前
父節點
當前提交
0d29fff1dd
共有 3 個文件被更改,包括 26 次插入3 次删除
  1. 8 0
      README.md
  2. 10 0
      select2.css
  3. 8 3
      select2.js

+ 8 - 0
README.md

@@ -19,6 +19,14 @@ result set allowing for the 'infinite scrolling' of results.
 * Ability to add results on the fly: Select2 provides the ability to add results from the search term entered by the user, which allows it to be used for
 tagging.
 
+Browser Compatibility
+--------------------
+* IE 8+ (7 mostly works except for [issue with z-index](https://github.com/ivaynberg/select2/issues/37))
+* Chrome 8+
+* Firefox 3.5+
+* Safari 3+
+* Opera 10.6+
+
 Bug tracker
 -----------
 

+ 10 - 0
select2.css

@@ -144,6 +144,12 @@ Version: @@ver@@ Timestamp: @@timestamp@@
   padding-right: 4px;
 }
 
+.select2-container .select2-search-hidden {
+  display: block;
+  position: absolute;
+  left: -10000px;
+}
+
 .select2-container .select2-search input {
     background: #fff url('select2.png') no-repeat 100% -22px;
     background: url('select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
@@ -322,6 +328,10 @@ disabled look for already selected choices in the results dropdown
     margin-top:0;
 }
 
+.select2-container-multi .select2-choices {
+    min-height: 26px;
+}
+
 .select2-container-multi.select2-container-active .select2-choices {
     -webkit-box-shadow: 0 0 5px rgba(0,0,0,.3);
     -moz-box-shadow   : 0 0 5px rgba(0,0,0,.3);

+ 8 - 3
select2.js

@@ -317,7 +317,7 @@
      * blurs any Select2 container that has focus when an element outside them was clicked or received focus
      */
     $(document).ready(function () {
-        $(document).delegate("*", "mousedown focusin", function (e) {
+        $(document).delegate("*", "mousedown focusin touchend", function (e) {
             var target = $(e.target).closest("div.select2-container").get(0);
             $(document).find("div.select2-container-active").each(function () {
                 if (this !== target) $(this).data("select2").blur();
@@ -714,6 +714,11 @@
         updateResults: function (initial) {
             var search = this.search, results = this.results, opts = this.opts, self=this;
 
+            // if the search is currently hidden we do not alter the results
+            if (initial !== true && this.showSearchInput === false) {
+                return;
+            }
+
             search.addClass("select2-active");
 
             function render(html) {
@@ -1028,8 +1033,8 @@
             // hide the search box if this is the first we got the results and there are a few of them
 
             if (initial === true) {
-                showSearchInput = data.results.length >= this.opts.minimumResultsForSearch;
-                this.search.parent().toggle(showSearchInput);
+                showSearchInput = this.showSearchInput = data.results.length >= this.opts.minimumResultsForSearch;
+                this.container.find(".select2-search")[showSearchInput ? "removeClass" : "addClass"]("select2-search-hidden");
 
                 //add "select2-with-searchbox" to the container if search box is shown
                 this.container[showSearchInput ? "addClass" : "removeClass"]("select2-with-searchbox");