import rt 3.8.7
[freeside.git] / rt / share / html / NoAuth / RichText / FCKeditor / editor / _source / classes / fckelementpath.js
diff --git a/rt/share/html/NoAuth/RichText/FCKeditor/editor/_source/classes/fckelementpath.js b/rt/share/html/NoAuth/RichText/FCKeditor/editor/_source/classes/fckelementpath.js
new file mode 100644 (file)
index 0000000..488b19f
--- /dev/null
@@ -0,0 +1,89 @@
+/*\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
+ * Manages the DOM ascensors element list of a specific DOM node\r
+ * (limited to body, inclusive).\r
+ */\r
+\r
+var FCKElementPath = function( lastNode )\r
+{\r
+       var eBlock = null ;\r
+       var eBlockLimit = null ;\r
+\r
+       var aElements = new Array() ;\r
+\r
+       var e = lastNode ;\r
+       while ( e )\r
+       {\r
+               if ( e.nodeType == 1 )\r
+               {\r
+                       if ( !this.LastElement )\r
+                               this.LastElement = e ;\r
+\r
+                       var sElementName = e.nodeName.toLowerCase() ;\r
+                       if ( FCKBrowserInfo.IsIE && e.scopeName != 'HTML' )\r
+                               sElementName = e.scopeName.toLowerCase() + ':' + sElementName ;\r
+\r
+                       if ( !eBlockLimit )\r
+                       {\r
+                               if ( !eBlock && FCKListsLib.PathBlockElements[ sElementName ] != null )\r
+                                       eBlock = e ;\r
+\r
+                               if ( FCKListsLib.PathBlockLimitElements[ sElementName ] != null )\r
+                               {\r
+                                       // DIV is considered the Block, if no block is available (#525)\r
+                                       // and if it doesn't contain other blocks.\r
+                                       if ( !eBlock && sElementName == 'div' && !FCKElementPath._CheckHasBlock( e ) )\r
+                                               eBlock = e ;\r
+                                       else\r
+                                               eBlockLimit = e ;\r
+                               }\r
+                       }\r
+\r
+                       aElements.push( e ) ;\r
+\r
+                       if ( sElementName == 'body' )\r
+                               break ;\r
+               }\r
+               e = e.parentNode ;\r
+       }\r
+\r
+       this.Block = eBlock ;\r
+       this.BlockLimit = eBlockLimit ;\r
+       this.Elements = aElements ;\r
+}\r
+\r
+/**\r
+ * Check if an element contains any block element.\r
+ */\r
+FCKElementPath._CheckHasBlock = function( element )\r
+{\r
+       var childNodes = element.childNodes ;\r
+\r
+       for ( var i = 0, count = childNodes.length ; i < count ; i++ )\r
+       {\r
+               var child = childNodes[i] ;\r
+\r
+               if ( child.nodeType == 1 && FCKListsLib.BlockElements[ child.nodeName.toLowerCase() ] )\r
+                       return true ;\r
+       }\r
+\r
+       return false ;\r
+}\r