Przeglądaj źródła

ref(small-video): remove some global jquery dom querying

Create a reference to the jquery element instead of querying for
it globally. This is to better encapsulate the small video
component.
master
Leonard Kim 8 lat temu
rodzic
commit
52ee8fd473

+ 1
- 0
modules/UI/shared_video/SharedVideo.js Wyświetl plik

647
     this.setVideoType(SHARED_VIDEO_CONTAINER_TYPE);
647
     this.setVideoType(SHARED_VIDEO_CONTAINER_TYPE);
648
     this.videoSpanId = "sharedVideoContainer";
648
     this.videoSpanId = "sharedVideoContainer";
649
     this.container = this.createContainer(this.videoSpanId);
649
     this.container = this.createContainer(this.videoSpanId);
650
+    this.$container = $(this.container);
650
     this.container.onclick = this.videoClick.bind(this);
651
     this.container.onclick = this.videoClick.bind(this);
651
     this.bindHoverHandler();
652
     this.bindHoverHandler();
652
     SmallVideo.call(this, VideoLayout);
653
     SmallVideo.call(this, VideoLayout);

+ 8
- 8
modules/UI/videolayout/LocalVideo.js Wyświetl plik

19
     this.videoSpanId = "localVideoContainer";
19
     this.videoSpanId = "localVideoContainer";
20
 
20
 
21
     this.container = this.createContainer();
21
     this.container = this.createContainer();
22
+    this.$container = $(this.container);
22
     $("#filmstripLocalVideo").append(this.container);
23
     $("#filmstripLocalVideo").append(this.container);
23
 
24
 
24
     this.localVideoId = null;
25
     this.localVideoId = null;
122
         }
123
         }
123
     };
124
     };
124
 
125
 
125
-    let localVideoContainerSelector = $('#localVideoContainer');
126
-    localVideoContainerSelector.off('click');
127
-    localVideoContainerSelector.on('click', localVideoClick);
126
+    this.$container.off('click');
127
+    this.$container.on('click', localVideoClick);
128
 
128
 
129
     this.localVideoId = 'localVideo_' + stream.getId();
129
     this.localVideoId = 'localVideo_' + stream.getId();
130
 
130
 
173
 
173
 
174
     // We toggle the hidden class as an indication to other interested parties
174
     // We toggle the hidden class as an indication to other interested parties
175
     // that this container has been hidden on purpose.
175
     // that this container has been hidden on purpose.
176
-    $("#localVideoContainer").toggleClass("hidden");
176
+    this.$container.toggleClass("hidden");
177
 
177
 
178
     // We still show/hide it as we need to overwrite the style property if we
178
     // We still show/hide it as we need to overwrite the style property if we
179
     // want our action to take effect. Toggling the display property through
179
     // want our action to take effect. Toggling the display property through
180
     // the above css class didn't succeed in overwriting the style.
180
     // the above css class didn't succeed in overwriting the style.
181
     if (visible) {
181
     if (visible) {
182
-        $("#localVideoContainer").show();
182
+        this.$container.show();
183
     }
183
     }
184
     else {
184
     else {
185
-        $("#localVideoContainer").hide();
185
+        this.$container.hide();
186
     }
186
     }
187
 };
187
 };
188
 
188
 
233
  * @param enable {boolean} true for enable, false for disable
233
  * @param enable {boolean} true for enable, false for disable
234
  */
234
  */
235
 LocalVideo.prototype._enableDisableContextMenu = function (enable) {
235
 LocalVideo.prototype._enableDisableContextMenu = function (enable) {
236
-    if($('#' + this.videoSpanId).contextMenu)
237
-        $('#' + this.videoSpanId).contextMenu(enable);
236
+    if(this.$container.contextMenu)
237
+        this.$container.contextMenu(enable);
238
 };
238
 };
239
 
239
 
240
 export default LocalVideo;
240
 export default LocalVideo;

+ 3
- 2
modules/UI/videolayout/RemoteVideo.js Wyświetl plik

85
 
85
 
86
 RemoteVideo.prototype.addRemoteVideoContainer = function() {
86
 RemoteVideo.prototype.addRemoteVideoContainer = function() {
87
     this.container = RemoteVideo.createContainer(this.videoSpanId);
87
     this.container = RemoteVideo.createContainer(this.videoSpanId);
88
+    this.$container = $(this.container);
88
 
89
 
89
     this.initBrowserSpecificProperties();
90
     this.initBrowserSpecificProperties();
90
 
91
 
409
  * @inheritDoc
410
  * @inheritDoc
410
  */
411
  */
411
 RemoteVideo.prototype.updateView = function () {
412
 RemoteVideo.prototype.updateView = function () {
412
-    $(this.container).toggleClass('audio-only', APP.conference.isAudioOnly());
413
+    this.$container.toggleClass('audio-only', APP.conference.isAudioOnly());
413
 
414
 
414
     this.updateConnectionStatusIndicator();
415
     this.updateConnectionStatusIndicator();
415
 
416
 
610
  * @param videoElementId the id of local or remote video element.
611
  * @param videoElementId the id of local or remote video element.
611
  */
612
  */
612
 RemoteVideo.prototype.removeRemoteVideoMenu = function() {
613
 RemoteVideo.prototype.removeRemoteVideoMenu = function() {
613
-    var menuSpan = $('#' + this.videoSpanId + '> .remotevideomenu');
614
+    var menuSpan = this.$container.find('.remotevideomenu');
614
 
615
 
615
     if (menuSpan.length) {
616
     if (menuSpan.length) {
616
         ReactDOM.unmountComponentAtNode(menuSpan.get(0));
617
         ReactDOM.unmountComponentAtNode(menuSpan.get(0));

+ 13
- 13
modules/UI/videolayout/SmallVideo.js Wyświetl plik

146
  * <tt>false</tt> - otherwise.
146
  * <tt>false</tt> - otherwise.
147
  */
147
  */
148
 SmallVideo.prototype.isVisible = function () {
148
 SmallVideo.prototype.isVisible = function () {
149
-    return $('#' + this.videoSpanId).is(':visible');
149
+    return this.$container.is(':visible');
150
 };
150
 };
151
 
151
 
152
 /**
152
 /**
171
     if(!this.container)
171
     if(!this.container)
172
         return;
172
         return;
173
 
173
 
174
-    var noMic = $("#" + this.videoSpanId + " > .noMic");
175
-    var noVideo =  $("#" + this.videoSpanId + " > .noVideo");
174
+    var noMic = this.$container.find('.noMic');
175
+    var noVideo =  this.$container.find('.noVideo');
176
 
176
 
177
     noMic.remove();
177
     noMic.remove();
178
     noVideo.remove();
178
     noVideo.remove();
249
  */
249
  */
250
 SmallVideo.prototype.bindHoverHandler = function () {
250
 SmallVideo.prototype.bindHoverHandler = function () {
251
     // Add hover handler
251
     // Add hover handler
252
-    $(this.container).hover(
252
+    this.$container.hover(
253
         () => {
253
         () => {
254
             this.videoIsHovered = true;
254
             this.videoIsHovered = true;
255
             this.updateView();
255
             this.updateView();
429
  * array (after checking its length of course!).
429
  * array (after checking its length of course!).
430
  */
430
  */
431
 SmallVideo.prototype.selectVideoElement = function () {
431
 SmallVideo.prototype.selectVideoElement = function () {
432
-    return $(RTCUIHelper.findVideoElement($('#' + this.videoSpanId)[0]));
432
+    return $(RTCUIHelper.findVideoElement(this.container));
433
 };
433
 };
434
 
434
 
435
 /**
435
 /**
439
  * element which displays the user's avatar.
439
  * element which displays the user's avatar.
440
  */
440
  */
441
 SmallVideo.prototype.$avatar = function () {
441
 SmallVideo.prototype.$avatar = function () {
442
-    return $('#' + this.videoSpanId + ' .avatar-container');
442
+    return this.$container.find('.avatar-container');
443
 };
443
 };
444
 
444
 
445
 /**
445
 /**
449
  * the video thumbnail
449
  * the video thumbnail
450
  */
450
  */
451
 SmallVideo.prototype.$displayName = function () {
451
 SmallVideo.prototype.$displayName = function () {
452
-    return $('#' + this.videoSpanId + ' .displayNameContainer');
452
+    return this.$container.find('.displayNameContainer');
453
 };
453
 };
454
 
454
 
455
 /**
455
 /**
498
  */
498
  */
499
 SmallVideo.prototype.focus = function(isFocused) {
499
 SmallVideo.prototype.focus = function(isFocused) {
500
     var focusedCssClass = "videoContainerFocused";
500
     var focusedCssClass = "videoContainerFocused";
501
-    var isFocusClassEnabled = $(this.container).hasClass(focusedCssClass);
501
+    var isFocusClassEnabled = this.$container.hasClass(focusedCssClass);
502
 
502
 
503
     if (!isFocused && isFocusClassEnabled) {
503
     if (!isFocused && isFocusClassEnabled) {
504
-        $(this.container).removeClass(focusedCssClass);
504
+        this.$container.removeClass(focusedCssClass);
505
     }
505
     }
506
     else if (isFocused && !isFocusClassEnabled) {
506
     else if (isFocused && !isFocusClassEnabled) {
507
-        $(this.container).addClass(focusedCssClass);
507
+        this.$container.addClass(focusedCssClass);
508
     }
508
     }
509
 };
509
 };
510
 
510
 
608
                                 || displayMode === DISPLAY_AVATAR_WITH_NAME));
608
                                 || displayMode === DISPLAY_AVATAR_WITH_NAME));
609
     // show hide overlay when there is a video or avatar under
609
     // show hide overlay when there is a video or avatar under
610
     // the display name
610
     // the display name
611
-    UIUtil.setVisibleBySelector($('#' + this.videoSpanId
612
-                                + ' .videocontainer__hoverOverlay'),
611
+    UIUtil.setVisibleBySelector(this.$container.find(
612
+                                '.videocontainer__hoverOverlay'),
613
                                 (displayMode === DISPLAY_AVATAR_WITH_NAME
613
                                 (displayMode === DISPLAY_AVATAR_WITH_NAME
614
                                 || displayMode === DISPLAY_VIDEO_WITH_NAME));
614
                                 || displayMode === DISPLAY_VIDEO_WITH_NAME));
615
 };
615
 };
738
     if (userAgent.indexOf("QtWebEngine") > -1
738
     if (userAgent.indexOf("QtWebEngine") > -1
739
         && (userAgent.indexOf("Windows") > -1
739
         && (userAgent.indexOf("Windows") > -1
740
             || userAgent.indexOf("Linux") > -1)) {
740
             || userAgent.indexOf("Linux") > -1)) {
741
-        $('#' + this.videoSpanId).css("overflow", "hidden");
741
+        this.$container.css("overflow", "hidden");
742
     }
742
     }
743
 };
743
 };
744
 
744
 

Ładowanie…
Anuluj
Zapisz