Move scroll_to_selected to navigate.js.

This commit is contained in:
Vishnu Ks 2016-05-25 16:56:57 +05:30 committed by Tim Abbott
parent e329c9e0f5
commit 4be20c4b4a
7 changed files with 14 additions and 15 deletions

View File

@ -39,7 +39,7 @@ exports.initialize = function () {
viewport.scrollTop(scroll_positions[target_tab]);
} else {
if (target_tab === '#home') {
scroll_to_selected();
navigate.scroll_to_selected();
} else {
viewport.scrollTop(0);
}

View File

@ -577,7 +577,7 @@ MessageListView.prototype = {
// autoscroll_forever: if we're on the last message, keep us on the last message
if (last_message_was_selected && page_params.autoscroll_forever) {
this.list.select_id(this.list.last().id, {from_rendering: true});
scroll_to_selected();
navigate.scroll_to_selected();
this.list.reselect_selected_id();
return;
}
@ -597,7 +597,7 @@ MessageListView.prototype = {
// autoscroll_forever: if we've sent a message, move pointer at least that far.
if (page_params.autoscroll_forever && id_of_last_message_sent_by_us > -1 && (rows.last_visible().offset().top - this.list.selected_row().offset().top) < (viewport.height())) {
this.list.select_id(id_of_last_message_sent_by_us, {from_rendering: true});
scroll_to_selected();
navigate.scroll_to_selected();
return;
}

View File

@ -102,12 +102,19 @@ exports.cycle_stream = function (direction) {
narrow.by('stream', nextStream.data('name'));
};
exports.scroll_to_selected = function () {
var selected_row = current_msg_list.selected_row();
if (selected_row && (selected_row.length !== 0)) {
recenter_view(selected_row);
}
};
exports.maybe_scroll_to_selected = function () {
// If we have been previously instructed to re-center to the
// selected message, then do so
if (pointer.recenter_pointer_on_display) {
scroll_to_selected();
exports.scroll_to_selected();
pointer.recenter_pointer_on_display = false;
}
};

View File

@ -582,7 +582,7 @@ exports.register_click_handlers = function () {
$('#out-of-view-notification').on('click', '.compose_notification_scroll_to_message', function (e) {
var msgid = $(e.currentTarget).data('msgid');
current_msg_list.select_id(msgid);
scroll_to_selected();
navigate.scroll_to_selected();
e.stopPropagation();
e.preventDefault();
});

View File

@ -254,7 +254,7 @@ exports.handler = function (e) {
// but before we've loaded in the messages; in that case, don't
// try to scroll to one.
if (current_msg_list.selected_id() !== -1) {
scroll_to_selected();
navigate.scroll_to_selected();
}
};

View File

@ -49,14 +49,6 @@ function recenter_view(message, opts) {
}
}
function scroll_to_selected() {
var selected_row = current_msg_list.selected_row();
if (selected_row && (selected_row.length !== 0)) {
recenter_view(selected_row);
}
}
function get_private_message_recipient(message, attr, fallback_attr) {
var recipient, i;
var other_recipients = _.filter(message.display_recipient,

View File

@ -55,7 +55,7 @@ var globals =
// zulip.js
+ ' home_msg_list current_msg_list'
+ ' respond_to_message recenter_view'
+ ' scroll_to_selected get_private_message_recipient'
+ ' get_private_message_recipient'
+ ' process_loaded_for_unread'
+ ' recent_subjects unread_subjects'
;