2012-10-18 20:12:04 +02:00
|
|
|
var narrow = (function () {
|
|
|
|
|
|
|
|
var exports = {};
|
|
|
|
|
2012-12-19 23:58:02 +01:00
|
|
|
var filter_function = false;
|
|
|
|
var current_operators = false;
|
2012-10-24 00:29:06 +02:00
|
|
|
|
2012-10-18 20:12:04 +02:00
|
|
|
exports.active = function () {
|
|
|
|
// Cast to bool
|
2012-12-12 19:00:50 +01:00
|
|
|
return !!filter_function;
|
2012-10-18 20:12:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.predicate = function () {
|
2012-11-09 01:06:07 +01:00
|
|
|
if (filter_function) {
|
|
|
|
return filter_function;
|
2012-10-18 20:12:04 +02:00
|
|
|
} else {
|
|
|
|
return function () { return true; };
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-12-19 23:58:02 +01:00
|
|
|
exports.operators = function () {
|
|
|
|
return current_operators;
|
|
|
|
};
|
|
|
|
|
2013-02-05 19:25:30 +01:00
|
|
|
/* Operators we should send to the server. */
|
|
|
|
exports.public_operators = function () {
|
|
|
|
var safe_to_return;
|
|
|
|
safe_to_return = [];
|
|
|
|
$.each(current_operators, function (index, value) {
|
|
|
|
// Currently just filter out the "in" keyword.
|
|
|
|
if (value[0] !== "in") {
|
|
|
|
safe_to_return.push(value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (safe_to_return.length !== 0) {
|
|
|
|
return safe_to_return;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-12-12 19:36:18 +01:00
|
|
|
/* Convert a list of operators to a string.
|
2012-12-12 19:00:50 +01:00
|
|
|
Each operator is a key-value pair like
|
|
|
|
|
|
|
|
['subject', 'my amazing subject']
|
|
|
|
|
|
|
|
These are not keys in a JavaScript object, because we
|
2013-03-04 23:42:30 +01:00
|
|
|
might need to support multiple operators of the same type.
|
|
|
|
|
|
|
|
Results are not escaped in any way.
|
|
|
|
*/
|
2012-12-12 19:36:18 +01:00
|
|
|
function unparse(operators) {
|
|
|
|
var parts = [];
|
|
|
|
$.each(operators, function (index, elem) {
|
|
|
|
var operator = elem[0];
|
|
|
|
if (operator === 'search') {
|
|
|
|
// Search terms are the catch-all case.
|
|
|
|
// All tokens that don't start with a known operator and
|
|
|
|
// a colon are glued together to form a search term.
|
|
|
|
parts.push(elem[1]);
|
|
|
|
} else {
|
2013-03-04 23:42:30 +01:00
|
|
|
parts.push(elem[0] + ':' + elem[1].toLowerCase());
|
2012-12-12 19:36:18 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return parts.join(' ');
|
|
|
|
}
|
|
|
|
|
2012-12-18 00:18:30 +01:00
|
|
|
// Convert a list of operators to a human-readable description.
|
|
|
|
exports.describe = function (operators) {
|
|
|
|
return $.map(operators, function (elem) {
|
|
|
|
var operand = elem[1];
|
|
|
|
switch (elem[0]) {
|
|
|
|
case 'is':
|
|
|
|
if (operand === 'private-message')
|
2013-03-05 00:15:53 +01:00
|
|
|
return 'Narrow to all private messages';
|
2012-12-18 00:18:30 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'stream':
|
2013-03-05 00:15:53 +01:00
|
|
|
return 'Narrow to stream ' + operand;
|
2012-12-18 00:18:30 +01:00
|
|
|
|
|
|
|
case 'subject':
|
2013-03-05 00:15:53 +01:00
|
|
|
return 'Narrow to subject ' + operand;
|
2012-12-18 00:18:30 +01:00
|
|
|
|
2013-02-28 22:10:22 +01:00
|
|
|
case 'sender':
|
2013-03-05 00:15:53 +01:00
|
|
|
return 'Narrow to sender ' + operand;
|
2013-02-28 22:10:22 +01:00
|
|
|
|
2012-12-18 00:18:30 +01:00
|
|
|
case 'pm-with':
|
2013-03-05 00:15:53 +01:00
|
|
|
return 'Narrow to private messages with ' + operand;
|
2012-12-18 00:18:30 +01:00
|
|
|
|
|
|
|
case 'search':
|
2013-03-05 00:17:59 +01:00
|
|
|
return 'Search for ' + operand;
|
2013-01-30 21:10:55 +01:00
|
|
|
|
|
|
|
case 'in':
|
2013-03-05 00:15:53 +01:00
|
|
|
return 'Narrow to messages in ' + operand;
|
2012-12-18 00:18:30 +01:00
|
|
|
}
|
2013-03-05 00:15:53 +01:00
|
|
|
return 'Narrow to (unknown operator)';
|
2012-12-18 00:18:30 +01:00
|
|
|
}).join(', ');
|
|
|
|
};
|
|
|
|
|
2013-02-27 19:24:56 +01:00
|
|
|
// Collect operators which appear only once into an object,
|
|
|
|
// and discard those which appear more than once.
|
|
|
|
function collect_single(operators) {
|
|
|
|
var seen = {};
|
|
|
|
var result = {};
|
|
|
|
$.each(operators, function (index, elem) {
|
|
|
|
var key = elem[0];
|
|
|
|
if (seen.hasOwnProperty(key)) {
|
|
|
|
delete result[key];
|
|
|
|
} else {
|
|
|
|
result[key] = elem[1];
|
|
|
|
seen [key] = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Modify default compose parameters (stream etc.) based on
|
|
|
|
// the current narrowed view.
|
|
|
|
//
|
|
|
|
// This logic is here and not in the 'compose' module because
|
|
|
|
// it will get more complicated as we add things to the narrow
|
|
|
|
// operator language.
|
|
|
|
exports.set_compose_defaults = function (opts) {
|
|
|
|
var single = collect_single(exports.operators());
|
|
|
|
|
|
|
|
// Set the stream, subject, and/or PM recipient if they are
|
|
|
|
// uniquely specified in the narrow view.
|
|
|
|
$.each(['stream', 'subject'], function (idx, key) {
|
|
|
|
if (single[key] !== undefined)
|
|
|
|
opts[key] = single[key];
|
|
|
|
});
|
|
|
|
|
|
|
|
if (single['pm-with'] !== undefined)
|
|
|
|
opts.private_message_recipient = single['pm-with'];
|
|
|
|
};
|
|
|
|
|
2012-12-17 23:18:16 +01:00
|
|
|
// Parse a string into a list of operators (see below).
|
|
|
|
exports.parse = function (str) {
|
|
|
|
var operators = [];
|
|
|
|
var search_term = [];
|
|
|
|
$.each(str.split(/ +/), function (idx, token) {
|
|
|
|
var parts, operator;
|
|
|
|
if (token.length === 0)
|
|
|
|
return;
|
|
|
|
parts = token.split(':');
|
|
|
|
if (parts.length > 1) {
|
|
|
|
// Looks like an operator.
|
|
|
|
// FIXME: Should we skip unknown operator names here?
|
|
|
|
operator = parts.shift();
|
|
|
|
operators.push([operator, decodeURIComponent(parts.join(':'))]);
|
|
|
|
} else {
|
|
|
|
// Looks like a normal search term.
|
|
|
|
search_term.push(token);
|
|
|
|
}
|
|
|
|
});
|
2012-12-18 00:28:31 +01:00
|
|
|
// NB: Callers of 'parse' can assume that the 'search' operator is last.
|
2012-12-17 23:18:16 +01:00
|
|
|
if (search_term.length > 0)
|
2012-12-18 21:34:59 +01:00
|
|
|
operators.push(['search', search_term.join(' ')]);
|
2012-12-17 23:18:16 +01:00
|
|
|
return operators;
|
|
|
|
};
|
|
|
|
|
2013-02-27 19:18:21 +01:00
|
|
|
exports.stream_in_home = function (stream_name) {
|
2013-02-21 15:20:54 +01:00
|
|
|
// If we don't know about this stream for some reason,
|
|
|
|
// we might not have loaded the in_home_view information
|
|
|
|
// yet so show it
|
2013-02-27 19:18:21 +01:00
|
|
|
var stream = subs.have(stream_name);
|
|
|
|
if (stream) {
|
|
|
|
return stream.in_home_view;
|
2013-02-21 15:20:54 +01:00
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
2013-01-30 21:10:55 +01:00
|
|
|
};
|
|
|
|
|
2013-02-27 19:18:21 +01:00
|
|
|
exports.message_in_home = function (message) {
|
|
|
|
if (message.type === "private") {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return exports.stream_in_home(message.display_recipient);
|
|
|
|
};
|
|
|
|
|
2012-12-12 19:36:18 +01:00
|
|
|
// Build a filter function from a list of operators.
|
2012-12-18 21:34:59 +01:00
|
|
|
function build_filter(operators_mixed_case) {
|
|
|
|
var operators = [];
|
|
|
|
// We don't use $.map because it flattens returned arrays.
|
|
|
|
$.each(operators_mixed_case, function (idx, operator) {
|
|
|
|
operators.push([operator[0], operator[1].toLowerCase()]);
|
|
|
|
});
|
|
|
|
|
2012-12-12 19:00:50 +01:00
|
|
|
// FIXME: This is probably pretty slow.
|
|
|
|
// We could turn it into something more like a compiler:
|
|
|
|
// build JavaScript code in a string and then eval() it.
|
|
|
|
|
|
|
|
return function (message) {
|
|
|
|
var operand, i;
|
2013-03-04 23:24:36 +01:00
|
|
|
for (i = 0; i < operators.length; i++) {
|
2012-12-12 19:00:50 +01:00
|
|
|
operand = operators[i][1];
|
|
|
|
switch (operators[i][0]) {
|
|
|
|
case 'is':
|
2012-12-19 22:30:57 +01:00
|
|
|
if (operand === 'private-message') {
|
2012-12-12 19:00:50 +01:00
|
|
|
if (message.type !== 'private')
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
2012-10-24 00:29:06 +02:00
|
|
|
|
2013-01-30 21:10:55 +01:00
|
|
|
case 'in':
|
|
|
|
if (operand === 'home') {
|
|
|
|
return exports.in_home(message);
|
|
|
|
}
|
|
|
|
else if (operand === 'all') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-12 19:00:50 +01:00
|
|
|
case 'stream':
|
|
|
|
if ((message.type !== 'stream') ||
|
2012-12-18 21:34:59 +01:00
|
|
|
(message.display_recipient.toLowerCase() !== operand))
|
2012-12-12 19:00:50 +01:00
|
|
|
return false;
|
|
|
|
break;
|
2012-12-07 20:52:39 +01:00
|
|
|
|
2012-12-12 19:00:50 +01:00
|
|
|
case 'subject':
|
|
|
|
if ((message.type !== 'stream') ||
|
|
|
|
(message.subject.toLowerCase() !== operand))
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
|
2013-02-28 22:10:22 +01:00
|
|
|
case 'sender':
|
|
|
|
if ((message.sender_email.toLowerCase() !== operand))
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
|
2012-12-12 19:00:50 +01:00
|
|
|
case 'pm-with':
|
|
|
|
if ((message.type !== 'private') ||
|
2013-03-04 23:55:59 +01:00
|
|
|
message.reply_to.toLowerCase() !== operand.split(',').sort().join(','))
|
2012-12-07 20:52:39 +01:00
|
|
|
return false;
|
2012-12-12 19:00:50 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'search':
|
2013-01-31 23:05:47 +01:00
|
|
|
var words = operand.trim().split(/\s+/);
|
|
|
|
var j;
|
|
|
|
for (j = 0; j < words.length; ++j) {
|
|
|
|
if (message.content.toLowerCase().indexOf(words[j]) === -1) {
|
|
|
|
if ((message.type !== 'stream') ||
|
|
|
|
(message.subject.toLowerCase().indexOf(words[j]) === -1)) {
|
|
|
|
return false;
|
|
|
|
}
|
2012-12-12 19:00:50 +01:00
|
|
|
}
|
2012-12-07 20:52:39 +01:00
|
|
|
}
|
2012-12-12 19:00:50 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// All filters passed.
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2012-12-12 20:22:18 +01:00
|
|
|
exports.activate = function (operators, opts) {
|
2012-12-12 19:00:50 +01:00
|
|
|
opts = $.extend({}, {
|
2013-03-14 18:27:58 +01:00
|
|
|
then_select_id: home_msg_list.selected_id(),
|
|
|
|
select_first_unread: false
|
2012-12-12 19:00:50 +01:00
|
|
|
}, opts);
|
2012-12-07 20:52:39 +01:00
|
|
|
|
2013-02-13 21:30:17 +01:00
|
|
|
// Unfade the home view before we switch tables.
|
|
|
|
compose.unfade_messages();
|
|
|
|
|
2012-10-27 02:58:21 +02:00
|
|
|
var was_narrowed = exports.active();
|
2013-02-20 22:59:56 +01:00
|
|
|
var then_select_id = opts.then_select_id;
|
2012-10-27 02:58:21 +02:00
|
|
|
|
2012-12-19 23:58:02 +01:00
|
|
|
filter_function = build_filter(operators);
|
|
|
|
current_operators = operators;
|
2012-12-12 19:00:50 +01:00
|
|
|
|
2013-02-28 23:33:53 +01:00
|
|
|
var collapse_messages = true;
|
|
|
|
$.each(operators, function (idx, operator) {
|
|
|
|
if (operator[0].toLowerCase() === 'search') {
|
|
|
|
collapse_messages = false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
narrowed_msg_list = new MessageList('zfilt', {collapse_messages: collapse_messages});
|
2013-02-12 20:01:24 +01:00
|
|
|
current_msg_list = narrowed_msg_list;
|
|
|
|
|
2013-02-20 18:18:15 +01:00
|
|
|
function maybe_select_closest() {
|
|
|
|
if (! narrowed_msg_list.empty()) {
|
2013-03-14 18:27:58 +01:00
|
|
|
if (opts.select_first_unread) {
|
|
|
|
then_select_id = narrowed_msg_list.last().id;
|
|
|
|
$.each(narrowed_msg_list.all(), function (idx, msg) {
|
|
|
|
if (message_unread(msg)) {
|
|
|
|
then_select_id = msg.id;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2013-02-22 17:46:05 +01:00
|
|
|
narrowed_msg_list.select_id(then_select_id, {then_scroll: true, use_closest: true});
|
2013-02-20 18:18:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-20 22:59:56 +01:00
|
|
|
// Don't bother populating a message list when it won't contain
|
|
|
|
// the message we want anyway
|
|
|
|
if (all_msg_list.get(then_select_id) !== undefined) {
|
|
|
|
add_messages(all_msg_list.all(), narrowed_msg_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (narrowed_msg_list.empty()) {
|
2013-03-14 19:42:37 +01:00
|
|
|
load_old_messages({
|
|
|
|
anchor: then_select_id,
|
|
|
|
num_before: 200,
|
|
|
|
num_after: 200,
|
|
|
|
msg_list: narrowed_msg_list,
|
|
|
|
cont: function (messages) {
|
|
|
|
maybe_select_closest();
|
|
|
|
},
|
|
|
|
for_narrow: true,
|
|
|
|
cont_will_add_messages: false
|
|
|
|
});
|
2013-02-20 19:35:15 +01:00
|
|
|
}
|
|
|
|
|
2012-10-03 20:49:58 +02:00
|
|
|
// Show the new set of messages.
|
|
|
|
$("#main_div").addClass("narrowed_view");
|
2013-01-09 23:22:21 +01:00
|
|
|
$("#zfilt").addClass("focused_table");
|
2012-10-03 20:49:58 +02:00
|
|
|
$("#zhome").removeClass("focused_table");
|
2013-01-09 23:46:32 +01:00
|
|
|
$("#zfilt").css("opacity", 0).animate({opacity: 1});
|
2013-01-09 23:22:21 +01:00
|
|
|
|
|
|
|
reset_load_more_status();
|
2013-02-28 17:08:54 +01:00
|
|
|
maybe_select_closest();
|
2012-10-26 16:59:38 +02:00
|
|
|
|
2013-03-04 23:24:36 +01:00
|
|
|
function extract_search_terms(operators) {
|
|
|
|
var i = 0;
|
|
|
|
for (i = 0; i < operators.length; i++) {
|
|
|
|
var type = operators[i][0];
|
|
|
|
if (type === "search") {
|
|
|
|
return operators[i][1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
search.update_highlighting(extract_search_terms(operators));
|
|
|
|
|
2012-12-12 19:36:18 +01:00
|
|
|
// Put the narrow operators in the URL fragment and search bar
|
2012-12-12 19:00:50 +01:00
|
|
|
hashchange.save_narrow(operators);
|
2012-12-12 19:36:18 +01:00
|
|
|
$('#search_query').val(unparse(operators));
|
2012-12-18 23:38:55 +01:00
|
|
|
search.update_button_visibility();
|
2013-03-12 20:53:54 +01:00
|
|
|
compose.update_recipient_on_narrow();
|
2013-03-06 23:47:49 +01:00
|
|
|
compose.update_faded_messages();
|
2013-02-06 19:48:26 +01:00
|
|
|
|
|
|
|
$("ul.filters li").removeClass('active-filter');
|
|
|
|
if (operators.length === 1) {
|
2013-02-06 21:24:44 +01:00
|
|
|
if (operators[0][0] === 'in' && operators[0][1] === 'all') {
|
2013-02-20 00:02:59 +01:00
|
|
|
$("#global_filters li[data-name='all']").addClass('active-filter');
|
2013-02-06 21:24:44 +01:00
|
|
|
} else if (operators[0][0] === "stream") {
|
2013-03-09 01:36:52 +01:00
|
|
|
ui.get_filter_li('stream', operators[0][1]).addClass('active-filter');
|
2013-02-06 22:33:06 +01:00
|
|
|
} else if (operators[0][0] === "is" && operators[0][1] === "private-message") {
|
2013-02-20 00:02:59 +01:00
|
|
|
$("#global_filters li[data-name='private']").addClass('active-filter');
|
2013-02-06 19:48:26 +01:00
|
|
|
}
|
|
|
|
}
|
2012-12-12 19:00:50 +01:00
|
|
|
};
|
2012-10-03 20:49:58 +02:00
|
|
|
|
2013-01-02 19:21:39 +01:00
|
|
|
// Activate narrowing with a single operator.
|
|
|
|
// This is just for syntactic convenience.
|
|
|
|
exports.by = function (operator, operand, opts) {
|
|
|
|
exports.activate([[operator, operand]], opts);
|
2013-02-09 08:27:20 +01:00
|
|
|
};
|
|
|
|
|
2013-02-12 23:38:08 +01:00
|
|
|
exports.by_subject = function (target_id) {
|
2013-02-12 20:01:24 +01:00
|
|
|
var original = current_msg_list.get(target_id);
|
2012-10-24 05:04:42 +02:00
|
|
|
if (original.type !== 'stream') {
|
|
|
|
// Only stream messages have subjects, but the
|
|
|
|
// user wants us to narrow in some way.
|
2013-02-12 23:38:08 +01:00
|
|
|
exports.by_recipient(target_id);
|
2012-10-03 20:49:58 +02:00
|
|
|
return;
|
2012-10-24 05:04:42 +02:00
|
|
|
}
|
2012-12-12 20:34:47 +01:00
|
|
|
exports.activate([
|
|
|
|
['stream', original.display_recipient],
|
2012-12-18 21:34:59 +01:00
|
|
|
['subject', original.subject]
|
2013-02-20 22:59:56 +01:00
|
|
|
], { then_select_id: target_id });
|
2012-11-15 16:57:59 +01:00
|
|
|
};
|
|
|
|
|
2012-10-10 23:24:11 +02:00
|
|
|
// Called for the 'narrow by stream' hotkey.
|
2013-02-12 23:38:08 +01:00
|
|
|
exports.by_recipient = function (target_id) {
|
2013-02-12 20:01:24 +01:00
|
|
|
var message = current_msg_list.get(target_id);
|
2012-12-12 20:22:18 +01:00
|
|
|
var new_narrow, emails;
|
2012-10-19 19:00:46 +02:00
|
|
|
switch (message.type) {
|
2012-12-03 19:49:12 +01:00
|
|
|
case 'private':
|
2013-02-20 22:59:56 +01:00
|
|
|
exports.by('pm-with', message.reply_to, { then_select_id: target_id });
|
2012-10-19 17:11:31 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'stream':
|
2013-02-20 22:59:56 +01:00
|
|
|
exports.by('stream', message.display_recipient, { then_select_id: target_id });
|
2012-10-19 17:11:31 +02:00
|
|
|
break;
|
2012-10-03 20:49:58 +02:00
|
|
|
}
|
2012-10-18 20:12:04 +02:00
|
|
|
};
|
2012-10-03 20:49:58 +02:00
|
|
|
|
2013-02-28 23:21:37 +01:00
|
|
|
exports.by_time_travel = function (target_id) {
|
|
|
|
narrow.activate([], { then_select_id: target_id });
|
|
|
|
};
|
|
|
|
|
2012-12-12 20:36:05 +01:00
|
|
|
exports.deactivate = function () {
|
2012-12-12 19:00:50 +01:00
|
|
|
if (!filter_function) {
|
2012-10-03 20:49:58 +02:00
|
|
|
return;
|
|
|
|
}
|
2012-12-19 23:58:02 +01:00
|
|
|
filter_function = false;
|
|
|
|
current_operators = false;
|
2012-10-03 20:49:58 +02:00
|
|
|
|
2013-02-23 19:38:25 +01:00
|
|
|
util.hide_empty_narrow_message();
|
|
|
|
|
2012-10-03 20:49:58 +02:00
|
|
|
$("#main_div").removeClass('narrowed_view');
|
2012-10-26 19:55:39 +02:00
|
|
|
$("#searchbox").removeClass('narrowed_view');
|
2013-01-09 23:22:21 +01:00
|
|
|
$("#zfilt").removeClass('focused_table');
|
|
|
|
$("#zhome").addClass('focused_table');
|
2013-01-09 23:46:32 +01:00
|
|
|
$("#zhome").css("opacity", 0).animate({opacity: 1});
|
|
|
|
|
2012-12-12 19:36:18 +01:00
|
|
|
$('#search_query').val('');
|
2013-01-09 23:22:21 +01:00
|
|
|
reset_load_more_status();
|
2013-02-14 23:48:37 +01:00
|
|
|
|
2013-02-22 20:48:31 +01:00
|
|
|
current_msg_list = home_msg_list;
|
|
|
|
// We fall back to the closest selected id, if the user has removed a stream from the home
|
|
|
|
// view since leaving it the old selected id might no longer be there
|
|
|
|
home_msg_list.select_id(home_msg_list.selected_id(), {then_scroll: true, use_closest: true});
|
2013-01-11 16:57:17 +01:00
|
|
|
|
2013-03-04 23:24:36 +01:00
|
|
|
search.clear_highlighting();
|
|
|
|
|
2012-12-12 19:00:50 +01:00
|
|
|
hashchange.save_narrow();
|
2013-01-11 16:57:17 +01:00
|
|
|
|
2013-02-06 19:48:26 +01:00
|
|
|
$("ul.filters li").removeClass('active-filter');
|
2013-02-20 00:02:59 +01:00
|
|
|
$("#global_filters li[data-name='home']").addClass('active-filter');
|
2013-02-26 23:30:39 +01:00
|
|
|
|
|
|
|
// This really shouldn't be necessary since the act of unnarrowing
|
|
|
|
// fires a "message_selected.zephyr" event that in principle goes
|
|
|
|
// and takes care of this, but on Safari (at least) there
|
|
|
|
// seems to be some sort of order-of-events issue that causes
|
|
|
|
// the scrolling not to happen, so this is my hack for now.
|
|
|
|
scroll_to_selected();
|
2012-10-18 20:12:04 +02:00
|
|
|
};
|
|
|
|
|
2012-11-04 02:16:15 +01:00
|
|
|
exports.restore_home_state = function() {
|
|
|
|
// If we click on the Home link while already at Home, unnarrow.
|
|
|
|
// If we click on the Home link from another nav pane, just go
|
|
|
|
// back to the state you were in (possibly still narrowed) before
|
|
|
|
// you left the Home pane.
|
2013-03-13 05:39:33 +01:00
|
|
|
if (!ui.home_tab_obscured()) {
|
2012-12-12 20:36:05 +01:00
|
|
|
exports.deactivate();
|
2012-11-04 02:16:15 +01:00
|
|
|
}
|
2013-02-12 22:32:14 +01:00
|
|
|
maybe_scroll_to_selected();
|
2012-11-04 02:16:15 +01:00
|
|
|
};
|
|
|
|
|
2012-10-18 20:12:04 +02:00
|
|
|
return exports;
|
|
|
|
|
|
|
|
}());
|