# HG changeset patch
# User hamidouk
# Date 1324480001 -3600
# Node ID b1e442d9a1bc2cd7fda271e5880b9739f99895ff
# Parent cb88c0c8ddfa2e0ba9fb34ae9e1c0f18034e710f# Parent 02daece5dfda3bdb7f5ab6fbdd3f5d9c843851fe
Merge with lab-port
diff -r cb88c0c8ddfa -r b1e442d9a1bc sbin/build/client.xml
--- a/sbin/build/client.xml Wed Dec 21 10:56:09 2011 +0100
+++ b/sbin/build/client.xml Wed Dec 21 16:06:41 2011 +0100
@@ -50,7 +50,7 @@
+ files="lab.js mustache.js"/>
diff -r cb88c0c8ddfa -r b1e442d9a1bc src/js/init.js
--- a/src/js/init.js Wed Dec 21 10:56:09 2011 +0100
+++ b/src/js/init.js Wed Dec 21 16:06:41 2011 +0100
@@ -30,7 +30,7 @@
if (options.hasOwnProperty("height"))
IriSP.jQuery("#" + containerDiv).css("height", options.height);
- pop = Popcorn("#" + tmpId).mediafragment({start : 0});
+ pop = Popcorn("#" + tmpId);
break;
case "jwplayer":
@@ -69,7 +69,7 @@
// Popcorn.youtube wants us to specify the size of the player in the style attribute of its container div.
IriSP.jQuery("#" + containerDiv).attr("style", str);
- pop = Popcorn.youtube("#" + containerDiv, opts.video, opts).mediafragment({start : 0});
+ pop = Popcorn.youtube("#" + containerDiv, opts.video, opts);
break;
default:
diff -r cb88c0c8ddfa -r b1e442d9a1bc src/js/layout.js
--- a/src/js/layout.js Wed Dec 21 10:56:09 2011 +0100
+++ b/src/js/layout.js Wed Dec 21 16:06:41 2011 +0100
@@ -51,8 +51,8 @@
if (typeof(stem) === "undefined")
stem = "";
- var newDiv = Popcorn.guid(this._div + "_widget_" + stem + "_");
- var spacerDiv = Popcorn.guid("LdtPlayer_spacer_");
+ var newDiv = IriSP.guid(this._div + "_widget_" + stem + "_");
+ var spacerDiv = IriSP.guid("LdtPlayer_spacer_");
this._widgets.push(newDiv);
var divTempl = "
0) {
+ for (var i=0; i=0;) {
+ val = queue.shift();
+ $L = $L[val.type].apply(null,val.args);
+ }
+ return $L;
+ },
+
+ // rollback `[global].$LAB` to what it was before this file was loaded, the return this current instance of $LAB
+ noConflict:function(){
+ global.$LAB = _$LAB;
+ return instanceAPI;
+ },
+
+ // create another clean instance of $LAB
+ sandbox:function(){
+ return create_sandbox();
+ }
+ };
+
+ return instanceAPI;
+ }
+
+ // create the main instance of $LAB
+ global.$LAB = create_sandbox();
+
+
+ /* The following "hack" was suggested by Andrea Giammarchi and adapted from: http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html
+ NOTE: this hack only operates in FF and then only in versions where document.readyState is not present (FF < 3.6?).
+
+ The hack essentially "patches" the **page** that LABjs is loaded onto so that it has a proper conforming document.readyState, so that if a script which does
+ proper and safe dom-ready detection is loaded onto a page, after dom-ready has passed, it will still be able to detect this state, by inspecting the now hacked
+ document.readyState property. The loaded script in question can then immediately trigger any queued code executions that were waiting for the DOM to be ready.
+ For instance, jQuery 1.4+ has been patched to take advantage of document.readyState, which is enabled by this hack. But 1.3.2 and before are **not** safe or
+ fixed by this hack, and should therefore **not** be lazy-loaded by script loader tools such as LABjs.
+ */
+ (function(addEvent,domLoaded,handler){
+ if (document.readyState == null && document[addEvent]){
+ document.readyState = "loading";
+ document[addEvent](domLoaded,handler = function(){
+ document.removeEventListener(domLoaded,handler,false);
+ document.readyState = "complete";
+ },false);
+ }
+ })("addEventListener","DOMContentLoaded");
+
+})(this);
\ No newline at end of file
diff -r cb88c0c8ddfa -r b1e442d9a1bc src/js/libs/popcorn.mediafragment.js
--- a/src/js/libs/popcorn.mediafragment.js Wed Dec 21 10:56:09 2011 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-// PLUGIN: Mediafragment
-
-(function ( Popcorn ) {
-
- /**
- * Mediafragment popcorn plug-in
- * Adds (limited) support for mediafragment requests
- * to a popcorn video.
- * @param {Object} options
- *
- **/
- Popcorn.plugin( "mediafragment" , {
-
- manifest: {
- about: {
- name: "Popcorn mediafragment plugin",
- version: "0.1",
- author: "Karim Hamidou",
- website: "http://neyret.fr/~karim"
- },
- options: {
- }
- },
-
- _setup: function( options ) {
- var advanceTime = function() {
- var url = window.location.href;
-
- if ( url.split( "#" )[ 1 ] != null ) {
- pageoffset = url.split( "#" )[1];
-
- if ( pageoffset.substring( 2 ) != null ) {
- var offsettime = pageoffset.substring( 2 );
- this.currentTime( parseFloat( offsettime ) );
- }
- }
- }
-
- var updateTime = function() {
- var history = window.history;
- if ( !history.pushState ) {
- return false;
- }
-
- splitArr = window.location.href.split( "#" )
- history.replaceState( {}, "", splitArr[0] + "#t=" + this.currentTime().toFixed( 2 ) );
- };
-
- this.listen( "loadedmetadata", advanceTime );
- this.listen( "pause", updateTime );
- this.listen( "seeked", updateTime );
- },
-
- _teardown: function( options ) {
- // FIXME: anything to implement here ?
- }
- });
-})( Popcorn );
diff -r cb88c0c8ddfa -r b1e442d9a1bc src/js/main.js
--- a/src/js/main.js Wed Dec 21 10:56:09 2011 +0100
+++ b/src/js/main.js Wed Dec 21 16:06:41 2011 +0100
@@ -5,127 +5,68 @@
var __IriSP = IriSP; /* for backward compatibility */
}
-/* crap code will be the first against the wall when the
- revolution comes */
-IriSP.loadLibs = function( libs, customCssPath, metadata_url, callback ) {
- // Localize jQuery variable
+IriSP.loadLibs = function( libs, config, metadata_url, callback ) {
+ // Localize jQuery variable
IriSP.jQuery = null;
-
- /* FIXME : to refactor using popcorn.getscript ? */
- /******** Load jQuery if not present *********/
- if ( window.jQuery === undefined || window.jQuery.fn.jquery !== '1.4.2' ) {
-
- var script_tag = document.createElement( 'script' );
- script_tag.setAttribute( "type", "text/javascript" );
- script_tag.setAttribute( "src", libs.jQuery );
-
- script_tag.onload = scriptLibHandler;
- script_tag.onreadystatechange = function () { // Same thing but for IE
- if ( this.readyState == 'complete' || this.readyState == 'loaded' ) {
- scriptLibHandler();
- }
- };
-
- // Try to find the head, otherwise default to the documentElement
- ( document.getElementsByTagName("head")[0] || document.documentElement ).appendChild( script_tag );
- } else {
- // The jQuery version on the window is the one we want to use
- IriSP.jQuery = window.jQuery;
- scriptLibHandler();
- }
+ var $L = $LAB.script(libs.jQuery).script(libs.swfObject)
+ .script(libs.jQueryUI)
+
+ if (config.player.type === "jwplayer") {
+ // load our popcorn.js lookalike
+ $L = $L.script(libs.jwplayer);
+ } else {
+ // load the real popcorn
+ $L = $L.script(libs.popcorn).script(libs["popcorn.code"]);
+ if (config.player.type === "youtube") {
+ $L = $L.script(libs["popcorn.youtube"]);
+ }
+ if (config.player.type === "vimeo")
+ $L = $L.script(libs["popcorn.vimeo"]);
+
+ /* do nothing for html5 */
+ }
+
+ /* widget specific requirements */
+ for (var idx in config.gui.widgets) {
+ if (config.gui.widgets[idx].type === "PolemicWidget") {
+ $L.script(libs.raphael);
+ }
+ }
+
+ // same for modules
+ /*
+ for (var idx in config.modules) {
+ if (config.modules[idx].type === "PolemicWidget")
+ $L.script(libs.raphaelJs);
+ }
+ */
- /******** Called once jQuery has loaded ******/
- function scriptLibHandler() {
-
- var script_jqUi_tooltip = document.createElement( 'script' );
- script_jqUi_tooltip.setAttribute( "type", "text/javascript" );
- script_jqUi_tooltip.setAttribute( "src", libs.jQueryToolTip );
- script_jqUi_tooltip.onload = scriptLoadHandler;
- script_jqUi_tooltip.onreadystatechange = function () { // Same thing but for IE
- if ( this.readyState == 'complete' || this.readyState == 'loaded' ) {
- scriptLoadHandler( "jquery.tools.min.js loded" );
- }
- };
-
- var script_swfObj = document.createElement('script');
- script_swfObj.setAttribute( "type","text/javascript" );
- script_swfObj.setAttribute( "src",libs.swfObject );
- script_swfObj.onload = scriptLoadHandler;
- script_swfObj.onreadystatechange = function () { // Same thing but for IE
- if ( this.readyState == 'complete' || this.readyState == 'loaded' ) {
- scriptLoadHandler( "swfobject.js loded" );
- }
- };
-
- var script_jqUi = document.createElement( 'script' );
- script_jqUi.setAttribute( "type","text/javascript" );
- script_jqUi.setAttribute( "src",libs.jQueryUI );
- script_jqUi.onload = scriptLoadHandler;
- script_jqUi.onreadystatechange = function () { // Same thing but for IE
- if ( this.readyState == 'complete' || this.readyState == 'loaded' ) {
- scriptLoadHandler( "jquery-ui.min.js loded" );
- }
- };
-
-
- ( document.getElementsByTagName("head")[0] || document.documentElement ).appendChild( script_jqUi_tooltip);
- ( document.getElementsByTagName("head")[0] || document.documentElement ).appendChild( script_jqUi );
- ( document.getElementsByTagName("head")[0] || document.documentElement ).appendChild( script_swfObj );
-
-
- };
-
- /******** Called once all lib are loaded ******/
- var loadLib = 0;
- /* FIXME : ugly */
- function scriptLoadHandler( Mylib ) {
- //alert(Mylib);
- loadLib +=1;
- if( loadLib===3 ) {
- main();
- }
- };
-
- /******** Our main function ********/
- function main() {
-
-
- // Make our own IriSP.jQuery and restore window.jQuery if there was one.
- IriSP.jQuery = window.jQuery.noConflict( true );
- // Call our Jquery
- IriSP.jQuery( document ).ready( function($) {
-
- /******* Load CSS *******/
- var css_link_jquery = IriSP.jQuery( "", {
- rel: "stylesheet",
- type: "text/css",
- href: libs.cssjQueryUI,
- 'class': "dynamic_css"
- } );
- var css_link_custom = IriSP.jQuery( "", {
- rel: "stylesheet",
- type: "text/css",
- href: customCssPath,
- 'class': "dynamic_css"
- } );
-
- css_link_jquery.appendTo( 'head' );
- css_link_custom.appendTo( 'head' );
-
- // to see dynamicly loaded css on IE
- if ( $.browser.msie ) {
- $( '.dynamic_css' ).clone().appendTo( 'head' );
- }
-
- IriSP.setupDataLoader();
- IriSP.__dataloader.get(metadata_url,
- function(data) {
- /* save the data so that we could re-use it to
- configure the video
- */
- IriSP.__jsonMetadata = data;
- callback.call(window) });
- });
- }
-};
-
+ $L.wait(function() {
+ IriSP.jQuery = window.jQuery.noConflict( true );
+
+ var css_link_jquery = IriSP.jQuery( "", {
+ rel: "stylesheet",
+ type: "text/css",
+ href: libs.cssjQueryUI,
+ 'class': "dynamic_css"
+ } );
+ var css_link_custom = IriSP.jQuery( "", {
+ rel: "stylesheet",
+ type: "text/css",
+ href: config.gui.css,
+ 'class': "dynamic_css"
+ } );
+
+ css_link_jquery.appendTo('head');
+ css_link_custom.appendTo('head');
+
+ IriSP.setupDataLoader();
+ IriSP.__dataloader.get(metadata_url,
+ function(data) {
+ /* save the data so that we could re-use it to
+ configure the video
+ */
+ IriSP.__jsonMetadata = data;
+ callback.call(window) });
+ });
+};
\ No newline at end of file
diff -r cb88c0c8ddfa -r b1e442d9a1bc src/js/utils.js
--- a/src/js/utils.js Wed Dec 21 10:56:09 2011 +0100
+++ b/src/js/utils.js Wed Dec 21 16:06:41 2011 +0100
@@ -122,7 +122,11 @@
replace(/\)/g, '%29').replace(/\*/g, '%2A');
}
-
+IriSP.__guidCounter = 0;
+IriSP.guid = function(prefix) {
+ IriSP.__guidCounter += 1;
+ return prefix + IriSP.__guidCounter;
+};
/* for ie compatibility
if (Object.prototype.__defineGetter__&&!Object.defineProperty) {
Object.defineProperty=function(obj,prop,desc) {
diff -r cb88c0c8ddfa -r b1e442d9a1bc test/integration/jwplayer-video.htm
--- a/test/integration/jwplayer-video.htm Wed Dec 21 10:56:09 2011 +0100
+++ b/test/integration/jwplayer-video.htm Wed Dec 21 16:06:41 2011 +0100
@@ -16,15 +16,11 @@
-
-
-
diff -r cb88c0c8ddfa -r b1e442d9a1bc test/integration/polemic-youtube.htm
--- a/test/integration/polemic-youtube.htm Wed Dec 21 10:56:09 2011 +0100
+++ b/test/integration/polemic-youtube.htm Wed Dec 21 16:06:41 2011 +0100
@@ -16,16 +16,11 @@
-
-
-
-
diff -r cb88c0c8ddfa -r b1e442d9a1bc test/integration/polemic.htm
--- a/test/integration/polemic.htm Wed Dec 21 10:56:09 2011 +0100
+++ b/test/integration/polemic.htm Wed Dec 21 16:06:41 2011 +0100
@@ -15,17 +15,12 @@
-
-
-
-
-
+
diff -r cb88c0c8ddfa -r b1e442d9a1bc test/integration/radio.htm
--- a/test/integration/radio.htm Wed Dec 21 10:56:09 2011 +0100
+++ b/test/integration/radio.htm Wed Dec 21 16:06:41 2011 +0100
@@ -16,16 +16,11 @@
-
-
-
-
diff -r cb88c0c8ddfa -r b1e442d9a1bc test/integration/youtube.htm
--- a/test/integration/youtube.htm Wed Dec 21 10:56:09 2011 +0100
+++ b/test/integration/youtube.htm Wed Dec 21 16:06:41 2011 +0100
@@ -16,13 +16,10 @@
-
-
-
+
diff -r cb88c0c8ddfa -r b1e442d9a1bc unittests/index.html
--- a/unittests/index.html Wed Dec 21 10:56:09 2011 +0100
+++ b/unittests/index.html Wed Dec 21 16:06:41 2011 +0100
@@ -13,6 +13,10 @@
+
+
+
+