| author | hamidouk |
| Mon, 21 Nov 2011 11:34:07 +0100 | |
| branch | popcorn-port |
| changeset 287 | 5c7495102bd7 |
| parent 217 | ec3e6d34462c |
| child 288 | 25fe0c8831de |
| permissions | -rw-r--r-- |
| 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 |
|
|
15 |
if (options === undefined) { |
|
16 |
options = {}; |
|
17 |
}; |
|
18 |
|
|
| 117 | 19 |
if (options.hasOwnProperty('container')) { |
20 |
this._div = options.container; |
|
| 111 | 21 |
} |
22 |
||
23 |
if (options.hasOwnProperty('width')) { |
|
24 |
this._width = options.width; |
|
25 |
} |
|
26 |
|
|
27 |
if (options.hasOwnProperty('height')) { |
|
28 |
this._height = options.height; |
|
29 |
} |
|
30 |
|
|
| 113 | 31 |
/* this is a shortcut */ |
32 |
this.selector = IriSP.jQuery("#" + this._div); |
|
33 |
|
|
34 |
this.selector.css("width", this._width); |
|
| 159 | 35 |
|
36 |
if (this._height !== undefined) |
|
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 |
} |
|
48 |
||
| 113 | 49 |
IriSP.LayoutManager.prototype.createDiv = function() { |
50 |
var newDiv = Popcorn.guid(this._div + "_widget_"); |
|
|
287
5c7495102bd7
added a spacer div to simplify some graphic animations.
hamidouk
parents:
217
diff
changeset
|
51 |
var spacerDiv = Popcorn.guid("_spacer_"); |
| 217 | 52 |
this._widgets.push(newDiv); |
53 |
||
|
287
5c7495102bd7
added a spacer div to simplify some graphic animations.
hamidouk
parents:
217
diff
changeset
|
54 |
var divTempl = "<div id='{{id}}' style='width: 100%; position: relative;'></div"; |
|
5c7495102bd7
added a spacer div to simplify some graphic animations.
hamidouk
parents:
217
diff
changeset
|
55 |
var spacerTempl = "<div id='{{spacer_id}}' style='width: 100%; position: relative; height: 5px;'></div"; |
| 113 | 56 |
|
|
287
5c7495102bd7
added a spacer div to simplify some graphic animations.
hamidouk
parents:
217
diff
changeset
|
57 |
var divCode = Mustache.to_html(divTempl, {id: newDiv}); |
|
5c7495102bd7
added a spacer div to simplify some graphic animations.
hamidouk
parents:
217
diff
changeset
|
58 |
var spacerCode = Mustache.to_html(spacerTempl, {spacer_id: spacerDiv}); |
|
5c7495102bd7
added a spacer div to simplify some graphic animations.
hamidouk
parents:
217
diff
changeset
|
59 |
|
|
5c7495102bd7
added a spacer div to simplify some graphic animations.
hamidouk
parents:
217
diff
changeset
|
60 |
this.selector.append(spacerCode); |
|
5c7495102bd7
added a spacer div to simplify some graphic animations.
hamidouk
parents:
217
diff
changeset
|
61 |
this.selector.append(divCode); |
|
5c7495102bd7
added a spacer div to simplify some graphic animations.
hamidouk
parents:
217
diff
changeset
|
62 |
|
|
5c7495102bd7
added a spacer div to simplify some graphic animations.
hamidouk
parents:
217
diff
changeset
|
63 |
return [newDiv, spacerDiv]; |
| 113 | 64 |
}; |