isArray: Array.isArray || function( array ) {
return toString.call( array ) === "[object Array]";
},
- nop: function () {}
+
+ nop: function () {},
+
+ position: function( elem ) {
+
+ var clientRect = elem.getBoundingClientRect(),
+ bounds = {},
+ doc = elem.ownerDocument,
+ docElem = document.documentElement,
+ body = document.body,
+ clientTop, clientLeft, scrollTop, scrollLeft, top, left;
+
+ // Determine correct clientTop/Left
+ clientTop = docElem.clientTop || body.clientTop || 0;
+ clientLeft = docElem.clientLeft || body.clientLeft || 0;
+
+ // Determine correct scrollTop/Left
+ scrollTop = ( global.pageYOffset && docElem.scrollTop || body.scrollTop );
+ scrollLeft = ( global.pageXOffset && docElem.scrollLeft || body.scrollLeft );
+
+ // Temp top/left
+ top = Math.ceil( clientRect.top + scrollTop - clientTop );
+ left = Math.ceil( clientRect.left + scrollLeft - clientLeft );
+
+ for ( var p in clientRect ) {
+ bounds[ p ] = Math.round( clientRect[ p ] );
+ }
+
+ return Popcorn.extend({}, bounds, { top: top, left: left });
+ }
});
// Memoized GUID Counter
return this;
},
-
- // Popcorn Object Element Utils
position: function() {
- var media = this.media,
- clientRect = media.getBoundingClientRect(),
- bounds = {},
- doc = media.ownerDocument,
- docElem = document.documentElement,
- body = document.body,
- clientTop, clientLeft, scrollTop, scrollLeft, top, left;
-
- // Determine correct clientTop/Left
- clientTop = docElem.clientTop || body.clientTop || 0;
- clientLeft = docElem.clientLeft || body.clientLeft || 0;
-
- // Determine correct scrollTop/Left
- scrollTop = ( global.pageYOffset && docElem.scrollTop || body.scrollTop );
- scrollLeft = ( global.pageXOffset && docElem.scrollLeft || body.scrollLeft );
-
- // Temp top/left
- top = Math.ceil( clientRect.top + scrollTop - clientTop );
- left = Math.ceil( clientRect.left + scrollLeft - clientLeft );
-
- for ( var p in clientRect ) {
- bounds[ p ] = Math.round( clientRect[ p ] );
- }
-
- return Popcorn.extend({}, bounds, { top: top, left: left });
+ return Popcorn.position( this.media );
}
});
return plugin;
};
- // Popcorn Plugin Inheritance Helper Methods
- // Internal use only
+ // Popcorn Plugin Inheritance Helper Methods
+ // Internal use only
Popcorn.plugin.getDefinition = function( name ) {
var registry = Popcorn.registryByName;
Popcorn.error( "Cannot inherit from "+ name +"; Object does not exist" );
};
- // Internal use only
+ // Internal use only
Popcorn.plugin.delegate = function( instance, name, plugins ) {
return function() {
};
};
- // Plugin inheritance
+ // Plugin inheritance
Popcorn.plugin.inherit = function( name, parents, definition, manifest ) {
return pluginFn;
};
- // Augment Popcorn;
+ // Augment Popcorn;
Popcorn.inherit = Popcorn.plugin.inherit;
// stores parsers keyed on filetype
equals( typeof Popcorn.sizeOf, "function" , "Popcorn.sizeOf is a provided utility function");
equals( typeof Popcorn.nop, "function" , "Popcorn.nop is a provided utility function");
equals( typeof Popcorn.addTrackEvent, "function" , "Popcorn.addTrackEvent is a provided utility function");
-
-
-
-
+ equals( typeof Popcorn.position, "function" , "Popcorn.position is a provided utility function");
});
test("Standard Time Strings" , function () {
module("Popcorn Position");
test("position", function () {
- expect(25);
-
+ expect(25);
+
var $absolute = $(".absolute"),
$relative = $(".relative"),
$fixed = $(".fixed"),
$static = $(".static"),
tests;
- $("#position-tests").show();
+ $("#position-tests").show();
// console.log( $absolute );
// console.log( $fixed );
// console.log( $relative );
ok( false, e );
}
- $("#position-tests").hide();
+ $("#position-tests").hide();
});
test("position called from plugin", function () {
} catch (e) {};
- // Trigger follow-up tests to run in iframes
- (function( $ ) {
+ // Trigger follow-up tests to run in iframes
+ (function( $ ) {
- $("iframe[data-src]").attr( "src", function() {
- return $(this).data("src");
- });
-
- })( jQuery );
+ $("iframe[data-src]").attr( "src", function() {
+ return $(this).data("src");
+ });
+
+ })( jQuery );
});