Permalink
Browse files

Code cleanup

  • Loading branch information...
1 parent 5e9dbcf commit 8372067129579522cd995e0acdfb8ff15564453a @rwaldron committed Apr 28, 2011
Showing with 15 additions and 8 deletions.
  1. +15 −8 popcorn.zoom.js
View
@@ -2,16 +2,20 @@
* Popcorn.transform; zoom(), rotate()
*
* Copyright 2011, Rick Waldron
- * Licensed under MIT license.
+ * MIT License
*
*/
// Requires Popcorn.js
-(function( global, Popcorn ) {
+(function( global, document, undefined ){
- // Determine CSS3 Transform support
- var doc = global.document,
+ var
+ // Localize global references
+ doc = document,
+ hasOwn = Object.prototype.hasOwnProperty,
+
+ // Setup for CSS3 Transform support
video = doc.createElement("video"),
specProp = "Transform",
prefixes = [ "Webkit", "Moz", "ms", "O", "" ],
@@ -60,18 +64,21 @@
// TODO: wrapper creation should be optional
var parent = media.parentNode,
+ hasFrame = parent.getAttribute("data-popcorn-zoom-frame"),
wrapNode, wrapDims;
- if ( wrap && !parent.getAttribute("data-popcorn-zoom-frame") ) {
+ if ( wrap && !hasFrame ) {
- wrapNode = doc.createElement("div"),
+ wrapNode = doc.createElement("div");
wrapDims = { "Width": true, "Height": true };
wrapNode.setAttribute("data-popcorn-zoom-frame", "true");
pop.listen( "canplaythrough", function() {
for ( var prop in wrapDims ) {
- wrapNode.style[ prop.toLowerCase() ] = media[ "video" + prop ] + "px";
+ if ( hasOwn.call( wrapDims, prop ) ) {
+ wrapNode.style[ prop.toLowerCase() ] = media[ "video" + prop ] + "px";
+ }
}
});
@@ -97,7 +104,7 @@
}
// Remove wrapper if function was called without wrap=true
- if ( !wrap && parent.getAttribute("data-popcorn-zoom-frame") ) {
+ if ( !wrap && hasFrame ) {
parent.parentNode.appendChild( media );
parent.parentNode.removeChild( parent );
}

0 comments on commit 8372067

Please sign in to comment.