19
19
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
//
22
- // VERSION 1.3
22
+ // VERSION 1.4b
23
23
24
24
var Window = Class . create ( ) ;
25
25
@@ -56,7 +56,6 @@ Window.prototype = {
56
56
57
57
this . options = Object . extend ( {
58
58
className : "dialog" ,
59
- windowClassName : null ,
60
59
blurClassName : null ,
61
60
minWidth : 100 ,
62
61
minHeight : 20 ,
@@ -80,7 +79,6 @@ Window.prototype = {
80
79
opacity : 1 ,
81
80
recenterAuto : true ,
82
81
wiredDrag : false ,
83
- closeOnEsc : true ,
84
82
closeCallback : null ,
85
83
destroyOnClose : false ,
86
84
gridX : 1 ,
@@ -123,8 +121,6 @@ Window.prototype = {
123
121
this . eventOnLoad = this . _getWindowBorderSize . bindAsEventListener ( this ) ;
124
122
this . eventMouseDownContent = this . toFront . bindAsEventListener ( this ) ;
125
123
this . eventResize = this . _recenter . bindAsEventListener ( this ) ;
126
- this . eventKeyUp = this . _keyUp . bindAsEventListener ( this ) ;
127
-
128
124
this . topbar = $ ( this . element . id + "_top" ) ;
129
125
this . bottombar = $ ( this . element . id + "_bottom" ) ;
130
126
this . content = $ ( this . element . id + "_content" ) ;
@@ -135,7 +131,6 @@ Window.prototype = {
135
131
Event . observe ( window , "load" , this . eventOnLoad ) ;
136
132
Event . observe ( window , "resize" , this . eventResize ) ;
137
133
Event . observe ( window , "scroll" , this . eventResize ) ;
138
- Event . observe ( document , "keyup" , this . eventKeyUp ) ;
139
134
Event . observe ( this . options . parent , "scroll" , this . eventResize ) ;
140
135
141
136
if ( this . options . draggable ) {
@@ -179,11 +174,8 @@ Window.prototype = {
179
174
this . storedLocation = null ;
180
175
181
176
this . setOpacity ( this . options . opacity ) ;
182
- if ( this . options . zIndex ) {
177
+ if ( this . options . zIndex )
183
178
this . setZIndex ( this . options . zIndex )
184
- } else {
185
- this . setZIndex ( this . getMaxZIndex ( ) ) ;
186
- }
187
179
188
180
if ( this . options . destroyOnClose )
189
181
this . setDestroyOnClose ( true ) ;
@@ -201,20 +193,6 @@ Window.prototype = {
201
193
this . setTitle ( this . options . title )
202
194
Windows . register ( this ) ;
203
195
} ,
204
-
205
- getMaxZIndex : function ( ) {
206
- var max = 0 , i ;
207
- var cn = document . body . childNodes ;
208
- for ( i = 0 ; i < cn . length ; i ++ ) {
209
- var el = cn [ i ] ;
210
- var zIndex = el . nodeType == 1 ? parseInt ( el . style . zIndex , 10 ) || 0 : 0 ;
211
- if ( zIndex < 10000 ) {
212
- max = Math . max ( max , zIndex ) ;
213
- }
214
- }
215
- return max + 10 ;
216
- } ,
217
-
218
196
// Destructor
219
197
destroy : function ( ) {
220
198
this . _notify ( "onDestroy" ) ;
@@ -225,9 +203,9 @@ Window.prototype = {
225
203
Event . stopObserving ( window , "load" , this . eventOnLoad ) ;
226
204
Event . stopObserving ( window , "resize" , this . eventResize ) ;
227
205
Event . stopObserving ( window , "scroll" , this . eventResize ) ;
206
+ Event . stopObserving ( this . options . parent , "scroll" , this . eventResize ) ;
228
207
229
208
Event . stopObserving ( this . content , "load" , this . options . onload ) ;
230
- Event . stopObserving ( document , "keyup" , this . eventKeyUp ) ;
231
209
232
210
if ( this . _oldParent ) {
233
211
var content = this . getContent ( ) ;
@@ -248,7 +226,8 @@ Window.prototype = {
248
226
249
227
if ( this . options . url )
250
228
this . content . src = null
251
-
229
+ if ( this . wiredElement )
230
+ this . wiredElement . remove ( ) ;
252
231
if ( this . iefix )
253
232
Element . remove ( this . iefix ) ;
254
233
@@ -304,8 +283,8 @@ Window.prototype = {
304
283
305
284
this . content = $ ( this . element . id + "_content" ) ;
306
285
}
307
-
308
- this . getContent ( ) . innerHTML = html ;
286
+ this . getContent ( ) . update ( html ) ;
287
+ return this ;
309
288
} ,
310
289
311
290
setAjaxContent : function ( url , options , showCentered , showModal ) {
@@ -610,9 +589,6 @@ Window.prototype = {
610
589
var win = document . createElement ( "div" ) ;
611
590
win . setAttribute ( 'id' , id ) ;
612
591
win . className = "dialog" ;
613
- if ( this . options . windowClassName ) {
614
- win . className += ' ' + this . options . windowClassName ;
615
- }
616
592
617
593
var content ;
618
594
if ( this . options . url )
@@ -627,7 +603,6 @@ Window.prototype = {
627
603
var blank = "../themes/default/blank.gif" ;
628
604
629
605
win . innerHTML = closeDiv + minDiv + maxDiv + "\
630
- <a href='#' id='" + id + "_focus_anchor'><!-- --></a>\
631
606
<table id='" + id + "_row1' class=\"top table_window\">\
632
607
<tr>\
633
608
<td class='" + className + "_nw'></td>\
@@ -660,10 +635,12 @@ Window.prototype = {
660
635
changeClassName : function ( newClassName ) {
661
636
var className = this . options . className ;
662
637
var id = this . getId ( ) ;
663
- $A ( [ "_close" , "_minimize" , "_maximize" , "_sizer" , " _content"] ) . each ( function ( value ) { this . _toggleClassName ( $ ( id + value ) , className + value , newClassName + value ) } . bind ( this ) ) ;
638
+ $A ( [ "_close" , "_minimize" , "_maximize" , "_content" ] ) . each ( function ( value ) { this . _toggleClassName ( $ ( id + value ) , className + value , newClassName + value ) } . bind ( this ) ) ;
664
639
this . _toggleClassName ( $ ( id + "_top" ) , className + "_title" , newClassName + "_title" ) ;
665
640
$$ ( "#" + id + " td" ) . each ( function ( td ) { td . className = td . className . sub ( className , newClassName ) ; } ) ;
666
641
this . options . className = newClassName ;
642
+ this . _getWindowBorderSize ( ) ;
643
+ this . setSize ( this . width , this . height )
667
644
} ,
668
645
669
646
_toggleClassName : function ( element , oldClassName , newClassName ) {
@@ -822,7 +799,6 @@ Window.prototype = {
822
799
this . _checkIEOverlapping ( ) ;
823
800
WindowUtilities . focusedWindow = this
824
801
this . _notify ( "onShow" ) ;
825
- $ ( this . element . id + '_focus_anchor' ) . focus ( ) ;
826
802
} ,
827
803
828
804
// Displays window modal state or not at the center of the page
@@ -917,12 +893,15 @@ Window.prototype = {
917
893
} ,
918
894
919
895
minimize : function ( ) {
920
- if ( this . resizing )
896
+ if ( this . isMaximized ( ) || this . resizing )
921
897
return ;
922
898
899
+ // Backward compatibility
900
+ if ( this . minimized ) {
901
+ this . restore ( ) ;
902
+ return ;
903
+ }
923
904
var r2 = $ ( this . getId ( ) + "_row2" ) ;
924
-
925
- if ( ! this . minimized ) {
926
905
this . minimized = true ;
927
906
928
907
var dh = r2 . getDimensions ( ) . height ;
@@ -936,13 +915,21 @@ Window.prototype = {
936
915
this . element . setStyle ( { height : h + "px" } ) ;
937
916
r2 . hide ( ) ;
938
917
}
939
-
940
918
if ( ! this . useTop ) {
941
919
var bottom = parseFloat ( this . element . getStyle ( 'bottom' ) ) ;
942
920
this . element . setStyle ( { bottom : ( bottom + dh ) + 'px' } ) ;
943
921
}
944
- }
945
- else {
922
+ this . _notify ( "onMinimize" ) ;
923
+
924
+ // Store new location/size if need be
925
+ this . _saveCookie ( )
926
+ } ,
927
+
928
+ restore : function ( ) {
929
+ if ( ! this . minimized || this . resizing )
930
+ return ;
931
+
932
+ var r2 = $ ( this . getId ( ) + "_row2" ) ;
946
933
this . minimized = false ;
947
934
948
935
var dh = this . r2Height ;
@@ -961,11 +948,9 @@ Window.prototype = {
961
948
this . element . setStyle ( { bottom : ( bottom - dh ) + 'px' } ) ;
962
949
}
963
950
this . toFront ( ) ;
964
- }
965
- this . _notify ( "onMinimize" ) ;
966
951
967
952
// Store new location/size if need be
968
- this . _saveCookie ( )
953
+ this . _saveCookie ( ) ;
969
954
} ,
970
955
971
956
maximize : function ( ) {
@@ -1013,8 +998,8 @@ Window.prototype = {
1013
998
}
1014
999
else {
1015
1000
this . setSize ( width , height ) ;
1016
- this . element . setStyle ( this . useLeft ? { left : left } : { right : left } ) ;
1017
- this . element . setStyle ( this . useTop ? { top : top } : { bottom : top } ) ;
1001
+ this . element . setStyle ( this . useLeft ? { left : left + "px" } : { right : left + "px" } ) ;
1002
+ this . element . setStyle ( this . useTop ? { top : top + "px" } : { bottom : top + "px" } ) ;
1018
1003
}
1019
1004
1020
1005
this . toFront ( ) ;
@@ -1084,12 +1069,6 @@ Window.prototype = {
1084
1069
this . iefix . show ( ) ;
1085
1070
} ,
1086
1071
1087
- _keyUp : function ( event ) {
1088
- if ( 27 == event . keyCode && this . options . closeOnEsc ) {
1089
- this . close ( ) ;
1090
- }
1091
- } ,
1092
-
1093
1072
_getWindowBorderSize : function ( event ) {
1094
1073
// Hack to get real window border size!!
1095
1074
var div = this . _createHiddenDiv ( this . options . className + "_n" )
@@ -1291,11 +1270,6 @@ var Windows = {
1291
1270
this . focusedWindow = this . windows . length >= 2 ? this . windows [ this . windows . length - 2 ] : null ;
1292
1271
} ,
1293
1272
1294
- // Registers a new window (called by Windows constructor)
1295
- register : function ( win ) {
1296
- this . windows . push ( win ) ;
1297
- } ,
1298
-
1299
1273
// Add a modal window in the stack
1300
1274
addModalWindow : function ( win ) {
1301
1275
// Disable screen if first modal window
@@ -1449,14 +1423,13 @@ var Dialog = {
1449
1423
1450
1424
parameters . className = parameters . className || "alert" ;
1451
1425
1452
- var okButtonClass = "class ='" + ( parameters . buttonClass ? parameters . buttonClass + " " : "" ) + " ok_button'" ;
1453
- var cancelButtonClass = "class ='" + ( parameters . buttonClass ? parameters . buttonClass + " " : "" ) + " cancel_button'" ;
1454
-
1426
+ var okButtonClass = "class ='" + ( parameters . buttonClass ? parameters . buttonClass + " " : "" ) + " ok_button'"
1427
+ var cancelButtonClass = "class ='" + ( parameters . buttonClass ? parameters . buttonClass + " " : "" ) + " cancel_button'"
1455
1428
var content = "\
1456
1429
<div class='" + parameters . className + "_message'>" + content + "</div>\
1457
1430
<div class='" + parameters . className + "_buttons'>\
1458
- <button type='button' title ='" + okLabel + "' onclick='Dialog.okCallback()' " + okButtonClass + "><span><span><span>" + okLabel + "</span></span></span></button >\
1459
- <button type='button' title ='" + cancelLabel + "' onclick='Dialog.cancelCallback()' " + cancelButtonClass + "><span><span><span>" + cancelLabel + "</span></span></span></button >\
1431
+ <input type='button' value ='" + okLabel + "' onclick='Dialog.okCallback()' " + okButtonClass + "/ >\
1432
+ <input type='button' value ='" + cancelLabel + "' onclick='Dialog.cancelCallback()' " + cancelButtonClass + "/ >\
1460
1433
</div>\
1461
1434
" ;
1462
1435
return this . _openDialog ( content , parameters )
@@ -1479,11 +1452,11 @@ var Dialog = {
1479
1452
1480
1453
parameters . className = parameters . className || "alert" ;
1481
1454
1482
- var okButtonClass = "class ='" + ( parameters . buttonClass ? parameters . buttonClass + " " : "" ) + " ok_button'" ;
1455
+ var okButtonClass = "class ='" + ( parameters . buttonClass ? parameters . buttonClass + " " : "" ) + " ok_button'"
1483
1456
var content = "\
1484
1457
<div class='" + parameters . className + "_message'>" + content + "</div>\
1485
1458
<div class='" + parameters . className + "_buttons'>\
1486
- <button type='button' title ='" + okLabel + "' onclick='Dialog.okCallback()' " + okButtonClass + "><span><span><span>" + okLabel + "</span></span></span></button >\
1459
+ <input type='button' value ='" + okLabel + "' onclick='Dialog.okCallback()' " + okButtonClass + "/ >\
1487
1460
</div>" ;
1488
1461
return this . _openDialog ( content , parameters )
1489
1462
} ,
@@ -1525,7 +1498,7 @@ var Dialog = {
1525
1498
var className = parameters . className ;
1526
1499
1527
1500
if ( ! parameters . height && ! parameters . width ) {
1528
- parameters . width = WindowUtilities . getPageSize ( parameters . options . parent || document . body ) . pageWidth / 2 ;
1501
+ parameters . width = WindowUtilities . getPageSize ( ( parameters . options && parameters . options . parent ) || document . body ) . pageWidth / 2 ;
1529
1502
}
1530
1503
if ( parameters . id )
1531
1504
this . dialogId = parameters . id ;
@@ -1551,8 +1524,9 @@ var Dialog = {
1551
1524
parameters . closable = parameters . closable || false ;
1552
1525
1553
1526
var win = new Window ( parameters ) ;
1554
- win . getContent ( ) . innerHTML = content ;
1555
-
1527
+ if ( ! parameters . url ) {
1528
+ win . setHTMLContent ( content ) ;
1529
+ }
1556
1530
win . showCenter ( true , parameters . top , parameters . left ) ;
1557
1531
win . setDestroyOnClose ( ) ;
1558
1532
@@ -1678,7 +1652,7 @@ var WindowUtilities = {
1678
1652
1679
1653
1680
1654
if ( self . innerHeight ) { // all except Explorer
1681
- windowWidth = document . documentElement . clientWidth ; // self.innerWidth;
1655
+ windowWidth = self . innerWidth ;
1682
1656
windowHeight = self . innerHeight ;
1683
1657
} else if ( document . documentElement && document . documentElement . clientHeight ) { // Explorer 6 Strict Mode
1684
1658
windowWidth = document . documentElement . clientWidth ;
@@ -1822,7 +1796,7 @@ var WindowUtilities = {
1822
1796
1823
1797
setCookie : function ( value , parameters ) {
1824
1798
document . cookie = parameters [ 0 ] + "=" + escape ( value ) +
1825
- ( ( parameters [ 1 ] ) ? "; expires=" + parameters [ 1 ] . toUTCString ( ) : "" ) +
1799
+ ( ( parameters [ 1 ] ) ? "; expires=" + parameters [ 1 ] . toGMTString ( ) : "" ) +
1826
1800
( ( parameters [ 2 ] ) ? "; path=" + parameters [ 2 ] : "" ) +
1827
1801
( ( parameters [ 3 ] ) ? "; domain=" + parameters [ 3 ] : "" ) +
1828
1802
( ( parameters [ 4 ] ) ? "; secure" : "" ) ;
@@ -1861,7 +1835,7 @@ var WindowUtilities = {
1861
1835
tmpObj . style . left = '0' ;
1862
1836
tmpObj . style . display = 'none' ;
1863
1837
1864
- tmpObj . innerHTML = content ;
1838
+ tmpObj . innerHTML = content . stripScripts ( ) ;
1865
1839
objBody . insertBefore ( tmpObj , objBody . firstChild ) ;
1866
1840
1867
1841
var size ;
0 commit comments