Put spaces after "function" in JS code (cosmetic).

(imported from commit 7579547bfed70b3e53122109d0d6f30ea01f5ac3)
This commit is contained in:
Steve Howell 2013-07-05 11:43:56 -04:00
parent 26c66b17a9
commit 249252f700
25 changed files with 67 additions and 67 deletions

View File

@ -150,7 +150,7 @@ exports.wrap_function = function blueslip_wrap_function(func) {
// Catch all exceptions from jQuery event handlers, $(document).ready
// functions, and ajax success/failure continuations and funnel them
// through blueslip.
(function() {
(function () {
// This reference counting scheme can't break all the circular
// references we create because users can remove jQuery event
// handlers without referencing the particular handler they want

View File

@ -115,7 +115,7 @@ exports.update_faded_messages = function () {
ui.disable_floating_recipient_bar();
};
exports.update_recipient_on_narrow = function() {
exports.update_recipient_on_narrow = function () {
if (!compose.composing()) {
return;
}
@ -244,7 +244,7 @@ exports.cancel = function () {
respond_to_sent_message = false;
};
exports.empty_subject_placeholder = function() {
exports.empty_subject_placeholder = function () {
return empty_subject_placeholder;
};
@ -271,7 +271,7 @@ function create_message_object() {
return message;
}
exports.snapshot_message = function(message) {
exports.snapshot_message = function (message) {
if (!exports.composing() || (exports.message_content() === "")) {
// If you aren't in the middle of composing the body of a
// message, don't try to snapshot.
@ -291,7 +291,7 @@ function clear_message_snapshot() {
message_snapshot = undefined;
}
exports.restore_message = function() {
exports.restore_message = function () {
if (!message_snapshot) {
return;
}

View File

@ -133,14 +133,14 @@ function handle_keyup(e) {
// http://stackoverflow.com/questions/3380458/looking-for-a-better-workaround-to-chrome-select-on-focus-bug
function select_on_focus(field_id) {
$("#" + field_id).focus(function(e) {
$("#" + field_id).focus(function (e) {
$("#" + field_id).select().one('mouseup', function (e) {
e.preventDefault();
});
});
}
exports.split_at_cursor = function(query) {
exports.split_at_cursor = function (query) {
var cursor = $('#new_message_content').caret().start;
return [query.slice(0, cursor), query.slice(cursor)];
};
@ -151,10 +151,10 @@ exports.initialize = function () {
select_on_focus("private_message_recipient");
// These handlers are at the "form" level so that they are called after typeahead
$("form#send_message_form").keydown(function(e) {
$("form#send_message_form").keydown(function (e) {
handle_keydown(e);
});
$("form#send_message_form").keyup(function(e) {
$("form#send_message_form").keyup(function (e) {
handle_keyup(e);
});

View File

@ -79,7 +79,7 @@ IterationProfiler.prototype = {
this.last_time = now;
},
section: function(label) {
section: function (label) {
var now = window.performance.now();
if (this.sections[label] === undefined) {
this.sections[label] = 0;

View File

@ -9,7 +9,7 @@ var changing_hash = false;
// window.location.hash. So we hide our URI-encoding
// by replacing % with . (like MediaWiki).
exports.encodeHashComponent = function(str) {
exports.encodeHashComponent = function (str) {
return encodeURIComponent(str)
.replace(/\./g, '%2E')
.replace(/%/g, '.');

View File

@ -42,7 +42,7 @@ exports.initialize = function () {
$("#invite_user_form").ajaxForm({
dataType: 'json',
beforeSubmit: function(arr, $form, options) {
beforeSubmit: function (arr, $form, options) {
reset_error_messages();
// TODO: You could alternatively parse the textarea here, and return errors to
// the user if they don't match certain constraints (i.e. not real email addresses,

View File

@ -76,14 +76,14 @@ exports.end = function (row) {
}
};
exports.maybe_show_edit = function(row, id) {
exports.maybe_show_edit = function (row, id) {
if (currently_editing_messages[id] !== undefined){
current_msg_list.show_edit_message(row, currently_editing_messages[id]);
}
};
$(document).on('narrow_deactivated.zephyr', function (event) {
$.each(currently_editing_messages, function(idx, elem) {
$.each(currently_editing_messages, function (idx, elem) {
if (current_msg_list.get(idx) !== undefined) {
var row = rows.get(idx, current_msg_list.table_name);
current_msg_list.show_edit_message(row, elem);

View File

@ -448,7 +448,7 @@ MessageList.prototype = {
}});
}
$.each(rendered_elems, function(idx, elem) {
$.each(rendered_elems, function (idx, elem) {
var row = $(elem);
if (! row.hasClass('message_row')) {
return;
@ -490,7 +490,7 @@ MessageList.prototype = {
}
var new_messages_height = 0;
$.each(rendered_elems, function() {
$.each(rendered_elems, function () {
// Sometimes there are non-DOM elements in rendered_elems; only
// try to get the heights of actual trs.
if ($(this).is("tr")) {
@ -600,7 +600,7 @@ MessageList.prototype = {
// existing messages list, we just add the new messages and
// then rerender the whole thing.
this._items = messages.concat(this._items);
this._items.sort(function(a, b) {return a.id - b.id;});
this._items.sort(function (a, b) {return a.id - b.id;});
this._add_to_hash(messages);
this._clear_rendering_state();

View File

@ -554,7 +554,7 @@ exports.deactivate = function () {
$(document).trigger($.Event('narrow_deactivated.zephyr', {msg_list: current_msg_list}));
};
exports.restore_home_state = function() {
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

View File

@ -35,7 +35,7 @@ exports.initialize = function () {
});
if ($.browser.mozilla === true && typeof Notification !== "undefined") {
Notification.requestPermission(function() {
Notification.requestPermission(function () {
asked_permission_already = true;
});
}

View File

@ -40,7 +40,7 @@ exports.update = function (num_unread) {
};
// We disable the notifications bar if it overlaps with the composebox
exports.maybe_disable = function() {
exports.maybe_disable = function () {
if ($("#compose").offset().left + $("#compose").width() > $(area_selector).offset().left) {
disabled = true;
hide();
@ -48,7 +48,7 @@ exports.maybe_disable = function() {
};
// Un-disable the notifications bar, then call the update function to see if it should be displayed
exports.enable = function() {
exports.enable = function () {
disabled = false;
exports.update();
};

View File

@ -79,16 +79,16 @@ exports.update_typeahead = function () {
var stream_names = subs.subscribed_streams();
stream_names.sort();
var streams = $.map(stream_names, function(elt,idx) {
var streams = $.map(stream_names, function (elt,idx) {
return {action: 'stream', query: elt};
});
var people_names = page_params.people_list;
var people = $.map(people_names, function(elt,idx) {
var people = $.map(people_names, function (elt,idx) {
return {action: 'private_message', query: elt};
});
var senders = $.map(people_names, function(elt,idx) {
var senders = $.map(people_names, function (elt,idx) {
return {action: 'sender', query: elt};
});

View File

@ -60,12 +60,12 @@ $(function () {
$('#bot_avatar_upload_button').show();
}
$('#bot_avatar_clear_button').click(function(e) {
$('#bot_avatar_clear_button').click(function (e) {
clear_bot_avatar_file_input();
e.preventDefault();
});
$('#bot_avatar_upload_button').on('drop', function(e) {
$('#bot_avatar_upload_button').on('drop', function (e) {
var files = e.dataTransfer.files;
if (files === null || files === undefined || files.length === 0) {
return false;
@ -88,7 +88,7 @@ $(function () {
return $.inArray(type, supported_types) >= 0;
}
$('#bot_avatar_file_input').change(function(e) {
$('#bot_avatar_file_input').change(function (e) {
if (e.target.files.length === 0) {
$('#bot_avatar_file_input_error').hide();
} else if (e.target.files.length === 1) {
@ -111,7 +111,7 @@ $(function () {
}
});
$('#bot_avatar_upload_button').click(function(e) {
$('#bot_avatar_upload_button').click(function (e) {
$('#bot_avatar_file_input').trigger('click');
e.preventDefault();
});
@ -128,7 +128,7 @@ $(function () {
formData.append('csrfmiddlewaretoken', csrf_token);
formData.append('full_name', full_name);
formData.append('short_name', short_name);
jQuery.each($('#bot_avatar_file_input')[0].files, function(i, file) {
jQuery.each($('#bot_avatar_file_input')[0].files, function (i, file) {
formData.append('file-'+i, file);
});
util.make_loading_indicator($('#create_bot_spinner'), 'Adding bot');

View File

@ -14,7 +14,7 @@ exports.sort_narrow_list = function () {
var sort_recent = (streams.length > 40);
streams.sort(function(a, b) {
streams.sort(function (a, b) {
if (sort_recent) {
if (recent_subjects[b] !== undefined &&
recent_subjects[a] === undefined) {
@ -38,7 +38,7 @@ exports.sort_narrow_list = function () {
parent.empty();
var elems = [];
$.each(streams, function(i, stream) {
$.each(streams, function (i, stream) {
var li = $(subs.get(stream).sidebar_li);
if (sort_recent) {
if (recent_subjects[stream] === undefined) {
@ -235,19 +235,19 @@ exports.update_dom_with_unread_counts = function (counts) {
// Our job is to update some DOM elements.
// counts.stream_count maps streams to counts
$.each(counts.stream_count, function(stream, count) {
$.each(counts.stream_count, function (stream, count) {
exports.set_count("stream", stream, count);
});
// counts.subject_count maps streams to hashes of subjects to counts
$.each(counts.subject_count, function(stream, subject_hash) {
$.each(subject_hash, function(subject, count) {
$.each(counts.subject_count, function (stream, subject_hash) {
$.each(subject_hash, function (subject, count) {
exports.set_subject_count(stream, subject, count);
});
});
// counts.pm_count maps people to counts
$.each(counts.pm_count, function(person, count) {
$.each(counts.pm_count, function (person, count) {
exports.set_count("private", person, count);
});

View File

@ -34,7 +34,7 @@ function get_sub(stream_name) {
// Classes which could be returned by get_color_class.
exports.color_classes = 'dark_background';
exports.stream_info = function(new_stream_info) {
exports.stream_info = function (new_stream_info) {
if (new_stream_info !== undefined) {
stream_info = new_stream_info;
} else {
@ -117,7 +117,7 @@ function update_table_stream_color(table, stream_name, color) {
});
}
exports.stream_id = function(stream_name) {
exports.stream_id = function (stream_name) {
var sub = get_sub(stream_name);
if (sub === undefined) {
blueslip.error("Tried to get subs.stream_id for a stream user is not subscribed to!");
@ -550,7 +550,7 @@ exports.setup_page = function () {
/* arguments are [ "success", statusText, jqXHR ] */
if (stream_data.length > 2 && stream_data[2]) {
var stream_response = JSON.parse(stream_data[2].responseText);
$.each(stream_response.streams, function(idx, stream) {
$.each(stream_response.streams, function (idx, stream) {
all_streams.push(stream.name);
});
}
@ -561,7 +561,7 @@ exports.setup_page = function () {
// All streams won't contain invite-only streams,
// or anything at all if should_list_all_streams() is false
$.each(our_subs, function(idx, stream) {
$.each(our_subs, function (idx, stream) {
if (all_streams.indexOf(stream.name) === -1) {
all_streams.push(stream.name);
}

View File

@ -153,7 +153,7 @@ function set_tutorial_status(status, callback) {
});
}
exports.is_running = function() {
exports.is_running = function () {
return is_running;
};

View File

@ -33,7 +33,7 @@ exports.highlight_with_escaping = function (query, item) {
// to know the case of the content we're replacing (you can't just use a bolded
// version of 'query')
var result = "";
$.each(pieces, function(idx, piece) {
$.each(pieces, function (idx, piece) {
if (piece.match(regex)) {
result += "<strong>" + Handlebars.Utils.escapeExpression(piece) + "</strong>";
} else {
@ -46,7 +46,7 @@ exports.highlight_with_escaping = function (query, item) {
exports.highlight_with_escaping_and_regex = function (regex, item) {
var pieces = item.split(regex);
var result = "";
$.each(pieces, function(idx, piece) {
$.each(pieces, function (idx, piece) {
if (piece.match(regex)) {
result += "<strong>" + Handlebars.Utils.escapeExpression(piece) + "</strong>";
} else {
@ -162,7 +162,7 @@ exports.compare_by_pms = function (user_a, user_b) {
return 1;
};
exports.sort_by_pms = function(objs) {
exports.sort_by_pms = function (objs) {
objs.sort(exports.compare_by_pms);
return objs;
};
@ -183,7 +183,7 @@ exports.sort_recipients = function (matches, query) {
return matches_sorted_by_pms.concat(rest_sorted_by_pms);
};
exports.sort_textbox_typeahead = function(matches) {
exports.sort_textbox_typeahead = function (matches) {
// input may be free text ending in @ for autocomplete
var query = composebox_typeahead.split_at_cursor(this.query)[0];
if (query.indexOf('@') > -1) {
@ -193,7 +193,7 @@ exports.sort_textbox_typeahead = function(matches) {
return exports.sort_recipients(matches, query);
};
exports.sort_recipientbox_typeahead = function(matches) {
exports.sort_recipientbox_typeahead = function (matches) {
// input_text may be one or more pm recipients
var cleaned = composebox_typeahead.get_cleaned_pm_recipients(this.query);
var query = cleaned[cleaned.length - 1];

View File

@ -119,7 +119,7 @@ function copy_handler(e) {
ranges.push(range);
startc = $(range.startContainer);
start_data = find_boundary_tr($(startc.parents('tr')[0]), function(row) {
start_data = find_boundary_tr($(startc.parents('tr')[0]), function (row) {
return row.next();
});
if (start_data === undefined) {
@ -136,7 +136,7 @@ function copy_handler(e) {
} else {
initial_end_tr = $(endc.parents('tr')[0]);
}
end_data = find_boundary_tr(initial_end_tr, function(row) {
end_data = find_boundary_tr(initial_end_tr, function (row) {
return row.prev();
});
if (end_data === undefined) {
@ -186,7 +186,7 @@ function copy_handler(e) {
// After the copy has happened, delete the div and
// change the selection back to the original selection
window.setTimeout(function() {
window.setTimeout(function () {
selection = window.getSelection();
selection.removeAllRanges();
$.each(ranges, function (index, range) {
@ -1324,12 +1324,12 @@ $(function () {
$(e.target).popover("show");
var popover = $('.streams_popover[data-id=' + subs.get(stream).id + ']');
update_spectrum(popover, function(colorpicker) {
update_spectrum(popover, function (colorpicker) {
colorpicker.spectrum(subs.sidebar_popover_colorpicker_options);
});
$('.streams_popover').on('click', '.custom_color', function (e) {
update_spectrum($(e.target).closest('.streams_popover'), function(colorpicker) {
update_spectrum($(e.target).closest('.streams_popover'), function (colorpicker) {
colorpicker.spectrum("destroy");
colorpicker.spectrum(subs.sidebar_popover_colorpicker_options_full);
// In theory this should clean up the old color picker,

View File

@ -130,7 +130,7 @@ exports.get_counts = function () {
});
}
$.each(unread_counts.stream, function(stream, msgs) {
$.each(unread_counts.stream, function (stream, msgs) {
if (! subs.is_subscribed(stream)) {
return true;
}
@ -152,7 +152,7 @@ exports.get_counts = function () {
});
var pm_count = 0;
$.each(unread_counts["private"], function(index, obj) {
$.each(unread_counts["private"], function (index, obj) {
var count = Object.keys(obj).length;
res.pm_count[index] = count;
pm_count += count;

View File

@ -234,7 +234,7 @@ exports.strcmp = (function () {
};
}());
exports.escape_regexp = function(string) {
exports.escape_regexp = function (string) {
// code from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
// Modified to escape the ^ to appease jslint. :/
return string.replace(/([.*+?\^=!:${}()|\[\]\/\\])/g, "\\$1");

View File

@ -126,7 +126,7 @@ function make_dimen_wrapper(dimen_name, dimen_func) {
exports.height = make_dimen_wrapper('height', $(window).height);
exports.width = make_dimen_wrapper('width', $(window).width);
exports.stop_auto_scrolling = function() {
exports.stop_auto_scrolling = function () {
if (in_stoppable_autoscroll) {
$("html, body").stop();
}

View File

@ -797,12 +797,12 @@ function get_updates_success(data) {
break;
case 'subscriptions':
if (event.op === 'add') {
$.each(event.subscriptions, function(index, subscription) {
$.each(event.subscriptions, function (index, subscription) {
$(document).trigger($.Event('subscription_add.zephyr',
{subscription: subscription}));
});
} else if (event.op === 'remove') {
$.each(event.subscriptions, function(index, subscription) {
$.each(event.subscriptions, function (index, subscription) {
$(document).trigger($.Event('subscription_remove.zephyr',
{subscription: subscription}));
});

View File

@ -2,7 +2,7 @@ var common = require('../common.js').common;
common.start_and_log_in();
casper.then(function() {
casper.then(function () {
casper.test.info('Subscriptions page');
casper.click('a[href^="#subscriptions"]');
casper.test.assertUrlMatch(/^http:\/\/[^\/]+\/#subscriptions/, 'URL suggests we are on subscriptions page');
@ -11,13 +11,13 @@ casper.then(function() {
// the word "Unsubscribe" will appear
casper.waitForText('Unsubscribe');
});
casper.then(function() {
casper.then(function () {
casper.test.assertTextExists('Unsubscribe', 'Initial subscriptions loaded');
casper.fill('form#add_new_subscription', {stream_name: 'Waseemio'});
casper.click('form#add_new_subscription input.btn.btn-primary');
casper.waitForText('Waseemio');
});
casper.then(function() {
casper.then(function () {
casper.test.assertTextExists('Create stream Waseemio', 'Modal for specifying new stream users');
casper.click('form#stream_creation_form button.btn.btn-primary');
casper.waitFor(function () {
@ -26,19 +26,19 @@ casper.then(function() {
});
});
});
casper.then(function() {
casper.then(function () {
casper.test.assertSelectorHasText('.subscription_name', 'Waseemio', 'Subscribing to a stream');
casper.fill('form#add_new_subscription', {stream_name: 'WASeemio'});
casper.click('form#add_new_subscription input.btn.btn-primary');
casper.waitForText('Already subscribed');
});
casper.then(function() {
casper.then(function () {
casper.test.assertTextExists('Already subscribed', "Can't subscribe twice to a stream");
casper.fill('form#add_new_subscription', {stream_name: ' '});
casper.click('form#add_new_subscription input.btn.btn-primary');
casper.waitForText('Error adding subscription');
});
casper.then(function() {
casper.then(function () {
casper.test.assertTextExists('Error adding subscription', "Can't subscribe to an empty stream name");
});

View File

@ -4,7 +4,7 @@ common.start_and_log_in();
var form_sel = 'form[action^="/json/settings/change"]';
casper.then(function() {
casper.then(function () {
casper.test.info('Settings page');
casper.click('a[href^="#settings"]');
casper.test.assertUrlMatch(/^http:\/\/[^\/]+\/#settings/, 'URL suggests we are on settings page');
@ -16,7 +16,7 @@ casper.then(function() {
casper.click(".change_password_button");
});
casper.waitUntilVisible("#old_password", function() {
casper.waitUntilVisible("#old_password", function () {
casper.test.assertVisible("#old_password");
casper.test.assertVisible("#new_password");
casper.test.assertVisible("#confirm_password");

View File

@ -14,7 +14,7 @@ function toggle_last_star() {
common.start_and_log_in();
casper.then(function() {
casper.then(function () {
casper.test.info("Sending test message");
common.send_message('stream', {
stream: 'Verona',
@ -24,7 +24,7 @@ casper.then(function() {
casper.waitForText("test star");
});
casper.then(function() {
casper.then(function () {
casper.test.info("Checking star counts");
// Initially, no messages are starred.
@ -45,7 +45,7 @@ casper.waitUntilVisible('#zfilt', function () {
common.un_narrow();
});
casper.then(function() {
casper.then(function () {
// Clicking on a starred message unstars it.
toggle_last_star();
casper.test.assertEquals(star_count(), 0,