| author | hamidouk |
| Mon, 14 Nov 2011 17:19:26 +0100 | |
| branch | require-js |
| changeset 238 | 6008172a0592 |
| parent 217 | ec3e6d34462c |
| permissions | -rw-r--r-- |
| 111 | 1 |
/* layout.js - very basic layout management */ |
2 |
||
|
238
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
3 |
define(["IriSP"], function() { |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
4 |
/* |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
5 |
a layout manager manages a div and the layout of objects |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
6 |
inside it. |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
7 |
*/ |
| 111 | 8 |
|
|
238
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
9 |
IriSP.LayoutManager = function(options) { |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
10 |
this._Popcorn = null; |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
11 |
this._widgets = []; |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
12 |
|
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
13 |
this._div = "LdtPlayer"; |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
14 |
this._width = 640; |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
15 |
|
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
16 |
if (options === undefined) { |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
17 |
options = {}; |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
18 |
}; |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
19 |
|
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
20 |
if (options.hasOwnProperty('container')) { |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
21 |
this._div = options.container; |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
22 |
} |
| 111 | 23 |
|
|
238
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
24 |
if (options.hasOwnProperty('width')) { |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
25 |
this._width = options.width; |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
26 |
} |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
27 |
|
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
28 |
if (options.hasOwnProperty('height')) { |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
29 |
this._height = options.height; |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
30 |
} |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
31 |
|
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
32 |
/* this is a shortcut */ |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
33 |
this.selector = IriSP.jQuery("#" + this._div); |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
34 |
|
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
35 |
this.selector.css("width", this._width); |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
36 |
|
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
37 |
if (this._height !== undefined) |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
38 |
this.selector.css("height", this._height); |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
39 |
}; |
| 111 | 40 |
|
|
238
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
41 |
/* we need this special setter because of a chicken and egg problem : |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
42 |
we want the manager to use popcorn but the popcorn div will be managed |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
43 |
by the manager. So we need a way to set the instance the manager uses |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
44 |
*/ |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
45 |
|
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
46 |
IriSP.LayoutManager.prototype.setPopcornInstance = function(popcorn) { |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
47 |
this._Popcorn = popcorn; |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
48 |
/* FIXME - don't forget to add the popcorn messages handlers there */ |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
49 |
} |
| 111 | 50 |
|
|
238
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
51 |
IriSP.LayoutManager.prototype.createDiv = function() { |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
52 |
var newDiv = Popcorn.guid(this._div + "_widget_"); |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
53 |
this._widgets.push(newDiv); |
| 217 | 54 |
|
|
238
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
55 |
var templ = "<div id='{{id}}' style='width: 100%; position: relative;'></div"; |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
56 |
var txt = Mustache.to_html(templ, {id: newDiv}); |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
57 |
this.selector.append(txt); |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
58 |
|
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
59 |
return newDiv; |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
60 |
}; |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
217
diff
changeset
|
61 |
}); |