Added clear search on dialog select
This commit is contained in:
parent
6700acac74
commit
921410c3a8
@ -338,7 +338,9 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
|||||||
});
|
});
|
||||||
|
|
||||||
$scope.$on('esc_no_more', function () {
|
$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'])
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$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;
|
||||||
|
@ -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,27 +535,29 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (nextDialogWrap) {
|
if (nextDialogWrap) {
|
||||||
var elTop = nextDialogWrap.offsetTop,
|
scrollToDialog(nextDialogWrap);
|
||||||
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});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cancelEvent(e);
|
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…
x
Reference in New Issue
Block a user