[geeklog-cvs] Geeklog-1.x/public_html/fckeditor/editor/dialog fck_about.html, 1.7, 1.8 fck_anchor.html, 1.7, 1.8 fck_flash.html, 1.5, 1.6 fck_image.html, 1.8, 1.9 fck_link.html, 1.7, 1.8 fck_listprop.html, 1.6, 1.7 fck_paste.html, 1.6, 1.7 fck_replace.html, 1.5, 1.6 fck_spellerpages.html, 1.5, 1.6

Blaine Lang blaine at qs1489.pair.com
Sun Aug 10 12:46:30 EDT 2008


Update of /cvsroot/geeklog/Geeklog-1.x/public_html/fckeditor/editor/dialog
In directory qs1489.pair.com:/tmp/cvs-serv4567/editor/dialog

Modified Files:
	fck_about.html fck_anchor.html fck_flash.html fck_image.html 
	fck_link.html fck_listprop.html fck_paste.html 
	fck_replace.html fck_spellerpages.html 
Log Message:
Upgrade to FCKeditor ver 2.6.3

Index: fck_link.html
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/fckeditor/editor/dialog/fck_link.html,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** fck_link.html	5 May 2008 00:35:24 -0000	1.7
--- fck_link.html	10 Aug 2008 16:46:28 -0000	1.8
***************
*** 109,113 ****
  				<br />
  				<input id="btnUpload" type="submit" value="Send it to the Server" fckLang="DlgLnkBtnUpload" />
! 				<iframe name="UploadWindow" style="DISPLAY: none" src="javascript:void(0)"></iframe>
  			</form>
  		</div>
--- 109,115 ----
  				<br />
  				<input id="btnUpload" type="submit" value="Send it to the Server" fckLang="DlgLnkBtnUpload" />
! 				<script type="text/javascript">
! 					document.write( '<iframe name="UploadWindow" style="display: none" src="' + FCKTools.GetVoidUrl() + '"><\/iframe>' ) ;
! 				</script>
  			</form>
  		</div>

Index: fck_flash.html
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/fckeditor/editor/dialog/fck_flash.html,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** fck_flash.html	5 May 2008 00:35:24 -0000	1.5
--- fck_flash.html	10 Aug 2008 16:46:28 -0000	1.6
***************
*** 98,102 ****
  				<input id="btnUpload" type="submit" value="Send it to the Server" fckLang="DlgLnkBtnUpload" />
  				<script type="text/javascript">
! 					document.write( '<iframe name="UploadWindow" style="DISPLAY: none" src="' + FCKTools.GetVoidUrl() + '"></iframe>' ) ;
  				</script>
  			</form>
--- 98,102 ----
  				<input id="btnUpload" type="submit" value="Send it to the Server" fckLang="DlgLnkBtnUpload" />
  				<script type="text/javascript">
! 					document.write( '<iframe name="UploadWindow" style="DISPLAY: none" src="' + FCKTools.GetVoidUrl() + '"><\/iframe>' ) ;
  				</script>
  			</form>

Index: fck_spellerpages.html
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/fckeditor/editor/dialog/fck_spellerpages.html,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** fck_spellerpages.html	5 May 2008 00:35:24 -0000	1.5
--- fck_spellerpages.html	10 Aug 2008 16:46:28 -0000	1.6
***************
*** 53,57 ****
  {
  	if ( numberOCorrections > 0 )
! 		oEditor.FCK.SetData( document.getElementById('txtHtml').value ) ;
  	window.parent.Cancel() ;
  }
--- 53,62 ----
  {
  	if ( numberOCorrections > 0 )
! 	{
! 		oEditor.FCKUndo.SaveUndoStep() ;
! 		oEditor.FCK.EditorDocument.body.innerHTML = document.getElementById('txtHtml').value ;
! 		if ( oEditor.FCKBrowserInfo.IsIE )
! 			oEditor.FCKSelection.Collapse( true ) ;
! 	}
  	window.parent.Cancel() ;
  }

Index: fck_anchor.html
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/fckeditor/editor/dialog/fck_anchor.html,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** fck_anchor.html	5 May 2008 00:35:24 -0000	1.7
--- fck_anchor.html	10 Aug 2008 16:46:28 -0000	1.8
***************
*** 120,127 ****
  
  	if ( aNewAnchors.length == 0 )
! 	{
! 		// Nothing was selected, so now just create a normal A
! 		aNewAnchors.push( oEditor.FCK.InsertElement( 'a' ) ) ;
! 	}
  	else
  	{
--- 120,124 ----
  
  	if ( aNewAnchors.length == 0 )
! 			aNewAnchors.push( oEditor.FCK.InsertElement( 'a' ) ) ;
  	else
  	{
***************
*** 137,141 ****
  
  		// Set the name
! 		oAnchor.name = sNewName ;
  
  		// IE does require special processing to show the Anchor's image
--- 134,149 ----
  
  		// Set the name
! 		if ( FCKBrowserInfo.IsIE )
! 		{
! 			// Setting anchor names directly in IE will trash the HTML code stored
! 			// in FCKTempBin after undos. See #2263.
! 			var replaceAnchor = oEditor.FCK.EditorDocument.createElement( '<a name="' +
! 					FCKTools.HTMLEncode( sNewName ).replace( '"', '"' ) + '">' ) ;
! 			oEditor.FCKDomTools.MoveChildren( oAnchor, replaceAnchor ) ;
! 			oAnchor.parentNode.replaceChild( replaceAnchor, oAnchor ) ;
! 			oAnchor = replaceAnchor ;
! 		}
! 		else
! 			oAnchor.name = sNewName ;
  
  		// IE does require special processing to show the Anchor's image

Index: fck_listprop.html
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/fckeditor/editor/dialog/fck_listprop.html,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** fck_listprop.html	5 May 2008 00:35:24 -0000	1.6
--- fck_listprop.html	10 Aug 2008 16:46:28 -0000	1.7
***************
*** 68,72 ****
  	dialog.SetAutoSize( true ) ;
  
! 	SelectField( 'txtStartPosition' ) ;
  }
  
--- 68,72 ----
  	dialog.SetAutoSize( true ) ;
  
! 	SelectField( sListType == 'OL' ? 'txtStartPosition' : 'selBulleted' ) ;
  }
  

Index: fck_about.html
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/fckeditor/editor/dialog/fck_about.html,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** fck_about.html	5 May 2008 00:35:24 -0000	1.7
--- fck_about.html	10 Aug 2008 16:46:28 -0000	1.8
***************
*** 79,84 ****
  								<span fcklang="DlgAboutVersion">version</span>
  								<br />
! 								<b>2.6</b><br />
! 								Build 18638</td>
  						</tr>
  					</table>
--- 79,84 ----
  								<span fcklang="DlgAboutVersion">version</span>
  								<br />
! 								<b>2.6.3</b><br />
! 								Build 19836</td>
  						</tr>
  					</table>

Index: fck_paste.html
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/fckeditor/editor/dialog/fck_paste.html,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** fck_paste.html	5 May 2008 00:35:24 -0000	1.6
--- fck_paste.html	10 Aug 2008 16:46:28 -0000	1.7
***************
*** 65,69 ****
  		var eFrameSpace = document.getElementById( 'xFrameSpace' ) ;
  		eFrameSpace.innerHTML = '<iframe id="frmData" src="' + sFrameUrl + '" ' +
! 					'height="98%" width="99%" frameborder="0" style="border: #000000 1px; background-color: #ffffff"></iframe>' ;
  
  		var oFrame = eFrameSpace.firstChild ;
--- 65,69 ----
  		var eFrameSpace = document.getElementById( 'xFrameSpace' ) ;
  		eFrameSpace.innerHTML = '<iframe id="frmData" src="' + sFrameUrl + '" ' +
! 					'height="98%" width="99%" frameborder="0" style="border: #000000 1px; background-color: #ffffff"><\/iframe>' ;
  
  		var oFrame = eFrameSpace.firstChild ;
***************
*** 188,192 ****
  
  	html = html.replace(/<o:p>\s*<\/o:p>/g, '') ;
! 	html = html.replace(/<o:p>.*?<\/o:p>/g, ' ') ;
  
  	// Remove mso-xxx styles.
--- 188,192 ----
  
  	html = html.replace(/<o:p>\s*<\/o:p>/g, '') ;
! 	html = html.replace(/<o:p>[\s\S]*?<\/o:p>/g, ' ') ;
  
  	// Remove mso-xxx styles.
***************
*** 225,228 ****
--- 225,232 ----
  		html = html.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;
  
+ 	// Remove style, meta and link tags
+ 	html = html.replace( /<STYLE[^>]*>[\s\S]*?<\/STYLE[^>]*>/gi, '' ) ;
+ 	html = html.replace( /<(?:META|LINK)[^>]*>\s*/gi, '' ) ;
+ 
  	// Remove empty styles.
  	html =  html.replace( /\s*style="\s*"/gi, '' ) ;
***************
*** 235,250 ****
  	html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
  
! 	html = html.replace( /<SPAN\s*>(.*?)<\/SPAN>/gi, '$1' ) ;
  
! 	html = html.replace( /<FONT\s*>(.*?)<\/FONT>/gi, '$1' ) ;
  
  	// Remove XML elements and declarations
  	html = html.replace(/<\\?\?xml[^>]*>/gi, '' ) ;
  
  	// Remove Tags with XML namespace declarations: <o:p><\/o:p>
  	html = html.replace(/<\/?\w+:[^>]*>/gi, '' ) ;
  
  	// Remove comments [SF BUG-1481861].
! 	html = html.replace(/<\!--.*?-->/g, '' ) ;
  
  	html = html.replace( /<(U|I|STRIKE)> <\/\1>/g, ' ' ) ;
--- 239,257 ----
  	html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
  
! 	html = html.replace( /<SPAN\s*>([\s\S]*?)<\/SPAN>/gi, '$1' ) ;
  
! 	html = html.replace( /<FONT\s*>([\s\S]*?)<\/FONT>/gi, '$1' ) ;
  
  	// Remove XML elements and declarations
  	html = html.replace(/<\\?\?xml[^>]*>/gi, '' ) ;
  
+ 	// Remove w: tags with contents.
+ 	html = html.replace( /<w:[^>]*>[\s\S]*?<\/w:[^>]*>/gi, '' ) ;
+ 
  	// Remove Tags with XML namespace declarations: <o:p><\/o:p>
  	html = html.replace(/<\/?\w+:[^>]*>/gi, '' ) ;
  
  	// Remove comments [SF BUG-1481861].
! 	html = html.replace(/<\!--[\s\S]*?-->/g, '' ) ;
  
  	html = html.replace( /<(U|I|STRIKE)> <\/\1>/g, ' ' ) ;
***************
*** 253,257 ****
  
  	// Remove "display:none" tags.
! 	html = html.replace( /<(\w+)[^>]*\sstyle="[^"]*DISPLAY\s?:\s?none(.*?)<\/\1>/ig, '' ) ;
  
  	// Remove language tags
--- 260,264 ----
  
  	// Remove "display:none" tags.
! 	html = html.replace( /<(\w+)[^>]*\sstyle="[^"]*DISPLAY\s?:\s?none[\s\S]*?<\/\1>/ig, '' ) ;
  
  	// Remove language tags
***************
*** 268,273 ****
  
  		// Word likes to insert extra <font> tags, when using MSIE. (Wierd).
! 		html = html.replace( /<(H\d)><FONT[^>]*>(.*?)<\/FONT><\/\1>/gi, '<$1>$2<\/$1>' );
! 		html = html.replace( /<(H\d)><EM>(.*?)<\/EM><\/\1>/gi, '<$1>$2<\/$1>' );
  	}
  	else
--- 275,280 ----
  
  		// Word likes to insert extra <font> tags, when using MSIE. (Wierd).
! 		html = html.replace( /<(H\d)><FONT[^>]*>([\s\S]*?)<\/FONT><\/\1>/gi, '<$1>$2<\/$1>' );
! 		html = html.replace( /<(H\d)><EM>([\s\S]*?)<\/EM><\/\1>/gi, '<$1>$2<\/$1>' );
  	}
  	else
***************
*** 283,287 ****
  
  		// Transform <P> to <DIV>
! 		var re = new RegExp( '(<P)([^>]*>.*?)(<\/P>)', 'gi' ) ;	// Different because of a IE 5.0 error
  		html = html.replace( re, '<div$2<\/div>' ) ;
  
--- 290,294 ----
  
  		// Transform <P> to <DIV>
! 		var re = new RegExp( '(<P)([^>]*>[\\s\\S]*?)(<\/P>)', 'gi' ) ;	// Different because of a IE 5.0 error
  		html = html.replace( re, '<div$2<\/div>' ) ;
  

Index: fck_image.html
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/fckeditor/editor/dialog/fck_image.html,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** fck_image.html	5 May 2008 00:35:24 -0000	1.8
--- fck_image.html	10 Aug 2008 16:46:28 -0000	1.9
***************
*** 166,170 ****
  			<input id="btnUpload" type="submit" value="Send it to the Server" fcklang="DlgLnkBtnUpload" />
  			<script type="text/javascript">
! 				document.write( '<iframe name="UploadWindow" style="display: none" src="' + FCKTools.GetVoidUrl() + '"></iframe>' ) ;
  			</script>
  		</form>
--- 166,170 ----
  			<input id="btnUpload" type="submit" value="Send it to the Server" fcklang="DlgLnkBtnUpload" />
  			<script type="text/javascript">
! 				document.write( '<iframe name="UploadWindow" style="display: none" src="' + FCKTools.GetVoidUrl() + '"><\/iframe>' ) ;
  			</script>
  		</form>

Index: fck_replace.html
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/fckeditor/editor/dialog/fck_replace.html,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** fck_replace.html	5 May 2008 00:35:24 -0000	1.5
--- fck_replace.html	10 Aug 2008 16:46:28 -0000	1.6
***************
*** 35,38 ****
--- 35,44 ----
  
  var FCKLang = oEditor.FCKLang ;
+ var FCKDomTools = oEditor.FCKDomTools ;
+ var FCKDomRange = oEditor.FCKDomRange ;
+ var FCKListsLib = oEditor.FCKListsLib ;
+ var FCKTools = oEditor.FCKTools ;
+ var EditorDocument = oEditor.FCK.EditorDocument ;
+ var HighlightStyle = oEditor.FCKStyles.GetStyle( '_FCK_SelectionHighlight' )  ;
  
  dialog.AddTab( 'Find', FCKLang.DlgFindTitle ) ;
***************
*** 52,231 ****
  }
  
! // Place a range at the start of document.
! // This will be the starting point of our search.
! var GlobalRange = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
! 
! function ResetGlobalRange()
! {
! 	GlobalRange.SetStart( oEditor.FCK.EditorDocument.body, 1 ) ;
! 	GlobalRange.SetEnd( oEditor.FCK.EditorDocument.body, 1 ) ;
! 	GlobalRange.Collapse( true ) ;
! }
! ResetGlobalRange() ;
! 
! var HighlightRange = null ;
! function Highlight()
  {
! 	if ( HighlightRange )
! 		ClearHighlight() ;
! 	var cloneRange = GlobalRange.Clone() ;
! 	oEditor.FCKStyles.GetStyle( '_FCK_SelectionHighlight' ).ApplyToRange( cloneRange, false, true ) ;
! 	HighlightRange = cloneRange ;
! 	GlobalRange = HighlightRange.Clone() ;
  }
  
! function ClearHighlight()
  {
! 	if ( HighlightRange )
  	{
! 		oEditor.FCKStyles.GetStyle( '_FCK_SelectionHighlight' ).RemoveFromRange( HighlightRange, false, true ) ;
! 		HighlightRange = null ;
  	}
  }
! 
! function OnLoad()
  {
! 	// First of all, translate the dialog box texts.
! 	oEditor.FCKLanguageManager.TranslatePage( document ) ;
  
! 	// Show the appropriate tab at startup.
! 	if ( dialogArguments.CustomValue == 'Find' )
  	{
! 		dialog.SetSelectedTab( 'Find' ) ;
! 		dialog.SetAutoSize( true ) ;
! 	}
! 	else
! 		dialog.SetSelectedTab( 'Replace' ) ;
  
! 	SelectField( 'txtFind' + dialogArguments.CustomValue ) ;
! }
  
! function btnStat()
! {
! 	GetE('btnReplace').disabled =
! 		GetE('btnReplaceAll').disabled =
! 			GetE('btnFind').disabled =
! 				( GetE(idMap["FindText"]).value.length == 0 ) ;
! }
  
! function btnStatDelayed()
! {
! 	setTimeout( btnStat, 1 ) ;
! }
  
! function GetSearchString()
! {
! 	return GetE(idMap['FindText']).value ;
! }
  
! function GetReplaceString()
! {
! 	return GetE("txtReplace").value ;
! }
  
! function GetCheckCase()
! {
! 	return !! ( GetE(idMap['CheckCase']).checked ) ;
! }
  
! function GetMatchWord()
  {
! 	return !! ( GetE(idMap['CheckWord']).checked ) ;
  }
! 
! // Get the data pointed to by a bookmark.
! function GetData( bookmark )
  {
! 	var cursor = oEditor.FCK.EditorDocument.documentElement ;
! 	for ( var i = 0 ; i < bookmark.length ; i++ )
  	{
! 		var target = bookmark[i] ;
! 		var currentIndex = -1 ;
! 		if ( cursor.nodeType != 3 )
! 		{
! 			for (var j = 0 ; j < cursor.childNodes.length ; j++ )
! 			{
! 				var candidate = cursor.childNodes[j] ;
! 				if ( candidate.nodeType == 3 &&
! 						candidate.previousSibling &&
! 						candidate.previousSibling.nodeType == 3 )
! 					continue ;
! 				currentIndex++ ;
! 				if ( currentIndex == target )
! 				{
! 					cursor = candidate ;
! 					break ;
! 				}
! 			}
! 			if ( currentIndex < target )
! 				return null ;
! 		}
! 		else
  		{
! 			if ( i != bookmark.length - 1 )
! 				return null ;
! 			while ( target >= cursor.length && cursor.nextSibling && cursor.nextSibling.nodeType == 3 )
! 			{
! 				target -= cursor.length ;
! 				cursor = cursor.nextSibling ;
! 			}
! 			cursor = cursor.nodeValue.charAt( target ) ;
! 			if ( cursor == "" )
! 				cursor = null ;
  		}
  	}
! 	return cursor ;
! }
  
! // With this function, we can treat the bookmark as an iterator for DFS.
! function NextPosition( bookmark )
  {
! 	// See if there's anything further down the tree.
! 	var next = bookmark.concat( [0] ) ;
! 	if ( GetData( next ) != null )
! 		return next ;
! 
! 	// Nothing down there? See if there's anything next to me.
! 	var next = bookmark.slice( 0, bookmark.length - 1 ).concat( [ bookmark[ bookmark.length - 1 ] + 1 ] ) ;
! 	if ( GetData( next ) != null )
! 		return next ;
  
! 	// Nothing even next to me? See if there's anything next to my ancestors.
! 	for ( var i = bookmark.length - 1 ; i > 0 ; i-- )
  	{
! 		var next = bookmark.slice( 0, i - 1 ).concat( [ bookmark[ i - 1 ] + 1 ] ) ;
! 		if ( GetData( next ) != null )
! 			return next ;
  	}
  
! 	// There's absolutely nothing left to walk, return null.
! 	return null ;
! }
  
! // Is this character a unicode whitespace?
! // Reference: http://unicode.org/Public/UNIDATA/PropList.txt
! function CheckIsWhitespace( c )
! {
! 	var code = c.charCodeAt( 0 );
! 	if ( code >= 9 && code <= 0xd )
! 		return true;
! 	if ( code >= 0x2000 && code <= 0x200a )
! 		return true;
! 	switch ( code )
  	{
! 		case 0x20:
! 		case 0x85:
! 		case 0xa0:
! 		case 0x1680:
! 		case 0x180e:
! 		case 0x2028:
! 		case 0x2029:
! 		case 0x202f:
! 		case 0x205f:
! 		case 0x3000:
! 			return true;
! 		default:
! 			return false;
  	}
  }
  
--- 58,309 ----
  }
  
! GetNextNonEmptyTextNode = function( node, stopNode )
  {
! 	while ( ( node = FCKDomTools.GetNextSourceNode( node, false, 3, stopNode ) ) && node && node.length < 1 )
! 		1 ;
! 	return node ;
  }
  
! CharacterCursor = function( arg )
  {
! 	if ( arg.nodeType && arg.nodeType == 9 )
  	{
! 		this._textNode = GetNextNonEmptyTextNode( arg.body, arg.documentElement ) ;
! 		this._offset = 0 ;
! 		this._doc = arg ;
! 	}
! 	else
! 	{
! 		this._textNode = arguments[0] ;
! 		this._offset = arguments[1] ;
! 		this._doc = FCKTools.GetElementDocument( arguments[0] ) ;
  	}
  }
! CharacterCursor.prototype =
  {
! 	GetCharacter : function()
! 	{
! 		return ( this._textNode && this._textNode.nodeValue.charAt( this._offset ) ) || null ;
! 	},
  
! 	// Non-normalized.
! 	GetTextNode : function()
  	{
! 		return this._textNode ;
! 	},
  
! 	// Non-normalized.
! 	GetIndex : function()
! 	{
! 		return this._offset ;
! 	},
  
! 	// Return value means whehther we've crossed a line break or a paragraph boundary.
! 	MoveNext : function()
! 	{
! 		if ( this._offset < this._textNode.length - 1 )
! 		{
! 			this._offset++ ;
! 			return false ;
! 		}
  
! 		var crossed = false ;
! 		var curNode = this._textNode ;
! 		while ( ( curNode = FCKDomTools.GetNextSourceNode( curNode ) )
! 				&& curNode && ( curNode.nodeType != 3 || curNode.length < 1 ) )
! 		{
! 			var tag = curNode.nodeName.toLowerCase() ;
! 			if ( FCKListsLib.BlockElements[tag] || tag == 'br' )
! 				crossed = true ;
! 		}
  
! 		this._textNode = curNode ;
! 		this._offset = 0 ;
! 		return crossed ;
! 	},
  
! 	// Return value means whehther we've crossed a line break or a paragraph boundary.
! 	MoveBack : function()
! 	{
! 		if ( this._offset > 0 && this._textNode.length > 0 )
! 		{
! 			this._offset = Math.min( this._offset - 1, this._textNode.length - 1 ) ;
! 			return false ;
! 		}
  
! 		var crossed = false ;
! 		var curNode = this._textNode ;
! 		while ( ( curNode = FCKDomTools.GetPreviousSourceNode( curNode ) )
! 				&& curNode && ( curNode.nodeType != 3 || curNode.length < 1 ) )
! 		{
! 			var tag = curNode.nodeName.toLowerCase() ;
! 			if ( FCKListsLib.BlockElements[tag] || tag == 'br' )
! 				crossed = true ;
! 		}
  
! 		this._textNode = curNode ;
! 		this._offset = curNode.length - 1 ;
! 		return crossed ;
! 	},
! 
! 	Clone : function()
! 	{
! 		return new CharacterCursor( this._textNode, this._offset ) ;
! 	}
! } ;
! 
! CharacterRange = function( initCursor, maxLength )
  {
! 	this._cursors = initCursor.push ? initCursor : [initCursor] ;
! 	this._maxLength = maxLength ;
! 	this._highlightRange = null ;
  }
! CharacterRange.prototype =
  {
! 	ToDomRange : function()
  	{
! 		var firstCursor = this._cursors[0] ;
! 		var lastCursor = this._cursors[ this._cursors.length - 1 ] ;
! 		var domRange = new FCKDomRange( FCKTools.GetElementWindow( firstCursor.GetTextNode() ) ) ;
! 		var w3cRange = domRange._Range = domRange.CreateRange() ;
! 		w3cRange.setStart( firstCursor.GetTextNode(), firstCursor.GetIndex() ) ;
! 		w3cRange.setEnd( lastCursor.GetTextNode(), lastCursor.GetIndex() + 1 ) ;
! 		domRange._UpdateElementInfo() ;
! 		return domRange ;
! 	},
! 
! 	Highlight : function()
! 	{
! 		if ( this._cursors.length < 1 )
! 			return ;
! 
! 		var domRange = this.ToDomRange() ;
! 		HighlightStyle.ApplyToRange( domRange, false, true ) ;
! 		this._highlightRange = domRange ;
! 
! 		var charRange = CharacterRange.CreateFromDomRange( domRange ) ;
! 		var focusNode = domRange.StartNode ;
! 		if ( focusNode.nodeType != 1 )
! 			focusNode = focusNode.parentNode ;
! 		FCKDomTools.ScrollIntoView( focusNode, false ) ;
! 		this._cursors = charRange._cursors ;
! 	},
! 
! 	RemoveHighlight : function()
! 	{
! 		if ( this._highlightRange )
  		{
! 			HighlightStyle.RemoveFromRange( this._highlightRange, false, true ) ;
! 			var charRange = CharacterRange.CreateFromDomRange( this._highlightRange ) ;
! 			this._cursors = charRange._cursors ;
! 			this._highlightRange = null ;
  		}
+ 	},
+ 
+ 	GetHighlightDomRange : function()
+ 	{
+ 		return this._highlightRange;
+ 	},
+ 
+ 	MoveNext : function()
+ 	{
+ 		var next = this._cursors[ this._cursors.length - 1 ].Clone() ;
+ 		var retval = next.MoveNext() ;
+ 		if ( retval )
+ 			this._cursors = [] ;
+ 		this._cursors.push( next ) ;
+ 		if ( this._cursors.length > this._maxLength )
+ 			this._cursors.shift() ;
+ 		return retval ;
+ 	},
+ 
+ 	MoveBack : function()
+ 	{
+ 		var prev = this._cursors[0].Clone() ;
+ 		var retval = prev.MoveBack() ;
+ 		if ( retval )
+ 			this._cursors = [] ;
+ 		this._cursors.unshift( prev ) ;
+ 		if ( this._cursors.length > this._maxLength )
+ 			this._cursors.pop() ;
+ 		return retval ;
+ 	},
+ 
+ 	GetEndCharacter : function()
+ 	{
+ 		if ( this._cursors.length < 1 )
+ 			return null ;
+ 		var retval = this._cursors[ this._cursors.length - 1 ].GetCharacter() ;
+ 		return retval ;
+ 	},
+ 
+ 	GetNextRange : function( len )
+ 	{
+ 		if ( this._cursors.length == 0 )
+ 			return null ;
+ 		var cur = this._cursors[ this._cursors.length - 1 ].Clone() ;
+ 		cur.MoveNext() ;
+ 		return new CharacterRange( cur, len ) ;
+ 	},
+ 
+ 	GetCursors : function()
+ 	{
+ 		return this._cursors ;
  	}
! } ;
  
! CharacterRange.CreateFromDomRange = function( domRange )
  {
! 	var w3cRange = domRange._Range ;
! 	var startContainer = w3cRange.startContainer ;
! 	var endContainer = w3cRange.endContainer ;
! 	var startTextNode, startIndex, endTextNode, endIndex ;
  
! 	if ( startContainer.nodeType == 3 )
  	{
! 		startTextNode = startContainer ;
! 		startIndex = w3cRange.startOffset ;
! 	}
! 	else if ( domRange.StartNode.nodeType == 3 )
! 	{
! 		startTextNode = domRange.StartNode ;
! 		startIndex = 0 ;
! 	}
! 	else
! 	{
! 		startTextNode = GetNextNonEmptyTextNode( domRange.StartNode, domRange.StartNode.parentNode ) ;
! 		if ( !startTextNode )
! 			return null ;
! 		startIndex = 0 ;
  	}
  
! 	if ( endContainer.nodeType == 3 && w3cRange.endOffset > 0 )
! 	{
! 		endTextNode = endContainer ;
! 		endIndex = w3cRange.endOffset - 1 ;
! 	}
! 	else
! 	{
! 		endTextNode = domRange.EndNode ;
! 		while ( endTextNode.nodeType != 3 )
! 			endTextNode = endTextNode.lastChild ;
! 		endIndex = endTextNode.length - 1 ;
! 	}
  
! 	var cursors = [] ;
! 	var current = new CharacterCursor( startTextNode, startIndex ) ;
! 	cursors.push( current ) ;
! 	if ( !( current.GetTextNode() == endTextNode && current.GetIndex() == endIndex ) && !domRange.CheckIsEmpty() )
  	{
! 		do
! 		{
! 			current = current.Clone() ;
! 			current.MoveNext() ;
! 			cursors.push( current ) ;
! 		}
! 		while ( !( current.GetTextNode() == endTextNode && current.GetIndex() == endIndex ) ) ;
  	}
+ 
+ 	return new CharacterRange( cursors, cursors.length ) ;
  }
  
***************
*** 234,238 ****
  KMP_ADVANCED = 1 ;
  KMP_MATCHED = 2 ;
! function KmpMatch( pattern, ignoreCase )
  {
  	var overlap = [ -1 ] ;
--- 312,316 ----
  KMP_ADVANCED = 1 ;
  KMP_MATCHED = 2 ;
! KmpMatch = function( pattern, ignoreCase )
  {
  	var overlap = [ -1 ] ;
***************
*** 252,256 ****
  }
  KmpMatch.prototype = {
! 	"FeedCharacter" : function( c )
  	{
  		if ( this._IgnoreCase )
--- 330,334 ----
  }
  KmpMatch.prototype = {
! 	FeedCharacter : function( c )
  	{
  		if ( this._IgnoreCase )
***************
*** 278,282 ****
  		return null ;
  	},
! 	"Reset" : function()
  	{
  		this._State = 0 ;
--- 356,361 ----
  		return null ;
  	},
! 
! 	Reset : function()
  	{
  		this._State = 0 ;
***************
*** 284,408 ****
  };
  
! function _Find()
  {
! 	// Start from the end of the current selection.
! 	var matcher = new KmpMatch( GetSearchString(), ! GetCheckCase() ) ;
! 	var cursor = GlobalRange.CreateBookmark2().End ;
! 	var matchState = KMP_NOMATCH ;
! 	var matchBookmark = null ;
! 	var matchBookmarkStart = [] ;
  
! 	// Match finding.
! 	while ( true )
  	{
! 		// Perform KMP stream matching.
! 		//	- Reset KMP matcher if we encountered a block element.
! 		var data = GetData( cursor ) ;
! 		if ( data )
! 		{
! 			if ( data.tagName )
! 			{
! 				if ( oEditor.FCKListsLib.BlockElements[ data.tagName.toLowerCase() ] )
! 				{
! 					matcher.Reset();
! 					matchBookmarkStart = [] ;
! 				}
! 			}
! 			else if ( data.charAt != undefined )
! 			{
! 				matchState = matcher.FeedCharacter(data) ;
  
! 				// No possible match of any useful substring in the pattern for the currently scanned character.
! 				// So delete any positional information.
! 				if ( matchState == KMP_NOMATCH )
! 					matchBookmarkStart = [] ;
! 				// We've matched something, but it's not a complete match, so let's just mark down the position for backtracking later.
! 				else if ( matchState == KMP_ADVANCED )
! 				{
! 					matchBookmarkStart.push( cursor.concat( [] ) ) ;
! 					if ( matchBookmarkStart.length > matcher._State )
! 						matchBookmarkStart.shift() ;
! 				}
! 				// Found a complete match! Mark down the ending position as well.
! 				else if ( matchState == KMP_MATCHED )
! 				{
! 					// It is possible to get a KMP_MATCHED without KMP_ADVANCED when the match pattern is only 1 character.
! 					// So need to check and mark down the starting position as well.
! 					if ( matchBookmarkStart.length == 0 )
! 						matchBookmarkStart = [cursor.concat( [] )] ;
  
! 					matchBookmark = { 'Start' : matchBookmarkStart.shift(), 'End' : cursor.concat( [] ) } ;
! 					matchBookmark.End[ matchBookmark.End.length - 1 ]++;
  
! 					// Wait, do we have to match a whole word?
! 					// If yes, carry out additional checks on what we've got.
! 					if ( GetMatchWord() )
! 					{
! 						var startOk = false ;
! 						var endOk = false ;
! 						var start = matchBookmark.Start ;
! 						var end = matchBookmark.End ;
! 						if ( start[ start.length - 1 ] == 0 )
! 							startOk = true ;
! 						else
! 						{
! 							var cursorBeforeStart = start.slice( 0, start.length - 1 ) ;
! 							cursorBeforeStart.push( start[ start.length - 1 ] - 1 ) ;
! 							var dataBeforeStart = GetData( cursorBeforeStart ) ;
! 							if ( dataBeforeStart == null || dataBeforeStart.charAt == undefined )
! 								startOk = true ;
! 							else if ( CheckIsWhitespace( dataBeforeStart ) )
! 								startOk = true ;
! 						}
  
! 						// this is already one character beyond the last char, no need to move
! 						var cursorAfterEnd = end ;
! 						var dataAfterEnd = GetData( cursorAfterEnd );
! 						if ( dataAfterEnd == null || dataAfterEnd.charAt == undefined )
! 							endOk = true ;
! 						else if ( CheckIsWhitespace( dataAfterEnd ) )
! 							endOk = true ;
  
! 						if ( startOk && endOk )
! 							break ;
! 						else
! 							matcher.Reset() ;
! 					}
! 					else
! 						break ;
! 				}
! 			}
! 		}
  
! 		// Perform DFS across the document, until we've reached the end.
! 		cursor = NextPosition( cursor ) ;
! 		if ( cursor == null )
! 			break;
  	}
  
! 	// If we've found a match, highlight the match.
! 	if ( matchState == KMP_MATCHED )
  	{
! 		GlobalRange.MoveToBookmark2( matchBookmark ) ;
! 		Highlight() ;
! 		var focus = GlobalRange._Range.endContainer ;
! 		while ( focus && focus.nodeType != 1 )
! 			focus = focus.parentNode ;
  
! 		if ( focus )
  		{
! 			if ( oEditor.FCKBrowserInfo.IsSafari )
! 				oEditor.FCKDomTools.ScrollIntoView( focus, false ) ;
! 			else
! 				focus.scrollIntoView( false ) ;
  		}
  
! 		return true ;
! 	}
! 	else
! 	{
! 		ResetGlobalRange() ;
! 		return false ;
  	}
  }
  
--- 363,493 ----
  };
  
! // Place a range at the start of document.
! function OnLoad()
  {
! 	// First of all, translate the dialog box texts.
! 	oEditor.FCKLanguageManager.TranslatePage( document ) ;
  
! 	// Show the appropriate tab at startup.
! 	if ( dialogArguments.CustomValue == 'Find' )
  	{
! 		dialog.SetSelectedTab( 'Find' ) ;
! 		dialog.SetAutoSize( true ) ;
! 	}
! 	else
! 		dialog.SetSelectedTab( 'Replace' ) ;
  
! 	SelectField( 'txtFind' + dialogArguments.CustomValue ) ;
! }
  
! function btnStat()
! {
! 	GetE('btnReplace').disabled =
! 		GetE('btnReplaceAll').disabled =
! 			GetE('btnFind').disabled =
! 				( GetE(idMap["FindText"]).value.length == 0 ) ;
! }
  
! function btnStatDelayed()
! {
! 	setTimeout( btnStat, 1 ) ;
! }
  
! function GetSearchString()
! {
! 	return GetE(idMap['FindText']).value ;
! }
  
! function GetReplaceString()
! {
! 	return GetE("txtReplace").value ;
! }
  
! function GetCheckCase()
! {
! 	return !! ( GetE(idMap['CheckCase']).checked ) ;
! }
! 
! function GetMatchWord()
! {
! 	return !! ( GetE(idMap['CheckWord']).checked ) ;
! }
! 
! /* Is this character a unicode whitespace or a punctuation mark?
!  * References:
!  * http://unicode.org/Public/UNIDATA/PropList.txt (whitespaces)
!  * http://php.chinaunix.net/manual/tw/ref.regex.php (punctuation marks)
!  */
! function CheckIsWordSeparator( c )
! {
! 	var code = c.charCodeAt( 0 );
! 	if ( code >= 9 && code <= 0xd )
! 		return true;
! 	if ( code >= 0x2000 && code <= 0x200a )
! 		return true;
! 	switch ( code )
! 	{
! 		case 0x20:
! 		case 0x85:
! 		case 0xa0:
! 		case 0x1680:
! 		case 0x180e:
! 		case 0x2028:
! 		case 0x2029:
! 		case 0x202f:
! 		case 0x205f:
! 		case 0x3000:
! 			return true;
! 		default:
  	}
+ 	return /[.,"'?!;:]/.test( c ) ;
+ }
  
! FindRange = null ;
! function _Find()
! {
! 	var searchString = GetSearchString() ;
! 	if ( !FindRange )
! 		FindRange = new CharacterRange( new CharacterCursor( EditorDocument ), searchString.length ) ;
! 	else
  	{
! 		FindRange.RemoveHighlight() ;
! 		FindRange = FindRange.GetNextRange( searchString.length ) ;
! 	}
! 	var matcher = new KmpMatch( searchString, ! GetCheckCase() ) ;
! 	var matchState = KMP_NOMATCH ;
! 	var character = '%' ;
  
! 	while ( character != null )
! 	{
! 		while ( ( character = FindRange.GetEndCharacter() ) )
  		{
! 			matchState = matcher.FeedCharacter( character ) ;
! 			if ( matchState == KMP_MATCHED )
! 				break ;
! 			if ( FindRange.MoveNext() )
! 				matcher.Reset() ;
  		}
  
! 		if ( matchState == KMP_MATCHED )
! 		{
! 			if ( GetMatchWord() )
! 			{
! 				var cursors = FindRange.GetCursors() ;
! 				var head = cursors[ cursors.length - 1 ].Clone() ;
! 				var tail = cursors[0].Clone() ;
! 				if ( !head.MoveNext() && !CheckIsWordSeparator( head.GetCharacter() ) )
! 					continue ;
! 				if ( !tail.MoveBack() && !CheckIsWordSeparator( tail.GetCharacter() ) )
! 					continue ;
! 			}
! 
! 			FindRange.Highlight() ;
! 			return true ;
! 		}
  	}
+ 
+ 	FindRange = null ;
+ 	return false ;
  }
  
***************
*** 410,435 ****
  {
  	if ( ! _Find() )
- 	{
- 		ClearHighlight() ;
  		alert( FCKLang.DlgFindNotFoundMsg ) ;
- 	}
  }
  
  function Replace()
  {
! 	if ( GlobalRange.CheckIsCollapsed() )
  	{
! 		if (! _Find() )
! 		{
! 			ClearHighlight() ;
! 			alert( FCKLang.DlgFindNotFoundMsg ) ;
! 		}
  	}
  	else
  	{
! 		oEditor.FCKUndo.SaveUndoStep() ;
! 		GlobalRange.DeleteContents() ;
! 		GlobalRange.InsertNode( oEditor.FCK.EditorDocument.createTextNode( GetReplaceString() ) ) ;
! 		GlobalRange.Collapse( false ) ;
  	}
  }
--- 495,540 ----
  {
  	if ( ! _Find() )
  		alert( FCKLang.DlgFindNotFoundMsg ) ;
  }
  
  function Replace()
  {
! 	var saveUndoStep = function( selectRange )
  	{
! 		var ieRange ;
! 		if ( oEditor.FCKBrowserInfo.IsIE )
! 			ieRange = document.selection.createRange() ;
! 
! 		selectRange.Select() ;
! 		oEditor.FCKUndo.SaveUndoStep() ;
! 		var cloneRange = selectRange.Clone() ;
! 		cloneRange.Collapse( false ) ;
! 		cloneRange.Select() ;
! 
! 		if ( ieRange )
! 			setTimeout( function(){ ieRange.select() ; }, 1 ) ;
! 	}
! 
! 	if ( FindRange && FindRange.GetHighlightDomRange() )
! 	{
! 		var range = FindRange.GetHighlightDomRange() ;
! 		var bookmark = range.CreateBookmark() ;
! 		FindRange.RemoveHighlight() ;
! 		range.MoveToBookmark( bookmark ) ;
! 
! 		saveUndoStep( range ) ;
! 		range.DeleteContents() ;
! 		range.InsertNode( EditorDocument.createTextNode( GetReplaceString() ) ) ;
! 		range._UpdateElementInfo() ;
! 
! 		FindRange = CharacterRange.CreateFromDomRange( range ) ;
  	}
  	else
  	{
! 		if ( ! _Find() )
! 		{
! 			FindRange && FindRange.RemoveHighlight() ;
! 			alert( FCKLang.DlgFindNotFoundMsg ) ;
! 		}
  	}
  }
***************
*** 442,454 ****
  	while ( _Find() )
  	{
! 		dialog.Selection.EnsureSelection() ;
! 		GlobalRange.DeleteContents() ;
! 		GlobalRange.InsertNode( oEditor.FCK.EditorDocument.createTextNode( GetReplaceString() ) ) ;
! 		GlobalRange.Collapse( false ) ;
  		replaceCount++ ;
  	}
  	if ( replaceCount == 0 )
  	{
! 		ClearHighlight() ;
  		alert( FCKLang.DlgFindNotFoundMsg ) ;
  	}
--- 547,565 ----
  	while ( _Find() )
  	{
! 		var range = FindRange.GetHighlightDomRange() ;
! 		var bookmark = range.CreateBookmark() ;
! 		FindRange.RemoveHighlight() ;
! 		range.MoveToBookmark( bookmark) ;
! 
! 		range.DeleteContents() ;
! 		range.InsertNode( EditorDocument.createTextNode( GetReplaceString() ) ) ;
! 		range._UpdateElementInfo() ;
! 
! 		FindRange = CharacterRange.CreateFromDomRange( range ) ;
  		replaceCount++ ;
  	}
  	if ( replaceCount == 0 )
  	{
! 		FindRange && FindRange.RemoveHighlight() ;
  		alert( FCKLang.DlgFindNotFoundMsg ) ;
  	}
***************
*** 456,460 ****
  }
  
! window.onunload = function(){ ClearHighlight() ; }
  	</script>
  </head>
--- 567,578 ----
  }
  
! window.onunload = function()
! {
! 	if ( FindRange )
! 	{
! 		FindRange.RemoveHighlight() ;
! 		FindRange.ToDomRange().Select() ;
! 	}
! }
  	</script>
  </head>




More information about the geeklog-cvs mailing list