src/js/main.js
author hamidouk
Fri, 23 Dec 2011 12:47:17 +0100
branchpopcorn-port
changeset 523 8dfeaec4724b
parent 520 fe008e95a716
child 531 e7f27746668e
permissions -rw-r--r--
first version of the sparkline widget.
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
  /**
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents: 511
diff changeset
     6
    We define here IriSP, the object under which everything goes.
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents: 511
diff changeset
     7
    We also alias it to __IriSP for backward compatibility
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents: 511
diff changeset
     8
  */
358
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
     9
	var IriSP = {}; 
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
    10
	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
    11
}
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
    12
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    13
IriSP.loadLibs = function( libs, config, metadata_url, callback ) {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    14
    // Localize jQuery variable
358
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
    15
		IriSP.jQuery = null;
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    16
    var $L = $LAB.script(libs.jQuery).script(libs.swfObject)
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    17
                .script(libs.jQueryUI)
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    18
                                   
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    19
    if (config.player.type === "jwplayer") {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    20
      // load our popcorn.js lookalike
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    21
      $L = $L.script(libs.jwplayer);
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    22
    } else {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    23
      // load the real popcorn
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    24
      $L = $L.script(libs.popcorn).script(libs["popcorn.code"]);
501
63e7b66d2a80 fixed typo which made stuff break.
hamidouk
parents: 498
diff changeset
    25
      if (config.player.type === "youtube") {
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    26
        $L = $L.script(libs["popcorn.youtube"]);
501
63e7b66d2a80 fixed typo which made stuff break.
hamidouk
parents: 498
diff changeset
    27
      } 
63e7b66d2a80 fixed typo which made stuff break.
hamidouk
parents: 498
diff changeset
    28
      if (config.player.type === "vimeo")
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    29
        $L = $L.script(libs["popcorn.vimeo"]);
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    30
      
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    31
      /* do nothing for html5 */
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    32
    }       
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
    /* widget specific requirements */
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    35
    for (var idx in config.gui.widgets) {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    36
      if (config.gui.widgets[idx].type === "PolemicWidget") {        
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    37
        $L.script(libs.raphael);
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    38
      }
523
8dfeaec4724b first version of the sparkline widget.
hamidouk
parents: 520
diff changeset
    39
8dfeaec4724b first version of the sparkline widget.
hamidouk
parents: 520
diff changeset
    40
      if (config.gui.widgets[idx].type === "SparklineWidget") {
8dfeaec4724b first version of the sparkline widget.
hamidouk
parents: 520
diff changeset
    41
        $L.script(libs.jquery_sparkline);
8dfeaec4724b first version of the sparkline widget.
hamidouk
parents: 520
diff changeset
    42
      }
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    43
    }
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    44
    
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    45
    // same for modules
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
    for (var idx in config.modules) {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    48
      if (config.modules[idx].type === "PolemicWidget")
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    49
        $L.script(libs.raphaelJs);
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    50
    }
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    51
    */
358
430c1a7a09de got rid of useless LdtPlayer.js -moved the necessary lines of code in main.js
hamidouk
parents:
diff changeset
    52
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    53
    $L.wait(function() {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    54
      IriSP.jQuery = window.jQuery.noConflict( true );
511
81eb8e686456 added underscore.js to the build.
hamidouk
parents: 501
diff changeset
    55
      IriSP._ = window._.noConflict();
81eb8e686456 added underscore.js to the build.
hamidouk
parents: 501
diff changeset
    56
      IriSP.underscore = IriSP._;
498
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    57
      
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    58
      var css_link_jquery = IriSP.jQuery( "<link>", { 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    59
        rel: "stylesheet", 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    60
        type: "text/css", 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    61
        href: libs.cssjQueryUI,
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    62
        'class': "dynamic_css"
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    63
      } );
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    64
      var css_link_custom = IriSP.jQuery( "<link>", { 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    65
        rel: "stylesheet", 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    66
        type: "text/css", 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    67
        href: config.gui.css,
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    68
        'class': "dynamic_css"
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    69
      } );
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
      css_link_jquery.appendTo('head');
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    72
      css_link_custom.appendTo('head');
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
      IriSP.setupDataLoader();
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    75
      IriSP.__dataloader.get(metadata_url, 
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    76
          function(data) {
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    77
            /* 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
    78
               configure the video
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    79
            */
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    80
            IriSP.__jsonMetadata = data;
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    81
            callback.call(window) });
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    82
    });
cf2a0505cadc rewrote the loadLibs function to use LAB.js
hamidouk
parents: 453
diff changeset
    83
};