From: ScottDowne Date: Mon, 11 Apr 2011 14:48:16 +0000 (-0400) Subject: [#467] popcorn.position use in subtitle and lowerthird X-Git-Tag: v0.5~22^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=7f77690067bf4960828c9215e4beafb1c08e9f6c;p=popcorn-js.git [#467] popcorn.position use in subtitle and lowerthird --- diff --git a/plugins/lowerthird/popcorn.lowerthird.js b/plugins/lowerthird/popcorn.lowerthird.js index ee0e472..7b28a0e 100644 --- a/plugins/lowerthird/popcorn.lowerthird.js +++ b/plugins/lowerthird/popcorn.lowerthird.js @@ -30,22 +30,6 @@ * */ - // just a little tool function - // calculates the top and left position of an element - var offset = function(elem) { - if ( !elem ) { elem = this; } - - var x = elem.offsetLeft; - var y = elem.offsetTop; - - while ( !!( elem = elem.offsetParent ) ) { - x += elem.offsetLeft; - y += elem.offsetTop; - } - - return { left: x, top: y }; - }; - Popcorn.plugin( "lowerthird" , { manifest: { @@ -80,7 +64,7 @@ // the video element must have height and width defined this.container.style.width = this.video.offsetWidth + "px"; - this.container.style.left = offset( this.video ).left + "px"; + this.container.style.left = this.position().left + "px"; this.video.parentNode.appendChild( this.container ); } @@ -103,7 +87,7 @@ */ start: function(event, options){ options.container.innerHTML = ( options.salutation ? options.salutation + " " : "" ) + options.name + ( options.role ? "
" + options.role : "" ); - this.container.style.top = offset( this.video ).top + this.video.offsetHeight - ( 40 + this.container.offsetHeight ) + "px"; + this.container.style.top = this.position().top + this.video.offsetHeight - ( 40 + this.container.offsetHeight ) + "px"; }, /** * @member lowerthird diff --git a/plugins/subtitle/popcorn.subtitle.js b/plugins/subtitle/popcorn.subtitle.js index adc8630..93dfc86 100644 --- a/plugins/subtitle/popcorn.subtitle.js +++ b/plugins/subtitle/popcorn.subtitle.js @@ -68,23 +68,6 @@ * */ - // just a little tool function - // calculates the top and left position of an element - var offset = function(obj) { - var left, top; - left = top = 0; - if (obj.offsetParent) { - do { - left += obj.offsetLeft; - top += obj.offsetTop; - } while ( !!(obj = obj.offsetParent) ); - } - return { - left : left, - top : top - }; - }; - // translates whatever is in options.container into selected language var translate = function( options, text ) { @@ -129,8 +112,8 @@ // the video element must have height and width defined this.container.style.width = this.media.offsetWidth + "px"; - this.container.style.top = offset( this.media ).top + this.media.offsetHeight - 65 + "px"; - this.container.style.left = offset( this.media ).left + "px"; + this.container.style.top = this.position().top + this.media.offsetHeight - 65 + "px"; + this.container.style.left = this.position().left + "px"; document.body.appendChild( this.container ); }