Parcourir la source

Fixes settings menu for non moderators

master
yanas il y a 8 ans
Parent
révision
a9e31a2843
2 fichiers modifiés avec 39 ajouts et 20 suppressions
  1. 21
    17
      modules/UI/side_pannels/settings/SettingsMenu.js
  2. 18
    3
      modules/UI/util/UIUtil.js

+ 21
- 17
modules/UI/side_pannels/settings/SettingsMenu.js Voir le fichier

@@ -74,11 +74,11 @@ export default {
74 74
                     }
75 75
                 });
76 76
 
77
-            // Only show the subtitle if this is the only setting section.
77
+            // Only show the subtitle if this isn't the only setting section.
78 78
             if (interfaceConfig.SETTINGS_SECTIONS.length > 1)
79
-                UIUtil.showHiddenElement("deviceOptionsTitle");
79
+                UIUtil.showElement("deviceOptionsTitle");
80 80
 
81
-            UIUtil.showHiddenElement("devicesOptions");
81
+            UIUtil.showElement("devicesOptions");
82 82
         }
83 83
 
84 84
         if (UIUtil.isSettingEnabled('language')) {
@@ -93,7 +93,7 @@ export default {
93 93
                 emitter.emit(UIEvents.LANG_CHANGED, languagesBox.val());
94 94
             });
95 95
 
96
-            UIUtil.showHiddenElement("languages_selectbox");
96
+            UIUtil.showElement("languages_selectbox");
97 97
         }
98 98
 
99 99
         if (UIUtil.isSettingEnabled('moderator')) {
@@ -116,13 +116,6 @@ export default {
116 116
                     isFollowMeEnabled
117 117
                 );
118 118
             });
119
-
120
-            // Only show the subtitle if this is the only setting section.
121
-            if (interfaceConfig.SETTINGS_SECTIONS.length > 1)
122
-                UIUtil.showHiddenElement("moderatorOptionsTitle");
123
-
124
-            UIUtil.showHiddenElement("startMutedOptions");
125
-            UIUtil.showHiddenElement("followMeOptions");
126 119
         }
127 120
     },
128 121
 
@@ -155,10 +148,21 @@ export default {
155 148
      * @param {boolean} show
156 149
      */
157 150
     showStartMutedOptions (show) {
158
-        if (show) {
159
-            $("#startMutedOptions").css("display", "block");
151
+        console.log("------", show, UIUtil.isSettingEnabled('moderator'));
152
+        if (show && UIUtil.isSettingEnabled('moderator')) {
153
+            console.log("idva li tuuk");
154
+            // Only show the subtitle if this isn't the only setting section.
155
+            if (!$("#moderatorOptionsTitle").is(":visible")
156
+                && interfaceConfig.SETTINGS_SECTIONS.length > 1)
157
+                UIUtil.showElement("moderatorOptionsTitle");
158
+
159
+            UIUtil.showElement("startMutedOptions");
160 160
         } else {
161
-            $("#startMutedOptions").css("display", "none");
161
+            // Only show the subtitle if this isn't the only setting section.
162
+            if ($("#moderatorOptionsTitle").is(":visible"))
163
+                UIUtil.hideElement("moderatorOptionsTitle");
164
+
165
+            UIUtil.hideElement("startMutedOptions");
162 166
         }
163 167
     },
164 168
 
@@ -173,10 +177,10 @@ export default {
173 177
      * @param {boolean} show {true} to show those options, {false} to hide them
174 178
      */
175 179
     showFollowMeOptions (show) {
176
-        if (show) {
177
-            $("#followMeOptions").css("display", "block");
180
+        if (show && UIUtil.isSettingEnabled('moderator')) {
181
+            UIUtil.showElement("followMeOptions");
178 182
         } else {
179
-            $("#followMeOptions").css("display", "none");
183
+            UIUtil.hideElement("followMeOptions");
180 184
         }
181 185
     },
182 186
 

+ 18
- 3
modules/UI/util/UIUtil.js Voir le fichier

@@ -129,10 +129,25 @@
129 129
     /**
130 130
      * Shows the element given by id.
131 131
      *
132
-     * @param {String} the identifier of the element
132
+     * @param {String} the identifier of the element to show
133 133
      */
134
-    showHiddenElement(id) {
135
-        $("#"+id).toggleClass("hide").toggleClass("show");
134
+    showElement(id) {
135
+        if ($("#"+id).hasClass("hide"))
136
+            $("#"+id).removeClass("hide");
137
+
138
+        $("#"+id).addClass("show");
139
+    },
140
+
141
+    /**
142
+     * Hides the element given by id.
143
+     *
144
+     * @param {String} the identifier of the element to hide
145
+     */
146
+    hideElement(id) {
147
+        if ($("#"+id).hasClass("show"))
148
+            $("#"+id).removeClass("show");
149
+
150
+        $("#"+id).addClass("hide");
136 151
     },
137 152
 
138 153
     hideDisabledButtons: function (mappings) {

Chargement…
Annuler
Enregistrer