equal
deleted
inserted
replaced
1 /* init.js - initialization and configuration of Popcorn and the widgets |
1 /* init.js - initialization and configuration of Popcorn and the widgets |
2 exemple json configuration: |
|
3 */ |
2 */ |
|
3 |
|
4 if (typeof window.IriSP === "undefined") { |
|
5 IriSP = {}; |
|
6 } |
4 |
7 |
5 /* The Metadataplayer Object, single point of entry, replaces IriSP.init_player */ |
8 /* The Metadataplayer Object, single point of entry, replaces IriSP.init_player */ |
6 |
9 |
7 IriSP.Metadataplayer = function(config, video_metadata) { |
10 IriSP.Metadataplayer = function(config, video_metadata) { |
8 for (var key in IriSP.guiDefaults) { |
11 for (var key in IriSP.guiDefaults) { |
9 if (IriSP.guiDefaults.hasOwnProperty(key) && !config.gui.hasOwnProperty('key')) { |
12 if (IriSP.guiDefaults.hasOwnProperty(key) && !config.gui.hasOwnProperty(key)) { |
10 config.gui[key] = IriSP.guiDefaults[key] |
13 config.gui[key] = IriSP.guiDefaults[key] |
11 } |
14 } |
12 } |
15 } |
13 var _container = document.getElementById(config.gui.container); |
16 var _container = document.getElementById(config.gui.container); |
14 _container.innerHTML = '<div class="Ldt-Loader">Loading... Chargement...</div>'; |
17 _container.innerHTML = '<h3 class="Ldt-Loader">Loading... Chargement...</h3>'; |
15 this.video_metadata = video_metadata; |
18 this.video_metadata = video_metadata; |
16 this.sourceManager = new IriSP.Model.Directory(); |
19 this.sourceManager = new IriSP.Model.Directory(); |
17 this.config = config; |
20 this.config = config; |
18 this.loadLibs(); |
21 this.loadLibs(); |
19 } |
22 } |
21 IriSP.Metadataplayer.prototype.toString = function() { |
24 IriSP.Metadataplayer.prototype.toString = function() { |
22 return 'A Metadataplayer in DIV #' + this.config.gui.container; |
25 return 'A Metadataplayer in DIV #' + this.config.gui.container; |
23 } |
26 } |
24 |
27 |
25 IriSP.Metadataplayer.prototype.loadLibs = function() { |
28 IriSP.Metadataplayer.prototype.loadLibs = function() { |
26 // Localize jQuery variable |
29 |
27 IriSP.jQuery = null; |
|
28 var $L = $LAB.script(IriSP.getLib("underscore")).script(IriSP.getLib("Mustache")).script(IriSP.getLib("jQuery")).script(IriSP.getLib("swfObject")).wait().script(IriSP.getLib("jQueryUI")); |
30 var $L = $LAB.script(IriSP.getLib("underscore")).script(IriSP.getLib("Mustache")).script(IriSP.getLib("jQuery")).script(IriSP.getLib("swfObject")).wait().script(IriSP.getLib("jQueryUI")); |
29 |
31 |
30 if(this.config.player.type === "jwplayer" || this.config.player.type === "allocine" || this.config.player.type === "dailymotion") { |
32 if(this.config.player.type === "jwplayer" || this.config.player.type === "allocine" || this.config.player.type === "dailymotion") { |
31 // load our popcorn.js lookalike |
33 // load our popcorn.js lookalike |
32 $L.script(IriSP.getLib("jwplayer")); |
34 $L.script(IriSP.getLib("jwplayer")); |
42 } |
44 } |
43 } |
45 } |
44 |
46 |
45 /* widget specific requirements */ |
47 /* widget specific requirements */ |
46 for(var _i = 0; _i < this.config.gui.widgets.length; _i++) { |
48 for(var _i = 0; _i < this.config.gui.widgets.length; _i++) { |
47 if(this.config.gui.widgets[_i].type === "Sparkline" || this.config.gui.widgets[_i].type === "Arrow") { |
49 var _t = this.config.gui.widgets[_i].type; |
48 $L.script(IriSP.getLib("raphael")); |
50 if (typeof IriSP.widgetsRequirements[_t] !== "undefined" && typeof IriSP.widgetsRequirements[_t].requires !== "undefined") { |
49 } |
51 $L.script(IriSP.getLib(IriSP.widgetsRequirements[_t].requires)); |
50 if(this.config.gui.widgets[_i].type === "TraceWidget") { |
|
51 $L.script(IriSP.getLib("tracemanager")) |
|
52 } |
52 } |
53 } |
53 } |
54 |
54 |
55 var _this = this; |
55 var _this = this; |
56 |
56 |
57 $L.wait(function() { |
57 $L.wait(function() { |
58 IriSP.jQuery = window.jQuery.noConflict(true); |
58 IriSP.jQuery = window.jQuery.noConflict(); |
59 IriSP._ = window._.noConflict(); |
59 IriSP._ = window._.noConflict(); |
60 |
60 |
61 IriSP.loadCss(IriSP.getLib("cssjQueryUI")) |
61 IriSP.loadCss(IriSP.getLib("cssjQueryUI")) |
62 IriSP.loadCss(_this.config.gui.css); |
62 IriSP.loadCss(_this.config.gui.css); |
63 |
63 |
65 |
65 |
66 }); |
66 }); |
67 } |
67 } |
68 |
68 |
69 IriSP.Metadataplayer.prototype.onLibsLoaded = function() { |
69 IriSP.Metadataplayer.prototype.onLibsLoaded = function() { |
70 console.log('OnLibsLoaded'); |
|
71 this.videoData = this.loadMetadata(this.video_metadata); |
70 this.videoData = this.loadMetadata(this.video_metadata); |
72 this.$ = IriSP.jQuery('#' + this.config.gui.container); |
71 this.$ = IriSP.jQuery('#' + this.config.gui.container); |
73 this.$.css({ |
72 this.$.css({ |
74 "width": this.config.gui.width, |
73 "width": this.config.gui.width, |
75 "clear": "both" |
74 "clear": "both" |
133 if (typeof IriSP.Widgets[_widgetConfig.type] !== "undefined") { |
132 if (typeof IriSP.Widgets[_widgetConfig.type] !== "undefined") { |
134 IriSP._.defer(function() { |
133 IriSP._.defer(function() { |
135 _callback(new IriSP.Widgets[_widgetConfig.type](_this, _widgetConfig)); |
134 _callback(new IriSP.Widgets[_widgetConfig.type](_this, _widgetConfig)); |
136 }); |
135 }); |
137 } else { |
136 } else { |
138 /* Loading Widget CSS */ |
137 /* Loading Widget CSS */ |
139 IriSP.loadCss(IriSP.widgetsDir + '/' + _widgetConfig.type + '.css'); |
138 if (typeof IriSP.widgetsRequirements[_widgetConfig.type] === "undefined" || typeof IriSP.widgetsRequirements[_widgetConfig.type].noCss === "undefined" || !IriSP.widgetsRequirements[_widgetConfig.type].noCss) { |
|
139 IriSP.loadCss(IriSP.widgetsDir + '/' + _widgetConfig.type + '.css'); |
|
140 } |
140 /* Loading Widget JS */ |
141 /* Loading Widget JS */ |
141 $LAB.script(IriSP.widgetsDir + '/' + _widgetConfig.type + '.js').wait(function() { |
142 $LAB.script(IriSP.widgetsDir + '/' + _widgetConfig.type + '.js').wait(function() { |
142 _callback(new IriSP.Widgets[_widgetConfig.type](_this, _widgetConfig)); |
143 _callback(new IriSP.Widgets[_widgetConfig.type](_this, _widgetConfig)); |
143 }); |
144 }); |
144 } |
145 } |