浏览代码

Merge pull request #1111 from BeatC/FIX-clean-js-from-styles-1

Fix clean js from styles 1
master
yanas 8 年前
父节点
当前提交
8caae4bfde

+ 4
- 0
css/_base.scss 查看文件

@@ -153,6 +153,10 @@ form {
153 153
     display: inline-block !important;
154 154
 }
155 155
 
156
+.show-list-item {
157
+    display: list-item !important;
158
+}
159
+
156 160
 /**
157 161
  * Shows a flex element.
158 162
  */

+ 3
- 3
modules/UI/UI.js 查看文件

@@ -31,7 +31,7 @@ var EventEmitter = require("events");
31 31
 UI.messageHandler = require("./util/MessageHandler");
32 32
 var messageHandler = UI.messageHandler;
33 33
 var JitsiPopover = require("./util/JitsiPopover");
34
-var Feedback = require("./feedback/Feedback");
34
+import Feedback from "./feedback/Feedback";
35 35
 import FollowMe from "../FollowMe";
36 36
 
37 37
 var eventEmitter = new EventEmitter();
@@ -444,10 +444,10 @@ UI.start = function () {
444 444
         // Display notice message at the top of the toolbar
445 445
         if (config.noticeMessage) {
446 446
             $('#noticeText').text(config.noticeMessage);
447
-            $('#notice').css({display: 'block'});
447
+            UIUtil.showElement('notice');
448 448
         }
449 449
     } else {
450
-        $("#mainToolbarContainer").css("display", "none");
450
+        UIUtil.hideElement('mainToolbarContainer');
451 451
         FilmStrip.setupFilmStripOnly();
452 452
         messageHandler.enableNotifications(false);
453 453
         JitsiPopover.enabled = false;

+ 3
- 36
modules/UI/feedback/Feedback.js 查看文件

@@ -1,36 +1,12 @@
1 1
 /* global $, APP, JitsiMeetJS */
2
-import UIEvents from "../../../service/UI/UIEvents";
3 2
 import FeedbackWindow from "./FeedbackWindow";
4 3
 
5
-/**
6
- * Shows / hides the feedback button.
7
- * @private
8
- */
9
-function _toggleFeedbackIcon() {
10
-    $('#feedbackButtonDiv').toggleClass("hidden");
11
-}
12
-
13
-/**
14
- * Shows / hides the feedback button.
15
- * @param {show} set to {true} to show the feedback button or to  {false}
16
- * to hide it
17
- * @private
18
- */
19
-function _showFeedbackButton (show) {
20
-    var feedbackButton = $("#feedbackButtonDiv");
21
-
22
-    if (show)
23
-        feedbackButton.css("display", "block");
24
-    else
25
-        feedbackButton.css("display", "none");
26
-}
27
-
28 4
 /**
29 5
  * Defines all methods in connection to the Feedback window.
30 6
  *
31 7
  * @type {{openFeedbackWindow: Function}}
32 8
  */
33
-var Feedback = {
9
+const Feedback = {
34 10
 
35 11
     /**
36 12
      * Initialise the Feedback functionality.
@@ -47,24 +23,15 @@ var Feedback = {
47 23
         if (typeof this.enabled == "undefined")
48 24
             this.enabled = true;
49 25
 
50
-        _showFeedbackButton(this.enabled);
51
-
52 26
         this.window = new FeedbackWindow();
27
+        this.emitter = emitter;
53 28
 
54 29
         $("#feedbackButton").click(Feedback.openFeedbackWindow);
55
-
56
-        // Show / hide the feedback button whenever the film strip is
57
-        // shown / hidden.
58
-        emitter.addListener(UIEvents.TOGGLE_FILM_STRIP, function () {
59
-            _toggleFeedbackIcon();
60
-        });
61 30
     },
62 31
     /**
63 32
      * Enables/ disabled the feedback feature.
64 33
      */
65 34
     enableFeedback: function (enable) {
66
-        if (this.enabled !== enable)
67
-            _showFeedbackButton(enable);
68 35
         this.enabled = enable;
69 36
     },
70 37
 
@@ -125,4 +92,4 @@ var Feedback = {
125 92
     }
126 93
 };
127 94
 
128
-module.exports = Feedback;
95
+export default Feedback;

+ 17
- 7
modules/UI/recording/Recording.js 查看文件

@@ -387,10 +387,15 @@ var Recording = {
387 387
      * @param show {true} to show the recording button, {false} to hide it
388 388
      */
389 389
     showRecordingButton (show) {
390
-        if (_isRecordingButtonEnabled() && show) {
391
-            $('#toolbar_button_record').css({display: "inline-block"});
390
+        let isVisible = show && _isRecordingButtonEnabled();
391
+        let id = 'toolbar_button_record';
392
+
393
+        console.log('recording is visible', isVisible);
394
+
395
+        if (isVisible) {
396
+            UIUtil.showElement(id);
392 397
         } else {
393
-            $('#toolbar_button_record').css({display: "none"});
398
+            UIUtil.hideElement(id);
394 399
         }
395 400
     },
396 401
 
@@ -474,10 +479,15 @@ var Recording = {
474 479
             labelSelector.css({display: "inline-block"});
475 480
 
476 481
         // Recording spinner
477
-        if (recordingState === Status.RETRYING)
478
-            $("#recordingSpinner").show();
479
-        else
480
-            $("#recordingSpinner").hide();
482
+        let spinnerId = 'recordingSpinner';
483
+        if(recordingState === Status.RETRYING) {
484
+            UIUtil.showElement(spinnerId);
485
+        } else {
486
+            UIUtil.hideElement(spinnerId);
487
+        }
488
+
489
+        document.querySelector('#recordingSpinner').classList
490
+                .toggle('show-inline', recordingState === Status.RETRYING);
481 491
     },
482 492
     // checks whether recording is enabled and whether we have params
483 493
     // to start automatically recording

+ 8
- 5
modules/UI/side_pannels/chat/Chat.js 查看文件

@@ -293,15 +293,18 @@ var Chat = {
293 293
      * @param subject the subject
294 294
      */
295 295
     setSubject (subject) {
296
+        let toggleFunction;
296 297
         if (subject) {
297 298
             subject = subject.trim();
298
-        }
299
-        $('#subject').html(linkify(UIUtil.escapeHtml(subject)));
300
-        if (subject) {
301
-            $("#subject").css({display: "block"});
299
+            toggleFunction = UIUtil.showElement.bind(UIUtil);
302 300
         } else {
303
-            $("#subject").css({display: "none"});
301
+            toggleFunction = UIUtil.hideElement.bind(UIUtil);
304 302
         }
303
+
304
+        let subjectId = 'subject';
305
+        let html = linkify(UIUtil.escapeHtml(subject));
306
+        $(`#${subjectId}`).html(html);
307
+        toggleFunction(subjectId);
305 308
     },
306 309
 
307 310
     /**

+ 39
- 27
modules/UI/toolbars/Toolbar.js 查看文件

@@ -401,9 +401,12 @@ Toolbar = {
401 401
      * @param show <tt>true</tt> to show or <tt>false</tt> to hide
402 402
      */
403 403
     showAuthenticateButton (show) {
404
-        let display = show ? 'block' : 'none';
405
-
406
-        $('#authenticationContainer').css({display});
404
+        let id = 'authenticationContainer';
405
+        if (show) {
406
+            UIUtil.showElement(id);
407
+        } else {
408
+            UIUtil.hideElement(id);
409
+        }
407 410
     },
408 411
 
409 412
     showEtherpadButton () {
@@ -414,13 +417,16 @@ Toolbar = {
414 417
 
415 418
     // Shows or hides the 'shared video' button.
416 419
     showSharedVideoButton () {
417
-        let $element = $('#toolbar_button_sharedvideo');
418
-        if (UIUtil.isButtonEnabled('sharedvideo')
419
-                && config.disableThirdPartyRequests !== true) {
420
-            $element.css({display: "inline-block"});
421
-            UIUtil.setTooltip($element.get(0), 'toolbar.sharedvideo', 'right');
420
+        let id = 'toolbar_button_sharedvideo';
421
+        let shouldShow = UIUtil.isButtonEnabled('sharedvideo')
422
+                && !config.disableThirdPartyRequests;
423
+
424
+        if (shouldShow) {
425
+            let el = document.getElementById(id);
426
+            UIUtil.setTooltip(el, 'toolbar.sharedvideo', 'right');
427
+            UIUtil.showElement(id);
422 428
         } else {
423
-            $('#toolbar_button_sharedvideo').css({display: "none"});
429
+            UIUtil.hideElement(id);
424 430
         }
425 431
     },
426 432
 
@@ -435,20 +441,25 @@ Toolbar = {
435 441
 
436 442
     // Shows or hides SIP calls button
437 443
     showSipCallButton (show) {
438
-        if (APP.conference.sipGatewayEnabled()
439
-            && UIUtil.isButtonEnabled('sip') && show) {
440
-            $('#toolbar_button_sip').css({display: "inline-block"});
444
+        let shouldShow = APP.conference.sipGatewayEnabled()
445
+            && UIUtil.isButtonEnabled('sip') && show;
446
+        let id = 'toolbar_button_sip';
447
+
448
+        if (shouldShow) {
449
+            UIUtil.showElement(id);
441 450
         } else {
442
-            $('#toolbar_button_sip').css({display: "none"});
451
+            UIUtil.hideElement(id);
443 452
         }
444 453
     },
445 454
 
446 455
     // Shows or hides the dialpad button
447 456
     showDialPadButton (show) {
448
-        if (UIUtil.isButtonEnabled('dialpad') && show) {
449
-            $('#toolbar_button_dialpad').css({display: "inline-block"});
457
+        let shouldShow = UIUtil.isButtonEnabled('dialpad') && show;
458
+        let id = 'toolbar_button_dialpad';
459
+        if (shouldShow) {
460
+            UIUtil.showElement(id);
450 461
         } else {
451
-            $('#toolbar_button_dialpad').css({display: "none"});
462
+            UIUtil.hideElement(id);
452 463
         }
453 464
     },
454 465
 
@@ -457,14 +468,13 @@ Toolbar = {
457 468
      * @param authIdentity identity name to be displayed.
458 469
      */
459 470
     setAuthenticatedIdentity (authIdentity) {
460
-        let selector = $('#toolbar_auth_identity');
461
-
462
-        if (authIdentity) {
463
-            selector.css({display: "list-item"});
464
-            selector.text(authIdentity);
471
+        let id = 'toolbar_auth_identity';
472
+        if(authIdentity) {
473
+            UIUtil.showElement(id);
474
+            $(`#${id}`).text(authIdentity);
465 475
         } else {
466
-            selector.css({display: "none"});
467
-            selector.text('');
476
+            UIUtil.hideElement(id);
477
+            $(`#${id}`).text('');
468 478
         }
469 479
     },
470 480
 
@@ -473,10 +483,11 @@ Toolbar = {
473 483
      * @param show <tt>true</tt> to show
474 484
      */
475 485
     showLoginButton (show) {
486
+        let id = 'toolbar_button_login';
476 487
         if (show) {
477
-            $('#toolbar_button_login').css({display: "list-item"});
488
+            UIUtil.showElement(id);
478 489
         } else {
479
-            $('#toolbar_button_login').css({display: "none"});
490
+            UIUtil.hideElement(id);
480 491
         }
481 492
     },
482 493
 
@@ -485,10 +496,11 @@ Toolbar = {
485 496
      * @param show <tt>true</tt> to show
486 497
      */
487 498
     showLogoutButton (show) {
499
+        let id = 'toolbar_button_logout';
488 500
         if (show) {
489
-            $('#toolbar_button_logout').css({display: "list-item"});
501
+            UIUtil.showElement(id);
490 502
         } else {
491
-            $('#toolbar_button_logout').css({display: "none"});
503
+            UIUtil.hideElement(id);
492 504
         }
493 505
     },
494 506
 

+ 59
- 6
modules/UI/util/UIUtil.js 查看文件

@@ -18,6 +18,15 @@ const TOOLTIP_POSITIONS = {
18 18
     'top-right': 'sw'
19 19
 };
20 20
 
21
+/**
22
+ * Associates the default display type with corresponding CSS class
23
+ */
24
+const SHOW_CLASSES = {
25
+    'block': 'show',
26
+    'inline': 'show-inline',
27
+    'list-item': 'show-list-item'
28
+};
29
+
21 30
 /**
22 31
  * Created by hristo on 12/22/14.
23 32
  */
@@ -217,10 +226,24 @@ const TOOLTIP_POSITIONS = {
217 226
      * @param {String} the identifier of the element to show
218 227
      */
219 228
     showElement(id) {
220
-        if ($("#"+id).hasClass("hide"))
221
-            $("#"+id).removeClass("hide");
229
+        let element;
230
+        if (id instanceof HTMLElement) {
231
+            element = id;
232
+        } else {
233
+            element = document.getElementById(id);
234
+        }
222 235
 
223
-        $("#"+id).addClass("show");
236
+        if (!element) {
237
+            return;
238
+        }
239
+
240
+        if(element.classList.contains('hide')) {
241
+            element.classList.remove('hide');
242
+        }
243
+
244
+        let type = this.getElementDefaultDisplay(element.tagName);
245
+        let className = SHOW_CLASSES[type];
246
+        element.classList.add(className);
224 247
     },
225 248
 
226 249
     /**
@@ -229,10 +252,40 @@ const TOOLTIP_POSITIONS = {
229 252
      * @param {String} the identifier of the element to hide
230 253
      */
231 254
     hideElement(id) {
232
-        if ($("#"+id).hasClass("show"))
233
-            $("#"+id).removeClass("show");
255
+        let element;
256
+        if (id instanceof HTMLElement) {
257
+            element = id;
258
+        } else {
259
+            element = document.getElementById(id);
260
+        }
261
+
262
+        if (!element) {
263
+            return;
264
+        }
265
+
266
+        let type = this.getElementDefaultDisplay(element.tagName);
267
+        let className = SHOW_CLASSES[type];
268
+
269
+        if(element.classList.contains(className)) {
270
+            element.classList.remove(className);
271
+        }
272
+
273
+        element.classList.add('hide');
274
+    },
275
+
276
+    /**
277
+     * Returns default display style for the tag
278
+     * @param tag
279
+     * @returns {*}
280
+     */
281
+    getElementDefaultDisplay(tag) {
282
+        let tempElement = document.createElement(tag);
283
+
284
+        document.body.appendChild(tempElement);
285
+        let style = window.getComputedStyle(tempElement).display;
286
+        document.body.removeChild(tempElement);
234 287
 
235
-        $("#"+id).addClass("hide");
288
+        return style;
236 289
     },
237 290
 
238 291
     /**

+ 3
- 2
modules/UI/videolayout/LargeVideoManager.js 查看文件

@@ -332,13 +332,14 @@ export default class LargeVideoManager {
332 332
             show = APP.conference.isConnectionInterrupted();
333 333
         }
334 334
 
335
+        let id = 'localConnectionMessage';
335 336
         if (show) {
336
-            $('#localConnectionMessage').css({display: "block"});
337
+            UIUtil.showElement(id);
337 338
             // Avatar message conflicts with 'videoConnectionMessage',
338 339
             // so it must be hidden
339 340
             this.showRemoteConnectionMessage(false);
340 341
         } else {
341
-            $('#localConnectionMessage').css({display: "none"});
342
+            UIUtil.hideElement(id);
342 343
         }
343 344
     }
344 345
 

+ 29
- 27
modules/UI/videolayout/SmallVideo.js 查看文件

@@ -216,15 +216,13 @@ SmallVideo.prototype.hideIndicator = function () {
216 216
  * or hidden
217 217
  */
218 218
 SmallVideo.prototype.showAudioIndicator = function(isMuted) {
219
-
220
-    var audioMutedIndicator = this.getAudioMutedIndicator();
221
-
222
-    if (!isMuted) {
223
-        audioMutedIndicator.hide();
224
-    }
225
-    else {
226
-        audioMutedIndicator.show();
219
+    let mutedIndicator = this.getAudioMutedIndicator();
220
+    if (isMuted) {
221
+        UIUtil.showElement(mutedIndicator);
222
+    } else {
223
+        UIUtil.hideElement(mutedIndicator);
227 224
     }
225
+
228 226
     this.isAudioMuted = isMuted;
229 227
 };
230 228
 
@@ -232,12 +230,13 @@ SmallVideo.prototype.showAudioIndicator = function(isMuted) {
232 230
  * Returns the audio muted indicator jquery object. If it doesn't exists -
233 231
  * creates it.
234 232
  *
235
- * @returns {jQuery|HTMLElement} the audio muted indicator
233
+ * @returns {HTMLElement} the audio muted indicator
236 234
  */
237 235
 SmallVideo.prototype.getAudioMutedIndicator = function () {
238
-    var audioMutedSpan = $('#' + this.videoSpanId + ' .audioMuted');
236
+    let selector = '#' + this.videoSpanId + ' .audioMuted';
237
+    let audioMutedSpan = document.querySelector(selector);
239 238
 
240
-    if (audioMutedSpan.length) {
239
+    if (audioMutedSpan) {
241 240
         return audioMutedSpan;
242 241
     }
243 242
 
@@ -248,16 +247,15 @@ SmallVideo.prototype.getAudioMutedIndicator = function () {
248 247
         "videothumbnail.mute",
249 248
         "top");
250 249
 
250
+    let mutedIndicator = document.createElement('i');
251
+    mutedIndicator.className = 'icon-mic-disabled';
252
+    audioMutedSpan.appendChild(mutedIndicator);
253
+
251 254
     this.container
252 255
         .querySelector('.videocontainer__toolbar')
253 256
         .appendChild(audioMutedSpan);
254 257
 
255
-
256
-    var mutedIndicator = document.createElement('i');
257
-    mutedIndicator.className = 'icon-mic-disabled';
258
-    audioMutedSpan.appendChild(mutedIndicator);
259
-
260
-    return $('#' + this.videoSpanId + ' .audioMuted');
258
+    return audioMutedSpan;
261 259
 };
262 260
 
263 261
 /**
@@ -271,9 +269,12 @@ SmallVideo.prototype.setVideoMutedView = function(isMuted) {
271 269
     this.isVideoMuted = isMuted;
272 270
     this.updateView();
273 271
 
274
-    var videoMutedSpan = this.getVideoMutedIndicator();
275
-
276
-    videoMutedSpan[isMuted ? 'show' : 'hide']();
272
+    let element = this.getVideoMutedIndicator();
273
+    if (isMuted) {
274
+        UIUtil.showElement(element);
275
+    } else {
276
+        UIUtil.hideElement(element);
277
+    }
277 278
 };
278 279
 
279 280
 /**
@@ -283,9 +284,10 @@ SmallVideo.prototype.setVideoMutedView = function(isMuted) {
283 284
  * @returns {jQuery|HTMLElement} the video muted indicator
284 285
  */
285 286
 SmallVideo.prototype.getVideoMutedIndicator = function () {
286
-    var videoMutedSpan = $('#' + this.videoSpanId + ' .videoMuted');
287
+    var selector = '#' + this.videoSpanId + ' .videoMuted';
288
+    var videoMutedSpan = document.querySelector(selector);
287 289
 
288
-    if (videoMutedSpan.length) {
290
+    if (videoMutedSpan) {
289 291
         return videoMutedSpan;
290 292
     }
291 293
 
@@ -305,7 +307,7 @@ SmallVideo.prototype.getVideoMutedIndicator = function () {
305 307
 
306 308
     videoMutedSpan.appendChild(mutedIndicator);
307 309
 
308
-    return $('#' + this.videoSpanId + ' .videoMuted');
310
+    return videoMutedSpan;
309 311
 };
310 312
 
311 313
 /**
@@ -575,9 +577,9 @@ SmallVideo.prototype.showDominantSpeakerIndicator = function (show) {
575 577
     });
576 578
 
577 579
     if (show) {
578
-        indicatorSpan.classList.add('show');
580
+        UIUtil.showElement(indicatorSpan);
579 581
     } else {
580
-        indicatorSpan.classList.remove('show');
582
+        UIUtil.hideElement(indicatorSpan);
581 583
     }
582 584
 };
583 585
 
@@ -603,9 +605,9 @@ SmallVideo.prototype.showRaisedHandIndicator = function (show) {
603 605
     });
604 606
 
605 607
     if (show) {
606
-        indicatorSpan.classList.add('show');
608
+        UIUtil.showElement(indicatorSpan);
607 609
     } else {
608
-        indicatorSpan.classList.remove('show');
610
+        UIUtil.hideElement(indicatorSpan);
609 611
     }
610 612
 };
611 613
 

+ 6
- 5
modules/UI/videolayout/VideoLayout.js 查看文件

@@ -1136,12 +1136,13 @@ var VideoLayout = {
1136 1136
      * video stream is currently HD.
1137 1137
      */
1138 1138
     updateResolutionLabel(isResolutionHD) {
1139
-        let videoResolutionLabel = $("#videoResolutionLabel");
1139
+        let id = 'videoResolutionLabel';
1140 1140
 
1141
-        if (isResolutionHD && !videoResolutionLabel.is(":visible"))
1142
-            videoResolutionLabel.css({display: "block"});
1143
-        else if (!isResolutionHD && videoResolutionLabel.is(":visible"))
1144
-            videoResolutionLabel.css({display: "none"});
1141
+        if (isResolutionHD) {
1142
+            UIUtil.showElement(id);
1143
+        } else {
1144
+            UIUtil.hideElement(id);
1145
+        }
1145 1146
     },
1146 1147
 
1147 1148
     /**

正在加载...
取消
保存