settings: Deduplicate the template code for checkboxes.

This commit is contained in:
Shubham Dhama
2018-04-18 01:22:25 +05:30
committed by Tim Abbott
parent a3ba484c99
commit 6a11ff5b28
4 changed files with 35 additions and 67 deletions

View File

@@ -77,6 +77,16 @@ function setup_settings_label() {
enable_digest_emails: i18n.t("Send digest emails when I'm away"),
message_content_in_email_notifications: i18n.t("Include message content in missed message emails"),
realm_name_in_notifications: i18n.t("Include organization name in subject of missed message emails"),
// display settings
night_mode: i18n.t("Night mode"),
high_contrast_mode: i18n.t("High contrast mode"),
left_side_userlist: i18n.t("User list on left sidebar in narrow windows"),
twenty_four_hour_time: i18n.t("24-hour time (17:00 instead of 5:00 PM)"),
translate_emoticons: i18n.t("Translate emoticons (convert <code>:)</code> to 😃 in messages)"),
// Zulip Labs
default_desktop_notifications: i18n.t("Enable desktop notifications for new streams"),
};
}

View File

@@ -5,7 +5,7 @@ var exports = {};
exports.set_up = function () {
$("#ui-settings-status").hide();
$("#ui-settings .change-setting").change(function (e) {
$("#ui-settings .ui-settings-form").change(function (e) {
e.preventDefault();
var labs_updates = {};
_.each(["default_desktop_notifications"],

View File

@@ -23,56 +23,30 @@
<h3 class="inline-block">{{t "Display settings" }}</h3>
<div class="alert-notification" id="display-settings-status"></div>
<div class="input-group">
<label class="checkbox">
<input type="checkbox" name="night_mode" id="night_mode"
{{#if page_params.night_mode}}
checked="checked"
{{/if}} />
<span></span>
</label>
<label for="night_mode" class="inline-block">{{t "Night mode" }}</label>
</div>
{{partial "settings_checkbox"
"setting_name" "night_mode"
"is_checked" page_params.night_mode
"label" settings_label.night_mode}}
<div class="input-group">
<label class="checkbox">
<input type="checkbox" name="high_contrast_mode" id="high_contrast_mode"
{{#if page_params.high_contrast_mode}}
checked="checked"
{{/if}} />
<span></span>
</label>
<label for="high_contrast_mode" class="inline-block">{{t "High contrast mode" }}</label>
</div>
{{partial "settings_checkbox"
"setting_name" "high_contrast_mode"
"is_checked" page_params.high_contrast_mode
"label" settings_label.high_contrast_mode}}
<div class="input-group">
<label class="checkbox">
<input type="checkbox" name="left_side_userlist" id="left_side_userlist"
{{#if page_params.left_side_userlist}}
checked="checked"
{{/if}} />
<span></span>
</label>
<label for="left_side_userlist" class="inline-block">{{t "User list on left sidebar in narrow windows" }}</label>
</div>
{{partial "settings_checkbox"
"setting_name" "left_side_userlist"
"is_checked" page_params.left_side_userlist
"label" settings_label.left_side_userlist}}
</div>
<div id="user-time-settings">
<h3 class="inline-block">{{t "Time settings" }}</h3>
<div class="alert-notification" id="time-settings-status"></div>
<div class="input-group">
<label class="checkbox">
<input type="checkbox" name="twenty_four_hour_time" id="twenty_four_hour_time"
{{#if page_params.twenty_four_hour_time}}
checked="checked"
{{/if}} />
<span></span>
</label>
<label for="twenty_four_hour_time" class="inline-block">
{{t "24-hour time (17:00 instead of 5:00 PM)" }}
</label>
</div>
{{partial "settings_checkbox"
"setting_name" "twenty_four_hour_time"
"is_checked" page_params.twenty_four_hour_time
"label" settings_label.twenty_four_hour_time}}
<div class="input-group">
<label for="timezone" class="dropdown-title">{{t "Time zone" }}:</label>
@@ -113,18 +87,10 @@
</div>
</div>
<div class="input-group">
<label class="checkbox">
<input type="checkbox" name="translate_emoticons" id="translate_emoticons"
{{#if page_params.translate_emoticons}}
checked="checked"
{{/if}} />
<span></span>
</label>
<label for="translate_emoticons" class="inline-block">
{{t "Translate emoticons (convert <code>:)</code> to 😃 in messages)" }}
</label>
</div>
{{partial "settings_checkbox"
"setting_name" "translate_emoticons"
"is_checked" page_params.translate_emoticons
"label" settings_label.translate_emoticons}}
</div>
</form>
</div>

View File

@@ -5,18 +5,10 @@
<div id="lab-ui-settings">
<h3>{{t "UI Settings"}}</h3>
<div class="input-group">
<label class="checkbox">
<input type="checkbox" class="inline-block change-setting" name="default_desktop_notifications" id="default_desktop_notifications"
{{#if page_params.default_desktop_notifications}}
checked="checked"
{{/if}} />
<span></span>
</label>
<label for="default_desktop_notifications" class="inline-block">
{{t "Enable desktop notifications for new streams" }}
</label>
</div>
{{partial "settings_checkbox"
"setting_name" "default_desktop_notifications"
"is_checked" page_params.default_desktop_notifications
"label" settings_label.default_desktop_notifications}}
</div>
</form>
</div>