| author | hamidouk |
| Tue, 25 Oct 2011 14:33:18 +0200 | |
| branch | popcorn-port |
| changeset 141 | becd5f52fa24 |
| parent 136 | 9c2e80e4f1b5 |
| child 158 | 1813e6e4f0d6 |
| permissions | -rw-r--r-- |
| 123 | 1 |
/* init.js - initialization and configuration of Popcorn and the widgets |
2 |
exemple json configuration: |
|
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
3 |
|
| 123 | 4 |
*/ |
5 |
||
6 |
IriSP.configurePopcorn = function (options) { |
|
7 |
var pop; |
|
8 |
|
|
| 127 | 9 |
switch(options.type) { |
| 123 | 10 |
/* |
11 |
todo : dynamically create the div/video tag which |
|
12 |
will contain the video. |
|
13 |
*/ |
|
14 |
case "html5": |
|
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
15 |
pop = Popcorn("#" + options.container); |
| 123 | 16 |
break; |
| 127 | 17 |
|
18 |
case "jwplayer": |
|
19 |
var opts = IriSP.jQuery.extend({}, options); |
|
20 |
delete opts.container; |
|
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
21 |
pop = Popcorn.jwplayer("#" + options.container, "", opts); |
| 127 | 22 |
break; |
23 |
|
|
24 |
default: |
|
25 |
pop = undefined; |
|
| 123 | 26 |
}; |
27 |
|
|
| 127 | 28 |
return pop; |
| 123 | 29 |
}; |
30 |
||
| 127 | 31 |
IriSP.configureWidgets = function (popcornInstance, guiOptions) { |
| 123 | 32 |
|
| 127 | 33 |
var dt = new IriSP.DataLoader(); |
34 |
var serialFactory = new IriSP.SerializerFactory(dt); |
|
35 |
|
|
36 |
var params = {width: guiOptions.width, height: guiOptions.height}; |
|
37 |
var lay = new IriSP.LayoutManager(params); |
|
|
136
9c2e80e4f1b5
oneliner to specify the popcorn instance to the layout manager.
hamidouk
parents:
129
diff
changeset
|
38 |
lay.setPopcornInstance(popcornInstance); |
| 127 | 39 |
|
40 |
var ret_widgets = []; |
|
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
41 |
var index; |
| 127 | 42 |
|
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
43 |
for (index = 0; index < guiOptions.widgets.length; index++) { |
| 127 | 44 |
var widget = guiOptions.widgets[index]; |
45 |
var container = lay.createDiv(); |
|
46 |
|
|
47 |
var arr = IriSP.jQuery.extend({}, widget); |
|
48 |
arr.container = container; |
|
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
49 |
|
| 129 | 50 |
var serializer = serialFactory.getSerializer(widget.metadata); |
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
51 |
|
| 127 | 52 |
// instantiate the object passed as a string |
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
53 |
var widget = new IriSP[widget.type](popcornInstance, arr, serializer); |
|
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
54 |
|
|
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
55 |
serializer.sync(IriSP.wrap(widget, function() { this.draw(); })); |
| 127 | 56 |
ret_widgets.push(widget); |
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
57 |
|
| 127 | 58 |
}; |
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
59 |
|
| 127 | 60 |
return ret_widgets; |
| 123 | 61 |
}; |