Browse Source

Added clear search on dialog select

master
Igor Zhukov 10 years ago
parent
commit
921410c3a8
  1. 17
      app/js/controllers.js
  2. 27
      app/js/directives.js

17
app/js/controllers.js

@ -338,7 +338,9 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}); });
$scope.$on('esc_no_more', function () { $scope.$on('esc_no_more', function () {
$rootScope.$apply(function () {
$location.url('/im'); $location.url('/im');
})
}); });
@ -393,11 +395,20 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}); });
}; };
$scope.searchClear = function () {
$scope.search.query = '';
$scope.search.messages = false;
$scope.$broadcast('search_clear');
}
$scope.dialogSelect = function (peerString, messageID) { $scope.dialogSelect = function (peerString, messageID) {
var params = {peerString: peerString}; var params = {peerString: peerString};
if (messageID) { if (messageID) {
params.messageID = messageID; params.messageID = messageID;
} }
else if ($scope.search.query) {
$scope.searchClear();
}
$rootScope.$broadcast('history_focus', params); $rootScope.$broadcast('history_focus', params);
}; };
@ -601,11 +612,6 @@ angular.module('myApp.controllers', ['myApp.i18n'])
} }
}); });
$scope.searchClear = function () {
$scope.search.query = '';
$scope.search.messages = false;
$scope.$broadcast('search_clear');
}
$scope.$on('ui_dialogs_search_clear', $scope.searchClear); $scope.$on('ui_dialogs_search_clear', $scope.searchClear);
var searchTimeoutPromise; var searchTimeoutPromise;
@ -1150,6 +1156,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
} }
function showEmptyHistory () { function showEmptyHistory () {
jump++;
safeReplaceObject($scope.historyPeer, {}); safeReplaceObject($scope.historyPeer, {});
safeReplaceObject($scope.state, {notSelected: true}); safeReplaceObject($scope.state, {notSelected: true});
peerHistory = false; peerHistory = false;

27
app/js/directives.js

@ -434,6 +434,15 @@ angular.module('myApp.directives', ['myApp.filters'])
$(document).off('keydown', onKeyDown); $(document).off('keydown', onKeyDown);
}); });
$scope.$on('ui_dialogs_change', function () {
onContentLoaded(function () {
var selectedDialog = $(scrollableWrap).find('.active a.im_dialog')[0];
if (selectedDialog) {
scrollToDialog(selectedDialog.parentNode);
}
});
});
function onKeyDown(e) { function onKeyDown(e) {
if (!searchFocused && $modalStack.getTop()) { if (!searchFocused && $modalStack.getTop()) {
return true; return true;
@ -526,12 +535,19 @@ angular.module('myApp.directives', ['myApp.filters'])
} }
if (nextDialogWrap) { if (nextDialogWrap) {
var elTop = nextDialogWrap.offsetTop, scrollToDialog(nextDialogWrap);
elHeight = nextDialogWrap.offsetHeight, }
return cancelEvent(e);
}
}
function scrollToDialog(dialogWrap) {
var elTop = dialogWrap.offsetTop,
elHeight = dialogWrap.offsetHeight,
scrollTop = scrollableWrap.scrollTop, scrollTop = scrollableWrap.scrollTop,
viewportHeight = scrollableWrap.clientHeight; viewportHeight = scrollableWrap.clientHeight;
if (scrollTop > elTop) { if (scrollTop > elTop) {
scrollableWrap.scrollTop = elTop; scrollableWrap.scrollTop = elTop;
$(dialogsWrap).nanoScroller({flash: true}); $(dialogsWrap).nanoScroller({flash: true});
@ -540,11 +556,6 @@ angular.module('myApp.directives', ['myApp.filters'])
scrollableWrap.scrollTop = elTop + elHeight - viewportHeight; scrollableWrap.scrollTop = elTop + elHeight - viewportHeight;
$(dialogsWrap).nanoScroller({flash: true}); $(dialogsWrap).nanoScroller({flash: true});
} }
}
return cancelEvent(e);
}
} }
} }

Loading…
Cancel
Save