JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.1.1
[ckeditor.git] / _source / plugins / pastefromword / filter / default.js
index 745bda3..b042a33 100644 (file)
@@ -25,7 +25,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                for ( var i = 0; i < children.length; i++ )\r
                {\r
                        child = children[ i ];\r
-                       if( !child.name )\r
+                       if ( !child.name )\r
                                continue;\r
 \r
                        if ( child.name == tagName )\r
@@ -80,9 +80,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        // style literal.\r
                        if ( typeof name == 'object' )\r
                        {\r
-                               for( var style in name )\r
+                               for ( var style in name )\r
                                {\r
-                                       if( name.hasOwnProperty( style ) )\r
+                                       if ( name.hasOwnProperty( style ) )\r
                                                addingStyleText += style + ':' + name[ style ] + ';';\r
                                }\r
                        }\r
@@ -93,7 +93,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        isPrepend = value;\r
                }\r
 \r
-               if( !this.attributes )\r
+               if ( !this.attributes )\r
                        this.attributes = {};\r
 \r
                styleText = this.attributes.style || '';\r
@@ -186,7 +186,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        isListBulletIndicator : function( element )\r
                        {\r
                                var styleText = element.attributes && element.attributes.style;\r
-                               if( /mso-list\s*:\s*Ignore/i.test( styleText ) )\r
+                               if ( /mso-list\s*:\s*Ignore/i.test( styleText ) )\r
                                        return true;\r
                        },\r
 \r
@@ -257,7 +257,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                                return function( cssLength )\r
                                {\r
-                                       if( cssLengthRelativeUnit.test( cssLength ) )\r
+                                       if ( cssLengthRelativeUnit.test( cssLength ) )\r
                                        {\r
                                                calculator.setStyle( 'width', cssLength );\r
                                                return calculator.$.clientWidth + 'px';\r
@@ -328,14 +328,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                child = children[ i ];\r
                                                var attributes = child.attributes;\r
 \r
-                                               if( child.name in CKEDITOR.dtd.$listItem )\r
+                                               if ( child.name in CKEDITOR.dtd.$listItem )\r
                                                {\r
                                                        var listItemChildren = child.children,\r
                                                                count = listItemChildren.length,\r
                                                                last = listItemChildren[ count - 1 ];\r
 \r
                                                        // Move out nested list.\r
-                                                       if( last.name in CKEDITOR.dtd.$list )\r
+                                                       if ( last.name in CKEDITOR.dtd.$list )\r
                                                        {\r
                                                                children.splice( i + 1, 0, last );\r
                                                                last.parent = element;\r
@@ -420,8 +420,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                {\r
                                                                        // There might be a negative gap between two list levels. (#4944)\r
                                                                        var diff = indent - listItemIndent,\r
-                                                                               parent = list.parent;\r
-                                                                       while( diff-- && parent )\r
+                                                                               parent;\r
+                                                                       while ( diff-- && ( parent = list.parent ) )\r
                                                                                list = parent.parent;\r
 \r
                                                                        list.add( listItem );\r
@@ -477,9 +477,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                 valuePattern,\r
                                                                                 newValue,\r
                                                                                 newName;\r
-                                                                        for( var i = 0 ; i < styles.length; i++ )\r
+                                                                        for ( var i = 0 ; i < styles.length; i++ )\r
                                                                         {\r
-                                                                               if( styles[ i ] )\r
+                                                                               if ( styles[ i ] )\r
                                                                                {\r
                                                                                        namePattern = styles[ i ][ 0 ];\r
                                                                                        valuePattern = styles[ i ][ 1 ];\r
@@ -492,15 +492,15 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                name = newName || name;\r
                                                                                                whitelist && ( newValue = newValue || value );\r
 \r
-                                                                                               if( typeof newValue == 'function' )\r
+                                                                                               if ( typeof newValue == 'function' )\r
                                                                                                        newValue = newValue( value, element, name );\r
 \r
                                                                                                // Return an couple indicate both name and value\r
                                                                                                // changed.\r
-                                                                                               if( newValue && newValue.push )\r
+                                                                                               if ( newValue && newValue.push )\r
                                                                                                        name = newValue[ 0 ], newValue = newValue[ 1 ];\r
 \r
-                                                                                               if( typeof newValue == 'string' )\r
+                                                                                               if ( typeof newValue == 'string' )\r
                                                                                                        rules.push( [ name, newValue ] );\r
                                                                                                return;\r
                                                                                        }\r
@@ -567,7 +567,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                 */\r
                                bogusAttrFilter : function( value, element )\r
                                {\r
-                                       if( element.name.indexOf( 'cke:' ) == -1 )\r
+                                       if ( element.name.indexOf( 'cke:' ) == -1 )\r
                                                return false;\r
                                },\r
 \r
@@ -645,7 +645,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                {\r
                                                        element.filterChildren();\r
                                                        // Is the heading actually a list item?\r
-                                                       if( resolveListItem( element ) )\r
+                                                       if ( resolveListItem( element ) )\r
                                                                return;\r
 \r
                                                        // Adapt heading styles to editor's convention.\r
@@ -720,12 +720,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                        className = className.substring( 1, className.length );\r
 \r
                                                                                                        // Reject MS-Word Normal styles.\r
-                                                                                                       if( className.match( /MsoNormal/ ) )\r
+                                                                                                       if ( className.match( /MsoNormal/ ) )\r
                                                                                                                return;\r
 \r
-                                                                                                       if( !rules[ tagName ] )\r
+                                                                                                       if ( !rules[ tagName ] )\r
                                                                                                                rules[ tagName ] = {};\r
-                                                                                                       if( className )\r
+                                                                                                       if ( className )\r
                                                                                                                rules[ tagName ][ className ] = styleBlock;\r
                                                                                                        else\r
                                                                                                                rules[ tagName ] = styleBlock;\r
@@ -738,10 +738,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                        var name = rules[ '*' ] ? '*' : element.name,\r
                                                                                className = element.attributes && element.attributes[ 'class' ],\r
                                                                                style;\r
-                                                                       if( name in rules )\r
+                                                                       if ( name in rules )\r
                                                                        {\r
                                                                                style = rules[ name ];\r
-                                                                               if( typeof style == 'object' )\r
+                                                                               if ( typeof style == 'object' )\r
                                                                                        style = style[ className ];\r
                                                                                // Maintain style rules priorities.\r
                                                                                style && element.addStyle( style, true );\r
@@ -782,7 +782,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                // table cells inherit as text-align styles, which is wrong.\r
                                                // Instead we use a clear-float div after the table to properly achieve the same layout.\r
                                                var singleChild = element.onlyChild();\r
-                                               if( singleChild && singleChild.name == 'table' )\r
+                                               if ( singleChild && singleChild.name == 'table' )\r
                                                {\r
                                                        var attrs = element.attributes;\r
                                                        singleChild.attributes = CKEDITOR.tools.extend( singleChild.attributes, attrs );\r
@@ -924,7 +924,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        'a' : function( element )\r
                                        {\r
                                                var attrs = element.attributes;\r
-                                               if( attrs && !attrs.href && attrs.name )\r
+                                               if ( attrs && !attrs.href && attrs.name )\r
                                                        delete element.name;\r
                                        },\r
                                        'cke:listbullet' : function( element )\r
@@ -983,14 +983,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                [ ( /^border.*|margin.*|vertical-align|float$/ ), null,\r
                                                        function( value, element )\r
                                                        {\r
-                                                               if( element.name == 'img' )\r
+                                                               if ( element.name == 'img' )\r
                                                                        return value;\r
                                                        } ],\r
 \r
                                                [ (/^width|height$/ ), null,\r
                                                        function( value, element )\r
                                                        {\r
-                                                               if( element.name in { table : 1, td : 1, th : 1, img : 1 } )\r
+                                                               if ( element.name in { table : 1, td : 1, th : 1, img : 1 } )\r
                                                                        return value;\r
                                                        } ]\r
                                        ] :\r
@@ -1000,9 +1000,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                // Fixing color values.\r
                                                [ ( /-color$/ ), null, function( value )\r
                                                {\r
-                                                       if( value == 'transparent' )\r
+                                                       if ( value == 'transparent' )\r
                                                                return false;\r
-                                                       if( CKEDITOR.env.gecko )\r
+                                                       if ( CKEDITOR.env.gecko )\r
                                                                return value.replace( /-moz-use-text-color/g, 'transparent' );\r
                                                } ],\r
                                                // Remove empty margin values, e.g. 0.00001pt 0em 0pt\r
@@ -1017,13 +1017,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        // Prefer width styles over 'width' attributes.\r
                                        'width' : function( value, element )\r
                                        {\r
-                                               if( element.name in dtd.$tableContent )\r
+                                               if ( element.name in dtd.$tableContent )\r
                                                        return false;\r
                                        },\r
                                        // Prefer border styles over table 'border' attributes.\r
                                        'border' : function( value, element )\r
                                        {\r
-                                               if( element.name in dtd.$tableContent )\r
+                                               if ( element.name in dtd.$tableContent )\r
                                                        return false;\r
                                        },\r
 \r
@@ -1064,7 +1064,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                        }\r
 \r
                                                        // Reveal the <img> element in conditional comments for Firefox.\r
-                                                       if( CKEDITOR.env.gecko && imageInfo )\r
+                                                       if ( CKEDITOR.env.gecko && imageInfo )\r
                                                        {\r
                                                                var img = CKEDITOR.htmlParser.fragment.fromHtml( imageInfo[ 0 ] ).children[ 0 ],\r
                                                                        previousComment = node.previous,\r
@@ -1107,7 +1107,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                // Firefox will be confused by those downlevel-revealed IE conditional\r
                // comments, fixing them first( convert it to upperlevel-revealed one ).\r
                // e.g. <![if !vml]>...<![endif]>\r
-               if( CKEDITOR.env.gecko )\r
+               if ( CKEDITOR.env.gecko )\r
                        data = data.replace( /(<!--\[if[^<]*?\])-->([\S\s]*?)<!--(\[endif\]-->)/gi, '$1$2$3' );\r
 \r
                var dataProcessor = new pasteProcessor(),\r
@@ -1144,11 +1144,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 })();\r
 \r
 /**\r
- * Whether the ignore all font-related format styles, including:\r
- * - font size;\r
- * - font family;\r
- * - font fore/background color;\r
+ * Whether to ignore all font related formatting styles, including:\r
+ * <ul>        <li>font size;</li>\r
+ *             <li>font family;</li>\r
+ *             <li>font foreground/background color.</li></ul>\r
  * @name CKEDITOR.config.pasteFromWordRemoveFontStyles\r
+ * @since 3.1\r
  * @type Boolean\r
  * @default true\r
  * @example\r
@@ -1156,8 +1157,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
  */\r
 \r
 /**\r
- * Whether transform MS-Word Outline Numbered Heading into html list.\r
+ * Whether to transform MS Word outline numbered headings into lists.\r
  * @name CKEDITOR.config.pasteFromWordNumberedHeadingToList\r
+ * @since 3.1\r
  * @type Boolean\r
  * @default false\r
  * @example\r
@@ -1165,10 +1167,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
  */\r
 \r
 /**\r
- * Whether remove element styles that can't be managed with editor, note that this\r
- * this doesn't handle the font-specific styles, which depends on\r
- * how {@link CKEDITOR.config.pasteFromWordRemoveFontStyles} is configured.\r
+ * Whether to remove element styles that can't be managed with the editor. Note\r
+ * that this doesn't handle the font specific styles, which depends on the\r
+ * {@link CKEDITOR.config.pasteFromWordRemoveFontStyles} setting instead.\r
  * @name CKEDITOR.config.pasteFromWordRemoveStyles\r
+ * @since 3.1\r
  * @type Boolean\r
  * @default true\r
  * @example\r