温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:博客源代码(课程设计,3层架构)
当前文件:
MVCBlog/fckeditor/editor/fckdialog.html,打开代码结构图
MVCBlog/fckeditor/editor/fckdialog.html,打开代码结构图1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2
<!-- 3
* FCKeditor - The text editor for Internet - http://www.fckeditor.net 4
* Copyright (C) 2003-2008 Frederico Caldeira Knabben 5
* 6
* == BEGIN LICENSE == 7
* 8
* Licensed under the terms of any of the following licenses at your 9
* choice: 10
* 11
* - GNU General Public License Version 2 or later (the "GPL") 12
* http://www.gnu.org/licenses/gpl.html 13
* 14
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL") 15
* http://www.gnu.org/licenses/lgpl.html 16
* 17
* - Mozilla Public License Version 1.1 or later (the "MPL") 18
* http://www.mozilla.org/MPL/MPL-1.1.html 19
* 20
* == END LICENSE == 21
* 22
* This page is used by all dialog box as the container. 23
--> 24
<html xmlns="http://www.w3.org/1999/xhtml"> 25
<head> 26
<title></title> 27
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 28
<meta name="robots" content="noindex, nofollow" /> 29
<script type="text/javascript"> 30
// Domain relaxation logic. 31
(function() 32
{ 33
var d = document.domain ; 34
35
while ( true ) 36
{ 37
// Test if we can access a parent property. 38
try 39
{ 40
var parentDomain = ( Args().TopWindow || E ).document.domain ; 41
42
if ( document.domain != parentDomain ) 43
document.domain = parentDomain ; 44
45
break ; 46
} 47
catch( e ) {} 48
49
// Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ... 50
d = d.replace( /.*?(?:\.|$)/, '' ) ; 51
52
if ( d.length == 0 ) 53
break ; // It was not able to detect the domain. 54
55
document.domain = d ; 56
} 57
})() ; 58
59
var E = frameElement._DialogArguments.Editor ; 60
61
// It seems referencing to frameElement._DialogArguments directly would lead to memory leaks in IE. 62
// So let's use functions to access its members instead. 63
function Args() 64
{ 65
return frameElement._DialogArguments ; 66
} 67
68
function ParentDialog( dialog ) 69
{ 70
return dialog ? dialog._ParentDialog : frameElement._ParentDialog ; 71
} 72
73
var FCK = E.FCK ; 74
var FCKTools = E.FCKTools ; 75
var FCKDomTools = E.FCKDomTools ; 76
var FCKDialog = E.FCKDialog ; 77
var FCKBrowserInfo = E.FCKBrowserInfo ; 78
var FCKConfig = E.FCKConfig ; 79
80
// Steal the focus so that the caret would no longer stay in the editor iframe. 81
window.focus() ; 82
83
// Sets the Skin CSS 84
document.write( FCKTools.GetStyleHtml( FCKConfig.SkinDialogCSS ) ) ; 85
86
// Sets the language direction. 87
var langDir = document.documentElement.dir = E.FCKLang.Dir ; 88
89
// For IE6-, the fck_dialog_ie6.js is loaded, used to fix limitations in the browser. 90
if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 ) 91
document.write( '<' + 'script type="text/javascript" src="' + FCKConfig.SkinPath + 'fck_dialog_ie6.js"><' + '\/script>' ) ; 92
93
FCKTools.RegisterDollarFunction( window ) ; 94
95
// Resize related functions. 96
var Sizer = function() 97
{ 98
var bAutoSize = false ; 99
100
var retval = { 101
// Sets whether the dialog should auto-resize according to its content's height. 102
SetAutoSize : function( autoSize ) 103
{ 104
bAutoSize = autoSize ; 105
this.RefreshSize() ; 106
}, 107
108
// Fit the dialog container's layout to the inner iframe's external size. 109
RefreshContainerSize : function() 110
{ 111
var frmMain = $( 'frmMain' ) ; 112
113
if ( frmMain ) 114
{ 115
// Get the container size. 116
var height = $( 'contents' ).offsetHeight ; 117
118
// Subtract the size of other elements. 119
height -= $( 'TitleArea' ).offsetHeight ; 120
height -= $( 'TabsRow' ).offsetHeight ; 121
height -= $( 'PopupButtons' ).offsetHeight ; 122
123
frmMain.style.height = Math.max( height, 0 ) + 'px' ; 124
} 125
}, 126
127
// Resize and re-layout the dialog. 128
// Triggers the onresize event for the layout logic. 129
ResizeDialog : function( width, height ) 130
{ 131
FCKDomTools.SetElementStyles( window.frameElement, 132
{ 133
'width' : width + 'px', 134
'height' : height + 'px' 135
} ) ; 136
137
// If the skin have defined a function for resize fixes, call it now. 138
if ( typeof window.DoResizeFixes == 'function' ) 139
window.DoResizeFixes() ; 140
}, 141
142
// if bAutoSize is true, automatically fit the dialog size and layout to 143
// accomodate the inner iframe's internal height. 144
// if bAutoSize is false, then only the layout logic for the dialog decorations 145
// is run to accomodate the inner iframe's external height. 146
RefreshSize : function() 147
{ 148
if ( bAutoSize ) 149
{ 150
var frmMain = $( 'frmMain' ) ; 151
var innerDoc = frmMain.contentWindow.document ; 152
var isStrict = FCKTools.IsStrictMode( innerDoc ) ; 153
154
// Get the size of the frame contents. 155
var innerWidth = isStrict ? innerDoc.documentElement.scrollWidth : innerDoc.body.scrollWidth ; 156
var innerHeight = isStrict ? innerDoc.documentElement.scrollHeight : innerDoc.body.scrollHeight ; 157
158
// Get the current frame size. 159
var frameSize = FCKTools.GetViewPaneSize( frmMain.contentWindow ) ; 160
161
var deltaWidth = innerWidth - frameSize.Width ; 162
var deltaHeight = innerHeight - frameSize.Height ; 163
164
// If the contents fits the current size. 165
if ( deltaWidth <= 0 && deltaHeight <= 0 ) 166
return ; 167
168
var dialogWidth = frameElement.offsetWidth + Math.max( deltaWidth, 0 ) ; 169
var dialogHeight = frameElement.offsetHeight + Math.max( deltaHeight, 0 ) ; 170
171
this.ResizeDialog( dialogWidth, dialogHeight ) ; 172
} 173
this.RefreshContainerSize() ; 174
} 175
} 176
177
/** 178
* Safari seems to have a bug with the time when RefreshSize() is executed - it 179
* thinks frmMain's innerHeight is 0 if we query the value too soon after the 180
* page is loaded in some circumstances. (#1316) 181
* TODO : Maybe this is not needed anymore after #35. 182
*/ 183
if ( FCKBrowserInfo.IsSafari ) 184
{ 185
var originalRefreshSize = retval.RefreshSize ; 186
187
retval.RefreshSize = function() 188
{ 189
FCKTools.SetTimeout( originalRefreshSize, 1, retval ) ; 190
} 191
} 192
193
window.onresize = function() 194
{ 195
retval.RefreshContainerSize() ; 196
} 197
198
window.SetAutoSize = FCKTools.Bind( retval, retval.SetAutoSize ) ; 199
200
return retval ; 201
}() ; 202
203
// Manages the throbber image that appears if the inner part of dialog is taking too long to load. 204
var Throbber = function() 205
{ 206
var timer ; 207
208
var updateThrobber = function() 209
{ 210
var throbberParent = $( 'throbberBlock' ) ; 211
var throbberBlocks = throbberParent.childNodes ; 212
var lastClass = throbberParent.lastChild.className ; 213
214
// From the last to the second one, copy the class from the previous one. 215
for ( var i = throbberBlocks.length - 1 ; i > 0 ; i-- ) 216
throbberBlocks[i].className = throbberBlocks[i-1].className ; 217
218
// For the first one, copy the last class (rotation). 219
throbberBlocks[0].className = lastClass ; 220
} 221
222
return { 223
Show : function( waitMilliseconds ) 224
{ 225
// Auto-setup the Show function to be called again after the 226
// requested amount of time. 227
if ( waitMilliseconds && waitMilliseconds > 0 ) 228
{ 229
timer = FCKTools.SetTimeout( this.Show, waitMilliseconds, this, null, window ) ; 230
return ; 231
} 232
233
var throbberParent = $( 'throbberBlock' ) ; 234
235
// Create the throbber blocks. 236
var classIds = [ 1,2,3,4,5,4,3,2 ] ; 237
while ( classIds.length > 0 ) 238
throbberParent.appendChild( document.createElement( 'div' ) ).className = ' throbber_' + classIds.shift() ; 239
240
// Center the throbber. 241
var frm = $( 'contents' ) ; 242
var frmCoords = FCKTools.GetDocumentPosition( window, frm ) ; 243
var x = frmCoords.x + ( frm.offsetWidth - throbberParent.offsetWidth ) / 2 ; 244
var y = frmCoords.y + ( frm.offsetHeight - throbberParent.offsetHeight ) / 2 ; 245
throbberParent.style.left = parseInt( x, 10 ) + 'px' ; 246
throbberParent.style.top = parseInt( y, 10 ) + 'px' ; 247
248
// Show it. 249
throbberParent.style.visibility = '' ; 250
251
// Setup the animation interval. 252
timer = setInterval( updateThrobber, 100 ) ; 253
}, 254
255
Hide : function() 256
{ 257
if ( timer ) 258
{ 259
clearInterval( timer ) ; 260
timer = null ; 261
![]()






}