update address standardization for cust_location changes
[freeside.git] / rt / share / html / NoAuth / RichText / FCKeditor / editor / _source / classes / fckdomrangeiterator.js
diff --git a/rt/share/html/NoAuth/RichText/FCKeditor/editor/_source/classes/fckdomrangeiterator.js b/rt/share/html/NoAuth/RichText/FCKeditor/editor/_source/classes/fckdomrangeiterator.js
deleted file mode 100644 (file)
index 962b8b1..0000000
+++ /dev/null
@@ -1,327 +0,0 @@
-/*\r
- * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
- * Copyright (C) 2003-2009 Frederico Caldeira Knabben\r
- *\r
- * == BEGIN LICENSE ==\r
- *\r
- * Licensed under the terms of any of the following licenses at your\r
- * choice:\r
- *\r
- *  - GNU General Public License Version 2 or later (the "GPL")\r
- *    http://www.gnu.org/licenses/gpl.html\r
- *\r
- *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
- *    http://www.gnu.org/licenses/lgpl.html\r
- *\r
- *  - Mozilla Public License Version 1.1 or later (the "MPL")\r
- *    http://www.mozilla.org/MPL/MPL-1.1.html\r
- *\r
- * == END LICENSE ==\r
- *\r
- * This class can be used to interate through nodes inside a range.\r
- *\r
- * During interation, the provided range can become invalid, due to document\r
- * mutations, so CreateBookmark() used to restore it after processing, if\r
- * needed.\r
- */\r
-\r
-var FCKDomRangeIterator = function( range )\r
-{\r
-       /**\r
-        * The FCKDomRange object that marks the interation boundaries.\r
-        */\r
-       this.Range = range ;\r
-\r
-       /**\r
-        * Indicates that <br> elements must be used as paragraph boundaries.\r
-        */\r
-       this.ForceBrBreak = false ;\r
-\r
-       /**\r
-        * Guarantees that the iterator will always return "real" block elements.\r
-        * If "false", elements like <li>, <th> and <td> are returned. If "true", a\r
-        * dedicated block element block element will be created inside those\r
-        * elements to hold the selected content.\r
-        */\r
-       this.EnforceRealBlocks = false ;\r
-}\r
-\r
-FCKDomRangeIterator.CreateFromSelection = function( targetWindow )\r
-{\r
-       var range = new FCKDomRange( targetWindow ) ;\r
-       range.MoveToSelection() ;\r
-       return new FCKDomRangeIterator( range ) ;\r
-}\r
-\r
-FCKDomRangeIterator.prototype =\r
-{\r
-       /**\r
-        * Get the next paragraph element. It automatically breaks the document\r
-        * when necessary to generate block elements for the paragraphs.\r
-        */\r
-       GetNextParagraph : function()\r
-       {\r
-               // The block element to be returned.\r
-               var block ;\r
-\r
-               // The range object used to identify the paragraph contents.\r
-               var range ;\r
-\r
-               // Indicated that the current element in the loop is the last one.\r
-               var isLast ;\r
-\r
-               // Instructs to cleanup remaining BRs.\r
-               var removePreviousBr ;\r
-               var removeLastBr ;\r
-\r
-               var boundarySet = this.ForceBrBreak ? FCKListsLib.ListBoundaries : FCKListsLib.BlockBoundaries ;\r
-\r
-               // This is the first iteration. Let's initialize it.\r
-               if ( !this._LastNode )\r
-               {\r
-                       var range = this.Range.Clone() ;\r
-                       range.Expand( this.ForceBrBreak ? 'list_contents' : 'block_contents' ) ;\r
-\r
-                       this._NextNode = range.GetTouchedStartNode() ;\r
-                       this._LastNode = range.GetTouchedEndNode() ;\r
-\r
-                       // Let's reuse this variable.\r
-                       range = null ;\r
-               }\r
-\r
-               var currentNode = this._NextNode ;\r
-               var lastNode = this._LastNode ;\r
-\r
-               this._NextNode = null ;\r
-\r
-               while ( currentNode )\r
-               {\r
-                       // closeRange indicates that a paragraph boundary has been found,\r
-                       // so the range can be closed.\r
-                       var closeRange = false ;\r
-\r
-                       // includeNode indicates that the current node is good to be part\r
-                       // of the range. By default, any non-element node is ok for it.\r
-                       var includeNode = ( currentNode.nodeType != 1 ) ;\r
-\r
-                       var continueFromSibling = false ;\r
-\r
-                       // If it is an element node, let's check if it can be part of the\r
-                       // range.\r
-                       if ( !includeNode )\r
-                       {\r
-                               var nodeName = currentNode.nodeName.toLowerCase() ;\r
-\r
-                               if ( boundarySet[ nodeName ] && ( !FCKBrowserInfo.IsIE || currentNode.scopeName == 'HTML' ) )\r
-                               {\r
-                                       // <br> boundaries must be part of the range. It will\r
-                                       // happen only if ForceBrBreak.\r
-                                       if ( nodeName == 'br' )\r
-                                               includeNode = true ;\r
-                                       else if ( !range && currentNode.childNodes.length == 0 && nodeName != 'hr' )\r
-                                       {\r
-                                               // If we have found an empty block, and haven't started\r
-                                               // the range yet, it means we must return this block.\r
-                                               block = currentNode ;\r
-                                               isLast = currentNode == lastNode ;\r
-                                               break ;\r
-                                       }\r
-\r
-                                       // The range must finish right before the boundary,\r
-                                       // including possibly skipped empty spaces. (#1603)\r
-                                       if ( range )\r
-                                       {\r
-                                               range.SetEnd( currentNode, 3, true ) ;\r
-\r
-                                               // The found boundary must be set as the next one at this\r
-                                               // point. (#1717)\r
-                                               if ( nodeName != 'br' )\r
-                                                       this._NextNode = FCKDomTools.GetNextSourceNode( currentNode, true, null, lastNode ) || currentNode ;\r
-                                       }\r
-\r
-                                       closeRange = true ;\r
-                               }\r
-                               else\r
-                               {\r
-                                       // If we have child nodes, let's check them.\r
-                                       if ( currentNode.firstChild )\r
-                                       {\r
-                                               // If we don't have a range yet, let's start it.\r
-                                               if ( !range )\r
-                                               {\r
-                                                       range = new FCKDomRange( this.Range.Window ) ;\r
-                                                       range.SetStart( currentNode, 3, true ) ;\r
-                                               }\r
-\r
-                                               currentNode = currentNode.firstChild ;\r
-                                               continue ;\r
-                                       }\r
-                                       includeNode = true ;\r
-                               }\r
-                       }\r
-                       else if ( currentNode.nodeType == 3 )\r
-                       {\r
-                               // Ignore normal whitespaces (i.e. not including &nbsp; or\r
-                               // other unicode whitespaces) before/after a block node.\r
-                               if ( /^[\r\n\t ]+$/.test( currentNode.nodeValue ) )\r
-                                       includeNode = false ;\r
-                       }\r
-\r
-                       // The current node is good to be part of the range and we are\r
-                       // starting a new range, initialize it first.\r
-                       if ( includeNode && !range )\r
-                       {\r
-                               range = new FCKDomRange( this.Range.Window ) ;\r
-                               range.SetStart( currentNode, 3, true ) ;\r
-                       }\r
-\r
-                       // The last node has been found.\r
-                       isLast = ( ( !closeRange || includeNode ) && currentNode == lastNode ) ;\r
-//                     isLast = ( currentNode == lastNode && ( currentNode.nodeType != 1 || currentNode.childNodes.length == 0 ) ) ;\r
-\r
-                       // If we are in an element boundary, let's check if it is time\r
-                       // to close the range, otherwise we include the parent within it.\r
-                       if ( range && !closeRange )\r
-                       {\r
-                               while ( !currentNode.nextSibling && !isLast )\r
-                               {\r
-                                       var parentNode = currentNode.parentNode ;\r
-\r
-                                       if ( boundarySet[ parentNode.nodeName.toLowerCase() ] )\r
-                                       {\r
-                                               closeRange = true ;\r
-                                               isLast = isLast || ( parentNode == lastNode ) ;\r
-                                               break ;\r
-                                       }\r
-\r
-                                       currentNode = parentNode ;\r
-                                       includeNode = true ;\r
-                                       isLast = ( currentNode == lastNode ) ;\r
-                                       continueFromSibling = true ;\r
-                               }\r
-                       }\r
-\r
-                       // Now finally include the node.\r
-                       if ( includeNode )\r
-                               range.SetEnd( currentNode, 4, true ) ;\r
-\r
-                       // We have found a block boundary. Let's close the range and move out of the\r
-                       // loop.\r
-                       if ( ( closeRange || isLast ) && range )\r
-                       {\r
-                               range._UpdateElementInfo() ;\r
-\r
-                               if ( range.StartNode == range.EndNode\r
-                                               && range.StartNode.parentNode == range.StartBlockLimit\r
-                                               && range.StartNode.getAttribute && range.StartNode.getAttribute( '_fck_bookmark' ) )\r
-                                       range = null ;\r
-                               else\r
-                                       break ;\r
-                       }\r
-\r
-                       if ( isLast )\r
-                               break ;\r
-\r
-                       currentNode = FCKDomTools.GetNextSourceNode( currentNode, continueFromSibling, null, lastNode ) ;\r
-               }\r
-\r
-               // Now, based on the processed range, look for (or create) the block to be returned.\r
-               if ( !block )\r
-               {\r
-                       // If no range has been found, this is the end.\r
-                       if ( !range )\r
-                       {\r
-                               this._NextNode = null ;\r
-                               return null ;\r
-                       }\r
-\r
-                       block = range.StartBlock ;\r
-\r
-                       if ( !block\r
-                               && !this.EnforceRealBlocks\r
-                               && range.StartBlockLimit.nodeName.IEquals( 'DIV', 'TH', 'TD' )\r
-                               && range.CheckStartOfBlock()\r
-                               && range.CheckEndOfBlock() )\r
-                       {\r
-                               block = range.StartBlockLimit ;\r
-                       }\r
-                       else if ( !block || ( this.EnforceRealBlocks && block.nodeName.toLowerCase() == 'li' ) )\r
-                       {\r
-                               // Create the fixed block.\r
-                               block = this.Range.Window.document.createElement( FCKConfig.EnterMode == 'p' ? 'p' : 'div' ) ;\r
-\r
-                               // Move the contents of the temporary range to the fixed block.\r
-                               range.ExtractContents().AppendTo( block ) ;\r
-                               FCKDomTools.TrimNode( block ) ;\r
-\r
-                               // Insert the fixed block into the DOM.\r
-                               range.InsertNode( block ) ;\r
-\r
-                               removePreviousBr = true ;\r
-                               removeLastBr = true ;\r
-                       }\r
-                       else if ( block.nodeName.toLowerCase() != 'li' )\r
-                       {\r
-                               // If the range doesn't includes the entire contents of the\r
-                               // block, we must split it, isolating the range in a dedicated\r
-                               // block.\r
-                               if ( !range.CheckStartOfBlock() || !range.CheckEndOfBlock() )\r
-                               {\r
-                                       // The resulting block will be a clone of the current one.\r
-                                       block = block.cloneNode( false ) ;\r
-\r
-                                       // Extract the range contents, moving it to the new block.\r
-                                       range.ExtractContents().AppendTo( block ) ;\r
-                                       FCKDomTools.TrimNode( block ) ;\r
-\r
-                                       // Split the block. At this point, the range will be in the\r
-                                       // right position for our intents.\r
-                                       var splitInfo = range.SplitBlock() ;\r
-\r
-                                       removePreviousBr = !splitInfo.WasStartOfBlock ;\r
-                                       removeLastBr = !splitInfo.WasEndOfBlock ;\r
-\r
-                                       // Insert the new block into the DOM.\r
-                                       range.InsertNode( block ) ;\r
-                               }\r
-                       }\r
-                       else if ( !isLast )\r
-                       {\r
-                               // LIs are returned as is, with all their children (due to the\r
-                               // nested lists). But, the next node is the node right after\r
-                               // the current range, which could be an <li> child (nested\r
-                               // lists) or the next sibling <li>.\r
-\r
-                               this._NextNode = block == lastNode ? null : FCKDomTools.GetNextSourceNode( range.EndNode, true, null, lastNode ) ;\r
-                               return block ;\r
-                       }\r
-               }\r
-\r
-               if ( removePreviousBr )\r
-               {\r
-                       var previousSibling = block.previousSibling ;\r
-                       if ( previousSibling && previousSibling.nodeType == 1 )\r
-                       {\r
-                               if ( previousSibling.nodeName.toLowerCase() == 'br' )\r
-                                       previousSibling.parentNode.removeChild( previousSibling ) ;\r
-                               else if ( previousSibling.lastChild && previousSibling.lastChild.nodeName.IEquals( 'br' ) )\r
-                                       previousSibling.removeChild( previousSibling.lastChild ) ;\r
-                       }\r
-               }\r
-\r
-               if ( removeLastBr )\r
-               {\r
-                       var lastChild = block.lastChild ;\r
-                       if ( lastChild && lastChild.nodeType == 1 && lastChild.nodeName.toLowerCase() == 'br' )\r
-                               block.removeChild( lastChild ) ;\r
-               }\r
-\r
-               // Get a reference for the next element. This is important because the\r
-               // above block can be removed or changed, so we can rely on it for the\r
-               // next interation.\r
-               if ( !this._NextNode )\r
-                       this._NextNode = ( isLast || block == lastNode ) ? null : FCKDomTools.GetNextSourceNode( block, true, null, lastNode ) ;\r
-\r
-               return block ;\r
-       }\r
-} ;\r