Mercurial > moin > 1.9
changeset 4018:6d7d40363f3c
Code reformatting : indent and insert new line to most of moinmoin fckeditor plugin
author | Byeongweon [tasyblue@gmail.com] |
---|---|
date | Sun, 17 Aug 2008 23:18:35 +0900 |
parents | 05f8344e6085 |
children | db5023512482 |
files | wiki/htdocs/applets/moinFCKplugins/macro/fckplugin.js wiki/htdocs/applets/moinFCKplugins/moinbehaviour/fckplugin.js wiki/htdocs/applets/moinFCKplugins/moinformat/fckplugin.js wiki/htdocs/applets/moinFCKplugins/moinlink/fck_link.js wiki/htdocs/applets/moinFCKplugins/moinlink/fckplugin.js wiki/htdocs/applets/moinFCKplugins/moinunlink/fckplugin.js wiki/htdocs/applets/moinFCKplugins/placeholder/fckplugin.js wiki/htdocs/applets/moinFCKplugins/restrict_actions/fckplugin.js wiki/htdocs/applets/moinFCKplugins/selection/fckplugin.js |
diffstat | 9 files changed, 183 insertions(+), 187 deletions(-) [+] |
line wrap: on
line diff
--- a/wiki/htdocs/applets/moinFCKplugins/macro/fckplugin.js Sun Aug 17 23:00:51 2008 +0900 +++ b/wiki/htdocs/applets/moinFCKplugins/macro/fckplugin.js Sun Aug 17 23:18:35 2008 +0900 @@ -1,25 +1,21 @@ var oMacroItem; if (1 || !FCKBrowserInfo.IsIE){ + // Register the related command. + FCKCommands.RegisterCommand('Macro', new FCKDialogCommand('Macro', FCKLang.MacroDlgTitle, FCKConfig.WikiBasePath + FCKConfig.WikiPage + '?action=fckdialog&dialog=macro', 440, 300, FCKSelection.CheckForNodeNames, noFormat)); -// Register the related command. -FCKCommands.RegisterCommand('Macro', new FCKDialogCommand('Macro', FCKLang.MacroDlgTitle, FCKConfig.WikiBasePath + FCKConfig.WikiPage + '?action=fckdialog&dialog=macro', 440, 300, FCKSelection.CheckForNodeNames, noFormat)); - -oMacroItem = new FCKToolbarButton('Macro', FCKLang.MacroBtn, null, - null, false, true); + oMacroItem = new FCKToolbarButton('Macro', FCKLang.MacroBtn, null, null, false, true); } else { -FCKCommands.RegisterCommand('Macro', new FCKDialogCommand('Macro', FCKLang.MacroDlgTitle, FCKConfig.WikiBasePath + FCKConfig.WikiPage + '?action=fckdialog&dialog=macro', 440, 300, null, null)); -oMacroItem = new FCKToolbarButton('Macro', FCKLang.MacroBtn, null, - null, false, false); + FCKCommands.RegisterCommand('Macro', new FCKDialogCommand('Macro', FCKLang.MacroDlgTitle, FCKConfig.WikiBasePath + FCKConfig.WikiPage + '?action=fckdialog&dialog=macro', 440, 300, null, null)); + oMacroItem = new FCKToolbarButton('Macro', FCKLang.MacroBtn, null, null, false, false); } // Create the "Macro" toolbar button. oMacroItem.IconPath = FCKPlugins.Items['macro'].Path + 'macro.gif'; FCKToolbarItems.RegisterItem('Macro', oMacroItem); - // The object used for all Macro operations. var FCKMacros = new Object();
--- a/wiki/htdocs/applets/moinFCKplugins/moinbehaviour/fckplugin.js Sun Aug 17 23:00:51 2008 +0900 +++ b/wiki/htdocs/applets/moinFCKplugins/moinbehaviour/fckplugin.js Sun Aug 17 23:18:35 2008 +0900 @@ -8,32 +8,32 @@ { var e = FCK.EditorWindow.event; if (e.keyCode == 13) // ENTER - { - if (e.ctrlKey || e.altKey || e.shiftKey|| - !FCKSelection.HasAncestorNode("PRE")) - return true; + { + if (e.ctrlKey || e.altKey || e.shiftKey|| !FCKSelection.HasAncestorNode("PRE")) { + return true; + } + else + { + FCKSelection.Delete(); + var oTmpNode = FCK.CreateElement("B"); + oTmpNode.innerHTML = " "; + if (oTmpNode.previousSibling && oTmpNode.previousSibling.nodeType==3) + { + oTmpNode.previousSibling.nodeValue = + oTmpNode.previousSibling.nodeValue + '\r'; + } else - { - FCKSelection.Delete(); - var oTmpNode = FCK.CreateElement("B"); - oTmpNode.innerHTML = " "; - if (oTmpNode.previousSibling && oTmpNode.previousSibling.nodeType==3) - { - oTmpNode.previousSibling.nodeValue = - oTmpNode.previousSibling.nodeValue + '\r'; - } - else - { - var oTxt = FCK.EditorDocument.createTextNode('\r'); - oTmpNode.parentNode.insertBefore(oTxt, oTmpNode); - } - var oRange = FCK.EditorDocument.selection.createRange(); - oRange.moveToElementText(oTmpNode); - oRange.select(); - FCK.EditorDocument.selection.clear(); - return false; - } + { + var oTxt = FCK.EditorDocument.createTextNode('\r'); + oTmpNode.parentNode.insertBefore(oTxt, oTmpNode); + } + var oRange = FCK.EditorDocument.selection.createRange(); + oRange.moveToElementText(oTmpNode); + oRange.select(); + FCK.EditorDocument.selection.clear(); + return false; } + } return true; } @@ -45,13 +45,14 @@ if (e.keyCode == 8 || e.keyCode==46) // backspace, delete { */ - var oNode = FCKSelection.GetParentElement(); - var siHTML = oNode.innerHTML; - if (siHTML.search(/ /i)!=-1) - { - oNode.normalize(); - alert("DING"); - } + var oNode = FCKSelection.GetParentElement(); + var siHTML = oNode.innerHTML; + + if (siHTML.search(/ /i)!=-1) + { + oNode.normalize(); + alert("DING"); + } // } } /* ##########################################################################
--- a/wiki/htdocs/applets/moinFCKplugins/moinformat/fckplugin.js Sun Aug 17 23:00:51 2008 +0900 +++ b/wiki/htdocs/applets/moinFCKplugins/moinformat/fckplugin.js Sun Aug 17 23:18:35 2008 +0900 @@ -19,8 +19,8 @@ var MoinToolbarFontFormatCombo = function() { - this.CommandName = 'FontFormat'; - this.Command = FCKCommands.GetCommand(this.CommandName); + this.CommandName = 'FontFormat'; + this.Command = FCKCommands.GetCommand(this.CommandName); } // Inherit from MoinToolbarSpecialCombo. @@ -28,31 +28,30 @@ MoinToolbarFontFormatCombo.prototype.GetLabel = function() { - return FCKLang.FontFormat; + return FCKLang.FontFormat; } MoinToolbarFontFormatCombo.prototype.CreateItems = function(targetSpecialCombo) { - // Get the format names from the language file. - var aNames = FCKLang['FontFormats'].split(';'); - var oNames = { - p : aNames[0], - pre : aNames[1], - h2 : aNames[3], // h2 as Title 1 - h3 : aNames[4], // and so on - h4 : aNames[5], - h5 : aNames[6], - h6 : aNames[7] - }; + // Get the format names from the language file. + var aNames = FCKLang['FontFormats'].split(';'); + var oNames = { + p : aNames[0], + pre : aNames[1], + h2 : aNames[3], // h2 as Title 1 + h3 : aNames[4], // and so on + h4 : aNames[5], + h5 : aNames[6], + h6 : aNames[7] + }; - // Get the available formats from the configuration file. - var aTags = FCKConfig.FontFormats.split(';'); - - for (var i in oNames) - { - this._Combo.AddItem(i, '<' + i + '>' + oNames[i] + '</' + i + '>', oNames[i]); - } + // Get the available formats from the configuration file. + var aTags = FCKConfig.FontFormats.split(';'); + + for (var i in oNames) + { + this._Combo.AddItem(i, '<' + i + '>' + oNames[i] + '</' + i + '>', oNames[i]); + } } FCKToolbarItems.RegisterItem( 'MoinFormat', new MoinToolbarFontFormatCombo()); -
--- a/wiki/htdocs/applets/moinFCKplugins/moinlink/fck_link.js Sun Aug 17 23:00:51 2008 +0900 +++ b/wiki/htdocs/applets/moinFCKplugins/moinlink/fck_link.js Sun Aug 17 23:18:35 2008 +0900 @@ -349,4 +349,3 @@ document.getElementById('txtUrl').value = url; OnUrlChange(); } -
--- a/wiki/htdocs/applets/moinFCKplugins/moinlink/fckplugin.js Sun Aug 17 23:00:51 2008 +0900 +++ b/wiki/htdocs/applets/moinFCKplugins/moinlink/fckplugin.js Sun Aug 17 23:18:35 2008 +0900 @@ -1,23 +1,20 @@ var noLink = /^(?:H1|H2|H3|H4|H5|H6|PRE|TT|IMG)$/i; -if (1 || !FCKBrowserInfo.IsIE){ - -function LinkState() +if (1 || !FCKBrowserInfo.IsIE) { - if (FCKSelection.CheckForNodeNames(noLink)) + function LinkState() { - return FCK_TRISTATE_DISABLED; + if (FCKSelection.CheckForNodeNames(noLink)) + { + return FCK_TRISTATE_DISABLED; + } + return (FCK.GetNamedCommandState('CreateLink')==FCK_TRISTATE_ON) ? FCK_TRISTATE_ON : FCK_TRISTATE_OFF; } - return (FCK.GetNamedCommandState('CreateLink')==FCK_TRISTATE_ON) ? - FCK_TRISTATE_ON : FCK_TRISTATE_OFF; -} -// Register the related command. -FCKCommands.RegisterCommand('Link', new FCKDialogCommand( 'Link', FCKLang.DlgLnkWindowTitle, FCKConfig.WikiBasePath + FCKConfig.WikiPage + '?action=fckdialog&dialog=link', 400, 330, LinkState, 'CreateLink')) ; - + // Register the related command. + FCKCommands.RegisterCommand('Link', new FCKDialogCommand( 'Link', FCKLang.DlgLnkWindowTitle, FCKConfig.WikiBasePath + FCKConfig.WikiPage + '?action=fckdialog&dialog=link', 400, 330, LinkState, 'CreateLink')); } else { -FCKCommands.RegisterCommand('Link', new FCKDialogCommand( 'Link', FCKLang.DlgLnkWindowTitle, FCKConfig.WikiBasePath + FCKConfig.WikiPage + '?action=fckdialog&dialog=link', 400, 330, FCK.GetNamedCommandState, 'CreateLink')) ; - + FCKCommands.RegisterCommand('Link', new FCKDialogCommand( 'Link', FCKLang.DlgLnkWindowTitle, FCKConfig.WikiBasePath + FCKConfig.WikiPage + '?action=fckdialog&dialog=link', 400, 330, FCK.GetNamedCommandState, 'CreateLink')); }
--- a/wiki/htdocs/applets/moinFCKplugins/moinunlink/fckplugin.js Sun Aug 17 23:00:51 2008 +0900 +++ b/wiki/htdocs/applets/moinFCKplugins/moinunlink/fckplugin.js Sun Aug 17 23:18:35 2008 +0900 @@ -6,7 +6,9 @@ MoinUnlink.prototype.Execute = function() { - if (0) // code for selection debugging + /* + // code for selection debugging + if (0) { var oStart = FCKSelection.GetStartNode() var sStart = "" @@ -34,6 +36,7 @@ "Type:" + FCKSelection.GetType()); return } + */ if(FCKSelection.GetType()=='Control') { @@ -42,13 +45,15 @@ else //if (FCK.GetNamedCommandState("Unlink")==FCK_TRISTATE_ON) { if (FCKSelection.IsCollapsed()) - { - FCKSelection.SelectNode(FCKSelection.MoveToAncestorNode('A')); - } + { + FCKSelection.SelectNode(FCKSelection.MoveToAncestorNode('A')); + } + var sText = FCKSelection.GetText(); - //alert("'" + sText + "'"); + FCK.ExecuteNamedCommand('Unlink'); FCKSelection.Collapse(); + if (word_rule.test(sText)) { FCK.InsertHtml('<span style="background-color:#ffff11">!</span>'); @@ -59,4 +64,3 @@ //MoinUnlink.prototype.GetState = function(){return FCK_TRISTATE_OFF} FCKCommands.RegisterCommand('Unlink', new MoinUnlink()); -
--- a/wiki/htdocs/applets/moinFCKplugins/placeholder/fckplugin.js Sun Aug 17 23:00:51 2008 +0900 +++ b/wiki/htdocs/applets/moinFCKplugins/placeholder/fckplugin.js Sun Aug 17 23:18:35 2008 +0900 @@ -13,48 +13,48 @@ // Add a new placeholder at the actual selection. FCKPlaceholders.Add = function( name ) { - var oSpan = FCK.CreateElement( 'SPAN' ) ; - this.SetupSpan( oSpan, name ) ; + var oSpan = FCK.CreateElement( 'SPAN' ) ; + this.SetupSpan( oSpan, name ) ; } FCKPlaceholders.SetupSpan = function( span, name ) { - span.innerHTML = '[[ ' + name + ' ]]' ; + span.innerHTML = '[[ ' + name + ' ]]' ; span.style.backgroundColor = '#ffff00' ; span.style.color = '#000000' ; if ( FCKBrowserInfo.IsGecko ) - span.style.cursor = 'default' ; + span.style.cursor = 'default' ; span._fckplaceholder = name ; span.contentEditable = false ; - // To avoid it to be resized. - span.onresizestart = function() - { - FCK.EditorWindow.event.returnValue = false ; - return false ; - } + // To avoid it to be resized. + span.onresizestart = function() + { + FCK.EditorWindow.event.returnValue = false ; + return false ; + } } // On Gecko we must do this trick so the user select all the SPAN when clicking on it. FCKPlaceholders._SetupClickListener = function() { - FCKPlaceholders._ClickListener = function( e ) - { - if ( e.target.tagName == 'SPAN' && e.target._fckplaceholder ) - FCKSelection.SelectNode( e.target ) ; - } + FCKPlaceholders._ClickListener = function( e ) + { + if ( e.target.tagName == 'SPAN' && e.target._fckplaceholder ) + FCKSelection.SelectNode( e.target ) ; + } - FCK.EditorDocument.addEventListener( 'click', FCKPlaceholders._ClickListener, true ) ; + FCK.EditorDocument.addEventListener( 'click', FCKPlaceholders._ClickListener, true ) ; } // Open the Placeholder dialog on double click. FCKPlaceholders.OnDoubleClick = function( span ) { - if ( span.tagName == 'SPAN' && span._fckplaceholder ) - FCKCommands.GetCommand( 'Placeholder' ).Execute() ; + if ( span.tagName == 'SPAN' && span._fckplaceholder ) + FCKCommands.GetCommand( 'Placeholder' ).Execute() ; } FCK.RegisterDoubleClickHandler( FCKPlaceholders.OnDoubleClick, 'SPAN' ) ; @@ -62,83 +62,83 @@ // Check if a Placholder name is already in use. FCKPlaceholders.Exist = function( name ) { - var aSpans = FCK.EditorDocument.getElementsByTagName( 'SPAN' ) + var aSpans = FCK.EditorDocument.getElementsByTagName( 'SPAN' ) - for ( var i = 0 ; i < aSpans.length ; i++ ) - { - if ( aSpans[i]._fckplaceholder == name ) - return true ; - } + for ( var i = 0 ; i < aSpans.length ; i++ ) + { + if ( aSpans[i]._fckplaceholder == name ) + return true ; + } } if ( FCKBrowserInfo.IsIE ) { - FCKPlaceholders.Redraw = function() - { - var aPlaholders = FCK.EditorDocument.body.innerText.match( /\[\[[^\[\]]+\]\]/g ) ; - if ( !aPlaholders ) - return ; - - var oRange = FCK.EditorDocument.body.createTextRange() ; + FCKPlaceholders.Redraw = function() + { + var aPlaholders = FCK.EditorDocument.body.innerText.match( /\[\[[^\[\]]+\]\]/g ) ; + if ( !aPlaholders ) + return ; - for ( var i = 0 ; i < aPlaholders.length ; i++ ) - { - if ( oRange.findText( aPlaholders[i] ) ) - { - var sName = aPlaholders[i].match( /\[\[\s*([^\]]*?)\s*\]\]/ )[1] ; - oRange.pasteHTML( '<span style="color: #000000; background-color: #ffff00" contenteditable="false" _fckplaceholder="' + sName + '">' + aPlaholders[i] + '</span>' ) ; - } - } - } + var oRange = FCK.EditorDocument.body.createTextRange() ; + + for ( var i = 0 ; i < aPlaholders.length ; i++ ) + { + if ( oRange.findText( aPlaholders[i] ) ) + { + var sName = aPlaholders[i].match( /\[\[\s*([^\]]*?)\s*\]\]/ )[1] ; + oRange.pasteHTML( '<span style="color: #000000; background-color: #ffff00" contenteditable="false" _fckplaceholder="' + sName + '">' + aPlaholders[i] + '</span>' ) ; + } + } + } } else { - FCKPlaceholders.Redraw = function() - { - var oInteractor = FCK.EditorDocument.createTreeWalker( FCK.EditorDocument.body, NodeFilter.SHOW_TEXT, FCKPlaceholders._AcceptNode, true ) ; - - var aNodes = new Array() ; - - while ( oNode = oInteractor.nextNode() ) - { - aNodes[ aNodes.length ] = oNode ; - } - - for ( var n = 0 ; n < aNodes.length ; n++ ) - { - var aPieces = aNodes[n].nodeValue.split( /(\[\[[^\[\]]+\]\])/g ) ; - - for ( var i = 0 ; i < aPieces.length ; i++ ) - { - if ( aPieces[i].length > 0 ) - { - if ( aPieces[i].indexOf( '[[' ) == 0 ) - { - var sName = aPieces[i].match( /\[\[\s*([^\]]*?)\s*\]\]/ )[1] ; + FCKPlaceholders.Redraw = function() + { + var oInteractor = FCK.EditorDocument.createTreeWalker( FCK.EditorDocument.body, NodeFilter.SHOW_TEXT, FCKPlaceholders._AcceptNode, true ) ; - var oSpan = FCK.EditorDocument.createElement( 'span' ) ; - FCKPlaceholders.SetupSpan( oSpan, sName ) ; - - aNodes[n].parentNode.insertBefore( oSpan, aNodes[n] ) ; - } - else - aNodes[n].parentNode.insertBefore( FCK.EditorDocument.createTextNode( aPieces[i] ) , aNodes[n] ) ; - } - } + var aNodes = new Array() ; - aNodes[n].parentNode.removeChild( aNodes[n] ) ; - } - - FCKPlaceholders._SetupClickListener() ; - } + while ( oNode = oInteractor.nextNode() ) + { + aNodes[ aNodes.length ] = oNode ; + } - FCKPlaceholders._AcceptNode = function( node ) - { - if ( /\[\[[^\[\]]+\]\]/.test( node.nodeValue ) ) - return NodeFilter.FILTER_ACCEPT ; - else - return NodeFilter.FILTER_SKIP ; - } + for ( var n = 0 ; n < aNodes.length ; n++ ) + { + var aPieces = aNodes[n].nodeValue.split( /(\[\[[^\[\]]+\]\])/g ) ; + + for ( var i = 0 ; i < aPieces.length ; i++ ) + { + if ( aPieces[i].length > 0 ) + { + if ( aPieces[i].indexOf( '[[' ) == 0 ) + { + var sName = aPieces[i].match( /\[\[\s*([^\]]*?)\s*\]\]/ )[1] ; + + var oSpan = FCK.EditorDocument.createElement( 'span' ) ; + FCKPlaceholders.SetupSpan( oSpan, sName ) ; + + aNodes[n].parentNode.insertBefore( oSpan, aNodes[n] ) ; + } + else + aNodes[n].parentNode.insertBefore( FCK.EditorDocument.createTextNode( aPieces[i] ) , aNodes[n] ) ; + } + } + + aNodes[n].parentNode.removeChild( aNodes[n] ) ; + } + + FCKPlaceholders._SetupClickListener() ; + } + + FCKPlaceholders._AcceptNode = function( node ) + { + if ( /\[\[[^\[\]]+\]\]/.test( node.nodeValue ) ) + return NodeFilter.FILTER_ACCEPT ; + else + return NodeFilter.FILTER_SKIP ; + } } FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKPlaceholders.Redraw ) ; @@ -149,10 +149,10 @@ // We must process the SPAN tags to replace then with the real resulting value of the placeholder. FCKXHtml.TagProcessors['span'] = function( node, htmlNode ) { - if ( htmlNode._fckplaceholder ) - node = FCKXHtml.XML.createTextNode( '[[' + htmlNode._fckplaceholder + ']]' ) ; - else - FCKXHtml._AppendChildNodes( node, htmlNode, false ) ; + if ( htmlNode._fckplaceholder ) + node = FCKXHtml.XML.createTextNode( '[[' + htmlNode._fckplaceholder + ']]' ) ; + else + FCKXHtml._AppendChildNodes( node, htmlNode, false ) ; - return node ; + return node ; }
--- a/wiki/htdocs/applets/moinFCKplugins/restrict_actions/fckplugin.js Sun Aug 17 23:00:51 2008 +0900 +++ b/wiki/htdocs/applets/moinFCKplugins/restrict_actions/fckplugin.js Sun Aug 17 23:18:35 2008 +0900 @@ -6,8 +6,8 @@ */ var RestrictedNamedCommand = function(commandName, forbidden) { - this.Name = commandName; - this.forbidden = forbidden; + this.Name = commandName; + this.forbidden = forbidden; } RestrictedNamedCommand.prototype = new FCKNamedCommand(); @@ -53,11 +53,10 @@ * extends FCKFormatBlockCommand * ####################################################### */ - var RestrictedFormatBlockCommand = function(forbidden) { - this.Name = 'FormatBlock' ; - this.forbidden = forbidden; + this.Name = 'FormatBlock' ; + this.forbidden = forbidden; } RestrictedFormatBlockCommand.prototype = new FCKFormatBlockCommand(); @@ -121,10 +120,11 @@ { if (styleName == "Typewriter") FCK.ExecuteNamedCommand('RemoveFormat'); + styleComboItem.Style.ApplyToSelection() ; } - FCK.Focus() ; - FCK.Events.FireEvent( "OnSelectionChange" ) ; + FCK.Focus(); + FCK.Events.FireEvent( "OnSelectionChange" ); } /* #################################################################### @@ -134,7 +134,8 @@ var StyleButtonCommand = function(stylename, unique) { - this.style = FCK.Styles.GetStyle(stylename); // using FCK.Style instead of fckstylesloader + // using FCK.Style instead of fckstylesloader + this.style = FCK.Styles.GetStyle(stylename); this.unique = unique; } @@ -267,11 +268,11 @@ */ FCKToolbarItems.RegisterItem('Big', new FCKToolbarButton - ('Big', 'Big>', 'Big', - FCK_TOOLBARITEM_ONLYICON, false, true)); -FCKToolbarItems.RegisterItem('Small', new FCKToolbarButton - ('Small', 'Small', 'Small', - FCK_TOOLBARITEM_ONLYICON, false, true)); -FCKToolbarItems.RegisterItem('Typewriter', new FCKToolbarButton - ('Typewriter', 'Typewriter', 'Typewriter', - FCK_TOOLBARITEM_ONLYICON, false, true)); + ('Big', 'Big>', 'Big', + FCK_TOOLBARITEM_ONLYICON, false, true)); + FCKToolbarItems.RegisterItem('Small', new FCKToolbarButton + ('Small', 'Small', 'Small', + FCK_TOOLBARITEM_ONLYICON, false, true)); + FCKToolbarItems.RegisterItem('Typewriter', new FCKToolbarButton + ('Typewriter', 'Typewriter', 'Typewriter', + FCK_TOOLBARITEM_ONLYICON, false, true));