diff --git a/dist/select.css b/dist/select.css index bc7d86104..a38cdbda3 100644 --- a/dist/select.css +++ b/dist/select.css @@ -1,7 +1,7 @@ /*! * ui-select * http://github.com/angular-ui/ui-select - * Version: 0.14.1 - 2016-01-27T22:27:00.588Z + * Version: 0.14.2 - 2016-02-15T14:03:12.217Z * License: MIT */ diff --git a/dist/select.js b/dist/select.js index e4ac95e24..41909a753 100644 --- a/dist/select.js +++ b/dist/select.js @@ -1,7 +1,7 @@ /*! * ui-select * http://github.com/angular-ui/ui-select - * Version: 0.14.1 - 2016-01-27T22:27:00.452Z + * Version: 0.14.2 - 2016-02-15T14:03:12.096Z * License: MIT */ @@ -145,7 +145,7 @@ var uis = angular.module('ui.select', []) */ .filter('highlight', function() { function escapeRegexp(queryToEscape) { - return queryToEscape.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1'); + return ('' + queryToEscape).replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1'); } return function(matchItem, query) { @@ -1002,7 +1002,7 @@ uis.directive('uiSelect', if (!contains && !$select.clickTriggeredSelect) { //Will lose focus only with certain targets - var focusableControls = ['input','button','textarea']; + var focusableControls = ['input','button','textarea','select']; var targetController = angular.element(e.target).controller('uiSelect'); //To check if target is other ui-select var skipFocusser = targetController && targetController !== $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 @@ -1218,6 +1218,10 @@ uis.directive('uiSelectMatch', ['uiSelectConfig', function(uiSelectConfig) { $select.placeholder = placeholder !== undefined ? placeholder : uiSelectConfig.placeholder; }); + attrs.$observe('placeholderAlwaysVisible', function(placeholderAlwaysVisible) { + $select.placeholderAlwaysVisible = placeholderAlwaysVisible !== undefined ? placeholderAlwaysVisible : uiSelectConfig.placeholderAlwaysVisible; + }); + function setAllowClear(allow) { $select.allowClear = (angular.isDefined(allow)) ? (allow === '') ? true : (allow.toLowerCase() === 'true') : false; } @@ -1244,7 +1248,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec $select = $scope.$select, ngModel; - //Wait for link fn to inject it + //Wait for link fn to inject it $scope.$evalAsync(function(){ ngModel = $scope.ngModel; }); ctrl.activeMatchIndex = -1; @@ -1256,7 +1260,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec ctrl.refreshComponent = function(){ //Remove already selected items - //e.g. When user clicks on a selection, the selected array changes and + //e.g. When user clicks on a selection, the selected array changes and //the dropdown should remove that item $select.refreshItems(); $select.sizeSearchInput(); @@ -1291,7 +1295,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec ctrl.getPlaceholder = function(){ //Refactor single? - if($select.selected && $select.selected.length) return; + if($select.selected && $select.selected.length && !$select.placeholderAlwaysVisible) return; return $select.placeholder; }; @@ -1355,7 +1359,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec }; if (!inputValue) return resultMultiple; //If ngModel was undefined for (var k = inputValue.length - 1; k >= 0; k--) { - //Check model array of currently selected items + //Check model array of currently selected items if (!checkFnMultiple($select.selected, inputValue[k])){ //Check model array of all items available if (!checkFnMultiple(data, inputValue[k])){ @@ -1366,8 +1370,8 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec } return resultMultiple; }); - - //Watch for external model changes + + //Watch for external model changes 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 @@ -1988,4 +1992,4 @@ $templateCache.put("select2/select-multiple.tpl.html","
"); $templateCache.put("selectize/choices.tpl.html","
"); $templateCache.put("selectize/match.tpl.html","
"); -$templateCache.put("selectize/select.tpl.html","
");}]); \ No newline at end of file +$templateCache.put("selectize/select.tpl.html","
");}]); \ No newline at end of file diff --git a/dist/select.min.css b/dist/select.min.css index c883b95e1..211ac813f 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.14.1 - 2016-01-27T22:27:00.588Z + * Version: 0.14.2 - 2016-02-15T14:03:12.217Z * 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}.ui-select-choices-row:hover{background-color:#f5f5f5}.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}body>.select2-container.open{z-index:9999}.ui-select-container[theme=select2].direction-up .ui-select-match{border-radius:0 0 4px 4px}.ui-select-container[theme=select2].direction-up .ui-select-dropdown{border-radius:4px 4px 0 0;border-top-width:1px;border-top-style:solid;box-shadow:0 -4px 8px rgba(0,0,0,.25);margin-top:-4px}.ui-select-container[theme=select2].direction-up .ui-select-dropdown .select2-search{margin-top:4px}.ui-select-container[theme=select2].direction-up.select2-dropdown-open .ui-select-match{border-bottom-color:#5897fb}.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}.ui-select-container[theme=selectize].direction-up .ui-select-dropdown{box-shadow:0 -4px 8px rgba(0,0,0,.25);margin-top:-2px}.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}.input-group>.ui-select-bootstrap>input.ui-select-search.form-control.direction-up{border-radius:4px 0 0 4px!important}.ui-select-bootstrap>.ui-select-match>.btn{text-align:left!important}.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}body>.ui-select-bootstrap.open{z-index:1000}.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}.ui-select-container[theme=bootstrap].direction-up .ui-select-dropdown{box-shadow:0 -4px 8px rgba(0,0,0,.25)} \ No newline at end of file diff --git a/dist/select.min.js b/dist/select.min.js index ea71b5cbf..e00211969 100644 --- a/dist/select.min.js +++ b/dist/select.min.js @@ -1,8 +1,8 @@ /*! * ui-select * http://github.com/angular-ui/ui-select - * Version: 0.14.1 - 2016-01-27T22:27:00.452Z + * Version: 0.14.2 - 2016-02-15T14:03:12.096Z * 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 i=t.which;switch(i){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)},toSeparator:function(t){var i={ENTER:"\n",TAB:" ",SPACE:" "}[t];return i?i:e[t]?void 0: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],i=t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector;t;){if(i.bind(t)(e))return t;t=t.parentElement}return!1});var t=0,i=angular.module("ui.select",[]).constant("uiSelectConfig",{theme:"bootstrap",searchEnabled:!0,sortable:!1,placeholder:"",refreshDelay:1e3,closeOnSelect:!0,dropdownPosition:"auto",generateId:function(){return t++},appendToBody:!1}).service("uiSelectMinErr",function(){var e=angular.$$minErr("ui.select");return function(){var t=e.apply(this,arguments),i=t.message.replace(new RegExp("\nhttp://errors.angularjs.org/.*"),"");return new Error(i)}}).directive("uisTranscludeAppend",function(){return{link:function(e,t,i,c,s){s(e,function(e){t.append(e)})}}}).filter("highlight",function(){function e(e){return e.replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}return function(t,i){return i&&t?(""+t).replace(new RegExp(e(i),"gi"),'$&'):t}}).factory("uisOffset",["$document","$window",function(e,t){return function(i){var c=i[0].getBoundingClientRect();return{width:c.width||i.prop("offsetWidth"),height:c.height||i.prop("offsetHeight"),top:c.top+(t.pageYOffset||e[0].documentElement.scrollTop),left:c.left+(t.pageXOffset||e[0].documentElement.scrollLeft)}}}]);i.directive("uiSelectChoices",["uiSelectConfig","uisRepeatParser","uiSelectMinErr","$compile",function(e,t,i,c){return{restrict:"EA",require:"^uiSelect",replace:!0,transclude:!0,templateUrl:function(t){var i=t.parent().attr("theme")||e.theme;return i+"/choices.tpl.html"},compile:function(s,l){if(!l.repeat)throw i("repeat","Expected 'repeat' expression.");return function(s,l,n,a,r){var o=n.groupBy,u=n.groupFilter;if(a.parseRepeatAttr(n.repeat,o,u),a.disableChoiceExpression=n.uiDisableChoice,a.onHighlightCallback=n.onHighlight,a.dropdownPosition=n.position?n.position.toLowerCase():e.dropdownPosition,o){var d=l.querySelectorAll(".ui-select-choices-group");if(1!==d.length)throw i("rows","Expected 1 .ui-select-choices-group but got '{0}'.",d.length);d.attr("ng-repeat",t.getGroupNgRepeatExpression())}var p=l.querySelectorAll(".ui-select-choices-row");if(1!==p.length)throw i("rows","Expected 1 .ui-select-choices-row but got '{0}'.",p.length);p.attr("ng-repeat",a.parserResult.repeatExpression(o)).attr("ng-if","$select.open").attr("ng-click","$select.select("+a.parserResult.itemName+",false,$event)");var h=l.querySelectorAll(".ui-select-choices-row-inner");if(1!==h.length)throw i("rows","Expected 1 .ui-select-choices-row-inner but got '{0}'.",h.length);h.attr("uis-transclude-append",""),c(l,r)(s),s.$watch("$select.search",function(e){e&&!a.open&&a.multiple&&a.activate(!1,!0),a.activeIndex=a.tagging.isActivated?-1:0,!n.minimumInputLength||a.search.length>=n.minimumInputLength?a.refresh(n.refresh):a.items=[]}),n.$observe("refreshDelay",function(){var t=s.$eval(n.refreshDelay);a.refreshDelay=void 0!==t?t:e.refreshDelay})}}}}]),i.controller("uiSelectCtrl",["$scope","$element","$timeout","$filter","uisRepeatParser","uiSelectMinErr","uiSelectConfig","$parse","$injector",function(t,i,c,s,l,n,a,r,o){function u(){(g.resetSearchInput||void 0===g.resetSearchInput&&a.resetSearchInput)&&(g.search=f,g.selected&&g.items.length&&!g.multiple&&(g.activeIndex=g.items.findIndex(function(e){return angular.equals(this,e)},g.selected)))}function d(e,t){var i,c,s=[];for(i=0;i0||0===g.search.length&&g.tagging.isActivated&&g.activeIndex>-1)&&g.activeIndex--;break;case e.TAB:(!g.multiple||g.open)&&g.select(g.items[g.activeIndex],!0);break;case e.ENTER:g.open&&(g.tagging.isActivated||g.activeIndex>=0)?g.select(g.items[g.activeIndex]):g.activate(!1,!0);break;case e.ESC:g.close();break;default:i=!1}return i}function h(){var e=i.querySelectorAll(".ui-select-choices-content"),t=e.querySelectorAll(".ui-select-choices-row");if(t.length<1)throw n("choices","Expected multiple .ui-select-choices-row but got '{0}'.",t.length);if(!(g.activeIndex<0)){var c=t[g.activeIndex],s=c.offsetTop+c.clientHeight-e[0].scrollTop,l=e[0].offsetHeight;s>l?e[0].scrollTop+=s-l:s=g.items.length?0:g.activeIndex,-1===g.activeIndex&&g.taggingLabel!==!1&&(g.activeIndex=0);var l=i.querySelectorAll(".ui-select-choices-content");g.$animate&&g.$animate.enabled(l[0])?g.$animate.on("enter",l[0],function(t,i){"close"===i&&c(function(){g.focusSearchInput(e)})}):c(function(){g.focusSearchInput(e)})}},g.focusSearchInput=function(e){g.search=e||g.search,g.searchInput[0].focus(),!g.tagging.isActivated&&g.items.length>1&&h()},g.findGroupByName=function(e){return g.groups&&g.groups.filter(function(t){return t.name===e})[0]},g.parseRepeatAttr=function(e,i,c){function s(e){var s=t.$eval(i);if(g.groups=[],angular.forEach(e,function(e){var t=angular.isFunction(s)?s(e):e[s],i=g.findGroupByName(t);i?i.items.push(e):g.groups.push({name:t,items:[e]})}),c){var l=t.$eval(c);angular.isFunction(l)?g.groups=l(g.groups):angular.isArray(l)&&(g.groups=d(g.groups,l))}g.items=[],g.groups.forEach(function(e){g.items=g.items.concat(e.items)})}function a(e){g.items=e}g.setItemsFn=i?s:a,g.parserResult=l.parse(e),g.isGrouped=!!i,g.itemProperty=g.parserResult.itemName;var o=g.parserResult.source,u=function(){var e=o(t);t.$uisSource=Object.keys(e).map(function(t){var i={};return i[g.parserResult.keyName]=t,i.value=e[t],i})};g.parserResult.keyName&&(u(),g.parserResult.source=r("$uisSource"+g.parserResult.filters),t.$watch(o,function(e,t){e!==t&&u()},!0)),g.refreshItems=function(e){e=e||g.parserResult.source(t);var i=g.selected;if(g.isEmpty()||angular.isArray(i)&&!i.length||!g.removeSelected)g.setItemsFn(e);else if(void 0!==e){var c=e.filter(function(e){return i&&i.indexOf(e)<0});g.setItemsFn(c)}("auto"===g.dropdownPosition||"up"===g.dropdownPosition)&&t.calculateDropdownPos()},t.$watchCollection(g.parserResult.source,function(e){if(void 0===e||null===e)g.items=[];else{if(!angular.isArray(e))throw n("items","Expected an array but got '{0}'.",e);g.refreshItems(e),g.ngModel.$modelValue=null}})};var v;g.refresh=function(e){void 0!==e&&(v&&c.cancel(v),v=c(function(){t.$eval(e)},g.refreshDelay))},g.isActive=function(e){if(!g.open)return!1;var t=g.items.indexOf(e[g.itemProperty]),i=t==g.activeIndex;return!i||0>t&&g.taggingLabel!==!1||0>t&&g.taggingLabel===!1?!1:(i&&!angular.isUndefined(g.onHighlightCallback)&&e.$eval(g.onHighlightCallback),i)},g.isDisabled=function(e){if(g.open){var t,i=g.items.indexOf(e[g.itemProperty]),c=!1;return i>=0&&!angular.isUndefined(g.disableChoiceExpression)&&(t=g.items[i],c=!!e.$eval(g.disableChoiceExpression),t._uiSelectChoiceDisabled=c),c}},g.select=function(e,i,s){if(void 0===e||!e._uiSelectChoiceDisabled){if(!g.items&&!g.search&&!g.tagging.isActivated)return;if(!e||!e._uiSelectChoiceDisabled){if(g.tagging.isActivated){if(g.taggingLabel===!1)if(g.activeIndex<0){if(e=void 0!==g.tagging.fct?g.tagging.fct(g.search):g.search,!e||angular.equals(g.items[0],e))return}else e=g.items[g.activeIndex];else if(0===g.activeIndex){if(void 0===e)return;if(void 0!==g.tagging.fct&&"string"==typeof e){if(e=g.tagging.fct(g.search),!e)return}else"string"==typeof e&&(e=e.replace(g.taggingLabel,"").trim())}if(g.selected&&angular.isArray(g.selected)&&g.selected.filter(function(t){return angular.equals(t,e)}).length>0)return g.close(i),void 0}t.$broadcast("uis:select",e);var l={};l[g.parserResult.itemName]=e,c(function(){g.onSelectCallback(t,{$item:e,$model:g.parserResult.modelMapper(t,l)})}),g.closeOnSelect&&g.close(i),s&&"click"===s.type&&(g.clickTriggeredSelect=!0)}}},g.close=function(e){g.open&&(g.ngModel&&g.ngModel.$setTouched&&g.ngModel.$setTouched(),u(),g.open=!1,t.$broadcast("uis:close",e))},g.setFocus=function(){g.focus||g.focusInput[0].focus()},g.clear=function(e){g.select(void 0),e.stopPropagation(),c(function(){g.focusser[0].focus()},0,!1)},g.toggle=function(e){g.open?(g.close(),e.preventDefault(),e.stopPropagation()):g.activate()},g.isLocked=function(e,t){var i,c=g.selected[t];return c&&!angular.isUndefined(g.lockChoiceExpression)&&(i=!!e.$eval(g.lockChoiceExpression),c._uiSelectChoiceLocked=i),i};var m=null;g.sizeSearchInput=function(){var e=g.searchInput[0],i=g.searchInput.parent().parent()[0],s=function(){return i.clientWidth*!!e.offsetParent},l=function(t){if(0===t)return!1;var i=t-e.offsetLeft-10;return 50>i&&(i=t),g.searchInput.css("width",i+"px"),!0};g.searchInput.css("width","10px"),c(function(){null!==m||l(s())||(m=t.$watch(s,function(e){l(e)&&(m(),m=null)}))})},g.searchInput.on("keydown",function(i){var s=i.which;t.$apply(function(){var t=!1;if((g.items.length>0||g.tagging.isActivated)&&(p(s),g.taggingTokens.isActivated)){for(var l=0;l0&&(t=!0);t&&c(function(){g.searchInput.triggerHandler("tagged");var t=g.search.replace(e.MAP[i.keyCode],"").trim();g.tagging.fct&&(t=g.tagging.fct(t)),t&&g.select(t,!0)})}}),e.isVerticalMovement(s)&&g.items.length>0&&h(),(s===e.ENTER||s===e.ESC)&&(i.preventDefault(),i.stopPropagation())}),g.searchInput.on("paste",function(t){var i=t.originalEvent.clipboardData.getData("text/plain");if(i&&i.length>0&&g.taggingTokens.isActivated){var c=e.toSeparator(g.taggingTokens.tokens[0]),s=i.split(c);if(s&&s.length>0){var l=g.search;angular.forEach(s,function(e){g.search=e,g.select(e,!0)}),g.search=l,t.preventDefault(),t.stopPropagation()}}}),g.searchInput.on("tagged",function(){c(function(){u()})}),t.$on("$destroy",function(){g.searchInput.off("keyup keydown tagged blur paste")})}]),Array.prototype.findIndex||(Array.prototype.findIndex=function(e){if(null===this)throw new TypeError("Array.prototype.findIndex called on null or undefined");if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var t,i=Object(this),c=i.length>>>0,s=arguments[1],l=0;c>l;l++)if(t=i[l],e.call(s,t,l,i))return l;return-1}),i.directive("uiSelect",["$document","uiSelectConfig","uiSelectMinErr","uisOffset","$compile","$parse","$timeout",function(e,t,i,c,s,l,n){return{restrict:"EA",templateUrl:function(e,i){var c=i.theme||t.theme;return c+(angular.isDefined(i.multiple)?"/select-multiple.tpl.html":"/select.tpl.html")},replace:!0,transclude:!0,require:["uiSelect","^ngModel"],scope:!0,controller:"uiSelectCtrl",controllerAs:"$select",compile:function(s,a){return angular.isDefined(a.multiple)?s.append("").removeAttr("multiple"):s.append(""),a.inputId&&(s.querySelectorAll("input.ui-select-search")[0].id=a.inputId),function(s,a,r,o,u){function d(e){if(g.open){var t=!1;if(t=window.jQuery?window.jQuery.contains(a[0],e.target):a[0].contains(e.target),!t&&!g.clickTriggeredSelect){var i=["input","button","textarea"],c=angular.element(e.target).controller("uiSelect"),l=c&&c!==g;l||(l=~i.indexOf(e.target.tagName.toLowerCase())),g.close(l),s.$digest()}g.clickTriggeredSelect=!1}}function p(){var t=c(a);m=angular.element('
'),m[0].style.width=t.width+"px",m[0].style.height=t.height+"px",a.after(m),$=a[0].style.width,e.find("body").append(a),a[0].style.position="absolute",a[0].style.left=t.left+"px",a[0].style.top=t.top+"px",a[0].style.width=t.width+"px"}function h(){null!==m&&(m.replaceWith(a),m=null,a[0].style.position="",a[0].style.left="",a[0].style.top="",a[0].style.width=$)}var g=o[0],f=o[1];g.generatedId=t.generateId(),g.baseTitle=r.title||"Select box",g.focusserTitle=g.baseTitle+" focus",g.focusserId="focusser-"+g.generatedId,g.closeOnSelect=function(){return angular.isDefined(r.closeOnSelect)?l(r.closeOnSelect)():t.closeOnSelect}(),g.onSelectCallback=l(r.onSelect),g.onRemoveCallback=l(r.onRemove),g.limit=angular.isDefined(r.limit)?parseInt(r.limit,10):void 0,g.ngModel=f,g.choiceGrouped=function(e){return g.isGrouped&&e&&e.name},r.tabindex&&r.$observe("tabindex",function(e){g.focusInput.attr("tabindex",e),a.removeAttr("tabindex")}),s.$watch("searchEnabled",function(){var e=s.$eval(r.searchEnabled);g.searchEnabled=void 0!==e?e:t.searchEnabled}),s.$watch("sortable",function(){var e=s.$eval(r.sortable);g.sortable=void 0!==e?e:t.sortable}),r.$observe("disabled",function(){g.disabled=void 0!==r.disabled?r.disabled:!1}),r.$observe("resetSearchInput",function(){var e=s.$eval(r.resetSearchInput);g.resetSearchInput=void 0!==e?e:!0}),r.$observe("tagging",function(){if(void 0!==r.tagging){var e=s.$eval(r.tagging);g.tagging={isActivated:!0,fct:e!==!0?e:void 0}}else g.tagging={isActivated:!1,fct:void 0}}),r.$observe("taggingLabel",function(){void 0!==r.tagging&&(g.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"];g.taggingTokens={isActivated:!0,tokens:e}}}),angular.isDefined(r.autofocus)&&n(function(){g.setFocus()}),angular.isDefined(r.focusOn)&&s.$on(r.focusOn,function(){n(function(){g.setFocus()})}),e.on("click",d),s.$on("$destroy",function(){e.off("click",d)}),u(s,function(e){var t=angular.element("
").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);a.querySelectorAll(".ui-select-match").replaceWith(c);var s=t.querySelectorAll(".ui-select-choices");if(s.removeAttr("ui-select-choices"),s.removeAttr("data-ui-select-choices"),1!==s.length)throw i("transcluded","Expected 1 .ui-select-choices but got '{0}'.",s.length);a.querySelectorAll(".ui-select-choices").replaceWith(s)});var v=s.$eval(r.appendToBody);(void 0!==v?v:t.appendToBody)&&(s.$watch("$select.open",function(e){e?p():h()}),s.$on("$destroy",function(){h()}));var m=null,$="",b=null,w="direction-up";s.$watch("$select.open",function(){("auto"===g.dropdownPosition||"up"===g.dropdownPosition)&&s.calculateDropdownPos()});var x=function(e,t){e=e||c(a),t=t||c(b),b[0].style.position="absolute",b[0].style.top=-1*t.height+"px",a.addClass(w)},y=function(e,t){a.removeClass(w),e=e||c(a),t=t||c(b),b[0].style.position="",b[0].style.top=""};s.calculateDropdownPos=function(){if(g.open){if(b=angular.element(a).querySelectorAll(".ui-select-dropdown"),0===b.length)return;b[0].style.opacity=0,n(function(){if("up"===g.dropdownPosition)x();else{a.removeClass(w);var t=c(a),i=c(b),s=e[0].documentElement.scrollTop||e[0].body.scrollTop;t.top+t.height+i.height>s+e[0].documentElement.clientHeight?x(t,i):y(t,i)}b[0].style.opacity=1})}else{if(null===b||0===b.length)return;b[0].style.position="",b[0].style.top="",a.removeClass(w)}}}}}}]),i.directive("uiSelectMatch",["uiSelectConfig",function(e){return{restrict:"EA",require:"^uiSelect",replace:!0,transclude:!0,templateUrl:function(t){var i=t.parent().attr("theme")||e.theme,c=t.parent().attr("multiple");return i+(c?"/match-multiple.tpl.html":"/match.tpl.html")},link:function(t,i,c,s){function l(e){s.allowClear=angular.isDefined(e)?""===e?!0:"true"===e.toLowerCase():!1}s.lockChoiceExpression=c.uiLockChoice,c.$observe("placeholder",function(t){s.placeholder=void 0!==t?t:e.placeholder}),c.$observe("allowClear",l),l(c.allowClear),s.multiple&&s.sizeSearchInput()}}}]),i.directive("uiSelectMultiple",["uiSelectMinErr","$timeout",function(t,i){return{restrict:"EA",require:["^uiSelect","^ngModel"],controller:["$scope","$timeout",function(e,t){var i,c=this,s=e.$select;e.$evalAsync(function(){i=e.ngModel}),c.activeMatchIndex=-1,c.updateModel=function(){i.$setViewValue(Date.now()),c.refreshComponent()},c.refreshComponent=function(){s.refreshItems(),s.sizeSearchInput()},c.removeChoice=function(i){var l=s.selected[i];if(!l._uiSelectChoiceLocked){var n={};n[s.parserResult.itemName]=l,s.selected.splice(i,1),c.activeMatchIndex=-1,s.sizeSearchInput(),t(function(){s.onRemoveCallback(e,{$item:l,$model:s.parserResult.modelMapper(e,n)})}),c.updateModel()}},c.getPlaceholder=function(){return s.selected&&s.selected.length?void 0:s.placeholder}}],controllerAs:"$selectMultiple",link:function(c,s,l,n){function a(e){return angular.isNumber(e.selectionStart)?e.selectionStart:e.value.length}function r(t){function i(){switch(t){case e.LEFT:return~h.activeMatchIndex?u:n;case e.RIGHT:return~h.activeMatchIndex&&r!==n?o:(d.activate(),!1);case e.BACKSPACE:return~h.activeMatchIndex?(h.removeChoice(r),u):n;case e.DELETE:return~h.activeMatchIndex?(h.removeChoice(h.activeMatchIndex),r):!1}}var c=a(d.searchInput[0]),s=d.selected.length,l=0,n=s-1,r=h.activeMatchIndex,o=h.activeMatchIndex+1,u=h.activeMatchIndex-1,p=r;return c>0||d.search.length&&t==e.RIGHT?!1:(d.close(),p=i(),h.activeMatchIndex=d.selected.length&&p!==!1?Math.min(n,Math.max(l,p)):-1,!0)}function o(e){if(void 0===e||void 0===d.search)return!1;var t=e.filter(function(e){return void 0===d.search.toUpperCase()||void 0===e?!1:e.toUpperCase()===d.search.toUpperCase()}).length>0;return t}function u(e,t){var i=-1;if(angular.isArray(e))for(var c=angular.copy(e),s=0;s=0;s--)t={},t[d.parserResult.itemName]=d.selected[s],e=d.parserResult.modelMapper(c,t),i.unshift(e);return i}),p.$formatters.unshift(function(e){var t,i=d.parserResult.source(c,{$select:{search:""}}),s={};if(!i)return e;var l=[],n=function(e,i){if(e&&e.length){for(var n=e.length-1;n>=0;n--){if(s[d.parserResult.itemName]=e[n],t=d.parserResult.modelMapper(c,s),d.parserResult.trackByExp){var a=/\.(.+)/.exec(d.parserResult.trackByExp);if(a.length>0&&t[a[1]]==i[a[1]])return l.unshift(e[n]),!0}if(angular.equals(t,i))return l.unshift(e[n]),!0}return!1}};if(!e)return l;for(var a=e.length-1;a>=0;a--)n(d.selected,e[a])||n(i,e[a])||l.unshift(e[a]);return l}),c.$watchCollection(function(){return p.$modelValue},function(e,t){t!=e&&(p.$modelValue=null,h.refreshComponent())}),p.$render=function(){if(!angular.isArray(p.$viewValue)){if(!angular.isUndefined(p.$viewValue)&&null!==p.$viewValue)throw t("multiarr","Expected model value to be array but got '{0}'",p.$viewValue);d.selected=[]}d.selected=p.$viewValue,c.$evalAsync()},c.$on("uis:select",function(e,t){d.selected.length>=d.limit||(d.selected.push(t),h.updateModel())}),c.$on("uis:activate",function(){h.activeMatchIndex=-1}),c.$watch("$select.disabled",function(e,t){t&&!e&&d.sizeSearchInput()}),d.searchInput.on("keydown",function(t){var i=t.which;c.$apply(function(){var c=!1;e.isHorizontalMovement(i)&&(c=r(i)),c&&i!=e.TAB&&(t.preventDefault(),t.stopPropagation())})}),d.searchInput.on("keyup",function(t){if(e.isVerticalMovement(t.which)||c.$evalAsync(function(){d.activeIndex=d.taggingLabel===!1?-1:0}),d.tagging.isActivated&&d.search.length>0){if(t.which===e.TAB||e.isControl(t)||e.isFunctionKey(t)||t.which===e.ESC||e.isVerticalMovement(t.which))return;if(d.activeIndex=d.taggingLabel===!1?-1:0,d.taggingLabel===!1)return;var i,s,l,n,a=angular.copy(d.items),r=angular.copy(d.items),p=!1,h=-1;if(void 0!==d.tagging.fct){if(l=d.$filter("filter")(a,{isTag:!0}),l.length>0&&(n=l[0]),a.length>0&&n&&(p=!0,a=a.slice(1,a.length),r=r.slice(1,r.length)),i=d.tagging.fct(d.search),i.isTag=!0,r.filter(function(e){return angular.equals(e,d.tagging.fct(d.search))}).length>0)return;i.isTag=!0}else{if(l=d.$filter("filter")(a,function(e){return e.match(d.taggingLabel)}),l.length>0&&(n=l[0]),s=a[0],void 0!==s&&a.length>0&&n&&(p=!0,a=a.slice(1,a.length),r=r.slice(1,r.length)),i=d.search+" "+d.taggingLabel,u(d.selected,d.search)>-1)return;if(o(r.concat(d.selected)))return p&&(a=r,c.$evalAsync(function(){d.activeIndex=0,d.items=a})),void 0;if(o(r))return p&&(d.items=r.slice(1,r.length)),void 0}p&&(h=u(d.selected,i)),h>-1?a=a.slice(h+1,a.length-1):(a=[],a.push(i),a=a.concat(r)),c.$evalAsync(function(){d.activeIndex=0,d.items=a})}}),d.searchInput.on("blur",function(){i(function(){h.activeMatchIndex=-1})})}}}]),i.directive("uiSelectSingle",["$timeout","$compile",function(t,i){return{restrict:"EA",require:["^uiSelect","^ngModel"],link:function(c,s,l,n){var a=n[0],r=n[1];r.$parsers.unshift(function(e){var t,i={};return i[a.parserResult.itemName]=e,t=a.parserResult.modelMapper(c,i)}),r.$formatters.unshift(function(e){var t,i=a.parserResult.source(c,{$select:{search:""}}),s={};if(i){var l=function(i){return s[a.parserResult.itemName]=i,t=a.parserResult.modelMapper(c,s),t==e};if(a.selected&&l(a.selected))return a.selected;for(var n=i.length-1;n>=0;n--)if(l(i[n]))return i[n]}return e}),c.$watch("$select.selected",function(e){r.$viewValue!==e&&r.$setViewValue(e)}),r.$render=function(){a.selected=r.$viewValue},c.$on("uis:select",function(e,t){a.selected=t}),c.$on("uis:close",function(e,i){t(function(){a.focusser.prop("disabled",!1),i||a.focusser[0].focus()},0,!1)}),c.$on("uis:activate",function(){o.prop("disabled",!0)});var o=angular.element("");i(o)(c),a.focusser=o,a.focusInput=o,s.parent().append(o),o.bind("focus",function(){c.$evalAsync(function(){a.focus=!0})}),o.bind("blur",function(){c.$evalAsync(function(){a.focus=!1})}),o.bind("keydown",function(t){return t.which===e.BACKSPACE?(t.preventDefault(),t.stopPropagation(),a.select(void 0),c.$apply(),void 0):(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(),a.activate()),c.$digest()),void 0)}),o.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||(a.activate(o.val()),o.val(""),c.$digest())})}}}]),i.directive("uiSelectSort",["$timeout","uiSelectConfig","uiSelectMinErr",function(e,t,i){return{require:"^uiSelect",link:function(t,c,s,l){if(null===t[s.uiSelectSort])throw i("sort","Expected a list to sort");var n=angular.extend({axis:"horizontal"},t.$eval(s.uiSelectSortOptions)),a=n.axis,r="dragging",o="dropping",u="dropping-before",d="dropping-after";t.$watch(function(){return l.sortable},function(e){e?c.attr("draggable",!0):c.removeAttr("draggable")}),c.on("dragstart",function(e){c.addClass(r),(e.dataTransfer||e.originalEvent.dataTransfer).setData("text/plain",t.$index)}),c.on("dragend",function(){c.removeClass(r)});var p,h=function(e,t){this.splice(t,0,this.splice(e,1)[0])},g=function(e){e.preventDefault();var t="vertical"===a?e.offsetY||e.layerY||(e.originalEvent?e.originalEvent.offsetY:0):e.offsetX||e.layerX||(e.originalEvent?e.originalEvent.offsetX:0);t
  • '),e.put("bootstrap/match-multiple.tpl.html",' × '),e.put("bootstrap/match.tpl.html",'
    {{$select.placeholder}}
    '),e.put("bootstrap/select-multiple.tpl.html",''),e.put("bootstrap/select.tpl.html",''),e.put("select2/choices.tpl.html",'
    '),e.put("select2/match-multiple.tpl.html",'
  • '),e.put("select2/match.tpl.html",'{{$select.placeholder}} '),e.put("select2/select-multiple.tpl.html",'
    '),e.put("select2/select.tpl.html",'
    '),e.put("selectize/choices.tpl.html",'
    '),e.put("selectize/match.tpl.html",'
    '),e.put("selectize/select.tpl.html",'
    ') +!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 i=t.which;switch(i){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)},toSeparator:function(t){var i={ENTER:"\n",TAB:" ",SPACE:" "}[t];return i?i:e[t]?void 0: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],i=t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector;t;){if(i.bind(t)(e))return t;t=t.parentElement}return!1});var t=0,i=angular.module("ui.select",[]).constant("uiSelectConfig",{theme:"bootstrap",searchEnabled:!0,sortable:!1,placeholder:"",refreshDelay:1e3,closeOnSelect:!0,dropdownPosition:"auto",generateId:function(){return t++},appendToBody:!1}).service("uiSelectMinErr",function(){var e=angular.$$minErr("ui.select");return function(){var t=e.apply(this,arguments),i=t.message.replace(new RegExp("\nhttp://errors.angularjs.org/.*"),"");return new Error(i)}}).directive("uisTranscludeAppend",function(){return{link:function(e,t,i,c,s){s(e,function(e){t.append(e)})}}}).filter("highlight",function(){function e(e){return(""+e).replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}return function(t,i){return i&&t?(""+t).replace(new RegExp(e(i),"gi"),'$&'):t}}).factory("uisOffset",["$document","$window",function(e,t){return function(i){var c=i[0].getBoundingClientRect();return{width:c.width||i.prop("offsetWidth"),height:c.height||i.prop("offsetHeight"),top:c.top+(t.pageYOffset||e[0].documentElement.scrollTop),left:c.left+(t.pageXOffset||e[0].documentElement.scrollLeft)}}}]);i.directive("uiSelectChoices",["uiSelectConfig","uisRepeatParser","uiSelectMinErr","$compile",function(e,t,i,c){return{restrict:"EA",require:"^uiSelect",replace:!0,transclude:!0,templateUrl:function(t){var i=t.parent().attr("theme")||e.theme;return i+"/choices.tpl.html"},compile:function(s,l){if(!l.repeat)throw i("repeat","Expected 'repeat' expression.");return function(s,l,n,a,r){var o=n.groupBy,u=n.groupFilter;if(a.parseRepeatAttr(n.repeat,o,u),a.disableChoiceExpression=n.uiDisableChoice,a.onHighlightCallback=n.onHighlight,a.dropdownPosition=n.position?n.position.toLowerCase():e.dropdownPosition,o){var d=l.querySelectorAll(".ui-select-choices-group");if(1!==d.length)throw i("rows","Expected 1 .ui-select-choices-group but got '{0}'.",d.length);d.attr("ng-repeat",t.getGroupNgRepeatExpression())}var p=l.querySelectorAll(".ui-select-choices-row");if(1!==p.length)throw i("rows","Expected 1 .ui-select-choices-row but got '{0}'.",p.length);p.attr("ng-repeat",a.parserResult.repeatExpression(o)).attr("ng-if","$select.open").attr("ng-click","$select.select("+a.parserResult.itemName+",false,$event)");var h=l.querySelectorAll(".ui-select-choices-row-inner");if(1!==h.length)throw i("rows","Expected 1 .ui-select-choices-row-inner but got '{0}'.",h.length);h.attr("uis-transclude-append",""),c(l,r)(s),s.$watch("$select.search",function(e){e&&!a.open&&a.multiple&&a.activate(!1,!0),a.activeIndex=a.tagging.isActivated?-1:0,!n.minimumInputLength||a.search.length>=n.minimumInputLength?a.refresh(n.refresh):a.items=[]}),n.$observe("refreshDelay",function(){var t=s.$eval(n.refreshDelay);a.refreshDelay=void 0!==t?t:e.refreshDelay})}}}}]),i.controller("uiSelectCtrl",["$scope","$element","$timeout","$filter","uisRepeatParser","uiSelectMinErr","uiSelectConfig","$parse","$injector",function(t,i,c,s,l,n,a,r,o){function u(){(g.resetSearchInput||void 0===g.resetSearchInput&&a.resetSearchInput)&&(g.search=f,g.selected&&g.items.length&&!g.multiple&&(g.activeIndex=g.items.findIndex(function(e){return angular.equals(this,e)},g.selected)))}function d(e,t){var i,c,s=[];for(i=0;i0||0===g.search.length&&g.tagging.isActivated&&g.activeIndex>-1)&&g.activeIndex--;break;case e.TAB:(!g.multiple||g.open)&&g.select(g.items[g.activeIndex],!0);break;case e.ENTER:g.open&&(g.tagging.isActivated||g.activeIndex>=0)?g.select(g.items[g.activeIndex]):g.activate(!1,!0);break;case e.ESC:g.close();break;default:i=!1}return i}function h(){var e=i.querySelectorAll(".ui-select-choices-content"),t=e.querySelectorAll(".ui-select-choices-row");if(t.length<1)throw n("choices","Expected multiple .ui-select-choices-row but got '{0}'.",t.length);if(!(g.activeIndex<0)){var c=t[g.activeIndex],s=c.offsetTop+c.clientHeight-e[0].scrollTop,l=e[0].offsetHeight;s>l?e[0].scrollTop+=s-l:s=g.items.length?0:g.activeIndex,-1===g.activeIndex&&g.taggingLabel!==!1&&(g.activeIndex=0);var l=i.querySelectorAll(".ui-select-choices-content");g.$animate&&g.$animate.enabled(l[0])?g.$animate.on("enter",l[0],function(t,i){"close"===i&&c(function(){g.focusSearchInput(e)})}):c(function(){g.focusSearchInput(e)})}},g.focusSearchInput=function(e){g.search=e||g.search,g.searchInput[0].focus(),!g.tagging.isActivated&&g.items.length>1&&h()},g.findGroupByName=function(e){return g.groups&&g.groups.filter(function(t){return t.name===e})[0]},g.parseRepeatAttr=function(e,i,c){function s(e){var s=t.$eval(i);if(g.groups=[],angular.forEach(e,function(e){var t=angular.isFunction(s)?s(e):e[s],i=g.findGroupByName(t);i?i.items.push(e):g.groups.push({name:t,items:[e]})}),c){var l=t.$eval(c);angular.isFunction(l)?g.groups=l(g.groups):angular.isArray(l)&&(g.groups=d(g.groups,l))}g.items=[],g.groups.forEach(function(e){g.items=g.items.concat(e.items)})}function a(e){g.items=e}g.setItemsFn=i?s:a,g.parserResult=l.parse(e),g.isGrouped=!!i,g.itemProperty=g.parserResult.itemName;var o=g.parserResult.source,u=function(){var e=o(t);t.$uisSource=Object.keys(e).map(function(t){var i={};return i[g.parserResult.keyName]=t,i.value=e[t],i})};g.parserResult.keyName&&(u(),g.parserResult.source=r("$uisSource"+g.parserResult.filters),t.$watch(o,function(e,t){e!==t&&u()},!0)),g.refreshItems=function(e){e=e||g.parserResult.source(t);var i=g.selected;if(g.isEmpty()||angular.isArray(i)&&!i.length||!g.removeSelected)g.setItemsFn(e);else if(void 0!==e){var c=e.filter(function(e){return i&&i.indexOf(e)<0});g.setItemsFn(c)}("auto"===g.dropdownPosition||"up"===g.dropdownPosition)&&t.calculateDropdownPos()},t.$watchCollection(g.parserResult.source,function(e){if(void 0===e||null===e)g.items=[];else{if(!angular.isArray(e))throw n("items","Expected an array but got '{0}'.",e);g.refreshItems(e),g.ngModel.$modelValue=null}})};var v;g.refresh=function(e){void 0!==e&&(v&&c.cancel(v),v=c(function(){t.$eval(e)},g.refreshDelay))},g.isActive=function(e){if(!g.open)return!1;var t=g.items.indexOf(e[g.itemProperty]),i=t==g.activeIndex;return!i||0>t&&g.taggingLabel!==!1||0>t&&g.taggingLabel===!1?!1:(i&&!angular.isUndefined(g.onHighlightCallback)&&e.$eval(g.onHighlightCallback),i)},g.isDisabled=function(e){if(g.open){var t,i=g.items.indexOf(e[g.itemProperty]),c=!1;return i>=0&&!angular.isUndefined(g.disableChoiceExpression)&&(t=g.items[i],c=!!e.$eval(g.disableChoiceExpression),t._uiSelectChoiceDisabled=c),c}},g.select=function(e,i,s){if(void 0===e||!e._uiSelectChoiceDisabled){if(!g.items&&!g.search&&!g.tagging.isActivated)return;if(!e||!e._uiSelectChoiceDisabled){if(g.tagging.isActivated){if(g.taggingLabel===!1)if(g.activeIndex<0){if(e=void 0!==g.tagging.fct?g.tagging.fct(g.search):g.search,!e||angular.equals(g.items[0],e))return}else e=g.items[g.activeIndex];else if(0===g.activeIndex){if(void 0===e)return;if(void 0!==g.tagging.fct&&"string"==typeof e){if(e=g.tagging.fct(g.search),!e)return}else"string"==typeof e&&(e=e.replace(g.taggingLabel,"").trim())}if(g.selected&&angular.isArray(g.selected)&&g.selected.filter(function(t){return angular.equals(t,e)}).length>0)return g.close(i),void 0}t.$broadcast("uis:select",e);var l={};l[g.parserResult.itemName]=e,c(function(){g.onSelectCallback(t,{$item:e,$model:g.parserResult.modelMapper(t,l)})}),g.closeOnSelect&&g.close(i),s&&"click"===s.type&&(g.clickTriggeredSelect=!0)}}},g.close=function(e){g.open&&(g.ngModel&&g.ngModel.$setTouched&&g.ngModel.$setTouched(),u(),g.open=!1,t.$broadcast("uis:close",e))},g.setFocus=function(){g.focus||g.focusInput[0].focus()},g.clear=function(e){g.select(void 0),e.stopPropagation(),c(function(){g.focusser[0].focus()},0,!1)},g.toggle=function(e){g.open?(g.close(),e.preventDefault(),e.stopPropagation()):g.activate()},g.isLocked=function(e,t){var i,c=g.selected[t];return c&&!angular.isUndefined(g.lockChoiceExpression)&&(i=!!e.$eval(g.lockChoiceExpression),c._uiSelectChoiceLocked=i),i};var m=null;g.sizeSearchInput=function(){var e=g.searchInput[0],i=g.searchInput.parent().parent()[0],s=function(){return i.clientWidth*!!e.offsetParent},l=function(t){if(0===t)return!1;var i=t-e.offsetLeft-10;return 50>i&&(i=t),g.searchInput.css("width",i+"px"),!0};g.searchInput.css("width","10px"),c(function(){null!==m||l(s())||(m=t.$watch(s,function(e){l(e)&&(m(),m=null)}))})},g.searchInput.on("keydown",function(i){var s=i.which;t.$apply(function(){var t=!1;if((g.items.length>0||g.tagging.isActivated)&&(p(s),g.taggingTokens.isActivated)){for(var l=0;l0&&(t=!0);t&&c(function(){g.searchInput.triggerHandler("tagged");var t=g.search.replace(e.MAP[i.keyCode],"").trim();g.tagging.fct&&(t=g.tagging.fct(t)),t&&g.select(t,!0)})}}),e.isVerticalMovement(s)&&g.items.length>0&&h(),(s===e.ENTER||s===e.ESC)&&(i.preventDefault(),i.stopPropagation())}),g.searchInput.on("paste",function(t){var i=t.originalEvent.clipboardData.getData("text/plain");if(i&&i.length>0&&g.taggingTokens.isActivated){var c=e.toSeparator(g.taggingTokens.tokens[0]),s=i.split(c);if(s&&s.length>0){var l=g.search;angular.forEach(s,function(e){g.search=e,g.select(e,!0)}),g.search=l,t.preventDefault(),t.stopPropagation()}}}),g.searchInput.on("tagged",function(){c(function(){u()})}),t.$on("$destroy",function(){g.searchInput.off("keyup keydown tagged blur paste")})}]),Array.prototype.findIndex||(Array.prototype.findIndex=function(e){if(null===this)throw new TypeError("Array.prototype.findIndex called on null or undefined");if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var t,i=Object(this),c=i.length>>>0,s=arguments[1],l=0;c>l;l++)if(t=i[l],e.call(s,t,l,i))return l;return-1}),i.directive("uiSelect",["$document","uiSelectConfig","uiSelectMinErr","uisOffset","$compile","$parse","$timeout",function(e,t,i,c,s,l,n){return{restrict:"EA",templateUrl:function(e,i){var c=i.theme||t.theme;return c+(angular.isDefined(i.multiple)?"/select-multiple.tpl.html":"/select.tpl.html")},replace:!0,transclude:!0,require:["uiSelect","^ngModel"],scope:!0,controller:"uiSelectCtrl",controllerAs:"$select",compile:function(s,a){return angular.isDefined(a.multiple)?s.append("").removeAttr("multiple"):s.append(""),a.inputId&&(s.querySelectorAll("input.ui-select-search")[0].id=a.inputId),function(s,a,r,o,u){function d(e){if(g.open){var t=!1;if(t=window.jQuery?window.jQuery.contains(a[0],e.target):a[0].contains(e.target),!t&&!g.clickTriggeredSelect){var i=["input","button","textarea","select"],c=angular.element(e.target).controller("uiSelect"),l=c&&c!==g;l||(l=~i.indexOf(e.target.tagName.toLowerCase())),g.close(l),s.$digest()}g.clickTriggeredSelect=!1}}function p(){var t=c(a);m=angular.element('
    '),m[0].style.width=t.width+"px",m[0].style.height=t.height+"px",a.after(m),$=a[0].style.width,e.find("body").append(a),a[0].style.position="absolute",a[0].style.left=t.left+"px",a[0].style.top=t.top+"px",a[0].style.width=t.width+"px"}function h(){null!==m&&(m.replaceWith(a),m=null,a[0].style.position="",a[0].style.left="",a[0].style.top="",a[0].style.width=$)}var g=o[0],f=o[1];g.generatedId=t.generateId(),g.baseTitle=r.title||"Select box",g.focusserTitle=g.baseTitle+" focus",g.focusserId="focusser-"+g.generatedId,g.closeOnSelect=function(){return angular.isDefined(r.closeOnSelect)?l(r.closeOnSelect)():t.closeOnSelect}(),g.onSelectCallback=l(r.onSelect),g.onRemoveCallback=l(r.onRemove),g.limit=angular.isDefined(r.limit)?parseInt(r.limit,10):void 0,g.ngModel=f,g.choiceGrouped=function(e){return g.isGrouped&&e&&e.name},r.tabindex&&r.$observe("tabindex",function(e){g.focusInput.attr("tabindex",e),a.removeAttr("tabindex")}),s.$watch("searchEnabled",function(){var e=s.$eval(r.searchEnabled);g.searchEnabled=void 0!==e?e:t.searchEnabled}),s.$watch("sortable",function(){var e=s.$eval(r.sortable);g.sortable=void 0!==e?e:t.sortable}),r.$observe("disabled",function(){g.disabled=void 0!==r.disabled?r.disabled:!1}),r.$observe("resetSearchInput",function(){var e=s.$eval(r.resetSearchInput);g.resetSearchInput=void 0!==e?e:!0}),r.$observe("tagging",function(){if(void 0!==r.tagging){var e=s.$eval(r.tagging);g.tagging={isActivated:!0,fct:e!==!0?e:void 0}}else g.tagging={isActivated:!1,fct:void 0}}),r.$observe("taggingLabel",function(){void 0!==r.tagging&&(g.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"];g.taggingTokens={isActivated:!0,tokens:e}}}),angular.isDefined(r.autofocus)&&n(function(){g.setFocus()}),angular.isDefined(r.focusOn)&&s.$on(r.focusOn,function(){n(function(){g.setFocus()})}),e.on("click",d),s.$on("$destroy",function(){e.off("click",d)}),u(s,function(e){var t=angular.element("
    ").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);a.querySelectorAll(".ui-select-match").replaceWith(c);var s=t.querySelectorAll(".ui-select-choices");if(s.removeAttr("ui-select-choices"),s.removeAttr("data-ui-select-choices"),1!==s.length)throw i("transcluded","Expected 1 .ui-select-choices but got '{0}'.",s.length);a.querySelectorAll(".ui-select-choices").replaceWith(s)});var v=s.$eval(r.appendToBody);(void 0!==v?v:t.appendToBody)&&(s.$watch("$select.open",function(e){e?p():h()}),s.$on("$destroy",function(){h()}));var m=null,$="",b=null,w="direction-up";s.$watch("$select.open",function(){("auto"===g.dropdownPosition||"up"===g.dropdownPosition)&&s.calculateDropdownPos()});var y=function(e,t){e=e||c(a),t=t||c(b),b[0].style.position="absolute",b[0].style.top=-1*t.height+"px",a.addClass(w)},x=function(e,t){a.removeClass(w),e=e||c(a),t=t||c(b),b[0].style.position="",b[0].style.top=""};s.calculateDropdownPos=function(){if(g.open){if(b=angular.element(a).querySelectorAll(".ui-select-dropdown"),0===b.length)return;b[0].style.opacity=0,n(function(){if("up"===g.dropdownPosition)y();else{a.removeClass(w);var t=c(a),i=c(b),s=e[0].documentElement.scrollTop||e[0].body.scrollTop;t.top+t.height+i.height>s+e[0].documentElement.clientHeight?y(t,i):x(t,i)}b[0].style.opacity=1})}else{if(null===b||0===b.length)return;b[0].style.position="",b[0].style.top="",a.removeClass(w)}}}}}}]),i.directive("uiSelectMatch",["uiSelectConfig",function(e){return{restrict:"EA",require:"^uiSelect",replace:!0,transclude:!0,templateUrl:function(t){var i=t.parent().attr("theme")||e.theme,c=t.parent().attr("multiple");return i+(c?"/match-multiple.tpl.html":"/match.tpl.html")},link:function(t,i,c,s){function l(e){s.allowClear=angular.isDefined(e)?""===e?!0:"true"===e.toLowerCase():!1}s.lockChoiceExpression=c.uiLockChoice,c.$observe("placeholder",function(t){s.placeholder=void 0!==t?t:e.placeholder}),c.$observe("placeholderAlwaysVisible",function(t){s.placeholderAlwaysVisible=void 0!==t?t:e.placeholderAlwaysVisible}),c.$observe("allowClear",l),l(c.allowClear),s.multiple&&s.sizeSearchInput()}}}]),i.directive("uiSelectMultiple",["uiSelectMinErr","$timeout",function(t,i){return{restrict:"EA",require:["^uiSelect","^ngModel"],controller:["$scope","$timeout",function(e,t){var i,c=this,s=e.$select;e.$evalAsync(function(){i=e.ngModel}),c.activeMatchIndex=-1,c.updateModel=function(){i.$setViewValue(Date.now()),c.refreshComponent()},c.refreshComponent=function(){s.refreshItems(),s.sizeSearchInput()},c.removeChoice=function(i){var l=s.selected[i];if(!l._uiSelectChoiceLocked){var n={};n[s.parserResult.itemName]=l,s.selected.splice(i,1),c.activeMatchIndex=-1,s.sizeSearchInput(),t(function(){s.onRemoveCallback(e,{$item:l,$model:s.parserResult.modelMapper(e,n)})}),c.updateModel()}},c.getPlaceholder=function(){return s.selected&&s.selected.length&&!s.placeholderAlwaysVisible?void 0:s.placeholder}}],controllerAs:"$selectMultiple",link:function(c,s,l,n){function a(e){return angular.isNumber(e.selectionStart)?e.selectionStart:e.value.length}function r(t){function i(){switch(t){case e.LEFT:return~h.activeMatchIndex?u:n;case e.RIGHT:return~h.activeMatchIndex&&r!==n?o:(d.activate(),!1);case e.BACKSPACE:return~h.activeMatchIndex?(h.removeChoice(r),u):n;case e.DELETE:return~h.activeMatchIndex?(h.removeChoice(h.activeMatchIndex),r):!1}}var c=a(d.searchInput[0]),s=d.selected.length,l=0,n=s-1,r=h.activeMatchIndex,o=h.activeMatchIndex+1,u=h.activeMatchIndex-1,p=r;return c>0||d.search.length&&t==e.RIGHT?!1:(d.close(),p=i(),h.activeMatchIndex=d.selected.length&&p!==!1?Math.min(n,Math.max(l,p)):-1,!0)}function o(e){if(void 0===e||void 0===d.search)return!1;var t=e.filter(function(e){return void 0===d.search.toUpperCase()||void 0===e?!1:e.toUpperCase()===d.search.toUpperCase()}).length>0;return t}function u(e,t){var i=-1;if(angular.isArray(e))for(var c=angular.copy(e),s=0;s=0;s--)t={},t[d.parserResult.itemName]=d.selected[s],e=d.parserResult.modelMapper(c,t),i.unshift(e);return i}),p.$formatters.unshift(function(e){var t,i=d.parserResult.source(c,{$select:{search:""}}),s={};if(!i)return e;var l=[],n=function(e,i){if(e&&e.length){for(var n=e.length-1;n>=0;n--){if(s[d.parserResult.itemName]=e[n],t=d.parserResult.modelMapper(c,s),d.parserResult.trackByExp){var a=/\.(.+)/.exec(d.parserResult.trackByExp);if(a.length>0&&t[a[1]]==i[a[1]])return l.unshift(e[n]),!0}if(angular.equals(t,i))return l.unshift(e[n]),!0}return!1}};if(!e)return l;for(var a=e.length-1;a>=0;a--)n(d.selected,e[a])||n(i,e[a])||l.unshift(e[a]);return l}),c.$watchCollection(function(){return p.$modelValue},function(e,t){t!=e&&(p.$modelValue=null,h.refreshComponent())}),p.$render=function(){if(!angular.isArray(p.$viewValue)){if(!angular.isUndefined(p.$viewValue)&&null!==p.$viewValue)throw t("multiarr","Expected model value to be array but got '{0}'",p.$viewValue);d.selected=[]}d.selected=p.$viewValue,c.$evalAsync()},c.$on("uis:select",function(e,t){d.selected.length>=d.limit||(d.selected.push(t),h.updateModel())}),c.$on("uis:activate",function(){h.activeMatchIndex=-1}),c.$watch("$select.disabled",function(e,t){t&&!e&&d.sizeSearchInput()}),d.searchInput.on("keydown",function(t){var i=t.which;c.$apply(function(){var c=!1;e.isHorizontalMovement(i)&&(c=r(i)),c&&i!=e.TAB&&(t.preventDefault(),t.stopPropagation())})}),d.searchInput.on("keyup",function(t){if(e.isVerticalMovement(t.which)||c.$evalAsync(function(){d.activeIndex=d.taggingLabel===!1?-1:0}),d.tagging.isActivated&&d.search.length>0){if(t.which===e.TAB||e.isControl(t)||e.isFunctionKey(t)||t.which===e.ESC||e.isVerticalMovement(t.which))return;if(d.activeIndex=d.taggingLabel===!1?-1:0,d.taggingLabel===!1)return;var i,s,l,n,a=angular.copy(d.items),r=angular.copy(d.items),p=!1,h=-1;if(void 0!==d.tagging.fct){if(l=d.$filter("filter")(a,{isTag:!0}),l.length>0&&(n=l[0]),a.length>0&&n&&(p=!0,a=a.slice(1,a.length),r=r.slice(1,r.length)),i=d.tagging.fct(d.search),i.isTag=!0,r.filter(function(e){return angular.equals(e,d.tagging.fct(d.search))}).length>0)return;i.isTag=!0}else{if(l=d.$filter("filter")(a,function(e){return e.match(d.taggingLabel)}),l.length>0&&(n=l[0]),s=a[0],void 0!==s&&a.length>0&&n&&(p=!0,a=a.slice(1,a.length),r=r.slice(1,r.length)),i=d.search+" "+d.taggingLabel,u(d.selected,d.search)>-1)return;if(o(r.concat(d.selected)))return p&&(a=r,c.$evalAsync(function(){d.activeIndex=0,d.items=a})),void 0;if(o(r))return p&&(d.items=r.slice(1,r.length)),void 0}p&&(h=u(d.selected,i)),h>-1?a=a.slice(h+1,a.length-1):(a=[],a.push(i),a=a.concat(r)),c.$evalAsync(function(){d.activeIndex=0,d.items=a})}}),d.searchInput.on("blur",function(){i(function(){h.activeMatchIndex=-1})})}}}]),i.directive("uiSelectSingle",["$timeout","$compile",function(t,i){return{restrict:"EA",require:["^uiSelect","^ngModel"],link:function(c,s,l,n){var a=n[0],r=n[1];r.$parsers.unshift(function(e){var t,i={};return i[a.parserResult.itemName]=e,t=a.parserResult.modelMapper(c,i)}),r.$formatters.unshift(function(e){var t,i=a.parserResult.source(c,{$select:{search:""}}),s={};if(i){var l=function(i){return s[a.parserResult.itemName]=i,t=a.parserResult.modelMapper(c,s),t==e};if(a.selected&&l(a.selected))return a.selected;for(var n=i.length-1;n>=0;n--)if(l(i[n]))return i[n]}return e}),c.$watch("$select.selected",function(e){r.$viewValue!==e&&r.$setViewValue(e)}),r.$render=function(){a.selected=r.$viewValue},c.$on("uis:select",function(e,t){a.selected=t}),c.$on("uis:close",function(e,i){t(function(){a.focusser.prop("disabled",!1),i||a.focusser[0].focus()},0,!1)}),c.$on("uis:activate",function(){o.prop("disabled",!0)});var o=angular.element("");i(o)(c),a.focusser=o,a.focusInput=o,s.parent().append(o),o.bind("focus",function(){c.$evalAsync(function(){a.focus=!0})}),o.bind("blur",function(){c.$evalAsync(function(){a.focus=!1})}),o.bind("keydown",function(t){return t.which===e.BACKSPACE?(t.preventDefault(),t.stopPropagation(),a.select(void 0),c.$apply(),void 0):(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(),a.activate()),c.$digest()),void 0)}),o.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||(a.activate(o.val()),o.val(""),c.$digest())})}}}]),i.directive("uiSelectSort",["$timeout","uiSelectConfig","uiSelectMinErr",function(e,t,i){return{require:"^uiSelect",link:function(t,c,s,l){if(null===t[s.uiSelectSort])throw i("sort","Expected a list to sort");var n=angular.extend({axis:"horizontal"},t.$eval(s.uiSelectSortOptions)),a=n.axis,r="dragging",o="dropping",u="dropping-before",d="dropping-after";t.$watch(function(){return l.sortable},function(e){e?c.attr("draggable",!0):c.removeAttr("draggable")}),c.on("dragstart",function(e){c.addClass(r),(e.dataTransfer||e.originalEvent.dataTransfer).setData("text/plain",t.$index)}),c.on("dragend",function(){c.removeClass(r)});var p,h=function(e,t){this.splice(t,0,this.splice(e,1)[0])},g=function(e){e.preventDefault();var t="vertical"===a?e.offsetY||e.layerY||(e.originalEvent?e.originalEvent.offsetY:0):e.offsetX||e.layerX||(e.originalEvent?e.originalEvent.offsetX:0);t
  • '),e.put("bootstrap/match-multiple.tpl.html",' × '),e.put("bootstrap/match.tpl.html",'
    {{$select.placeholder}}
    '),e.put("bootstrap/select-multiple.tpl.html",''),e.put("bootstrap/select.tpl.html",''),e.put("select2/choices.tpl.html",'
    '),e.put("select2/match-multiple.tpl.html",'
  • '),e.put("select2/match.tpl.html",'{{$select.placeholder}} '),e.put("select2/select-multiple.tpl.html",'
    '),e.put("select2/select.tpl.html",'
    '),e.put("selectize/choices.tpl.html",'
    '),e.put("selectize/match.tpl.html",'
    '),e.put("selectize/select.tpl.html",'
    ') }]); \ No newline at end of file diff --git a/src/uiSelectMatchDirective.js b/src/uiSelectMatchDirective.js index 2f723eaad..f623f3185 100644 --- a/src/uiSelectMatchDirective.js +++ b/src/uiSelectMatchDirective.js @@ -19,6 +19,10 @@ uis.directive('uiSelectMatch', ['uiSelectConfig', function(uiSelectConfig) { $select.placeholder = placeholder !== undefined ? placeholder : uiSelectConfig.placeholder; }); + attrs.$observe('placeholderAlwaysVisible', function(placeholderAlwaysVisible) { + $select.placeholderAlwaysVisible = placeholderAlwaysVisible !== undefined ? placeholderAlwaysVisible : uiSelectConfig.placeholderAlwaysVisible; + }); + function setAllowClear(allow) { $select.allowClear = (angular.isDefined(allow)) ? (allow === '') ? true : (allow.toLowerCase() === 'true') : false; } diff --git a/src/uiSelectMultipleDirective.js b/src/uiSelectMultipleDirective.js index 472555172..333ee883e 100644 --- a/src/uiSelectMultipleDirective.js +++ b/src/uiSelectMultipleDirective.js @@ -9,7 +9,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec $select = $scope.$select, ngModel; - //Wait for link fn to inject it + //Wait for link fn to inject it $scope.$evalAsync(function(){ ngModel = $scope.ngModel; }); ctrl.activeMatchIndex = -1; @@ -21,7 +21,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec ctrl.refreshComponent = function(){ //Remove already selected items - //e.g. When user clicks on a selection, the selected array changes and + //e.g. When user clicks on a selection, the selected array changes and //the dropdown should remove that item $select.refreshItems(); $select.sizeSearchInput(); @@ -56,7 +56,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec ctrl.getPlaceholder = function(){ //Refactor single? - if($select.selected && $select.selected.length) return; + if($select.selected && $select.selected.length && !$select.placeholderAlwaysVisible) return; return $select.placeholder; }; @@ -120,7 +120,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec }; if (!inputValue) return resultMultiple; //If ngModel was undefined for (var k = inputValue.length - 1; k >= 0; k--) { - //Check model array of currently selected items + //Check model array of currently selected items if (!checkFnMultiple($select.selected, inputValue[k])){ //Check model array of all items available if (!checkFnMultiple(data, inputValue[k])){ @@ -131,8 +131,8 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec } return resultMultiple; }); - - //Watch for external model changes + + //Watch for external model changes 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