| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 | 
							- /* global $, interfaceConfig, APP */
 - import ConnectionIndicator from "./ConnectionIndicator";
 - import UIUtil from "../util/UIUtil";
 - import UIEvents from "../../../service/UI/UIEvents";
 - import SmallVideo from "./SmallVideo";
 - 
 - var LargeVideo = require("./LargeVideo");
 - var RTCBrowserType = require("../../RTC/RTCBrowserType");
 - 
 - function LocalVideo(VideoLayout, emitter) {
 -     this.videoSpanId = "localVideoContainer";
 -     this.container = $("#localVideoContainer").get(0);
 -     this.bindHoverHandler();
 -     this.VideoLayout = VideoLayout;
 -     this.flipX = true;
 -     this.isLocal = true;
 -     this.emitter = emitter;
 - }
 - 
 - LocalVideo.prototype = Object.create(SmallVideo.prototype);
 - LocalVideo.prototype.constructor = LocalVideo;
 - 
 - /**
 -  * Creates the edit display name button.
 -  *
 -  * @returns {object} the edit button
 -  */
 - function createEditDisplayNameButton() {
 -     var editButton = document.createElement('a');
 -     editButton.className = 'displayname';
 -     UIUtil.setTooltip(editButton,
 -         "videothumbnail.editnickname",
 -         "top");
 -     editButton.innerHTML = '<i class="fa fa-pencil"></i>';
 - 
 -     return editButton;
 - }
 - 
 - /**
 -  * Sets the display name for the given video span id.
 -  */
 - LocalVideo.prototype.setDisplayName = function(displayName, key) {
 -     if (!this.container) {
 -         console.warn(
 -                 "Unable to set displayName - " + this.videoSpanId +
 -                 " does not exist");
 -         return;
 -     }
 - 
 -     var nameSpan = $('#' + this.videoSpanId + '>span.displayname');
 -     var defaultLocalDisplayName = APP.translation.generateTranslationHTML(
 -         interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME);
 - 
 -     var meHTML;
 -     // If we already have a display name for this video.
 -     if (nameSpan.length > 0) {
 -         if (nameSpan.text() !== displayName) {
 -             if (displayName && displayName.length > 0) {
 -                 meHTML = APP.translation.generateTranslationHTML("me");
 -                 $('#localDisplayName').html(displayName + ' (' + meHTML + ')');
 -             } else {
 -                 $('#localDisplayName').html(defaultLocalDisplayName);
 -             }
 -         }
 -     } else {
 -         var editButton = createEditDisplayNameButton();
 - 
 -         nameSpan = document.createElement('span');
 -         nameSpan.className = 'displayname';
 -         $('#' + this.videoSpanId)[0].appendChild(nameSpan);
 - 
 - 
 -         if (displayName && displayName.length > 0) {
 -             meHTML = APP.translation.generateTranslationHTML("me");
 -             nameSpan.innerHTML = displayName + meHTML;
 -         }
 -         else {
 -             nameSpan.innerHTML = defaultLocalDisplayName;
 -         }
 - 
 - 
 -         nameSpan.id = 'localDisplayName';
 -         this.container.appendChild(editButton);
 -         //translates popover of edit button
 -         APP.translation.translateElement($("a.displayname"));
 - 
 -         var editableText = document.createElement('input');
 -         editableText.className = 'displayname';
 -         editableText.type = 'text';
 -         editableText.id = 'editDisplayName';
 - 
 -         if (displayName && displayName.length) {
 -             editableText.value = displayName;
 -         }
 - 
 -         var defaultNickname = APP.translation.translateString(
 -             "defaultNickname", {name: "Jane Pink"});
 -         editableText.setAttribute('style', 'display:none;');
 -         editableText.setAttribute('data-18n',
 -             '[placeholder]defaultNickname');
 -         editableText.setAttribute("data-i18n-options",
 -             JSON.stringify({name: "Jane Pink"}));
 -         editableText.setAttribute("placeholder", defaultNickname);
 - 
 -         this.container.appendChild(editableText);
 - 
 -         var self = this;
 -         $('#localVideoContainer .displayname')
 -             .bind("click", function (e) {
 - 
 -                 var editDisplayName = $('#editDisplayName');
 -                 e.preventDefault();
 -                 e.stopPropagation();
 -                 $('#localDisplayName').hide();
 -                 editDisplayName.show();
 -                 editDisplayName.focus();
 -                 editDisplayName.select();
 - 
 -                 editDisplayName.one("focusout", function (e) {
 -                     self.VideoLayout.inputDisplayNameHandler(this.value);
 -                     $('#editDisplayName').hide();
 -                 });
 - 
 -                 editDisplayName.on('keydown', function (e) {
 -                     if (e.keyCode === 13) {
 -                         e.preventDefault();
 -                         $('#editDisplayName').hide();
 -                         self.VideoLayout.inputDisplayNameHandler(this.value);
 -                     }
 -                 });
 -             });
 -     }
 - };
 - 
 - LocalVideo.prototype.inputDisplayNameHandler = function (name) {
 -     this.emitter.emit(UIEvents.NICKNAME_CHANGED, UIUtil.escapeHtml(name));
 - };
 - 
 - LocalVideo.prototype.createConnectionIndicator = function() {
 -     if(this.connectionIndicator)
 -         return;
 - 
 -     this.connectionIndicator = new ConnectionIndicator(this, null);
 - };
 - 
 - LocalVideo.prototype.changeVideo = function (stream) {
 -     this.stream = stream;
 - 
 -     let localVideoClick = (event) => {
 -         // FIXME: with Temasys plugin event arg is not an event, but
 -         // the clicked object itself, so we have to skip this call
 -         if (event.stopPropagation) {
 -             event.stopPropagation();
 -         }
 -         this.VideoLayout.handleVideoThumbClicked(true, this.id);
 -     };
 - 
 -     let localVideoContainerSelector = $('#localVideoContainer');
 -     localVideoContainerSelector.off('click');
 -     localVideoContainerSelector.on('click', localVideoClick);
 - 
 -     this.flipX = stream.videoType != "screen";
 -     let localVideo = document.createElement('video');
 -     localVideo.id = 'localVideo_' + stream.getId();
 -     if (!RTCBrowserType.isIExplorer()) {
 -         localVideo.autoplay = true;
 -         localVideo.volume = 0; // is it required if audio is separated ?
 -     }
 -     localVideo.oncontextmenu = function () { return false; };
 - 
 -     var localVideoContainer = document.getElementById('localVideoWrapper');
 -     // Put the new video always in front
 -     UIUtil.prependChild(localVideoContainer, localVideo);
 - 
 -     var localVideoSelector = $('#' + localVideo.id);
 - 
 -     // Add click handler to both video and video wrapper elements in case
 -     // there's no video.
 - 
 -     // onclick has to be used with Temasys plugin
 -     localVideo.onclick = localVideoClick;
 - 
 -     if (this.flipX) {
 -         localVideoSelector.addClass("flipVideoX");
 -     }
 - 
 -     // Attach WebRTC stream
 -     stream.attach(localVideoSelector);
 - 
 -     // FIXME handle
 -     return;
 - 
 -     // Add stream ended handler
 -     APP.RTC.addMediaStreamInactiveHandler(
 -         stream.getOriginalStream(), function () {
 -         // We have to re-select after attach when Temasys plugin is used,
 -         // because <video> element is replaced with <object>
 -         localVideo = $('#' + localVideo.id)[0];
 -         localVideoContainer.removeChild(localVideo);
 -         self.VideoLayout.updateRemovedVideo(self.id);
 -     });
 - };
 - 
 - LocalVideo.prototype.joined = function (id) {
 -     this.id = id;
 - };
 - 
 - export default LocalVideo;
 
 
  |