]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#467] popcorn.position use in subtitle and lowerthird
authorScottDowne <sdowne@learn.senecac.on.ca>
Mon, 11 Apr 2011 14:48:16 +0000 (10:48 -0400)
committerScottDowne <sdowne@learn.senecac.on.ca>
Mon, 11 Apr 2011 14:48:16 +0000 (10:48 -0400)
plugins/lowerthird/popcorn.lowerthird.js
plugins/subtitle/popcorn.subtitle.js

index ee0e47238783810051154881185070ca27e1b820..7b28a0e7a169837142971b332bf874fa6f568046 100644 (file)
    *
    */
 
-  // 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 );
         }
        */
       start: function(event, options){
         options.container.innerHTML = ( options.salutation ? options.salutation + " " : "" ) + options.name + ( options.role ? "<br />" + 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
index adc8630643970dd55c12a8688ef2bddd268fa822..93dfc86a5fd959ebefbb88e964fdf4175ca3e297 100644 (file)
    *
    */
 
-  // 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 ) {
 
 
           // 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 );
         }