author | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
commit | 541bb378ddece2eab135a8066a16994e94436dea (patch) (unidiff) | |
tree | ff160ea3e26f7fe07fcfd401387c5a0232ca715e /frontend/beta/js/YUI-extensions/layout/LayoutManager.js | |
parent | 1bf431fd3d45cbdf4afa3e12afefe5d24f4d3bc7 (diff) | |
parent | ecad5e895831337216544e81f1a467e0c68c4a6a (diff) | |
download | clipperz-541bb378ddece2eab135a8066a16994e94436dea.zip clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.gz clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.bz2 |
Merge pull request #1 from gcsolaroli/master
First version of the restructured repository
Diffstat (limited to 'frontend/beta/js/YUI-extensions/layout/LayoutManager.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/YUI-extensions/layout/LayoutManager.js | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/frontend/beta/js/YUI-extensions/layout/LayoutManager.js b/frontend/beta/js/YUI-extensions/layout/LayoutManager.js new file mode 100644 index 0000000..c59bf0e --- a/dev/null +++ b/frontend/beta/js/YUI-extensions/layout/LayoutManager.js | |||
@@ -0,0 +1,135 @@ | |||
1 | /** | ||
2 | * @class YAHOO.ext.LayoutManager | ||
3 | * @extends YAHOO.ext.util.Observable | ||
4 | * Base class for layout managers. | ||
5 | */ | ||
6 | YAHOO.ext.LayoutManager = function(container){ | ||
7 | YAHOO.ext.LayoutManager.superclass.constructor.call(this); | ||
8 | this.el = getEl(container, true); | ||
9 | // ie scrollbar fix | ||
10 | if(this.el.dom == document.body && YAHOO.ext.util.Browser.isIE){ | ||
11 | document.body.scroll = 'no'; | ||
12 | } | ||
13 | this.id = this.el.id; | ||
14 | this.el.addClass('ylayout-container'); | ||
15 | /** false to disable window resize monitoring @type Boolean */ | ||
16 | this.monitorWindowResize = true; | ||
17 | this.regions = {}; | ||
18 | this.events = { | ||
19 | /** | ||
20 | * @event layout | ||
21 | * Fires when a layout is performed. | ||
22 | * @param {YAHOO.ext.LayoutManager} this | ||
23 | */ | ||
24 | 'layout' : new YAHOO.util.CustomEvent(), | ||
25 | /** | ||
26 | * @event regionresized | ||
27 | * Fires when the user resizes a region. | ||
28 | * @param {YAHOO.ext.LayoutRegion} region | ||
29 | * @param {Number} newSize The new size (width for east/west, height for north/south) | ||
30 | */ | ||
31 | 'regionresized' : new YAHOO.util.CustomEvent(), | ||
32 | /** | ||
33 | * @event regioncollapsed | ||
34 | * Fires when a region is collapsed. | ||
35 | * @param {YAHOO.ext.LayoutRegion} region | ||
36 | */ | ||
37 | 'regioncollapsed' : new YAHOO.util.CustomEvent(), | ||
38 | /** | ||
39 | * @event regionexpanded | ||
40 | * Fires when a region is expanded. | ||
41 | * @param {YAHOO.ext.LayoutRegion} region | ||
42 | */ | ||
43 | 'regionexpanded' : new YAHOO.util.CustomEvent() | ||
44 | }; | ||
45 | this.updating = false; | ||
46 | YAHOO.ext.EventManager.onWindowResize(this.onWindowResize, this, true); | ||
47 | }; | ||
48 | |||
49 | YAHOO.extendX(YAHOO.ext.LayoutManager, YAHOO.ext.util.Observable, { | ||
50 | /** | ||
51 | * Returns true if this layout is currently being updated | ||
52 | * @return {Boolean} | ||
53 | */ | ||
54 | isUpdating : function(){ | ||
55 | return this.updating; | ||
56 | }, | ||
57 | |||
58 | /** | ||
59 | * Suspend the LayoutManager from doing auto-layouts while | ||
60 | * making multiple add or remove calls | ||
61 | */ | ||
62 | beginUpdate : function(){ | ||
63 | this.updating = true; | ||
64 | }, | ||
65 | |||
66 | /** | ||
67 | * Restore auto-layouts and optionally disable the manager from performing a layout | ||
68 | * @param {Boolean} noLayout true to disable a layout update | ||
69 | */ | ||
70 | endUpdate : function(noLayout){ | ||
71 | this.updating = false; | ||
72 | if(!noLayout){ | ||
73 | this.layout(); | ||
74 | } | ||
75 | }, | ||
76 | |||
77 | layout: function(){ | ||
78 | |||
79 | }, | ||
80 | |||
81 | onRegionResized : function(region, newSize){ | ||
82 | this.fireEvent('regionresized', region, newSize); | ||
83 | this.layout(); | ||
84 | }, | ||
85 | |||
86 | onRegionCollapsed : function(region){ | ||
87 | this.fireEvent('regioncollapsed', region); | ||
88 | }, | ||
89 | |||
90 | onRegionExpanded : function(region){ | ||
91 | this.fireEvent('regionexpanded', region); | ||
92 | }, | ||
93 | |||
94 | /** | ||
95 | * Returns the size of the current view, This method normalizes document.body and element embedded layouts and | ||
96 | * performs box-model adjustments. | ||
97 | * @return {Object} The size as an object {width: (the width), height: (the height)} | ||
98 | */ | ||
99 | getViewSize : function(){ | ||
100 | var size; | ||
101 | if(this.el.dom != document.body){ | ||
102 | this.el.beginMeasure(); | ||
103 | size = this.el.getSize(); | ||
104 | this.el.endMeasure(); | ||
105 | }else{ | ||
106 | size = {width: YAHOO.util.Dom.getViewportWidth(), height: YAHOO.util.Dom.getViewportHeight()}; | ||
107 | } | ||
108 | size.width -= this.el.getBorderWidth('lr')-this.el.getPadding('lr'); | ||
109 | size.height -= this.el.getBorderWidth('tb')-this.el.getPadding('tb'); | ||
110 | return size; | ||
111 | }, | ||
112 | |||
113 | /** | ||
114 | * Returns the element this layout is bound to. | ||
115 | * @return {YAHOO.ext.Element} | ||
116 | */ | ||
117 | getEl : function(){ | ||
118 | return this.el; | ||
119 | }, | ||
120 | |||
121 | /** | ||
122 | * Returns the specified region. | ||
123 | * @param {String} target The region key | ||
124 | * @return {YAHOO.ext.LayoutRegion} | ||
125 | */ | ||
126 | getRegion : function(target){ | ||
127 | return this.regions[target.toLowerCase()]; | ||
128 | }, | ||
129 | |||
130 | onWindowResize : function(){ | ||
131 | if(this.monitorWindowResize){ | ||
132 | this.layout(); | ||
133 | } | ||
134 | } | ||
135 | }); | ||