mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 22:19:48 +00:00
Replace $.extend
(imported from commit 2c1ee3c2714d388f2a71398fe81c049cc54ff94d)
This commit is contained in:
@@ -23,7 +23,7 @@ var console = (function () {
|
|||||||
var reported_errors = {};
|
var reported_errors = {};
|
||||||
var last_report_attempt = {};
|
var last_report_attempt = {};
|
||||||
function report_error(msg, stack, opts) {
|
function report_error(msg, stack, opts) {
|
||||||
opts = $.extend({}, {show_ui_msg: false}, opts);
|
opts = _.extend({show_ui_msg: false}, opts);
|
||||||
|
|
||||||
if (stack === undefined) {
|
if (stack === undefined) {
|
||||||
stack = 'No stacktrace available';
|
stack = 'No stacktrace available';
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ exports.start = function (msg_type, opts) {
|
|||||||
// Set default parameters based on the current narrowed view.
|
// Set default parameters based on the current narrowed view.
|
||||||
narrow.set_compose_defaults(default_opts);
|
narrow.set_compose_defaults(default_opts);
|
||||||
|
|
||||||
opts = $.extend(default_opts, opts);
|
opts = _.extend(default_opts, opts);
|
||||||
|
|
||||||
if (!(compose.composing() === msg_type &&
|
if (!(compose.composing() === msg_type &&
|
||||||
((msg_type === "stream" &&
|
((msg_type === "stream" &&
|
||||||
@@ -312,7 +312,7 @@ exports.snapshot_message = function (message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (message !== undefined) {
|
if (message !== undefined) {
|
||||||
message_snapshot = $.extend({}, message);
|
message_snapshot = _.extend({}, message);
|
||||||
} else {
|
} else {
|
||||||
// Save what we can.
|
// Save what we can.
|
||||||
message_snapshot = create_message_object();
|
message_snapshot = create_message_object();
|
||||||
@@ -328,14 +328,13 @@ exports.restore_message = function () {
|
|||||||
if (!message_snapshot) {
|
if (!message_snapshot) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var snapshot_copy = $.extend({}, message_snapshot);
|
var snapshot_copy = _.extend({}, message_snapshot);
|
||||||
if ((snapshot_copy.type === "stream" &&
|
if ((snapshot_copy.type === "stream" &&
|
||||||
snapshot_copy.stream.length > 0 &&
|
snapshot_copy.stream.length > 0 &&
|
||||||
snapshot_copy.subject.length > 0) ||
|
snapshot_copy.subject.length > 0) ||
|
||||||
(snapshot_copy.type === "private" &&
|
(snapshot_copy.type === "private" &&
|
||||||
snapshot_copy.reply_to.length > 0)) {
|
snapshot_copy.reply_to.length > 0)) {
|
||||||
snapshot_copy = $.extend({replying_to_message: snapshot_copy},
|
_.defaults(snapshot_copy, {replying_to_message: snapshot_copy});
|
||||||
snapshot_copy);
|
|
||||||
}
|
}
|
||||||
clear_message_snapshot();
|
clear_message_snapshot();
|
||||||
exports.unfade_messages(true);
|
exports.unfade_messages(true);
|
||||||
@@ -392,7 +391,8 @@ function send_message() {
|
|||||||
else {
|
else {
|
||||||
respond_to_cursor = false;
|
respond_to_cursor = false;
|
||||||
if (page_params.staging) {
|
if (page_params.staging) {
|
||||||
var new_msg = $.extend({replying_to_message: request}, request);
|
var new_msg = _.extend({replying_to_message: request},
|
||||||
|
request);
|
||||||
new_msg.content = "";
|
new_msg.content = "";
|
||||||
compose.start(new_msg.type, new_msg);
|
compose.start(new_msg.type, new_msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*jslint nomen: true */
|
/*jslint nomen: true */
|
||||||
function MessageList(table_name, filter, opts) {
|
function MessageList(table_name, filter, opts) {
|
||||||
$.extend(this, {collapse_messages: true}, opts);
|
_.extend(this, {collapse_messages: true}, opts);
|
||||||
this._items = [];
|
this._items = [];
|
||||||
this._hash = {};
|
this._hash = {};
|
||||||
this.table_name = table_name;
|
this.table_name = table_name;
|
||||||
@@ -93,7 +93,7 @@ MessageList.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
clear: function MessageList_clear(opts) {
|
clear: function MessageList_clear(opts) {
|
||||||
opts = $.extend({}, {clear_selected_id: true}, opts);
|
opts = _.extend({clear_selected_id: true}, opts);
|
||||||
|
|
||||||
this._items = [];
|
this._items = [];
|
||||||
this._hash = {};
|
this._hash = {};
|
||||||
@@ -109,7 +109,7 @@ MessageList.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
select_id: function MessageList_select_id(id, opts) {
|
select_id: function MessageList_select_id(id, opts) {
|
||||||
opts = $.extend({
|
opts = _.extend({
|
||||||
then_scroll: false,
|
then_scroll: false,
|
||||||
use_closest: false,
|
use_closest: false,
|
||||||
mark_read: true
|
mark_read: true
|
||||||
|
|||||||
@@ -334,12 +334,12 @@ exports.activate = function (operators, opts) {
|
|||||||
return exports.deactivate();
|
return exports.deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
opts = $.extend({}, {
|
opts = _.defaults({}, opts, {
|
||||||
then_select_id: home_msg_list.selected_id(),
|
then_select_id: home_msg_list.selected_id(),
|
||||||
select_first_unread: false,
|
select_first_unread: false,
|
||||||
change_hash: true,
|
change_hash: true,
|
||||||
trigger: 'unknown'
|
trigger: 'unknown'
|
||||||
}, opts);
|
});
|
||||||
|
|
||||||
if (opts.then_select_id === -1) {
|
if (opts.then_select_id === -1) {
|
||||||
// If we're loading the page via a narrowed URL, we may not
|
// If we're loading the page via a narrowed URL, we may not
|
||||||
@@ -481,7 +481,7 @@ exports.by_subject = function (target_id, opts) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mark_message_as_read(original);
|
mark_message_as_read(original);
|
||||||
opts = $.extend({}, {then_select_id: target_id}, opts);
|
opts = _.defaults({}, opts, {then_select_id: target_id});
|
||||||
exports.activate([
|
exports.activate([
|
||||||
['stream', original.stream],
|
['stream', original.stream],
|
||||||
['topic', original.subject]
|
['topic', original.subject]
|
||||||
@@ -490,7 +490,7 @@ exports.by_subject = function (target_id, opts) {
|
|||||||
|
|
||||||
// Called for the 'narrow by stream' hotkey.
|
// Called for the 'narrow by stream' hotkey.
|
||||||
exports.by_recipient = function (target_id, opts) {
|
exports.by_recipient = function (target_id, opts) {
|
||||||
opts = $.extend({}, {then_select_id: target_id}, opts);
|
opts = _.defaults({}, opts, {then_select_id: target_id});
|
||||||
var message = current_msg_list.get(target_id);
|
var message = current_msg_list.get(target_id);
|
||||||
mark_message_as_read(message);
|
mark_message_as_read(message);
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
@@ -505,7 +505,7 @@ exports.by_recipient = function (target_id, opts) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.by_time_travel = function (target_id, opts) {
|
exports.by_time_travel = function (target_id, opts) {
|
||||||
opts = $.extend({}, {then_select_id: target_id}, opts);
|
opts = _.defaults({}, opts, {then_select_id: target_id});
|
||||||
narrow.activate([], opts);
|
narrow.activate([], opts);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -107,10 +107,11 @@ function do_reload_app(send_after_reload, save_state, message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports.initiate = function (options) {
|
exports.initiate = function (options) {
|
||||||
var defaults = {immediate: false,
|
options = _.defaults({}, options, {
|
||||||
save_state: true,
|
immediate: false,
|
||||||
send_after_reload: false};
|
save_state: true,
|
||||||
options = $.extend(defaults, options);
|
send_after_reload: false
|
||||||
|
});
|
||||||
|
|
||||||
if (options.immediate) {
|
if (options.immediate) {
|
||||||
do_reload_app(options.send_after_reload, options.save_state, options.message);
|
do_reload_app(options.send_after_reload, options.save_state, options.message);
|
||||||
|
|||||||
@@ -152,12 +152,12 @@ var subscriptions_table_colorpicker_options = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function set_colorpicker_color(colorpicker, color) {
|
function set_colorpicker_color(colorpicker, color) {
|
||||||
colorpicker.spectrum($.extend(subscriptions_table_colorpicker_options,
|
colorpicker.spectrum(_.extend(subscriptions_table_colorpicker_options,
|
||||||
{color: color}));
|
{color: color}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_stream_color(stream_name, color, opts) {
|
function update_stream_color(stream_name, color, opts) {
|
||||||
opts = $.extend({}, {update_historical: false}, opts);
|
opts = _.defaults({}, opts, {update_historical: false});
|
||||||
var sub = get_sub(stream_name);
|
var sub = get_sub(stream_name);
|
||||||
sub.color = color;
|
sub.color = color;
|
||||||
var id = parseInt(sub.id, 10);
|
var id = parseInt(sub.id, 10);
|
||||||
@@ -304,13 +304,16 @@ function create_sub(stream_name, attrs) {
|
|||||||
return sub;
|
return sub;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub = $.extend({}, {name: stream_name, id: next_sub_id++,
|
sub = _.defaults({}, attrs, {
|
||||||
render_subscribers: should_render_subscribers(),
|
name: stream_name,
|
||||||
subscribed: true, in_home_view: true, invite_only: false,
|
id: next_sub_id++,
|
||||||
notifications: false}, attrs);
|
render_subscribers: should_render_subscribers(),
|
||||||
if (sub.color === undefined) {
|
subscribed: true,
|
||||||
sub.color = pick_color();
|
in_home_view: true,
|
||||||
}
|
invite_only: false,
|
||||||
|
notifications: false,
|
||||||
|
color: pick_color()
|
||||||
|
});
|
||||||
mark_color_used(sub.color);
|
mark_color_used(sub.color);
|
||||||
|
|
||||||
add_sub(stream_name, sub);
|
add_sub(stream_name, sub);
|
||||||
@@ -548,7 +551,7 @@ function populate_subscriptions(subs, subscribed) {
|
|||||||
|
|
||||||
exports.reload_subscriptions = function (opts) {
|
exports.reload_subscriptions = function (opts) {
|
||||||
var on_success;
|
var on_success;
|
||||||
opts = $.extend({}, {clear_first: false, custom_callbacks: false}, opts);
|
opts = _.defaults({}, opts, {clear_first: false, custom_callbacks: false});
|
||||||
|
|
||||||
if (! opts.custom_callbacks) {
|
if (! opts.custom_callbacks) {
|
||||||
on_success = function (data) {
|
on_success = function (data) {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ exports.set_favicon = function (url) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.make_loading_indicator = function (outer_container, opts) {
|
exports.make_loading_indicator = function (outer_container, opts) {
|
||||||
opts = $.extend({}, opts);
|
opts = opts || {};
|
||||||
var container = outer_container;
|
var container = outer_container;
|
||||||
container.empty();
|
container.empty();
|
||||||
|
|
||||||
|
|||||||
@@ -153,7 +153,8 @@ function keep_pointer_in_view() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function recenter_view(message, opts) {
|
function recenter_view(message, opts) {
|
||||||
opts = $.extend({}, opts);
|
opts = opts || {};
|
||||||
|
|
||||||
// Barnowl-style recentering: if the pointer is too high, move it to
|
// Barnowl-style recentering: if the pointer is too high, move it to
|
||||||
// the 1/2 marks. If the pointer is too low, move it to the 1/7 mark.
|
// the 1/2 marks. If the pointer is too low, move it to the 1/7 mark.
|
||||||
// See keep_pointer_in_view() for related logic to keep the pointer onscreen.
|
// See keep_pointer_in_view() for related logic to keep the pointer onscreen.
|
||||||
@@ -932,8 +933,7 @@ function get_updates_success(data) {
|
|||||||
var get_updates_xhr;
|
var get_updates_xhr;
|
||||||
var get_updates_timeout;
|
var get_updates_timeout;
|
||||||
function get_updates(options) {
|
function get_updates(options) {
|
||||||
var defaults = {dont_block: false};
|
options = _.extend({dont_block: false}, options);
|
||||||
options = $.extend({}, defaults, options);
|
|
||||||
|
|
||||||
get_updates_params.pointer = furthest_read;
|
get_updates_params.pointer = furthest_read;
|
||||||
get_updates_params.dont_block = options.dont_block || get_updates_failures > 0;
|
get_updates_params.dont_block = options.dont_block || get_updates_failures > 0;
|
||||||
@@ -1003,9 +1003,7 @@ function force_get_updates() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function load_old_messages(opts) {
|
function load_old_messages(opts) {
|
||||||
opts = $.extend({}, {
|
opts = _.extend({cont_will_add_messages: false}, opts);
|
||||||
cont_will_add_messages: false
|
|
||||||
}, opts);
|
|
||||||
|
|
||||||
var data = {anchor: opts.anchor,
|
var data = {anchor: opts.anchor,
|
||||||
num_before: opts.num_before,
|
num_before: opts.num_before,
|
||||||
|
|||||||
Reference in New Issue
Block a user