src/js/main.js
author hamidouk
Thu, 22 Dec 2011 16:06:45 +0100
branchcalage-segmentsWidget
changeset 511 81eb8e686456
parent 501 63e7b66d2a80
child 520 fe008e95a716
permissions -rw-r--r--
added underscore.js to the build.
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 );
511
81eb8e686456 added underscore.js to the build.
hamidouk
parents: 501
diff changeset
    46
      IriSP._ = window._.noConflict();
81eb8e686456 added underscore.js to the build.
hamidouk
parents: 501
diff changeset
    47
      IriSP.underscore = IriSP._;
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    48
      
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    49
      var css_link_jquery = IriSP.jQuery( "<link>", { 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    50
        rel: "stylesheet", 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    51
        type: "text/css", 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    52
        href: libs.cssjQueryUI,
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    53
        'class': "dynamic_css"
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    54
      } );
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    55
      var css_link_custom = IriSP.jQuery( "<link>", { 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    56
        rel: "stylesheet", 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    57
        type: "text/css", 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    58
        href: config.gui.css,
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    59
        'class': "dynamic_css"
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    60
      } );
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    61
      
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    62
      css_link_jquery.appendTo('head');
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    63
      css_link_custom.appendTo('head');
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    64
          
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    65
      IriSP.setupDataLoader();
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    66
      IriSP.__dataloader.get(metadata_url, 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    67
          function(data) {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    68
            /* 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
    69
               configure the video
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    70
            */
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    71
            IriSP.__jsonMetadata = data;
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    72
            callback.call(window) });
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    73
    });
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    74
};