diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | js/components/contactDetails/contactDetails_controller.js | 2 | ||||
-rw-r--r-- | js/components/contactList/contactList_controller.js | 22 | ||||
-rw-r--r-- | js/components/groupList/groupList_controller.js | 1 | ||||
-rw-r--r-- | js/public/script.js | 37 | ||||
-rw-r--r-- | js/services/search_service.js | 12 | ||||
-rw-r--r-- | templates/contactList.html | 2 |
7 files changed, 45 insertions, 35 deletions
@@ -34,5 +34,5 @@ appstore_package: clean $(project_dir)/js/vendor/angular-bootstrap/ui-bootstrap.min.js \ $(project_dir)/js/vendor/angular-bootstrap/ui-bootstrap-tpls.min.js \ $(project_dir)/js/vendor/angular-sanitize/angular-sanitize.js \ - $(project_dir)/js/vendor/ui-select/dist/select.js \ - $(project_dir)/js/vendor/jquery-timepicker/jquery.ui.timepicker.js \ + $(project_dir)/js/vendor/ui-select/dist/select.js \ + $(project_dir)/js/vendor/jquery-timepicker/jquery.ui.timepicker.js diff --git a/js/components/contactDetails/contactDetails_controller.js b/js/components/contactDetails/contactDetails_controller.js index 4bd6607c..4bba9877 100644 --- a/js/components/contactDetails/contactDetails_controller.js +++ b/js/components/contactDetails/contactDetails_controller.js @@ -1,4 +1,4 @@ -app.controller('contactdetailsCtrl', function(ContactService, AddressBookService, vCardPropertiesService, SearchService, $routeParams, $scope) { +app.controller('contactdetailsCtrl', function(ContactService, AddressBookService, vCardPropertiesService, $routeParams, $scope) { var ctrl = this; ctrl.uid = $routeParams.uid; diff --git a/js/components/contactList/contactList_controller.js b/js/components/contactList/contactList_controller.js index a56a452d..c00d89c0 100644 --- a/js/components/contactList/contactList_controller.js +++ b/js/components/contactList/contactList_controller.js @@ -8,21 +8,25 @@ app.controller('contactlistCtrl', function($scope, $filter, $route, $routeParams ctrl.contactList = []; ctrl.query = ''; + ctrl.selectedContactId = undefined; $scope.query = function(contact) { return contact.matches(SearchService.getSearchTerm()); }; SearchService.registerObserverCallback(function(ev) { - $scope.$apply(function() { - if (ev.event === 'enterOnSearch') { - $route.updateParams({ - uid: !_.isEmpty(ctrl.contactList) ? ctrl.contactList[0].uid() : undefined - }); - } - }); - $scope.selectedContactId = $routeParams.uid; - $('#details-fullName').focus(); + if (ev.event === 'submitSearch') { + var uid = !_.isEmpty(ctrl.contactList) ? ctrl.contactList[0].uid() : undefined; + $route.updateParams({ + uid: uid + }); + ctrl.selectedContactId = uid; + $scope.$apply(); + } + if (ev.event === 'changeSearch') { + ctrl.query = ev.searchTerm; + $scope.$apply(); + } }); ContactService.registerObserverCallback(function(ev) { diff --git a/js/components/groupList/groupList_controller.js b/js/components/groupList/groupList_controller.js index 5fe4cb2b..5036cbd2 100644 --- a/js/components/groupList/groupList_controller.js +++ b/js/components/groupList/groupList_controller.js @@ -8,7 +8,6 @@ app.controller('grouplistCtrl', function($scope, ContactService, SearchService, $scope.selectedGroup = $routeParams.gid; $scope.setSelected = function (selectedGroup) { - $('.searchbox')[0].reset(); SearchService.cleanSearch(); $scope.selectedGroup = selectedGroup; }; diff --git a/js/public/script.js b/js/public/script.js index 0ac00503..e66b7554 100644 --- a/js/public/script.js +++ b/js/public/script.js @@ -251,7 +251,7 @@ app.directive('contact', function() { }; }); -app.controller('contactdetailsCtrl', ['ContactService', 'AddressBookService', 'vCardPropertiesService', 'SearchService', '$routeParams', '$scope', function(ContactService, AddressBookService, vCardPropertiesService, SearchService, $routeParams, $scope) { +app.controller('contactdetailsCtrl', ['ContactService', 'AddressBookService', 'vCardPropertiesService', '$routeParams', '$scope', function(ContactService, AddressBookService, vCardPropertiesService, $routeParams, $scope) { var ctrl = this; ctrl.uid = $routeParams.uid; @@ -350,21 +350,25 @@ app.controller('contactlistCtrl', ['$scope', '$filter', '$route', '$routeParams' ctrl.contactList = []; ctrl.query = ''; + ctrl.selectedContactId = undefined; $scope.query = function(contact) { return contact.matches(SearchService.getSearchTerm()); }; SearchService.registerObserverCallback(function(ev) { - $scope.$apply(function() { - if (ev.event === 'enterOnSearch') { - $route.updateParams({ - uid: !_.isEmpty(ctrl.contactList) ? ctrl.contactList[0].uid() : undefined - }); - } - }); - $scope.selectedContactId = $routeParams.uid; - $('#details-fullName').focus(); + if (ev.event === 'submitSearch') { + var uid = !_.isEmpty(ctrl.contactList) ? ctrl.contactList[0].uid() : undefined; + $route.updateParams({ + uid: uid + }); + ctrl.selectedContactId = uid; + $scope.$apply(); + } + if (ev.event === 'changeSearch') { + ctrl.query = ev.searchTerm; + $scope.$apply(); + } }); ContactService.registerObserverCallback(function(ev) { @@ -592,7 +596,6 @@ app.controller('grouplistCtrl', ['$scope', 'ContactService', 'SearchService', '$ $scope.selectedGroup = $routeParams.gid; $scope.setSelected = function (selectedGroup) { - $('.searchbox')[0].reset(); SearchService.cleanSearch(); $scope.selectedGroup = selectedGroup; }; @@ -1269,7 +1272,7 @@ app.service('DavService', ['DavClient', function(DavClient) { }); }]); -app.service('SearchService', function($rootScope) { +app.service('SearchService', function() { var searchTerm = ''; var observerCallbacks = []; @@ -1288,14 +1291,13 @@ app.service('SearchService', function($rootScope) { }); }; - SearchProxy = { + var SearchProxy = { attach: function(search) { search.setFilter('contacts', this.filterProxy); }, filterProxy: function(query) { - console.log(query); searchTerm = query; - $rootScope.$apply(); + notifyObservers('changeSearch'); } }; @@ -1304,6 +1306,9 @@ app.service('SearchService', function($rootScope) { }; this.cleanSearch = function() { + if (!_.isUndefined($('.searchbox'))) { + $('.searchbox')[0].reset(); + } searchTerm = ''; }; @@ -1314,7 +1319,7 @@ app.service('SearchService', function($rootScope) { if (!_.isUndefined($('.searchbox'))) { $('.searchbox')[0].addEventListener('keypress', function(e) { if(e.keyCode === 13) { - notifyObservers('enterOnSearch'); + notifyObservers('submitSearch'); } }); } diff --git a/js/services/search_service.js b/js/services/search_service.js index 82cec202..77516085 100644 --- a/js/services/search_service.js +++ b/js/services/search_service.js @@ -1,4 +1,4 @@ -app.service('SearchService', function($rootScope) { +app.service('SearchService', function() { var searchTerm = ''; var observerCallbacks = []; @@ -17,14 +17,13 @@ app.service('SearchService', function($rootScope) { }); }; - SearchProxy = { + var SearchProxy = { attach: function(search) { search.setFilter('contacts', this.filterProxy); }, filterProxy: function(query) { - console.log(query); searchTerm = query; - $rootScope.$apply(); + notifyObservers('changeSearch'); } }; @@ -33,6 +32,9 @@ app.service('SearchService', function($rootScope) { }; this.cleanSearch = function() { + if (!_.isUndefined($('.searchbox'))) { + $('.searchbox')[0].reset(); + } searchTerm = ''; }; @@ -43,7 +45,7 @@ app.service('SearchService', function($rootScope) { if (!_.isUndefined($('.searchbox'))) { $('.searchbox')[0].addEventListener('keypress', function(e) { if(e.keyCode === 13) { - notifyObservers('enterOnSearch'); + notifyObservers('submitSearch'); } }); } diff --git a/templates/contactList.html b/templates/contactList.html index 2068c828..778a9c9a 100644 --- a/templates/contactList.html +++ b/templates/contactList.html @@ -2,5 +2,5 @@ <div class="app-content-list-item" ng-repeat="contact in ctrl.contactList = (ctrl.contacts | contactGroupFilter:ctrl.routeParams.gid | orderBy:'fullName()' | filter:query) track by contact.uid()" contact data="contact" - ng-click="setSelected(contact.uid())" ng-class="{active: contact.uid() === selectedContactId}"> + ng-click="setSelected(contact.uid())" ng-class="{active: contact.uid() === ctrl.selectedContactId}"> </div> |