/*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
{\r
var $clone = this.$.cloneNode( includeChildren );\r
\r
- if ( !cloneId )\r
+ var removeIds = function( node )\r
{\r
- var removeIds = function( node )\r
- {\r
- if ( node.nodeType != CKEDITOR.NODE_ELEMENT )\r
- return;\r
+ if ( node.nodeType != CKEDITOR.NODE_ELEMENT )\r
+ return;\r
\r
- node.removeAttribute( 'id', false ) ;\r
- node.removeAttribute( '_cke_expando', false ) ;\r
+ if ( !cloneId )\r
+ node.removeAttribute( 'id', false );\r
+ node.removeAttribute( 'data-cke-expando', false );\r
\r
+ if ( includeChildren )\r
+ {\r
var childs = node.childNodes;\r
- for ( var i=0 ; i < childs.length ; i++ )\r
+ for ( var i=0; i < childs.length; i++ )\r
removeIds( childs[ i ] );\r
- };\r
+ }\r
+ };\r
\r
- // The "id" attribute should never be cloned to avoid duplication.\r
- removeIds( $clone );\r
- }\r
+ // The "id" attribute should never be cloned to avoid duplication.\r
+ removeIds( $clone );\r
\r
return new CKEDITOR.dom.node( $clone );\r
},\r
*/\r
getDocument : function()\r
{\r
- var document = new CKEDITOR.dom.document( this.$.ownerDocument || this.$.parentNode.ownerDocument );\r
-\r
- return (\r
- this.getDocument = function()\r
- {\r
- return document;\r
- })();\r
+ return new CKEDITOR.dom.document( this.$.ownerDocument || this.$.parentNode.ownerDocument );\r
},\r
\r
getIndex : function()\r
child.parentNode.removeChild( child ) ;\r
}\r
}\r
+ },\r
+\r
+ /**\r
+ * Checks is this node is read-only (should not be changed). It\r
+ * additionaly returns the element, if any, which defines the read-only\r
+ * state of this node. It may be the node itself or any of its parent\r
+ * nodes.\r
+ * @returns {CKEDITOR.dom.element|Boolean} An element containing\r
+ * read-only attributes or "false" if none is found.\r
+ * @since 3.5\r
+ * @example\r
+ * // For the following HTML:\r
+ * // <div contenteditable="false">Some <b>text</b></div>\r
+ *\r
+ * // If "ele" is the above <div>\r
+ * ele.isReadOnly(); // the <div> element\r
+ *\r
+ * // If "ele" is the above <b>\r
+ * ele.isReadOnly(); // the <div> element\r
+ */\r
+ isReadOnly : function()\r
+ {\r
+ var current = this;\r
+ while( current )\r
+ {\r
+ if ( current.type == CKEDITOR.NODE_ELEMENT )\r
+ {\r
+ if ( current.is( 'body' ) || !!current.data( 'cke-editable' ) )\r
+ break;\r
+\r
+ if ( current.getAttribute( 'contentEditable' ) == 'false' )\r
+ return current;\r
+ else if ( current.getAttribute( 'contentEditable' ) == 'true' )\r
+ break;\r
+ }\r
+ current = current.getParent();\r
+ }\r
+\r
+ return false;\r
}\r
}\r
);\r