### Eclipse Workspace Patch 1.0
#P ckeditor3.0
|
|
|
1 | 1 | /* |
2 | | * CKEditor - The text editor for Internet - http://ckeditor.com |
3 | | * Copyright (C) 2003-2008 Frederico Caldeira Knabben |
4 | | * |
5 | | * == BEGIN LICENSE == |
6 | | * |
7 | | * Licensed under the terms of any of the following licenses at your |
8 | | * choice: |
9 | | * |
10 | | * - GNU General Public License Version 2 or later (the "GPL") |
11 | | * http://www.gnu.org/licenses/gpl.html |
12 | | * |
13 | | * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") |
14 | | * http://www.gnu.org/licenses/lgpl.html |
15 | | * |
16 | | * - Mozilla Public License Version 1.1 or later (the "MPL") |
17 | | * http://www.mozilla.org/MPL/MPL-1.1.html |
18 | | * |
19 | | * == END LICENSE == |
| 2 | * CKEditor - The text editor for Internet - http://ckeditor.com Copyright (C) 2003-2008 Frederico Caldeira Knabben == |
| 3 | * BEGIN LICENSE == |
| 4 | * |
| 5 | * Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or |
| 6 | * later (the "GPL") http://www.gnu.org/licenses/gpl.html - GNU Lesser General Public License Version 2.1 or later (the |
| 7 | * "LGPL") http://www.gnu.org/licenses/lgpl.html - Mozilla Public License Version 1.1 or later (the "MPL") |
| 8 | * http://www.mozilla.org/MPL/MPL-1.1.html == END LICENSE == |
20 | 9 | */ |
21 | 10 | |
22 | 11 | /** |
23 | 12 | * A lightweight representation of an HTML element. |
24 | | * @param {String} name The element name. |
25 | | * @param {Object} attributes And object holding all attributes defined for |
26 | | * this element. |
| 13 | * |
| 14 | * @param {String} |
| 15 | * name The element name. |
| 16 | * @param {Object} |
| 17 | * attributes And object holding all attributes defined for this element. |
27 | 18 | * @constructor |
28 | 19 | * @example |
29 | 20 | */ |
30 | | CKEDITOR.htmlParser.element = function( name, attributes ) |
| 21 | CKEDITOR.htmlParser.element = function ( name, attributes ) |
31 | 22 | { |
32 | 23 | /** |
33 | 24 | * The element name. |
| 25 | * |
34 | 26 | * @type String |
35 | 27 | * @example |
36 | 28 | */ |
… |
… |
|
38 | 30 | |
39 | 31 | /** |
40 | 32 | * Holds the attributes defined for this element. |
| 33 | * |
41 | 34 | * @type Object |
42 | 35 | * @example |
43 | 36 | */ |
… |
… |
|
45 | 38 | |
46 | 39 | /** |
47 | 40 | * The nodes that are direct children of this element. |
| 41 | * |
48 | 42 | * @type Array |
49 | 43 | * @example |
50 | 44 | */ |
51 | 45 | this.children = []; |
52 | 46 | |
53 | | var dtd = CKEDITOR.dtd, |
54 | | isBlockLike = !!( dtd.$block[ name ] || dtd.$listItem[ name ] || dtd.$tableContent[ name ] ), |
55 | | isEmpty = !!dtd.$empty[ name ]; |
| 47 | var dtd = CKEDITOR.dtd , isBlockLike = !! ( dtd.$block[ name ] |
| 48 | || dtd.$listItem[ name ] || dtd.$tableContent[ name ] ) , isEmpty = !!dtd.$empty[ name ]; |
56 | 49 | |
57 | 50 | /** @private */ |
58 | | this._ = |
59 | | { |
60 | | isBlockLike : isBlockLike, |
61 | | isEmpty : isEmpty, |
62 | | hasInlineStarted : isEmpty || !isBlockLike |
| 51 | this._ = { |
| 52 | isBlockLike :isBlockLike, |
| 53 | isEmpty :isEmpty, |
| 54 | hasInlineStarted :isEmpty || !isBlockLike |
63 | 55 | }; |
64 | 56 | }; |
65 | 57 | |
66 | | (function() |
| 58 | ( function ( ) |
67 | 59 | { |
68 | 60 | // Used to sort attribute entries in an array, where the first element of |
69 | 61 | // each object is the attribute name. |
70 | | var sortAttribs = function( a, b ) |
| 62 | var sortAttribs = function ( a, b ) |
71 | 63 | { |
72 | | a = a[0]; |
73 | | b = b[0]; |
| 64 | a = a[ 0 ]; |
| 65 | b = b[ 0 ]; |
74 | 66 | return a < b ? -1 : a > b ? 1 : 0; |
75 | 67 | }; |
76 | 68 | |
77 | | CKEDITOR.htmlParser.element.prototype = |
78 | | { |
| 69 | CKEDITOR.htmlParser.element.prototype = { |
79 | 70 | /** |
80 | 71 | * The node type. This is a constant value set to {@link CKEDITOR.NODE_ELEMENT}. |
| 72 | * |
81 | 73 | * @type Number |
82 | 74 | * @example |
83 | 75 | */ |
84 | | type : CKEDITOR.NODE_ELEMENT, |
| 76 | type :CKEDITOR.NODE_ELEMENT, |
85 | 77 | |
86 | 78 | /** |
87 | 79 | * Adds a node to the element children list. |
88 | | * @param {Object} node The node to be added. It can be any of of the |
89 | | * following types: {@link CKEDITOR.htmlParser.element}, |
90 | | * {@link CKEDITOR.htmlParser.text} and |
91 | | * {@link CKEDITOR.htmlParser.comment}. |
| 80 | * |
| 81 | * @param {Object} |
| 82 | * node The node to be added. It can be any of of the following types: |
| 83 | * {@link CKEDITOR.htmlParser.element}, {@link CKEDITOR.htmlParser.text} and |
| 84 | * {@link CKEDITOR.htmlParser.comment}. |
92 | 85 | * @function |
93 | 86 | * @example |
94 | 87 | */ |
95 | | add : CKEDITOR.htmlParser.fragment.prototype.add, |
| 88 | add :CKEDITOR.htmlParser.fragment.prototype.add, |
96 | 89 | |
97 | 90 | /** |
98 | 91 | * Clone this element. |
| 92 | * |
99 | 93 | * @returns {CKEDITOR.htmlParser.element} The element clone. |
100 | 94 | * @example |
101 | 95 | */ |
102 | | clone : function() |
| 96 | clone : function ( ) |
103 | 97 | { |
104 | | return new CKEDITOR.htmlParser.element( this.name, this.attributes ); |
| 98 | return new CKEDITOR.htmlParser.element( this.name , this.attributes ); |
105 | 99 | }, |
106 | 100 | |
107 | 101 | /** |
108 | 102 | * Writes the element HTML to a CKEDITOR.htmlWriter. |
109 | | * @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML. |
| 103 | * |
| 104 | * @param {CKEDITOR.htmlWriter} |
| 105 | * writer The writer to which write the HTML. |
110 | 106 | * @example |
111 | | */ |
112 | | writeHtml : function( writer ) |
| 107 | // */ |
| 108 | writeHtml : function ( writer ) |
113 | 109 | { |
114 | | // Open element tag. |
115 | | writer.openTag( this.name, this.attributes ); |
116 | | |
| 110 | // Open element tag. |
| 111 | writer.openTag( this.name , this.attributes ); |
| 112 | |
117 | 113 | // Copy all attributes to an array. |
118 | 114 | var attribsArray = []; |
119 | 115 | for ( var a in this.attributes ) |
| 116 | { |
| 117 | if ( CKEDITOR.env.ie && a === '_cke_expando' ) // IE's treated expand fields as dom attributes, skip i |
| 118 | continue; |
120 | 119 | attribsArray.push( [ a, this.attributes[ a ] ] ); |
121 | | |
| 120 | } |
| 121 | |
122 | 122 | // Sort the attributes by name. |
123 | 123 | attribsArray.sort( sortAttribs ); |
124 | | |
| 124 | |
125 | 125 | // Send the attributes. |
126 | 126 | for ( var i = 0, len = attribsArray.length ; i < len ; i++ ) |
127 | 127 | { |
128 | 128 | var attrib = attribsArray[ i ]; |
129 | | writer.attribute( attrib[0], attrib[1] ); |
| 129 | writer.attribute( attrib[ 0 ] , attrib[ 1 ] ); |
130 | 130 | } |
131 | | |
| 131 | |
132 | 132 | // Close the tag. |
133 | | writer.openTagClose( this.name, this._.isEmpty ); |
134 | | |
| 133 | writer.openTagClose( this.name , this._.isEmpty ); |
| 134 | |
135 | 135 | if ( !this._.isEmpty ) |
136 | 136 | { |
137 | 137 | // Send children. |
138 | | CKEDITOR.htmlParser.fragment.prototype.writeHtml.apply( this, arguments ); |
139 | | |
| 138 | CKEDITOR.htmlParser.fragment.prototype.writeHtml.apply( this , |
| 139 | arguments ); |
| 140 | |
140 | 141 | // Close the element. |
141 | 142 | writer.closeTag( this.name ); |
142 | 143 | } |
143 | 144 | } |
144 | 145 | }; |
145 | | })(); |
| 146 | } )(); |