瀏覽代碼

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.
j8
Leonard Kim 8 年之前
父節點
當前提交
52ee8fd473

+ 1
- 0
modules/UI/shared_video/SharedVideo.js 查看文件

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

+ 8
- 8
modules/UI/videolayout/LocalVideo.js 查看文件

@@ -19,6 +19,7 @@ function LocalVideo(VideoLayout, emitter) {
19 19
     this.videoSpanId = "localVideoContainer";
20 20
 
21 21
     this.container = this.createContainer();
22
+    this.$container = $(this.container);
22 23
     $("#filmstripLocalVideo").append(this.container);
23 24
 
24 25
     this.localVideoId = null;
@@ -122,9 +123,8 @@ LocalVideo.prototype.changeVideo = function (stream) {
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 129
     this.localVideoId = 'localVideo_' + stream.getId();
130 130
 
@@ -173,16 +173,16 @@ LocalVideo.prototype.setVisible = function(visible) {
173 173
 
174 174
     // We toggle the hidden class as an indication to other interested parties
175 175
     // that this container has been hidden on purpose.
176
-    $("#localVideoContainer").toggleClass("hidden");
176
+    this.$container.toggleClass("hidden");
177 177
 
178 178
     // We still show/hide it as we need to overwrite the style property if we
179 179
     // want our action to take effect. Toggling the display property through
180 180
     // the above css class didn't succeed in overwriting the style.
181 181
     if (visible) {
182
-        $("#localVideoContainer").show();
182
+        this.$container.show();
183 183
     }
184 184
     else {
185
-        $("#localVideoContainer").hide();
185
+        this.$container.hide();
186 186
     }
187 187
 };
188 188
 
@@ -233,8 +233,8 @@ LocalVideo.prototype._buildContextMenu = function () {
233 233
  * @param enable {boolean} true for enable, false for disable
234 234
  */
235 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 240
 export default LocalVideo;

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

@@ -85,6 +85,7 @@ RemoteVideo.prototype.constructor = RemoteVideo;
85 85
 
86 86
 RemoteVideo.prototype.addRemoteVideoContainer = function() {
87 87
     this.container = RemoteVideo.createContainer(this.videoSpanId);
88
+    this.$container = $(this.container);
88 89
 
89 90
     this.initBrowserSpecificProperties();
90 91
 
@@ -409,7 +410,7 @@ RemoteVideo.prototype.isVideoPlayable = function () {
409 410
  * @inheritDoc
410 411
  */
411 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 415
     this.updateConnectionStatusIndicator();
415 416
 
@@ -610,7 +611,7 @@ RemoteVideo.prototype.setDisplayName = function(displayName) {
610 611
  * @param videoElementId the id of local or remote video element.
611 612
  */
612 613
 RemoteVideo.prototype.removeRemoteVideoMenu = function() {
613
-    var menuSpan = $('#' + this.videoSpanId + '> .remotevideomenu');
614
+    var menuSpan = this.$container.find('.remotevideomenu');
614 615
 
615 616
     if (menuSpan.length) {
616 617
         ReactDOM.unmountComponentAtNode(menuSpan.get(0));

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

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

Loading…
取消
儲存