|
111
|
1 |
/* layout.js - very basic layout management */ |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
a layout manager manages a div and the layout of objects |
|
|
5 |
inside it. |
|
|
6 |
*/ |
|
|
7 |
|
|
|
8 |
IriSP.LayoutManager = function(options) { |
|
|
9 |
this._Popcorn = null; |
|
|
10 |
this._widgets = []; |
|
|
11 |
|
|
113
|
12 |
this._div = "LdtPlayer"; |
|
111
|
13 |
this._width = 640; |
|
|
14 |
this._height = 480; |
|
|
15 |
|
|
|
16 |
if (options === undefined) { |
|
|
17 |
options = {}; |
|
|
18 |
console.error("The options parameter is undefined."); |
|
|
19 |
}; |
|
|
20 |
|
|
117
|
21 |
if (options.hasOwnProperty('container')) { |
|
|
22 |
this._div = options.container; |
|
111
|
23 |
} |
|
|
24 |
|
|
|
25 |
if (options.hasOwnProperty('width')) { |
|
|
26 |
this._width = options.width; |
|
|
27 |
} |
|
|
28 |
|
|
|
29 |
if (options.hasOwnProperty('height')) { |
|
|
30 |
this._height = options.height; |
|
|
31 |
} |
|
|
32 |
|
|
113
|
33 |
/* this is a shortcut */ |
|
|
34 |
this.selector = IriSP.jQuery("#" + this._div); |
|
|
35 |
|
|
|
36 |
this.selector.css("width", this._width); |
|
|
37 |
this.selector.css("height", this._height); |
|
111
|
38 |
}; |
|
|
39 |
|
|
|
40 |
/* we need this special setter because of a chicken and egg problem : |
|
|
41 |
we want the manager to use popcorn but the popcorn div will be managed |
|
|
42 |
by the manager. So we need a way to set the instance the manager uses |
|
|
43 |
*/ |
|
|
44 |
|
|
|
45 |
IriSP.LayoutManager.prototype.setPopcornInstance = function(popcorn) { |
|
|
46 |
this._Popcorn = popcorn; |
|
|
47 |
/* FIXME - don't forget to add the popcorn messages handlers there */ |
|
|
48 |
} |
|
|
49 |
|
|
113
|
50 |
IriSP.LayoutManager.prototype.createDiv = function() { |
|
|
51 |
var newDiv = Popcorn.guid(this._div + "_widget_"); |
|
|
52 |
this._widgets.push(newDiv); |
|
|
53 |
this.selector.append("<div id='" + newDiv + "'></div"); |
|
|
54 |
|
|
|
55 |
return newDiv; |
|
|
56 |
}; |