src/js/main.js
author veltr
Fri, 06 Apr 2012 17:10:09 +0200
branchcinecast-traces
changeset 845 c921b7289049
parent 743 69a9969daa41
child 834 573c7ca752e0
permissions -rw-r--r--
Merged back into default
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
520
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents: 511
diff changeset
     3
358
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
     4
if ( window.IriSP === undefined && window.__IriSP === undefined ) { 
520
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents: 511
diff changeset
     5
  /**
531
e7f27746668e beefed up the docs.
hamidouk
parents: 523
diff changeset
     6
    @class
e7f27746668e beefed up the docs.
hamidouk
parents: 523
diff changeset
     7
    the object under which everything goes.        
520
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents: 511
diff changeset
     8
  */
531
e7f27746668e beefed up the docs.
hamidouk
parents: 523
diff changeset
     9
	IriSP = {}; 
e7f27746668e beefed up the docs.
hamidouk
parents: 523
diff changeset
    10
  
e7f27746668e beefed up the docs.
hamidouk
parents: 523
diff changeset
    11
  /** Alias to IriSP for backward compatibility */
e7f27746668e beefed up the docs.
hamidouk
parents: 523
diff changeset
    12
	__IriSP = IriSP;
358
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
    13
}
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
    14
743
69a9969daa41 better defaults - paths are now computed at run-time.
hamidouk
parents: 662
diff changeset
    15
/* underscore comes bundled with the player and we need 
69a9969daa41 better defaults - paths are now computed at run-time.
hamidouk
parents: 662
diff changeset
    16
   it ASAP, so load it that way
69a9969daa41 better defaults - paths are now computed at run-time.
hamidouk
parents: 662
diff changeset
    17
*/
69a9969daa41 better defaults - paths are now computed at run-time.
hamidouk
parents: 662
diff changeset
    18
69a9969daa41 better defaults - paths are now computed at run-time.
hamidouk
parents: 662
diff changeset
    19
IriSP._ = window._.noConflict();
69a9969daa41 better defaults - paths are now computed at run-time.
hamidouk
parents: 662
diff changeset
    20
IriSP.underscore = IriSP._;
69a9969daa41 better defaults - paths are now computed at run-time.
hamidouk
parents: 662
diff changeset
    21
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    22
IriSP.loadLibs = function( libs, config, metadata_url, callback ) {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    23
    // Localize jQuery variable
358
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
    24
		IriSP.jQuery = null;
574
5770c64e2ec6 re-fixed the same race condition.
hamidouk
parents: 572
diff changeset
    25
    var $L = $LAB.script(libs.jQuery).script(libs.swfObject).wait()
5770c64e2ec6 re-fixed the same race condition.
hamidouk
parents: 572
diff changeset
    26
                .script(libs.jQueryUI);
498
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
    if (config.player.type === "jwplayer") {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    29
      // load our popcorn.js lookalike
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    30
      $L = $L.script(libs.jwplayer);
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    31
    } else {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    32
      // load the real popcorn
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    33
      $L = $L.script(libs.popcorn).script(libs["popcorn.code"]);
501
63e7b66d2a80 fixed typo which made stuff break.
hamidouk
parents: 498
diff changeset
    34
      if (config.player.type === "youtube") {
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    35
        $L = $L.script(libs["popcorn.youtube"]);
501
63e7b66d2a80 fixed typo which made stuff break.
hamidouk
parents: 498
diff changeset
    36
      } 
63e7b66d2a80 fixed typo which made stuff break.
hamidouk
parents: 498
diff changeset
    37
      if (config.player.type === "vimeo")
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    38
        $L = $L.script(libs["popcorn.vimeo"]);
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    39
      
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    40
      /* do nothing for html5 */
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
    
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    43
    /* widget specific requirements */
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    44
    for (var idx in config.gui.widgets) {
662
5e10069c5c21 load raphael for the stackGraphWidget.
hamidouk
parents: 574
diff changeset
    45
      if (config.gui.widgets[idx].type === "PolemicWidget" ||
5e10069c5c21 load raphael for the stackGraphWidget.
hamidouk
parents: 574
diff changeset
    46
          config.gui.widgets[idx].type === "StackGraphWidget") {        
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    47
        $L.script(libs.raphael);
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    48
      }
523
8dfeaec4724b first version of the sparkline widget.
hamidouk
parents: 520
diff changeset
    49
8dfeaec4724b first version of the sparkline widget.
hamidouk
parents: 520
diff changeset
    50
      if (config.gui.widgets[idx].type === "SparklineWidget") {
8dfeaec4724b first version of the sparkline widget.
hamidouk
parents: 520
diff changeset
    51
        $L.script(libs.jquery_sparkline);
8dfeaec4724b first version of the sparkline widget.
hamidouk
parents: 520
diff changeset
    52
      }
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    53
    }
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
    // same for modules
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    56
    /*
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    57
    for (var idx in config.modules) {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    58
      if (config.modules[idx].type === "PolemicWidget")
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    59
        $L.script(libs.raphaelJs);
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
    */
358
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
    62
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    63
    $L.wait(function() {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    64
      IriSP.jQuery = window.jQuery.noConflict( true );
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    65
      
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    66
      var css_link_jquery = IriSP.jQuery( "<link>", { 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    67
        rel: "stylesheet", 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    68
        type: "text/css", 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    69
        href: libs.cssjQueryUI,
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    70
        'class': "dynamic_css"
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
      var css_link_custom = IriSP.jQuery( "<link>", { 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    73
        rel: "stylesheet", 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    74
        type: "text/css", 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    75
        href: config.gui.css,
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    76
        'class': "dynamic_css"
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    77
      } );
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    78
      
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    79
      css_link_jquery.appendTo('head');
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    80
      css_link_custom.appendTo('head');
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    81
          
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    82
      IriSP.setupDataLoader();
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    83
      IriSP.__dataloader.get(metadata_url, 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    84
          function(data) {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    85
            /* 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
    86
               configure the video
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    87
            */
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    88
            IriSP.__jsonMetadata = data;
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    89
            callback.call(window) });
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    90
    });
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    91
};