diff --git a/bower.json b/bower.json index e00315d..96b0413 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-advanced-searchbox", - "version": "3.0.0", + "version": "3.0.1", "homepage": "https://github.com/dnauck/angular-advanced-searchbox", "authors": [ "Daniel Nauck " diff --git a/dist/angular-advanced-searchbox-tpls.js b/dist/angular-advanced-searchbox-tpls.js index 3997fbb..486475c 100644 --- a/dist/angular-advanced-searchbox-tpls.js +++ b/dist/angular-advanced-searchbox-tpls.js @@ -150,6 +150,21 @@ angular.module('angular-advanced-searchbox', []) return $filter('filter')($scope.searchParams, function (param) { return param.key === value.key && !param.allowMultiple; }).length === 0; }; + $scope.canAddParameter = function () { + var availableParameters = $scope.parameters.length; + for (var i = 0; i < $scope.parameters.length; i++) { + if (!$scope.parameters[i].allowMultiple) { + for ( var j = 0; j < $scope.searchParams.length; j++) { + if ($scope.parameters[i].key === $scope.searchParams[j].key) { + availableParameters -= 1; + break; + } + } + } + } + return availableParameters > 0; + }; + $scope.addSearchParam = function (searchParam, value, enterEditModel) { if (enterEditModel === undefined) enterEditModel = true; @@ -444,7 +459,7 @@ angular.module('angular-advanced-searchbox').run(['$templateCache', function($te 'use strict'; $templateCache.put('angular-advanced-searchbox.html', - "
0 || searchQuery.length > 0\" ng-click=removeAll() role=button>
{{searchParam.name}}:
{{searchParam.value}}
{{parametersLabel}}: {{param.name}}
" + "
0 || searchQuery.length > 0\" ng-click=removeAll() role=button>
{{searchParam.name}}:
{{searchParam.value}}
{{parametersLabel}}: {{param.name}}
" ); }]); diff --git a/dist/angular-advanced-searchbox-tpls.min.js b/dist/angular-advanced-searchbox-tpls.min.js index 3ddf561..a210d5d 100644 --- a/dist/angular-advanced-searchbox-tpls.min.js +++ b/dist/angular-advanced-searchbox-tpls.min.js @@ -1,7 +1,7 @@ /*! - * angular-advanced-searchbox v3.0.0 + * angular-advanced-searchbox v3.0.1 * https://github.com/dnauck/angular-advanced-searchbox * Copyright (c) 2016 Nauck IT KG http://www.nauck-it.de/ * License: MIT */ -!function(){"use strict";angular.module("angular-advanced-searchbox",[]).directive("nitAdvancedSearchbox",function(){return{restrict:"E",scope:{model:"=ngModel",parameters:"=",parametersLabel:"@",parametersDisplayLimit:"=?",placeholder:"@",searchThrottleTime:"=?"},replace:!0,templateUrl:function(a,b){return b.templateUrl||"angular-advanced-searchbox.html"},controller:["$scope","$attrs","$element","$timeout","$filter","setFocusFor",function(a,b,c,d,e,f){function g(){angular.forEach(a.model,function(b,c){if("query"===c)a.searchQuery=b;else{var d=e("filter")(a.parameters,function(a){return a.key===c})[0];void 0!==d&&a.addSearchParam(d,b,!1)}})}function h(b,c,f,g){j&&d.cancel(j),k=e("filter")(k,function(a){return a.key!==c&&a.index!==f}),k.push({command:b,key:c,index:f,value:g}),j=d(function(){angular.forEach(k,function(b){var d=e("filter")(a.parameters,function(a){return a.key===c})[0];d&&d.allowMultiple?(angular.isArray(a.model[b.key])||(a.model[b.key]=[]),"delete"===b.command?(a.model[b.key].splice(b.index,1),0===a.model[b.key].length&&delete a.model[b.key]):a.model[b.key][b.index]=b.value):"delete"===b.command?delete a.model[b.key]:a.model[b.key]=b.value}),k.length=0,a.$emit("advanced-searchbox:modelUpdated",a.model)},a.searchThrottleTime)}function i(a){if(!a)return 0;try{if("number"==typeof a.selectionStart)return"backward"===a.selectionDirection?a.selectionStart:a.selectionEnd;if(document.selection){a.focus();var b=document.selection.createRange(),c=document.selection.createRange().text.length;return b.moveStart("character",-a.value.length),b.text.length-c}}catch(d){}return 0}a.parametersLabel=a.parametersLabel||"Parameter Suggestions",a.parametersDisplayLimit=a.parametersDisplayLimit||8,a.placeholder=a.placeholder||"Search ...",a.searchThrottleTime=a.searchThrottleTime||1e3,a.searchParams=[],a.searchQuery="",a.setFocusFor=f;var j,k=[];a.$watch("model",function(b,c){if(!angular.equals(b,c)){angular.forEach(a.model,function(b,c){if("query"===c&&a.searchQuery!==b)a.searchQuery=b;else{var d=e("filter")(a.parameters,function(a){return a.key===c})[0],f=e("filter")(a.searchParams,function(a){return a.key===c});if(void 0!==d)if(d.allowMultiple){if(angular.isArray(b)||(b=[b]),b.forEach(function(b,c){if(f.some(function(a){return a.index===c})){var e=f.filter(function(a){return a.index===c});e[0].value!==b&&(e[0].value=b)}else a.addSearchParam(d,b,!1)}),b.length=0;d--){var f=a.searchParams[d];if(!a.model.hasOwnProperty(f.key)){var g=a.searchParams.map(function(a){return a.key}).indexOf(f.key);a.removeSearchParam(g)}}}},!0),a.searchParamValueChanged=function(a){h("change",a.key,a.index,a.value)},a.searchQueryChanged=function(a){h("change","query",0,a)},a.enterEditMode=function(b,c){if(void 0!==b&&b.stopPropagation(),void 0!==c){var d=a.searchParams[c];d.editMode=!0,f("searchParam:"+d.key),a.$emit("advanced-searchbox:enteredEditMode",d)}},a.leaveEditMode=function(b,c){if(void 0!==c){var d=a.searchParams[c];d.editMode=!1,a.$emit("advanced-searchbox:leavedEditMode",d),d.value||a.removeSearchParam(c)}},a.searchQueryTypeaheadOnSelect=function(b){a.addSearchParam(b),a.searchQuery="",h("delete","query",0)},a.searchParamTypeaheadOnSelect=function(b,c){c.value=b,a.searchParamValueChanged(c)},a.isUnsedParameter=function(b){return 0===e("filter")(a.searchParams,function(a){return a.key===b.key&&!a.allowMultiple}).length},a.addSearchParam=function(b,c,f){if(void 0===f&&(f=!0),a.isUnsedParameter(b)){var g=0;b.allowMultiple&&(g=e("filter")(a.searchParams,function(a){return a.key===b.key}).length);var i=a.searchParams.push({key:b.key,name:b.name,type:b.type||"text",placeholder:b.placeholder,allowMultiple:b.allowMultiple||!1,suggestedValues:b.suggestedValues||[],restrictToSuggestedValues:b.restrictToSuggestedValues||!1,index:g,value:c||""})-1;h("add",b.key,g,c),f===!0&&d(function(){a.enterEditMode(void 0,i)},100),a.$emit("advanced-searchbox:addedSearchParam",b)}},a.removeSearchParam=function(b){if(void 0!==b){var c=a.searchParams[b];if(a.searchParams.splice(b,1),c.allowMultiple)for(var d=e("filter")(a.searchParams,function(a){return a.key===c.key}),f=0;f0?a.enterEditMode(void 0,b-1):a.searchParams.length>0?a.enterEditMode(void 0,a.searchParams.length-1):0===a.searchParams.length&&f("searchbox")},a.editNext=function(b){void 0!==b&&(a.leaveEditMode(void 0,b),b'),g=angular.element(''),h="none"===c.css("maxWidth")?c.parent().innerWidth():c.css("maxWidth");c.css("maxWidth",h),angular.forEach(["fontSize","fontFamily","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent","boxSizing","borderLeftWidth","borderRightWidth","borderLeftStyle","borderRightStyle","paddingLeft","paddingRight","marginLeft","marginRight"],function(a){g.css(a,c.css(a))}),angular.element("body").append(f.append(g)),d(),b.model?b.$watch("model",function(){d()}):c.on("keypress keyup keydown focus input propertychange change",function(){d()})}}}])}(),angular.module("angular-advanced-searchbox").run(["$templateCache",function(a){"use strict";a.put("angular-advanced-searchbox.html",'
{{searchParam.name}}:
{{searchParam.value}}
{{parametersLabel}}: {{param.name}}
')}]); \ No newline at end of file +!function(){"use strict";angular.module("angular-advanced-searchbox",[]).directive("nitAdvancedSearchbox",function(){return{restrict:"E",scope:{model:"=ngModel",parameters:"=",parametersLabel:"@",parametersDisplayLimit:"=?",placeholder:"@",searchThrottleTime:"=?"},replace:!0,templateUrl:function(a,b){return b.templateUrl||"angular-advanced-searchbox.html"},controller:["$scope","$attrs","$element","$timeout","$filter","setFocusFor",function(a,b,c,d,e,f){function g(){angular.forEach(a.model,function(b,c){if("query"===c)a.searchQuery=b;else{var d=e("filter")(a.parameters,function(a){return a.key===c})[0];void 0!==d&&a.addSearchParam(d,b,!1)}})}function h(b,c,f,g){j&&d.cancel(j),k=e("filter")(k,function(a){return a.key!==c&&a.index!==f}),k.push({command:b,key:c,index:f,value:g}),j=d(function(){angular.forEach(k,function(b){var d=e("filter")(a.parameters,function(a){return a.key===c})[0];d&&d.allowMultiple?(angular.isArray(a.model[b.key])||(a.model[b.key]=[]),"delete"===b.command?(a.model[b.key].splice(b.index,1),0===a.model[b.key].length&&delete a.model[b.key]):a.model[b.key][b.index]=b.value):"delete"===b.command?delete a.model[b.key]:a.model[b.key]=b.value}),k.length=0,a.$emit("advanced-searchbox:modelUpdated",a.model)},a.searchThrottleTime)}function i(a){if(!a)return 0;try{if("number"==typeof a.selectionStart)return"backward"===a.selectionDirection?a.selectionStart:a.selectionEnd;if(document.selection){a.focus();var b=document.selection.createRange(),c=document.selection.createRange().text.length;return b.moveStart("character",-a.value.length),b.text.length-c}}catch(d){}return 0}a.parametersLabel=a.parametersLabel||"Parameter Suggestions",a.parametersDisplayLimit=a.parametersDisplayLimit||8,a.placeholder=a.placeholder||"Search ...",a.searchThrottleTime=a.searchThrottleTime||1e3,a.searchParams=[],a.searchQuery="",a.setFocusFor=f;var j,k=[];a.$watch("model",function(b,c){if(!angular.equals(b,c)){angular.forEach(a.model,function(b,c){if("query"===c&&a.searchQuery!==b)a.searchQuery=b;else{var d=e("filter")(a.parameters,function(a){return a.key===c})[0],f=e("filter")(a.searchParams,function(a){return a.key===c});if(void 0!==d)if(d.allowMultiple){if(angular.isArray(b)||(b=[b]),b.forEach(function(b,c){if(f.some(function(a){return a.index===c})){var e=f.filter(function(a){return a.index===c});e[0].value!==b&&(e[0].value=b)}else a.addSearchParam(d,b,!1)}),b.length=0;d--){var f=a.searchParams[d];if(!a.model.hasOwnProperty(f.key)){var g=a.searchParams.map(function(a){return a.key}).indexOf(f.key);a.removeSearchParam(g)}}}},!0),a.searchParamValueChanged=function(a){h("change",a.key,a.index,a.value)},a.searchQueryChanged=function(a){h("change","query",0,a)},a.enterEditMode=function(b,c){if(void 0!==b&&b.stopPropagation(),void 0!==c){var d=a.searchParams[c];d.editMode=!0,f("searchParam:"+d.key),a.$emit("advanced-searchbox:enteredEditMode",d)}},a.leaveEditMode=function(b,c){if(void 0!==c){var d=a.searchParams[c];d.editMode=!1,a.$emit("advanced-searchbox:leavedEditMode",d),d.value||a.removeSearchParam(c)}},a.searchQueryTypeaheadOnSelect=function(b,c,d){a.addSearchParam(b),a.searchQuery="",h("delete","query",0)},a.searchParamTypeaheadOnSelect=function(b,c){c.value=b,a.searchParamValueChanged(c)},a.isUnsedParameter=function(b,c){return 0===e("filter")(a.searchParams,function(a){return a.key===b.key&&!a.allowMultiple}).length},a.canAddParameter=function(){for(var b=a.parameters.length,c=0;c0},a.addSearchParam=function(b,c,f){if(void 0===f&&(f=!0),a.isUnsedParameter(b)){var g=0;b.allowMultiple&&(g=e("filter")(a.searchParams,function(a){return a.key===b.key}).length);var i=a.searchParams.push({key:b.key,name:b.name,type:b.type||"text",placeholder:b.placeholder,allowMultiple:b.allowMultiple||!1,suggestedValues:b.suggestedValues||[],restrictToSuggestedValues:b.restrictToSuggestedValues||!1,index:g,value:c||""})-1;h("add",b.key,g,c),f===!0&&d(function(){a.enterEditMode(void 0,i)},100),a.$emit("advanced-searchbox:addedSearchParam",b)}},a.removeSearchParam=function(b){if(void 0!==b){var c=a.searchParams[b];if(a.searchParams.splice(b,1),c.allowMultiple)for(var d=e("filter")(a.searchParams,function(a){return a.key===c.key}),f=0;f0?a.enterEditMode(void 0,b-1):a.searchParams.length>0?a.enterEditMode(void 0,a.searchParams.length-1):0===a.searchParams.length&&f("searchbox")},a.editNext=function(b){void 0!==b&&(a.leaveEditMode(void 0,b),b'),h=angular.element(''),i="none"===c.css("maxWidth")?c.parent().innerWidth():c.css("maxWidth");c.css("maxWidth",i),angular.forEach(["fontSize","fontFamily","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent","boxSizing","borderLeftWidth","borderRightWidth","borderLeftStyle","borderRightStyle","paddingLeft","paddingRight","marginLeft","marginRight"],function(a){h.css(a,c.css(a))}),angular.element("body").append(g.append(h)),e(),b.model?b.$watch("model",function(){e()}):c.on("keypress keyup keydown focus input propertychange change",function(){e()})}}}])}(),angular.module("angular-advanced-searchbox").run(["$templateCache",function(a){"use strict";a.put("angular-advanced-searchbox.html",'
{{searchParam.name}}:
{{searchParam.value}}
{{parametersLabel}}: {{param.name}}
')}]); \ No newline at end of file diff --git a/dist/angular-advanced-searchbox.html b/dist/angular-advanced-searchbox.html index 8210ce2..58a0f56 100644 --- a/dist/angular-advanced-searchbox.html +++ b/dist/angular-advanced-searchbox.html @@ -26,7 +26,8 @@ typeahead-editable="searchParam.restrictToSuggestedValues !== true" typeahead-select-on-exact="true" typeahead-select-on-blur="searchParam.restrictToSuggestedValues !== true ? false : true" - placeholder="{{searchParam.placeholder}}" /> + placeholder="{{searchParam.placeholder}}" + ng-click="enterEditMode($event, $index)" /> -
+
{{parametersLabel}}: 0; + }; + $scope.addSearchParam = function (searchParam, value, enterEditModel) { if (enterEditModel === undefined) enterEditModel = true; diff --git a/dist/angular-advanced-searchbox.min.css b/dist/angular-advanced-searchbox.min.css index 29b9198..eb437a5 100644 --- a/dist/angular-advanced-searchbox.min.css +++ b/dist/angular-advanced-searchbox.min.css @@ -1,5 +1,5 @@ /*! - * angular-advanced-searchbox v3.0.0 + * angular-advanced-searchbox v3.0.1 * https://github.com/dnauck/angular-advanced-searchbox * Copyright (c) 2016 Nauck IT KG http://www.nauck-it.de/ * License: MIT diff --git a/dist/angular-advanced-searchbox.min.js b/dist/angular-advanced-searchbox.min.js index 6ee2321..ab92f59 100644 --- a/dist/angular-advanced-searchbox.min.js +++ b/dist/angular-advanced-searchbox.min.js @@ -1,7 +1,7 @@ /*! - * angular-advanced-searchbox v3.0.0 + * angular-advanced-searchbox v3.0.1 * https://github.com/dnauck/angular-advanced-searchbox * Copyright (c) 2016 Nauck IT KG http://www.nauck-it.de/ * License: MIT */ -!function(){"use strict";angular.module("angular-advanced-searchbox",[]).directive("nitAdvancedSearchbox",function(){return{restrict:"E",scope:{model:"=ngModel",parameters:"=",parametersLabel:"@",parametersDisplayLimit:"=?",placeholder:"@",searchThrottleTime:"=?"},replace:!0,templateUrl:function(a,b){return b.templateUrl||"angular-advanced-searchbox.html"},controller:["$scope","$attrs","$element","$timeout","$filter","setFocusFor",function(a,b,c,d,e,f){function g(){angular.forEach(a.model,function(b,c){if("query"===c)a.searchQuery=b;else{var d=e("filter")(a.parameters,function(a){return a.key===c})[0];void 0!==d&&a.addSearchParam(d,b,!1)}})}function h(b,c,f,g){j&&d.cancel(j),k=e("filter")(k,function(a){return a.key!==c&&a.index!==f}),k.push({command:b,key:c,index:f,value:g}),j=d(function(){angular.forEach(k,function(b){var d=e("filter")(a.parameters,function(a){return a.key===c})[0];d&&d.allowMultiple?(angular.isArray(a.model[b.key])||(a.model[b.key]=[]),"delete"===b.command?(a.model[b.key].splice(b.index,1),0===a.model[b.key].length&&delete a.model[b.key]):a.model[b.key][b.index]=b.value):"delete"===b.command?delete a.model[b.key]:a.model[b.key]=b.value}),k.length=0,a.$emit("advanced-searchbox:modelUpdated",a.model)},a.searchThrottleTime)}function i(a){if(!a)return 0;try{if("number"==typeof a.selectionStart)return"backward"===a.selectionDirection?a.selectionStart:a.selectionEnd;if(document.selection){a.focus();var b=document.selection.createRange(),c=document.selection.createRange().text.length;return b.moveStart("character",-a.value.length),b.text.length-c}}catch(d){}return 0}a.parametersLabel=a.parametersLabel||"Parameter Suggestions",a.parametersDisplayLimit=a.parametersDisplayLimit||8,a.placeholder=a.placeholder||"Search ...",a.searchThrottleTime=a.searchThrottleTime||1e3,a.searchParams=[],a.searchQuery="",a.setFocusFor=f;var j,k=[];a.$watch("model",function(b,c){if(!angular.equals(b,c)){angular.forEach(a.model,function(b,c){if("query"===c&&a.searchQuery!==b)a.searchQuery=b;else{var d=e("filter")(a.parameters,function(a){return a.key===c})[0],f=e("filter")(a.searchParams,function(a){return a.key===c});if(void 0!==d)if(d.allowMultiple){if(angular.isArray(b)||(b=[b]),b.forEach(function(b,c){if(f.some(function(a){return a.index===c})){var e=f.filter(function(a){return a.index===c});e[0].value!==b&&(e[0].value=b)}else a.addSearchParam(d,b,!1)}),b.length=0;d--){var f=a.searchParams[d];if(!a.model.hasOwnProperty(f.key)){var g=a.searchParams.map(function(a){return a.key}).indexOf(f.key);a.removeSearchParam(g)}}}},!0),a.searchParamValueChanged=function(a){h("change",a.key,a.index,a.value)},a.searchQueryChanged=function(a){h("change","query",0,a)},a.enterEditMode=function(b,c){if(void 0!==b&&b.stopPropagation(),void 0!==c){var d=a.searchParams[c];d.editMode=!0,f("searchParam:"+d.key),a.$emit("advanced-searchbox:enteredEditMode",d)}},a.leaveEditMode=function(b,c){if(void 0!==c){var d=a.searchParams[c];d.editMode=!1,a.$emit("advanced-searchbox:leavedEditMode",d),d.value||a.removeSearchParam(c)}},a.searchQueryTypeaheadOnSelect=function(b){a.addSearchParam(b),a.searchQuery="",h("delete","query",0)},a.searchParamTypeaheadOnSelect=function(b,c){c.value=b,a.searchParamValueChanged(c)},a.isUnsedParameter=function(b){return 0===e("filter")(a.searchParams,function(a){return a.key===b.key&&!a.allowMultiple}).length},a.addSearchParam=function(b,c,f){if(void 0===f&&(f=!0),a.isUnsedParameter(b)){var g=0;b.allowMultiple&&(g=e("filter")(a.searchParams,function(a){return a.key===b.key}).length);var i=a.searchParams.push({key:b.key,name:b.name,type:b.type||"text",placeholder:b.placeholder,allowMultiple:b.allowMultiple||!1,suggestedValues:b.suggestedValues||[],restrictToSuggestedValues:b.restrictToSuggestedValues||!1,index:g,value:c||""})-1;h("add",b.key,g,c),f===!0&&d(function(){a.enterEditMode(void 0,i)},100),a.$emit("advanced-searchbox:addedSearchParam",b)}},a.removeSearchParam=function(b){if(void 0!==b){var c=a.searchParams[b];if(a.searchParams.splice(b,1),c.allowMultiple)for(var d=e("filter")(a.searchParams,function(a){return a.key===c.key}),f=0;f0?a.enterEditMode(void 0,b-1):a.searchParams.length>0?a.enterEditMode(void 0,a.searchParams.length-1):0===a.searchParams.length&&f("searchbox")},a.editNext=function(b){void 0!==b&&(a.leaveEditMode(void 0,b),b
'),g=angular.element(''),h="none"===c.css("maxWidth")?c.parent().innerWidth():c.css("maxWidth");c.css("maxWidth",h),angular.forEach(["fontSize","fontFamily","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent","boxSizing","borderLeftWidth","borderRightWidth","borderLeftStyle","borderRightStyle","paddingLeft","paddingRight","marginLeft","marginRight"],function(a){g.css(a,c.css(a))}),angular.element("body").append(f.append(g)),d(),b.model?b.$watch("model",function(){d()}):c.on("keypress keyup keydown focus input propertychange change",function(){d()})}}}])}(); \ No newline at end of file +!function(){"use strict";angular.module("angular-advanced-searchbox",[]).directive("nitAdvancedSearchbox",function(){return{restrict:"E",scope:{model:"=ngModel",parameters:"=",parametersLabel:"@",parametersDisplayLimit:"=?",placeholder:"@",searchThrottleTime:"=?"},replace:!0,templateUrl:function(a,b){return b.templateUrl||"angular-advanced-searchbox.html"},controller:["$scope","$attrs","$element","$timeout","$filter","setFocusFor",function(a,b,c,d,e,f){function g(){angular.forEach(a.model,function(b,c){if("query"===c)a.searchQuery=b;else{var d=e("filter")(a.parameters,function(a){return a.key===c})[0];void 0!==d&&a.addSearchParam(d,b,!1)}})}function h(b,c,f,g){j&&d.cancel(j),k=e("filter")(k,function(a){return a.key!==c&&a.index!==f}),k.push({command:b,key:c,index:f,value:g}),j=d(function(){angular.forEach(k,function(b){var d=e("filter")(a.parameters,function(a){return a.key===c})[0];d&&d.allowMultiple?(angular.isArray(a.model[b.key])||(a.model[b.key]=[]),"delete"===b.command?(a.model[b.key].splice(b.index,1),0===a.model[b.key].length&&delete a.model[b.key]):a.model[b.key][b.index]=b.value):"delete"===b.command?delete a.model[b.key]:a.model[b.key]=b.value}),k.length=0,a.$emit("advanced-searchbox:modelUpdated",a.model)},a.searchThrottleTime)}function i(a){if(!a)return 0;try{if("number"==typeof a.selectionStart)return"backward"===a.selectionDirection?a.selectionStart:a.selectionEnd;if(document.selection){a.focus();var b=document.selection.createRange(),c=document.selection.createRange().text.length;return b.moveStart("character",-a.value.length),b.text.length-c}}catch(d){}return 0}a.parametersLabel=a.parametersLabel||"Parameter Suggestions",a.parametersDisplayLimit=a.parametersDisplayLimit||8,a.placeholder=a.placeholder||"Search ...",a.searchThrottleTime=a.searchThrottleTime||1e3,a.searchParams=[],a.searchQuery="",a.setFocusFor=f;var j,k=[];a.$watch("model",function(b,c){if(!angular.equals(b,c)){angular.forEach(a.model,function(b,c){if("query"===c&&a.searchQuery!==b)a.searchQuery=b;else{var d=e("filter")(a.parameters,function(a){return a.key===c})[0],f=e("filter")(a.searchParams,function(a){return a.key===c});if(void 0!==d)if(d.allowMultiple){if(angular.isArray(b)||(b=[b]),b.forEach(function(b,c){if(f.some(function(a){return a.index===c})){var e=f.filter(function(a){return a.index===c});e[0].value!==b&&(e[0].value=b)}else a.addSearchParam(d,b,!1)}),b.length=0;d--){var f=a.searchParams[d];if(!a.model.hasOwnProperty(f.key)){var g=a.searchParams.map(function(a){return a.key}).indexOf(f.key);a.removeSearchParam(g)}}}},!0),a.searchParamValueChanged=function(a){h("change",a.key,a.index,a.value)},a.searchQueryChanged=function(a){h("change","query",0,a)},a.enterEditMode=function(b,c){if(void 0!==b&&b.stopPropagation(),void 0!==c){var d=a.searchParams[c];d.editMode=!0,f("searchParam:"+d.key),a.$emit("advanced-searchbox:enteredEditMode",d)}},a.leaveEditMode=function(b,c){if(void 0!==c){var d=a.searchParams[c];d.editMode=!1,a.$emit("advanced-searchbox:leavedEditMode",d),d.value||a.removeSearchParam(c)}},a.searchQueryTypeaheadOnSelect=function(b,c,d){a.addSearchParam(b),a.searchQuery="",h("delete","query",0)},a.searchParamTypeaheadOnSelect=function(b,c){c.value=b,a.searchParamValueChanged(c)},a.isUnsedParameter=function(b,c){return 0===e("filter")(a.searchParams,function(a){return a.key===b.key&&!a.allowMultiple}).length},a.canAddParameter=function(){for(var b=a.parameters.length,c=0;c0},a.addSearchParam=function(b,c,f){if(void 0===f&&(f=!0),a.isUnsedParameter(b)){var g=0;b.allowMultiple&&(g=e("filter")(a.searchParams,function(a){return a.key===b.key}).length);var i=a.searchParams.push({key:b.key,name:b.name,type:b.type||"text",placeholder:b.placeholder,allowMultiple:b.allowMultiple||!1,suggestedValues:b.suggestedValues||[],restrictToSuggestedValues:b.restrictToSuggestedValues||!1,index:g,value:c||""})-1;h("add",b.key,g,c),f===!0&&d(function(){a.enterEditMode(void 0,i)},100),a.$emit("advanced-searchbox:addedSearchParam",b)}},a.removeSearchParam=function(b){if(void 0!==b){var c=a.searchParams[b];if(a.searchParams.splice(b,1),c.allowMultiple)for(var d=e("filter")(a.searchParams,function(a){return a.key===c.key}),f=0;f0?a.enterEditMode(void 0,b-1):a.searchParams.length>0?a.enterEditMode(void 0,a.searchParams.length-1):0===a.searchParams.length&&f("searchbox")},a.editNext=function(b){void 0!==b&&(a.leaveEditMode(void 0,b),b
'),h=angular.element(''),i="none"===c.css("maxWidth")?c.parent().innerWidth():c.css("maxWidth");c.css("maxWidth",i),angular.forEach(["fontSize","fontFamily","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent","boxSizing","borderLeftWidth","borderRightWidth","borderLeftStyle","borderRightStyle","paddingLeft","paddingRight","marginLeft","marginRight"],function(a){h.css(a,c.css(a))}),angular.element("body").append(g.append(h)),e(),b.model?b.$watch("model",function(){e()}):c.on("keypress keyup keydown focus input propertychange change",function(){e()})}}}])}(); \ No newline at end of file diff --git a/package.json b/package.json index 6871408..852195d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-advanced-searchbox", - "version": "3.0.0", + "version": "3.0.1", "description": "A directive for AngularJS providing a advanced visual search box", "main": "dist/angular-advanced-searchbox-tpls.js", "repository": {