X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=inline;f=_source%2Fcore%2Fdom%2Felement.js;h=6e6a42c181c9a68aba087442c69e1ebf38e626dd;hb=4e70ea24db840898be8cc21c950363a52a2a6aba;hp=0243dea37764845c1b25ab6406f1d9de884f4869;hpb=9afde8772159bd3436f1f5b7862960307710ae5a;p=ckeditor.git
diff --git a/_source/core/dom/element.js b/_source/core/dom/element.js
index 0243dea..6e6a42c 100644
--- a/_source/core/dom/element.js
+++ b/_source/core/dom/element.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
@@ -307,6 +307,7 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
/**
* Moves the selection focus to this element.
+ * @function
* @param {Boolean} defer Whether to asynchronously defer the
* execution by 100 ms.
* @example
@@ -428,6 +429,13 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
name = 'className';
break;
+ case 'http-equiv':
+ name = 'httpEquiv';
+ break;
+
+ case 'name':
+ return this.$.name;
+
case 'tabindex':
var tabIndex = standard.call( this, name );
@@ -452,7 +460,8 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
}
case 'hspace':
- return this.$.hspace;
+ case 'value':
+ return this.$[ name ];
case 'style':
// IE does not return inline styles via getAttribute(). See #2947.
@@ -712,6 +721,9 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
isEditable : function()
{
+ if ( this.isReadOnly() )
+ return false;
+
// Get the element name.
var name = this.getName();
@@ -815,14 +827,15 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
},
/**
- * Indicates that the element has defined attributes.
+ * Checks if the element has any defined attributes.
+ * @function
* @returns {Boolean} True if the element has attributes.
* @example
- * var element = CKEDITOR.dom.element.createFromHtml( '
Example
' );
- * alert( element.hasAttributes() ); "true"
+ * var element = CKEDITOR.dom.element.createFromHtml( '<div title="Test">Example</div>' );
+ * alert( element.hasAttributes() ); // "true"
* @example
- * var element = CKEDITOR.dom.element.createFromHtml( 'Example
' );
- * alert( element.hasAttributes() ); "false"
+ * var element = CKEDITOR.dom.element.createFromHtml( '<div>Example</div>' );
+ * alert( element.hasAttributes() ); // "false"
*/
hasAttributes :
CKEDITOR.env.ie && ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) ?
@@ -876,16 +889,33 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
},
/**
- * Indicates whether a specified attribute is defined for this element.
+ * Checks if the specified attribute is defined for this element.
* @returns {Boolean} True if the specified attribute is defined.
- * @param (String) name The attribute name.
+ * @param {String} name The attribute name.
* @example
*/
- hasAttribute : function( name )
+ hasAttribute : (function()
{
- var $attr = this.$.attributes.getNamedItem( name );
- return !!( $attr && $attr.specified );
- },
+ function standard( name )
+ {
+ var $attr = this.$.attributes.getNamedItem( name );
+ return !!( $attr && $attr.specified );
+ }
+
+ return ( CKEDITOR.env.ie && CKEDITOR.env.version < 8 ) ?
+ function( name )
+ {
+ // On IE < 8 the name attribute cannot be retrieved
+ // right after the element creation and setting the
+ // name with setAttribute.
+ if ( name == 'name' )
+ return !!this.$.name;
+
+ return standard.call( this, name );
+ }
+ :
+ standard;
+ })(),
/**
* Hides this element (display:none).
@@ -920,6 +950,14 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
}
},
+ /**
+ * Merges sibling elements that are identical to this one.
+ *
+ * Identical child elements are also merged. For example:
+ * <b><i></i></b><b><i></i></b> => <b><i></i></b>
+ * @function
+ * @param {Boolean} [inlineOnly] Allow only inline elements to be merged. Defaults to "true".
+ */
mergeSiblings : ( function()
{
function mergeElements( element, sibling, isNext )
@@ -959,11 +997,14 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
}
}
- return function()
+ return function( inlineOnly )
{
- // Merge empty links and anchors also. (#5567)
- if ( !( CKEDITOR.dtd.$removeEmpty[ this.getName() ] || this.is( 'a' ) ) )
+ if ( ! ( inlineOnly === false
+ || CKEDITOR.dtd.$removeEmpty[ this.getName() ]
+ || this.is( 'a' ) ) ) // Merge empty links and anchors also. (#5567)
+ {
return;
+ }
mergeElements( this, this.getNext(), true );
mergeElements( this, this.getPrevious() );
@@ -1547,9 +1588,12 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
/**
* Gets, sets and removes custom data to be stored as HTML5 data-* attributes.
- * @name CKEDITOR.dom.element.data
- * @param {String} name The name of the attribute, execluding the 'data-' part.
+ * @param {String} name The name of the attribute, excluding the 'data-' part.
* @param {String} [value] The value to set. If set to false, the attribute will be removed.
+ * @example
+ * element.data( 'extra-info', 'test' ); // appended the attribute data-extra-info="test" to the element
+ * alert( element.data( 'extra-info' ) ); // "test"
+ * element.data( 'extra-info', false ); // remove the data-extra-info attribute from the element
*/
data : function ( name, value )
{
@@ -1560,6 +1604,8 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
this.removeAttribute( name );
else
this.setAttribute( name, value );
+
+ return null;
}
});
@@ -1579,11 +1625,12 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
}
/**
- * Update the element's size with box model awareness.
- * @name CKEDITOR.dom.element.setSize
- * @param {String} type [width|height]
+ * Sets the element size considering the box model.
+ * @name CKEDITOR.dom.element.prototype.setSize
+ * @function
+ * @param {String} type The dimension to set. It accepts "width" and "height".
* @param {Number} size The length unit in px.
- * @param isBorderBox Apply the {@param width} and {@param height} based on border box model.
+ * @param {Boolean} isBorderBox Apply the size based on the border box model.
*/
CKEDITOR.dom.element.prototype.setSize = function( type, size, isBorderBox )
{
@@ -1597,17 +1644,18 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
};
/**
- * Get the element's size, possibly with box model awareness.
- * @name CKEDITOR.dom.element.getSize
- * @param {String} type [width|height]
- * @param {Boolean} contentSize Get the {@param width} or {@param height} based on border box model.
+ * Gets the element size, possibly considering the box model.
+ * @name CKEDITOR.dom.element.prototype.getSize
+ * @function
+ * @param {String} type The dimension to get. It accepts "width" and "height".
+ * @param {Boolean} isBorderBox Get the size based on the border box model.
*/
- CKEDITOR.dom.element.prototype.getSize = function( type, contentSize )
+ CKEDITOR.dom.element.prototype.getSize = function( type, isBorderBox )
{
var size = Math.max( this.$[ 'offset' + CKEDITOR.tools.capitalize( type ) ],
this.$[ 'client' + CKEDITOR.tools.capitalize( type ) ] ) || 0;
- if ( contentSize )
+ if ( isBorderBox )
size -= marginAndPaddingSize.call( this, type );
return size;