import rt 3.8.7
[freeside.git] / rt / share / html / NoAuth / RichText / FCKeditor / editor / _source / classes / fckelementpath.js
1 /*\r
2  * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
3  * Copyright (C) 2003-2009 Frederico Caldeira Knabben\r
4  *\r
5  * == BEGIN LICENSE ==\r
6  *\r
7  * Licensed under the terms of any of the following licenses at your\r
8  * choice:\r
9  *\r
10  *  - GNU General Public License Version 2 or later (the "GPL")\r
11  *    http://www.gnu.org/licenses/gpl.html\r
12  *\r
13  *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
14  *    http://www.gnu.org/licenses/lgpl.html\r
15  *\r
16  *  - Mozilla Public License Version 1.1 or later (the "MPL")\r
17  *    http://www.mozilla.org/MPL/MPL-1.1.html\r
18  *\r
19  * == END LICENSE ==\r
20  *\r
21  * Manages the DOM ascensors element list of a specific DOM node\r
22  * (limited to body, inclusive).\r
23  */\r
24 \r
25 var FCKElementPath = function( lastNode )\r
26 {\r
27         var eBlock = null ;\r
28         var eBlockLimit = null ;\r
29 \r
30         var aElements = new Array() ;\r
31 \r
32         var e = lastNode ;\r
33         while ( e )\r
34         {\r
35                 if ( e.nodeType == 1 )\r
36                 {\r
37                         if ( !this.LastElement )\r
38                                 this.LastElement = e ;\r
39 \r
40                         var sElementName = e.nodeName.toLowerCase() ;\r
41                         if ( FCKBrowserInfo.IsIE && e.scopeName != 'HTML' )\r
42                                 sElementName = e.scopeName.toLowerCase() + ':' + sElementName ;\r
43 \r
44                         if ( !eBlockLimit )\r
45                         {\r
46                                 if ( !eBlock && FCKListsLib.PathBlockElements[ sElementName ] != null )\r
47                                         eBlock = e ;\r
48 \r
49                                 if ( FCKListsLib.PathBlockLimitElements[ sElementName ] != null )\r
50                                 {\r
51                                         // DIV is considered the Block, if no block is available (#525)\r
52                                         // and if it doesn't contain other blocks.\r
53                                         if ( !eBlock && sElementName == 'div' && !FCKElementPath._CheckHasBlock( e ) )\r
54                                                 eBlock = e ;\r
55                                         else\r
56                                                 eBlockLimit = e ;\r
57                                 }\r
58                         }\r
59 \r
60                         aElements.push( e ) ;\r
61 \r
62                         if ( sElementName == 'body' )\r
63                                 break ;\r
64                 }\r
65                 e = e.parentNode ;\r
66         }\r
67 \r
68         this.Block = eBlock ;\r
69         this.BlockLimit = eBlockLimit ;\r
70         this.Elements = aElements ;\r
71 }\r
72 \r
73 /**\r
74  * Check if an element contains any block element.\r
75  */\r
76 FCKElementPath._CheckHasBlock = function( element )\r
77 {\r
78         var childNodes = element.childNodes ;\r
79 \r
80         for ( var i = 0, count = childNodes.length ; i < count ; i++ )\r
81         {\r
82                 var child = childNodes[i] ;\r
83 \r
84                 if ( child.nodeType == 1 && FCKListsLib.BlockElements[ child.nodeName.toLowerCase() ] )\r
85                         return true ;\r
86         }\r
87 \r
88         return false ;\r
89 }\r