Ticket #1011: 1011.patch

File 1011.patch, 5.0 KB (added by Artur Formella, 16 years ago)
  • fckeditor_config.js

     
    1212        ['Cut','Copy','Paste',/*'PasteText','PasteWord',*/'-','Print'],
    1313        ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
    1414        ['SpecialChar','Table','Image','Rule'],
    15         ['MW_Template','MW_Special','MW_Ref','MW_References','MW_Math'],
     15        ['MW_Template','MW_Special','MW_Ref','MW_References','MW_Math','MW_Signature'],
    1616        '/',
    1717        ['FontFormat'],
    1818        ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
     
    3636// FCKConfig.DisableObjectResizing = true ;
    3737
    3838FCKConfig.EditorAreaStyles = '\
    39 .FCK__MWTemplate, .FCK__MWRef, .FCK__MWSpecial, .FCK__MWReferences, .FCK__MWMath, .FCK__MWNowiki, .FCK__MWIncludeonly, .FCK__MWNoinclude, .FCK__MWOnlyinclude, .FCK__MWGallery \
     39.FCK__MWTemplate, .FCK__MWRef, .FCK__MWSignature, .FCK__MWSpecial, .FCK__MWReferences, .FCK__MWMath, .FCK__MWNowiki, .FCK__MWIncludeonly, .FCK__MWNoinclude, .FCK__MWOnlyinclude, .FCK__MWGallery \
    4040{ \
    4141        border: 1px dotted #00F; \
    4242        background-position: center center; \
     
    103103        width: 66px; \
    104104        height: 15px; \
    105105} \
     106.FCK__MWSignature \
     107{ \
     108        background-image: url(' + FCKConfig.PluginsPath + 'mediawiki/images/icon_signature.gif); \
     109        width: 66px; \
     110        height: 15px; \
     111} \
    106112.FCK__MWReferences \
    107113{ \
    108114        background-image: url(' + FCKConfig.PluginsPath + 'mediawiki/images/icon_references.gif); \
  • plugins/mediawiki/fckplugin.js

     
    7474}
    7575FCKToolbarItems.RegisterItem( 'MW_References', tbButton ) ;
    7676
     77//Signature button
     78var FCKSignature = function( )  {       } ;
     79FCKSignature.prototype.GetState = function()    { return ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED) } ;
     80FCKCommands.RegisterCommand( 'MW_Signature', new FCKSignature() ) ;
     81tbButton = new FCKToolbarButton( 'MW_Signature', 'Signature', FCKLang.wikiBtnSignature || 'Insert signature', FCK_TOOLBARITEM_ONLYICON,true, true, 1  );
     82tbButton.IconPath = FCKConfig.PluginsPath + 'mediawiki/images/tb_signature.gif' ;
     83
     84FCKSignature.prototype.Execute = function()
     85{
     86        if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
     87                return ;
     88       
     89        FCKUndo.SaveUndoStep() ;
     90        var e = FCK.EditorDocument.createElement( 'span' ) ;
     91        e.className = "fck_mw_signature";
     92       
     93        oFakeImage = FCK.InsertElement( FCKDocumentProcessor_CreateFakeImage( 'FCK__MWSignature', e ) ) ;
     94}
     95FCKToolbarItems.RegisterItem( 'MW_Signature', tbButton ) ;
     96
    7797tbButton = new FCKToolbarButton( 'MW_Math', 'Formula', FCKLang.wikiBtnFormula || 'Insert/Edit Formula' ) ;
    7898tbButton.IconPath = FCKConfig.PluginsPath + 'mediawiki/images/tb_icon_math.gif' ;
    7999FCKToolbarItems.RegisterItem( 'MW_Math', tbButton ) ;
     
    579599                                                                        stringBuilder.push( '<references />' ) ;
    580600                                                                        return ;
    581601
     602                                                                case 'fck_mw_signature' :
     603                                                                        stringBuilder.push( '--~~~~' ) ;
     604                                                                        return ;
     605
    582606                                                                case 'fck_mw_template' :
    583607                                                                        stringBuilder.push( FCKTools.HTMLDecode(htmlNode.innerHTML).replace(/fckLR/g,'\r\n') ) ;
    584608                                                                        return ;
     
    689713
    690714                                var parentIsSpecialTag = htmlNode.parentNode.getAttribute( '_fck_mw_customtag' ) ;
    691715                                var textValue = htmlNode.nodeValue;
    692        
     716
    693717                                if ( !parentIsSpecialTag )
    694718                                {
    695719                                        if ( FCKBrowserInfo.IsIE && this._inLSpace ) {
     
    887911// MediaWiki document processor.
    888912FCKDocumentProcessor.AppendNew().ProcessDocument = function( document )
    889913{
     914        //Change Signatures to SPANS.
     915  var aTextNodes = document.getElementsByTagName( '*' ) ;       
     916  var i = 0 ;
     917  while (element = aTextNodes[i++]) {
     918    var nodes = element.childNodes ;
     919    var j = 0 ;
     920    while ( node = nodes[j++] )
     921                {
     922      if (node.nodeType == 3) {         //textNode
     923                                var index = 0 ;
     924                                while (aSignatures = node.nodeValue.match( /--~~~~/g ))                 //#1011: change Signatures to SPANs.
     925                                {
     926                                        index = node.nodeValue.indexOf(aSignatures[0]) ;
     927                                        if (index != -1)
     928                                        {
     929                                                var e = FCK.EditorDocument.createElement( 'span' ) ;
     930                                                e.className = "fck_mw_signature";
     931            var oFakeImage = FCKDocumentProcessor_CreateFakeImage( 'FCK__MWSignature', e ) ;
     932
     933                                                var substr1 = FCK.EditorDocument.createTextNode( node.nodeValue.substring(0, index) ) ;
     934                                                var substr2 = FCK.EditorDocument.createTextNode( node.nodeValue.substring(index + aSignatures[0].length) ) ;
     935
     936                                                node.parentNode.insertBefore( substr1, node ) ;
     937                                                node.parentNode.insertBefore( oFakeImage, node ) ;
     938                                                node.parentNode.insertBefore( substr2, node ) ;
     939
     940                                                node.parentNode.removeChild( node ) ;
     941                                                if ( node ) node.nodeValue = '' ;
     942                                        }
     943                                }
     944                        }
     945                }
     946        }
     947
     948       
    890949        // Templates and magic words.
    891950        var aSpans = document.getElementsByTagName( 'SPAN' ) ;
    892951       
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy