|
1 /* main file */ |
|
2 // Why is it called main ? It only loads the libs ! |
|
3 |
|
4 if ( window.IriSP === undefined && window.__IriSP === undefined ) { |
|
5 /** |
|
6 @class |
|
7 the object under which everything goes. |
|
8 */ |
|
9 IriSP = {}; |
|
10 |
|
11 /** Alias to IriSP for backward compatibility */ |
|
12 __IriSP = IriSP; |
|
13 } |
|
14 |
|
15 /* underscore comes bundled with the player and we need |
|
16 it ASAP, so load it that way |
|
17 */ |
|
18 |
|
19 IriSP._ = window._.noConflict(); |
|
20 IriSP.underscore = IriSP._; |
|
21 |
|
22 IriSP.getLib = function(lib) { |
|
23 return ( |
|
24 IriSP.libFiles.useCdn && typeof IriSP.libFiles.cdn[lib] == "string" |
|
25 ? IriSP.libFiles.cdn[lib] |
|
26 : ( |
|
27 typeof IriSP.libFiles.locations[lib] == "string" |
|
28 ? IriSP.libFiles.locations[lib] |
|
29 : ( |
|
30 typeof IriSP.libFiles.inDefaultDir[lib] == "string" |
|
31 ? IriSP.libFiles.defaultDir + IriSP.libFiles.inDefaultDir[lib] |
|
32 : null |
|
33 ) |
|
34 ) |
|
35 ) |
|
36 } |
|
37 |
|
38 IriSP.loadLibs = function( config, metadata_url, callback ) { |
|
39 // Localize jQuery variable |
|
40 IriSP.jQuery = null; |
|
41 var $L = $LAB.script(IriSP.getLib("jQuery")).script(IriSP.getLib("swfObject")).wait() |
|
42 .script(IriSP.getLib("jQueryUI")); |
|
43 |
|
44 if (config.player.type === "jwplayer" || config.player.type === "allocine") { |
|
45 // load our popcorn.js lookalike |
|
46 $L.script(IriSP.getLib("jwplayer")); |
|
47 } else { |
|
48 // load the real popcorn |
|
49 $L.script(IriSP.getLib("popcorn")).script(IriSP.getLib("popcorn.code")); |
|
50 if (config.player.type === "youtube") { |
|
51 $L.script(IriSP.getLib("popcorn.youtube")); |
|
52 } |
|
53 if (config.player.type === "vimeo") |
|
54 $L.script(IriSP.getLib("popcorn.vimeo")); |
|
55 |
|
56 /* do nothing for html5 */ |
|
57 } |
|
58 |
|
59 /* widget specific requirements */ |
|
60 for (var idx in config.gui.widgets) { |
|
61 if (config.gui.widgets[idx].type === "PolemicWidget" || |
|
62 config.gui.widgets[idx].type === "StackGraphWidget" || |
|
63 config.gui.widgets[idx].type === "SparklineWidget") { |
|
64 $L.script(IriSP.getLib("raphael")); |
|
65 } |
|
66 if (config.gui.widgets[idx].type === "TraceWidget") { |
|
67 $L.script(IriSP.getLib("tracemanager")) |
|
68 } |
|
69 } |
|
70 |
|
71 // same for modules |
|
72 /* |
|
73 for (var idx in config.modules) { |
|
74 if (config.modules[idx].type === "PolemicWidget") |
|
75 $L.script(IriSP.getLib("raphaelJs")); |
|
76 } |
|
77 */ |
|
78 |
|
79 $L.wait(function() { |
|
80 IriSP.jQuery = window.jQuery.noConflict( true ); |
|
81 |
|
82 var css_link_jquery = IriSP.jQuery( "<link>", { |
|
83 rel: "stylesheet", |
|
84 type: "text/css", |
|
85 href: IriSP.getLib("cssjQueryUI"), |
|
86 'class': "dynamic_css" |
|
87 } ); |
|
88 var css_link_custom = IriSP.jQuery( "<link>", { |
|
89 rel: "stylesheet", |
|
90 type: "text/css", |
|
91 href: config.gui.css, |
|
92 'class': "dynamic_css" |
|
93 } ); |
|
94 |
|
95 css_link_jquery.appendTo('head'); |
|
96 css_link_custom.appendTo('head'); |
|
97 |
|
98 IriSP.setupDataLoader(); |
|
99 IriSP.__dataloader.get(metadata_url, |
|
100 function(data) { |
|
101 /* save the data so that we could re-use it to |
|
102 configure the video |
|
103 */ |
|
104 IriSP.__jsonMetadata = data; |
|
105 callback.call(window) }); |
|
106 }); |
|
107 }; |