1 | (function() { |
---|
2 | var Dom = YAHOO.util.Dom, |
---|
3 | Event = YAHOO.util.Event; |
---|
4 | |
---|
5 | Event.onDOMReady(function() { |
---|
6 | var layout = new YAHOO.widget.Layout({ |
---|
7 | units: [ |
---|
8 | /* header */ |
---|
9 | { position: 'top', height: 114, body: 'hd', |
---|
10 | gutter: '1px' }, |
---|
11 | /* footer */ |
---|
12 | { position: 'bottom', height: 30, |
---|
13 | body: 'ft', gutter: '-1px' }, |
---|
14 | /* left sidebar */ |
---|
15 | { position: 'left', header: 'Actions', width: 200, resize: true, |
---|
16 | body: 'left', gutter: '5px', collapse: true, |
---|
17 | collapseSize: 25, scroll: true, animate: true }, |
---|
18 | /* main area */ |
---|
19 | { position: 'center', body: 'yui-main', scroll: true } |
---|
20 | ] |
---|
21 | }); |
---|
22 | layout.on('render', function() { |
---|
23 | layout.getUnitByPosition('left').on('close', function() { |
---|
24 | closeLeft(); |
---|
25 | }); |
---|
26 | }); |
---|
27 | layout.render(); |
---|
28 | Event.on('tLeft', 'click', function(ev) { |
---|
29 | Event.stopEvent(ev); |
---|
30 | layout.getUnitByPosition('left').toggle(); |
---|
31 | }); |
---|
32 | Event.on('padRight', 'click', function(ev) { |
---|
33 | Event.stopEvent(ev); |
---|
34 | var pad = prompt('CSS gutter to apply: ("2px" or "2px 4px" or any combination of the 4 sides)', layout.getUnitByPosition('right').get('gutter')); |
---|
35 | layout.getUnitByPosition('right').set('gutter', pad); |
---|
36 | }); |
---|
37 | var closeLeft = function() { |
---|
38 | var a = document.createElement('a'); |
---|
39 | a.href = '#'; |
---|
40 | a.innerHTML = 'Add Left Unit'; |
---|
41 | Dom.get('closeLeft').parentNode.appendChild(a); |
---|
42 | |
---|
43 | Dom.setStyle('tLeft', 'display', 'none'); |
---|
44 | Dom.setStyle('closeLeft', 'display', 'none'); |
---|
45 | Event.on(a, 'click', function(ev) { |
---|
46 | Event.stopEvent(ev); |
---|
47 | Dom.setStyle('tLeft', 'display', 'inline'); |
---|
48 | Dom.setStyle('closeLeft', 'display', 'inline'); |
---|
49 | a.parentNode.removeChild(a); |
---|
50 | layout.addUnit(layout.get('units')[3]); |
---|
51 | layout.getUnitByPosition('left').on('close', function() { |
---|
52 | closeLeft(); |
---|
53 | }); |
---|
54 | }); |
---|
55 | }; |
---|
56 | Event.on('closeLeft', 'click', function(ev) { |
---|
57 | Event.stopEvent(ev); |
---|
58 | layout.getUnitByPosition('left').close(); |
---|
59 | }); |
---|
60 | }); |
---|
61 | |
---|
62 | |
---|
63 | })(); |
---|
64 | |
---|