/* global $ */ var Private = { addControls: function() { var self = this this.$audioControl = $('
') this.$videoControl = $('') this.$audioControl.on('click', function() { Handlers.audioControlClick.call(self) }) this.$videoControl.on('click', function() { Handlers.videoControlClick.call(self) }) this.$container.append(this.$audioControl) this.$container.append(this.$videoControl) }, cancelClick: function() { this.mouseIsDown = false if (this.hasMoved) { } $(document).trigger(VideoView.events.dragEnd) } } var Handlers = { mousedown: function(event) { this.mouseIsDown = true this.hasMoved = false this.mouseMoveStart = { x: event.pageX, y: event.pageY } this.posStart = { x: parseInt(this.$container.css('left'), '10'), y: parseInt(this.$container.css('top'), '10') } $(document).trigger(VideoView.events.mousedown) }, mouseup: function(event) { $(document).trigger(VideoView.events.mouseup, [this]) var storedTime = this.lastClick var now = Date.now() this.lastClick = now if (now - storedTime < this.config.DOUBLE_CLICK_TOLERANCE) { $(document).trigger(VideoView.events.doubleClick, [this]) } }, mousemove: function(event) { var diffX, diffY, newX, newY if (this.$parent && this.mouseIsDown) { this.manuallyPositioned = true this.hasMoved = true diffX = event.pageX - this.mouseMoveStart.x diffY = this.mouseMoveStart.y - event.pageY newX = this.posStart.x + diffX newY = this.posStart.y - diffY this.$container.css({ top: newY, left: newX }) } }, audioControlClick: function() { if (this.audioStatus) { this.audioOff() } else { this.audioOn() } $(document).trigger(VideoView.events.audioControlClick, [this]) }, videoControlClick: function() { if (this.videoStatus) { this.videoOff() } else { this.videoOn() } $(document).trigger(VideoView.events.videoControlClick, [this]) } } var VideoView = function(video, $parent, id, isMyself, config) { var self = this this.$parent = $parent // mapView this.video = video this.id = id this.config = config this.mouseIsDown = false this.mouseDownOffset = { x: 0, y: 0 } this.lastClick = null this.hasMoved = false this.audioStatus = true this.videoStatus = true this.$container = $('') this.$container.addClass('collaborator-video' + (isMyself ? ' my-video' : '')) this.$container.attr('id', 'container_' + id) var $vidContainer = $('') $vidContainer.addClass('video-cutoff') $vidContainer.append(this.video) this.avatar = config.avatar this.$avatar = $('