温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:WO@BIZ第一季1.2版源码
当前文件:
WOBIZ/admin/Js/Wo_Modal.js,打开代码结构图
WOBIZ/admin/Js/Wo_Modal.js,打开代码结构图12
Wo_Modal = new Object(); 3
Wo_Modal._variableName = 'Wo_Modal'; 4
Wo_Modal.LoadingHtmlUrl = null; 5
Wo_Modal.WindowCssClasses = new Array(); 6
Wo_Modal.WindowTitleCssClasses = new Array(); 7
Wo_Modal.WindowCloseCssClasses = new Array(); 8
Wo_Modal.WindowContentCssClasses = new Array(); 9
Wo_Modal.WindowMaskCssClasses = new Array(); 10
Wo_Modal.WindowFooterCssClasses = new Array(); 11
Wo_Modal.WindowResizeCssClasses = new Array(); 12
Wo_Modal.ZIndex = 100; 13
Wo_Modal._isShown = false; 14
Wo_Modal._initialized = false; 15
Wo_Modal._modal = null; 16
Wo_Modal._modalTitle = null; 17
Wo_Modal._modalClose = null; 18
Wo_Modal._modalAnimationMask = null; 19
Wo_Modal._modalMask = null; 20
Wo_Modal._modalIframe = null; 21
Wo_Modal._modalResize = null; 22
Wo_Modal._modalFooter = null; 23
Wo_Modal._modalContent = null; 24
Wo_Modal._animationHandle = null; 25
Wo_Modal._isOpening = false; 26
Wo_Modal._hiddenSelects = null; 27
Wo_Modal._checkForScrollResizeHandle = null; 28
Wo_Modal._lastModalInfo = null; 29
Wo_Modal._lastWindowInfo = null; 30
Wo_Modal._isDragging = false; 31
Wo_Modal._moveModalInfo = null; 32
Wo_Modal._resizeModalInfo = null; 33
Wo_Modal._isResizing = false; 34
35
Wo_Modal.Configure = function(loadingHtmlUrl, windowCssClasses, windowTitleCssClasses, windowCloseCssClasses, windowContentCssClasses, windowFooterCssClasses, windowResizeCssClasses, windowMaskCssClasses, zIndex) 36
{ 37
this.LoadingHtmlUrl = loadingHtmlUrl; 38
this.WindowCssClasses = windowCssClasses; 39
this.WindowTitleCssClasses = windowTitleCssClasses; 40
this.WindowCloseCssClasses = windowCloseCssClasses; 41
this.WindowContentCssClasses = windowContentCssClasses; 42
this.WindowMaskCssClasses = windowMaskCssClasses; 43
this.WindowFooterCssClasses = windowFooterCssClasses; 44
this.WindowResizeCssClasses = windowResizeCssClasses; 45
this.ZIndex = zIndex; 46
} 47
48
Wo_Modal.IsShown = function() 49
{ 50
return this._isShown; 51
} 52
53
Wo_Modal._getWindowInfo = function() 54
{ 55
var scrollX = 0, scrollY = 0, width = 0, height = 0, contentWidth = 0, contentHeight = 0; 56
57
if (typeof(window.pageXOffset) == 'number') 58
{ 59
//Netscape compliant 60
scrollX = window.pageXOffset; 61
scrollY = window.pageYOffset; 62
} 63
else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) 64
{ 65
//DOM compliant 66
scrollX = document.body.scrollLeft; 67
scrollY = document.body.scrollTop; 68
} 69
else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) 70
{ 71
//IE6 standards compliant mode 72
scrollX = document.documentElement.scrollLeft; 73
scrollY = document.documentElement.scrollTop; 74
} 75
76
if (typeof(window.innerWidth) == 'number') 77
{ 78
//Non-IE 79
width = window.innerWidth; 80
height = window.innerHeight; 81
} 82
else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) 83
{ 84
//IE 6+ in 'standards compliant mode' 85
width = document.documentElement.clientWidth; 86
height = document.documentElement.clientHeight; 87
} 88
else if (document.body && (document.body.clientWidth || document.body.clientHeight)) 89
{ 90
//IE 4 compatible 91
width = document.body.clientWidth; 92
height = document.body.clientHeight; 93
} 94
95
if (document.documentElement && (document.documentElement.scrollHeight || document.documentElement.offsetHeight)) 96
{ 97
if (document.documentElement.scrollHeight > document.documentElement.offsetHeight) 98
{ 99
contentWidth = document.documentElement.scrollWidth; 100
contentHeight = document.documentElement.scrollHeight; 101
} 102
else 103
{ 104
contentWidth = document.documentElement.offsetWidth; 105
contentHeight = document.documentElement.offsetHeight; 106
} 107
} 108
else if (document.body && (document.body.scrollHeight || document.body.offsetHeight)) 109
{ 110
if (document.body.scrollHeight > document.body.offsetHeight) 111
{ 112
contentWidth = document.body.scrollWidth; 113
contentHeight = document.body.scrollHeight; 114
} 115
else 116
{ 117
contentWidth = document.body.offsetWidth; 118
contentHeight = document.body.offsetHeight; 119
} 120
} 121
else 122
{ 123
contentWidth = width; 124
contentHeight = height; 125
} 126
127
if (height > contentHeight) 128
height = contentHeight; 129
130
if (width > contentWidth) 131
width = contentWidth; 132
133
var rect = new Object(); 134
rect.ScrollX = scrollX; 135
rect.ScrollY = scrollY; 136
rect.Width = width; 137
rect.Height = height; 138
rect.ContentWidth = contentWidth; 139
rect.ContentHeight = contentHeight; 140
141
return rect; 142
} 143
144
Wo_Modal._getCurrentStyleValue = function(element, styleRule, jsStyleRule) 145
{ 146
var value = 0; 147
148
if(document.defaultView && document.defaultView.getComputedStyle) 149
value = parseInt(document.defaultView.getComputedStyle(element, "").getPropertyValue(styleRule), 0); 150
else if(element.currentStyle) 151
value = parseInt(element.currentStyle[jsStyleRule], 0); 152
153
if (!isNaN(value)) 154
return value; 155
else 156
return 0; 157
} 158
159
Wo_Modal._calculateStyleOffset = function(element) 160
{ 161
var result = new Object(); 162
163
result.Height = this._getCurrentStyleValue(element, 'border-top-width', 'borderTopWidth') + 164
this._getCurrentStyleValue(element, 'border-bottom-width', 'borderBottomWidth') + 165
this._getCurrentStyleValue(element, 'padding-top', 'paddingTop') + 166
this._getCurrentStyleValue(element, 'padding-bottom', 'paddingBottom'); 167
168
result.Width = this._getCurrentStyleValue(element, 'border-left-width', 'borderLeftWidth') + 169
this._getCurrentStyleValue(element, 'border-right-width', 'borderRightWidth') + 170
this._getCurrentStyleValue(element, 'padding-left', 'paddingLeft') + 171
this._getCurrentStyleValue(element, 'padding-right', 'paddingRight'); 172
173
return result; 174
} 175
176
Wo_Modal.Open = function (url, width, height, onCloseFunction, x, y, ignoreCloseAndAnimation) 177
{ 178
if (!ignoreCloseAndAnimation && this._isShown) 179
this.Close(); 180
else if (this._hiddenSelects) 181
{ 182
for (var i = 0; i < this._hiddenSelects.length; i++) 183
{ 184
if (this._hiddenSelects[i].Element.style.visibility == 'hidden') 185
this._hiddenSelects[i].Element.style.visibility = this._hiddenSelects[i].Visibility; 186
} 187
188
this._hiddenSelects = null; 189
} 190
191
if (!this._initialized) 192
this._initialize(); 193
194
try 195
{ 196
this._modalTitle.childNodes[1].innerHTML = this._modalIframe.contentWindow.document.title; 197
} 198
catch (err) 199
{ 200
} 201
202
if (!ignoreCloseAndAnimation) 203
this._modalIframe.src = url; 204
205
try 206
{ 207
this._modalIframe.contentWindow.opener = window; 208
} 209
catch (err) 210
{ 211
} 212
213
this._modalAnimationMask.style.display = 'none'; 214
this._modalMask.style.display = 'none'; 215
216
// retrieve the window info 217
this._lastWindowInfo = this._getWindowInfo(); 218
219
this._modalAnimationMask.style.display = 'block'; 220
221
// width/height of panel 222
if (width > this._lastWindowInfo.Width) 223
width = this._lastWindowInfo.Width; 224
225
this._modalAnimationMask.style.position = 'absolute'; 226
this._modalAnimationMask.style.zIndex = this.ZIndex; 227
this._modalAnimationMask.style.display = 'block'; 228
this._modalAnimationMask.style.visibility = 'hidden'; 229
this._modalAnimationMask.style.overflow = 'hidden'; 230
231
this._modalAnimationMask.style.width = width + 'px'; 232
this._modalContent.style.width = width + 'px'; 233
234
this._modal.style.position = 'absolute'; 235
this._modal.style.display = 'block'; 236
this._modal.style.visibility = 'hidden'; 237
this._modal.style.left = '0px'; 238
this._modal.style.top = '0px'; 239
240
this._modalMask.style.position = 'absolute'; 241
this._modalMask.style.display = 'block'; 242
this._modalMask.style.zIndex = this.ZIndex; 243
this._modalMask.style.visibility = 'visible'; 244
245
var modalContentOffset = this._calculateStyleOffset(this._modalContent); 246
247
var offset = (this._modal.offsetHeight - this._modalContent.offsetHeight) - modalContentOffset.Height; 248
if (height + offset > this._lastWindowInfo.Height) 249
height = this._lastWindowInfo.Height - offset; 250
251
if (width < this._modalResize.offsetWidth * 2) 252
width = this._modalResize.offsetWidth * 2; 253
254
if (width < this._modalClose.offsetWidth * 2) 255
width = this._modalClose.offsetWidth * 2; 256
257
if (height < this._modalTitle.offsetHeight + this._modalFooter.offsetHeight) 258
height = this._modalTitle.offsetHeight + this._modalFooter.offsetHeight; 259
260
this._modalIframe.style.height = height + 'px'; 261
this._modalContent.style.height = height + 'px'; 262
this._modalContent.style.width = (width - (this._modal.offsetWidth - this._modalContent.offsetWidth) - modalContentOffset.Width) + 'px'; 263
this._modalAnimationMask.style.width = width + 'px'; 264
this._modalAnimationMask.style.height = this._modal.offsetHeight + 'px'; 265
266
this._modalMask.style.left = '0px'; 267
this._modalMask.style.top = '0px'; 268
this._modalMask.style.width = this._lastWindowInfo.ContentWidth + 'px'; 269
this._modalMask.style.height = this._lastWindowInfo.ContentHeight + 'px'; 270
271
this._lastWindowInfo = this._getWindowInfo(); 272
273
var panelWidth = this._modal.offsetWidth; 274
var panelHeight = this._modal.offsetHeight; 275
var animatePropertyName, animateTargetValue, animateNextValue; 276
277
if (typeof(x) == 'undefined' || isNaN(parseInt(x, 10))) 278
x = ((this._lastWindowInfo.Width - panelWidth) / 2) + this._lastWindowInfo.ScrollX; 279
280
if (x + panelWidth > this._lastWindowInfo.Width + this._lastWindowInfo.ScrollX) 281
x = this._lastWindowInfo.Width + this._lastWindowInfo.ScrollX - panelWidth; 282
283
if (x < this._lastWindowInfo.ScrollX) 284
x = this._lastWindowInfo.ScrollX; 285
286
if (typeof(y) == 'undefined' || isNaN(parseInt(y, 10))) 287
y = ((this._lastWindowInfo.Height - panelHeight) / 2) + this._lastWindowInfo.ScrollY; 288
289
if (y + panelHeight > this._lastWindowInfo.Height + this._lastWindowInfo.ScrollY) 290
y = this._lastWindowInfo.Height + this._lastWindowInfo.ScrollY - panelHeight; 291
292
if (y < this._lastWindowInfo.ScrollY) 293
y = this._lastWindowInfo.ScrollY; 294
295
this._modalAnimationMask.style.left = x + 'px'; 296
this._modalAnimationMask.style.top = y + 'px'; 297
298
animateTargetValue = 0; 299
animateNextValue = -panelHeight; 300
301
this._modal.style.visibility = 'visible'; 302
this._modalAnimationMask.style.visibility = 'visible'; 303
this._modalAnimationMask.style.overflow = 'hidden'; 304
305
// detect and hide select boxes 306
if (this._modalAnimationMask.getClientRects) 307




}
}