Built motion from commit 1038d87.|0.0.141
[motion.git] / public / bower_components / select2 / select2.js
index 9b0e044..69e8bc7 100644 (file)
@@ -1,5 +1,5 @@
 /*!
- * Select2 4.0.2
+ * Select2 4.0.1
  * https://select2.github.io
  *
  * Released under the MIT license
@@ -1142,7 +1142,11 @@ S2.define('select2/results',[
       this.$results.on('mousewheel', function (e) {
         var top = self.$results.scrollTop();
 
-        var bottom = self.$results.get(0).scrollHeight - top + e.deltaY;
+        var bottom = (
+          self.$results.get(0).scrollHeight -
+          self.$results.scrollTop() +
+          e.deltaY
+        );
 
         var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
         var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
@@ -3328,7 +3332,7 @@ S2.define('select2/data/array',[
         var $existingOption = $existing.filter(onlyItem(item));
 
         var existingData = this.item($existingOption);
-        var newData = $.extend(true, {}, item, existingData);
+        var newData = $.extend(true, {}, existingData, item);
 
         var $newOption = this.option(newData);
 
@@ -3436,9 +3440,7 @@ S2.define('select2/data/ajax',[
 
         callback(results);
       }, function () {
-        self.trigger('results:message', {
-          message: 'errorLoading'
-        });
+        // TODO: Handle AJAX errors
       });
 
       self._request = $request;
@@ -3470,12 +3472,6 @@ S2.define('select2/data/tags',[
       this.createTag = createTag;
     }
 
-    var insertTag = options.get('insertTag');
-
-    if (insertTag !== undefined) {
-        this.insertTag = insertTag;
-    }
-
     decorated.call(this, $element, options);
 
     if ($.isArray(tags)) {
@@ -4175,6 +4171,7 @@ S2.define('select2/dropdown/attachBody',[
 
     var newDirection = null;
 
+    var position = this.$container.position();
     var offset = this.$container.offset();
 
     offset.bottom = offset.top + this.$container.outerHeight(false);
@@ -4203,20 +4200,14 @@ S2.define('select2/dropdown/attachBody',[
       top: container.bottom
     };
 
-    // Determine what the parent element is to use for calciulating the offset
-    var $offsetParent = this.$dropdownParent;
+    // Fix positioning with static parents
+    if (this.$dropdownParent[0].style.position !== 'static') {
+      var parentOffset = this.$dropdownParent.offset();
 
-    // For statically positoned elements, we need to get the element
-    // that is determining the offset
-    if ($offsetParent.css('position') === 'static') {
-      $offsetParent = $offsetParent.offsetParent();
+      css.top -= parentOffset.top;
+      css.left -= parentOffset.left;
     }
 
-    var parentOffset = $offsetParent.offset();
-
-    css.top -= parentOffset.top;
-    css.left -= parentOffset.left;
-
     if (!isCurrentlyAbove && !isCurrentlyBelow) {
       newDirection = 'below';
     }
@@ -4483,7 +4474,7 @@ S2.define('select2/defaults',[
   }
 
   Defaults.prototype.apply = function (options) {
-    options = $.extend(true, {}, this.defaults, options);
+    options = $.extend({}, this.defaults, options);
 
     if (options.dataAdapter == null) {
       if (options.ajax != null) {
@@ -5047,7 +5038,6 @@ S2.define('select2/core',[
       id = Utils.generateChars(4);
     }
 
-    id = id.replace(/(:|\.|\[|\]|,)/g, '');
     id = 'select2-' + id;
 
     return id;