eslint: change quote-props from off to error and fix violations.

This commit is contained in:
AZtheAsian 2016-12-02 19:08:47 -07:00 committed by Tim Abbott
parent 1923045ca6
commit 5e9918135b
33 changed files with 199 additions and 198 deletions

View File

@ -167,7 +167,7 @@
"new-parens": 2, "new-parens": 2,
"one-var": ["error", "never"], "one-var": ["error", "never"],
"quotes": [1, "single"], "quotes": [1, "single"],
"quote-props": 0, "quote-props": ["error", "as-needed", { "keywords": false, "unnecessary": true, "numbers": false }],
"radix": 2, "radix": 2,
"semi": 2, "semi": 2,
"keyword-spacing": ["error", { "keyword-spacing": ["error", {

View File

@ -41,10 +41,10 @@ casper.then(function () {
casper.test.assertEqual(casper.getFormValues(form_sel).full_name, "Iago"); casper.test.assertEqual(casper.getFormValues(form_sel).full_name, "Iago");
casper.fill(form_sel, { casper.fill(form_sel, {
"full_name": "IagoNew", full_name: "IagoNew",
"old_password": test_credentials.default_user.password, old_password: test_credentials.default_user.password,
"new_password": "qwertyuiop", new_password: "qwertyuiop",
"confirm_password": "qwertyuiop" confirm_password: "qwertyuiop"
}); });
casper.click('input[name="change_settings"]'); casper.click('input[name="change_settings"]');
}); });
@ -61,7 +61,7 @@ casper.then(function () {
casper.then(function () { casper.then(function () {
casper.waitUntilVisible('#get_api_key_password', function () { casper.waitUntilVisible('#get_api_key_password', function () {
casper.fill('form[action^="/json/fetch_api_key"]', {'password':'qwertyuiop'}); casper.fill('form[action^="/json/fetch_api_key"]', {password:'qwertyuiop'});
casper.click('input[name="view_api_key"]'); casper.click('input[name="view_api_key"]');
}); });
}); });
@ -72,10 +72,10 @@ casper.then(function () {
// Change it all back so the next test can still log in // Change it all back so the next test can still log in
casper.fill(form_sel, { casper.fill(form_sel, {
"full_name": "Iago", full_name: "Iago",
"old_password": "qwertyuiop", old_password: "qwertyuiop",
"new_password": test_credentials.default_user.password, new_password: test_credentials.default_user.password,
"confirm_password": test_credentials.default_user.password confirm_password: test_credentials.default_user.password
}); });
casper.click('input[name="change_settings"]'); casper.click('input[name="change_settings"]');
}); });

View File

@ -150,8 +150,8 @@ casper.then(function () {
// Test custom realm emoji // Test custom realm emoji
casper.waitForSelector('.admin-emoji-form', function () { casper.waitForSelector('.admin-emoji-form', function () {
casper.fill('form.admin-emoji-form', { casper.fill('form.admin-emoji-form', {
'name': 'MouseFace', name: 'MouseFace',
'url': 'http://zulipdev.com:9991/static/images/integrations/logos/jenkins.png' url: 'http://zulipdev.com:9991/static/images/integrations/logos/jenkins.png'
}); });
casper.click('form.admin-emoji-form input.button'); casper.click('form.admin-emoji-form input.button');
}); });
@ -180,8 +180,8 @@ casper.then(function () {
// Test custom realm filters // Test custom realm filters
casper.waitForSelector('.admin-filter-form', function () { casper.waitForSelector('.admin-filter-form', function () {
casper.fill('form.admin-filter-form', { casper.fill('form.admin-filter-form', {
'pattern': '#(?P<id>[0-9]+)', pattern: '#(?P<id>[0-9]+)',
'url_format_string': 'https://trac.example.com/ticket/%(id)s' url_format_string: 'https://trac.example.com/ticket/%(id)s'
}); });
casper.click('form.admin-filter-form input.btn'); casper.click('form.admin-filter-form input.btn');
}); });
@ -202,8 +202,8 @@ casper.waitWhileSelector('.filter_row', function () {
casper.waitForSelector('.admin-filter-form', function () { casper.waitForSelector('.admin-filter-form', function () {
casper.fill('form.admin-filter-form', { casper.fill('form.admin-filter-form', {
'pattern': 'a$', pattern: 'a$',
'url_format_string': 'https://trac.example.com/ticket/%(id)s' url_format_string: 'https://trac.example.com/ticket/%(id)s'
}); });
casper.click('form.admin-filter-form input.btn'); casper.click('form.admin-filter-form input.btn');
}); });

View File

@ -118,7 +118,7 @@ set_global('blueslip', {});
caught = undefined; caught = undefined;
try { try {
Dict.from_array({'bogus': true}); Dict.from_array({bogus: true});
} catch (e2) { } catch (e2) {
caught = true; caught = true;
assert.equal(e2.toString(), 'TypeError: Argument is not an array'); assert.equal(e2.toString(), 'TypeError: Argument is not an array');

View File

@ -171,8 +171,8 @@ var event_fixtures = {
op: 'update_dict', op: 'update_dict',
property: 'default', property: 'default',
data: { data: {
'allow_message_editing': true, allow_message_editing: true,
'message_content_edit_limit_seconds': 5 message_content_edit_limit_seconds: 5
} }
}, },
@ -207,7 +207,7 @@ var event_fixtures = {
realm_emoji: { realm_emoji: {
type: 'realm_emoji', type: 'realm_emoji',
realm_emoji: { realm_emoji: {
'airplane': { airplane: {
display_url: 'some_url' display_url: 'some_url'
} }
} }

View File

@ -16,7 +16,7 @@ i18n.init({
resources: { resources: {
fr: { fr: {
translation: { translation: {
'Reply': "French", Reply: "French",
"You'll receive notifications when a message arrives and __page_params.product_name__ isn't in focus or the message is offscreen.": "Some French text with __page_params.product_name__" "You'll receive notifications when a message arrives and __page_params.product_name__ isn't in focus or the message is offscreen.": "Some French text with __page_params.product_name__"
} }
} }
@ -32,16 +32,16 @@ var _ = global._;
(function test_t_tag() { (function test_t_tag() {
var args = { var args = {
"message": { message: {
is_stream: true, is_stream: true,
id: "99", id: "99",
stream: "devel", stream: "devel",
subject: "testing", subject: "testing",
sender_full_name: "King Lear" sender_full_name: "King Lear"
}, },
"can_edit_message": true, can_edit_message: true,
"can_mute_topic": true, can_mute_topic: true,
"narrowed": true narrowed: true
}; };
var html = '<div style="height: 250px">'; var html = '<div style="height: 250px">';
@ -54,24 +54,24 @@ var _ = global._;
(function test_tr_tag() { (function test_tr_tag() {
var args = { var args = {
"page_params": { page_params: {
"fullname": "John Doe", fullname: "John Doe",
"product_name": "Zulip", product_name: "Zulip",
"password_auth_enabled": false, password_auth_enabled: false,
"avatar_url": "http://example.com", avatar_url: "http://example.com",
"left_side_userlist": false, left_side_userlist: false,
"twenty_four_hour_time": false, twenty_four_hour_time: false,
"stream_desktop_notifications_enabled": false, stream_desktop_notifications_enabled: false,
"stream_sounds_enabled": false, stream_sounds_enabled: false,
"desktop_notifications_enabled": false, desktop_notifications_enabled: false,
"sounds_enabled": false, sounds_enabled: false,
"enable_offline_email_notifications": false, enable_offline_email_notifications: false,
"enable_offline_push_notifications": false, enable_offline_push_notifications: false,
"enable_online_push_notifications": false, enable_online_push_notifications: false,
"enable_digest_emails": false, enable_digest_emails: false,
"domain": "zulip.com", domain: "zulip.com",
"autoscroll_forever": false, autoscroll_forever: false,
"default_desktop_notifications": false default_desktop_notifications: false
} }
}; };

View File

@ -249,10 +249,10 @@ global.stream_data.populate_stream_topics_for_tests({});
}; };
global.stream_data.populate_stream_topics_for_tests({ global.stream_data.populate_stream_topics_for_tests({
'devel': [ devel: [
{subject: 'REXX'} {subject: 'REXX'}
], ],
'office': [ office: [
{subject: 'team'}, {subject: 'team'},
{subject: 'ignore'}, {subject: 'ignore'},
{subject: 'test'} {subject: 'test'}

View File

@ -73,16 +73,16 @@ function render(template_name, args) {
(function actions_popover_content() { (function actions_popover_content() {
var args = { var args = {
"message": { message: {
is_stream: true, is_stream: true,
id: "99", id: "99",
stream: "devel", stream: "devel",
subject: "testing", subject: "testing",
sender_full_name: "King Lear" sender_full_name: "King Lear"
}, },
"can_edit_message": true, can_edit_message: true,
"can_mute_topic": true, can_mute_topic: true,
"narrowed": true narrowed: true
}; };
var html = '<div style="height: 250px">'; var html = '<div style="height: 250px">';
@ -109,9 +109,9 @@ function render(template_name, args) {
(function admin_emoji_list() { (function admin_emoji_list() {
var args = { var args = {
emoji: { emoji: {
"name": "MouseFace", name: "MouseFace",
"display_url": "http://emojipedia-us.s3.amazonaws.com/cache/46/7f/467fe69069c408e07517621f263ea9b5.png", display_url: "http://emojipedia-us.s3.amazonaws.com/cache/46/7f/467fe69069c408e07517621f263ea9b5.png",
"source_url": "http://emojipedia-us.s3.amazonaws.com/cache/46/7f/467fe69069c408e07517621f263ea9b5.png" source_url: "http://emojipedia-us.s3.amazonaws.com/cache/46/7f/467fe69069c408e07517621f263ea9b5.png"
} }
}; };
@ -132,8 +132,8 @@ function render(template_name, args) {
(function admin_filter_list() { (function admin_filter_list() {
var args = { var args = {
filter: { filter: {
"pattern": "#(?P<id>[0-9]+)", pattern: "#(?P<id>[0-9]+)",
"url_format_string": "https://trac.example.com/ticket/%(id)s" url_format_string: "https://trac.example.com/ticket/%(id)s"
} }
}; };
@ -183,11 +183,11 @@ function render(template_name, args) {
var users = ['alice', 'bob', 'carl']; var users = ['alice', 'bob', 'carl'];
_.each(users, function (user) { _.each(users, function (user) {
var args = { var args = {
"user": { user: {
"is_active": true, is_active: true,
"is_active_human": true, is_active_human: true,
"email": user + '@zulip.com', email: user + '@zulip.com',
"full_name": user full_name: user
} }
}; };
html += render('admin_user_list', args); html += render('admin_user_list', args);
@ -241,8 +241,8 @@ function render(template_name, args) {
(function admin_auth_methods_list() { (function admin_auth_methods_list() {
var args = { var args = {
method: { method: {
"method": "Email", method: "Email",
"enabled": false enabled: false
} }
}; };
@ -296,10 +296,10 @@ function render(template_name, args) {
html += '<div class="bot-settings-form">'; html += '<div class="bot-settings-form">';
html += '<ol id="bots_list" style="display: block">'; html += '<ol id="bots_list" style="display: block">';
var args = { var args = {
"email": "hamlet@zulip.com", email: "hamlet@zulip.com",
"api_key": "123456ABCD", api_key: "123456ABCD",
"name": "Hamlet", name: "Hamlet",
"avatar_url": "/hamlet/avatar/url" avatar_url: "/hamlet/avatar/url"
}; };
html += render('bot_avatar_row', args); html += render('bot_avatar_row', args);
html += '</ol>'; html += '</ol>';
@ -338,10 +338,10 @@ function render(template_name, args) {
(function compose_notification() { (function compose_notification() {
var args = { var args = {
"note": "You sent a message to a muted topic.", note: "You sent a message to a muted topic.",
"link_text": "Narrow to here", link_text: "Narrow to here",
"link_msg_id": "99", link_msg_id: "99",
"link_class": "compose_notification_narrow_by_subject" link_class: "compose_notification_narrow_by_subject"
}; };
var html = '<div id="out-of-view-notification" class="notification-alert">'; var html = '<div id="out-of-view-notification" class="notification-alert">';
html += render('compose_notification', args); html += render('compose_notification', args);
@ -374,12 +374,12 @@ function render(template_name, args) {
(function group_pms() { (function group_pms() {
var args = { var args = {
"group_pms": [ group_pms: [
{ {
"fraction_present": 0.1, fraction_present: 0.1,
"emails": "alice@zulip.com,bob@zulip.com", emails: "alice@zulip.com,bob@zulip.com",
"short_name": "Alice and Bob", short_name: "Alice and Bob",
"name": "Alice and Bob" name: "Alice and Bob"
} }
] ]
}; };
@ -437,9 +437,9 @@ function render(template_name, args) {
(function message_edit_form() { (function message_edit_form() {
var args = { var args = {
"topic": "lunch", topic: "lunch",
"content": "Let's go to lunch!", content: "Let's go to lunch!",
"is_stream": true is_stream: true
}; };
var html = render('message_edit_form', args); var html = render('message_edit_form', args);
global.write_handlebars_output("message_edit_form", html); global.write_handlebars_output("message_edit_form", html);
@ -557,9 +557,9 @@ function render(template_name, args) {
(function notification() { (function notification() {
var args = { var args = {
"content": "Hello", content: "Hello",
"gravatar_url": "/gravatar/url", gravatar_url: "/gravatar/url",
"title": "You have a notification" title: "You have a notification"
}; };
var html = render('notification', args); var html = render('notification', args);
@ -837,19 +837,19 @@ function render(template_name, args) {
var args = { var args = {
users: [ users: [
{ {
"my_fullname": true, my_fullname: true,
"type_desc": "Active", type_desc: "Active",
"type": "active", type: "active",
"num_unread": 0, num_unread: 0,
"email": "lear@zulip.com", email: "lear@zulip.com",
"name": "King Lear" name: "King Lear"
}, },
{ {
"type_desc": "Away", type_desc: "Away",
"type": "away", type: "away",
"num_unread": 5, num_unread: 5,
"email": "othello@zulip.com", email: "othello@zulip.com",
"name": "Othello" name: "Othello"
} }
] ]
}; };

View File

@ -25,7 +25,7 @@ global.compile_template('topic_list_item');
var topics = [ var topics = [
{subject: "coding"} {subject: "coding"}
]; ];
global.stream_data.populate_stream_topics_for_tests({"devel": topics}); global.stream_data.populate_stream_topics_for_tests({devel: topics});
global.unread.num_unread_for_subject = function () { global.unread.num_unread_for_subject = function () {
return 1; return 1;
}; };
@ -42,4 +42,3 @@ global.compile_template('topic_list_item');
global.write_test_output("test_topic_list_build_widget", parent_elem.html()); global.write_test_output("test_topic_list_build_widget", parent_elem.html());
}()); }());

View File

@ -399,7 +399,7 @@ function status_from_timestamp(baseline_time, presence) {
} }
break; break;
default: default:
blueslip.error('Unexpected status', {'presence_object': device_presence, 'device': device}, undefined); blueslip.error('Unexpected status', {presence_object: device_presence, device: device}, undefined);
} }
} }
}); });
@ -531,7 +531,7 @@ function maybe_select_person (e) {
// undefined if there are no results // undefined if there are no results
var email = people.get_person_from_user_id(topPerson).email; var email = people.get_person_from_user_id(topPerson).email;
compose.start('private', compose.start('private',
{trigger: 'sidebar enter key', "private_message_recipient": email}); {trigger: 'sidebar enter key', private_message_recipient: email});
} }
// Clear the user filter // Clear the user filter
exports.escape_search(); exports.escape_search();

View File

@ -378,7 +378,7 @@ function _setup_page() {
var stream_name = row.find('.default_stream_name').text(); var stream_name = row.find('.default_stream_name').text();
channel.del({ channel.del({
url: '/json/default_streams'+ '?' + $.param({"stream_name": stream_name}), url: '/json/default_streams'+ '?' + $.param({stream_name: stream_name}),
error: function (xhr, error_type) { error: function (xhr, error_type) {
if (xhr.status.toString().charAt(0) === "4") { if (xhr.status.toString().charAt(0) === "4") {
$(".active_default_stream_row button").closest("td").html( $(".active_default_stream_row button").closest("td").html(
@ -567,7 +567,7 @@ function _setup_page() {
} }
if (response_data.restricted_to_domain !== undefined) { if (response_data.restricted_to_domain !== undefined) {
if (response_data.restricted_to_domain) { if (response_data.restricted_to_domain) {
ui.report_success(i18n.t("New users must have e-mails ending in __atdomains_string__!", {'atdomains_string': atdomains_string}), restricted_to_domain_status); ui.report_success(i18n.t("New users must have e-mails ending in __atdomains_string__!", {atdomains_string: atdomains_string}), restricted_to_domain_status);
} else { } else {
ui.report_success(i18n.t("New users may have arbitrary e-mails!"), restricted_to_domain_status); ui.report_success(i18n.t("New users may have arbitrary e-mails!"), restricted_to_domain_status);
} }
@ -605,8 +605,10 @@ function _setup_page() {
Math.ceil(response_data.message_content_edit_limit_seconds / 60); Math.ceil(response_data.message_content_edit_limit_seconds / 60);
if (response_data.allow_message_editing) { if (response_data.allow_message_editing) {
if (response_data.message_content_edit_limit_seconds > 0) { if (response_data.message_content_edit_limit_seconds > 0) {
ui.report_success(i18n.t("Users can now edit topics for all their messages, and the content of messages which are less than __num_minutes__ minutes old.", ui.report_success(i18n.t("Users can now edit topics for all their messages,"
{'num_minutes' : data_message_content_edit_limit_minutes}), +" and the content of messages which are less than __num_minutes__ minutes old.",
{num_minutes :
data_message_content_edit_limit_minutes}),
message_editing_status); message_editing_status);
} else { } else {
ui.report_success(i18n.t("Users can now edit the content and topics of all their past messages!"), message_editing_status); ui.report_success(i18n.t("Users can now edit the content and topics of all their past messages!"), message_editing_status);

View File

@ -20,12 +20,12 @@ function add_alert_word(word, event) {
$("#empty_alert_word_error").show(); $("#empty_alert_word_error").show();
return; return;
} }
var final_li = templates.render('alert_word_settings_item', {'word': word, editing: false}); var final_li = templates.render('alert_word_settings_item', {word: word, editing: false});
var li = $(event.target).parents('li'); var li = $(event.target).parents('li');
li.replaceWith(final_li); li.replaceWith(final_li);
var new_word = templates.render('alert_word_settings_item', {'word': '', editing: true}); var new_word = templates.render('alert_word_settings_item', {word: '', editing: true});
var word_list = $('#alert_words_list'); var word_list = $('#alert_words_list');
word_list.append(new_word); word_list.append(new_word);
@ -41,10 +41,10 @@ exports.set_up_alert_words = function () {
var word_list = $('#alert_words_list'); var word_list = $('#alert_words_list');
_.each(alert_words.words, function (word) { _.each(alert_words.words, function (word) {
var li = templates.render('alert_word_settings_item', {'word': word}); var li = templates.render('alert_word_settings_item', {word: word});
word_list.append(li); word_list.append(li);
}); });
var new_word = templates.render('alert_word_settings_item', {'word': '', editing: true}); var new_word = templates.render('alert_word_settings_item', {word: '', editing: true});
word_list.append(new_word); word_list.append(new_word);
$('#alert_words_list').on('click', '#create_alert_word_button', function (event) { $('#alert_words_list').on('click', '#create_alert_word_button', function (event) {

View File

@ -317,14 +317,14 @@ $(function () {
// Keep these 2 feedback bot triggers separate because they have to // Keep these 2 feedback bot triggers separate because they have to
// propagate the event differently. // propagate the event differently.
$('.feedback').click(function (e) { $('.feedback').click(function (e) {
compose.start('private', { 'private_message_recipient': 'feedback@zulip.com', compose.start('private', { private_message_recipient: 'feedback@zulip.com',
trigger: 'feedback menu item' }); trigger: 'feedback menu item' });
}); });
$('#feedback_button').click(function (e) { $('#feedback_button').click(function (e) {
e.stopPropagation(); e.stopPropagation();
popovers.hide_all(); popovers.hide_all();
compose.start('private', { 'private_message_recipient': 'feedback@zulip.com', compose.start('private', { private_message_recipient: 'feedback@zulip.com',
trigger: 'feedback button' }); trigger: 'feedback button' });
}); });

View File

@ -428,10 +428,10 @@ function send_message_ajax(request, success, error) {
} }
function report_send_time(send_time, receive_time, display_time, locally_echoed, rendered_changed) { function report_send_time(send_time, receive_time, display_time, locally_echoed, rendered_changed) {
var data = {"time": send_time.toString(), var data = {time: send_time.toString(),
"received": receive_time.toString(), received: receive_time.toString(),
"displayed": display_time.toString(), displayed: display_time.toString(),
"locally_echoed": locally_echoed}; locally_echoed: locally_echoed};
if (locally_echoed) { if (locally_echoed) {
data.rendered_content_disparity = rendered_changed; data.rendered_content_disparity = rendered_changed;
} }
@ -642,10 +642,10 @@ exports.respond_to_message = function (opts) {
} else { } else {
msg_type = message.type; msg_type = message.type;
} }
compose.start(msg_type, {'stream': stream, 'subject': subject, compose.start(msg_type, {stream: stream, subject: subject,
'private_message_recipient': pm_recipient, private_message_recipient: pm_recipient,
'replying_to_message': message, replying_to_message: message,
'trigger': opts.trigger}); trigger: opts.trigger});
}; };
@ -729,7 +729,7 @@ exports.has_message_content = function () {
// *Synchronously* check if a stream exists. // *Synchronously* check if a stream exists.
exports.check_stream_existence = function (stream_name, autosubscribe) { exports.check_stream_existence = function (stream_name, autosubscribe) {
var result = "error"; var result = "error";
var request = {'stream': stream_name}; var request = {stream: stream_name};
if (autosubscribe) { if (autosubscribe) {
request.autosubscribe = true; request.autosubscribe = true;
} }
@ -856,11 +856,11 @@ function validate_private_message() {
invalid_recipients.push(email); invalid_recipients.push(email);
}); });
if (invalid_recipients.length === 1) { if (invalid_recipients.length === 1) {
context = {'recipient': invalid_recipients.join()}; context = {recipient: invalid_recipients.join()};
compose_error(i18n.t("The recipient __recipient__ is not valid ", context), $("#private_message_recipient")); compose_error(i18n.t("The recipient __recipient__ is not valid ", context), $("#private_message_recipient"));
return false; return false;
} else if (invalid_recipients.length > 1) { } else if (invalid_recipients.length > 1) {
context = {'recipients': invalid_recipients.join()}; context = {recipients: invalid_recipients.join()};
compose_error(i18n.t("The recipients __recipients__ are not valid ", context), $("#private_message_recipient")); compose_error(i18n.t("The recipients __recipients__ are not valid ", context), $("#private_message_recipient"));
return false; return false;
} }

View File

@ -368,7 +368,7 @@ exports.initialize = function () {
return channel.post({ return channel.post({
url: '/json/users/me/enter-sends', url: '/json/users/me/enter-sends',
idempotent: true, idempotent: true,
data: {'enter_sends': page_params.enter_sends} data: {enter_sends: page_params.enter_sends}
}); });
}); });
$("#enter_sends").prop('checked', page_params.enter_sends); $("#enter_sends").prop('checked', page_params.enter_sends);

View File

@ -123,7 +123,7 @@ function copy_handler(e) {
// Select div so that the browser will copy it // Select div so that the browser will copy it
// instead of copying the original selection // instead of copying the original selection
div.css({position: 'absolute', 'left': '-99999px'}) div.css({position: 'absolute', left: '-99999px'})
.attr('id', 'copytempdiv'); .attr('id', 'copytempdiv');
$('body').append(div); $('body').append(div);
selection.selectAllChildren(div[0]); selection.selectAllChildren(div[0]);

View File

@ -13,14 +13,14 @@ var exports = {};
channel.post({ channel.post({
url: '/json/users/me/subscriptions', url: '/json/users/me/subscriptions',
data: { data: {
subscriptions: JSON.stringify([{'name': stream_name}]) subscriptions: JSON.stringify([{name: stream_name}])
} }
}).then( }).then(
function (data) { function (data) {
if (!$.isEmptyObject(data.already_subscribed)) { if (!$.isEmptyObject(data.already_subscribed)) {
// Display the canonical stream capitalization. // Display the canonical stream capitalization.
var true_stream_name = data.already_subscribed[page_params.email][0]; var true_stream_name = data.already_subscribed[page_params.email][0];
ui.report_success(i18n.t("Already subscribed to __stream__", {'stream': true_stream_name}), ui.report_success(i18n.t("Already subscribed to __stream__", {stream: true_stream_name}),
$status_message); $status_message);
} }
}, function (xhr) { }, function (xhr) {
@ -45,13 +45,13 @@ var exports = {};
} }
function display_subscribe($button, stream_name) { function display_subscribe($button, stream_name) {
$button.text(i18n.t('Subscribe to __stream__', {'stream': stream_data.canonicalized_name(stream_name)})) $button.text(i18n.t('Subscribe to __stream__', {stream: stream_data.canonicalized_name(stream_name)}))
.removeClass('btn-success') .removeClass('btn-success')
.addClass('btn-default'); .addClass('btn-default');
} }
function display_unsubscribe($button, stream_name) { function display_unsubscribe($button, stream_name) {
$button.text(i18n.t('Unsubscribe from __stream__', {'stream': stream_data.canonicalized_name(stream_name)})) $button.text(i18n.t('Unsubscribe from __stream__', {stream: stream_data.canonicalized_name(stream_name)}))
.removeClass('btn-default') .removeClass('btn-default')
.addClass('btn-success'); .addClass('btn-success');
} }

View File

@ -118,7 +118,7 @@ function Filter(operators) {
} }
} }
var canonical_operators = {"from": "sender", "subject": "topic"}; var canonical_operators = {from: "sender", subject: "topic"};
Filter.canonicalize_operator = function (operator) { Filter.canonicalize_operator = function (operator) {
operator = operator.toLowerCase(); operator = operator.toLowerCase();

View File

@ -65,7 +65,7 @@ exports.initialize = function () {
}, },
success: function (resp, statusText, xhr, form) { success: function (resp, statusText, xhr, form) {
$('#submit-invitation').button('reset'); $('#submit-invitation').button('reset');
invite_status.text(i18n.t('User invited successfully.', {'count': (invitee_emails.val().match(/@/g) || [] ).length})) invite_status.text(i18n.t('User invited successfully.', {count: (invitee_emails.val().match(/@/g) || [] ).length}))
.addClass('alert-success') .addClass('alert-success')
.show(); .show();
invitee_emails.val(''); invitee_emails.val('');

View File

@ -143,11 +143,11 @@ function timer_text(seconds_left) {
var minutes = Math.floor(seconds_left / 60); var minutes = Math.floor(seconds_left / 60);
var seconds = seconds_left % 60; var seconds = seconds_left % 60;
if (minutes >= 1) { if (minutes >= 1) {
return i18n.t("__minutes__ min to edit", {'minutes': minutes.toString()}); return i18n.t("__minutes__ min to edit", {minutes: minutes.toString()});
} else if (seconds_left >= 10) { } else if (seconds_left >= 10) {
return i18n.t("__seconds__ sec to edit", {'seconds': (seconds - seconds % 5).toString()}); return i18n.t("__seconds__ sec to edit", {seconds: (seconds - seconds % 5).toString()});
} }
return i18n.t("__seconds__ sec to edit", {'seconds': seconds.toString()}); return i18n.t("__seconds__ sec to edit", {seconds: seconds.toString()});
} }
function edit_message (row, raw_content) { function edit_message (row, raw_content) {

View File

@ -120,9 +120,9 @@ function add_message_metadata(message) {
stream_data.process_message_for_recent_topics(message); stream_data.process_message_for_recent_topics(message);
involved_people = [{'full_name': message.sender_full_name, involved_people = [{full_name: message.sender_full_name,
'user_id': message.sender_id, user_id: message.sender_id,
'email': message.sender_email}]; email: message.sender_email}];
set_topic_edit_properties(message); set_topic_edit_properties(message);
break; break;
@ -592,8 +592,8 @@ util.execute_early(function () {
// backfill more messages after the user is idle // backfill more messages after the user is idle
var backfill_batch_size = 1000; var backfill_batch_size = 1000;
$(document).idle({'idle': 1000*10, $(document).idle({idle: 1000*10,
'onIdle': function () { onIdle: function () {
var first_id = message_list.all.first().id; var first_id = message_list.all.first().id;
exports.load_old_messages({ exports.load_old_messages({
anchor: first_id, anchor: first_id,

View File

@ -111,9 +111,9 @@ exports.topic = function () {
function report_narrow_time(initial_core_time, initial_free_time, network_time) { function report_narrow_time(initial_core_time, initial_free_time, network_time) {
channel.post({ channel.post({
url: '/json/report_narrow_time', url: '/json/report_narrow_time',
data: {"initial_core": initial_core_time.toString(), data: {initial_core: initial_core_time.toString(),
"initial_free": initial_free_time.toString(), initial_free: initial_free_time.toString(),
"network": network_time.toString()} network: network_time.toString()}
}); });
} }
@ -141,8 +141,8 @@ function report_unnarrow_time() {
channel.post({ channel.post({
url: '/json/report_unnarrow_time', url: '/json/report_unnarrow_time',
data: {"initial_core": initial_core_time.toString(), data: {initial_core: initial_core_time.toString(),
"initial_free": initial_free_time.toString()} initial_free: initial_free_time.toString()}
}); });
unnarrow_times = {}; unnarrow_times = {};

View File

@ -183,8 +183,8 @@ exports.get_rest_of_realm = function get_rest_of_realm() {
var people_minus_you = []; var people_minus_you = [];
realm_people_dict.each(function (person) { realm_people_dict.each(function (person) {
if (!util.is_current_user(person.email)) { if (!util.is_current_user(person.email)) {
people_minus_you.push({"email": person.email, people_minus_you.push({email: person.email,
"full_name": person.full_name}); full_name: person.full_name});
} }
}); });
return people_minus_you.sort(people_cmp); return people_minus_you.sort(people_cmp);

View File

@ -371,7 +371,7 @@ exports.register_click_handlers = function () {
var email = people.get_person_from_user_id(user_id).email; var email = people.get_person_from_user_id(user_id).email;
popovers.hide_user_sidebar_popover(); popovers.hide_user_sidebar_popover();
compose.start('private', {"private_message_recipient": email, trigger: 'sidebar user actions'}); compose.start('private', {private_message_recipient: email, trigger: 'sidebar user actions'});
e.stopPropagation(); e.stopPropagation();
}); });
@ -447,10 +447,10 @@ exports.register_click_handlers = function () {
var can_unmute_topic = is_muted; var can_unmute_topic = is_muted;
var content = templates.render('topic_sidebar_actions', { var content = templates.render('topic_sidebar_actions', {
'stream_name': stream_name, stream_name: stream_name,
'topic_name': topic_name, topic_name: topic_name,
'can_mute_topic': can_mute_topic, can_mute_topic: can_mute_topic,
'can_unmute_topic': can_unmute_topic can_unmute_topic: can_unmute_topic
}); });
$(elt).popover({ $(elt).popover({
@ -523,7 +523,7 @@ exports.register_click_handlers = function () {
var ypos = $(elt).offset().top - viewport.scrollTop(); var ypos = $(elt).offset().top - viewport.scrollTop();
$(elt).popover({ $(elt).popover({
content: templates.render('stream_sidebar_actions', {'stream': stream_data.get_sub(stream)}), content: templates.render('stream_sidebar_actions', {stream: stream_data.get_sub(stream)}),
trigger: "manual", trigger: "manual",
fixed: true fixed: true
}); });
@ -664,7 +664,7 @@ exports.register_click_handlers = function () {
$('body').on('click', '.compose_to_stream', function (e) { $('body').on('click', '.compose_to_stream', function (e) {
var stream = $(e.currentTarget).parents('ul').attr('data-name'); var stream = $(e.currentTarget).parents('ul').attr('data-name');
popovers.hide_stream_sidebar_popover(); popovers.hide_stream_sidebar_popover();
compose.start('stream', {"stream": stream, trigger: 'sidebar stream actions'}); compose.start('stream', {stream: stream, trigger: 'sidebar stream actions'});
e.stopPropagation(); e.stopPropagation();
}); });

View File

@ -241,29 +241,29 @@ exports.initiate = function (options) {
compose_done_handler = function () { compose_done_handler = function () {
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.zulip compose_finished.zulip', $(document).off('compose_canceled.zulip compose_finished.zulip',
compose_done_handler); compose_done_handler);
$(document).on('compose_started.zulip', 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.zulip', compose_started_handler); $(document).off('compose_started.zulip', compose_started_handler);
$(document).on('compose_canceled.zulip compose_finished.zulip', $(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.zulip compose_finished.zulip', $(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.zulip', compose_started_handler); $(document).on('compose_started.zulip', compose_started_handler);
} }
}; };

View File

@ -35,10 +35,10 @@ $(function () {
$(".column-right").css("right", sbWidth + "px"); $(".column-right").css("right", sbWidth + "px");
$(".app-main .right-sidebar").css({"margin-left": (sbWidth) + "px", $(".app-main .right-sidebar").css({"margin-left": (sbWidth) + "px",
"width": (250 - sbWidth) + "px"}); width: (250 - sbWidth) + "px"});
$("#compose").css("left", "-" + sbWidth + "px"); $("#compose").css("left", "-" + sbWidth + "px");
$(".compose-content").css({"left": sbWidth + "px", $(".compose-content").css({left: sbWidth + "px",
"margin-right": (250 + sbWidth) + "px"}); "margin-right": (250 + sbWidth) + "px"});
$("#compose-container").css("max-width", (1400 + sbWidth) + "px"); $("#compose-container").css("max-width", (1400 + sbWidth) + "px");

View File

@ -17,7 +17,7 @@ function build_stream_list($select, extra_names) {
}; };
var public_names = _.chain(stream_items) var public_names = _.chain(stream_items)
.where({'invite_only': false}) .where({invite_only: false})
.pluck('name') .pluck('name')
.map(function (x) { return [x, x]; }) .map(function (x) { return [x, x]; })
.value(); .value();
@ -30,7 +30,7 @@ function build_stream_list($select, extra_names) {
.value(); .value();
var private_options = _.chain(stream_items) var private_options = _.chain(stream_items)
.where({'invite_only': true}) .where({invite_only: true})
.pluck('name') .pluck('name')
.map(function (x) { return [x, x]; }) .map(function (x) { return [x, x]; })
.map(build_option) .map(build_option)

View File

@ -1,12 +1,12 @@
var Socket = (function () { var Socket = (function () {
var CLOSE_REASONS = { var CLOSE_REASONS = {
'none_given': {code: 4000, msg: "No reason provided"}, none_given: {code: 4000, msg: "No reason provided"},
'no_heartbeat': {code: 4001, msg: "Missed too many heartbeats"}, no_heartbeat: {code: 4001, msg: "Missed too many heartbeats"},
'auth_fail': {code: 4002, msg: "Authentication failed"}, auth_fail: {code: 4002, msg: "Authentication failed"},
'ack_timeout': {code: 4003, msg: "ACK timeout"}, ack_timeout: {code: 4003, msg: "ACK timeout"},
'cant_send': {code: 4004, msg: "User attempted to send while Socket was not ready"}, cant_send: {code: 4004, msg: "User attempted to send while Socket was not ready"},
'unsuspend': {code: 4005, msg: "Got unsuspend event"} unsuspend: {code: 4005, msg: "Got unsuspend event"}
}; };
function Socket(url) { function Socket(url) {

View File

@ -49,7 +49,7 @@ function update_table_stream_color(table, stream_name, color) {
if ($.trim($label.text()) === stream_name) { if ($.trim($label.text()) === stream_name) {
var messages = $label.closest(".recipient_row").children(".message_row"); var messages = $label.closest(".recipient_row").children(".message_row");
messages.children(".messagebox").css("box-shadow", "inset 2px 0px 0px 0px " + style + ", -1px 0px 0px 0px " + style); messages.children(".messagebox").css("box-shadow", "inset 2px 0px 0px 0px " + style + ", -1px 0px 0px 0px " + style);
$label.css({"background": style, $label.css({background: style,
"border-left-color": style}); "border-left-color": style});
$label.removeClass(exports.color_classes); $label.removeClass(exports.color_classes);
$label.addClass(color_class); $label.addClass(color_class);

View File

@ -270,9 +270,9 @@ exports.receives_audible_notifications = function (stream_name) {
exports.add_admin_options = function (sub) { exports.add_admin_options = function (sub) {
return _.extend(sub, { return _.extend(sub, {
'is_admin': page_params.is_admin, is_admin: page_params.is_admin,
'can_make_public': page_params.is_admin && sub.invite_only && sub.subscribed, can_make_public: page_params.is_admin && sub.invite_only && sub.subscribed,
'can_make_private': page_params.is_admin && !sub.invite_only can_make_private: page_params.is_admin && !sub.invite_only
}); });
}; };

View File

@ -43,7 +43,7 @@ function set_stream_property(stream_name, property, value) {
var sub_data = {stream: stream_name, property: property, value: value}; var sub_data = {stream: stream_name, property: property, value: value};
return channel.post({ return channel.post({
url: '/json/subscriptions/property', url: '/json/subscriptions/property',
data: {"subscription_data": JSON.stringify([sub_data])}, data: {subscription_data: JSON.stringify([sub_data])},
timeout: 10*1000 timeout: 10*1000
}); });
} }
@ -247,10 +247,10 @@ function add_email_hint(row, email_address_hint_content) {
// Add a popover explaining stream e-mail addresses on hover. // Add a popover explaining stream e-mail addresses on hover.
var hint_id = "#email-address-hint-" + row.stream_id; var hint_id = "#email-address-hint-" + row.stream_id;
var email_address_hint = $(hint_id); var email_address_hint = $(hint_id);
email_address_hint.popover({"placement": "bottom", email_address_hint.popover({placement: "bottom",
"title": "Email integration", title: "Email integration",
"content": email_address_hint_content, content: email_address_hint_content,
"trigger": "manual"}); trigger: "manual"});
$("body").on("mouseover", hint_id, function (e) { $("body").on("mouseover", hint_id, function (e) {
email_address_hint.popover('show'); email_address_hint.popover('show');
@ -598,7 +598,7 @@ function ajaxSubscribe(stream) {
return channel.post({ return channel.post({
url: "/json/users/me/subscriptions", url: "/json/users/me/subscriptions",
data: {"subscriptions": JSON.stringify([{"name": stream}]) }, data: {subscriptions: JSON.stringify([{name: stream}]) },
success: function (resp, statusText, xhr, form) { success: function (resp, statusText, xhr, form) {
$("#create_stream_name").val(""); $("#create_stream_name").val("");
exports.filter_table({input: ""}); exports.filter_table({input: ""});
@ -607,7 +607,7 @@ function ajaxSubscribe(stream) {
if (!$.isEmptyObject(res.already_subscribed)) { if (!$.isEmptyObject(res.already_subscribed)) {
// Display the canonical stream capitalization. // Display the canonical stream capitalization.
true_stream_name = res.already_subscribed[page_params.email][0]; true_stream_name = res.already_subscribed[page_params.email][0];
ui.report_success(i18n.t("Already subscribed to __stream__", {'stream': true_stream_name}), ui.report_success(i18n.t("Already subscribed to __stream__", {stream: true_stream_name}),
$("#subscriptions-status"), 'subscriptions-status'); $("#subscriptions-status"), 'subscriptions-status');
} }
// The rest of the work is done via the subscribe event we will get // The rest of the work is done via the subscribe event we will get
@ -622,7 +622,7 @@ function ajaxSubscribe(stream) {
function ajaxUnsubscribe(stream) { function ajaxUnsubscribe(stream) {
return channel.post({ return channel.post({
url: "/json/subscriptions/remove", url: "/json/subscriptions/remove",
data: {"subscriptions": JSON.stringify([stream]) }, data: {subscriptions: JSON.stringify([stream]) },
success: function (resp, statusText, xhr, form) { success: function (resp, statusText, xhr, form) {
var name; var name;
var res = JSON.parse(xhr.responseText); var res = JSON.parse(xhr.responseText);
@ -644,10 +644,10 @@ function ajaxSubscribeForCreation(stream, description, principals, invite_only,
// Subscribe yourself and possible other people to a new stream. // Subscribe yourself and possible other people to a new stream.
return channel.post({ return channel.post({
url: "/json/users/me/subscriptions", url: "/json/users/me/subscriptions",
data: {"subscriptions": JSON.stringify([{"name": stream, "description": description}]), data: {subscriptions: JSON.stringify([{name: stream, description: description}]),
"principals": JSON.stringify(principals), principals: JSON.stringify(principals),
"invite_only": JSON.stringify(invite_only), invite_only: JSON.stringify(invite_only),
"announce": JSON.stringify(announce) announce: JSON.stringify(announce)
}, },
success: function (data) { success: function (data) {
$("#create_stream_name").val(""); $("#create_stream_name").val("");
@ -702,8 +702,8 @@ function show_new_stream_modal() {
exports.invite_user_to_stream = function (user_email, stream_name, success, failure) { exports.invite_user_to_stream = function (user_email, stream_name, success, failure) {
return channel.post({ return channel.post({
url: "/json/users/me/subscriptions", url: "/json/users/me/subscriptions",
data: {"subscriptions": JSON.stringify([{"name": stream_name}]), data: {subscriptions: JSON.stringify([{name: stream_name}]),
"principals": JSON.stringify([user_email])}, principals: JSON.stringify([user_email])},
success: success, success: success,
error: failure error: failure
}); });
@ -712,8 +712,8 @@ exports.invite_user_to_stream = function (user_email, stream_name, success, fail
exports.remove_user_from_stream = function (user_email, stream_name, success, failure) { exports.remove_user_from_stream = function (user_email, stream_name, success, failure) {
return channel.post({ return channel.post({
url: "/json/subscriptions/remove", url: "/json/subscriptions/remove",
data: {"subscriptions": JSON.stringify([stream_name]), data: {subscriptions: JSON.stringify([stream_name]),
"principals": JSON.stringify([user_email])}, principals: JSON.stringify([user_email])},
success: success, success: success,
error: failure error: failure
}); });
@ -779,7 +779,7 @@ $(function () {
// Hide users which aren't in filtered users // Hide users which aren't in filtered users
_.each(users, function (user) { _.each(users, function (user) {
var display_type = filtered_users.hasOwnProperty(user.email)? "block" : "none"; var display_type = filtered_users.hasOwnProperty(user.email)? "block" : "none";
$("label[data-name='" + user.email + "']").css({"display":display_type}); $("label[data-name='" + user.email + "']").css({display:display_type});
}); });
update_announce_stream_state(); update_announce_stream_state();
@ -787,9 +787,9 @@ $(function () {
}); });
var announce_stream_docs = $("#announce-stream-docs"); var announce_stream_docs = $("#announce-stream-docs");
announce_stream_docs.popover({"placement": "right", announce_stream_docs.popover({placement: "right",
"content": templates.render('announce_stream_docs'), content: templates.render('announce_stream_docs'),
"trigger": "manual"}); trigger: "manual"});
$("body").on("mouseover", "#announce-stream-docs", function (e) { $("body").on("mouseover", "#announce-stream-docs", function (e) {
announce_stream_docs.popover('show'); announce_stream_docs.popover('show');
announce_stream_docs.data('popover').tip().css('z-index', 2000); announce_stream_docs.data('popover').tip().css('z-index', 2000);
@ -1021,7 +1021,7 @@ $(function () {
channel.patch({ channel.patch({
// Stream names might contain unsafe characters so we must encode it first. // Stream names might contain unsafe characters so we must encode it first.
url: "/json/streams/" + encodeURIComponent(sub.name), url: "/json/streams/" + encodeURIComponent(sub.name),
data: {"new_name": JSON.stringify(new_name)}, data: {new_name: JSON.stringify(new_name)},
success: function (data) { success: function (data) {
new_name_box.val(''); new_name_box.val('');
ui.report_success(i18n.t("The stream has been renamed!"), $("#subscriptions-status "), ui.report_success(i18n.t("The stream has been renamed!"), $("#subscriptions-status "),
@ -1048,7 +1048,7 @@ $(function () {
// Stream names might contain unsafe characters so we must encode it first. // Stream names might contain unsafe characters so we must encode it first.
url: '/json/streams/' + encodeURIComponent(stream_name), url: '/json/streams/' + encodeURIComponent(stream_name),
data: { data: {
'description': JSON.stringify(description) description: JSON.stringify(description)
}, },
success: function () { success: function () {
// The event from the server will update the rest of the UI // The event from the server will update the rest of the UI
@ -1093,7 +1093,7 @@ $(function () {
var sub = stream_data.get_sub_by_id(stream_id); var sub = stream_data.get_sub_by_id(stream_id);
$("#subscriptions-status").hide(); $("#subscriptions-status").hide();
var data = {"stream_name": sub.name}; var data = {stream_name: sub.name};
channel.post({ channel.post({
url: url, url: url,

View File

@ -188,10 +188,10 @@ var fake_messages = [
]; ];
function send_delayed_stream_message(stream, topic, content, delay) { function send_delayed_stream_message(stream, topic, content, delay) {
var data = {'type': JSON.stringify('stream'), var data = {type: JSON.stringify('stream'),
'recipient': JSON.stringify(stream), recipient: JSON.stringify(stream),
'topic': JSON.stringify(topic), topic: JSON.stringify(topic),
'content': JSON.stringify(content)}; content: JSON.stringify(content)};
setTimeout(function () { setTimeout(function () {
$.ajax({ $.ajax({
dataType: 'json', dataType: 'json',
@ -203,7 +203,7 @@ function send_delayed_stream_message(stream, topic, content, delay) {
} }
function disable_event_handlers() { function disable_event_handlers() {
$('body').css({'overflow':'hidden'}); // prevents scrolling the feed $('body').css({overflow:'hidden'}); // prevents scrolling the feed
_.each(["keydown", "keyup", "keypress", "scroll"], function (event_name) { _.each(["keydown", "keyup", "keypress", "scroll"], function (event_name) {
var existing_events = $._data(document, "events")[event_name]; var existing_events = $._data(document, "events")[event_name];
if (existing_events === undefined) { if (existing_events === undefined) {
@ -215,7 +215,7 @@ function disable_event_handlers() {
} }
function enable_event_handlers() { function enable_event_handlers() {
$('body').css({'overflow':'auto'}); // enables scrolling the feed $('body').css({overflow:'auto'}); // enables scrolling the feed
_.each(["keydown", "keyup", "keypress", "scroll"], function (event_name) { _.each(["keydown", "keyup", "keypress", "scroll"], function (event_name) {
$._data(document, "events")[event_name] = event_handlers[event_name]; $._data(document, "events")[event_name] = event_handlers[event_name];
}); });

View File

@ -329,7 +329,7 @@ function consider_bankruptcy() {
if ((page_params.unread_count > 500) && if ((page_params.unread_count > 500) &&
(now - page_params.furthest_read_time > 60 * 60 * 24 * 2)) { // 2 days. (now - page_params.furthest_read_time > 60 * 60 * 24 * 2)) { // 2 days.
var unread_info = templates.render('bankruptcy_modal', var unread_info = templates.render('bankruptcy_modal',
{"unread_count": page_params.unread_count}); {unread_count: page_params.unread_count});
$('#bankruptcy-unread-count').html(unread_info); $('#bankruptcy-unread-count').html(unread_info);
$('#bankruptcy').modal('show'); $('#bankruptcy').modal('show');
} else { } else {