From da159d4633b21d9761b28a35996170d540f07578 Mon Sep 17 00:00:00 2001
From: Wladimir Coka <wlacoka@gmail.com>
Date: Thu, 26 Feb 2015 01:35:54 -0500
Subject: [PATCH] chore(build): v0.10.0

---
 bower.json          |    2 +-
 dist/select.css     |   43 +-
 dist/select.js      | 2362 +++++++++++++++++++++++--------------------
 dist/select.min.css |    4 +-
 dist/select.min.js  |    4 +-
 package.json        |    2 +-
 6 files changed, 1296 insertions(+), 1121 deletions(-)

diff --git a/bower.json b/bower.json
index b66c12190..71a24e391 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
 {
   "name": "ui-select",
-  "version": "0.9.9",
+  "version": "0.10.0",
   "homepage": "https://github.com/angular-ui/ui-select",
   "authors": [
     "AngularUI"
diff --git a/dist/select.css b/dist/select.css
index 98f40eed3..7aa436b97 100644
--- a/dist/select.css
+++ b/dist/select.css
@@ -1,7 +1,7 @@
 /*!
  * ui-select
  * http://github.com/angular-ui/ui-select
- * Version: 0.9.9 - 2015-02-18T03:49:07.281Z
+ * Version: 0.10.0 - 2015-02-26T06:35:06.243Z
  * License: MIT
  */
 
@@ -82,9 +82,6 @@
 
 .ui-select-bootstrap .ui-select-toggle {
   position: relative;
-
-  /* Instead of center because of .btn */
-  text-align: left;
 }
 
 .ui-select-bootstrap .ui-select-toggle > .caret {
@@ -107,6 +104,11 @@
   border-bottom-right-radius: 0;
 }
 
+.ui-select-bootstrap > .ui-select-match {
+  /* Instead of center because of .btn */
+  text-align: left;
+}
+
 .ui-select-bootstrap > .ui-select-match > .caret {
   position: absolute;
   top: 45%;
@@ -119,11 +121,12 @@
   height: auto;
   max-height: 200px;
   overflow-x: hidden;
+  margin-top: -1px;
 }
 
 .ui-select-multiple.ui-select-bootstrap {
   height: auto;
-  padding: .3em;
+  padding: 3px 3px 0 3px;
 }
 
 .ui-select-multiple.ui-select-bootstrap input.ui-select-search {
@@ -131,6 +134,7 @@
   border: none;
   outline: none;
   height: 1.666666em;
+  margin-bottom: 3px;
 }
 
 .ui-select-multiple.ui-select-bootstrap .ui-select-match .close {
@@ -138,8 +142,33 @@
   line-height: 0.75;
 }
 
-.ui-select-multiple.ui-select-bootstrap .ui-select-match-item{
+.ui-select-multiple.ui-select-bootstrap .ui-select-match-item {
   outline: 0;
+  margin: 0 3px 3px 0;
+}
+
+.ui-select-multiple .ui-select-match-item {
+  position: relative;
+}
+
+.ui-select-multiple .ui-select-match-item.dropping-before:before {
+  content: "";
+  position: absolute;
+  top: 0;
+  right: 100%;
+  height: 100%;
+  margin-right: 2px;
+  border-left: 1px solid #428bca;
+}
+
+.ui-select-multiple .ui-select-match-item.dropping-after:after {
+  content: "";
+  position: absolute;
+  top: 0;
+  left: 100%;
+  height: 100%;
+  margin-left: 2px;
+  border-right: 1px solid #428bca;
 }
 
 .ui-select-bootstrap .ui-select-choices-row>a {
@@ -181,4 +210,4 @@
 /* Mark invalid Bootstrap */
 .ui-select-bootstrap.ng-dirty.ng-invalid > button.btn.ui-select-match {
     border-color: #D44950;
-}
+}
\ No newline at end of file
diff --git a/dist/select.js b/dist/select.js
index 881374198..534269d2a 100755
--- a/dist/select.js
+++ b/dist/select.js
@@ -1,15 +1,15 @@
 /*!
  * ui-select
  * http://github.com/angular-ui/ui-select
- * Version: 0.9.9 - 2015-02-18T03:49:07.277Z
+ * Version: 0.10.0 - 2015-02-26T06:35:06.239Z
  * License: MIT
  */
 
 
-(function () {
-  "use strict";
+(function () { 
+"use strict";
 
-  var KEY = {
+var KEY = {
     TAB: 9,
     ENTER: 13,
     ESC: 27,
@@ -58,1341 +58,1487 @@
     }
   };
 
-  /**
-   * Add querySelectorAll() to jqLite.
-   *
-   * jqLite find() is limited to lookups by tag name.
-   * TODO This will change with future versions of AngularJS, to be removed when this happens
-   *
-   * See jqLite.find - why not use querySelectorAll? https://github.com/angular/angular.js/issues/3586
-   * See feat(jqLite): use querySelectorAll instead of getElementsByTagName in jqLite.find https://github.com/angular/angular.js/pull/3598
-   */
-  if (angular.element.prototype.querySelectorAll === undefined) {
-    angular.element.prototype.querySelectorAll = function(selector) {
-      return angular.element(this[0].querySelectorAll(selector));
-    };
-  }
+/**
+ * Add querySelectorAll() to jqLite.
+ *
+ * jqLite find() is limited to lookups by tag name.
+ * TODO This will change with future versions of AngularJS, to be removed when this happens
+ *
+ * See jqLite.find - why not use querySelectorAll? https://github.com/angular/angular.js/issues/3586
+ * See feat(jqLite): use querySelectorAll instead of getElementsByTagName in jqLite.find https://github.com/angular/angular.js/pull/3598
+ */
+if (angular.element.prototype.querySelectorAll === undefined) {
+  angular.element.prototype.querySelectorAll = function(selector) {
+    return angular.element(this[0].querySelectorAll(selector));
+  };
+}
 
-  /**
-   * Add closest() to jqLite.
-   */
-  if (angular.element.prototype.closest === undefined) {
-    angular.element.prototype.closest = function( selector) {
-      var elem = this[0];
-      var matchesSelector = elem.matches || elem.webkitMatchesSelector || elem.mozMatchesSelector || elem.msMatchesSelector;
-
-      while (elem) {
-        if (matchesSelector.bind(elem)(selector)) {
-          return elem;
-        } else {
-          elem = elem.parentElement;
-        }
+/**
+ * Add closest() to jqLite.
+ */
+if (angular.element.prototype.closest === undefined) {
+  angular.element.prototype.closest = function( selector) {
+    var elem = this[0];
+    var matchesSelector = elem.matches || elem.webkitMatchesSelector || elem.mozMatchesSelector || elem.msMatchesSelector;
+
+    while (elem) {
+      if (matchesSelector.bind(elem)(selector)) {
+        return elem;
+      } else {
+        elem = elem.parentElement;
       }
-      return false;
-    };
-  }
-
-  var latestId = 0;
-  angular.module('ui.select', [])
-
-  .constant('uiSelectConfig', {
-    theme: 'bootstrap',
-    searchEnabled: true,
-    placeholder: '', // Empty by default, like HTML tag <select>
-    refreshDelay: 1000, // In milliseconds
-    closeOnSelect: true,
-    generateId: function() {
-      return latestId++;
     }
-  })
-
-  // See Rename minErr and make it accessible from outside https://github.com/angular/angular.js/issues/6913
-  .service('uiSelectMinErr', function() {
-    var minErr = angular.$$minErr('ui.select');
-    return function() {
-      var error = minErr.apply(this, arguments);
-      var message = error.message.replace(new RegExp('\nhttp://errors.angularjs.org/.*'), '');
-      return new Error(message);
-    };
-  })
+    return false;
+  };
+}
 
-  /**
-   * Parses "repeat" attribute.
-   *
-   * Taken from AngularJS ngRepeat source code
-   * See https://github.com/angular/angular.js/blob/v1.2.15/src/ng/directive/ngRepeat.js#L211
-   *
-   * Original discussion about parsing "repeat" attribute instead of fully relying on ng-repeat:
-   * https://github.com/angular-ui/ui-select/commit/5dd63ad#commitcomment-5504697
-   */
-  .service('RepeatParser', ['uiSelectMinErr','$parse', function(uiSelectMinErr, $parse) {
-    var self = this;
-
-    /**
-     * Example:
-     * expression = "address in addresses | filter: {street: $select.search} track by $index"
-     * itemName = "address",
-     * source = "addresses | filter: {street: $select.search}",
-     * trackByExp = "$index",
-     */
-    self.parse = function(expression) {
-
-      var match = expression.match(/^\s*(?:([\s\S]+?)\s+as\s+)?([\S]+?)\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?\s*$/);
-
-      if (!match) {
-        throw uiSelectMinErr('iexp', "Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'.",
-                expression);
-      }
+var latestId = 0;
 
-      return {
-        itemName: match[2], // (lhs) Left-hand side,
-        source: $parse(match[3]),
-        trackByExp: match[4],
-        modelMapper: $parse(match[1] || match[2])
-      };
+var uis = angular.module('ui.select', [])
 
+.constant('uiSelectConfig', {
+  theme: 'bootstrap',
+  searchEnabled: true,
+  sortable: false,
+  placeholder: '', // Empty by default, like HTML tag <select>
+  refreshDelay: 1000, // In milliseconds
+  closeOnSelect: true,
+  generateId: function() {
+    return latestId++;
+  }
+})
+
+// See Rename minErr and make it accessible from outside https://github.com/angular/angular.js/issues/6913
+.service('uiSelectMinErr', function() {
+  var minErr = angular.$$minErr('ui.select');
+  return function() {
+    var error = minErr.apply(this, arguments);
+    var message = error.message.replace(new RegExp('\nhttp://errors.angularjs.org/.*'), '');
+    return new Error(message);
+  };
+})
+
+// Recreates old behavior of ng-transclude. Used internally.
+.directive('uisTranscludeAppend', function () {
+  return {
+    link: function (scope, element, attrs, ctrl, transclude) {
+        transclude(scope, function (clone) {
+          element.append(clone);
+        });
+      }
     };
+})
 
-    self.getGroupNgRepeatExpression = function() {
-      return '$group in $select.groups';
-    };
+/**
+ * Highlights text that matches $select.search.
+ *
+ * Taken from AngularUI Bootstrap Typeahead
+ * See https://github.com/angular-ui/bootstrap/blob/0.10.0/src/typeahead/typeahead.js#L340
+ */
+.filter('highlight', function() {
+  function escapeRegexp(queryToEscape) {
+    return queryToEscape.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
+  }
 
-    self.getNgRepeatExpression = function(itemName, source, trackByExp, grouped) {
-      var expression = itemName + ' in ' + (grouped ? '$group.items' : source);
-      if (trackByExp) {
-        expression += ' track by ' + trackByExp;
-      }
-      return expression;
-    };
-  }])
+  return function(matchItem, query) {
+    return query && matchItem ? matchItem.replace(new RegExp(escapeRegexp(query), 'gi'), '<span class="ui-select-highlight">$&</span>') : matchItem;
+  };
+});
+
+
+/**
+ * Parses "repeat" attribute.
+ *
+ * Taken from AngularJS ngRepeat source code
+ * See https://github.com/angular/angular.js/blob/v1.2.15/src/ng/directive/ngRepeat.js#L211
+ *
+ * Original discussion about parsing "repeat" attribute instead of fully relying on ng-repeat:
+ * https://github.com/angular-ui/ui-select/commit/5dd63ad#commitcomment-5504697
+ */
+
+uis.service('RepeatParser', ['uiSelectMinErr','$parse', function(uiSelectMinErr, $parse) {
+  var self = this;
 
   /**
-   * Contains ui-select "intelligence".
-   *
-   * The goal is to limit dependency on the DOM whenever possible and
-   * put as much logic in the controller (instead of the link functions) as possible so it can be easily tested.
+   * Example:
+   * expression = "address in addresses | filter: {street: $select.search} track by $index"
+   * itemName = "address",
+   * source = "addresses | filter: {street: $select.search}",
+   * trackByExp = "$index",
    */
-  .controller('uiSelectCtrl',
-    ['$scope', '$element', '$timeout', '$filter', 'RepeatParser', 'uiSelectMinErr', 'uiSelectConfig',
-    function($scope, $element, $timeout, $filter, RepeatParser, uiSelectMinErr, uiSelectConfig) {
+  self.parse = function(expression) {
 
-    var ctrl = this;
+    var match = expression.match(/^\s*(?:([\s\S]+?)\s+as\s+)?([\S]+?)\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?\s*$/);
 
-    var EMPTY_SEARCH = '';
+    if (!match) {
+      throw uiSelectMinErr('iexp', "Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'.",
+              expression);
+    }
 
-    ctrl.placeholder = undefined;
-    ctrl.search = EMPTY_SEARCH;
-    ctrl.activeIndex = 0;
-    ctrl.activeMatchIndex = -1;
-    ctrl.items = [];
-    ctrl.selected = undefined;
-    ctrl.open = false;
-    ctrl.focus = false;
-    ctrl.focusser = undefined; //Reference to input element used to handle focus events
-    ctrl.disabled = undefined; // Initialized inside uiSelect directive link function
-    ctrl.searchEnabled = undefined; // Initialized inside uiSelect directive link function
-    ctrl.resetSearchInput = undefined; // Initialized inside uiSelect directive link function
-    ctrl.refreshDelay = undefined; // Initialized inside uiSelectChoices directive link function
-    ctrl.multiple = false; // Initialized inside uiSelect directive link function
-    ctrl.disableChoiceExpression = undefined; // Initialized inside uiSelect directive link function
-    ctrl.tagging = {isActivated: false, fct: undefined};
-    ctrl.taggingTokens = {isActivated: false, tokens: undefined};
-    ctrl.lockChoiceExpression = undefined; // Initialized inside uiSelect directive link function
-    ctrl.closeOnSelect = true; // Initialized inside uiSelect directive link function
-    ctrl.clickTriggeredSelect = false;
-    ctrl.$filter = $filter;
-
-    ctrl.isEmpty = function() {
-      return angular.isUndefined(ctrl.selected) || ctrl.selected === null || ctrl.selected === '';
+    return {
+      itemName: match[2], // (lhs) Left-hand side,
+      source: $parse(match[3]),
+      trackByExp: match[4],
+      modelMapper: $parse(match[1] || match[2])
     };
 
-    var _searchInput = $element.querySelectorAll('input.ui-select-search');
-    if (_searchInput.length !== 1) {
-      throw uiSelectMinErr('searchInput', "Expected 1 input.ui-select-search but got '{0}'.", _searchInput.length);
-    }
+  };
 
-    // Most of the time the user does not want to empty the search input when in typeahead mode
-    function _resetSearchInput() {
-      if (ctrl.resetSearchInput || (ctrl.resetSearchInput === undefined && uiSelectConfig.resetSearchInput)) {
-        ctrl.search = EMPTY_SEARCH;
-        //reset activeIndex
-        if (ctrl.selected && ctrl.items.length && !ctrl.multiple) {
-          ctrl.activeIndex = ctrl.items.indexOf(ctrl.selected);
-        }
-      }
+  self.getGroupNgRepeatExpression = function() {
+    return '$group in $select.groups';
+  };
+
+  self.getNgRepeatExpression = function(itemName, source, trackByExp, grouped) {
+    var expression = itemName + ' in ' + (grouped ? '$group.items' : source);
+    if (trackByExp) {
+      expression += ' track by ' + trackByExp;
     }
+    return expression;
+  };
+}]);
+
+uis.directive('uiSelectChoices',
+  ['uiSelectConfig', 'RepeatParser', 'uiSelectMinErr', '$compile',
+  function(uiSelectConfig, RepeatParser, uiSelectMinErr, $compile) {
+
+  return {
+    restrict: 'EA',
+    require: '^uiSelect',
+    replace: true,
+    transclude: true,
+    templateUrl: function(tElement) {
+      // Gets theme attribute from parent (ui-select)
+      var theme = tElement.parent().attr('theme') || uiSelectConfig.theme;
+      return theme + '/choices.tpl.html';
+    },
+
+    compile: function(tElement, tAttrs) {
+
+      if (!tAttrs.repeat) throw uiSelectMinErr('repeat', "Expected 'repeat' expression.");
+
+      return function link(scope, element, attrs, $select, transcludeFn) {
 
-    // When the user clicks on ui-select, displays the dropdown list
-    ctrl.activate = function(initSearchValue, avoidReset) {
-      if (!ctrl.disabled  && !ctrl.open) {
-        if(!avoidReset) _resetSearchInput();
-        ctrl.focusser.prop('disabled', true); //Will reactivate it on .close()
-        ctrl.open = true;
-        ctrl.activeMatchIndex = -1;
+        // var repeat = RepeatParser.parse(attrs.repeat);
+        var groupByExp = attrs.groupBy;
 
-        ctrl.activeIndex = ctrl.activeIndex >= ctrl.items.length ? 0 : ctrl.activeIndex;
+        $select.parseRepeatAttr(attrs.repeat, groupByExp); //Result ready at $select.parserResult
 
-        // ensure that the index is set to zero for tagging variants
-        // that where first option is auto-selected
-        if ( ctrl.activeIndex === -1 && ctrl.taggingLabel !== false ) {
-          ctrl.activeIndex = 0;
+        $select.disableChoiceExpression = attrs.uiDisableChoice;
+        $select.onHighlightCallback = attrs.onHighlight;
+
+        if(groupByExp) {
+          var groups = element.querySelectorAll('.ui-select-choices-group');
+          if (groups.length !== 1) throw uiSelectMinErr('rows', "Expected 1 .ui-select-choices-group but got '{0}'.", groups.length);
+          groups.attr('ng-repeat', RepeatParser.getGroupNgRepeatExpression());
         }
 
-        // Give it time to appear before focus
-        $timeout(function() {
-          ctrl.search = initSearchValue || ctrl.search;
-          _searchInput[0].focus();
-        });
-      }
-    };
+        var choices = element.querySelectorAll('.ui-select-choices-row');
+        if (choices.length !== 1) {
+          throw uiSelectMinErr('rows', "Expected 1 .ui-select-choices-row but got '{0}'.", choices.length);
+        }
 
-    ctrl.findGroupByName = function(name) {
-      return ctrl.groups && ctrl.groups.filter(function(group) {
-        return group.name === name;
-      })[0];
-    };
+        choices.attr('ng-repeat', RepeatParser.getNgRepeatExpression($select.parserResult.itemName, '$select.items', $select.parserResult.trackByExp, groupByExp))
+            .attr('ng-if', '$select.open') //Prevent unnecessary watches when dropdown is closed
+            .attr('ng-mouseenter', '$select.setActiveItem('+$select.parserResult.itemName +')')
+            .attr('ng-click', '$select.select(' + $select.parserResult.itemName + ',false,$event)');
 
-    ctrl.parseRepeatAttr = function(repeatAttr, groupByExp) {
-      function updateGroups(items) {
-        ctrl.groups = [];
-        angular.forEach(items, function(item) {
-          var groupFn = $scope.$eval(groupByExp);
-          var groupName = angular.isFunction(groupFn) ? groupFn(item) : item[groupFn];
-          var group = ctrl.findGroupByName(groupName);
-          if(group) {
-            group.items.push(item);
-          }
-          else {
-            ctrl.groups.push({name: groupName, items: [item]});
-          }
+        var rowsInner = element.querySelectorAll('.ui-select-choices-row-inner');
+        if (rowsInner.length !== 1) throw uiSelectMinErr('rows', "Expected 1 .ui-select-choices-row-inner but got '{0}'.", rowsInner.length);
+        rowsInner.attr('uis-transclude-append', ''); //Adding uisTranscludeAppend directive to row element after choices element has ngRepeat
+
+        $compile(element, transcludeFn)(scope); //Passing current transcludeFn to be able to append elements correctly from uisTranscludeAppend
+
+        scope.$watch('$select.search', function(newValue) {
+          if(newValue && !$select.open && $select.multiple) $select.activate(false, true);
+          $select.activeIndex = $select.tagging.isActivated ? -1 : 0;
+          $select.refresh(attrs.refresh);
         });
-        ctrl.items = [];
-        ctrl.groups.forEach(function(group) {
-          ctrl.items = ctrl.items.concat(group.items);
+
+        attrs.$observe('refreshDelay', function() {
+          // $eval() is needed otherwise we get a string instead of a number
+          var refreshDelay = scope.$eval(attrs.refreshDelay);
+          $select.refreshDelay = refreshDelay !== undefined ? refreshDelay : uiSelectConfig.refreshDelay;
         });
-      }
+      };
+    }
+  };
+}]);
 
-      function setPlainItems(items) {
-        ctrl.items = items;
+/**
+ * Contains ui-select "intelligence".
+ *
+ * The goal is to limit dependency on the DOM whenever possible and
+ * put as much logic in the controller (instead of the link functions) as possible so it can be easily tested.
+ */
+uis.controller('uiSelectCtrl',
+  ['$scope', '$element', '$timeout', '$filter', 'RepeatParser', 'uiSelectMinErr', 'uiSelectConfig',
+  function($scope, $element, $timeout, $filter, RepeatParser, uiSelectMinErr, uiSelectConfig) {
+
+  var ctrl = this;
+
+  var EMPTY_SEARCH = '';
+
+  ctrl.placeholder = uiSelectConfig.placeholder;
+  ctrl.search = EMPTY_SEARCH;
+  ctrl.activeIndex = 0;
+  ctrl.activeMatchIndex = -1;
+  ctrl.items = [];
+  ctrl.selected = undefined;
+  ctrl.open = false;
+  ctrl.focus = false;
+  ctrl.focusser = undefined; //Reference to input element used to handle focus events
+  ctrl.disabled = false;
+  ctrl.searchEnabled = uiSelectConfig.searchEnabled;
+  ctrl.sortable = uiSelectConfig.sortable;
+  ctrl.resetSearchInput = true;
+  ctrl.multiple = undefined; // Initialized inside uiSelect directive link function
+  ctrl.refreshDelay = uiSelectConfig.refreshDelay;
+  ctrl.disableChoiceExpression = undefined; // Initialized inside uiSelectChoices directive link function
+  ctrl.tagging = {isActivated: false, fct: undefined};
+  ctrl.taggingTokens = {isActivated: false, tokens: undefined};
+  ctrl.lockChoiceExpression = undefined; // Initialized inside uiSelectMatch directive link function
+  ctrl.closeOnSelect = true; // Initialized inside uiSelect directive link function
+  ctrl.clickTriggeredSelect = false;
+  ctrl.$filter = $filter;
+
+  ctrl.isEmpty = function() {
+    return angular.isUndefined(ctrl.selected) || ctrl.selected === null || ctrl.selected === '';
+  };
+
+  var _searchInput = $element.querySelectorAll('input.ui-select-search');
+  if (_searchInput.length !== 1) {
+    throw uiSelectMinErr('searchInput', "Expected 1 input.ui-select-search but got '{0}'.", _searchInput.length);
+  }
+
+  // Most of the time the user does not want to empty the search input when in typeahead mode
+  function _resetSearchInput() {
+    if (ctrl.resetSearchInput || (ctrl.resetSearchInput === undefined && uiSelectConfig.resetSearchInput)) {
+      ctrl.search = EMPTY_SEARCH;
+      //reset activeIndex
+      if (ctrl.selected && ctrl.items.length && !ctrl.multiple) {
+        ctrl.activeIndex = ctrl.items.indexOf(ctrl.selected);
       }
+    }
+  }
 
-      var setItemsFn = groupByExp ? updateGroups : setPlainItems;
+  // When the user clicks on ui-select, displays the dropdown list
+  ctrl.activate = function(initSearchValue, avoidReset) {
+    if (!ctrl.disabled  && !ctrl.open) {
+      if(!avoidReset) _resetSearchInput();
+      ctrl.focusser.prop('disabled', true); //Will reactivate it on .close()
+      ctrl.open = true;
+      ctrl.activeMatchIndex = -1;
 
-      ctrl.parserResult = RepeatParser.parse(repeatAttr);
+      ctrl.activeIndex = ctrl.activeIndex >= ctrl.items.length ? 0 : ctrl.activeIndex;
 
-      ctrl.isGrouped = !!groupByExp;
-      ctrl.itemProperty = ctrl.parserResult.itemName;
+      // ensure that the index is set to zero for tagging variants
+      // that where first option is auto-selected
+      if ( ctrl.activeIndex === -1 && ctrl.taggingLabel !== false ) {
+        ctrl.activeIndex = 0;
+      }
 
-      // See https://github.com/angular/angular.js/blob/v1.2.15/src/ng/directive/ngRepeat.js#L259
-      $scope.$watchCollection(ctrl.parserResult.source, function(items) {
+      // Give it time to appear before focus
+      $timeout(function() {
+        ctrl.search = initSearchValue || ctrl.search;
+        _searchInput[0].focus();
+      });
+    }
+  };
 
-        if (items === undefined || items === null) {
-          // If the user specifies undefined or null => reset the collection
-          // Special case: items can be undefined if the user did not initialized the collection on the scope
-          // i.e $scope.addresses = [] is missing
-          ctrl.items = [];
-        } else {
-          if (!angular.isArray(items)) {
-            throw uiSelectMinErr('items', "Expected an array but got '{0}'.", items);
-          } else {
-            if (ctrl.multiple){
-              //Remove already selected items (ex: while searching)
-              var filteredItems = items.filter(function(i) {return ctrl.selected.indexOf(i) < 0;});
-              setItemsFn(filteredItems);
-            }else{
-              setItemsFn(items);
-            }
-            ctrl.ngModel.$modelValue = null; //Force scope model value and ngModel value to be out of sync to re-run formatters
+  ctrl.findGroupByName = function(name) {
+    return ctrl.groups && ctrl.groups.filter(function(group) {
+      return group.name === name;
+    })[0];
+  };
 
-          }
+  ctrl.parseRepeatAttr = function(repeatAttr, groupByExp) {
+    function updateGroups(items) {
+      ctrl.groups = [];
+      angular.forEach(items, function(item) {
+        var groupFn = $scope.$eval(groupByExp);
+        var groupName = angular.isFunction(groupFn) ? groupFn(item) : item[groupFn];
+        var group = ctrl.findGroupByName(groupName);
+        if(group) {
+          group.items.push(item);
         }
-
+        else {
+          ctrl.groups.push({name: groupName, items: [item]});
+        }
+      });
+      ctrl.items = [];
+      ctrl.groups.forEach(function(group) {
+        ctrl.items = ctrl.items.concat(group.items);
       });
+    }
+
+    function setPlainItems(items) {
+      ctrl.items = items;
+    }
+
+    var setItemsFn = groupByExp ? updateGroups : setPlainItems;
+
+    ctrl.parserResult = RepeatParser.parse(repeatAttr);
+
+    ctrl.isGrouped = !!groupByExp;
+    ctrl.itemProperty = ctrl.parserResult.itemName;
 
-      if (ctrl.multiple){
-        //Remove already selected items
-        $scope.$watchCollection('$select.selected', function(selectedItems){
-          var data = ctrl.parserResult.source($scope);
-          if (!selectedItems.length) {
-            setItemsFn(data);
+    // See https://github.com/angular/angular.js/blob/v1.2.15/src/ng/directive/ngRepeat.js#L259
+    $scope.$watchCollection(ctrl.parserResult.source, function(items) {
+
+      if (items === undefined || items === null) {
+        // If the user specifies undefined or null => reset the collection
+        // Special case: items can be undefined if the user did not initialized the collection on the scope
+        // i.e $scope.addresses = [] is missing
+        ctrl.items = [];
+      } else {
+        if (!angular.isArray(items)) {
+          throw uiSelectMinErr('items', "Expected an array but got '{0}'.", items);
+        } else {
+          if (ctrl.multiple){
+            //Remove already selected items (ex: while searching)
+            var filteredItems = items.filter(function(i) {return ctrl.selected.indexOf(i) < 0;});
+            setItemsFn(filteredItems);
           }else{
-            if ( data !== undefined ) {
-              var filteredItems = data.filter(function(i) {return selectedItems.indexOf(i) < 0;});
-              setItemsFn(filteredItems);
-            }
+            setItemsFn(items);
           }
-          ctrl.sizeSearchInput();
-        });
+          ctrl.ngModel.$modelValue = null; //Force scope model value and ngModel value to be out of sync to re-run formatters
+
+        }
       }
 
-    };
+    });
 
-    var _refreshDelayPromise;
-
-    /**
-     * Typeahead mode: lets the user refresh the collection using his own function.
-     *
-     * See Expose $select.search for external / remote filtering https://github.com/angular-ui/ui-select/pull/31
-     */
-    ctrl.refresh = function(refreshAttr) {
-      if (refreshAttr !== undefined) {
-
-        // Debounce
-        // See https://github.com/angular-ui/bootstrap/blob/0.10.0/src/typeahead/typeahead.js#L155
-        // FYI AngularStrap typeahead does not have debouncing: https://github.com/mgcrea/angular-strap/blob/v2.0.0-rc.4/src/typeahead/typeahead.js#L177
-        if (_refreshDelayPromise) {
-          $timeout.cancel(_refreshDelayPromise);
+    if (ctrl.multiple){
+      //Remove already selected items
+      $scope.$watchCollection('$select.selected', function(selectedItems){
+        var data = ctrl.parserResult.source($scope);
+        if (!selectedItems.length) {
+          setItemsFn(data);
+        }else{
+          if ( data !== undefined ) {
+            var filteredItems = data.filter(function(i) {return selectedItems.indexOf(i) < 0;});
+            setItemsFn(filteredItems);
+          }
         }
-        _refreshDelayPromise = $timeout(function() {
-          $scope.$eval(refreshAttr);
-        }, ctrl.refreshDelay);
-      }
-    };
+        ctrl.sizeSearchInput();
+      });
+    }
 
-    ctrl.setActiveItem = function(item) {
-      ctrl.activeIndex = ctrl.items.indexOf(item);
-    };
+  };
 
-    ctrl.isActive = function(itemScope) {
-      if ( !ctrl.open ) {
-        return false;
-      }
-      var itemIndex = ctrl.items.indexOf(itemScope[ctrl.itemProperty]);
-      var isActive =  itemIndex === ctrl.activeIndex;
+  var _refreshDelayPromise;
 
-      if ( !isActive || ( itemIndex < 0 && ctrl.taggingLabel !== false ) ||( itemIndex < 0 && ctrl.taggingLabel === false) ) {
-        return false;
+  /**
+   * Typeahead mode: lets the user refresh the collection using his own function.
+   *
+   * See Expose $select.search for external / remote filtering https://github.com/angular-ui/ui-select/pull/31
+   */
+  ctrl.refresh = function(refreshAttr) {
+    if (refreshAttr !== undefined) {
+
+      // Debounce
+      // See https://github.com/angular-ui/bootstrap/blob/0.10.0/src/typeahead/typeahead.js#L155
+      // FYI AngularStrap typeahead does not have debouncing: https://github.com/mgcrea/angular-strap/blob/v2.0.0-rc.4/src/typeahead/typeahead.js#L177
+      if (_refreshDelayPromise) {
+        $timeout.cancel(_refreshDelayPromise);
       }
+      _refreshDelayPromise = $timeout(function() {
+        $scope.$eval(refreshAttr);
+      }, ctrl.refreshDelay);
+    }
+  };
 
-      if (isActive && !angular.isUndefined(ctrl.onHighlightCallback)) {
-        itemScope.$eval(ctrl.onHighlightCallback);
-      }
+  ctrl.setActiveItem = function(item) {
+    ctrl.activeIndex = ctrl.items.indexOf(item);
+  };
 
-      return isActive;
-    };
+  ctrl.isActive = function(itemScope) {
+    if ( !ctrl.open ) {
+      return false;
+    }
+    var itemIndex = ctrl.items.indexOf(itemScope[ctrl.itemProperty]);
+    var isActive =  itemIndex === ctrl.activeIndex;
 
-    ctrl.isDisabled = function(itemScope) {
+    if ( !isActive || ( itemIndex < 0 && ctrl.taggingLabel !== false ) ||( itemIndex < 0 && ctrl.taggingLabel === false) ) {
+      return false;
+    }
 
-      if (!ctrl.open) return;
+    if (isActive && !angular.isUndefined(ctrl.onHighlightCallback)) {
+      itemScope.$eval(ctrl.onHighlightCallback);
+    }
 
-      var itemIndex = ctrl.items.indexOf(itemScope[ctrl.itemProperty]);
-      var isDisabled = false;
-      var item;
+    return isActive;
+  };
 
-      if (itemIndex >= 0 && !angular.isUndefined(ctrl.disableChoiceExpression)) {
-        item = ctrl.items[itemIndex];
-        isDisabled = !!(itemScope.$eval(ctrl.disableChoiceExpression)); // force the boolean value
-        item._uiSelectChoiceDisabled = isDisabled; // store this for later reference
-      }
+  ctrl.isDisabled = function(itemScope) {
 
-      return isDisabled;
-    };
+    if (!ctrl.open) return;
+
+    var itemIndex = ctrl.items.indexOf(itemScope[ctrl.itemProperty]);
+    var isDisabled = false;
+    var item;
 
+    if (itemIndex >= 0 && !angular.isUndefined(ctrl.disableChoiceExpression)) {
+      item = ctrl.items[itemIndex];
+      isDisabled = !!(itemScope.$eval(ctrl.disableChoiceExpression)); // force the boolean value
+      item._uiSelectChoiceDisabled = isDisabled; // store this for later reference
+    }
+
+    return isDisabled;
+  };
 
-    // When the user selects an item with ENTER or clicks the dropdown
-    ctrl.select = function(item, skipFocusser, $event) {
-      if (item === undefined || !item._uiSelectChoiceDisabled) {
 
-        if ( ! ctrl.items && ! ctrl.search ) return;
+  // When the user selects an item with ENTER or clicks the dropdown
+  ctrl.select = function(item, skipFocusser, $event) {
+    if (item === undefined || !item._uiSelectChoiceDisabled) {
 
-        if (!item || !item._uiSelectChoiceDisabled) {
-          if(ctrl.tagging.isActivated) {
-            // if taggingLabel is disabled, we pull from ctrl.search val
-            if ( ctrl.taggingLabel === false ) {
-              if ( ctrl.activeIndex < 0 ) {
-                item = ctrl.tagging.fct !== undefined ? ctrl.tagging.fct(ctrl.search) : ctrl.search;
-                if (!item || angular.equals( ctrl.items[0], item ) ) {
-                  return;
-                }
-              } else {
-                // keyboard nav happened first, user selected from dropdown
-                item = ctrl.items[ctrl.activeIndex];
+      if ( ! ctrl.items && ! ctrl.search ) return;
+
+      if (!item || !item._uiSelectChoiceDisabled) {
+        if(ctrl.tagging.isActivated) {
+          // if taggingLabel is disabled, we pull from ctrl.search val
+          if ( ctrl.taggingLabel === false ) {
+            if ( ctrl.activeIndex < 0 ) {
+              item = ctrl.tagging.fct !== undefined ? ctrl.tagging.fct(ctrl.search) : ctrl.search;
+              if (!item || angular.equals( ctrl.items[0], item ) ) {
+                return;
               }
             } else {
-              // tagging always operates at index zero, taggingLabel === false pushes
-              // the ctrl.search value without having it injected
-              if ( ctrl.activeIndex === 0 ) {
-                // ctrl.tagging pushes items to ctrl.items, so we only have empty val
-                // for `item` if it is a detected duplicate
-                if ( item === undefined ) return;
-
-                // create new item on the fly if we don't already have one;
-                // use tagging function if we have one
-                if ( ctrl.tagging.fct !== undefined && typeof item === 'string' ) {
-                  item = ctrl.tagging.fct(ctrl.search);
-                  if (!item) return;
-                // if item type is 'string', apply the tagging label
-                } else if ( typeof item === 'string' ) {
-                  // trim the trailing space
-                  item = item.replace(ctrl.taggingLabel,'').trim();
-                }
-              }
+              // keyboard nav happened first, user selected from dropdown
+              item = ctrl.items[ctrl.activeIndex];
             }
-            // search ctrl.selected for dupes potentially caused by tagging and return early if found
-            if ( ctrl.selected && angular.isArray(ctrl.selected) && ctrl.selected.filter( function (selection) { return angular.equals(selection, item); }).length > 0 ) {
-              ctrl.close(skipFocusser);
-              return;
+          } else {
+            // tagging always operates at index zero, taggingLabel === false pushes
+            // the ctrl.search value without having it injected
+            if ( ctrl.activeIndex === 0 ) {
+              // ctrl.tagging pushes items to ctrl.items, so we only have empty val
+              // for `item` if it is a detected duplicate
+              if ( item === undefined ) return;
+
+              // create new item on the fly if we don't already have one;
+              // use tagging function if we have one
+              if ( ctrl.tagging.fct !== undefined && typeof item === 'string' ) {
+                item = ctrl.tagging.fct(ctrl.search);
+                if (!item) return;
+              // if item type is 'string', apply the tagging label
+              } else if ( typeof item === 'string' ) {
+                // trim the trailing space
+                item = item.replace(ctrl.taggingLabel,'').trim();
+              }
             }
           }
+          // search ctrl.selected for dupes potentially caused by tagging and return early if found
+          if ( ctrl.selected && angular.isArray(ctrl.selected) && ctrl.selected.filter( function (selection) { return angular.equals(selection, item); }).length > 0 ) {
+            ctrl.close(skipFocusser);
+            return;
+          }
+        }
 
-          var locals = {};
-          locals[ctrl.parserResult.itemName] = item;
+        var locals = {};
+        locals[ctrl.parserResult.itemName] = item;
 
-          if(ctrl.multiple) {
-            ctrl.selected.push(item);
-            ctrl.sizeSearchInput();
-          } else {
-            ctrl.selected = item;
-          }
+        if(ctrl.multiple) {
+          ctrl.selected.push(item);
+          ctrl.sizeSearchInput();
+        } else {
+          ctrl.selected = item;
+        }
 
-          $timeout(function(){
-            ctrl.onSelectCallback($scope, {
-              $item: item,
-              $model: ctrl.parserResult.modelMapper($scope, locals)
-            });
+        $timeout(function(){
+          ctrl.onSelectCallback($scope, {
+            $item: item,
+            $model: ctrl.parserResult.modelMapper($scope, locals)
           });
+        });
 
-          if (!ctrl.multiple || ctrl.closeOnSelect) {
-            ctrl.close(skipFocusser);
-          }
-          if ($event && $event.type === 'click') {
-            ctrl.clickTriggeredSelect = true;
-          }
+        if (!ctrl.multiple || ctrl.closeOnSelect) {
+          ctrl.close(skipFocusser);
+        }
+        if ($event && $event.type === 'click') {
+          ctrl.clickTriggeredSelect = true;
         }
       }
-    };
+    }
+  };
 
-    // Closes the dropdown
-    ctrl.close = function(skipFocusser) {
-      if (!ctrl.open) return;
-      if (ctrl.ngModel && ctrl.ngModel.$setTouched) ctrl.ngModel.$setTouched();
-      _resetSearchInput();
-      ctrl.open = false;
-      if (!ctrl.multiple){
-        $timeout(function(){
-          ctrl.focusser.prop('disabled', false);
-          if (!skipFocusser) ctrl.focusser[0].focus();
-        },0,false);
-      }
-    };
+  // Closes the dropdown
+  ctrl.close = function(skipFocusser) {
+    if (!ctrl.open) return;
+    if (ctrl.ngModel && ctrl.ngModel.$setTouched) ctrl.ngModel.$setTouched();
+    _resetSearchInput();
+    ctrl.open = false;
+    if (!ctrl.multiple){
+      $timeout(function(){
+        ctrl.focusser.prop('disabled', false);
+        if (!skipFocusser) ctrl.focusser[0].focus();
+      },0,false);
+    }
+  };
 
-    ctrl.clear = function($event) {
-      ctrl.select(undefined);
-      $event.stopPropagation();
-      ctrl.focusser[0].focus();
-    };
+  ctrl.clear = function($event) {
+    ctrl.select(undefined);
+    $event.stopPropagation();
+    ctrl.focusser[0].focus();
+  };
 
-    // Toggle dropdown
-    ctrl.toggle = function(e) {
-      if (ctrl.open) {
-        ctrl.close();
-        e.preventDefault();
-        e.stopPropagation();
-      } else {
-        ctrl.activate();
-      }
-    };
+  // Toggle dropdown
+  ctrl.toggle = function(e) {
+    if (ctrl.open) {
+      ctrl.close();
+      e.preventDefault();
+      e.stopPropagation();
+    } else {
+      ctrl.activate();
+    }
+  };
 
-    ctrl.isLocked = function(itemScope, itemIndex) {
-        var isLocked, item = ctrl.selected[itemIndex];
+  ctrl.isLocked = function(itemScope, itemIndex) {
+      var isLocked, item = ctrl.selected[itemIndex];
 
-        if (item && !angular.isUndefined(ctrl.lockChoiceExpression)) {
-            isLocked = !!(itemScope.$eval(ctrl.lockChoiceExpression)); // force the boolean value
-            item._uiSelectChoiceLocked = isLocked; // store this for later reference
-        }
+      if (item && !angular.isUndefined(ctrl.lockChoiceExpression)) {
+          isLocked = !!(itemScope.$eval(ctrl.lockChoiceExpression)); // force the boolean value
+          item._uiSelectChoiceLocked = isLocked; // store this for later reference
+      }
 
-        return isLocked;
-    };
+      return isLocked;
+  };
 
-    // Remove item from multiple select
-    ctrl.removeChoice = function(index){
-      var removedChoice = ctrl.selected[index];
+  // Remove item from multiple select
+  ctrl.removeChoice = function(index){
+    var removedChoice = ctrl.selected[index];
 
-      // if the choice is locked, can't remove it
-      if(removedChoice._uiSelectChoiceLocked) return;
+    // if the choice is locked, can't remove it
+    if(removedChoice._uiSelectChoiceLocked) return;
 
-      var locals = {};
-      locals[ctrl.parserResult.itemName] = removedChoice;
+    var locals = {};
+    locals[ctrl.parserResult.itemName] = removedChoice;
 
-      ctrl.selected.splice(index, 1);
-      ctrl.activeMatchIndex = -1;
-      ctrl.sizeSearchInput();
+    ctrl.selected.splice(index, 1);
+    ctrl.activeMatchIndex = -1;
+    ctrl.sizeSearchInput();
 
-      // Give some time for scope propagation.
-      $timeout(function(){
-        ctrl.onRemoveCallback($scope, {
-          $item: removedChoice,
-          $model: ctrl.parserResult.modelMapper($scope, locals)
-        });
+    // Give some time for scope propagation.
+    $timeout(function(){
+      ctrl.onRemoveCallback($scope, {
+        $item: removedChoice,
+        $model: ctrl.parserResult.modelMapper($scope, locals)
       });
-    };
+    });
+  };
+
+  ctrl.getPlaceholder = function(){
+    //Refactor single?
+    if(ctrl.multiple && ctrl.selected.length) return;
+    return ctrl.placeholder;
+  };
 
-    ctrl.getPlaceholder = function(){
-      //Refactor single?
-      if(ctrl.multiple && ctrl.selected.length) return;
-      return ctrl.placeholder;
+  var containerSizeWatch;
+  ctrl.sizeSearchInput = function(){
+    var input = _searchInput[0],
+        container = _searchInput.parent().parent()[0];
+    _searchInput.css('width','10px');
+    var calculate = function(){
+      var newWidth = container.clientWidth - input.offsetLeft - 10;
+      if(newWidth < 50) newWidth = container.clientWidth;
+      _searchInput.css('width',newWidth+'px');
     };
+    $timeout(function(){ //Give tags time to render correctly
+      if (container.clientWidth === 0 && !containerSizeWatch){
+        containerSizeWatch = $scope.$watch(function(){ return container.clientWidth;}, function(newValue){
+          if (newValue !== 0){
+            calculate();
+            containerSizeWatch();
+            containerSizeWatch = null;
+          }
+        });
+      }else if (!containerSizeWatch) {
+        calculate();
+      }
+    }, 0, false);
+  };
 
-    var containerSizeWatch;
-    ctrl.sizeSearchInput = function(){
-      var input = _searchInput[0],
-          container = _searchInput.parent().parent()[0];
-      _searchInput.css('width','10px');
-      var calculate = function(){
-        var newWidth = container.clientWidth - input.offsetLeft - 10;
-        if(newWidth < 50) newWidth = container.clientWidth;
-        _searchInput.css('width',newWidth+'px');
-      };
-      $timeout(function(){ //Give tags time to render correctly
-        if (container.clientWidth === 0 && !containerSizeWatch){
-          containerSizeWatch = $scope.$watch(function(){ return container.clientWidth;}, function(newValue){
-            if (newValue !== 0){
-              calculate();
-              containerSizeWatch();
-              containerSizeWatch = null;
-            }
-          });
-        }else if (!containerSizeWatch) {
-          calculate();
+  function _handleDropDownSelection(key) {
+    var processed = true;
+    switch (key) {
+      case KEY.DOWN:
+        if (!ctrl.open && ctrl.multiple) ctrl.activate(false, true); //In case its the search input in 'multiple' mode
+        else if (ctrl.activeIndex < ctrl.items.length - 1) { ctrl.activeIndex++; }
+        break;
+      case KEY.UP:
+        if (!ctrl.open && ctrl.multiple) ctrl.activate(false, true); //In case its the search input in 'multiple' mode
+        else if (ctrl.activeIndex > 0 || (ctrl.search.length === 0 && ctrl.tagging.isActivated && ctrl.activeIndex > -1)) { ctrl.activeIndex--; }
+        break;
+      case KEY.TAB:
+        if (!ctrl.multiple || ctrl.open) ctrl.select(ctrl.items[ctrl.activeIndex], true);
+        break;
+      case KEY.ENTER:
+        if(ctrl.open && ctrl.activeIndex >= 0){
+          ctrl.select(ctrl.items[ctrl.activeIndex]); // Make sure at least one dropdown item is highlighted before adding.
+        } else {
+          ctrl.activate(false, true); //In case its the search input in 'multiple' mode
         }
-      }, 0, false);
-    };
+        break;
+      case KEY.ESC:
+        ctrl.close();
+        break;
+      default:
+        processed = false;
+    }
+    return processed;
+  }
 
-    function _handleDropDownSelection(key) {
-      var processed = true;
-      switch (key) {
-        case KEY.DOWN:
-          if (!ctrl.open && ctrl.multiple) ctrl.activate(false, true); //In case its the search input in 'multiple' mode
-          else if (ctrl.activeIndex < ctrl.items.length - 1) { ctrl.activeIndex++; }
+  // Handles selected options in "multiple" mode
+  function _handleMatchSelection(key){
+    var caretPosition = _getCaretPosition(_searchInput[0]),
+        length = ctrl.selected.length,
+        // none  = -1,
+        first = 0,
+        last  = length-1,
+        curr  = ctrl.activeMatchIndex,
+        next  = ctrl.activeMatchIndex+1,
+        prev  = ctrl.activeMatchIndex-1,
+        newIndex = curr;
+
+    if(caretPosition > 0 || (ctrl.search.length && key == KEY.RIGHT)) return false;
+
+    ctrl.close();
+
+    function getNewActiveMatchIndex(){
+      switch(key){
+        case KEY.LEFT:
+          // Select previous/first item
+          if(~ctrl.activeMatchIndex) return prev;
+          // Select last item
+          else return last;
           break;
-        case KEY.UP:
-          if (!ctrl.open && ctrl.multiple) ctrl.activate(false, true); //In case its the search input in 'multiple' mode
-          else if (ctrl.activeIndex > 0 || (ctrl.search.length === 0 && ctrl.tagging.isActivated && ctrl.activeIndex > -1)) { ctrl.activeIndex--; }
-          break;
-        case KEY.TAB:
-          if (!ctrl.multiple || ctrl.open) ctrl.select(ctrl.items[ctrl.activeIndex], true);
-          break;
-        case KEY.ENTER:
-          if(ctrl.open && ctrl.activeIndex >= 0){
-            ctrl.select(ctrl.items[ctrl.activeIndex]); // Make sure at least one dropdown item is highlighted before adding.
-          } else {
-            ctrl.activate(false, true); //In case its the search input in 'multiple' mode
+        case KEY.RIGHT:
+          // Open drop-down
+          if(!~ctrl.activeMatchIndex || curr === last){
+            ctrl.activate();
+            return false;
           }
+          // Select next/last item
+          else return next;
           break;
-        case KEY.ESC:
-          ctrl.close();
+        case KEY.BACKSPACE:
+          // Remove selected item and select previous/first
+          if(~ctrl.activeMatchIndex){
+            ctrl.removeChoice(curr);
+            return prev;
+          }
+          // Select last item
+          else return last;
           break;
-        default:
-          processed = false;
+        case KEY.DELETE:
+          // Remove selected item and select next item
+          if(~ctrl.activeMatchIndex){
+            ctrl.removeChoice(ctrl.activeMatchIndex);
+            return curr;
+          }
+          else return false;
       }
-      return processed;
     }
 
-    // Handles selected options in "multiple" mode
-    function _handleMatchSelection(key){
-      var caretPosition = _getCaretPosition(_searchInput[0]),
-          length = ctrl.selected.length,
-          // none  = -1,
-          first = 0,
-          last  = length-1,
-          curr  = ctrl.activeMatchIndex,
-          next  = ctrl.activeMatchIndex+1,
-          prev  = ctrl.activeMatchIndex-1,
-          newIndex = curr;
-
-      if(caretPosition > 0 || (ctrl.search.length && key == KEY.RIGHT)) return false;
-
-      ctrl.close();
-
-      function getNewActiveMatchIndex(){
-        switch(key){
-          case KEY.LEFT:
-            // Select previous/first item
-            if(~ctrl.activeMatchIndex) return prev;
-            // Select last item
-            else return last;
-            break;
-          case KEY.RIGHT:
-            // Open drop-down
-            if(!~ctrl.activeMatchIndex || curr === last){
-              ctrl.activate();
-              return false;
-            }
-            // Select next/last item
-            else return next;
-            break;
-          case KEY.BACKSPACE:
-            // Remove selected item and select previous/first
-            if(~ctrl.activeMatchIndex){
-              ctrl.removeChoice(curr);
-              return prev;
-            }
-            // Select last item
-            else return last;
-            break;
-          case KEY.DELETE:
-            // Remove selected item and select next item
-            if(~ctrl.activeMatchIndex){
-              ctrl.removeChoice(ctrl.activeMatchIndex);
-              return curr;
-            }
-            else return false;
-        }
-      }
-
-      newIndex = getNewActiveMatchIndex();
+    newIndex = getNewActiveMatchIndex();
 
-      if(!ctrl.selected.length || newIndex === false) ctrl.activeMatchIndex = -1;
-      else ctrl.activeMatchIndex = Math.min(last,Math.max(first,newIndex));
+    if(!ctrl.selected.length || newIndex === false) ctrl.activeMatchIndex = -1;
+    else ctrl.activeMatchIndex = Math.min(last,Math.max(first,newIndex));
 
-      return true;
-    }
+    return true;
+  }
 
-    // Bind to keyboard shortcuts
-    _searchInput.on('keydown', function(e) {
+  // Bind to keyboard shortcuts
+  _searchInput.on('keydown', function(e) {
 
-      var key = e.which;
+    var key = e.which;
 
-      // if(~[KEY.ESC,KEY.TAB].indexOf(key)){
-      //   //TODO: SEGURO?
-      //   ctrl.close();
-      // }
+    // if(~[KEY.ESC,KEY.TAB].indexOf(key)){
+    //   //TODO: SEGURO?
+    //   ctrl.close();
+    // }
 
-      $scope.$apply(function() {
-        var processed = false;
-        var tagged = false;
+    $scope.$apply(function() {
+      var processed = false;
+      var tagged = false;
 
-        if(ctrl.multiple && KEY.isHorizontalMovement(key)){
-          processed = _handleMatchSelection(key);
-        }
+      if(ctrl.multiple && KEY.isHorizontalMovement(key)){
+        processed = _handleMatchSelection(key);
+      }
 
-        if (!processed && (ctrl.items.length > 0 || ctrl.tagging.isActivated)) {
-          processed = _handleDropDownSelection(key);
-          if ( ctrl.taggingTokens.isActivated ) {
-            for (var i = 0; i < ctrl.taggingTokens.tokens.length; i++) {
-              if ( ctrl.taggingTokens.tokens[i] === KEY.MAP[e.keyCode] ) {
-                // make sure there is a new value to push via tagging
-                if ( ctrl.search.length > 0 ) {
-                  tagged = true;
-                }
+      if (!processed && (ctrl.items.length > 0 || ctrl.tagging.isActivated)) {
+        processed = _handleDropDownSelection(key);
+        if ( ctrl.taggingTokens.isActivated ) {
+          for (var i = 0; i < ctrl.taggingTokens.tokens.length; i++) {
+            if ( ctrl.taggingTokens.tokens[i] === KEY.MAP[e.keyCode] ) {
+              // make sure there is a new value to push via tagging
+              if ( ctrl.search.length > 0 ) {
+                tagged = true;
               }
             }
-            if ( tagged ) {
-              $timeout(function() {
-                _searchInput.triggerHandler('tagged');
-                var newItem = ctrl.search.replace(KEY.MAP[e.keyCode],'').trim();
-                if ( ctrl.tagging.fct ) {
-                  newItem = ctrl.tagging.fct( newItem );
-                }
-                if (newItem) ctrl.select(newItem, true);
-              });
-            }
+          }
+          if ( tagged ) {
+            $timeout(function() {
+              _searchInput.triggerHandler('tagged');
+              var newItem = ctrl.search.replace(KEY.MAP[e.keyCode],'').trim();
+              if ( ctrl.tagging.fct ) {
+                newItem = ctrl.tagging.fct( newItem );
+              }
+              if (newItem) ctrl.select(newItem, true);
+            });
           }
         }
-
-        if (processed  && key != KEY.TAB) {
-          //TODO Check si el tab selecciona aun correctamente
-          //Crear test
-          e.preventDefault();
-          e.stopPropagation();
-        }
-      });
-
-      if(KEY.isVerticalMovement(key) && ctrl.items.length > 0){
-        _ensureHighlightVisible();
       }
 
-    });
-
-    // If tagging try to split by tokens and add items
-    _searchInput.on('paste', function (e) {
-      var data = e.originalEvent.clipboardData.getData('text/plain');
-      if (data && data.length > 0 && ctrl.taggingTokens.isActivated && ctrl.tagging.fct) {
-        var items = data.split(ctrl.taggingTokens.tokens[0]); // split by first token only
-        if (items && items.length > 0) {
-          angular.forEach(items, function (item) {
-            var newItem = ctrl.tagging.fct(item);
-            if (newItem) {
-              ctrl.select(newItem, true);
-            }
-          });
-          e.preventDefault();
-          e.stopPropagation();
-        }
+      if (processed  && key != KEY.TAB) {
+        //TODO Check si el tab selecciona aun correctamente
+        //Crear test
+        e.preventDefault();
+        e.stopPropagation();
       }
     });
 
-    _searchInput.on('keyup', function(e) {
-      if ( ! KEY.isVerticalMovement(e.which) ) {
-        $scope.$evalAsync( function () {
-          ctrl.activeIndex = ctrl.taggingLabel === false ? -1 : 0;
+    if(KEY.isVerticalMovement(key) && ctrl.items.length > 0){
+      _ensureHighlightVisible();
+    }
+
+  });
+
+  // If tagging try to split by tokens and add items
+  _searchInput.on('paste', function (e) {
+    var data = e.originalEvent.clipboardData.getData('text/plain');
+    if (data && data.length > 0 && ctrl.taggingTokens.isActivated && ctrl.tagging.fct) {
+      var items = data.split(ctrl.taggingTokens.tokens[0]); // split by first token only
+      if (items && items.length > 0) {
+        angular.forEach(items, function (item) {
+          var newItem = ctrl.tagging.fct(item);
+          if (newItem) {
+            ctrl.select(newItem, true);
+          }
         });
+        e.preventDefault();
+        e.stopPropagation();
       }
-      // Push a "create new" item into array if there is a search string
-      if ( ctrl.tagging.isActivated && ctrl.search.length > 0 ) {
+    }
+  });
+
+  _searchInput.on('keyup', function(e) {
+    if ( ! KEY.isVerticalMovement(e.which) ) {
+      $scope.$evalAsync( function () {
+        ctrl.activeIndex = ctrl.taggingLabel === false ? -1 : 0;
+      });
+    }
+    // Push a "create new" item into array if there is a search string
+    if ( ctrl.tagging.isActivated && ctrl.search.length > 0 ) {
 
-        // return early with these keys
-        if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC || KEY.isVerticalMovement(e.which) ) {
+      // return early with these keys
+      if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC || KEY.isVerticalMovement(e.which) ) {
+        return;
+      }
+      // always reset the activeIndex to the first item when tagging
+      ctrl.activeIndex = ctrl.taggingLabel === false ? -1 : 0;
+      // taggingLabel === false bypasses all of this
+      if (ctrl.taggingLabel === false) return;
+
+      var items = angular.copy( ctrl.items );
+      var stashArr = angular.copy( ctrl.items );
+      var newItem;
+      var item;
+      var hasTag = false;
+      var dupeIndex = -1;
+      var tagItems;
+      var tagItem;
+
+      // case for object tagging via transform `ctrl.tagging.fct` function
+      if ( ctrl.tagging.fct !== undefined) {
+        tagItems = ctrl.$filter('filter')(items,{'isTag': true});
+        if ( tagItems.length > 0 ) {
+          tagItem = tagItems[0];
+        }
+        // remove the first element, if it has the `isTag` prop we generate a new one with each keyup, shaving the previous
+        if ( items.length > 0 && tagItem ) {
+          hasTag = true;
+          items = items.slice(1,items.length);
+          stashArr = stashArr.slice(1,stashArr.length);
+        }
+        newItem = ctrl.tagging.fct(ctrl.search);
+        newItem.isTag = true;
+        // verify the the tag doesn't match the value of an existing item
+        if ( stashArr.filter( function (origItem) { return angular.equals( origItem, ctrl.tagging.fct(ctrl.search) ); } ).length > 0 ) {
           return;
         }
-        // always reset the activeIndex to the first item when tagging
-        ctrl.activeIndex = ctrl.taggingLabel === false ? -1 : 0;
-        // taggingLabel === false bypasses all of this
-        if (ctrl.taggingLabel === false) return;
-
-        var items = angular.copy( ctrl.items );
-        var stashArr = angular.copy( ctrl.items );
-        var newItem;
-        var item;
-        var hasTag = false;
-        var dupeIndex = -1;
-        var tagItems;
-        var tagItem;
-
-        // case for object tagging via transform `ctrl.tagging.fct` function
-        if ( ctrl.tagging.fct !== undefined) {
-          tagItems = ctrl.$filter('filter')(items,{'isTag': true});
-          if ( tagItems.length > 0 ) {
-            tagItem = tagItems[0];
-          }
-          // remove the first element, if it has the `isTag` prop we generate a new one with each keyup, shaving the previous
-          if ( items.length > 0 && tagItem ) {
-            hasTag = true;
-            items = items.slice(1,items.length);
-            stashArr = stashArr.slice(1,stashArr.length);
-          }
-          newItem = ctrl.tagging.fct(ctrl.search);
-          newItem.isTag = true;
-          // verify the the tag doesn't match the value of an existing item
-          if ( stashArr.filter( function (origItem) { return angular.equals( origItem, ctrl.tagging.fct(ctrl.search) ); } ).length > 0 ) {
-            return;
-          }
-          newItem.isTag = true;
-        // handle newItem string and stripping dupes in tagging string context
-        } else {
-          // find any tagging items already in the ctrl.items array and store them
-          tagItems = ctrl.$filter('filter')(items,function (item) {
-            return item.match(ctrl.taggingLabel);
-          });
-          if ( tagItems.length > 0 ) {
-            tagItem = tagItems[0];
-          }
-          item = items[0];
-          // remove existing tag item if found (should only ever be one tag item)
-          if ( item !== undefined && items.length > 0 && tagItem ) {
-            hasTag = true;
-            items = items.slice(1,items.length);
-            stashArr = stashArr.slice(1,stashArr.length);
-          }
-          newItem = ctrl.search+' '+ctrl.taggingLabel;
-          if ( _findApproxDupe(ctrl.selected, ctrl.search) > -1 ) {
-            return;
-          }
-          // verify the the tag doesn't match the value of an existing item from
-          // the searched data set or the items already selected
-          if ( _findCaseInsensitiveDupe(stashArr.concat(ctrl.selected)) ) {
-            // if there is a tag from prev iteration, strip it / queue the change
-            // and return early
-            if ( hasTag ) {
-              items = stashArr;
-              $scope.$evalAsync( function () {
-                ctrl.activeIndex = 0;
-                ctrl.items = items;
-              });
-            }
-            return;
-          }
-          if ( _findCaseInsensitiveDupe(stashArr) ) {
-            // if there is a tag from prev iteration, strip it
-            if ( hasTag ) {
-              ctrl.items = stashArr.slice(1,stashArr.length);
-            }
-            return;
+        newItem.isTag = true;
+      // handle newItem string and stripping dupes in tagging string context
+      } else {
+        // find any tagging items already in the ctrl.items array and store them
+        tagItems = ctrl.$filter('filter')(items,function (item) {
+          return item.match(ctrl.taggingLabel);
+        });
+        if ( tagItems.length > 0 ) {
+          tagItem = tagItems[0];
+        }
+        item = items[0];
+        // remove existing tag item if found (should only ever be one tag item)
+        if ( item !== undefined && items.length > 0 && tagItem ) {
+          hasTag = true;
+          items = items.slice(1,items.length);
+          stashArr = stashArr.slice(1,stashArr.length);
+        }
+        newItem = ctrl.search+' '+ctrl.taggingLabel;
+        if ( _findApproxDupe(ctrl.selected, ctrl.search) > -1 ) {
+          return;
+        }
+        // verify the the tag doesn't match the value of an existing item from
+        // the searched data set or the items already selected
+        if ( _findCaseInsensitiveDupe(stashArr.concat(ctrl.selected)) ) {
+          // if there is a tag from prev iteration, strip it / queue the change
+          // and return early
+          if ( hasTag ) {
+            items = stashArr;
+            $scope.$evalAsync( function () {
+              ctrl.activeIndex = 0;
+              ctrl.items = items;
+            });
           }
+          return;
         }
-        if ( hasTag ) dupeIndex = _findApproxDupe(ctrl.selected, newItem);
-        // dupe found, shave the first item
-        if ( dupeIndex > -1 ) {
-          items = items.slice(dupeIndex+1,items.length-1);
-        } else {
-          items = [];
-          items.push(newItem);
-          items = items.concat(stashArr);
+        if ( _findCaseInsensitiveDupe(stashArr) ) {
+          // if there is a tag from prev iteration, strip it
+          if ( hasTag ) {
+            ctrl.items = stashArr.slice(1,stashArr.length);
+          }
+          return;
         }
-        $scope.$evalAsync( function () {
-          ctrl.activeIndex = 0;
-          ctrl.items = items;
-        });
       }
-    });
-
-    _searchInput.on('tagged', function() {
-      $timeout(function() {
-        _resetSearchInput();
+      if ( hasTag ) dupeIndex = _findApproxDupe(ctrl.selected, newItem);
+      // dupe found, shave the first item
+      if ( dupeIndex > -1 ) {
+        items = items.slice(dupeIndex+1,items.length-1);
+      } else {
+        items = [];
+        items.push(newItem);
+        items = items.concat(stashArr);
+      }
+      $scope.$evalAsync( function () {
+        ctrl.activeIndex = 0;
+        ctrl.items = items;
       });
+    }
+  });
+
+  _searchInput.on('tagged', function() {
+    $timeout(function() {
+      _resetSearchInput();
     });
+  });
 
-    _searchInput.on('blur', function() {
-      $timeout(function() {
-        ctrl.activeMatchIndex = -1;
-      });
+  _searchInput.on('blur', function() {
+    $timeout(function() {
+      ctrl.activeMatchIndex = -1;
     });
+  });
 
-    function _findCaseInsensitiveDupe(arr) {
-      if ( arr === undefined || ctrl.search === undefined ) {
+  function _findCaseInsensitiveDupe(arr) {
+    if ( arr === undefined || ctrl.search === undefined ) {
+      return false;
+    }
+    var hasDupe = arr.filter( function (origItem) {
+      if ( ctrl.search.toUpperCase() === undefined || origItem === undefined ) {
         return false;
       }
-      var hasDupe = arr.filter( function (origItem) {
-        if ( ctrl.search.toUpperCase() === undefined || origItem === undefined ) {
-          return false;
-        }
-        return origItem.toUpperCase() === ctrl.search.toUpperCase();
-      }).length > 0;
+      return origItem.toUpperCase() === ctrl.search.toUpperCase();
+    }).length > 0;
 
-      return hasDupe;
-    }
+    return hasDupe;
+  }
 
-    function _findApproxDupe(haystack, needle) {
-      var dupeIndex = -1;
-	  if(angular.isArray(haystack)) {
-		  var tempArr = angular.copy(haystack);
-		  for (var i = 0; i <tempArr.length; i++) {
-			// handle the simple string version of tagging
-			if ( ctrl.tagging.fct === undefined ) {
-			  // search the array for the match
-			  if ( tempArr[i]+' '+ctrl.taggingLabel === needle ) {
-				dupeIndex = i;
-			  }
-			// handle the object tagging implementation
-			} else {
-			  var mockObj = tempArr[i];
-			  mockObj.isTag = true;
-			  if ( angular.equals(mockObj, needle) ) {
-				dupeIndex = i;
-			  }
-			}
-		  }
-	  }
-      return dupeIndex;
+  function _findApproxDupe(haystack, needle) {
+    var dupeIndex = -1;
+  if(angular.isArray(haystack)) {
+    var tempArr = angular.copy(haystack);
+    for (var i = 0; i <tempArr.length; i++) {
+    // handle the simple string version of tagging
+    if ( ctrl.tagging.fct === undefined ) {
+      // search the array for the match
+      if ( tempArr[i]+' '+ctrl.taggingLabel === needle ) {
+      dupeIndex = i;
+      }
+    // handle the object tagging implementation
+    } else {
+      var mockObj = tempArr[i];
+      mockObj.isTag = true;
+      if ( angular.equals(mockObj, needle) ) {
+      dupeIndex = i;
+      }
     }
-
-    function _getCaretPosition(el) {
-      if(angular.isNumber(el.selectionStart)) return el.selectionStart;
-      // selectionStart is not supported in IE8 and we don't want hacky workarounds so we compromise
-      else return el.value.length;
     }
+  }
+    return dupeIndex;
+  }
 
-    // See https://github.com/ivaynberg/select2/blob/3.4.6/select2.js#L1431
-    function _ensureHighlightVisible() {
-      var container = $element.querySelectorAll('.ui-select-choices-content');
-      var choices = container.querySelectorAll('.ui-select-choices-row');
-      if (choices.length < 1) {
-        throw uiSelectMinErr('choices', "Expected multiple .ui-select-choices-row but got '{0}'.", choices.length);
-      }
+  function _getCaretPosition(el) {
+    if(angular.isNumber(el.selectionStart)) return el.selectionStart;
+    // selectionStart is not supported in IE8 and we don't want hacky workarounds so we compromise
+    else return el.value.length;
+  }
 
-      if (ctrl.activeIndex < 0) {
-        return;
-      }
+  // See https://github.com/ivaynberg/select2/blob/3.4.6/select2.js#L1431
+  function _ensureHighlightVisible() {
+    var container = $element.querySelectorAll('.ui-select-choices-content');
+    var choices = container.querySelectorAll('.ui-select-choices-row');
+    if (choices.length < 1) {
+      throw uiSelectMinErr('choices', "Expected multiple .ui-select-choices-row but got '{0}'.", choices.length);
+    }
 
-      var highlighted = choices[ctrl.activeIndex];
-      var posY = highlighted.offsetTop + highlighted.clientHeight - container[0].scrollTop;
-      var height = container[0].offsetHeight;
+    if (ctrl.activeIndex < 0) {
+      return;
+    }
 
-      if (posY > height) {
-        container[0].scrollTop += posY - height;
-      } else if (posY < highlighted.clientHeight) {
-        if (ctrl.isGrouped && ctrl.activeIndex === 0)
-          container[0].scrollTop = 0; //To make group header visible when going all the way up
-        else
-          container[0].scrollTop -= highlighted.clientHeight - posY;
-      }
+    var highlighted = choices[ctrl.activeIndex];
+    var posY = highlighted.offsetTop + highlighted.clientHeight - container[0].scrollTop;
+    var height = container[0].offsetHeight;
+
+    if (posY > height) {
+      container[0].scrollTop += posY - height;
+    } else if (posY < highlighted.clientHeight) {
+      if (ctrl.isGrouped && ctrl.activeIndex === 0)
+        container[0].scrollTop = 0; //To make group header visible when going all the way up
+      else
+        container[0].scrollTop -= highlighted.clientHeight - posY;
     }
+  }
 
-    $scope.$on('$destroy', function() {
-      _searchInput.off('keyup keydown tagged blur paste');
-    });
-  }])
+  $scope.$on('$destroy', function() {
+    _searchInput.off('keyup keydown tagged blur paste');
+  });
+}]);
 
-  .directive('uiSelect',
-    ['$document', 'uiSelectConfig', 'uiSelectMinErr', '$compile', '$parse',
-    function($document, uiSelectConfig, uiSelectMinErr, $compile, $parse) {
+uis.directive('uiSelect',
+  ['$document', 'uiSelectConfig', 'uiSelectMinErr', '$compile', '$parse',
+  function($document, uiSelectConfig, uiSelectMinErr, $compile, $parse) {
 
-    return {
-      restrict: 'EA',
-      templateUrl: function(tElement, tAttrs) {
-        var theme = tAttrs.theme || uiSelectConfig.theme;
-        return theme + (angular.isDefined(tAttrs.multiple) ? '/select-multiple.tpl.html' : '/select.tpl.html');
-      },
-      replace: true,
-      transclude: true,
-      require: ['uiSelect', '^ngModel'],
-      scope: true,
-
-      controller: 'uiSelectCtrl',
-      controllerAs: '$select',
-
-      link: function(scope, element, attrs, ctrls, transcludeFn) {
-        var $select = ctrls[0];
-        var ngModel = ctrls[1];
-
-        var searchInput = element.querySelectorAll('input.ui-select-search');
-
-        $select.generatedId = uiSelectConfig.generateId();
-        $select.baseTitle = attrs.title || 'Select box';
-        $select.focusserTitle = $select.baseTitle + ' focus';
-        $select.focusserId = 'focusser-' + $select.generatedId;
-
-        $select.multiple = angular.isDefined(attrs.multiple) && (
-            attrs.multiple === '' ||
-            attrs.multiple.toLowerCase() === 'multiple' ||
-            attrs.multiple.toLowerCase() === 'true'
-        );
-
-        $select.closeOnSelect = function() {
-          if (angular.isDefined(attrs.closeOnSelect)) {
-            return $parse(attrs.closeOnSelect)();
-          } else {
-            return uiSelectConfig.closeOnSelect;
-          }
-        }();
+  return {
+    restrict: 'EA',
+    templateUrl: function(tElement, tAttrs) {
+      var theme = tAttrs.theme || uiSelectConfig.theme;
+      return theme + (angular.isDefined(tAttrs.multiple) ? '/select-multiple.tpl.html' : '/select.tpl.html');
+    },
+    replace: true,
+    transclude: true,
+    require: ['uiSelect', '^ngModel'],
+    scope: true,
+
+    controller: 'uiSelectCtrl',
+    controllerAs: '$select',
+
+    link: function(scope, element, attrs, ctrls, transcludeFn) {
+      var $select = ctrls[0];
+      var ngModel = ctrls[1];
+
+      var searchInput = element.querySelectorAll('input.ui-select-search');
+
+      $select.generatedId = uiSelectConfig.generateId();
+      $select.baseTitle = attrs.title || 'Select box';
+      $select.focusserTitle = $select.baseTitle + ' focus';
+      $select.focusserId = 'focusser-' + $select.generatedId;
+
+      $select.multiple = angular.isDefined(attrs.multiple) && (
+          attrs.multiple === '' ||
+          attrs.multiple.toLowerCase() === 'multiple' ||
+          attrs.multiple.toLowerCase() === 'true'
+      );
+
+      $select.closeOnSelect = function() {
+        if (angular.isDefined(attrs.closeOnSelect)) {
+          return $parse(attrs.closeOnSelect)();
+        } else {
+          return uiSelectConfig.closeOnSelect;
+        }
+      }();
 
-        $select.onSelectCallback = $parse(attrs.onSelect);
-        $select.onRemoveCallback = $parse(attrs.onRemove);
+      $select.onSelectCallback = $parse(attrs.onSelect);
+      $select.onRemoveCallback = $parse(attrs.onRemove);
 
-        //From view --> model
-        ngModel.$parsers.unshift(function (inputValue) {
-          var locals = {},
-              result;
-          if ($select.multiple){
-            var resultMultiple = [];
-            for (var j = $select.selected.length - 1; j >= 0; j--) {
-              locals = {};
-              locals[$select.parserResult.itemName] = $select.selected[j];
-              result = $select.parserResult.modelMapper(scope, locals);
-              resultMultiple.unshift(result);
-            }
-            return resultMultiple;
-          }else{
+      //From view --> model
+      ngModel.$parsers.unshift(function (inputValue) {
+        var locals = {},
+            result;
+        if ($select.multiple){
+          var resultMultiple = [];
+          for (var j = $select.selected.length - 1; j >= 0; j--) {
             locals = {};
-            locals[$select.parserResult.itemName] = inputValue;
+            locals[$select.parserResult.itemName] = $select.selected[j];
             result = $select.parserResult.modelMapper(scope, locals);
-            return result;
+            resultMultiple.unshift(result);
           }
-        });
+          return resultMultiple;
+        }else{
+          locals = {};
+          locals[$select.parserResult.itemName] = inputValue;
+          result = $select.parserResult.modelMapper(scope, locals);
+          return result;
+        }
+      });
 
-        //From model --> view
-        ngModel.$formatters.unshift(function (inputValue) {
-          var data = $select.parserResult.source (scope, { $select : {search:''}}), //Overwrite $search
-              locals = {},
-              result;
-          if (data){
-            if ($select.multiple){
-              var resultMultiple = [];
-              var checkFnMultiple = function(list, value){
-                //if the list is empty add the value to the list
-                if (!list || !list.length){
-                    resultMultiple.unshift(value);
-                    return true;
-                }
-                for (var p = list.length - 1; p >= 0; p--) {
-                  locals[$select.parserResult.itemName] = list[p];
-                  result = $select.parserResult.modelMapper(scope, locals);
-                  if($select.parserResult.trackByExp){
-                      var matches = /\.(.+)/.exec($select.parserResult.trackByExp);
-                      if(matches.length>0 && result[matches[1]] == value[matches[1]]){
-                          resultMultiple.unshift(list[p]);
-                          return true;
-                      }
-                  }
-                  if (result == value){
-                    resultMultiple.unshift(list[p]);
-                    return true;
-                  }
-                }
-                return false;
-              };
-              if (!inputValue) return resultMultiple; //If ngModel was undefined
-              for (var k = inputValue.length - 1; k >= 0; k--) {
-                if (!checkFnMultiple($select.selected, inputValue[k])){
-                  checkFnMultiple(data, inputValue[k]);
-                }
+      //From model --> view
+      ngModel.$formatters.unshift(function (inputValue) {
+        var data = $select.parserResult.source (scope, { $select : {search:''}}), //Overwrite $search
+            locals = {},
+            result;
+        if (data){
+          if ($select.multiple){
+            var resultMultiple = [];
+            var checkFnMultiple = function(list, value){
+              //if the list is empty add the value to the list
+              if (!list || !list.length){
+                  resultMultiple.unshift(value);
+                  return true;
               }
-              return resultMultiple;
-            }else{
-              var checkFnSingle = function(d){
-                locals[$select.parserResult.itemName] = d;
+              for (var p = list.length - 1; p >= 0; p--) {
+                locals[$select.parserResult.itemName] = list[p];
                 result = $select.parserResult.modelMapper(scope, locals);
-                return result == inputValue;
-              };
-              //If possible pass same object stored in $select.selected
-              if ($select.selected && checkFnSingle($select.selected)) {
-                return $select.selected;
+                if($select.parserResult.trackByExp){
+                    var matches = /\.(.+)/.exec($select.parserResult.trackByExp);
+                    if(matches.length>0 && result[matches[1]] == value[matches[1]]){
+                        resultMultiple.unshift(list[p]);
+                        return true;
+                    }
+                }
+                if (result == value){
+                  resultMultiple.unshift(list[p]);
+                  return true;
+                }
               }
-              for (var i = data.length - 1; i >= 0; i--) {
-                if (checkFnSingle(data[i])) return data[i];
+              return false;
+            };
+            if (!inputValue) return resultMultiple; //If ngModel was undefined
+            for (var k = inputValue.length - 1; k >= 0; k--) {
+              if (!checkFnMultiple($select.selected, inputValue[k])){
+                checkFnMultiple(data, inputValue[k]);
               }
             }
+            return resultMultiple;
+          }else{
+            var checkFnSingle = function(d){
+              locals[$select.parserResult.itemName] = d;
+              result = $select.parserResult.modelMapper(scope, locals);
+              return result == inputValue;
+            };
+            //If possible pass same object stored in $select.selected
+            if ($select.selected && checkFnSingle($select.selected)) {
+              return $select.selected;
+            }
+            for (var i = data.length - 1; i >= 0; i--) {
+              if (checkFnSingle(data[i])) return data[i];
+            }
           }
-          return inputValue;
-        });
+        }
+        return inputValue;
+      });
 
-        //Set reference to ngModel from uiSelectCtrl
-        $select.ngModel = ngModel;
+      //Set reference to ngModel from uiSelectCtrl
+      $select.ngModel = ngModel;
 
-        $select.choiceGrouped = function(group){
-          return $select.isGrouped && group && group.name;
-        };
+      $select.choiceGrouped = function(group){
+        return $select.isGrouped && group && group.name;
+      };
 
-        //Idea from: https://github.com/ivaynberg/select2/blob/79b5bf6db918d7560bdd959109b7bcfb47edaf43/select2.js#L1954
-        var focusser = angular.element("<input ng-disabled='$select.disabled' class='ui-select-focusser ui-select-offscreen' type='text' id='{{ $select.focusserId }}' aria-label='{{ $select.focusserTitle }}' aria-haspopup='true' role='button' />");
+      //Idea from: https://github.com/ivaynberg/select2/blob/79b5bf6db918d7560bdd959109b7bcfb47edaf43/select2.js#L1954
+      var focusser = angular.element("<input ng-disabled='$select.disabled' class='ui-select-focusser ui-select-offscreen' type='text' id='{{ $select.focusserId }}' aria-label='{{ $select.focusserTitle }}' aria-haspopup='true' role='button' />");
 
-        if(attrs.tabindex){
-          //tabindex might be an expression, wait until it contains the actual value before we set the focusser tabindex
-          attrs.$observe('tabindex', function(value) {
-            //If we are using multiple, add tabindex to the search input
-            if($select.multiple){
-              searchInput.attr("tabindex", value);
-            } else {
-              focusser.attr("tabindex", value);
-            }
-            //Remove the tabindex on the parent so that it is not focusable
-            element.removeAttr("tabindex");
-          });
-        }
+      if(attrs.tabindex){
+        //tabindex might be an expression, wait until it contains the actual value before we set the focusser tabindex
+        attrs.$observe('tabindex', function(value) {
+          //If we are using multiple, add tabindex to the search input
+          if($select.multiple){
+            searchInput.attr("tabindex", value);
+          } else {
+            focusser.attr("tabindex", value);
+          }
+          //Remove the tabindex on the parent so that it is not focusable
+          element.removeAttr("tabindex");
+        });
+      }
 
-        $compile(focusser)(scope);
-        $select.focusser = focusser;
+      $compile(focusser)(scope);
+      $select.focusser = focusser;
 
-        if (!$select.multiple){
+      if (!$select.multiple){
 
-          element.append(focusser);
-          focusser.bind("focus", function(){
-            scope.$evalAsync(function(){
-              $select.focus = true;
-            });
+        element.append(focusser);
+        focusser.bind("focus", function(){
+          scope.$evalAsync(function(){
+            $select.focus = true;
           });
-          focusser.bind("blur", function(){
-            scope.$evalAsync(function(){
-              $select.focus = false;
-            });
+        });
+        focusser.bind("blur", function(){
+          scope.$evalAsync(function(){
+            $select.focus = false;
           });
-          focusser.bind("keydown", function(e){
-
-            if (e.which === KEY.BACKSPACE) {
-              e.preventDefault();
-              e.stopPropagation();
-              $select.select(undefined);
-              scope.$apply();
-              return;
-            }
+        });
+        focusser.bind("keydown", function(e){
 
-            if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC) {
-              return;
-            }
+          if (e.which === KEY.BACKSPACE) {
+            e.preventDefault();
+            e.stopPropagation();
+            $select.select(undefined);
+            scope.$apply();
+            return;
+          }
 
-            if (e.which == KEY.DOWN  || e.which == KEY.UP || e.which == KEY.ENTER || e.which == KEY.SPACE){
-              e.preventDefault();
-              e.stopPropagation();
-              $select.activate();
-            }
+          if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC) {
+            return;
+          }
 
-            scope.$digest();
-          });
+          if (e.which == KEY.DOWN  || e.which == KEY.UP || e.which == KEY.ENTER || e.which == KEY.SPACE){
+            e.preventDefault();
+            e.stopPropagation();
+            $select.activate();
+          }
 
-          focusser.bind("keyup input", function(e){
+          scope.$digest();
+        });
 
-            if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC || e.which == KEY.ENTER || e.which === KEY.BACKSPACE) {
-              return;
-            }
+        focusser.bind("keyup input", function(e){
 
-            $select.activate(focusser.val()); //User pressed some regular key, so we pass it to the search input
-            focusser.val('');
-            scope.$digest();
+          if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC || e.which == KEY.ENTER || e.which === KEY.BACKSPACE) {
+            return;
+          }
 
-          });
+          $select.activate(focusser.val()); //User pressed some regular key, so we pass it to the search input
+          focusser.val('');
+          scope.$digest();
 
-        }
+        });
 
+      }
 
-        scope.$watch('searchEnabled', function() {
-            var searchEnabled = scope.$eval(attrs.searchEnabled);
-            $select.searchEnabled = searchEnabled !== undefined ? searchEnabled : uiSelectConfig.searchEnabled;
-        });
 
-        attrs.$observe('disabled', function() {
-          // No need to use $eval() (thanks to ng-disabled) since we already get a boolean instead of a string
-          $select.disabled = attrs.disabled !== undefined ? attrs.disabled : false;
-        });
+      scope.$watch('searchEnabled', function() {
+          var searchEnabled = scope.$eval(attrs.searchEnabled);
+          $select.searchEnabled = searchEnabled !== undefined ? searchEnabled : uiSelectConfig.searchEnabled;
+      });
 
-        attrs.$observe('resetSearchInput', function() {
+      scope.$watch('sortable', function() {
+          var sortable = scope.$eval(attrs.sortable);
+          $select.sortable = sortable !== undefined ? sortable : uiSelectConfig.sortable;
+      });
+
+      attrs.$observe('disabled', function() {
+        // No need to use $eval() (thanks to ng-disabled) since we already get a boolean instead of a string
+        $select.disabled = attrs.disabled !== undefined ? attrs.disabled : false;
+      });
+
+      attrs.$observe('resetSearchInput', function() {
+        // $eval() is needed otherwise we get a string instead of a boolean
+        var resetSearchInput = scope.$eval(attrs.resetSearchInput);
+        $select.resetSearchInput = resetSearchInput !== undefined ? resetSearchInput : true;
+      });
+
+      attrs.$observe('tagging', function() {
+        if(attrs.tagging !== undefined)
+        {
           // $eval() is needed otherwise we get a string instead of a boolean
-          var resetSearchInput = scope.$eval(attrs.resetSearchInput);
-          $select.resetSearchInput = resetSearchInput !== undefined ? resetSearchInput : true;
-        });
+          var taggingEval = scope.$eval(attrs.tagging);
+          $select.tagging = {isActivated: true, fct: taggingEval !== true ? taggingEval : undefined};
+        }
+        else
+        {
+          $select.tagging = {isActivated: false, fct: undefined};
+        }
+      });
 
-        attrs.$observe('tagging', function() {
-          if(attrs.tagging !== undefined)
-          {
-            // $eval() is needed otherwise we get a string instead of a boolean
-            var taggingEval = scope.$eval(attrs.tagging);
-            $select.tagging = {isActivated: true, fct: taggingEval !== true ? taggingEval : undefined};
+      attrs.$observe('taggingLabel', function() {
+        if(attrs.tagging !== undefined )
+        {
+          // check eval for FALSE, in this case, we disable the labels
+          // associated with tagging
+          if ( attrs.taggingLabel === 'false' ) {
+            $select.taggingLabel = false;
           }
           else
           {
-            $select.tagging = {isActivated: false, fct: undefined};
+            $select.taggingLabel = attrs.taggingLabel !== undefined ? attrs.taggingLabel : '(new)';
           }
-        });
+        }
+      });
 
-        attrs.$observe('taggingLabel', function() {
-          if(attrs.tagging !== undefined )
-          {
-            // check eval for FALSE, in this case, we disable the labels
-            // associated with tagging
-            if ( attrs.taggingLabel === 'false' ) {
-              $select.taggingLabel = false;
-            }
-            else
-            {
-              $select.taggingLabel = attrs.taggingLabel !== undefined ? attrs.taggingLabel : '(new)';
-            }
+      attrs.$observe('taggingTokens', function() {
+        if (attrs.tagging !== undefined) {
+          var tokens = attrs.taggingTokens !== undefined ? attrs.taggingTokens.split('|') : [',','ENTER'];
+          $select.taggingTokens = {isActivated: true, tokens: tokens };
+        }
+      });
+
+      if ($select.multiple){
+        scope.$watchCollection(function(){ return ngModel.$modelValue; }, function(newValue, oldValue) {
+          if (oldValue != newValue)
+            ngModel.$modelValue = null; //Force scope model value and ngModel value to be out of sync to re-run formatters
+        });
+        $select.firstPass = true; // so the form doesn't get dirty as soon as it loads
+        scope.$watchCollection('$select.selected', function() {
+          if (!$select.firstPass) {
+            ngModel.$setViewValue(Date.now()); //Set timestamp as a unique string to force changes
+          } else {
+            $select.firstPass = false;
           }
         });
-
-        attrs.$observe('taggingTokens', function() {
-          if (attrs.tagging !== undefined) {
-            var tokens = attrs.taggingTokens !== undefined ? attrs.taggingTokens.split('|') : [',','ENTER'];
-            $select.taggingTokens = {isActivated: true, tokens: tokens };
+        focusser.prop('disabled', true); //Focusser isn't needed if multiple
+      }else{
+        scope.$watch('$select.selected', function(newValue) {
+          if (ngModel.$viewValue !== newValue) {
+            ngModel.$setViewValue(newValue);
           }
         });
+      }
 
-        if ($select.multiple){
-          scope.$watchCollection(function(){ return ngModel.$modelValue; }, function(newValue, oldValue) {
-            if (oldValue != newValue)
-              ngModel.$modelValue = null; //Force scope model value and ngModel value to be out of sync to re-run formatters
-          });
-          $select.firstPass = true; // so the form doesn't get dirty as soon as it loads
-          scope.$watchCollection('$select.selected', function() {
-            if (!$select.firstPass) {
-              ngModel.$setViewValue(Date.now()); //Set timestamp as a unique string to force changes
+      ngModel.$render = function() {
+        if($select.multiple){
+          // Make sure that model value is array
+          if(!angular.isArray(ngModel.$viewValue)){
+            // Have tolerance for null or undefined values
+            if(angular.isUndefined(ngModel.$viewValue) || ngModel.$viewValue === null){
+              $select.selected = [];
             } else {
-              $select.firstPass = false;
-            }
-          });
-          focusser.prop('disabled', true); //Focusser isn't needed if multiple
-        }else{
-          scope.$watch('$select.selected', function(newValue) {
-            if (ngModel.$viewValue !== newValue) {
-              ngModel.$setViewValue(newValue);
-            }
-          });
-        }
-
-        ngModel.$render = function() {
-          if($select.multiple){
-            // Make sure that model value is array
-            if(!angular.isArray(ngModel.$viewValue)){
-              // Have tolerance for null or undefined values
-              if(angular.isUndefined(ngModel.$viewValue) || ngModel.$viewValue === null){
-                $select.selected = [];
-              } else {
-                throw uiSelectMinErr('multiarr', "Expected model value to be array but got '{0}'", ngModel.$viewValue);
-              }
+              throw uiSelectMinErr('multiarr', "Expected model value to be array but got '{0}'", ngModel.$viewValue);
             }
           }
-          $select.selected = ngModel.$viewValue;
-        };
+        }
+        $select.selected = ngModel.$viewValue;
+      };
 
-        function onDocumentClick(e) {
-          if (!$select.open) return; //Skip it if dropdown is close
+      function onDocumentClick(e) {
+        if (!$select.open) return; //Skip it if dropdown is close
 
-          var contains = false;
+        var contains = false;
 
-          if (window.jQuery) {
-            // Firefox 3.6 does not support element.contains()
-            // See Node.contains https://developer.mozilla.org/en-US/docs/Web/API/Node.contains
-            contains = window.jQuery.contains(element[0], e.target);
-          } else {
-            contains = element[0].contains(e.target);
-          }
+        if (window.jQuery) {
+          // Firefox 3.6 does not support element.contains()
+          // See Node.contains https://developer.mozilla.org/en-US/docs/Web/API/Node.contains
+          contains = window.jQuery.contains(element[0], e.target);
+        } else {
+          contains = element[0].contains(e.target);
+        }
 
-          if (!contains && !$select.clickTriggeredSelect) {
-            //Will lose focus only with certain targets
-            var focusableControls = ['input','button','textarea'];
-            var targetScope = angular.element(e.target).scope(); //To check if target is other ui-select
-            var skipFocusser = targetScope && targetScope.$select && targetScope.$select !== $select; //To check if target is other ui-select
-            if (!skipFocusser) skipFocusser =  ~focusableControls.indexOf(e.target.tagName.toLowerCase()); //Check if target is input, button or textarea
-            $select.close(skipFocusser);
-            scope.$digest();
-          }
-          $select.clickTriggeredSelect = false;
+        if (!contains && !$select.clickTriggeredSelect) {
+          //Will lose focus only with certain targets
+          var focusableControls = ['input','button','textarea'];
+          var targetScope = angular.element(e.target).scope(); //To check if target is other ui-select
+          var skipFocusser = targetScope && targetScope.$select && targetScope.$select !== $select; //To check if target is other ui-select
+          if (!skipFocusser) skipFocusser =  ~focusableControls.indexOf(e.target.tagName.toLowerCase()); //Check if target is input, button or textarea
+          $select.close(skipFocusser);
+          scope.$digest();
         }
+        $select.clickTriggeredSelect = false;
+      }
 
-        // See Click everywhere but here event http://stackoverflow.com/questions/12931369
-        $document.on('click', onDocumentClick);
+      // See Click everywhere but here event http://stackoverflow.com/questions/12931369
+      $document.on('click', onDocumentClick);
 
-        scope.$on('$destroy', function() {
-          $document.off('click', onDocumentClick);
-        });
+      scope.$on('$destroy', function() {
+        $document.off('click', onDocumentClick);
+      });
 
-        // Move transcluded elements to their correct position in main template
-        transcludeFn(scope, function(clone) {
-          // See Transclude in AngularJS http://blog.omkarpatil.com/2012/11/transclude-in-angularjs.html
+      // Move transcluded elements to their correct position in main template
+      transcludeFn(scope, function(clone) {
+        // See Transclude in AngularJS http://blog.omkarpatil.com/2012/11/transclude-in-angularjs.html
 
-          // One day jqLite will be replaced by jQuery and we will be able to write:
-          // var transcludedElement = clone.filter('.my-class')
-          // instead of creating a hackish DOM element:
-          var transcluded = angular.element('<div>').append(clone);
+        // One day jqLite will be replaced by jQuery and we will be able to write:
+        // var transcludedElement = clone.filter('.my-class')
+        // instead of creating a hackish DOM element:
+        var transcluded = angular.element('<div>').append(clone);
 
-          var transcludedMatch = transcluded.querySelectorAll('.ui-select-match');
-          transcludedMatch.removeAttr('ui-select-match'); //To avoid loop in case directive as attr
-          transcludedMatch.removeAttr('data-ui-select-match'); // Properly handle HTML5 data-attributes
-          if (transcludedMatch.length !== 1) {
-            throw uiSelectMinErr('transcluded', "Expected 1 .ui-select-match but got '{0}'.", transcludedMatch.length);
-          }
-          element.querySelectorAll('.ui-select-match').replaceWith(transcludedMatch);
+        var transcludedMatch = transcluded.querySelectorAll('.ui-select-match');
+        transcludedMatch.removeAttr('ui-select-match'); //To avoid loop in case directive as attr
+        transcludedMatch.removeAttr('data-ui-select-match'); // Properly handle HTML5 data-attributes
+        if (transcludedMatch.length !== 1) {
+          throw uiSelectMinErr('transcluded', "Expected 1 .ui-select-match but got '{0}'.", transcludedMatch.length);
+        }
+        element.querySelectorAll('.ui-select-match').replaceWith(transcludedMatch);
 
-          var transcludedChoices = transcluded.querySelectorAll('.ui-select-choices');
-          transcludedChoices.removeAttr('ui-select-choices'); //To avoid loop in case directive as attr
-          transcludedChoices.removeAttr('data-ui-select-choices'); // Properly handle HTML5 data-attributes
-          if (transcludedChoices.length !== 1) {
-            throw uiSelectMinErr('transcluded', "Expected 1 .ui-select-choices but got '{0}'.", transcludedChoices.length);
-          }
-          element.querySelectorAll('.ui-select-choices').replaceWith(transcludedChoices);
-        });
+        var transcludedChoices = transcluded.querySelectorAll('.ui-select-choices');
+        transcludedChoices.removeAttr('ui-select-choices'); //To avoid loop in case directive as attr
+        transcludedChoices.removeAttr('data-ui-select-choices'); // Properly handle HTML5 data-attributes
+        if (transcludedChoices.length !== 1) {
+          throw uiSelectMinErr('transcluded', "Expected 1 .ui-select-choices but got '{0}'.", transcludedChoices.length);
+        }
+        element.querySelectorAll('.ui-select-choices').replaceWith(transcludedChoices);
+      });
+    }
+  };
+}]);
+
+uis.directive('uiSelectMatch', ['uiSelectConfig', function(uiSelectConfig) {
+  return {
+    restrict: 'EA',
+    require: '^uiSelect',
+    replace: true,
+    transclude: true,
+    templateUrl: function(tElement) {
+      // Gets theme attribute from parent (ui-select)
+      var theme = tElement.parent().attr('theme') || uiSelectConfig.theme;
+      var multi = tElement.parent().attr('multiple');
+      return theme + (multi ? '/match-multiple.tpl.html' : '/match.tpl.html');
+    },
+    link: function(scope, element, attrs, $select) {
+      $select.lockChoiceExpression = attrs.uiLockChoice;
+      attrs.$observe('placeholder', function(placeholder) {
+        $select.placeholder = placeholder !== undefined ? placeholder : uiSelectConfig.placeholder;
+      });
+
+      $select.allowClear = (angular.isDefined(attrs.allowClear)) ? (attrs.allowClear === '') ? true : (attrs.allowClear.toLowerCase() === 'true') : false;
+
+      if($select.multiple){
+        $select.sizeSearchInput();
       }
-    };
-  }])
 
-  .directive('uiSelectChoices',
-    ['uiSelectConfig', 'RepeatParser', 'uiSelectMinErr', '$compile',
-    function(uiSelectConfig, RepeatParser, uiSelectMinErr, $compile) {
+    }
+  };
+}]);
+
+// Make multiple matches sortable
+uis.directive('uiSelectSort', ['$timeout', 'uiSelectConfig', 'uiSelectMinErr', function($timeout, uiSelectConfig, uiSelectMinErr) {
+  return {
+    require: '^uiSelect',
+    link: function(scope, element, attrs, $select) {
+      if (scope[attrs.uiSelectSort] === null) {
+        throw uiSelectMinErr('sort', "Expected a list to sort");
+      }
 
-    return {
-      restrict: 'EA',
-      require: '^uiSelect',
-      replace: true,
-      transclude: true,
-      templateUrl: function(tElement) {
-        // Gets theme attribute from parent (ui-select)
-        var theme = tElement.parent().attr('theme') || uiSelectConfig.theme;
-        return theme + '/choices.tpl.html';
-      },
+      var options = angular.extend({
+          axis: 'horizontal'
+        },
+        scope.$eval(attrs.uiSelectSortOptions));
+
+      var axis = options.axis,
+        draggingClassName = 'dragging',
+        droppingClassName = 'dropping',
+        droppingBeforeClassName = 'dropping-before',
+        droppingAfterClassName = 'dropping-after';
+
+      scope.$watch(function(){
+        return $select.sortable;
+      }, function(n){
+        if (n) {
+          element.attr('draggable', true);
+        } else {
+          element.removeAttr('draggable');
+        }
+      });
 
-      compile: function(tElement, tAttrs) {
+      element.on('dragstart', function(e) {
+        element.addClass(draggingClassName);
 
-        if (!tAttrs.repeat) throw uiSelectMinErr('repeat', "Expected 'repeat' expression.");
+        (e.dataTransfer || e.originalEvent.dataTransfer).setData('text/plain', scope.$index);
+      });
 
-        return function link(scope, element, attrs, $select, transcludeFn) {
+      element.on('dragend', function() {
+        element.removeClass(draggingClassName);
+      });
 
-          // var repeat = RepeatParser.parse(attrs.repeat);
-          var groupByExp = attrs.groupBy;
+      var move = function(from, to) {
+        /*jshint validthis: true */
+        this.splice(to, 0, this.splice(from, 1)[0]);
+      };
 
-          $select.parseRepeatAttr(attrs.repeat, groupByExp); //Result ready at $select.parserResult
+      var dragOverHandler = function(e) {
+        e.preventDefault();
 
-          $select.disableChoiceExpression = attrs.uiDisableChoice;
-          $select.onHighlightCallback = attrs.onHighlight;
+        var offset = axis === 'vertical' ? e.offsetY || e.layerY || (e.originalEvent ? e.originalEvent.offsetY : 0) : e.offsetX || e.layerX || (e.originalEvent ? e.originalEvent.offsetX : 0);
 
-          if(groupByExp) {
-            var groups = element.querySelectorAll('.ui-select-choices-group');
-            if (groups.length !== 1) throw uiSelectMinErr('rows', "Expected 1 .ui-select-choices-group but got '{0}'.", groups.length);
-            groups.attr('ng-repeat', RepeatParser.getGroupNgRepeatExpression());
-          }
+        if (offset < (this[axis === 'vertical' ? 'offsetHeight' : 'offsetWidth'] / 2)) {
+          element.removeClass(droppingAfterClassName);
+          element.addClass(droppingBeforeClassName);
 
-          var choices = element.querySelectorAll('.ui-select-choices-row');
-          if (choices.length !== 1) {
-            throw uiSelectMinErr('rows', "Expected 1 .ui-select-choices-row but got '{0}'.", choices.length);
-          }
+        } else {
+          element.removeClass(droppingBeforeClassName);
+          element.addClass(droppingAfterClassName);
+        }
+      };
 
-          choices.attr('ng-repeat', RepeatParser.getNgRepeatExpression($select.parserResult.itemName, '$select.items', $select.parserResult.trackByExp, groupByExp))
-              .attr('ng-if', '$select.open') //Prevent unnecessary watches when dropdown is closed
-              .attr('ng-mouseenter', '$select.setActiveItem('+$select.parserResult.itemName +')')
-              .attr('ng-click', '$select.select(' + $select.parserResult.itemName + ',false,$event)');
+      var dropTimeout;
 
-          var rowsInner = element.querySelectorAll('.ui-select-choices-row-inner');
-          if (rowsInner.length !== 1) throw uiSelectMinErr('rows', "Expected 1 .ui-select-choices-row-inner but got '{0}'.", rowsInner.length);
-          rowsInner.attr('uis-transclude-append', ''); //Adding uisTranscludeAppend directive to row element after choices element has ngRepeat
+      var dropHandler = function(e) {
+        e.preventDefault();
 
-          $compile(element, transcludeFn)(scope); //Passing current transcludeFn to be able to append elements correctly from uisTranscludeAppend
+        var droppedItemIndex = parseInt((e.dataTransfer || e.originalEvent.dataTransfer).getData('text/plain'), 10);
 
-          scope.$watch('$select.search', function(newValue) {
-            if(newValue && !$select.open && $select.multiple) $select.activate(false, true);
-            $select.activeIndex = $select.tagging.isActivated ? -1 : 0;
-            $select.refresh(attrs.refresh);
-          });
+        // prevent event firing multiple times in firefox
+        $timeout.cancel(dropTimeout);
+        dropTimeout = $timeout(function() {
+          _dropHandler(droppedItemIndex);
+        }, 20);
+      };
 
-          attrs.$observe('refreshDelay', function() {
-            // $eval() is needed otherwise we get a string instead of a number
-            var refreshDelay = scope.$eval(attrs.refreshDelay);
-            $select.refreshDelay = refreshDelay !== undefined ? refreshDelay : uiSelectConfig.refreshDelay;
-          });
-        };
-      }
-    };
-  }])
-  // Recreates old behavior of ng-transclude. Used internally.
-  .directive('uisTranscludeAppend', function () {
-    return {
-      link: function (scope, element, attrs, ctrl, transclude) {
-          transclude(scope, function (clone) {
-            element.append(clone);
-          });
+      var _dropHandler = function(droppedItemIndex) {
+        var theList = scope.$eval(attrs.uiSelectSort),
+          itemToMove = theList[droppedItemIndex],
+          newIndex = null;
+
+        if (element.hasClass(droppingBeforeClassName)) {
+          if (droppedItemIndex < scope.$index) {
+            newIndex = scope.$index - 1;
+          } else {
+            newIndex = scope.$index;
+          }
+        } else {
+          if (droppedItemIndex < scope.$index) {
+            newIndex = scope.$index;
+          } else {
+            newIndex = scope.$index + 1;
+          }
         }
-      };
-  })
-  .directive('uiSelectMatch', ['uiSelectConfig', function(uiSelectConfig) {
-    return {
-      restrict: 'EA',
-      require: '^uiSelect',
-      replace: true,
-      transclude: true,
-      templateUrl: function(tElement) {
-        // Gets theme attribute from parent (ui-select)
-        var theme = tElement.parent().attr('theme') || uiSelectConfig.theme;
-        var multi = tElement.parent().attr('multiple');
-        return theme + (multi ? '/match-multiple.tpl.html' : '/match.tpl.html');
-      },
-      link: function(scope, element, attrs, $select) {
-        $select.lockChoiceExpression = attrs.uiLockChoice;
-        attrs.$observe('placeholder', function(placeholder) {
-          $select.placeholder = placeholder !== undefined ? placeholder : uiSelectConfig.placeholder;
+
+        move.apply(theList, [droppedItemIndex, newIndex]);
+
+        scope.$apply(function() {
+          scope.$emit('uiSelectSort:change', {
+            array: theList,
+            item: itemToMove,
+            from: droppedItemIndex,
+            to: newIndex
+          });
         });
 
-        $select.allowClear = (angular.isDefined(attrs.allowClear)) ? (attrs.allowClear === '') ? true : (attrs.allowClear.toLowerCase() === 'true') : false;
+        element.removeClass(droppingClassName);
+        element.removeClass(droppingBeforeClassName);
+        element.removeClass(droppingAfterClassName);
 
-        if($select.multiple){
-          $select.sizeSearchInput();
+        element.off('drop', dropHandler);
+      };
+
+      element.on('dragenter', function() {
+        if (element.hasClass(draggingClassName)) {
+          return;
         }
 
-      }
-    };
-  }])
+        element.addClass(droppingClassName);
 
-  /**
-   * Highlights text that matches $select.search.
-   *
-   * Taken from AngularUI Bootstrap Typeahead
-   * See https://github.com/angular-ui/bootstrap/blob/0.10.0/src/typeahead/typeahead.js#L340
-   */
-  .filter('highlight', function() {
-    function escapeRegexp(queryToEscape) {
-      return queryToEscape.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
+        element.on('dragover', dragOverHandler);
+        element.on('drop', dropHandler);
+      });
+
+      element.on('dragleave', function() {
+        element.removeClass(droppingClassName);
+        element.removeClass(droppingBeforeClassName);
+        element.removeClass(droppingAfterClassName);
+
+        element.off('dragover', dragOverHandler);
+        element.off('drop', dropHandler);
+      });
     }
+  };
+}]);
 
-    return function(matchItem, query) {
-      return query && matchItem ? matchItem.replace(new RegExp(escapeRegexp(query), 'gi'), '<span class="ui-select-highlight">$&</span>') : matchItem;
-    };
-  });
 }());
-
 angular.module("ui.select").run(["$templateCache", function($templateCache) {$templateCache.put("bootstrap/choices.tpl.html","<ul class=\"ui-select-choices ui-select-choices-content dropdown-menu\" role=\"listbox\" ng-show=\"$select.items.length > 0\"><li class=\"ui-select-choices-group\" id=\"ui-select-choices-{{ $select.generatedId }}\"><div class=\"divider\" ng-show=\"$select.isGrouped && $index > 0\"></div><div ng-show=\"$select.isGrouped\" class=\"ui-select-choices-group-label dropdown-header\" ng-bind=\"$group.name\"></div><div id=\"ui-select-choices-row-{{ $select.generatedId }}-{{$index}}\" class=\"ui-select-choices-row\" ng-class=\"{active: $select.isActive(this), disabled: $select.isDisabled(this)}\" role=\"option\"><a href=\"javascript:void(0)\" class=\"ui-select-choices-row-inner\"></a></div></li></ul>");
-$templateCache.put("bootstrap/match-multiple.tpl.html","<span class=\"ui-select-match\"><span ng-repeat=\"$item in $select.selected\"><span style=\"margin-right: 3px;\" class=\"ui-select-match-item btn btn-default btn-xs\" tabindex=\"-1\" type=\"button\" ng-disabled=\"$select.disabled\" ng-click=\"$select.activeMatchIndex = $index;\" ng-class=\"{\'btn-primary\':$select.activeMatchIndex === $index, \'select-locked\':$select.isLocked(this, $index)}\"><span class=\"close ui-select-match-close\" ng-hide=\"$select.disabled\" ng-click=\"$select.removeChoice($index)\">&nbsp;&times;</span> <span uis-transclude-append=\"\"></span></span></span></span>");
+$templateCache.put("bootstrap/match-multiple.tpl.html","<span class=\"ui-select-match\"><span ng-repeat=\"$item in $select.selected\"><span class=\"ui-select-match-item btn btn-default btn-xs\" tabindex=\"-1\" type=\"button\" ng-disabled=\"$select.disabled\" ng-click=\"$select.activeMatchIndex = $index;\" ng-class=\"{\'btn-primary\':$select.activeMatchIndex === $index, \'select-locked\':$select.isLocked(this, $index)}\" ui-select-sort=\"$select.selected\"><span class=\"close ui-select-match-close\" ng-hide=\"$select.disabled\" ng-click=\"$select.removeChoice($index)\">&nbsp;&times;</span> <span uis-transclude-append=\"\"></span></span></span></span>");
 $templateCache.put("bootstrap/match.tpl.html","<div class=\"ui-select-match\" ng-hide=\"$select.open\" ng-disabled=\"$select.disabled\" ng-class=\"{\'btn-default-focus\':$select.focus}\"><span tabindex=\"-1\" class=\"btn btn-default form-control ui-select-toggle\" aria-label=\"{{ $select.baseTitle }} activate\" ng-disabled=\"$select.disabled\" ng-click=\"$select.activate()\" style=\"outline: 0;\"><span ng-show=\"$select.isEmpty()\" class=\"ui-select-placeholder text-muted\">{{$select.placeholder}}</span> <span ng-hide=\"$select.isEmpty()\" class=\"ui-select-match-text pull-left\" ng-class=\"{\'ui-select-allow-clear\': $select.allowClear && !$select.isEmpty()}\" ng-transclude=\"\"></span> <i class=\"caret pull-right\" ng-click=\"$select.toggle($event)\"></i> <a ng-show=\"$select.allowClear && !$select.isEmpty()\" aria-label=\"{{ $select.baseTitle }} clear\" style=\"margin-right: 10px\" ng-click=\"$select.clear($event)\" class=\"btn btn-xs btn-link pull-right\"><i class=\"glyphicon glyphicon-remove\" aria-hidden=\"true\"></i></a></span></div>");
-$templateCache.put("bootstrap/select-multiple.tpl.html","<div class=\"ui-select-container ui-select-multiple ui-select-bootstrap dropdown form-control\" ng-class=\"{open: $select.open}\"><div><div class=\"ui-select-match\"></div><input type=\"text\" autocomplete=\"off\" autocorrect=\"off\" autocapitalize=\"off\" spellcheck=\"false\" class=\"ui-select-search input-xs\" placeholder=\"{{$select.getPlaceholder()}}\" ng-disabled=\"$select.disabled\" ng-hide=\"$select.disabled\" ng-click=\"$select.activate()\" ng-model=\"$select.search\" role=\"combobox\" aria-label=\"{{ $select.baseTitle }}\"></div><div class=\"ui-select-choices\"></div></div>");
+$templateCache.put("bootstrap/select-multiple.tpl.html","<div class=\"ui-select-container ui-select-multiple ui-select-bootstrap dropdown form-control\" ng-class=\"{open: $select.open}\"><div><div class=\"ui-select-match\"></div><input type=\"text\" autocomplete=\"off\" autocorrect=\"off\" autocapitalize=\"off\" spellcheck=\"false\" class=\"ui-select-search input-xs\" placeholder=\"{{$select.getPlaceholder()}}\" ng-disabled=\"$select.disabled\" ng-hide=\"$select.disabled\" ng-click=\"$select.activate()\" ng-model=\"$select.search\" role=\"combobox\" aria-label=\"{{ $select.baseTitle }}\" ondrop=\"return false;\"></div><div class=\"ui-select-choices\"></div></div>");
 $templateCache.put("bootstrap/select.tpl.html","<div class=\"ui-select-container ui-select-bootstrap dropdown\" ng-class=\"{open: $select.open}\"><div class=\"ui-select-match\"></div><input type=\"text\" autocomplete=\"off\" tabindex=\"-1\" aria-expanded=\"true\" aria-label=\"{{ $select.baseTitle }}\" aria-owns=\"ui-select-choices-{{ $select.generatedId }}\" aria-activedescendant=\"ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}\" class=\"form-control ui-select-search\" placeholder=\"{{$select.placeholder}}\" ng-model=\"$select.search\" ng-show=\"$select.searchEnabled && $select.open\"><div class=\"ui-select-choices\"></div></div>");
 $templateCache.put("select2/choices.tpl.html","<ul class=\"ui-select-choices ui-select-choices-content select2-results\"><li class=\"ui-select-choices-group\" ng-class=\"{\'select2-result-with-children\': $select.choiceGrouped($group) }\"><div ng-show=\"$select.choiceGrouped($group)\" class=\"ui-select-choices-group-label select2-result-label\" ng-bind=\"$group.name\"></div><ul role=\"listbox\" id=\"ui-select-choices-{{ $select.generatedId }}\" ng-class=\"{\'select2-result-sub\': $select.choiceGrouped($group), \'select2-result-single\': !$select.choiceGrouped($group) }\"><li role=\"option\" id=\"ui-select-choices-row-{{ $select.generatedId }}-{{$index}}\" class=\"ui-select-choices-row\" ng-class=\"{\'select2-highlighted\': $select.isActive(this), \'select2-disabled\': $select.isDisabled(this)}\"><div class=\"select2-result-label ui-select-choices-row-inner\"></div></li></ul></li></ul>");
-$templateCache.put("select2/match-multiple.tpl.html","<span class=\"ui-select-match\"><li class=\"ui-select-match-item select2-search-choice\" ng-repeat=\"$item in $select.selected\" ng-class=\"{\'select2-search-choice-focus\':$select.activeMatchIndex === $index, \'select2-locked\':$select.isLocked(this, $index)}\"><span uis-transclude-append=\"\"></span> <a href=\"javascript:;\" class=\"ui-select-match-close select2-search-choice-close\" ng-click=\"$select.removeChoice($index)\" tabindex=\"-1\"></a></li></span>");
+$templateCache.put("select2/match-multiple.tpl.html","<span class=\"ui-select-match\"><li class=\"ui-select-match-item select2-search-choice\" ng-repeat=\"$item in $select.selected\" ng-class=\"{\'select2-search-choice-focus\':$select.activeMatchIndex === $index, \'select2-locked\':$select.isLocked(this, $index)}\" ui-select-sort=\"$select.selected\"><span uis-transclude-append=\"\"></span> <a href=\"javascript:;\" class=\"ui-select-match-close select2-search-choice-close\" ng-click=\"$select.removeChoice($index)\" tabindex=\"-1\"></a></li></span>");
 $templateCache.put("select2/match.tpl.html","<a class=\"select2-choice ui-select-match\" ng-class=\"{\'select2-default\': $select.isEmpty()}\" ng-click=\"$select.activate()\" aria-label=\"{{ $select.baseTitle }} select\"><span ng-show=\"$select.isEmpty()\" class=\"select2-chosen\">{{$select.placeholder}}</span> <span ng-hide=\"$select.isEmpty()\" class=\"select2-chosen\" ng-transclude=\"\"></span> <abbr ng-if=\"$select.allowClear && !$select.isEmpty()\" class=\"select2-search-choice-close\" ng-click=\"$select.clear($event)\"></abbr> <span class=\"select2-arrow ui-select-toggle\" ng-click=\"$select.toggle($event)\"><b></b></span></a>");
-$templateCache.put("select2/select-multiple.tpl.html","<div class=\"ui-select-container ui-select-multiple select2 select2-container select2-container-multi\" ng-class=\"{\'select2-container-active select2-dropdown-open open\': $select.open,\n                \'select2-container-disabled\': $select.disabled}\"><ul class=\"select2-choices\"><span class=\"ui-select-match\"></span><li class=\"select2-search-field\"><input type=\"text\" autocomplete=\"off\" autocorrect=\"off\" autocapitalize=\"off\" spellcheck=\"false\" role=\"combobox\" aria-expanded=\"true\" aria-owns=\"ui-select-choices-{{ $select.generatedId }}\" aria-label=\"{{ $select.baseTitle }}\" aria-activedescendant=\"ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}\" class=\"select2-input ui-select-search\" placeholder=\"{{$select.getPlaceholder()}}\" ng-disabled=\"$select.disabled\" ng-hide=\"$select.disabled\" ng-model=\"$select.search\" ng-click=\"$select.activate()\" style=\"width: 34px;\"></li></ul><div class=\"select2-drop select2-with-searchbox select2-drop-active\" ng-class=\"{\'select2-display-none\': !$select.open}\"><div class=\"ui-select-choices\"></div></div></div>");
+$templateCache.put("select2/select-multiple.tpl.html","<div class=\"ui-select-container ui-select-multiple select2 select2-container select2-container-multi\" ng-class=\"{\'select2-container-active select2-dropdown-open open\': $select.open,\n                \'select2-container-disabled\': $select.disabled}\"><ul class=\"select2-choices\"><span class=\"ui-select-match\"></span><li class=\"select2-search-field\"><input type=\"text\" autocomplete=\"off\" autocorrect=\"off\" autocapitalize=\"off\" spellcheck=\"false\" role=\"combobox\" aria-expanded=\"true\" aria-owns=\"ui-select-choices-{{ $select.generatedId }}\" aria-label=\"{{ $select.baseTitle }}\" aria-activedescendant=\"ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}\" class=\"select2-input ui-select-search\" placeholder=\"{{$select.getPlaceholder()}}\" ng-disabled=\"$select.disabled\" ng-hide=\"$select.disabled\" ng-model=\"$select.search\" ng-click=\"$select.activate()\" style=\"width: 34px;\" ondrop=\"return false;\"></li></ul><div class=\"select2-drop select2-with-searchbox select2-drop-active\" ng-class=\"{\'select2-display-none\': !$select.open}\"><div class=\"ui-select-choices\"></div></div></div>");
 $templateCache.put("select2/select.tpl.html","<div class=\"ui-select-container select2 select2-container\" ng-class=\"{\'select2-container-active select2-dropdown-open open\': $select.open,\n                \'select2-container-disabled\': $select.disabled,\n                \'select2-container-active\': $select.focus,\n                \'select2-allowclear\': $select.allowClear && !$select.isEmpty()}\"><div class=\"ui-select-match\"></div><div class=\"select2-drop select2-with-searchbox select2-drop-active\" ng-class=\"{\'select2-display-none\': !$select.open}\"><div class=\"select2-search\" ng-show=\"$select.searchEnabled\"><input type=\"text\" autocomplete=\"off\" autocorrect=\"off\" autocapitalize=\"off\" spellcheck=\"false\" role=\"combobox\" aria-expanded=\"true\" aria-owns=\"ui-select-choices-{{ $select.generatedId }}\" aria-label=\"{{ $select.baseTitle }}\" aria-activedescendant=\"ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}\" class=\"ui-select-search select2-input\" ng-model=\"$select.search\"></div><div class=\"ui-select-choices\"></div></div></div>");
 $templateCache.put("selectize/choices.tpl.html","<div ng-show=\"$select.open\" class=\"ui-select-choices selectize-dropdown single\"><div class=\"ui-select-choices-content selectize-dropdown-content\"><div class=\"ui-select-choices-group optgroup\" role=\"listbox\"><div ng-show=\"$select.isGrouped\" class=\"ui-select-choices-group-label optgroup-header\" ng-bind=\"$group.name\"></div><div role=\"option\" class=\"ui-select-choices-row\" ng-class=\"{active: $select.isActive(this), disabled: $select.isDisabled(this)}\"><div class=\"option ui-select-choices-row-inner\" data-selectable=\"\"></div></div></div></div></div>");
 $templateCache.put("selectize/match.tpl.html","<div ng-hide=\"($select.open || $select.isEmpty())\" class=\"ui-select-match\" ng-transclude=\"\"></div>");
diff --git a/dist/select.min.css b/dist/select.min.css
index ea32cb46b..dfd1c1095 100644
--- a/dist/select.min.css
+++ b/dist/select.min.css
@@ -1,6 +1,6 @@
 /*!
  * ui-select
  * http://github.com/angular-ui/ui-select
- * Version: 0.9.9 - 2015-02-18T03:49:07.281Z
+ * Version: 0.10.0 - 2015-02-26T06:35:06.243Z
  * License: MIT
- */.ui-select-highlight{font-weight:700}.ui-select-offscreen{clip:rect(0 0 0 0)!important;width:1px!important;height:1px!important;border:0!important;margin:0!important;padding:0!important;overflow:hidden!important;position:absolute!important;outline:0!important;left:0!important;top:0!important}.ng-dirty.ng-invalid>a.select2-choice{border-color:#D44950}.select2-result-single{padding-left:0}.select-locked>.ui-select-match-close,.select2-locked>.select2-search-choice-close{display:none}.selectize-input.selectize-focus{border-color:#007FBB!important}.selectize-control>.selectize-dropdown,.selectize-control>.selectize-input>input{width:100%}.ng-dirty.ng-invalid>div.selectize-input{border-color:#D44950}.btn-default-focus{color:#333;background-color:#EBEBEB;border-color:#ADADAD;text-decoration:none;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}.ui-select-bootstrap .ui-select-toggle{position:relative;text-align:left}.ui-select-bootstrap .ui-select-toggle>.caret{position:absolute;height:10px;top:50%;right:10px;margin-top:-2px}.input-group>.ui-select-bootstrap.dropdown{position:static}.input-group>.ui-select-bootstrap>input.ui-select-search.form-control{border-radius:4px 0 0 4px}.ui-select-bootstrap>.ui-select-match>.caret{position:absolute;top:45%;right:15px}.ui-select-bootstrap>.ui-select-choices{width:100%;height:auto;max-height:200px;overflow-x:hidden}.ui-select-multiple.ui-select-bootstrap{height:auto;padding:.3em}.ui-select-multiple.ui-select-bootstrap input.ui-select-search{background-color:transparent!important;border:none;outline:0;height:1.666666em}.ui-select-multiple.ui-select-bootstrap .ui-select-match .close{font-size:1.6em;line-height:.75}.ui-select-multiple.ui-select-bootstrap .ui-select-match-item{outline:0}.ui-select-bootstrap .ui-select-choices-row>a{display:block;padding:3px 20px;clear:both;font-weight:400;line-height:1.42857143;color:#333;white-space:nowrap}.ui-select-bootstrap .ui-select-choices-row>a:focus,.ui-select-bootstrap .ui-select-choices-row>a:hover{text-decoration:none;color:#262626;background-color:#f5f5f5}.ui-select-bootstrap .ui-select-choices-row.active>a{color:#fff;text-decoration:none;outline:0;background-color:#428bca}.ui-select-bootstrap .ui-select-choices-row.active.disabled>a,.ui-select-bootstrap .ui-select-choices-row.disabled>a{color:#777;cursor:not-allowed;background-color:#fff}.ui-select-match.ng-hide-add,.ui-select-search.ng-hide-add{display:none!important}.ui-select-bootstrap.ng-dirty.ng-invalid>button.btn.ui-select-match{border-color:#D44950}
\ No newline at end of file
+ */.ui-select-highlight{font-weight:700}.ui-select-offscreen{clip:rect(0 0 0 0)!important;width:1px!important;height:1px!important;border:0!important;margin:0!important;padding:0!important;overflow:hidden!important;position:absolute!important;outline:0!important;left:0!important;top:0!important}.ng-dirty.ng-invalid>a.select2-choice{border-color:#D44950}.select2-result-single{padding-left:0}.select-locked>.ui-select-match-close,.select2-locked>.select2-search-choice-close{display:none}.selectize-input.selectize-focus{border-color:#007FBB!important}.selectize-control>.selectize-dropdown,.selectize-control>.selectize-input>input{width:100%}.ng-dirty.ng-invalid>div.selectize-input{border-color:#D44950}.btn-default-focus{color:#333;background-color:#EBEBEB;border-color:#ADADAD;text-decoration:none;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}.ui-select-bootstrap .ui-select-toggle{position:relative}.ui-select-bootstrap .ui-select-toggle>.caret{position:absolute;height:10px;top:50%;right:10px;margin-top:-2px}.input-group>.ui-select-bootstrap.dropdown{position:static}.input-group>.ui-select-bootstrap>input.ui-select-search.form-control{border-radius:4px 0 0 4px}.ui-select-bootstrap>.ui-select-match{text-align:left}.ui-select-bootstrap>.ui-select-match>.caret{position:absolute;top:45%;right:15px}.ui-select-bootstrap>.ui-select-choices{width:100%;height:auto;max-height:200px;overflow-x:hidden;margin-top:-1px}.ui-select-multiple.ui-select-bootstrap{height:auto;padding:3px 3px 0}.ui-select-multiple.ui-select-bootstrap input.ui-select-search{background-color:transparent!important;border:none;outline:0;height:1.666666em;margin-bottom:3px}.ui-select-multiple.ui-select-bootstrap .ui-select-match .close{font-size:1.6em;line-height:.75}.ui-select-multiple.ui-select-bootstrap .ui-select-match-item{outline:0;margin:0 3px 3px 0}.ui-select-multiple .ui-select-match-item{position:relative}.ui-select-multiple .ui-select-match-item.dropping-before:before{content:"";position:absolute;top:0;right:100%;height:100%;margin-right:2px;border-left:1px solid #428bca}.ui-select-multiple .ui-select-match-item.dropping-after:after{content:"";position:absolute;top:0;left:100%;height:100%;margin-left:2px;border-right:1px solid #428bca}.ui-select-bootstrap .ui-select-choices-row>a{display:block;padding:3px 20px;clear:both;font-weight:400;line-height:1.42857143;color:#333;white-space:nowrap}.ui-select-bootstrap .ui-select-choices-row>a:focus,.ui-select-bootstrap .ui-select-choices-row>a:hover{text-decoration:none;color:#262626;background-color:#f5f5f5}.ui-select-bootstrap .ui-select-choices-row.active>a{color:#fff;text-decoration:none;outline:0;background-color:#428bca}.ui-select-bootstrap .ui-select-choices-row.active.disabled>a,.ui-select-bootstrap .ui-select-choices-row.disabled>a{color:#777;cursor:not-allowed;background-color:#fff}.ui-select-match.ng-hide-add,.ui-select-search.ng-hide-add{display:none!important}.ui-select-bootstrap.ng-dirty.ng-invalid>button.btn.ui-select-match{border-color:#D44950}
\ No newline at end of file
diff --git a/dist/select.min.js b/dist/select.min.js
index 5b0b18ad7..57cb45822 100755
--- a/dist/select.min.js
+++ b/dist/select.min.js
@@ -1,7 +1,7 @@
 /*!
  * ui-select
  * http://github.com/angular-ui/ui-select
- * Version: 0.9.9 - 2015-02-18T03:49:07.277Z
+ * Version: 0.10.0 - 2015-02-26T06:35:06.239Z
  * License: MIT
  */
-!function(){"use strict";var e={TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,COMMAND:91,MAP:{91:"COMMAND",8:"BACKSPACE",9:"TAB",13:"ENTER",16:"SHIFT",17:"CTRL",18:"ALT",19:"PAUSEBREAK",20:"CAPSLOCK",27:"ESC",32:"SPACE",33:"PAGE_UP",34:"PAGE_DOWN",35:"END",36:"HOME",37:"LEFT",38:"UP",39:"RIGHT",40:"DOWN",43:"+",44:"PRINTSCREEN",45:"INSERT",46:"DELETE",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NUMLOCK",145:"SCROLLLOCK",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},isControl:function(t){var c=t.which;switch(c){case e.COMMAND:case e.SHIFT:case e.CTRL:case e.ALT:return!0}return t.metaKey?!0:!1},isFunctionKey:function(e){return e=e.which?e.which:e,e>=112&&123>=e},isVerticalMovement:function(t){return~[e.UP,e.DOWN].indexOf(t)},isHorizontalMovement:function(t){return~[e.LEFT,e.RIGHT,e.BACKSPACE,e.DELETE].indexOf(t)}};void 0===angular.element.prototype.querySelectorAll&&(angular.element.prototype.querySelectorAll=function(e){return angular.element(this[0].querySelectorAll(e))}),void 0===angular.element.prototype.closest&&(angular.element.prototype.closest=function(e){for(var t=this[0],c=t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector;t;){if(c.bind(t)(e))return t;t=t.parentElement}return!1});var t=0;angular.module("ui.select",[]).constant("uiSelectConfig",{theme:"bootstrap",searchEnabled:!0,placeholder:"",refreshDelay:1e3,closeOnSelect:!0,generateId:function(){return t++}}).service("uiSelectMinErr",function(){var e=angular.$$minErr("ui.select");return function(){var t=e.apply(this,arguments),c=t.message.replace(new RegExp("\nhttp://errors.angularjs.org/.*"),"");return new Error(c)}}).service("RepeatParser",["uiSelectMinErr","$parse",function(e,t){var c=this;c.parse=function(c){var i=c.match(/^\s*(?:([\s\S]+?)\s+as\s+)?([\S]+?)\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?\s*$/);if(!i)throw e("iexp","Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'.",c);return{itemName:i[2],source:t(i[3]),trackByExp:i[4],modelMapper:t(i[1]||i[2])}},c.getGroupNgRepeatExpression=function(){return"$group in $select.groups"},c.getNgRepeatExpression=function(e,t,c,i){var l=e+" in "+(i?"$group.items":t);return c&&(l+=" track by "+c),l}}]).controller("uiSelectCtrl",["$scope","$element","$timeout","$filter","RepeatParser","uiSelectMinErr","uiSelectConfig",function(t,c,i,l,s,a,n){function r(){(f.resetSearchInput||void 0===f.resetSearchInput&&n.resetSearchInput)&&(f.search=v,f.selected&&f.items.length&&!f.multiple&&(f.activeIndex=f.items.indexOf(f.selected)))}function o(t){var c=!0;switch(t){case e.DOWN:!f.open&&f.multiple?f.activate(!1,!0):f.activeIndex<f.items.length-1&&f.activeIndex++;break;case e.UP:!f.open&&f.multiple?f.activate(!1,!0):(f.activeIndex>0||0===f.search.length&&f.tagging.isActivated&&f.activeIndex>-1)&&f.activeIndex--;break;case e.TAB:(!f.multiple||f.open)&&f.select(f.items[f.activeIndex],!0);break;case e.ENTER:f.open&&f.activeIndex>=0?f.select(f.items[f.activeIndex]):f.activate(!1,!0);break;case e.ESC:f.close();break;default:c=!1}return c}function u(t){function c(){switch(t){case e.LEFT:return~f.activeMatchIndex?o:a;case e.RIGHT:return~f.activeMatchIndex&&n!==a?r:(f.activate(),!1);case e.BACKSPACE:return~f.activeMatchIndex?(f.removeChoice(n),o):a;case e.DELETE:return~f.activeMatchIndex?(f.removeChoice(f.activeMatchIndex),n):!1}}var i=g(m[0]),l=f.selected.length,s=0,a=l-1,n=f.activeMatchIndex,r=f.activeMatchIndex+1,o=f.activeMatchIndex-1,u=n;return i>0||f.search.length&&t==e.RIGHT?!1:(f.close(),u=c(),f.activeMatchIndex=f.selected.length&&u!==!1?Math.min(a,Math.max(s,u)):-1,!0)}function d(e){if(void 0===e||void 0===f.search)return!1;var t=e.filter(function(e){return void 0===f.search.toUpperCase()||void 0===e?!1:e.toUpperCase()===f.search.toUpperCase()}).length>0;return t}function p(e,t){var c=-1;if(angular.isArray(e))for(var i=angular.copy(e),l=0;l<i.length;l++)if(void 0===f.tagging.fct)i[l]+" "+f.taggingLabel===t&&(c=l);else{var s=i[l];s.isTag=!0,angular.equals(s,t)&&(c=l)}return c}function g(e){return angular.isNumber(e.selectionStart)?e.selectionStart:e.value.length}function h(){var e=c.querySelectorAll(".ui-select-choices-content"),t=e.querySelectorAll(".ui-select-choices-row");if(t.length<1)throw a("choices","Expected multiple .ui-select-choices-row but got '{0}'.",t.length);if(!(f.activeIndex<0)){var i=t[f.activeIndex],l=i.offsetTop+i.clientHeight-e[0].scrollTop,s=e[0].offsetHeight;l>s?e[0].scrollTop+=l-s:l<i.clientHeight&&(f.isGrouped&&0===f.activeIndex?e[0].scrollTop=0:e[0].scrollTop-=i.clientHeight-l)}}var f=this,v="";f.placeholder=void 0,f.search=v,f.activeIndex=0,f.activeMatchIndex=-1,f.items=[],f.selected=void 0,f.open=!1,f.focus=!1,f.focusser=void 0,f.disabled=void 0,f.searchEnabled=void 0,f.resetSearchInput=void 0,f.refreshDelay=void 0,f.multiple=!1,f.disableChoiceExpression=void 0,f.tagging={isActivated:!1,fct:void 0},f.taggingTokens={isActivated:!1,tokens:void 0},f.lockChoiceExpression=void 0,f.closeOnSelect=!0,f.clickTriggeredSelect=!1,f.$filter=l,f.isEmpty=function(){return angular.isUndefined(f.selected)||null===f.selected||""===f.selected};var m=c.querySelectorAll("input.ui-select-search");if(1!==m.length)throw a("searchInput","Expected 1 input.ui-select-search but got '{0}'.",m.length);f.activate=function(e,t){f.disabled||f.open||(t||r(),f.focusser.prop("disabled",!0),f.open=!0,f.activeMatchIndex=-1,f.activeIndex=f.activeIndex>=f.items.length?0:f.activeIndex,-1===f.activeIndex&&f.taggingLabel!==!1&&(f.activeIndex=0),i(function(){f.search=e||f.search,m[0].focus()}))},f.findGroupByName=function(e){return f.groups&&f.groups.filter(function(t){return t.name===e})[0]},f.parseRepeatAttr=function(e,c){function i(e){f.groups=[],angular.forEach(e,function(e){var i=t.$eval(c),l=angular.isFunction(i)?i(e):e[i],s=f.findGroupByName(l);s?s.items.push(e):f.groups.push({name:l,items:[e]})}),f.items=[],f.groups.forEach(function(e){f.items=f.items.concat(e.items)})}function l(e){f.items=e}var n=c?i:l;f.parserResult=s.parse(e),f.isGrouped=!!c,f.itemProperty=f.parserResult.itemName,t.$watchCollection(f.parserResult.source,function(e){if(void 0===e||null===e)f.items=[];else{if(!angular.isArray(e))throw a("items","Expected an array but got '{0}'.",e);if(f.multiple){var t=e.filter(function(e){return f.selected.indexOf(e)<0});n(t)}else n(e);f.ngModel.$modelValue=null}}),f.multiple&&t.$watchCollection("$select.selected",function(e){var c=f.parserResult.source(t);if(e.length){if(void 0!==c){var i=c.filter(function(t){return e.indexOf(t)<0});n(i)}}else n(c);f.sizeSearchInput()})};var $;f.refresh=function(e){void 0!==e&&($&&i.cancel($),$=i(function(){t.$eval(e)},f.refreshDelay))},f.setActiveItem=function(e){f.activeIndex=f.items.indexOf(e)},f.isActive=function(e){if(!f.open)return!1;var t=f.items.indexOf(e[f.itemProperty]),c=t===f.activeIndex;return!c||0>t&&f.taggingLabel!==!1||0>t&&f.taggingLabel===!1?!1:(c&&!angular.isUndefined(f.onHighlightCallback)&&e.$eval(f.onHighlightCallback),c)},f.isDisabled=function(e){if(f.open){var t,c=f.items.indexOf(e[f.itemProperty]),i=!1;return c>=0&&!angular.isUndefined(f.disableChoiceExpression)&&(t=f.items[c],i=!!e.$eval(f.disableChoiceExpression),t._uiSelectChoiceDisabled=i),i}},f.select=function(e,c,l){if(void 0===e||!e._uiSelectChoiceDisabled){if(!f.items&&!f.search)return;if(!e||!e._uiSelectChoiceDisabled){if(f.tagging.isActivated){if(f.taggingLabel===!1)if(f.activeIndex<0){if(e=void 0!==f.tagging.fct?f.tagging.fct(f.search):f.search,!e||angular.equals(f.items[0],e))return}else e=f.items[f.activeIndex];else if(0===f.activeIndex){if(void 0===e)return;if(void 0!==f.tagging.fct&&"string"==typeof e){if(e=f.tagging.fct(f.search),!e)return}else"string"==typeof e&&(e=e.replace(f.taggingLabel,"").trim())}if(f.selected&&angular.isArray(f.selected)&&f.selected.filter(function(t){return angular.equals(t,e)}).length>0)return void f.close(c)}var s={};s[f.parserResult.itemName]=e,f.multiple?(f.selected.push(e),f.sizeSearchInput()):f.selected=e,i(function(){f.onSelectCallback(t,{$item:e,$model:f.parserResult.modelMapper(t,s)})}),(!f.multiple||f.closeOnSelect)&&f.close(c),l&&"click"===l.type&&(f.clickTriggeredSelect=!0)}}},f.close=function(e){f.open&&(f.ngModel&&f.ngModel.$setTouched&&f.ngModel.$setTouched(),r(),f.open=!1,f.multiple||i(function(){f.focusser.prop("disabled",!1),e||f.focusser[0].focus()},0,!1))},f.clear=function(e){f.select(void 0),e.stopPropagation(),f.focusser[0].focus()},f.toggle=function(e){f.open?(f.close(),e.preventDefault(),e.stopPropagation()):f.activate()},f.isLocked=function(e,t){var c,i=f.selected[t];return i&&!angular.isUndefined(f.lockChoiceExpression)&&(c=!!e.$eval(f.lockChoiceExpression),i._uiSelectChoiceLocked=c),c},f.removeChoice=function(e){var c=f.selected[e];if(!c._uiSelectChoiceLocked){var l={};l[f.parserResult.itemName]=c,f.selected.splice(e,1),f.activeMatchIndex=-1,f.sizeSearchInput(),i(function(){f.onRemoveCallback(t,{$item:c,$model:f.parserResult.modelMapper(t,l)})})}},f.getPlaceholder=function(){return f.multiple&&f.selected.length?void 0:f.placeholder};var b;f.sizeSearchInput=function(){var e=m[0],c=m.parent().parent()[0];m.css("width","10px");var l=function(){var t=c.clientWidth-e.offsetLeft-10;50>t&&(t=c.clientWidth),m.css("width",t+"px")};i(function(){0!==c.clientWidth||b?b||l():b=t.$watch(function(){return c.clientWidth},function(e){0!==e&&(l(),b(),b=null)})},0,!1)},m.on("keydown",function(c){var l=c.which;t.$apply(function(){var t=!1,s=!1;if(f.multiple&&e.isHorizontalMovement(l)&&(t=u(l)),!t&&(f.items.length>0||f.tagging.isActivated)&&(t=o(l),f.taggingTokens.isActivated)){for(var a=0;a<f.taggingTokens.tokens.length;a++)f.taggingTokens.tokens[a]===e.MAP[c.keyCode]&&f.search.length>0&&(s=!0);s&&i(function(){m.triggerHandler("tagged");var t=f.search.replace(e.MAP[c.keyCode],"").trim();f.tagging.fct&&(t=f.tagging.fct(t)),t&&f.select(t,!0)})}t&&l!=e.TAB&&(c.preventDefault(),c.stopPropagation())}),e.isVerticalMovement(l)&&f.items.length>0&&h()}),m.on("paste",function(e){var t=e.originalEvent.clipboardData.getData("text/plain");if(t&&t.length>0&&f.taggingTokens.isActivated&&f.tagging.fct){var c=t.split(f.taggingTokens.tokens[0]);c&&c.length>0&&(angular.forEach(c,function(e){var t=f.tagging.fct(e);t&&f.select(t,!0)}),e.preventDefault(),e.stopPropagation())}}),m.on("keyup",function(c){if(e.isVerticalMovement(c.which)||t.$evalAsync(function(){f.activeIndex=f.taggingLabel===!1?-1:0}),f.tagging.isActivated&&f.search.length>0){if(c.which===e.TAB||e.isControl(c)||e.isFunctionKey(c)||c.which===e.ESC||e.isVerticalMovement(c.which))return;if(f.activeIndex=f.taggingLabel===!1?-1:0,f.taggingLabel===!1)return;var i,l,s,a,n=angular.copy(f.items),r=angular.copy(f.items),o=!1,u=-1;if(void 0!==f.tagging.fct){if(s=f.$filter("filter")(n,{isTag:!0}),s.length>0&&(a=s[0]),n.length>0&&a&&(o=!0,n=n.slice(1,n.length),r=r.slice(1,r.length)),i=f.tagging.fct(f.search),i.isTag=!0,r.filter(function(e){return angular.equals(e,f.tagging.fct(f.search))}).length>0)return;i.isTag=!0}else{if(s=f.$filter("filter")(n,function(e){return e.match(f.taggingLabel)}),s.length>0&&(a=s[0]),l=n[0],void 0!==l&&n.length>0&&a&&(o=!0,n=n.slice(1,n.length),r=r.slice(1,r.length)),i=f.search+" "+f.taggingLabel,p(f.selected,f.search)>-1)return;if(d(r.concat(f.selected)))return void(o&&(n=r,t.$evalAsync(function(){f.activeIndex=0,f.items=n})));if(d(r))return void(o&&(f.items=r.slice(1,r.length)))}o&&(u=p(f.selected,i)),u>-1?n=n.slice(u+1,n.length-1):(n=[],n.push(i),n=n.concat(r)),t.$evalAsync(function(){f.activeIndex=0,f.items=n})}}),m.on("tagged",function(){i(function(){r()})}),m.on("blur",function(){i(function(){f.activeMatchIndex=-1})}),t.$on("$destroy",function(){m.off("keyup keydown tagged blur paste")})}]).directive("uiSelect",["$document","uiSelectConfig","uiSelectMinErr","$compile","$parse",function(t,c,i,l,s){return{restrict:"EA",templateUrl:function(e,t){var i=t.theme||c.theme;return i+(angular.isDefined(t.multiple)?"/select-multiple.tpl.html":"/select.tpl.html")},replace:!0,transclude:!0,require:["uiSelect","^ngModel"],scope:!0,controller:"uiSelectCtrl",controllerAs:"$select",link:function(a,n,r,o,u){function d(e){if(p.open){var t=!1;if(t=window.jQuery?window.jQuery.contains(n[0],e.target):n[0].contains(e.target),!t&&!p.clickTriggeredSelect){var c=["input","button","textarea"],i=angular.element(e.target).scope(),l=i&&i.$select&&i.$select!==p;l||(l=~c.indexOf(e.target.tagName.toLowerCase())),p.close(l),a.$digest()}p.clickTriggeredSelect=!1}}var p=o[0],g=o[1],h=n.querySelectorAll("input.ui-select-search");p.generatedId=c.generateId(),p.baseTitle=r.title||"Select box",p.focusserTitle=p.baseTitle+" focus",p.focusserId="focusser-"+p.generatedId,p.multiple=angular.isDefined(r.multiple)&&(""===r.multiple||"multiple"===r.multiple.toLowerCase()||"true"===r.multiple.toLowerCase()),p.closeOnSelect=function(){return angular.isDefined(r.closeOnSelect)?s(r.closeOnSelect)():c.closeOnSelect}(),p.onSelectCallback=s(r.onSelect),p.onRemoveCallback=s(r.onRemove),g.$parsers.unshift(function(e){var t,c={};if(p.multiple){for(var i=[],l=p.selected.length-1;l>=0;l--)c={},c[p.parserResult.itemName]=p.selected[l],t=p.parserResult.modelMapper(a,c),i.unshift(t);return i}return c={},c[p.parserResult.itemName]=e,t=p.parserResult.modelMapper(a,c)}),g.$formatters.unshift(function(e){var t,c=p.parserResult.source(a,{$select:{search:""}}),i={};if(c){if(p.multiple){var l=[],s=function(e,c){if(!e||!e.length)return l.unshift(c),!0;for(var s=e.length-1;s>=0;s--){if(i[p.parserResult.itemName]=e[s],t=p.parserResult.modelMapper(a,i),p.parserResult.trackByExp){var n=/\.(.+)/.exec(p.parserResult.trackByExp);if(n.length>0&&t[n[1]]==c[n[1]])return l.unshift(e[s]),!0}if(t==c)return l.unshift(e[s]),!0}return!1};if(!e)return l;for(var n=e.length-1;n>=0;n--)s(p.selected,e[n])||s(c,e[n]);return l}var r=function(c){return i[p.parserResult.itemName]=c,t=p.parserResult.modelMapper(a,i),t==e};if(p.selected&&r(p.selected))return p.selected;for(var o=c.length-1;o>=0;o--)if(r(c[o]))return c[o]}return e}),p.ngModel=g,p.choiceGrouped=function(e){return p.isGrouped&&e&&e.name};var f=angular.element("<input ng-disabled='$select.disabled' class='ui-select-focusser ui-select-offscreen' type='text' id='{{ $select.focusserId }}' aria-label='{{ $select.focusserTitle }}' aria-haspopup='true' role='button' />");r.tabindex&&r.$observe("tabindex",function(e){p.multiple?h.attr("tabindex",e):f.attr("tabindex",e),n.removeAttr("tabindex")}),l(f)(a),p.focusser=f,p.multiple||(n.append(f),f.bind("focus",function(){a.$evalAsync(function(){p.focus=!0})}),f.bind("blur",function(){a.$evalAsync(function(){p.focus=!1})}),f.bind("keydown",function(t){return t.which===e.BACKSPACE?(t.preventDefault(),t.stopPropagation(),p.select(void 0),void a.$apply()):void(t.which===e.TAB||e.isControl(t)||e.isFunctionKey(t)||t.which===e.ESC||((t.which==e.DOWN||t.which==e.UP||t.which==e.ENTER||t.which==e.SPACE)&&(t.preventDefault(),t.stopPropagation(),p.activate()),a.$digest()))}),f.bind("keyup input",function(t){t.which===e.TAB||e.isControl(t)||e.isFunctionKey(t)||t.which===e.ESC||t.which==e.ENTER||t.which===e.BACKSPACE||(p.activate(f.val()),f.val(""),a.$digest())})),a.$watch("searchEnabled",function(){var e=a.$eval(r.searchEnabled);p.searchEnabled=void 0!==e?e:c.searchEnabled}),r.$observe("disabled",function(){p.disabled=void 0!==r.disabled?r.disabled:!1}),r.$observe("resetSearchInput",function(){var e=a.$eval(r.resetSearchInput);p.resetSearchInput=void 0!==e?e:!0}),r.$observe("tagging",function(){if(void 0!==r.tagging){var e=a.$eval(r.tagging);p.tagging={isActivated:!0,fct:e!==!0?e:void 0}}else p.tagging={isActivated:!1,fct:void 0}}),r.$observe("taggingLabel",function(){void 0!==r.tagging&&(p.taggingLabel="false"===r.taggingLabel?!1:void 0!==r.taggingLabel?r.taggingLabel:"(new)")}),r.$observe("taggingTokens",function(){if(void 0!==r.tagging){var e=void 0!==r.taggingTokens?r.taggingTokens.split("|"):[",","ENTER"];p.taggingTokens={isActivated:!0,tokens:e}}}),p.multiple?(a.$watchCollection(function(){return g.$modelValue},function(e,t){t!=e&&(g.$modelValue=null)}),p.firstPass=!0,a.$watchCollection("$select.selected",function(){p.firstPass?p.firstPass=!1:g.$setViewValue(Date.now())}),f.prop("disabled",!0)):a.$watch("$select.selected",function(e){g.$viewValue!==e&&g.$setViewValue(e)}),g.$render=function(){if(p.multiple&&!angular.isArray(g.$viewValue)){if(!angular.isUndefined(g.$viewValue)&&null!==g.$viewValue)throw i("multiarr","Expected model value to be array but got '{0}'",g.$viewValue);p.selected=[]}p.selected=g.$viewValue},t.on("click",d),a.$on("$destroy",function(){t.off("click",d)}),u(a,function(e){var t=angular.element("<div>").append(e),c=t.querySelectorAll(".ui-select-match");if(c.removeAttr("ui-select-match"),c.removeAttr("data-ui-select-match"),1!==c.length)throw i("transcluded","Expected 1 .ui-select-match but got '{0}'.",c.length);n.querySelectorAll(".ui-select-match").replaceWith(c);var l=t.querySelectorAll(".ui-select-choices");if(l.removeAttr("ui-select-choices"),l.removeAttr("data-ui-select-choices"),1!==l.length)throw i("transcluded","Expected 1 .ui-select-choices but got '{0}'.",l.length);n.querySelectorAll(".ui-select-choices").replaceWith(l)})}}}]).directive("uiSelectChoices",["uiSelectConfig","RepeatParser","uiSelectMinErr","$compile",function(e,t,c,i){return{restrict:"EA",require:"^uiSelect",replace:!0,transclude:!0,templateUrl:function(t){var c=t.parent().attr("theme")||e.theme;return c+"/choices.tpl.html"},compile:function(l,s){if(!s.repeat)throw c("repeat","Expected 'repeat' expression.");return function(l,s,a,n,r){var o=a.groupBy;if(n.parseRepeatAttr(a.repeat,o),n.disableChoiceExpression=a.uiDisableChoice,n.onHighlightCallback=a.onHighlight,o){var u=s.querySelectorAll(".ui-select-choices-group");if(1!==u.length)throw c("rows","Expected 1 .ui-select-choices-group but got '{0}'.",u.length);u.attr("ng-repeat",t.getGroupNgRepeatExpression())}var d=s.querySelectorAll(".ui-select-choices-row");if(1!==d.length)throw c("rows","Expected 1 .ui-select-choices-row but got '{0}'.",d.length);d.attr("ng-repeat",t.getNgRepeatExpression(n.parserResult.itemName,"$select.items",n.parserResult.trackByExp,o)).attr("ng-if","$select.open").attr("ng-mouseenter","$select.setActiveItem("+n.parserResult.itemName+")").attr("ng-click","$select.select("+n.parserResult.itemName+",false,$event)");var p=s.querySelectorAll(".ui-select-choices-row-inner");if(1!==p.length)throw c("rows","Expected 1 .ui-select-choices-row-inner but got '{0}'.",p.length);p.attr("uis-transclude-append",""),i(s,r)(l),l.$watch("$select.search",function(e){e&&!n.open&&n.multiple&&n.activate(!1,!0),n.activeIndex=n.tagging.isActivated?-1:0,n.refresh(a.refresh)}),a.$observe("refreshDelay",function(){var t=l.$eval(a.refreshDelay);n.refreshDelay=void 0!==t?t:e.refreshDelay})}}}}]).directive("uisTranscludeAppend",function(){return{link:function(e,t,c,i,l){l(e,function(e){t.append(e)})}}}).directive("uiSelectMatch",["uiSelectConfig",function(e){return{restrict:"EA",require:"^uiSelect",replace:!0,transclude:!0,templateUrl:function(t){var c=t.parent().attr("theme")||e.theme,i=t.parent().attr("multiple");return c+(i?"/match-multiple.tpl.html":"/match.tpl.html")},link:function(t,c,i,l){l.lockChoiceExpression=i.uiLockChoice,i.$observe("placeholder",function(t){l.placeholder=void 0!==t?t:e.placeholder}),l.allowClear=angular.isDefined(i.allowClear)?""===i.allowClear?!0:"true"===i.allowClear.toLowerCase():!1,l.multiple&&l.sizeSearchInput()}}}]).filter("highlight",function(){function e(e){return e.replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}return function(t,c){return c&&t?t.replace(new RegExp(e(c),"gi"),'<span class="ui-select-highlight">$&</span>'):t}})}(),angular.module("ui.select").run(["$templateCache",function(e){e.put("bootstrap/choices.tpl.html",'<ul class="ui-select-choices ui-select-choices-content dropdown-menu" role="listbox" ng-show="$select.items.length > 0"><li class="ui-select-choices-group" id="ui-select-choices-{{ $select.generatedId }}"><div class="divider" ng-show="$select.isGrouped && $index > 0"></div><div ng-show="$select.isGrouped" class="ui-select-choices-group-label dropdown-header" ng-bind="$group.name"></div><div id="ui-select-choices-row-{{ $select.generatedId }}-{{$index}}" class="ui-select-choices-row" ng-class="{active: $select.isActive(this), disabled: $select.isDisabled(this)}" role="option"><a href="javascript:void(0)" class="ui-select-choices-row-inner"></a></div></li></ul>'),e.put("bootstrap/match-multiple.tpl.html",'<span class="ui-select-match"><span ng-repeat="$item in $select.selected"><span style="margin-right: 3px;" class="ui-select-match-item btn btn-default btn-xs" tabindex="-1" type="button" ng-disabled="$select.disabled" ng-click="$select.activeMatchIndex = $index;" ng-class="{\'btn-primary\':$select.activeMatchIndex === $index, \'select-locked\':$select.isLocked(this, $index)}"><span class="close ui-select-match-close" ng-hide="$select.disabled" ng-click="$select.removeChoice($index)">&nbsp;&times;</span> <span uis-transclude-append=""></span></span></span></span>'),e.put("bootstrap/match.tpl.html",'<div class="ui-select-match" ng-hide="$select.open" ng-disabled="$select.disabled" ng-class="{\'btn-default-focus\':$select.focus}"><span tabindex="-1" class="btn btn-default form-control ui-select-toggle" aria-label="{{ $select.baseTitle }} activate" ng-disabled="$select.disabled" ng-click="$select.activate()" style="outline: 0;"><span ng-show="$select.isEmpty()" class="ui-select-placeholder text-muted">{{$select.placeholder}}</span> <span ng-hide="$select.isEmpty()" class="ui-select-match-text pull-left" ng-class="{\'ui-select-allow-clear\': $select.allowClear && !$select.isEmpty()}" ng-transclude=""></span> <i class="caret pull-right" ng-click="$select.toggle($event)"></i> <a ng-show="$select.allowClear && !$select.isEmpty()" aria-label="{{ $select.baseTitle }} clear" style="margin-right: 10px" ng-click="$select.clear($event)" class="btn btn-xs btn-link pull-right"><i class="glyphicon glyphicon-remove" aria-hidden="true"></i></a></span></div>'),e.put("bootstrap/select-multiple.tpl.html",'<div class="ui-select-container ui-select-multiple ui-select-bootstrap dropdown form-control" ng-class="{open: $select.open}"><div><div class="ui-select-match"></div><input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" class="ui-select-search input-xs" placeholder="{{$select.getPlaceholder()}}" ng-disabled="$select.disabled" ng-hide="$select.disabled" ng-click="$select.activate()" ng-model="$select.search" role="combobox" aria-label="{{ $select.baseTitle }}"></div><div class="ui-select-choices"></div></div>'),e.put("bootstrap/select.tpl.html",'<div class="ui-select-container ui-select-bootstrap dropdown" ng-class="{open: $select.open}"><div class="ui-select-match"></div><input type="text" autocomplete="off" tabindex="-1" aria-expanded="true" aria-label="{{ $select.baseTitle }}" aria-owns="ui-select-choices-{{ $select.generatedId }}" aria-activedescendant="ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}" class="form-control ui-select-search" placeholder="{{$select.placeholder}}" ng-model="$select.search" ng-show="$select.searchEnabled && $select.open"><div class="ui-select-choices"></div></div>'),e.put("select2/choices.tpl.html",'<ul class="ui-select-choices ui-select-choices-content select2-results"><li class="ui-select-choices-group" ng-class="{\'select2-result-with-children\': $select.choiceGrouped($group) }"><div ng-show="$select.choiceGrouped($group)" class="ui-select-choices-group-label select2-result-label" ng-bind="$group.name"></div><ul role="listbox" id="ui-select-choices-{{ $select.generatedId }}" ng-class="{\'select2-result-sub\': $select.choiceGrouped($group), \'select2-result-single\': !$select.choiceGrouped($group) }"><li role="option" id="ui-select-choices-row-{{ $select.generatedId }}-{{$index}}" class="ui-select-choices-row" ng-class="{\'select2-highlighted\': $select.isActive(this), \'select2-disabled\': $select.isDisabled(this)}"><div class="select2-result-label ui-select-choices-row-inner"></div></li></ul></li></ul>'),e.put("select2/match-multiple.tpl.html",'<span class="ui-select-match"><li class="ui-select-match-item select2-search-choice" ng-repeat="$item in $select.selected" ng-class="{\'select2-search-choice-focus\':$select.activeMatchIndex === $index, \'select2-locked\':$select.isLocked(this, $index)}"><span uis-transclude-append=""></span> <a href="javascript:;" class="ui-select-match-close select2-search-choice-close" ng-click="$select.removeChoice($index)" tabindex="-1"></a></li></span>'),e.put("select2/match.tpl.html",'<a class="select2-choice ui-select-match" ng-class="{\'select2-default\': $select.isEmpty()}" ng-click="$select.activate()" aria-label="{{ $select.baseTitle }} select"><span ng-show="$select.isEmpty()" class="select2-chosen">{{$select.placeholder}}</span> <span ng-hide="$select.isEmpty()" class="select2-chosen" ng-transclude=""></span> <abbr ng-if="$select.allowClear && !$select.isEmpty()" class="select2-search-choice-close" ng-click="$select.clear($event)"></abbr> <span class="select2-arrow ui-select-toggle" ng-click="$select.toggle($event)"><b></b></span></a>'),e.put("select2/select-multiple.tpl.html",'<div class="ui-select-container ui-select-multiple select2 select2-container select2-container-multi" ng-class="{\'select2-container-active select2-dropdown-open open\': $select.open,\n                \'select2-container-disabled\': $select.disabled}"><ul class="select2-choices"><span class="ui-select-match"></span><li class="select2-search-field"><input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="combobox" aria-expanded="true" aria-owns="ui-select-choices-{{ $select.generatedId }}" aria-label="{{ $select.baseTitle }}" aria-activedescendant="ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}" class="select2-input ui-select-search" placeholder="{{$select.getPlaceholder()}}" ng-disabled="$select.disabled" ng-hide="$select.disabled" ng-model="$select.search" ng-click="$select.activate()" style="width: 34px;"></li></ul><div class="select2-drop select2-with-searchbox select2-drop-active" ng-class="{\'select2-display-none\': !$select.open}"><div class="ui-select-choices"></div></div></div>'),e.put("select2/select.tpl.html",'<div class="ui-select-container select2 select2-container" ng-class="{\'select2-container-active select2-dropdown-open open\': $select.open,\n                \'select2-container-disabled\': $select.disabled,\n                \'select2-container-active\': $select.focus,\n                \'select2-allowclear\': $select.allowClear && !$select.isEmpty()}"><div class="ui-select-match"></div><div class="select2-drop select2-with-searchbox select2-drop-active" ng-class="{\'select2-display-none\': !$select.open}"><div class="select2-search" ng-show="$select.searchEnabled"><input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="combobox" aria-expanded="true" aria-owns="ui-select-choices-{{ $select.generatedId }}" aria-label="{{ $select.baseTitle }}" aria-activedescendant="ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}" class="ui-select-search select2-input" ng-model="$select.search"></div><div class="ui-select-choices"></div></div></div>'),e.put("selectize/choices.tpl.html",'<div ng-show="$select.open" class="ui-select-choices selectize-dropdown single"><div class="ui-select-choices-content selectize-dropdown-content"><div class="ui-select-choices-group optgroup" role="listbox"><div ng-show="$select.isGrouped" class="ui-select-choices-group-label optgroup-header" ng-bind="$group.name"></div><div role="option" class="ui-select-choices-row" ng-class="{active: $select.isActive(this), disabled: $select.isDisabled(this)}"><div class="option ui-select-choices-row-inner" data-selectable=""></div></div></div></div></div>'),e.put("selectize/match.tpl.html",'<div ng-hide="($select.open || $select.isEmpty())" class="ui-select-match" ng-transclude=""></div>'),e.put("selectize/select.tpl.html",'<div class="ui-select-container selectize-control single" ng-class="{\'open\': $select.open}"><div class="selectize-input" ng-class="{\'focus\': $select.open, \'disabled\': $select.disabled, \'selectize-focus\' : $select.focus}" ng-click="$select.activate()"><div class="ui-select-match"></div><input type="text" autocomplete="off" tabindex="-1" class="ui-select-search ui-select-toggle" ng-click="$select.toggle($event)" placeholder="{{$select.placeholder}}" ng-model="$select.search" ng-hide="!$select.searchEnabled || ($select.selected && !$select.open)" ng-disabled="$select.disabled" aria-label="{{ $select.baseTitle }}"></div><div class="ui-select-choices"></div></div>')}]);
\ No newline at end of file
+!function(){"use strict";var e={TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,COMMAND:91,MAP:{91:"COMMAND",8:"BACKSPACE",9:"TAB",13:"ENTER",16:"SHIFT",17:"CTRL",18:"ALT",19:"PAUSEBREAK",20:"CAPSLOCK",27:"ESC",32:"SPACE",33:"PAGE_UP",34:"PAGE_DOWN",35:"END",36:"HOME",37:"LEFT",38:"UP",39:"RIGHT",40:"DOWN",43:"+",44:"PRINTSCREEN",45:"INSERT",46:"DELETE",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NUMLOCK",145:"SCROLLLOCK",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},isControl:function(t){var c=t.which;switch(c){case e.COMMAND:case e.SHIFT:case e.CTRL:case e.ALT:return!0}return t.metaKey?!0:!1},isFunctionKey:function(e){return e=e.which?e.which:e,e>=112&&123>=e},isVerticalMovement:function(t){return~[e.UP,e.DOWN].indexOf(t)},isHorizontalMovement:function(t){return~[e.LEFT,e.RIGHT,e.BACKSPACE,e.DELETE].indexOf(t)}};void 0===angular.element.prototype.querySelectorAll&&(angular.element.prototype.querySelectorAll=function(e){return angular.element(this[0].querySelectorAll(e))}),void 0===angular.element.prototype.closest&&(angular.element.prototype.closest=function(e){for(var t=this[0],c=t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector;t;){if(c.bind(t)(e))return t;t=t.parentElement}return!1});var t=0,c=angular.module("ui.select",[]).constant("uiSelectConfig",{theme:"bootstrap",searchEnabled:!0,sortable:!1,placeholder:"",refreshDelay:1e3,closeOnSelect:!0,generateId:function(){return t++}}).service("uiSelectMinErr",function(){var e=angular.$$minErr("ui.select");return function(){var t=e.apply(this,arguments),c=t.message.replace(new RegExp("\nhttp://errors.angularjs.org/.*"),"");return new Error(c)}}).directive("uisTranscludeAppend",function(){return{link:function(e,t,c,i,l){l(e,function(e){t.append(e)})}}}).filter("highlight",function(){function e(e){return e.replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}return function(t,c){return c&&t?t.replace(new RegExp(e(c),"gi"),'<span class="ui-select-highlight">$&</span>'):t}});c.service("RepeatParser",["uiSelectMinErr","$parse",function(e,t){var c=this;c.parse=function(c){var i=c.match(/^\s*(?:([\s\S]+?)\s+as\s+)?([\S]+?)\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?\s*$/);if(!i)throw e("iexp","Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'.",c);return{itemName:i[2],source:t(i[3]),trackByExp:i[4],modelMapper:t(i[1]||i[2])}},c.getGroupNgRepeatExpression=function(){return"$group in $select.groups"},c.getNgRepeatExpression=function(e,t,c,i){var l=e+" in "+(i?"$group.items":t);return c&&(l+=" track by "+c),l}}]),c.directive("uiSelectChoices",["uiSelectConfig","RepeatParser","uiSelectMinErr","$compile",function(e,t,c,i){return{restrict:"EA",require:"^uiSelect",replace:!0,transclude:!0,templateUrl:function(t){var c=t.parent().attr("theme")||e.theme;return c+"/choices.tpl.html"},compile:function(l,s){if(!s.repeat)throw c("repeat","Expected 'repeat' expression.");return function(l,s,a,n,r){var o=a.groupBy;if(n.parseRepeatAttr(a.repeat,o),n.disableChoiceExpression=a.uiDisableChoice,n.onHighlightCallback=a.onHighlight,o){var u=s.querySelectorAll(".ui-select-choices-group");if(1!==u.length)throw c("rows","Expected 1 .ui-select-choices-group but got '{0}'.",u.length);u.attr("ng-repeat",t.getGroupNgRepeatExpression())}var d=s.querySelectorAll(".ui-select-choices-row");if(1!==d.length)throw c("rows","Expected 1 .ui-select-choices-row but got '{0}'.",d.length);d.attr("ng-repeat",t.getNgRepeatExpression(n.parserResult.itemName,"$select.items",n.parserResult.trackByExp,o)).attr("ng-if","$select.open").attr("ng-mouseenter","$select.setActiveItem("+n.parserResult.itemName+")").attr("ng-click","$select.select("+n.parserResult.itemName+",false,$event)");var p=s.querySelectorAll(".ui-select-choices-row-inner");if(1!==p.length)throw c("rows","Expected 1 .ui-select-choices-row-inner but got '{0}'.",p.length);p.attr("uis-transclude-append",""),i(s,r)(l),l.$watch("$select.search",function(e){e&&!n.open&&n.multiple&&n.activate(!1,!0),n.activeIndex=n.tagging.isActivated?-1:0,n.refresh(a.refresh)}),a.$observe("refreshDelay",function(){var t=l.$eval(a.refreshDelay);n.refreshDelay=void 0!==t?t:e.refreshDelay})}}}}]),c.controller("uiSelectCtrl",["$scope","$element","$timeout","$filter","RepeatParser","uiSelectMinErr","uiSelectConfig",function(t,c,i,l,s,a,n){function r(){(f.resetSearchInput||void 0===f.resetSearchInput&&n.resetSearchInput)&&(f.search=v,f.selected&&f.items.length&&!f.multiple&&(f.activeIndex=f.items.indexOf(f.selected)))}function o(t){var c=!0;switch(t){case e.DOWN:!f.open&&f.multiple?f.activate(!1,!0):f.activeIndex<f.items.length-1&&f.activeIndex++;break;case e.UP:!f.open&&f.multiple?f.activate(!1,!0):(f.activeIndex>0||0===f.search.length&&f.tagging.isActivated&&f.activeIndex>-1)&&f.activeIndex--;break;case e.TAB:(!f.multiple||f.open)&&f.select(f.items[f.activeIndex],!0);break;case e.ENTER:f.open&&f.activeIndex>=0?f.select(f.items[f.activeIndex]):f.activate(!1,!0);break;case e.ESC:f.close();break;default:c=!1}return c}function u(t){function c(){switch(t){case e.LEFT:return~f.activeMatchIndex?o:a;case e.RIGHT:return~f.activeMatchIndex&&n!==a?r:(f.activate(),!1);case e.BACKSPACE:return~f.activeMatchIndex?(f.removeChoice(n),o):a;case e.DELETE:return~f.activeMatchIndex?(f.removeChoice(f.activeMatchIndex),n):!1}}var i=g(m[0]),l=f.selected.length,s=0,a=l-1,n=f.activeMatchIndex,r=f.activeMatchIndex+1,o=f.activeMatchIndex-1,u=n;return i>0||f.search.length&&t==e.RIGHT?!1:(f.close(),u=c(),f.activeMatchIndex=f.selected.length&&u!==!1?Math.min(a,Math.max(s,u)):-1,!0)}function d(e){if(void 0===e||void 0===f.search)return!1;var t=e.filter(function(e){return void 0===f.search.toUpperCase()||void 0===e?!1:e.toUpperCase()===f.search.toUpperCase()}).length>0;return t}function p(e,t){var c=-1;if(angular.isArray(e))for(var i=angular.copy(e),l=0;l<i.length;l++)if(void 0===f.tagging.fct)i[l]+" "+f.taggingLabel===t&&(c=l);else{var s=i[l];s.isTag=!0,angular.equals(s,t)&&(c=l)}return c}function g(e){return angular.isNumber(e.selectionStart)?e.selectionStart:e.value.length}function h(){var e=c.querySelectorAll(".ui-select-choices-content"),t=e.querySelectorAll(".ui-select-choices-row");if(t.length<1)throw a("choices","Expected multiple .ui-select-choices-row but got '{0}'.",t.length);if(!(f.activeIndex<0)){var i=t[f.activeIndex],l=i.offsetTop+i.clientHeight-e[0].scrollTop,s=e[0].offsetHeight;l>s?e[0].scrollTop+=l-s:l<i.clientHeight&&(f.isGrouped&&0===f.activeIndex?e[0].scrollTop=0:e[0].scrollTop-=i.clientHeight-l)}}var f=this,v="";f.placeholder=n.placeholder,f.search=v,f.activeIndex=0,f.activeMatchIndex=-1,f.items=[],f.selected=void 0,f.open=!1,f.focus=!1,f.focusser=void 0,f.disabled=!1,f.searchEnabled=n.searchEnabled,f.sortable=n.sortable,f.resetSearchInput=!0,f.multiple=void 0,f.refreshDelay=n.refreshDelay,f.disableChoiceExpression=void 0,f.tagging={isActivated:!1,fct:void 0},f.taggingTokens={isActivated:!1,tokens:void 0},f.lockChoiceExpression=void 0,f.closeOnSelect=!0,f.clickTriggeredSelect=!1,f.$filter=l,f.isEmpty=function(){return angular.isUndefined(f.selected)||null===f.selected||""===f.selected};var m=c.querySelectorAll("input.ui-select-search");if(1!==m.length)throw a("searchInput","Expected 1 input.ui-select-search but got '{0}'.",m.length);f.activate=function(e,t){f.disabled||f.open||(t||r(),f.focusser.prop("disabled",!0),f.open=!0,f.activeMatchIndex=-1,f.activeIndex=f.activeIndex>=f.items.length?0:f.activeIndex,-1===f.activeIndex&&f.taggingLabel!==!1&&(f.activeIndex=0),i(function(){f.search=e||f.search,m[0].focus()}))},f.findGroupByName=function(e){return f.groups&&f.groups.filter(function(t){return t.name===e})[0]},f.parseRepeatAttr=function(e,c){function i(e){f.groups=[],angular.forEach(e,function(e){var i=t.$eval(c),l=angular.isFunction(i)?i(e):e[i],s=f.findGroupByName(l);s?s.items.push(e):f.groups.push({name:l,items:[e]})}),f.items=[],f.groups.forEach(function(e){f.items=f.items.concat(e.items)})}function l(e){f.items=e}var n=c?i:l;f.parserResult=s.parse(e),f.isGrouped=!!c,f.itemProperty=f.parserResult.itemName,t.$watchCollection(f.parserResult.source,function(e){if(void 0===e||null===e)f.items=[];else{if(!angular.isArray(e))throw a("items","Expected an array but got '{0}'.",e);if(f.multiple){var t=e.filter(function(e){return f.selected.indexOf(e)<0});n(t)}else n(e);f.ngModel.$modelValue=null}}),f.multiple&&t.$watchCollection("$select.selected",function(e){var c=f.parserResult.source(t);if(e.length){if(void 0!==c){var i=c.filter(function(t){return e.indexOf(t)<0});n(i)}}else n(c);f.sizeSearchInput()})};var $;f.refresh=function(e){void 0!==e&&($&&i.cancel($),$=i(function(){t.$eval(e)},f.refreshDelay))},f.setActiveItem=function(e){f.activeIndex=f.items.indexOf(e)},f.isActive=function(e){if(!f.open)return!1;var t=f.items.indexOf(e[f.itemProperty]),c=t===f.activeIndex;return!c||0>t&&f.taggingLabel!==!1||0>t&&f.taggingLabel===!1?!1:(c&&!angular.isUndefined(f.onHighlightCallback)&&e.$eval(f.onHighlightCallback),c)},f.isDisabled=function(e){if(f.open){var t,c=f.items.indexOf(e[f.itemProperty]),i=!1;return c>=0&&!angular.isUndefined(f.disableChoiceExpression)&&(t=f.items[c],i=!!e.$eval(f.disableChoiceExpression),t._uiSelectChoiceDisabled=i),i}},f.select=function(e,c,l){if(void 0===e||!e._uiSelectChoiceDisabled){if(!f.items&&!f.search)return;if(!e||!e._uiSelectChoiceDisabled){if(f.tagging.isActivated){if(f.taggingLabel===!1)if(f.activeIndex<0){if(e=void 0!==f.tagging.fct?f.tagging.fct(f.search):f.search,!e||angular.equals(f.items[0],e))return}else e=f.items[f.activeIndex];else if(0===f.activeIndex){if(void 0===e)return;if(void 0!==f.tagging.fct&&"string"==typeof e){if(e=f.tagging.fct(f.search),!e)return}else"string"==typeof e&&(e=e.replace(f.taggingLabel,"").trim())}if(f.selected&&angular.isArray(f.selected)&&f.selected.filter(function(t){return angular.equals(t,e)}).length>0)return void f.close(c)}var s={};s[f.parserResult.itemName]=e,f.multiple?(f.selected.push(e),f.sizeSearchInput()):f.selected=e,i(function(){f.onSelectCallback(t,{$item:e,$model:f.parserResult.modelMapper(t,s)})}),(!f.multiple||f.closeOnSelect)&&f.close(c),l&&"click"===l.type&&(f.clickTriggeredSelect=!0)}}},f.close=function(e){f.open&&(f.ngModel&&f.ngModel.$setTouched&&f.ngModel.$setTouched(),r(),f.open=!1,f.multiple||i(function(){f.focusser.prop("disabled",!1),e||f.focusser[0].focus()},0,!1))},f.clear=function(e){f.select(void 0),e.stopPropagation(),f.focusser[0].focus()},f.toggle=function(e){f.open?(f.close(),e.preventDefault(),e.stopPropagation()):f.activate()},f.isLocked=function(e,t){var c,i=f.selected[t];return i&&!angular.isUndefined(f.lockChoiceExpression)&&(c=!!e.$eval(f.lockChoiceExpression),i._uiSelectChoiceLocked=c),c},f.removeChoice=function(e){var c=f.selected[e];if(!c._uiSelectChoiceLocked){var l={};l[f.parserResult.itemName]=c,f.selected.splice(e,1),f.activeMatchIndex=-1,f.sizeSearchInput(),i(function(){f.onRemoveCallback(t,{$item:c,$model:f.parserResult.modelMapper(t,l)})})}},f.getPlaceholder=function(){return f.multiple&&f.selected.length?void 0:f.placeholder};var b;f.sizeSearchInput=function(){var e=m[0],c=m.parent().parent()[0];m.css("width","10px");var l=function(){var t=c.clientWidth-e.offsetLeft-10;50>t&&(t=c.clientWidth),m.css("width",t+"px")};i(function(){0!==c.clientWidth||b?b||l():b=t.$watch(function(){return c.clientWidth},function(e){0!==e&&(l(),b(),b=null)})},0,!1)},m.on("keydown",function(c){var l=c.which;t.$apply(function(){var t=!1,s=!1;if(f.multiple&&e.isHorizontalMovement(l)&&(t=u(l)),!t&&(f.items.length>0||f.tagging.isActivated)&&(t=o(l),f.taggingTokens.isActivated)){for(var a=0;a<f.taggingTokens.tokens.length;a++)f.taggingTokens.tokens[a]===e.MAP[c.keyCode]&&f.search.length>0&&(s=!0);s&&i(function(){m.triggerHandler("tagged");var t=f.search.replace(e.MAP[c.keyCode],"").trim();f.tagging.fct&&(t=f.tagging.fct(t)),t&&f.select(t,!0)})}t&&l!=e.TAB&&(c.preventDefault(),c.stopPropagation())}),e.isVerticalMovement(l)&&f.items.length>0&&h()}),m.on("paste",function(e){var t=e.originalEvent.clipboardData.getData("text/plain");if(t&&t.length>0&&f.taggingTokens.isActivated&&f.tagging.fct){var c=t.split(f.taggingTokens.tokens[0]);c&&c.length>0&&(angular.forEach(c,function(e){var t=f.tagging.fct(e);t&&f.select(t,!0)}),e.preventDefault(),e.stopPropagation())}}),m.on("keyup",function(c){if(e.isVerticalMovement(c.which)||t.$evalAsync(function(){f.activeIndex=f.taggingLabel===!1?-1:0}),f.tagging.isActivated&&f.search.length>0){if(c.which===e.TAB||e.isControl(c)||e.isFunctionKey(c)||c.which===e.ESC||e.isVerticalMovement(c.which))return;if(f.activeIndex=f.taggingLabel===!1?-1:0,f.taggingLabel===!1)return;var i,l,s,a,n=angular.copy(f.items),r=angular.copy(f.items),o=!1,u=-1;if(void 0!==f.tagging.fct){if(s=f.$filter("filter")(n,{isTag:!0}),s.length>0&&(a=s[0]),n.length>0&&a&&(o=!0,n=n.slice(1,n.length),r=r.slice(1,r.length)),i=f.tagging.fct(f.search),i.isTag=!0,r.filter(function(e){return angular.equals(e,f.tagging.fct(f.search))}).length>0)return;i.isTag=!0}else{if(s=f.$filter("filter")(n,function(e){return e.match(f.taggingLabel)}),s.length>0&&(a=s[0]),l=n[0],void 0!==l&&n.length>0&&a&&(o=!0,n=n.slice(1,n.length),r=r.slice(1,r.length)),i=f.search+" "+f.taggingLabel,p(f.selected,f.search)>-1)return;if(d(r.concat(f.selected)))return void(o&&(n=r,t.$evalAsync(function(){f.activeIndex=0,f.items=n})));if(d(r))return void(o&&(f.items=r.slice(1,r.length)))}o&&(u=p(f.selected,i)),u>-1?n=n.slice(u+1,n.length-1):(n=[],n.push(i),n=n.concat(r)),t.$evalAsync(function(){f.activeIndex=0,f.items=n})}}),m.on("tagged",function(){i(function(){r()})}),m.on("blur",function(){i(function(){f.activeMatchIndex=-1})}),t.$on("$destroy",function(){m.off("keyup keydown tagged blur paste")})}]),c.directive("uiSelect",["$document","uiSelectConfig","uiSelectMinErr","$compile","$parse",function(t,c,i,l,s){return{restrict:"EA",templateUrl:function(e,t){var i=t.theme||c.theme;return i+(angular.isDefined(t.multiple)?"/select-multiple.tpl.html":"/select.tpl.html")},replace:!0,transclude:!0,require:["uiSelect","^ngModel"],scope:!0,controller:"uiSelectCtrl",controllerAs:"$select",link:function(a,n,r,o,u){function d(e){if(p.open){var t=!1;if(t=window.jQuery?window.jQuery.contains(n[0],e.target):n[0].contains(e.target),!t&&!p.clickTriggeredSelect){var c=["input","button","textarea"],i=angular.element(e.target).scope(),l=i&&i.$select&&i.$select!==p;l||(l=~c.indexOf(e.target.tagName.toLowerCase())),p.close(l),a.$digest()}p.clickTriggeredSelect=!1}}var p=o[0],g=o[1],h=n.querySelectorAll("input.ui-select-search");p.generatedId=c.generateId(),p.baseTitle=r.title||"Select box",p.focusserTitle=p.baseTitle+" focus",p.focusserId="focusser-"+p.generatedId,p.multiple=angular.isDefined(r.multiple)&&(""===r.multiple||"multiple"===r.multiple.toLowerCase()||"true"===r.multiple.toLowerCase()),p.closeOnSelect=function(){return angular.isDefined(r.closeOnSelect)?s(r.closeOnSelect)():c.closeOnSelect}(),p.onSelectCallback=s(r.onSelect),p.onRemoveCallback=s(r.onRemove),g.$parsers.unshift(function(e){var t,c={};if(p.multiple){for(var i=[],l=p.selected.length-1;l>=0;l--)c={},c[p.parserResult.itemName]=p.selected[l],t=p.parserResult.modelMapper(a,c),i.unshift(t);return i}return c={},c[p.parserResult.itemName]=e,t=p.parserResult.modelMapper(a,c)}),g.$formatters.unshift(function(e){var t,c=p.parserResult.source(a,{$select:{search:""}}),i={};if(c){if(p.multiple){var l=[],s=function(e,c){if(!e||!e.length)return l.unshift(c),!0;for(var s=e.length-1;s>=0;s--){if(i[p.parserResult.itemName]=e[s],t=p.parserResult.modelMapper(a,i),p.parserResult.trackByExp){var n=/\.(.+)/.exec(p.parserResult.trackByExp);if(n.length>0&&t[n[1]]==c[n[1]])return l.unshift(e[s]),!0}if(t==c)return l.unshift(e[s]),!0}return!1};if(!e)return l;for(var n=e.length-1;n>=0;n--)s(p.selected,e[n])||s(c,e[n]);return l}var r=function(c){return i[p.parserResult.itemName]=c,t=p.parserResult.modelMapper(a,i),t==e};if(p.selected&&r(p.selected))return p.selected;for(var o=c.length-1;o>=0;o--)if(r(c[o]))return c[o]}return e}),p.ngModel=g,p.choiceGrouped=function(e){return p.isGrouped&&e&&e.name};var f=angular.element("<input ng-disabled='$select.disabled' class='ui-select-focusser ui-select-offscreen' type='text' id='{{ $select.focusserId }}' aria-label='{{ $select.focusserTitle }}' aria-haspopup='true' role='button' />");r.tabindex&&r.$observe("tabindex",function(e){p.multiple?h.attr("tabindex",e):f.attr("tabindex",e),n.removeAttr("tabindex")}),l(f)(a),p.focusser=f,p.multiple||(n.append(f),f.bind("focus",function(){a.$evalAsync(function(){p.focus=!0})}),f.bind("blur",function(){a.$evalAsync(function(){p.focus=!1})}),f.bind("keydown",function(t){return t.which===e.BACKSPACE?(t.preventDefault(),t.stopPropagation(),p.select(void 0),void a.$apply()):void(t.which===e.TAB||e.isControl(t)||e.isFunctionKey(t)||t.which===e.ESC||((t.which==e.DOWN||t.which==e.UP||t.which==e.ENTER||t.which==e.SPACE)&&(t.preventDefault(),t.stopPropagation(),p.activate()),a.$digest()))}),f.bind("keyup input",function(t){t.which===e.TAB||e.isControl(t)||e.isFunctionKey(t)||t.which===e.ESC||t.which==e.ENTER||t.which===e.BACKSPACE||(p.activate(f.val()),f.val(""),a.$digest())})),a.$watch("searchEnabled",function(){var e=a.$eval(r.searchEnabled);p.searchEnabled=void 0!==e?e:c.searchEnabled}),a.$watch("sortable",function(){var e=a.$eval(r.sortable);p.sortable=void 0!==e?e:c.sortable}),r.$observe("disabled",function(){p.disabled=void 0!==r.disabled?r.disabled:!1}),r.$observe("resetSearchInput",function(){var e=a.$eval(r.resetSearchInput);p.resetSearchInput=void 0!==e?e:!0}),r.$observe("tagging",function(){if(void 0!==r.tagging){var e=a.$eval(r.tagging);p.tagging={isActivated:!0,fct:e!==!0?e:void 0}}else p.tagging={isActivated:!1,fct:void 0}}),r.$observe("taggingLabel",function(){void 0!==r.tagging&&(p.taggingLabel="false"===r.taggingLabel?!1:void 0!==r.taggingLabel?r.taggingLabel:"(new)")}),r.$observe("taggingTokens",function(){if(void 0!==r.tagging){var e=void 0!==r.taggingTokens?r.taggingTokens.split("|"):[",","ENTER"];p.taggingTokens={isActivated:!0,tokens:e}}}),p.multiple?(a.$watchCollection(function(){return g.$modelValue},function(e,t){t!=e&&(g.$modelValue=null)}),p.firstPass=!0,a.$watchCollection("$select.selected",function(){p.firstPass?p.firstPass=!1:g.$setViewValue(Date.now())}),f.prop("disabled",!0)):a.$watch("$select.selected",function(e){g.$viewValue!==e&&g.$setViewValue(e)}),g.$render=function(){if(p.multiple&&!angular.isArray(g.$viewValue)){if(!angular.isUndefined(g.$viewValue)&&null!==g.$viewValue)throw i("multiarr","Expected model value to be array but got '{0}'",g.$viewValue);p.selected=[]}p.selected=g.$viewValue},t.on("click",d),a.$on("$destroy",function(){t.off("click",d)}),u(a,function(e){var t=angular.element("<div>").append(e),c=t.querySelectorAll(".ui-select-match");if(c.removeAttr("ui-select-match"),c.removeAttr("data-ui-select-match"),1!==c.length)throw i("transcluded","Expected 1 .ui-select-match but got '{0}'.",c.length);n.querySelectorAll(".ui-select-match").replaceWith(c);var l=t.querySelectorAll(".ui-select-choices");if(l.removeAttr("ui-select-choices"),l.removeAttr("data-ui-select-choices"),1!==l.length)throw i("transcluded","Expected 1 .ui-select-choices but got '{0}'.",l.length);n.querySelectorAll(".ui-select-choices").replaceWith(l)})}}}]),c.directive("uiSelectMatch",["uiSelectConfig",function(e){return{restrict:"EA",require:"^uiSelect",replace:!0,transclude:!0,templateUrl:function(t){var c=t.parent().attr("theme")||e.theme,i=t.parent().attr("multiple");return c+(i?"/match-multiple.tpl.html":"/match.tpl.html")},link:function(t,c,i,l){l.lockChoiceExpression=i.uiLockChoice,i.$observe("placeholder",function(t){l.placeholder=void 0!==t?t:e.placeholder}),l.allowClear=angular.isDefined(i.allowClear)?""===i.allowClear?!0:"true"===i.allowClear.toLowerCase():!1,l.multiple&&l.sizeSearchInput()}}}]),c.directive("uiSelectSort",["$timeout","uiSelectConfig","uiSelectMinErr",function(e,t,c){return{require:"^uiSelect",link:function(t,i,l,s){if(null===t[l.uiSelectSort])throw c("sort","Expected a list to sort");var a=angular.extend({axis:"horizontal"},t.$eval(l.uiSelectSortOptions)),n=a.axis,r="dragging",o="dropping",u="dropping-before",d="dropping-after";t.$watch(function(){return s.sortable},function(e){e?i.attr("draggable",!0):i.removeAttr("draggable")}),i.on("dragstart",function(e){i.addClass(r),(e.dataTransfer||e.originalEvent.dataTransfer).setData("text/plain",t.$index)}),i.on("dragend",function(){i.removeClass(r)});var p,g=function(e,t){this.splice(t,0,this.splice(e,1)[0])},h=function(e){e.preventDefault();var t="vertical"===n?e.offsetY||e.layerY||(e.originalEvent?e.originalEvent.offsetY:0):e.offsetX||e.layerX||(e.originalEvent?e.originalEvent.offsetX:0);t<this["vertical"===n?"offsetHeight":"offsetWidth"]/2?(i.removeClass(d),i.addClass(u)):(i.removeClass(u),i.addClass(d))},f=function(t){t.preventDefault();var c=parseInt((t.dataTransfer||t.originalEvent.dataTransfer).getData("text/plain"),10);e.cancel(p),p=e(function(){v(c)},20)},v=function(e){var c=t.$eval(l.uiSelectSort),s=c[e],a=null;a=i.hasClass(u)?e<t.$index?t.$index-1:t.$index:e<t.$index?t.$index:t.$index+1,g.apply(c,[e,a]),t.$apply(function(){t.$emit("uiSelectSort:change",{array:c,item:s,from:e,to:a})}),i.removeClass(o),i.removeClass(u),i.removeClass(d),i.off("drop",f)};i.on("dragenter",function(){i.hasClass(r)||(i.addClass(o),i.on("dragover",h),i.on("drop",f))}),i.on("dragleave",function(){i.removeClass(o),i.removeClass(u),i.removeClass(d),i.off("dragover",h),i.off("drop",f)})}}}])}(),angular.module("ui.select").run(["$templateCache",function(e){e.put("bootstrap/choices.tpl.html",'<ul class="ui-select-choices ui-select-choices-content dropdown-menu" role="listbox" ng-show="$select.items.length > 0"><li class="ui-select-choices-group" id="ui-select-choices-{{ $select.generatedId }}"><div class="divider" ng-show="$select.isGrouped && $index > 0"></div><div ng-show="$select.isGrouped" class="ui-select-choices-group-label dropdown-header" ng-bind="$group.name"></div><div id="ui-select-choices-row-{{ $select.generatedId }}-{{$index}}" class="ui-select-choices-row" ng-class="{active: $select.isActive(this), disabled: $select.isDisabled(this)}" role="option"><a href="javascript:void(0)" class="ui-select-choices-row-inner"></a></div></li></ul>'),e.put("bootstrap/match-multiple.tpl.html",'<span class="ui-select-match"><span ng-repeat="$item in $select.selected"><span class="ui-select-match-item btn btn-default btn-xs" tabindex="-1" type="button" ng-disabled="$select.disabled" ng-click="$select.activeMatchIndex = $index;" ng-class="{\'btn-primary\':$select.activeMatchIndex === $index, \'select-locked\':$select.isLocked(this, $index)}" ui-select-sort="$select.selected"><span class="close ui-select-match-close" ng-hide="$select.disabled" ng-click="$select.removeChoice($index)">&nbsp;&times;</span> <span uis-transclude-append=""></span></span></span></span>'),e.put("bootstrap/match.tpl.html",'<div class="ui-select-match" ng-hide="$select.open" ng-disabled="$select.disabled" ng-class="{\'btn-default-focus\':$select.focus}"><span tabindex="-1" class="btn btn-default form-control ui-select-toggle" aria-label="{{ $select.baseTitle }} activate" ng-disabled="$select.disabled" ng-click="$select.activate()" style="outline: 0;"><span ng-show="$select.isEmpty()" class="ui-select-placeholder text-muted">{{$select.placeholder}}</span> <span ng-hide="$select.isEmpty()" class="ui-select-match-text pull-left" ng-class="{\'ui-select-allow-clear\': $select.allowClear && !$select.isEmpty()}" ng-transclude=""></span> <i class="caret pull-right" ng-click="$select.toggle($event)"></i> <a ng-show="$select.allowClear && !$select.isEmpty()" aria-label="{{ $select.baseTitle }} clear" style="margin-right: 10px" ng-click="$select.clear($event)" class="btn btn-xs btn-link pull-right"><i class="glyphicon glyphicon-remove" aria-hidden="true"></i></a></span></div>'),e.put("bootstrap/select-multiple.tpl.html",'<div class="ui-select-container ui-select-multiple ui-select-bootstrap dropdown form-control" ng-class="{open: $select.open}"><div><div class="ui-select-match"></div><input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" class="ui-select-search input-xs" placeholder="{{$select.getPlaceholder()}}" ng-disabled="$select.disabled" ng-hide="$select.disabled" ng-click="$select.activate()" ng-model="$select.search" role="combobox" aria-label="{{ $select.baseTitle }}" ondrop="return false;"></div><div class="ui-select-choices"></div></div>'),e.put("bootstrap/select.tpl.html",'<div class="ui-select-container ui-select-bootstrap dropdown" ng-class="{open: $select.open}"><div class="ui-select-match"></div><input type="text" autocomplete="off" tabindex="-1" aria-expanded="true" aria-label="{{ $select.baseTitle }}" aria-owns="ui-select-choices-{{ $select.generatedId }}" aria-activedescendant="ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}" class="form-control ui-select-search" placeholder="{{$select.placeholder}}" ng-model="$select.search" ng-show="$select.searchEnabled && $select.open"><div class="ui-select-choices"></div></div>'),e.put("select2/choices.tpl.html",'<ul class="ui-select-choices ui-select-choices-content select2-results"><li class="ui-select-choices-group" ng-class="{\'select2-result-with-children\': $select.choiceGrouped($group) }"><div ng-show="$select.choiceGrouped($group)" class="ui-select-choices-group-label select2-result-label" ng-bind="$group.name"></div><ul role="listbox" id="ui-select-choices-{{ $select.generatedId }}" ng-class="{\'select2-result-sub\': $select.choiceGrouped($group), \'select2-result-single\': !$select.choiceGrouped($group) }"><li role="option" id="ui-select-choices-row-{{ $select.generatedId }}-{{$index}}" class="ui-select-choices-row" ng-class="{\'select2-highlighted\': $select.isActive(this), \'select2-disabled\': $select.isDisabled(this)}"><div class="select2-result-label ui-select-choices-row-inner"></div></li></ul></li></ul>'),e.put("select2/match-multiple.tpl.html",'<span class="ui-select-match"><li class="ui-select-match-item select2-search-choice" ng-repeat="$item in $select.selected" ng-class="{\'select2-search-choice-focus\':$select.activeMatchIndex === $index, \'select2-locked\':$select.isLocked(this, $index)}" ui-select-sort="$select.selected"><span uis-transclude-append=""></span> <a href="javascript:;" class="ui-select-match-close select2-search-choice-close" ng-click="$select.removeChoice($index)" tabindex="-1"></a></li></span>'),e.put("select2/match.tpl.html",'<a class="select2-choice ui-select-match" ng-class="{\'select2-default\': $select.isEmpty()}" ng-click="$select.activate()" aria-label="{{ $select.baseTitle }} select"><span ng-show="$select.isEmpty()" class="select2-chosen">{{$select.placeholder}}</span> <span ng-hide="$select.isEmpty()" class="select2-chosen" ng-transclude=""></span> <abbr ng-if="$select.allowClear && !$select.isEmpty()" class="select2-search-choice-close" ng-click="$select.clear($event)"></abbr> <span class="select2-arrow ui-select-toggle" ng-click="$select.toggle($event)"><b></b></span></a>'),e.put("select2/select-multiple.tpl.html",'<div class="ui-select-container ui-select-multiple select2 select2-container select2-container-multi" ng-class="{\'select2-container-active select2-dropdown-open open\': $select.open,\n                \'select2-container-disabled\': $select.disabled}"><ul class="select2-choices"><span class="ui-select-match"></span><li class="select2-search-field"><input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="combobox" aria-expanded="true" aria-owns="ui-select-choices-{{ $select.generatedId }}" aria-label="{{ $select.baseTitle }}" aria-activedescendant="ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}" class="select2-input ui-select-search" placeholder="{{$select.getPlaceholder()}}" ng-disabled="$select.disabled" ng-hide="$select.disabled" ng-model="$select.search" ng-click="$select.activate()" style="width: 34px;" ondrop="return false;"></li></ul><div class="select2-drop select2-with-searchbox select2-drop-active" ng-class="{\'select2-display-none\': !$select.open}"><div class="ui-select-choices"></div></div></div>'),e.put("select2/select.tpl.html",'<div class="ui-select-container select2 select2-container" ng-class="{\'select2-container-active select2-dropdown-open open\': $select.open,\n                \'select2-container-disabled\': $select.disabled,\n                \'select2-container-active\': $select.focus,\n                \'select2-allowclear\': $select.allowClear && !$select.isEmpty()}"><div class="ui-select-match"></div><div class="select2-drop select2-with-searchbox select2-drop-active" ng-class="{\'select2-display-none\': !$select.open}"><div class="select2-search" ng-show="$select.searchEnabled"><input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="combobox" aria-expanded="true" aria-owns="ui-select-choices-{{ $select.generatedId }}" aria-label="{{ $select.baseTitle }}" aria-activedescendant="ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}" class="ui-select-search select2-input" ng-model="$select.search"></div><div class="ui-select-choices"></div></div></div>'),e.put("selectize/choices.tpl.html",'<div ng-show="$select.open" class="ui-select-choices selectize-dropdown single"><div class="ui-select-choices-content selectize-dropdown-content"><div class="ui-select-choices-group optgroup" role="listbox"><div ng-show="$select.isGrouped" class="ui-select-choices-group-label optgroup-header" ng-bind="$group.name"></div><div role="option" class="ui-select-choices-row" ng-class="{active: $select.isActive(this), disabled: $select.isDisabled(this)}"><div class="option ui-select-choices-row-inner" data-selectable=""></div></div></div></div></div>'),e.put("selectize/match.tpl.html",'<div ng-hide="($select.open || $select.isEmpty())" class="ui-select-match" ng-transclude=""></div>'),e.put("selectize/select.tpl.html",'<div class="ui-select-container selectize-control single" ng-class="{\'open\': $select.open}"><div class="selectize-input" ng-class="{\'focus\': $select.open, \'disabled\': $select.disabled, \'selectize-focus\' : $select.focus}" ng-click="$select.activate()"><div class="ui-select-match"></div><input type="text" autocomplete="off" tabindex="-1" class="ui-select-search ui-select-toggle" ng-click="$select.toggle($event)" placeholder="{{$select.placeholder}}" ng-model="$select.search" ng-hide="!$select.searchEnabled || ($select.selected && !$select.open)" ng-disabled="$select.disabled" aria-label="{{ $select.baseTitle }}"></div><div class="ui-select-choices"></div></div>')}]);
\ No newline at end of file
diff --git a/package.json b/package.json
index 0df3ff3a5..52b98f46d 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,7 @@
   "repository": {
     "url": "git://github.com/angular-ui/ui-select.git"
   },
-  "version": "0.9.9",
+  "version": "0.10.0",
   "devDependencies": {
     "bower": "~1.3",
     "del": "~0.1.1",