src/js/main.js
author hamidouk
Wed, 21 Dec 2011 15:35:42 +0100
branchlab-port
changeset 501 63e7b66d2a80
parent 498 cf2a0505cadc
child 511 81eb8e686456
permissions -rw-r--r--
fixed typo which made stuff break.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
358
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
     1
/* main file */
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
     2
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
     3
if ( window.IriSP === undefined && window.__IriSP === undefined ) { 
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
     4
	var IriSP = {}; 
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
     5
	var __IriSP = IriSP; /* for backward compatibility */
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
     6
}
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
     7
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
     8
IriSP.loadLibs = function( libs, config, metadata_url, callback ) {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
     9
    // Localize jQuery variable
358
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
    10
		IriSP.jQuery = null;
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    11
    var $L = $LAB.script(libs.jQuery).script(libs.swfObject)
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    12
                .script(libs.jQueryUI)
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    13
                                   
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    14
    if (config.player.type === "jwplayer") {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    15
      // load our popcorn.js lookalike
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    16
      $L = $L.script(libs.jwplayer);
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    17
    } else {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    18
      // load the real popcorn
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    19
      $L = $L.script(libs.popcorn).script(libs["popcorn.code"]);
501
63e7b66d2a80 fixed typo which made stuff break.
hamidouk
parents: 498
diff changeset
    20
      if (config.player.type === "youtube") {
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    21
        $L = $L.script(libs["popcorn.youtube"]);
501
63e7b66d2a80 fixed typo which made stuff break.
hamidouk
parents: 498
diff changeset
    22
      } 
63e7b66d2a80 fixed typo which made stuff break.
hamidouk
parents: 498
diff changeset
    23
      if (config.player.type === "vimeo")
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    24
        $L = $L.script(libs["popcorn.vimeo"]);
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    25
      
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    26
      /* do nothing for html5 */
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    27
    }       
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    28
    
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    29
    /* widget specific requirements */
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    30
    for (var idx in config.gui.widgets) {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    31
      if (config.gui.widgets[idx].type === "PolemicWidget") {        
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    32
        $L.script(libs.raphael);
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    33
      }
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    34
    }
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    35
    
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    36
    // same for modules
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    37
    /*
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    38
    for (var idx in config.modules) {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    39
      if (config.modules[idx].type === "PolemicWidget")
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    40
        $L.script(libs.raphaelJs);
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    41
    }
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    42
    */
358
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
    43
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    44
    $L.wait(function() {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    45
      IriSP.jQuery = window.jQuery.noConflict( true );
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    46
      
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    47
      var css_link_jquery = IriSP.jQuery( "<link>", { 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    48
        rel: "stylesheet", 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    49
        type: "text/css", 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    50
        href: libs.cssjQueryUI,
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    51
        'class': "dynamic_css"
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    52
      } );
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    53
      var css_link_custom = IriSP.jQuery( "<link>", { 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    54
        rel: "stylesheet", 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    55
        type: "text/css", 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    56
        href: config.gui.css,
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    57
        'class': "dynamic_css"
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    58
      } );
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    59
      
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    60
      css_link_jquery.appendTo('head');
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    61
      css_link_custom.appendTo('head');
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    62
          
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    63
      IriSP.setupDataLoader();
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    64
      IriSP.__dataloader.get(metadata_url, 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    65
          function(data) {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    66
            /* save the data so that we could re-use it to
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    67
               configure the video
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    68
            */
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    69
            IriSP.__jsonMetadata = data;
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    70
            callback.call(window) });
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    71
    });
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    72
};