Selaa lähdekoodia

ref(jQuery) Replace some jQuery with JS (#13102)

factor2
Robert Pintilii 2 vuotta sitten
vanhempi
commit
ac8e088e50
No account linked to committer's email address

+ 19
- 19
modules/UI/UI.js Näytä tiedosto

@@ -5,7 +5,6 @@ const UI = {};
5 5
 
6 6
 import Logger from '@jitsi/logger';
7 7
 import EventEmitter from 'events';
8
-import $ from 'jquery';
9 8
 
10 9
 import { isMobileBrowser } from '../../react/features/base/environment/utils';
11 10
 import { setColorAlpha } from '../../react/features/base/util';
@@ -106,16 +105,16 @@ UI.start = function() {
106 105
     VideoLayout.resizeVideoArea();
107 106
 
108 107
     if (isMobileBrowser()) {
109
-        $('body').addClass('mobile-browser');
108
+        document.body.classList.add('mobile-browser');
110 109
     } else {
111
-        $('body').addClass('desktop-browser');
110
+        document.body.classList.add('desktop-browser');
112 111
     }
113 112
 
114 113
     if (config.backgroundAlpha !== undefined) {
115
-        const backgroundColor = $('body').css('background-color');
114
+        const backgroundColor = getComputedStyle(document.body).getPropertyValue('background-color');
116 115
         const alphaColor = setColorAlpha(backgroundColor, config.backgroundAlpha);
117 116
 
118
-        $('body').css('background-color', alphaColor);
117
+        document.body.style.backgroundColor = alphaColor;
119 118
     }
120 119
 
121 120
     if (config.iAmRecorder) {
@@ -134,33 +133,34 @@ UI.start = function() {
134 133
 UI.registerListeners
135 134
     = () => UIListeners.forEach((value, key) => UI.addListener(key, value));
136 135
 
136
+/**
137
+ *
138
+ */
139
+function onResize() {
140
+    VideoLayout.onResize();
141
+}
142
+
137 143
 /**
138 144
  * Setup some DOM event listeners.
139 145
  */
140 146
 UI.bindEvents = () => {
141
-    /**
142
-     *
143
-     */
144
-    function onResize() {
145
-        VideoLayout.onResize();
146
-    }
147
-
148 147
     // Resize and reposition videos in full screen mode.
149
-    $(document).on(
150
-            'webkitfullscreenchange mozfullscreenchange fullscreenchange',
151
-            onResize);
148
+    document.addEventListener('webkitfullscreenchange', onResize);
149
+    document.addEventListener('mozfullscreenchange', onResize);
150
+    document.addEventListener('fullscreenchange', onResize);
152 151
 
153
-    $(window).resize(onResize);
152
+    window.addEventListener('resize', onResize);
154 153
 };
155 154
 
156 155
 /**
157 156
  * Unbind some DOM event listeners.
158 157
  */
159 158
 UI.unbindEvents = () => {
160
-    $(document).off(
161
-            'webkitfullscreenchange mozfullscreenchange fullscreenchange');
159
+    document.removeEventListener('webkitfullscreenchange', onResize);
160
+    document.removeEventListener('mozfullscreenchange', onResize);
161
+    document.removeEventListener('fullscreenchange', onResize);
162 162
 
163
-    $(window).off('resize');
163
+    window.removeEventListener('resize', onResize);
164 164
 };
165 165
 
166 166
 /**

+ 3
- 5
modules/UI/videolayout/Filmstrip.js Näytä tiedosto

@@ -1,7 +1,5 @@
1 1
 /* global APP, interfaceConfig */
2 2
 
3
-import $ from 'jquery';
4
-
5 3
 import { getVerticalFilmstripVisibleAreaWidth, isFilmstripVisible } from '../../../react/features/filmstrip';
6 4
 
7 5
 const Filmstrip = {
@@ -14,16 +12,16 @@ const Filmstrip = {
14 12
         // horizontal film strip mode for calculating how tall large video
15 13
         // display should be.
16 14
         if (isFilmstripVisible(APP.store) && !interfaceConfig.VERTICAL_FILMSTRIP) {
17
-            return $('.filmstrip').outerHeight();
15
+            return document.querySelector('.filmstrip').offsetHeight;
18 16
         }
19 17
 
20 18
         return 0;
21 19
     },
22 20
 
23 21
     /**
24
-     * Returns the width of the vertical filmstip if the filmstrip is visible and 0 otherwise.
22
+     * Returns the width of the vertical filmstrip if the filmstrip is visible and 0 otherwise.
25 23
      *
26
-     * @returns {number} - The width of the vertical filmstip if the filmstrip is visible and 0 otherwise.
24
+     * @returns {number} - The width of the vertical filmstrip if the filmstrip is visible and 0 otherwise.
27 25
      */
28 26
     getVerticalFilmstripWidth() {
29 27
         return isFilmstripVisible(APP.store) ? getVerticalFilmstripVisibleAreaWidth() : 0;

+ 20
- 20
modules/UI/videolayout/LargeVideoManager.js Näytä tiedosto

@@ -128,16 +128,12 @@ export default class LargeVideoManager {
128 128
          */
129 129
         this.videoTrack = undefined;
130 130
 
131
-        this.$container = $('#largeVideoContainer');
131
+        this.container = document.getElementById('largeVideoContainer');
132 132
 
133
-        this.$container.css({
134
-            display: 'inline-block'
135
-        });
133
+        this.container.style.display = 'inline-block';
136 134
 
137
-        this.$container.hover(
138
-            e => this.onHoverIn(e),
139
-            e => this.onHoverOut(e)
140
-        );
135
+        this.container.addEventListener('mouseenter', e => this.onHoverIn(e));
136
+        this.container.addEventListener('mouseleave', e => this.onHoverOut(e));
141 137
 
142 138
         // Bind event handler so it is only bound once for every instance.
143 139
         this._onVideoResolutionUpdate
@@ -172,7 +168,7 @@ export default class LargeVideoManager {
172 168
 
173 169
         ReactDOM.unmountComponentAtNode(this._dominantSpeakerAvatarContainer);
174 170
 
175
-        this.$container.css({ display: 'none' });
171
+        this.container.style.display = 'none';
176 172
     }
177 173
 
178 174
     /**
@@ -540,8 +536,8 @@ export default class LargeVideoManager {
540 536
      * @returns {void}
541 537
      */
542 538
     updatePresenceLabel(id) {
543
-        const isConnectionMessageVisible
544
-            = $('#remoteConnectionMessage').is(':visible');
539
+        const isConnectionMessageVisible = getComputedStyle(
540
+            document.getElementById('remoteConnectionMessage')).display !== 'none';
545 541
 
546 542
         if (isConnectionMessageVisible) {
547 543
             this.removePresenceLabel();
@@ -549,9 +545,9 @@ export default class LargeVideoManager {
549 545
             return;
550 546
         }
551 547
 
552
-        const presenceLabelContainer = $('#remotePresenceMessage');
548
+        const presenceLabelContainer = document.getElementById('remotePresenceMessage');
553 549
 
554
-        if (presenceLabelContainer.length) {
550
+        if (presenceLabelContainer) {
555 551
             ReactDOM.render(
556 552
                 <Provider store = { APP.store }>
557 553
                     <I18nextProvider i18n = { i18next }>
@@ -560,7 +556,7 @@ export default class LargeVideoManager {
560 556
                             className = 'presence-label' />
561 557
                     </I18nextProvider>
562 558
                 </Provider>,
563
-                presenceLabelContainer.get(0));
559
+                presenceLabelContainer);
564 560
         }
565 561
     }
566 562
 
@@ -570,10 +566,10 @@ export default class LargeVideoManager {
570 566
      * @returns {void}
571 567
      */
572 568
     removePresenceLabel() {
573
-        const presenceLabelContainer = $('#remotePresenceMessage');
569
+        const presenceLabelContainer = document.getElementById('remotePresenceMessage');
574 570
 
575
-        if (presenceLabelContainer.length) {
576
-            ReactDOM.unmountComponentAtNode(presenceLabelContainer.get(0));
571
+        if (presenceLabelContainer) {
572
+            ReactDOM.unmountComponentAtNode(presenceLabelContainer);
577 573
         }
578 574
     }
579 575
 
@@ -582,7 +578,11 @@ export default class LargeVideoManager {
582 578
      * @param {boolean} show
583 579
      */
584 580
     showWatermark(show) {
585
-        $('.watermark').css('visibility', show ? 'visible' : 'hidden');
581
+        const watermark = document.querySelectorAll('.watermark');
582
+
583
+        watermark.forEach(el => {
584
+            el.style.visibility = show ? 'visible' : 'hidden';
585
+        });
586 586
     }
587 587
 
588 588
     /**
@@ -607,9 +607,9 @@ export default class LargeVideoManager {
607 607
         }
608 608
 
609 609
         if (show) {
610
-            $('#remoteConnectionMessage').css({ display: 'block' });
610
+            document.getElementById('remoteConnectionMessage').style.display = 'block';
611 611
         } else {
612
-            $('#remoteConnectionMessage').hide();
612
+            document.getElementById('remoteConnectionMessage').style.display = 'none';
613 613
         }
614 614
     }
615 615
 

+ 15
- 18
modules/UI/videolayout/VideoContainer.js Näytä tiedosto

@@ -223,15 +223,14 @@ export class VideoContainer extends LargeContainer {
223 223
          * @type {boolean}
224 224
          */
225 225
         this.avatarDisplayed = false;
226
-        this.$avatar = $('#dominantSpeaker');
226
+        this.avatar = document.getElementById('dominantSpeaker');
227 227
 
228 228
         /**
229
-         * A jQuery selector of the remote connection message.
230
-         * @type {jQuery|HTMLElement}
229
+         * The HTMLElements of the remote connection message.
230
+         * @type {HTMLElement}
231 231
          */
232
-        this.$remoteConnectionMessage = $('#remoteConnectionMessage');
233
-
234
-        this.$remotePresenceMessage = $('#remotePresenceMessage');
232
+        this.remoteConnectionMessage = document.getElementById('remoteConnectionMessage');
233
+        this.remotePresenceMessage = document.getElementById('remotePresenceMessage');
235 234
 
236 235
         this.$wrapper = $('#largeVideoWrapper');
237 236
 
@@ -241,7 +240,7 @@ export class VideoContainer extends LargeContainer {
241 240
          * video anyway.
242 241
          */
243 242
         this.$wrapperParent = this.$wrapper.parent();
244
-        this.avatarHeight = $('#dominantSpeakerAvatarContainer').height();
243
+        this.avatarHeight = document.getElementById('dominantSpeakerAvatarContainer').getBoundingClientRect().height;
245 244
         this.$video[0].onplaying = function(event) {
246 245
             if (typeof resizeContainer === 'function') {
247 246
                 resizeContainer(event);
@@ -358,8 +357,8 @@ export class VideoContainer extends LargeContainer {
358 357
      * @returns {void}
359 358
      */
360 359
     positionRemoteStatusMessages() {
361
-        this._positionParticipantStatus(this.$remoteConnectionMessage);
362
-        this._positionParticipantStatus(this.$remotePresenceMessage);
360
+        this._positionParticipantStatus(this.remoteConnectionMessage);
361
+        this._positionParticipantStatus(this.remotePresenceMessage);
363 362
     }
364 363
 
365 364
     /**
@@ -369,18 +368,16 @@ export class VideoContainer extends LargeContainer {
369 368
      * @private
370 369
      * @returns {void}
371 370
      */
372
-    _positionParticipantStatus($element) {
371
+    _positionParticipantStatus(element) {
373 372
         if (this.avatarDisplayed) {
374
-            const $avatarImage = $('#dominantSpeakerAvatarContainer');
373
+            const avatarImage = document.getElementById('dominantSpeakerAvatarContainer').getBoundingClientRect();
375 374
 
376
-            $element.css(
377
-                'top',
378
-                $avatarImage.offset().top + $avatarImage.height() + 10);
375
+            element.style.top = avatarImage.top + avatarImage.height + 10;
379 376
         } else {
380
-            const height = $element.height();
381
-            const parentHeight = $element.parent().height();
377
+            const height = element.getBoundingClientRect().height;
378
+            const parentHeight = element.parentElement.getBoundingClientRect().height;
382 379
 
383
-            $element.css('top', (parentHeight / 2) - (height / 2));
380
+            element.style.top = (parentHeight / 2) - (height / 2);
384 381
         }
385 382
     }
386 383
 
@@ -540,7 +537,7 @@ export class VideoContainer extends LargeContainer {
540 537
      * @param {boolean} show
541 538
      */
542 539
     showAvatar(show) {
543
-        this.$avatar.css('visibility', show ? 'visible' : 'hidden');
540
+        this.avatar.style.visibility = show ? 'visible' : 'hidden';
544 541
         this.avatarDisplayed = show;
545 542
 
546 543
         APP.API.notifyLargeVideoVisibilityChanged(show);

Loading…
Peruuta
Tallenna