mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
Unbreak custom alert words on the settings page.
This doesn't change the alerting UI logic, it just turns alert_words_ui into a module and calls the setup code from settings.js when the settings page is rendered. (imported from commit 05f95383b046086641280f82f648be58688efe61)
This commit is contained in:
@@ -1,13 +1,8 @@
|
|||||||
$(function () {
|
var alert_words_ui = (function () {
|
||||||
var word_list = $('#word-alerts');
|
|
||||||
_.each(alert_words.words, function (word) {
|
|
||||||
var li = templates.render('alert_word_settings_item', {'word': word});
|
|
||||||
word_list.append(li);
|
|
||||||
});
|
|
||||||
var new_word = templates.render('alert_word_settings_item', {'word': '', editing: true});
|
|
||||||
word_list.append(new_word);
|
|
||||||
|
|
||||||
function update_word_alerts() {
|
var exports = {};
|
||||||
|
|
||||||
|
function update_word_alerts() {
|
||||||
var words = _.map($('.alert-word-item'), function (e) {
|
var words = _.map($('.alert-word-item'), function (e) {
|
||||||
return $(e).data('word');
|
return $(e).data('word');
|
||||||
});
|
});
|
||||||
@@ -19,9 +14,9 @@ $(function () {
|
|||||||
url: '/json/set_alert_words',
|
url: '/json/set_alert_words',
|
||||||
idempotent: true,
|
idempotent: true,
|
||||||
data: {alert_words: JSON.stringify(words)}});
|
data: {alert_words: JSON.stringify(words)}});
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_alert_word(word, event) {
|
function add_alert_word(word, event) {
|
||||||
if (word === '') {
|
if (word === '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -32,6 +27,7 @@ $(function () {
|
|||||||
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 = $('#word-alerts');
|
||||||
word_list.append(new_word);
|
word_list.append(new_word);
|
||||||
|
|
||||||
if (word_list.find('input').length > 0) {
|
if (word_list.find('input').length > 0) {
|
||||||
@@ -39,7 +35,18 @@ $(function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update_word_alerts();
|
update_word_alerts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.set_up_alert_words = function () {
|
||||||
|
// The settings page must be rendered before this function gets called.
|
||||||
|
|
||||||
|
var word_list = $('#word-alerts');
|
||||||
|
_.each(alert_words.words, function (word) {
|
||||||
|
var li = templates.render('alert_word_settings_item', {'word': word});
|
||||||
|
word_list.append(li);
|
||||||
|
});
|
||||||
|
var new_word = templates.render('alert_word_settings_item', {'word': '', editing: true});
|
||||||
|
word_list.append(new_word);
|
||||||
|
|
||||||
$('#word-alerts').on('click', '.add-alert-word', function (event) {
|
$('#word-alerts').on('click', '.add-alert-word', function (event) {
|
||||||
var word = $(event.target).siblings('input').val();
|
var word = $(event.target).siblings('input').val();
|
||||||
@@ -63,5 +70,7 @@ $(function () {
|
|||||||
add_alert_word(word, event);
|
add_alert_word(word, event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
}());
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ exports.setup_page = function () {
|
|||||||
$("#notify-settings-status").hide();
|
$("#notify-settings-status").hide();
|
||||||
$("#ui-settings-status").hide();
|
$("#ui-settings-status").hide();
|
||||||
|
|
||||||
|
alert_words_ui.set_up_alert_words();
|
||||||
|
|
||||||
$("#api_key_value").text("");
|
$("#api_key_value").text("");
|
||||||
$("#get_api_key_box").hide();
|
$("#get_api_key_box").hide();
|
||||||
$("#show_api_key_box").hide();
|
$("#show_api_key_box").hide();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ var globals =
|
|||||||
+ ' compose compose_fade rows hotkeys narrow reload notifications_bar search subs'
|
+ ' compose compose_fade rows hotkeys narrow reload notifications_bar search subs'
|
||||||
+ ' composebox_typeahead server_events typeahead_helper notifications hashchange'
|
+ ' composebox_typeahead server_events typeahead_helper notifications hashchange'
|
||||||
+ ' invite ui util activity timerender MessageList MessageListView blueslip unread stream_list'
|
+ ' invite ui util activity timerender MessageList MessageListView blueslip unread stream_list'
|
||||||
+ ' message_edit tab_bar emoji popovers navigate people settings message_store'
|
+ ' message_edit tab_bar emoji popovers navigate people settings alert_words_ui message_store'
|
||||||
+ ' avatar feature_flags search_suggestion referral stream_color Dict'
|
+ ' avatar feature_flags search_suggestion referral stream_color Dict'
|
||||||
+ ' Filter summary admin stream_data muting WinChan muting_ui Socket channel'
|
+ ' Filter summary admin stream_data muting WinChan muting_ui Socket channel'
|
||||||
+ ' message_flags'
|
+ ' message_flags'
|
||||||
|
|||||||
Reference in New Issue
Block a user