Changeset 706

Show
Ignore:
Timestamp:
2007-08-23 01:23:53 (17 months ago)
Author:
fredck
Message:

Changes to Martin's proposal for #212:

  • Moved the styles to fck_internal.css. In this way our code is much simpler (almost ridiculous :)). It also makes it clearer to customize it.
  • Corrected the icon position and included it in the Office2003 and Silver skins.
Location:
FCKeditor/trunk/editor
Files:
10 added
10 removed
9 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/css/fck_internal.css

    r228 r706  
    2222 */ 
    2323 
    24 /* Fix to allow putting the caret at the end of the 
    25 content in Firefox if clicking below the content */ 
     24/* Fix to allow putting the caret at the end of the content in Firefox if 
     25   clicking below the content. */ 
    2626html 
    2727{ 
    2828        min-height: 100%; 
    2929} 
    30  
    3130 
    3231table.FCK__ShowTableBorders, table.FCK__ShowTableBorders td, table.FCK__ShowTableBorders th 
     
    7372} 
    7473 
    75 /* Any anchor for non-IE, if we combine it 
    76    with the previous rule IE ignores all. */ 
     74/* Any anchor for non-IE, if we combine it with the previous rule IE ignores all. */ 
    7775a[name] 
    7876{ 
     
    110108        background-position: center center; 
    111109} 
     110 
     111.FCK__ShowBlocks p, 
     112.FCK__ShowBlocks div, 
     113.FCK__ShowBlocks pre, 
     114.FCK__ShowBlocks address, 
     115.FCK__ShowBlocks h1, 
     116.FCK__ShowBlocks h2, 
     117.FCK__ShowBlocks h3, 
     118.FCK__ShowBlocks h4, 
     119.FCK__ShowBlocks h5, 
     120.FCK__ShowBlocks h6 
     121{ 
     122        background-repeat: no-repeat; 
     123        border: 1px dotted gray; 
     124        padding-top: 8px; 
     125        padding-left: 8px; 
     126} 
     127 
     128.FCK__ShowBlocks p 
     129{ 
     130        background-image: url(images/block_p.png); 
     131} 
     132 
     133.FCK__ShowBlocks div 
     134{ 
     135        background-image: url(images/block_div.png); 
     136} 
     137 
     138.FCK__ShowBlocks pre 
     139{ 
     140        background-image: url(images/block_pre.png); 
     141} 
     142 
     143.FCK__ShowBlocks address 
     144{ 
     145        background-image: url(images/block_address.png); 
     146} 
     147 
     148.FCK__ShowBlocks h1 
     149{ 
     150        background-image: url(images/block_h1.png); 
     151} 
     152 
     153.FCK__ShowBlocks h2 
     154{ 
     155        background-image: url(images/block_h2.png); 
     156} 
     157 
     158.FCK__ShowBlocks h3 
     159{ 
     160        background-image: url(images/block_h3.png); 
     161} 
     162 
     163.FCK__ShowBlocks h4 
     164{ 
     165        background-image: url(images/block_h4.png); 
     166} 
     167 
     168.FCK__ShowBlocks h5 
     169{ 
     170        background-image: url(images/block_h5.png); 
     171} 
     172 
     173.FCK__ShowBlocks h6 
     174{ 
     175        background-image: url(images/block_h6.png); 
     176} 
  • FCKeditor/trunk/editor/_source/commandclasses/fckshowblocks.js

    r702 r706  
    2525{ 
    2626        this.Name = name ; 
    27         this.CSSText = this._GetCSSText( ['p', 'div', 'pre', 'address', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'] ) ; 
    28         this.StyleSheetObj = null ; 
    2927} 
     28 
    3029FCKShowBlockCommand.prototype.Execute = function() 
    3130{ 
    32         if ( this._IsVisible() ) 
    33                 this._SetInvisible() ; 
     31        var state = this.GetState() ; 
     32 
     33        if ( state == FCK_TRISTATE_DISABLED ) 
     34                return false ; 
     35 
     36        var body = FCK.EditorDocument.body ; 
     37 
     38        if ( state == FCK_TRISTATE_ON ) 
     39                body.className = body.className.replace( /(^| )FCK__ShowBlocks/g, '' ) ; 
    3440        else 
    35                 this._SetVisible() ; 
     41                body.className += ' FCK__ShowBlocks' ; 
     42 
    3643        FCK.Events.FireEvent( 'OnSelectionChange' ) ; 
    3744} 
     45 
    3846FCKShowBlockCommand.prototype.GetState = function() 
    3947{ 
    4048        if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) 
    4149                return FCK_TRISTATE_DISABLED ; 
    42         return this._IsVisible() ? FCK_TRISTATE_ON : FCK_TRISTATE_OFF ; 
    43 } 
    44 FCKShowBlockCommand.prototype._IsVisible = function() 
    45 { 
    46         // The try.. catch... statements are here because accessing a stylesheet object of an inactive  
    47         // document would raise access denied error in IE. 
    48         // In such a case, we should clear the reference to prevent further errors, before returning false. 
     50 
     51        // On some cases FCK.EditorDocument.body is not yet available, so try/catch. 
    4952        try 
    5053        { 
    51                 if ( ! this.StyleSheetObj ) 
    52                         return false ; 
     54                if ( /FCK__ShowBlocks(?:\s|$)/.test( FCK.EditorDocument.body.className ) ) 
     55                        return FCK_TRISTATE_ON ; 
    5356        } 
    54         catch ( e ) 
    55         { 
    56                 this.StyleSheetObj = null ; 
    57                 return false ; 
    58         } 
    59         if ( FCKBrowserInfo.IsIE ) 
    60         { 
    61                 try 
    62                 { 
    63                         if ( this.StyleSheetObj.cssText == ''  
    64                                         || ! this.StyleSheetObj.owningElement  
    65                                         || this.StyleSheetObj.owningElement.ownerDocument != FCK.EditorDocument ) 
    66                                 return false ; 
    67                         else 
    68                                 return true ; 
    69                 } 
    70                 catch ( e ) 
    71                 { 
    72                         this.StyleSheetObj = null ; 
    73                         return false ; 
    74                 } 
    75         } 
    76         else 
    77         { 
    78                 if ( this.StyleSheetObj.parentNode && this.StyleSheetObj.ownerDocument == FCK.EditorDocument ) 
    79                         return true ; 
    80                 else 
    81                         return false ; 
    82         } 
     57        catch (e) 
     58        {} 
     59 
     60        return FCK_TRISTATE_OFF ; 
    8361} 
    84 FCKShowBlockCommand.prototype._SetVisible = function() 
    85 { 
    86         if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) 
    87                 return ; 
    88         if ( ! this.StyleSheetObj ) 
    89         { 
    90                 this.StyleSheetObj = FCKTools._AppendStyleString( FCK.EditorDocument, this.CSSText ) ; 
    91                 return ; 
    92         } 
    93  
    94         if ( FCKBrowserInfo.IsIE ) 
    95                 this.StyleSheetObj.cssText = this.CSSText ; 
    96         else 
    97                 FCK.EditorDocument.getElementsByTagName( 'head' )[0].appendChild( this.StyleSheetObj ) ; 
    98 } 
    99 FCKShowBlockCommand.prototype._SetInvisible = function() 
    100 { 
    101         if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) 
    102                 return ; 
    103         if ( ! this.StyleSheetObj ) 
    104                 return ; 
    105  
    106         if ( FCKBrowserInfo.IsIE ) 
    107                 this.StyleSheetObj.cssText = '' ; 
    108         else 
    109         { 
    110                 if ( this.StyleSheetObj.parentNode ) 
    111                         this.StyleSheetObj.parentNode.removeChild( this.StyleSheetObj ) ; 
    112         } 
    113 } 
    114 FCKShowBlockCommand.prototype._GetCSSText = function( tags ) 
    115 { 
    116         var template = '$TAG' 
    117                         + '{' 
    118                         + 'background-image: url($BASEPATHimages/block_$TAG.png);'  
    119                         + 'background-repeat: no-repeat;'  
    120                         + 'border: 1px dotted gray;' 
    121                         + 'padding-top: 8px;' 
    122                         + 'padding-left: 8px;' 
    123                         + '}\n'; 
    124  
    125         var retval = '' ; 
    126         for ( var i = 0 ; i < tags.length ; i++ ) 
    127                 retval += template.replace( new RegExp( '\\$TAG', 'g' ), tags[i] ) ; 
    128         retval = retval.replace( new RegExp( '\\$BASEPATH', 'g' ), FCKConfig.BasePath ) ; 
    129         return retval ; 
    130 } 
  • FCKeditor/trunk/editor/_source/internals/fckregexlib.js

    r704 r706  
    5050 
    5151// Temporary classes (Tables without border, Anchors with content) used in IE 
    52 FCK_Class               : /FCK__[^ ]*\s*/ , 
     52FCK_Class               : /\s*FCK__[^ ]*(?=\s+|$)/ , 
    5353 
    5454// Validate element names (it must be in lowercase). 
  • FCKeditor/trunk/editor/_source/internals/fckxhtml_gecko.js

    r694 r706  
    5454                        //              - for the "class" attribute 
    5555                        else if ( sAttName == 'class' ) 
    56                                 sAttValue = oAttribute.nodeValue ; 
     56                        { 
     57                                sAttValue = oAttribute.nodeValue.replace( FCKRegexLib.FCK_Class, '' ) ; 
     58                                if ( sAttValue.length == 0 ) 
     59                                        continue ; 
     60                        } 
    5761                        // XHTML doens't support attribute minimization like "CHECKED". It must be transformed to checked="checked". 
    5862                        else if ( oAttribute.nodeValue === true ) 
  • FCKeditor/trunk/editor/_source/internals/fckxhtml_ie.js

    r694 r706  
    5555                        //              - for the "class" attribute 
    5656                        //              - for events attributes (on IE only). 
    57                         else if ( sAttName == 'class' || sAttName.indexOf('on') == 0 ) 
     57                        else if ( sAttName == 'class' ) 
     58                        { 
     59                                sAttValue = oAttribute.nodeValue.replace( FCKRegexLib.FCK_Class, '' ) ; 
     60                                if ( sAttValue.length == 0 ) 
     61                                        continue ; 
     62                        } 
     63                        else if ( sAttName.indexOf('on') == 0 ) 
    5864                                sAttValue = oAttribute.nodeValue ; 
    5965                        else if ( nodeName == 'body' && sAttName == 'contenteditable' ) 
  • FCKeditor/trunk/editor/_source/internals/fckxhtml.js

    r640 r706  
    325325} 
    326326 
    327 // Remove part of an attribute from a node according to a regExp 
    328 FCKXHtml._RemoveAttribute = function( xmlNode, regX, sAttribute ) 
    329 { 
    330         var oAtt = xmlNode.attributes.getNamedItem( sAttribute ) ; 
    331  
    332         if ( oAtt && regX.test( oAtt.nodeValue ) ) 
    333         { 
    334                 var sValue = oAtt.nodeValue.replace( regX, '' ) ; 
    335  
    336                 if ( sValue.length == 0 ) 
    337                         xmlNode.attributes.removeNamedItem( sAttribute ) ; 
    338                 else 
    339                         oAtt.nodeValue = sValue ; 
    340         } 
    341 } 
    342  
    343327// An object that hold tag specific operations. 
    344328FCKXHtml.TagProcessors = 
     
    371355                if ( FCKBrowserInfo.IsIE ) 
    372356                { 
    373                         FCKXHtml._RemoveAttribute( node, FCKRegexLib.FCK_Class, 'class' ) ; 
    374  
    375357                        // Buggy IE, doesn't copy the name of changed anchors. 
    376358                        if ( htmlNode.name ) 
     
    426408        }, 
    427409 
    428         table : function( node, htmlNode ) 
    429         { 
    430                 // There is a trick to show table borders when border=0. We add to the 
    431                 // table class the FCK__ShowTableBorders rule. So now we must remove it. 
    432  
    433                 if ( FCKBrowserInfo.IsIE ) 
    434                         FCKXHtml._RemoveAttribute( node, FCKRegexLib.FCK_Class, 'class' ) ; 
    435  
    436                 node = FCKXHtml._AppendChildNodes( node, htmlNode, false ) ; 
    437  
    438                 return node ; 
    439         }, 
    440  
    441410        // Fix nested <ul> and <ol>. 
    442411        ol : function( node, htmlNode, targetNode )