JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.1.1
[ckeditor.git] / _source / plugins / styles / plugin.js
index 278f532..29a2112 100644 (file)
@@ -209,7 +209,7 @@ CKEDITOR.STYLE_OBJECT = 3;
                                                else if ( fullMatch )\r
                                                                return false;\r
                                        }\r
-                                       if( fullMatch )\r
+                                       if ( fullMatch )\r
                                                return true;\r
                                }\r
                                else\r
@@ -375,13 +375,17 @@ CKEDITOR.STYLE_OBJECT = 3;
                                }\r
 \r
                                // Check if the current node can be a child of the style element.\r
-                               if ( !nodeName || ( dtd[ nodeName ] && ( currentNode.getPosition( lastNode ) | CKEDITOR.POSITION_PRECEDING | CKEDITOR.POSITION_IDENTICAL | CKEDITOR.POSITION_IS_CONTAINED ) == ( CKEDITOR.POSITION_PRECEDING + CKEDITOR.POSITION_IDENTICAL + CKEDITOR.POSITION_IS_CONTAINED ) ) )\r
+                               if ( !nodeName || ( dtd[ nodeName ]\r
+                                       && ( currentNode.getPosition( lastNode ) | CKEDITOR.POSITION_PRECEDING | CKEDITOR.POSITION_IDENTICAL | CKEDITOR.POSITION_IS_CONTAINED ) == ( CKEDITOR.POSITION_PRECEDING + CKEDITOR.POSITION_IDENTICAL + CKEDITOR.POSITION_IS_CONTAINED )\r
+                                       && ( !def.childRule || def.childRule( currentNode ) ) ) )\r
                                {\r
                                        var currentParent = currentNode.getParent();\r
 \r
                                        // Check if the style element can be a child of the current\r
                                        // node parent or if the element is not defined in the DTD.\r
-                                       if ( currentParent && ( ( currentParent.getDtd() || CKEDITOR.dtd.span )[ elementName ] || isUnknownElement ) )\r
+                                       if ( currentParent\r
+                                               && ( ( currentParent.getDtd() || CKEDITOR.dtd.span )[ elementName ] || isUnknownElement )\r
+                                               && ( !def.parentRule || def.parentRule( currentParent ) ) )\r
                                        {\r
                                                // This node will be part of our range, so if it has not\r
                                                // been started, place its start right before the node.\r
@@ -406,7 +410,8 @@ CKEDITOR.STYLE_OBJECT = 3;
                                                        // to the range.\r
                                                        while ( !includedNode.$.nextSibling\r
                                                                && ( parentNode = includedNode.getParent(), dtd[ parentNode.getName() ] )\r
-                                                               && ( parentNode.getPosition( firstNode ) | CKEDITOR.POSITION_FOLLOWING | CKEDITOR.POSITION_IDENTICAL | CKEDITOR.POSITION_IS_CONTAINED ) == ( CKEDITOR.POSITION_FOLLOWING + CKEDITOR.POSITION_IDENTICAL + CKEDITOR.POSITION_IS_CONTAINED ) )\r
+                                                               && ( parentNode.getPosition( firstNode ) | CKEDITOR.POSITION_FOLLOWING | CKEDITOR.POSITION_IDENTICAL | CKEDITOR.POSITION_IS_CONTAINED ) == ( CKEDITOR.POSITION_FOLLOWING + CKEDITOR.POSITION_IDENTICAL + CKEDITOR.POSITION_IS_CONTAINED )\r
+                                                               && ( !def.childRule || def.childRule( parentNode ) ) )\r
                                                        {\r
                                                                includedNode = parentNode;\r
                                                        }\r
@@ -575,7 +580,7 @@ CKEDITOR.STYLE_OBJECT = 3;
                                        if ( newElement.equals( boundaryElement ) )\r
                                                break;\r
                                        // Avoid copying any matched element.\r
-                                       else if( newElement.match )\r
+                                       else if ( newElement.match )\r
                                                continue;\r
                                        else\r
                                                newElement = newElement.clone();\r
@@ -645,7 +650,7 @@ CKEDITOR.STYLE_OBJECT = 3;
                                if ( currentNode.type == CKEDITOR.NODE_ELEMENT && this.checkElementRemovable( currentNode ) )\r
                                {\r
                                        // Remove style from element or overriding element.\r
-                                       if( currentNode.getName() == this.element )\r
+                                       if ( currentNode.getName() == this.element )\r
                                                removeFromElement( this, currentNode );\r
                                        else\r
                                                removeOverrides( currentNode, getOverrides( this )[ currentNode.getName() ] );\r
@@ -682,7 +687,7 @@ CKEDITOR.STYLE_OBJECT = 3;
                var doc = range.document;\r
                var previousPreBlock;\r
 \r
-               while( ( block = iterator.getNextParagraph() ) )                // Only one =\r
+               while ( ( block = iterator.getNextParagraph() ) )               // Only one =\r
                {\r
                        var newBlock = getElement( this, doc );\r
                        replaceBlock( block, newBlock );\r
@@ -890,7 +895,7 @@ CKEDITOR.STYLE_OBJECT = 3;
 \r
                // Now remove override styles on the element.\r
                attributes = overrides[ element.getName() ];\r
-               if( attributes )\r
+               if ( attributes )\r
                        removeAttrs();\r
                removeNoAttribsElement( element );\r
        }\r
@@ -1126,7 +1131,7 @@ CKEDITOR.STYLE_OBJECT = 3;
         */\r
        function getOverrides( style )\r
        {\r
-               if( style._.overrides )\r
+               if ( style._.overrides )\r
                        return style._.overrides;\r
 \r
                var overrides = ( style._.overrides = {} ),\r
@@ -1191,7 +1196,7 @@ CKEDITOR.STYLE_OBJECT = 3;
                        // retrieving its final format.\r
                        var temp = new CKEDITOR.dom.element( 'span' );\r
                        temp.setAttribute( 'style', unparsedCssText );\r
-                       styleText = temp.getAttribute( 'style' );\r
+                       styleText = temp.getAttribute( 'style' ) || '';\r
                }\r
                else\r
                        styleText = unparsedCssText;\r