Skip to content

Commit ffdc070

Browse files
committed
Release v2.0.0
1 parent 589c027 commit ffdc070

9 files changed

+71
-35
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### 2.0.0 - unreleased
1+
### 2.0.0 - 11 December 2015
22
* Support to add, delete search parameters and change search parameter's values via ng-model, fixed issue #7, #9 and #10
33
* change main property of package.json to final build in dist folder, fixes #4
44
* use ng-if for search parameter input to avoid rendering issues and performance

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-advanced-searchbox",
3-
"version": "2.0.0-dev",
3+
"version": "2.0.0",
44
"homepage": "https://github.com/dnauck/angular-advanced-searchbox",
55
"authors": [
66
"Daniel Nauck <[email protected]>"

dist/angular-advanced-searchbox-tpls.js

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ angular.module('angular-advanced-searchbox', [])
1717
scope: {
1818
model: '=ngModel',
1919
parameters: '=',
20-
placeholder: '@'
20+
parametersLabel: '@',
21+
parametersDisplayLimit: '=',
22+
placeholder: '@',
23+
searchThrottleTime: '='
2124
},
2225
replace: true,
2326
templateUrl: 'angular-advanced-searchbox.html',
2427
controller: [
2528
'$scope', '$attrs', '$element', '$timeout', '$filter',
2629
function ($scope, $attrs, $element, $timeout, $filter) {
2730

31+
$scope.parametersLabel = $scope.parametersLabel || 'Parameter Suggestions';
32+
$scope.parametersDisplayLimit = $scope.parametersDisplayLimit || 8;
2833
$scope.placeholder = $scope.placeholder || 'Search ...';
34+
$scope.searchThrottleTime = $scope.searchThrottleTime || 1000;
2935
$scope.searchParams = [];
3036
$scope.searchQuery = '';
3137
$scope.setSearchFocus = false;
@@ -70,21 +76,28 @@ angular.module('angular-advanced-searchbox', [])
7076
updateModel('change', 'query', query);
7177
};
7278

73-
$scope.enterEditMode = function(index) {
79+
$scope.enterEditMode = function(e, index) {
80+
if(e !== undefined)
81+
e.stopPropagation();
82+
7483
if (index === undefined)
7584
return;
7685

7786
var searchParam = $scope.searchParams[index];
7887
searchParam.editMode = true;
88+
89+
$scope.$emit('advanced-searchbox:enteredEditMode', searchParam);
7990
};
8091

81-
$scope.leaveEditMode = function(index) {
92+
$scope.leaveEditMode = function(e, index) {
8293
if (index === undefined)
8394
return;
8495

8596
var searchParam = $scope.searchParams[index];
8697
searchParam.editMode = false;
8798

99+
$scope.$emit('advanced-searchbox:leavedEditMode', searchParam);
100+
88101
// remove empty search params
89102
if (!searchParam.value)
90103
$scope.removeSearchParam(index);
@@ -139,25 +152,25 @@ angular.module('angular-advanced-searchbox', [])
139152

140153
$scope.editPrevious = function(currentIndex) {
141154
if (currentIndex !== undefined)
142-
$scope.leaveEditMode(currentIndex);
155+
$scope.leaveEditMode(undefined, currentIndex);
143156

144157
//TODO: check if index == 0 -> what then?
145158
if (currentIndex > 0) {
146-
$scope.enterEditMode(currentIndex - 1);
159+
$scope.enterEditMode(undefined, currentIndex - 1);
147160
} else if ($scope.searchParams.length > 0) {
148-
$scope.enterEditMode($scope.searchParams.length - 1);
161+
$scope.enterEditMode(undefined, $scope.searchParams.length - 1);
149162
}
150163
};
151164

152165
$scope.editNext = function(currentIndex) {
153166
if (currentIndex === undefined)
154167
return;
155168

156-
$scope.leaveEditMode(currentIndex);
169+
$scope.leaveEditMode(undefined, currentIndex);
157170

158171
//TODO: check if index == array length - 1 -> what then?
159172
if (currentIndex < $scope.searchParams.length - 1) {
160-
$scope.enterEditMode(currentIndex + 1);
173+
$scope.enterEditMode(undefined, currentIndex + 1);
161174
} else {
162175
$scope.setSearchFocus = true;
163176
}
@@ -171,8 +184,10 @@ angular.module('angular-advanced-searchbox', [])
171184
var cursorPosition = getCurrentCaretPosition(e.target);
172185

173186
if (e.which == 8) { // backspace
174-
if (cursorPosition === 0)
187+
if (cursorPosition === 0) {
188+
e.preventDefault();
175189
$scope.editPrevious(searchParamIndex);
190+
}
176191

177192
} else if (e.which == 9) { // tab
178193
if (e.shiftKey) {
@@ -236,7 +251,10 @@ angular.module('angular-advanced-searchbox', [])
236251
});
237252

238253
changeBuffer.length = 0;
239-
}, 500);
254+
255+
$scope.$emit('advanced-searchbox:modelUpdated', $scope.model);
256+
257+
}, $scope.searchThrottleTime);
240258
}
241259

242260
function getCurrentCaretPosition(input) {
@@ -329,7 +347,7 @@ angular.module('angular-advanced-searchbox').run(['$templateCache', function($te
329347
'use strict';
330348

331349
$templateCache.put('angular-advanced-searchbox.html',
332-
"<div class=advancedSearchBox ng-class={active:focus} ng-init=\"focus = false\" ng-click=\"!focus ? setSearchFocus = true : null\"><span ng-show=\"searchParams.length < 1 && searchQuery.length === 0\" class=\"search-icon glyphicon glyphicon-search\"></span> <a ng-href=\"\" ng-show=\"searchParams.length > 0 || searchQuery.length > 0\" ng-click=removeAll() role=button><span class=\"remove-all-icon glyphicon glyphicon-trash\"></span></a><div><div class=search-parameter ng-repeat=\"searchParam in searchParams\"><a ng-href=\"\" ng-click=removeSearchParam($index) role=button><span class=\"remove glyphicon glyphicon-trash\"></span></a><div class=key>{{searchParam.name}}:</div><div class=value><span ng-if=!searchParam.editMode ng-click=enterEditMode($index)>{{searchParam.value}}</span> <input name=value nit-auto-size-input nit-set-focus=searchParam.editMode ng-keydown=\"keydown($event, $index)\" ng-blur=leaveEditMode($index) ng-if=searchParam.editMode ng-change=searchParamValueChanged(searchParam) ng-model=searchParam.value placeholder=\"{{searchParam.placeholder}}\"></div></div><input name=searchbox class=search-parameter-input nit-auto-size-input nit-set-focus=setSearchFocus ng-keydown=keydown($event) placeholder={{placeholder}} ng-focus=\"focus = true\" ng-blur=\"focus = false\" typeahead-on-select=\"typeaheadOnSelect($item, $model, $label)\" typeahead=\"parameter as parameter.name for parameter in parameters | filter:isUnsedParameter | filter:{name:$viewValue} | limitTo:8\" ng-change=searchQueryChanged(searchQuery) ng-model=\"searchQuery\"></div><div class=search-parameter-suggestions ng-show=\"parameters && focus\"><span class=title>Parameter Suggestions:</span> <span class=search-parameter ng-repeat=\"param in parameters | filter:isUnsedParameter | limitTo:8\" ng-mousedown=addSearchParam(param)>{{param.name}}</span></div></div>"
350+
"<div class=advancedSearchBox ng-class={active:focus} ng-init=\"focus = false\" ng-click=\"!focus ? setSearchFocus = true : null\"><span ng-show=\"searchParams.length < 1 && searchQuery.length === 0\" class=\"search-icon glyphicon glyphicon-search\"></span> <a ng-href=\"\" ng-show=\"searchParams.length > 0 || searchQuery.length > 0\" ng-click=removeAll() role=button><span class=\"remove-all-icon glyphicon glyphicon-trash\"></span></a><div><div class=search-parameter ng-repeat=\"searchParam in searchParams\"><a ng-href=\"\" ng-click=removeSearchParam($index) role=button><span class=\"remove glyphicon glyphicon-trash\"></span></a><div class=key ng-click=\"enterEditMode($event, $index)\">{{searchParam.name}}:</div><div class=value><span ng-if=!searchParam.editMode ng-click=\"enterEditMode($event, $index)\">{{searchParam.value}}</span> <input name=value nit-auto-size-input nit-set-focus=searchParam.editMode ng-keydown=\"keydown($event, $index)\" ng-blur=\"leaveEditMode($event, $index)\" ng-if=searchParam.editMode ng-change=searchParamValueChanged(searchParam) ng-model=searchParam.value placeholder=\"{{searchParam.placeholder}}\"></div></div><input name=searchbox class=search-parameter-input nit-auto-size-input nit-set-focus=setSearchFocus ng-keydown=keydown($event) placeholder={{placeholder}} ng-focus=\"focus = true\" ng-blur=\"focus = false\" typeahead-on-select=\"typeaheadOnSelect($item, $model, $label)\" typeahead=\"parameter as parameter.name for parameter in parameters | filter:isUnsedParameter | filter:{name:$viewValue} | limitTo:parametersDisplayLimit\" ng-change=searchQueryChanged(searchQuery) ng-model=\"searchQuery\"></div><div class=search-parameter-suggestions ng-show=\"parameters && focus\"><span class=title>{{parametersLabel}}:</span> <span class=search-parameter ng-repeat=\"param in parameters | filter:isUnsedParameter | limitTo:parametersDisplayLimit\" ng-mousedown=addSearchParam(param)>{{param.name}}</span></div></div>"
333351
);
334352

335353
}]);

0 commit comments

Comments
 (0)