-
Notifications
You must be signed in to change notification settings - Fork 0
/
pega_yui_layout.js
2137 lines (2038 loc) · 78 KB
/
pega_yui_layout.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 2.5.2
*/
/*
Bug-1087: Made following changes:
1)In initAttributes added a if(size in pixels<0) for this.setAttributeConfig('height' {...and this.setAttributeConfig('width', {
Task-8423: Collapsable/Expandable button has to be enabled in accessbility mode. Following changes are made
1)In _createClip function the anchor tag is added inside the collapsable div
2)In this.setAttributeConfig('collapse', {, the method is modified to get the anchor tag inside the div. In both the casses the class collapse is added to the anchor tag.
1)Removed couple of 'set' api calls in the 'resize' api of LayoutUnit. This has been done to improve performance while resizing the panel.
REDDN :-
Task-21143:- Removed 'resize' api call from the 'render' API to improve Layout intialization performance.
KUMAR4 :-
BUG-37961 - commented 'this.set('scroll', this._lastScroll);' in expand(). 'scroll' is already set in resize(), which is called just before the commented line of code.
*/
/**
* @description <p>Provides a fixed layout containing, top, bottom, left, right and center layout units. It can be applied to either the body or an element.</p>
* @namespace pega.widget
* @requires pega, dom, element, event
* @module layout
* @beta
*/
(function() {
var Dom = pega.util.Dom,
Event = pega.util.Event,
Lang = pega.lang;
/**
* @constructor
* @class Layout
* @extends pega.util.Element
* @description <p>Provides a fixed layout containing, top, bottom, left, right and center layout units. It can be applied to either the body or an element.</p>
* @param {String/HTMLElement} el The element to make contain a layout.
* @param {Object} attrs Object liternal containing configuration parameters.
*/
var Layout = function(el, config) {
if (Lang.isObject(el) && !el.tagName) {
config = el;
el = null;
}
if (Lang.isString(el)) {
if (Dom.get(el)) {
el = Dom.get(el);
}
}
if (!el) {
el = document.body;
}
var oConfig = {
element: el,
attributes: config || {}
};
Layout.superclass.constructor.call(this, oConfig.element, oConfig.attributes);
};
/**
* @private
* @static
* @property _instances
* @description Internal hash table for all layout instances
* @type Object
*/
Layout._instances = {};
/**
* @static
* @method getLayoutById
* @description Get's a layout object by the HTML id of the element associated with the Layout object.
* @return {Object} The Layout Object
*/
Layout.getLayoutById = function(id) {
if (Layout._instances[id]) {
return Layout._instances[id];
}
return false;
};
pega.extend(Layout, pega.util.Element, {
/**
* @property browser
* @description A modified version of the pega.env.ua object
* @type Object
*/
browser: function() {
var b = pega.env.ua;
b.standardsMode = false;
b.secure = false;
return b;
}(),
/**
* @private
* @property _rendered
* @description Set to true when the layout is rendered
* @type Boolean
*/
_rendered: null,
/**
* @private
* @property _zIndex
* @description The zIndex to set all LayoutUnits to
* @type Number
*/
_zIndex: null,
/**
* @private
* @property _sizes
* @description A collection of the current sizes of all usable LayoutUnits to be used for calculations
* @type Object
*/
_sizes: null,
/**
* @private
* @method _setBodySize
* @param {Boolean} set If set to false, it will NOT set the size, just perform the calculations (used for collapsing units)
* @description Used to set the body size of the layout, sets the height and width of the parent container
*/
_setBodySize: function(set) {
var h = 0, w = 0;
set = ((set === false) ? false : true);
if (this._isBody) {
h = Dom.getClientHeight();
w = Dom.getClientWidth();
} else {
h = parseInt(this.getStyle('height'), 10);
w = parseInt(this.getStyle('width'), 10);
if (isNaN(w)) {
w = this.get('element').clientWidth;
}
if (isNaN(h)) {
h = this.get('element').clientHeight;
}
}
if (this.get('minWidth')) {
if (w < this.get('minWidth')) {
w = this.get('minWidth');
}
}
if (this.get('minHeight')) {
if (h < this.get('minHeight')) {
h = this.get('minHeight');
}
}
if (set) {
Dom.setStyle(this._doc, 'height', h + 'px');
Dom.setStyle(this._doc, 'width', w + 'px');
}
this._sizes.doc = { h: h, w: w };
this._setSides(set);
},
/**
* @private
* @method _setSides
* @param {Boolean} set If set to false, it will NOT set the size, just perform the calculations (used for collapsing units)
* @description Used to set the size and position of the left, right, top and bottom units
*/
_setSides: function(set) {
var h1 = ((this._top) ? this._top.get('height') : 0),
h2 = ((this._bottom) ? this._bottom.get('height') : 0),
h = this._sizes.doc.h,
w = this._sizes.doc.w;
set = ((set === false) ? false : true);
this._sizes.top = {
h: h1, w: ((this._top) ? w : 0),
t: 0
};
this._sizes.bottom = {
h: h2, w: ((this._bottom) ? w : 0)
};
var newH = (h - (h1 + h2));
this._sizes.left = {
h: newH, w: ((this._left) ? this._left.get('width') : 0)
};
this._sizes.right = {
h: newH, w: ((this._right) ? this._right.get('width') : 0),
l: ((this._right) ? (w - this._right.get('width')) : 0),
t: ((this._top) ? this._sizes.top.h : 0)
};
if (this._right && set) {
this._right.set('top', this._sizes.right.t);
if (!this._right._collapsing) {
this._right.set('left', this._sizes.right.l);
}
this._right.set('height', this._sizes.right.h, true);
}
if (this._left) {
this._sizes.left.l = 0;
if (this._top) {
this._sizes.left.t = this._sizes.top.h;
} else {
this._sizes.left.t = 0;
}
if (set) {
this._left.set('top', this._sizes.left.t);
this._left.set('height', this._sizes.left.h, true);
this._left.set('left', 0);
}
}
if (this._bottom) {
this._sizes.bottom.t = this._sizes.top.h + this._sizes.left.h;
if (set) {
this._bottom.set('top', this._sizes.bottom.t);
this._bottom.set('width', this._sizes.bottom.w, true);
}
}
if (this._top) {
if (set) {
this._top.set('width', this._sizes.top.w, true);
}
}
this._setCenter(set);
},
/**
* @private
* @method _setCenter
* @param {Boolean} set If set to false, it will NOT set the size, just perform the calculations (used for collapsing units)
* @description Used to set the size and position of the center unit
*/
_setCenter: function(set) {
set = ((set === false) ? false : true);
var h = this._sizes.left.h;
var w = (this._sizes.doc.w - (this._sizes.left.w + this._sizes.right.w));
if (set) {
this._center.set('height', h, true);
this._center.set('width', w, true);
this._center.set('top', this._sizes.top.h);
this._center.set('left', this._sizes.left.w);
}
this._sizes.center = { h: h, w: w, t: this._sizes.top.h, l: this._sizes.left.w };
},
/**
* @method getSizes
* @description Get a reference to the internal Layout Unit sizes object used to build the layout wireframe
* @return {Object} An object of the layout unit sizes
*/
getSizes: function() {
return this._sizes;
},
/**
* @method getUnitById
* @param {String} id The HTML element id of the unit
* @description Get the LayoutUnit by it's HTML id
* @return {<a href="pega.widget.LayoutUnit.html">pega.widget.LayoutUnit</a>} The LayoutUnit instance
*/
getUnitById: function(id) {
return pega.widget.LayoutUnit.getLayoutUnitById(id);
},
/**
* @method getUnitByPosition
* @param {String} pos The position of the unit in this layout
* @description Get the LayoutUnit by it's position in this layout
* @return {<a href="pega.widget.LayoutUnit.html">pega.widget.LayoutUnit</a>} The LayoutUnit instance
*/
getUnitByPosition: function(pos) {
if (pos) {
pos = pos.toLowerCase();
if (this['_' + pos]) {
return this['_' + pos];
}
}
return false;
},
/**
* @method removeUnit
* @param {Object} unit The LayoutUnit that you want to remove
* @description Remove the unit from this layout and resize the layout.
*/
removeUnit: function(unit) {
this['_' + unit.get('position')] = null;
this.resize();
},
/**
* @method addUnit
* @param {Object} cfg The config for the LayoutUnit that you want to add
* @description Add a unit to this layout and if the layout is rendered, resize the layout.
* @return {<a href="pega.widget.LayoutUnit.html">pega.widget.LayoutUnit</a>} The LayoutUnit instance
*/
addUnit: function(cfg) {
if (!cfg.position) {
return false;
}
if (this['_' + cfg.position]) {
return false;
}
var element = null,
el = null;
if (cfg.id) {
if (Dom.get(cfg.id)) {
element = Dom.get(cfg.id);
delete cfg.id;
}
}
if (cfg.element) {
element = cfg.element;
}
if(!this.bNewGen) {
if (!el) {
el = document.createElement('div');
var id = Dom.generateId();
el.id = id;
}
if (!element) {
element = document.createElement('div');
}
Dom.addClass(element, 'yui-layout-wrap');
if (this.browser.ie && !this.browser.standardsMode) {
el.style.zoom = 1;
element.style.zoom = 1;
}
if (el.firstChild) {
el.insertBefore(element, el.firstChild);
} else {
el.appendChild(element);
}
this._doc.appendChild(el);
}
var h = false, w = false;
if (cfg.height) {
h = parseInt(cfg.height, 10);
}
if (cfg.width) {
w = parseInt(cfg.width, 10);
}
var unitConfig = {};
pega.lang.augmentObject(unitConfig, cfg); // break obj ref
unitConfig.parent = this;
unitConfig.height = h;
unitConfig.width = w;
var unit;
if(this.bNewGen) {
unitConfig.wrap = Dom.get(cfg.body).parentNode.parentNode;
unit = new pega.widget.LayoutUnit(Dom.get(cfg.body).parentNode.parentNode.parentNode, unitConfig);
} else {
unitConfig.wrap = element;
unit = new pega.widget.LayoutUnit(el, unitConfig);
}
unit.on('heightChange', this.resize, this, true);
unit.on('widthChange', this.resize, this, true);
unit.on('gutterChange', this.resize, this, true);
this['_' + cfg.position] = unit;
if (this._rendered) {
this.resize();
}
return unit;
},
/**
* @private
* @method _createUnits
* @description Private method to create units from the config that was passed in.
*/
_createUnits: function() {
var units = this.get('units');
for (var i in units) {
if (Lang.hasOwnProperty(units, i)) {
this.addUnit(units[i]);
}
}
},
/**
* @method resize
* @param {Boolean} set If set to false, it will NOT set the size, just perform the calculations (used for collapsing units)
* @description Starts the chain of resize routines that will resize all the units.
* @return {<a href="pega.widget.Layout.html">pega.widget.Layout</a>} The Layout instance
*/
resize: function(set) {
set = ((set === false) ? false : true);
if (set) {
var retVal = this.fireEvent('beforeResize');
if (retVal === false) {
set = false;
}
if (this.browser.ie) {
if (this._isBody) {
Dom.removeClass(document.documentElement, 'yui-layout');
Dom.addClass(document.documentElement, 'yui-layout');
} else {
this.removeClass('yui-layout');
this.addClass('yui-layout');
}
}
}
this._setBodySize(set);
if (set) {
this.fireEvent('resize', { target: this, sizes: this._sizes });
}
return this;
},
/**
* @private
* @method _setupBodyElements
* @description Sets up the main doc element when using the body as the main element.
*/
_setupBodyElements: function() {
this._doc = Dom.get('layout-doc');
if (!this._doc) {
this._doc = document.createElement('div');
this._doc.id = 'layout-doc';
if (document.body.firstChild) {
document.body.insertBefore(this._doc, document.body.firstChild);
} else {
document.body.appendChild(this._doc);
}
}
this._createUnits();
this._setBodySize();
Event.on(window, 'resize', this.resize, this, true);
if(!this.bNewGen) {
Dom.addClass(this._doc, 'yui-layout-doc');
}
},
/**
* @private
* @method _setupElements
* @description Sets up the main doc element when not using the body as the main element.
*/
_setupElements: function() {
if(!this.bNewGen) {
this._doc = this.getElementsByClassName('doc')[0];
} else {
this._doc = this.getElementsByClassName('yui-layout-doc')[0];
}
if (!this._doc) {
this._doc = document.createElement('div');
this.get('element').appendChild(this._doc);
}
this._createUnits();
this._setBodySize();
Event.on(window, 'resize', this.resize, this, true);
if(!this.bNewGen) {
Dom.addClass(this._doc, 'yui-layout-doc');
}
},
/**
* @private
* @property _isBody
* @description Flag to determine if we are using the body as the root element.
* @type Boolean
*/
_isBody: null,
/**
* @private
* @property _doc
* @description Reference to the root element
* @type HTMLElement
*/
_doc: null,
/**
* @private
* @property _left
* @description Reference to the left LayoutUnit Object
* @type {<a href="pega.widget.LayoutUnit.html">pega.widget.LayoutUnit</a>} A LayoutUnit instance
*/
_left: null,
/**
* @private
* @property _right
* @description Reference to the right LayoutUnit Object
* @type {<a href="pega.widget.LayoutUnit.html">pega.widget.LayoutUnit</a>} A LayoutUnit instance
*/
_right: null,
/**
* @private
* @property _top
* @description Reference to the top LayoutUnit Object
* @type {<a href="pega.widget.LayoutUnit.html">pega.widget.LayoutUnit</a>} A LayoutUnit instance
*/
_top: null,
/**
* @private
* @property _bottom
* @description Reference to the bottom LayoutUnit Object
* @type {<a href="pega.widget.LayoutUnit.html">pega.widget.LayoutUnit</a>} A LayoutUnit instance
*/
_bottom: null,
/**
* @private
* @property _center
* @description Reference to the center LayoutUnit Object
* @type {<a href="pega.widget.LayoutUnit.html">pega.widget.LayoutUnit</a>} A LayoutUnit instance
*/
_center: null,
/**
* @private
* @method init
* @description The Layout class' initialization method
*/
init: function(p_oElement, p_oAttributes) {
this._zIndex = 0;
Layout.superclass.init.call(this, p_oElement, p_oAttributes);
if (this.get('parent')) {
this._zIndex = this.get('parent')._zIndex + 10;
}
this._sizes = {};
var id = p_oElement;
if (!Lang.isString(id)) {
id = Dom.generateId(id);
}
if(Dom.get("layout-doc").getAttribute("data-newgen") === "true") {
this.bNewGen = true;
} else {
this.bNewGen = false;
}
Layout._instances[id] = this;
},
/**
* @method render
* @description This method starts the render process, applying classnames and creating elements
* @return {<a href="pega.widget.Layout.html">pega.widget.Layout</a>} The Layout instance
*/
render: function() {
this._stamp();
var el = this.get('element');
if (el && el.tagName && (el.tagName.toLowerCase() == 'body')) {
this._isBody = true;
if(!this.bNewGen) {
Dom.addClass(document.body, 'yui-layout');
if (Dom.hasClass(document.body, 'yui-skin-sam')) {
//Move the class up so we can have a css chain
Dom.addClass(document.documentElement, 'yui-skin-sam');
Dom.removeClass(document.body, 'yui-skin-sam');
}
}
this._setupBodyElements();
} else {
this._isBody = false;
this.addClass('yui-layout');
this._setupElements();
}
/* REDDN :- Task-21143:- Removed 'resize' api call to improve Layout intialization performance. */
/*this.resize();*/
this._rendered = true;
this.fireEvent('render');
return this;
},
/**
* @private
* @method _stamp
* @description Stamps the root node with a secure classname for ease of use. Also sets the this.browser.standardsMode variable.
*/
_stamp: function() {
if (document.compatMode == 'CSS1Compat') {
this.browser.standardsMode = true;
}
if (window.location.href.toLowerCase().indexOf("https") === 0) {
Dom.addClass(document.documentElement, 'secure');
this.browser.secure = true;
}
},
/**
* @private
* @method initAttributes
* @description Processes the config
*/
initAttributes: function(attr) {
Layout.superclass.initAttributes.call(this, attr);
/**
* @attribute units
* @description An array of config definitions for the LayoutUnits to add to this layout
* @type Array
*/
this.setAttributeConfig('units', {
writeOnce: true,
validator: pega.lang.isArray,
value: attr.units || []
});
/**
* @attribute minHeight
* @description The minimum height in pixels
* @type Number
*/
this.setAttributeConfig('minHeight', {
value: attr.minHeight || false,
validator: pega.lang.isNumber
});
/**
* @attribute minWidth
* @description The minimum width in pixels
* @type Number
*/
this.setAttributeConfig('minWidth', {
value: attr.minWidth || false,
validator: pega.lang.isNumber
});
/**
* @attribute height
* @description The height in pixels
* @type Number
*/
this.setAttributeConfig('height', {
value: attr.height || false,
validator: pega.lang.isNumber,
method: function(h) {
this.setStyle('height', h + 'px');
}
});
/**
* @attribute width
* @description The width in pixels
* @type Number
*/
this.setAttributeConfig('width', {
value: attr.width || false,
validator: pega.lang.isNumber,
method: function(w) {
this.setStyle('width', w + 'px');
}
});
/**
* @attribute parent
* @description If this layout is to be used as a child of another Layout instance, this config will bind the resize events together.
* @type Object pega.widget.Layout
*/
this.setAttributeConfig('parent', {
writeOnce: true,
value: attr.parent || false,
method: function(p) {
if (p) {
p.on('resize', this.resize, this, true);
}
}
});
},
/**
* @method toString
* @description Returns a string representing the Layout.
* @return {String}
*/
toString: function() {
if (this.get) {
return 'Layout #' + this.get('id');
}
return 'Layout';
}
});
/**
* @event resize
* @description Fired when this.resize is called
* @type pega.util.CustomEvent
*/
/**
* @event startResize
* @description Fired when the Resize Utility for a Unit fires it's startResize Event.
* @type pega.util.CustomEvent
*/
/**
* @event beforeResize
* @description Firef at the beginning of the resize method. If you return false, the resize is cancelled.
* @type pega.util.CustomEvent
*/
/**
* @event render
* @description Fired after the render method completes.
* @type pega.util.CustomEvent
*/
pega.widget.Layout = Layout;
})();
/**
* @description <p>Provides a fixed position unit containing a header, body and footer for use with a pega.widget.Layout instance.</p>
* @namespace pega.widget
* @requires pega, dom, element, event, layout
* @optional animation, dragdrop, selector
* @beta
*/
(function() {
var Dom = pega.util.Dom,
Sel = pega.util.Selector,
Event = pega.util.Event,
Lang = pega.lang;
/**
* @constructor
* @class LayoutUnit
* @extends pega.util.Element
* @description <p>Provides a fixed position unit containing a header, body and footer for use with a pega.widget.Layout instance.</p>
* @param {String/HTMLElement} el The element to make a unit.
* @param {Object} attrs Object liternal containing configuration parameters.
*/
var LayoutUnit = function(el, config) {
var oConfig = {
element: el,
attributes: config || {}
};
LayoutUnit.superclass.constructor.call(this, oConfig.element, oConfig.attributes);
};
/**
* @private
* @static
* @property _instances
* @description Internal hash table for all layout unit instances
* @type Object
*/
LayoutUnit._instances = {};
/**
* @static
* @method getLayoutUnitById
* @description Get's a layout unit object by the HTML id of the element associated with the Layout Unit object.
* @return {Object} The Layout Object
*/
LayoutUnit.getLayoutUnitById = function(id) {
if (LayoutUnit._instances[id]) {
return LayoutUnit._instances[id];
}
return false;
};
pega.extend(LayoutUnit, pega.util.Element, {
/**
* @property STR_CLOSE
* @description String used for close button title
* @type {String}
*/
STR_CLOSE: 'Click to close this pane.',
/**
* @property STR_COLLAPSE
* @description String used for collapse button title
* @type {String}
*/
STR_COLLAPSE: 'Click to collapse this pane.',
/**
* @property STR_EXPAND
* @description String used for expand button title
* @type {String}
*/
STR_EXPAND: 'Click to expand this pane.',
/**
* @property browser
* @description A modified version of the pega.env.ua object
* @type Object
*/
browser: null,
/**
* @private
* @property _sizes
* @description A collection of the current sizes of the contents of this Layout Unit
* @type Object
*/
_sizes: null,
/**
* @private
* @property _anim
* @description A reference to the Animation instance used by this LayouUnit
* @type pega.util.Anim
*/
_anim: null,
/**
* @private
* @property _resize
* @description A reference to the Resize instance used by this LayoutUnit
* @type pega.util.Resize
*/
_resize: null,
/**
* @private
* @property _clip
* @description A reference to the clip element used when collapsing the unit
* @type HTMLElement
*/
_clip: null,
/**
* @private
* @property _gutter
* @description A simple hash table used to store the gutter to apply to the Unit
* @type Object
*/
_gutter: null,
/**
* @property header
* @description A reference to the HTML element used for the Header
* @type HTMLELement
*/
header: null,
/**
* @property body
* @description A reference to the HTML element used for the body
* @type HTMLElement
*/
body: null,
/**
* @property footer
* @description A reference to the HTML element used for the footer
* @type HTMLElement
*/
footer: null,
/**
* @private
* @property _collapsed
* @description Flag to determine if the unit is collapsed or not.
* @type Boolean
*/
_collapsed: null,
/**
* @private
* @property _collapsing
* @description A flag set while the unit is being collapsed, used so we don't fire events while animating the size
* @type Boolean
*/
_collapsing: null,
/**
* @private
* @property _lastWidth
* @description A holder for the last known width of the unit
* @type Number
*/
_lastWidth: null,
/**
* @private
* @property _lastHeight
* @description A holder for the last known height of the unit
* @type Number
*/
_lastHeight: null,
/**
* @private
* @property _lastTop
* @description A holder for the last known top of the unit
* @type Number
*/
_lastTop: null,
/**
* @private
* @property _lastLeft
* @description A holder for the last known left of the unit
* @type Number
*/
_lastLeft: null,
/**
* @private
* @property _lastScroll
* @description A holder for the last known scroll state of the unit
* @type Boolean
*/
_lastScroll: null,
/**
* @private
* @property _lastCenetrScroll
* @description A holder for the last known scroll state of the center unit
* @type Boolean
*/
_lastCenterScroll: null,
/**
* @private
* @property _lastScrollTop
* @description A holder for the last known scrollTop state of the unit
* @type Number
*/
_lastScrollTop: null,
/**
* @method resize
* @description Resize either the unit or it's clipped state, also updating the box inside
* @param {Boolean} force This will force full calculations even when the unit is collapsed
* @return {<a href="pega.widget.LayoutUnit.html">pega.widget.LayoutUnit</a>} The LayoutUnit instance
*/
resize: function(force) {
var retVal = this.fireEvent('beforeResize');
if (retVal === false) {
return this;
}
if (!this._collapsing || (force === true)) {
var scroll = this.get('scroll');
/** Commenting this call -- Equivalent statements are written below **/
/* this.set('scroll', false); */
/** NEW code starts here **/
this.body.firstChild.setAttribute("scroll", false);
this.addClass('yui-layout-scroll');
this.removeClass('yui-layout-noscroll');
/** NEW code ends here **/
var hd = this._getBoxSize(this.header),
ft = this._getBoxSize(this.footer),
box = [this.get('height'), this.get('width')];
var nh = (box[0] - hd[0] - ft[0]) - (this._gutter.top + this._gutter.bottom),
nw = box[1] - (this._gutter.left + this._gutter.right);
var wrapH = (nh + (hd[0] + ft[0])),
wrapW = nw;
if (this._collapsed && !this._collapsing) {
this._setHeight(this._clip, wrapH);
this._setWidth(this._clip, wrapW);
Dom.setStyle(this._clip, 'top', this.get('top') + this._gutter.top + 'px');
Dom.setStyle(this._clip, 'left', this.get('left') + this._gutter.left + 'px');
} else if (!this._collapsed || (this._collapsed && this._collapsing)) {
wrapH = this._setHeight(this.get('wrap'), wrapH);
wrapW = this._setWidth(this.get('wrap'), wrapW);
this._sizes.wrap.h = wrapH;
this._sizes.wrap.w = wrapW;
Dom.setStyle(this.get('wrap'), 'top', this._gutter.top + 'px');
Dom.setStyle(this.get('wrap'), 'left', this._gutter.left + 'px');
this._sizes.header.w = this._setWidth(this.header, wrapW);
this._sizes.header.h = hd[0];
this._sizes.footer.w = this._setWidth(this.footer, wrapW);
this._sizes.footer.h = ft[0];
Dom.setStyle(this.footer, 'bottom', '0px');
this._sizes.body.h = this._setHeight(this.body, (wrapH - (hd[0] + ft[0])));
this._sizes.body.w =this._setWidth(this.body, wrapW);
Dom.setStyle(this.body, 'top', hd[0] + 'px');
/** Commenting this call -- Equivalent statements are written below **/
/*this.set('scroll', scroll);*/
/** NEW code starts here **/
this.body.firstChild.setAttribute("scroll", scroll);
this.addClass('yui-layout-scroll');
/** NEW code ends here **/
this.fireEvent('resize');
}
}
return this;
},
/**
* @private
* @method _setWidth
* @description Sets the width of the element based on the border size of the element.
* @param {HTMLElement} el The HTMLElement to have it's width set
* @param {Number} w The width that you want it the element set to
* @return {Number} The new width, fixed for borders and IE QuirksMode
*/
_setWidth: function(el, w) {
if (el) {
Dom.setStyle(el, 'width', w + 'px');
}
return w;
},
/**
* @private
* @method _setHeight
* @description Sets the height of the element based on the border size of the element.
* @param {HTMLElement} el The HTMLElement to have it's height set
* @param {Number} h The height that you want it the element set to
* @return {Number} The new height, fixed for borders and IE QuirksMode
*/
_setHeight: function(el, h) {
if (el) {
var b = this._getBorderSizes(el);
h = (h - (b[0] + b[2]));
h = this._fixQuirks(el, h, 'h');
Dom.setStyle(el, 'height', h + 'px');
}
return h;
},
/**
* @private
* @method _fixQuirks
* @description Fixes the box calculations for IE in QuirksMode
* @param {HTMLElement} el The HTMLElement to set the dimension on
* @param {Number} dim The number of the dimension to fix
* @param {String} side The dimension (h or w) to fix. Defaults to h
* @return {Number} The fixed dimension
*/
_fixQuirks: function(el, dim, side) {
var i1 = 0, i2 = 2;
if (side == 'w') {
i1 = 1;
i2 = 3;