Browse Source

Added clear search on dialog select

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

19
app/js/controllers.js

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

41
app/js/directives.js

@ -434,6 +434,15 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -434,6 +434,15 @@ angular.module('myApp.directives', ['myApp.filters'])
$(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) {
if (!searchFocused && $modalStack.getTop()) {
return true;
@ -526,27 +535,29 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -526,27 +535,29 @@ angular.module('myApp.directives', ['myApp.filters'])
}
if (nextDialogWrap) {
var elTop = nextDialogWrap.offsetTop,
elHeight = nextDialogWrap.offsetHeight,
scrollTop = scrollableWrap.scrollTop,
viewportHeight = scrollableWrap.clientHeight;
if (scrollTop > elTop) {
scrollableWrap.scrollTop = elTop;
$(dialogsWrap).nanoScroller({flash: true});
}
else if (scrollTop < elTop + elHeight - viewportHeight) {
scrollableWrap.scrollTop = elTop + elHeight - viewportHeight;
$(dialogsWrap).nanoScroller({flash: true});
}
scrollToDialog(nextDialogWrap);
}
return cancelEvent(e);
}
}
function scrollToDialog(dialogWrap) {
var elTop = dialogWrap.offsetTop,
elHeight = dialogWrap.offsetHeight,
scrollTop = scrollableWrap.scrollTop,
viewportHeight = scrollableWrap.clientHeight;
if (scrollTop > elTop) {
scrollableWrap.scrollTop = elTop;
$(dialogsWrap).nanoScroller({flash: true});
}
else if (scrollTop < elTop + elHeight - viewportHeight) {
scrollableWrap.scrollTop = elTop + elHeight - viewportHeight;
$(dialogsWrap).nanoScroller({flash: true});
}
}
}

Loading…
Cancel
Save