Rename our custom JS events to use Zulip, not Zephyr.

(imported from commit 61ac456d394a6dbc14f3e9183a53313990db5059)
This commit is contained in:
Tim Abbott
2013-07-25 16:48:55 -04:00
parent 3bba0cc927
commit bc4d7c687d
13 changed files with 37 additions and 37 deletions

View File

@@ -252,7 +252,7 @@ exports.start = function (msg_type, opts) {
update_fade(); update_fade();
exports.decorate_stream_bar(opts.stream); exports.decorate_stream_bar(opts.stream);
$(document).trigger($.Event('compose_started.zephyr', opts)); $(document).trigger($.Event('compose_started.zulip', opts));
}; };
function abort_xhr () { function abort_xhr () {
@@ -273,7 +273,7 @@ exports.cancel = function () {
if (message_snapshot !== undefined) { if (message_snapshot !== undefined) {
$('#restore-draft').show(); $('#restore-draft').show();
} }
$(document).trigger($.Event('compose_canceled.zephyr')); $(document).trigger($.Event('compose_canceled.zulip'));
respond_to_cursor = false; respond_to_cursor = false;
}; };
@@ -418,7 +418,7 @@ exports.finish = function () {
send_message(); send_message();
// TODO: Do we want to fire the event even if the send failed due // TODO: Do we want to fire the event even if the send failed due
// to a server-side error? // to a server-side error?
$(document).trigger($.Event('compose_finished.zephyr')); $(document).trigger($.Event('compose_finished.zulip'));
return true; return true;
}; };

View File

@@ -23,7 +23,7 @@ exports.changehash = function (newhash) {
if (changing_hash) { if (changing_hash) {
return; return;
} }
$(document).trigger($.Event('hashchange.zephyr')); $(document).trigger($.Event('hashchange.zulip'));
expected_hash = newhash; expected_hash = newhash;
// Some browsers reset scrollTop when changing the hash to "", // Some browsers reset scrollTop when changing the hash to "",
// so we save and restore it. // so we save and restore it.
@@ -99,7 +99,7 @@ function do_hashchange() {
return false; return false;
} }
$(document).trigger($.Event('hashchange.zephyr')); $(document).trigger($.Event('hashchange.zulip'));
// NB: In Firefox, window.location.hash is URI-decoded. // NB: In Firefox, window.location.hash is URI-decoded.
// Even if the URL bar says #%41%42%43%44, the value here will // Even if the URL bar says #%41%42%43%44, the value here will

View File

@@ -104,7 +104,7 @@ exports.maybe_show_edit = function (row, id) {
} }
}; };
$(document).on('narrow_deactivated.zephyr', function (event) { $(document).on('narrow_deactivated.zulip', function (event) {
$.each(currently_editing_messages, function (idx, elem) { $.each(currently_editing_messages, function (idx, elem) {
if (current_msg_list.get(idx) !== undefined) { if (current_msg_list.get(idx) !== undefined) {
var row = rows.get(idx, current_msg_list.table_name); var row = rows.get(idx, current_msg_list.table_name);

View File

@@ -137,7 +137,7 @@ MessageList.prototype = {
this._maybe_rerender(); this._maybe_rerender();
} }
$(document).trigger($.Event('message_selected.zephyr', opts)); $(document).trigger($.Event('message_selected.zulip', opts));
}, },
selected_message: function MessageList_selected_message() { selected_message: function MessageList_selected_message() {
@@ -706,7 +706,7 @@ MessageList.prototype = {
// doing something. Be careful, though, if you try to capture // doing something. Be careful, though, if you try to capture
// mousemove, then you will have to contend with the autoscroll // mousemove, then you will have to contend with the autoscroll
// itself generating mousemove events. // itself generating mousemove events.
$(document).on('message_selected.zephyr hashchange.zephyr mousewheel', function (event) { $(document).on('message_selected.zulip hashchange.zulip mousewheel', function (event) {
viewport.stop_auto_scrolling(); viewport.stop_auto_scrolling();
}); });
}()); }());

View File

@@ -24,7 +24,7 @@ mixpanel.register({user: page_params.email, realm: page_params.domain});
send_resize_event(); send_resize_event();
$(function () { $(function () {
$(document).on('compose_started.zephyr', function (event) { $(document).on('compose_started.zulip', function (event) {
if (! include_in_sample()) { if (! include_in_sample()) {
return; return;
} }
@@ -32,7 +32,7 @@ $(function () {
mixpanel.track('compose started', {type: event.message_type, mixpanel.track('compose started', {type: event.message_type,
trigger: event.trigger}); trigger: event.trigger});
}); });
$(document).on('narrow_activated.zephyr', function (event) { $(document).on('narrow_activated.zulip', function (event) {
if (! include_in_sample()) { if (! include_in_sample()) {
return; return;
} }

View File

@@ -487,7 +487,7 @@ exports.activate = function (operators, opts) {
compose.update_recipient_on_narrow(); compose.update_recipient_on_narrow();
compose.update_faded_messages(); compose.update_faded_messages();
$(document).trigger($.Event('narrow_activated.zephyr', {msg_list: narrowed_msg_list, $(document).trigger($.Event('narrow_activated.zulip', {msg_list: narrowed_msg_list,
filter: current_filter, filter: current_filter,
trigger: opts.trigger})); trigger: opts.trigger}));
}; };
@@ -585,7 +585,7 @@ exports.deactivate = function () {
hashchange.save_narrow(); hashchange.save_narrow();
compose.update_faded_messages(); compose.update_faded_messages();
$(document).trigger($.Event('narrow_deactivated.zephyr', {msg_list: current_msg_list})); $(document).trigger($.Event('narrow_deactivated.zulip', {msg_list: current_msg_list}));
}; };
exports.restore_home_state = function () { exports.restore_home_state = function () {

View File

@@ -367,7 +367,7 @@ exports.register_click_handlers = function () {
if (! $('#subscriptions').hasClass('active')) { if (! $('#subscriptions').hasClass('active')) {
// Go to streams page and once it loads, expand the relevant // Go to streams page and once it loads, expand the relevant
// stream's settings. // stream's settings.
$(document).one('subs_page_loaded.zephyr', function (event) { $(document).one('subs_page_loaded.zulip', function (event) {
subs.show_settings_for(stream); subs.show_settings_for(stream);
}); });
ui.change_tab_to('#subscriptions'); ui.change_tab_to('#subscriptions');

View File

@@ -141,28 +141,28 @@ exports.initiate = function (options) {
idle_control.cancel(); idle_control.cancel();
idle_control = $(document).idle({'idle': home_timeout, idle_control = $(document).idle({'idle': home_timeout,
'onIdle': reload_from_idle}); 'onIdle': reload_from_idle});
$(document).off('compose_canceled.zephyr compose_finished.zephyr', $(document).off('compose_canceled.zulip compose_finished.zulip',
compose_done_handler); compose_done_handler);
$(document).on('compose_started.zephyr', compose_started_handler); $(document).on('compose_started.zulip', compose_started_handler);
}; };
compose_started_handler = function () { compose_started_handler = function () {
idle_control.cancel(); idle_control.cancel();
idle_control = $(document).idle({'idle': composing_timeout, idle_control = $(document).idle({'idle': composing_timeout,
'onIdle': reload_from_idle}); 'onIdle': reload_from_idle});
$(document).off('compose_started.zephyr', compose_started_handler); $(document).off('compose_started.zulip', compose_started_handler);
$(document).on('compose_canceled.zephyr compose_finished.zephyr', $(document).on('compose_canceled.zulip compose_finished.zulip',
compose_done_handler); compose_done_handler);
}; };
if (compose.composing()) { if (compose.composing()) {
idle_control = $(document).idle({'idle': composing_timeout, idle_control = $(document).idle({'idle': composing_timeout,
'onIdle': reload_from_idle}); 'onIdle': reload_from_idle});
$(document).on('compose_canceled.zephyr compose_finished.zephyr', $(document).on('compose_canceled.zulip compose_finished.zulip',
compose_done_handler); compose_done_handler);
} else { } else {
idle_control = $(document).idle({'idle': home_timeout, idle_control = $(document).idle({'idle': home_timeout,
'onIdle': reload_from_idle}); 'onIdle': reload_from_idle});
$(document).on('compose_started.zephyr', compose_started_handler); $(document).on('compose_started.zulip', compose_started_handler);
} }
}; };

View File

@@ -261,7 +261,7 @@ exports.update_dom_with_unread_counts = function (counts) {
}; };
$(function () { $(function () {
$(document).on('narrow_activated.zephyr', function (event) { $(document).on('narrow_activated.zulip', function (event) {
$("ul.filters li").removeClass('active-filter active-subject-filter'); $("ul.filters li").removeClass('active-filter active-subject-filter');
$('.expanded_subjects').remove(); $('.expanded_subjects').remove();
@@ -293,13 +293,13 @@ $(function () {
} }
}); });
$(document).on('narrow_deactivated.zephyr', function (event) { $(document).on('narrow_deactivated.zulip', function (event) {
$("ul.filters li").removeClass('active-filter active-subject-filter'); $("ul.filters li").removeClass('active-filter active-subject-filter');
$("ul.expanded_subjects").remove(); $("ul.expanded_subjects").remove();
$("#global_filters li[data-name='home']").addClass('active-filter'); $("#global_filters li[data-name='home']").addClass('active-filter');
}); });
$(document).on('sub_obj_created.zephyr', function (event) { $(document).on('sub_obj_created.zulip', function (event) {
if (event.sub.subscribed) { if (event.sub.subscribed) {
var stream_name = event.sub.name; var stream_name = event.sub.name;
var li = add_narrow_filter(stream_name, "stream"); var li = add_narrow_filter(stream_name, "stream");
@@ -309,7 +309,7 @@ $(function () {
} }
}); });
$(document).on('subscription_add_done.zephyr', function (event) { $(document).on('subscription_add_done.zulip', function (event) {
var stream_name = event.sub.name; var stream_name = event.sub.name;
var li = add_narrow_filter(stream_name, "stream"); var li = add_narrow_filter(stream_name, "stream");
if (li) { if (li) {
@@ -318,7 +318,7 @@ $(function () {
exports.sort_narrow_list(); exports.sort_narrow_list();
}); });
$(document).on('subscription_remove_done.zephyr', function (event) { $(document).on('subscription_remove_done.zulip', function (event) {
var stream_name = event.sub.name; var stream_name = event.sub.name;
exports.remove_narrow_filter(stream_name, 'stream'); exports.remove_narrow_filter(stream_name, 'stream');
// We need to make sure we resort if the removed sub gets added again // We need to make sure we resort if the removed sub gets added again

View File

@@ -317,7 +317,7 @@ function create_sub(stream_name, attrs) {
mark_color_used(sub.color); mark_color_used(sub.color);
add_sub(stream_name, sub); add_sub(stream_name, sub);
$(document).trigger($.Event('sub_obj_created.zephyr', {sub: sub})); $(document).trigger($.Event('sub_obj_created.zulip', {sub: sub}));
return sub; return sub;
} }
@@ -398,7 +398,7 @@ function mark_subscribed(stream_name, attrs) {
// need its unread counts re-calculated // need its unread counts re-calculated
process_loaded_for_unread(all_msg_list.all()); process_loaded_for_unread(all_msg_list.all());
$(document).trigger($.Event('subscription_add_done.zephyr', {sub: sub})); $(document).trigger($.Event('subscription_add_done.zulip', {sub: sub}));
} }
function mark_unsubscribed(stream_name) { function mark_unsubscribed(stream_name) {
@@ -435,14 +435,14 @@ function mark_unsubscribed(stream_name) {
current_msg_list.update_trailing_bookend(); current_msg_list.update_trailing_bookend();
} }
$(document).trigger($.Event('subscription_remove_done.zephyr', {sub: sub})); $(document).trigger($.Event('subscription_remove_done.zulip', {sub: sub}));
} }
$(function () { $(function () {
$(document).on('subscription_add.zephyr', function (e) { $(document).on('subscription_add.zulip', function (e) {
mark_subscribed(e.subscription.name, e.subscription); mark_subscribed(e.subscription.name, e.subscription);
}); });
$(document).on('subscription_remove.zephyr', function (e) { $(document).on('subscription_remove.zulip', function (e) {
mark_unsubscribed(e.subscription.name); mark_unsubscribed(e.subscription.name);
}); });
@@ -628,7 +628,7 @@ exports.setup_page = function () {
$('#subscriptions_table').append(rendered); $('#subscriptions_table').append(rendered);
util.destroy_loading_indicator($('#subs_page_loading_indicator')); util.destroy_loading_indicator($('#subs_page_loading_indicator'));
$(document).trigger($.Event('subs_page_loaded.zephyr')); $(document).trigger($.Event('subs_page_loaded.zulip'));
} }
function failed_listing(xhr, error) { function failed_listing(xhr, error) {

View File

@@ -131,10 +131,10 @@ function build_tab_bar() {
} }
$(function () { $(function () {
$(document).on('narrow_activated.zephyr', function (event) { $(document).on('narrow_activated.zulip', function (event) {
build_tab_bar(); build_tab_bar();
}); });
$(document).on('narrow_deactivated.zephyr', function (event) { $(document).on('narrow_deactivated.zulip', function (event) {
build_tab_bar(); build_tab_bar();
}); });

View File

@@ -829,7 +829,7 @@ $(function () {
// If the streams page is shown by clicking directly on the "Streams" // If the streams page is shown by clicking directly on the "Streams"
// link (in the gear menu), then focus the new stream textbox. // link (in the gear menu), then focus the new stream textbox.
subs_link.on('click', function (e) { subs_link.on('click', function (e) {
$(document).one('subs_page_loaded.zephyr', function (e) { $(document).one('subs_page_loaded.zulip', function (e) {
$('#create_stream_name').focus().select(); $('#create_stream_name').focus().select();
}); });
}); });
@@ -1117,7 +1117,7 @@ $(function () {
$(document.body).removeClass('window_blurred'); $(document.body).removeClass('window_blurred');
}); });
$(document).on('message_selected.zephyr', function (event) { $(document).on('message_selected.zulip', function (event) {
if (current_msg_list !== event.msg_list) { if (current_msg_list !== event.msg_list) {
return; return;
} }

View File

@@ -453,7 +453,7 @@ $(function () {
onIdle: send_pointer_update, onIdle: send_pointer_update,
keepTracking: true}); keepTracking: true});
$(document).on('message_selected.zephyr', function (event) { $(document).on('message_selected.zulip', function (event) {
// Narrowing is a temporary view on top of the home view and // Narrowing is a temporary view on top of the home view and
// doesn't affect your pointer in the home view. // doesn't affect your pointer in the home view.
@@ -836,12 +836,12 @@ function get_updates_success(data) {
case 'subscriptions': case 'subscriptions':
if (event.op === 'add') { if (event.op === 'add') {
$.each(event.subscriptions, function (index, subscription) { $.each(event.subscriptions, function (index, subscription) {
$(document).trigger($.Event('subscription_add.zephyr', $(document).trigger($.Event('subscription_add.zulip',
{subscription: subscription})); {subscription: subscription}));
}); });
} else if (event.op === 'remove') { } else if (event.op === 'remove') {
$.each(event.subscriptions, function (index, subscription) { $.each(event.subscriptions, function (index, subscription) {
$(document).trigger($.Event('subscription_remove.zephyr', $(document).trigger($.Event('subscription_remove.zulip',
{subscription: subscription})); {subscription: subscription}));
}); });
} else if (event.op === 'update') { } else if (event.op === 'update') {