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