diff -r fcf75e232c5b -r 0ff3ba646492 web/drupal/modules/fckeditor/plugins/imgassist/fckplugin.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/drupal/modules/fckeditor/plugins/imgassist/fckplugin.js Fri Aug 21 16:26:26 2009 +0000 @@ -0,0 +1,217 @@ +/* +* FCKeditor - The text editor for Internet - http://www.fckeditor.net +* Copyright (C) 2003-2007 Frederico Caldeira Knabben +* +* == BEGIN LICENSE == +* +* Licensed under the terms of any of the following licenses at your +* choice: +* +* - GNU General Public License Version 2 or later (the "GPL") +* http://www.gnu.org/licenses/gpl.html +* +* - GNU Lesser General Public License Version 2.1 or later (the "LGPL") +* http://www.gnu.org/licenses/lgpl.html +* +* - Mozilla Public License Version 1.1 or later (the "MPL") +* http://www.mozilla.org/MPL/MPL-1.1.html +* +* == END LICENSE == +* +* Plugin to insert "Placeholders" in the editor. +*/ + +// The object used for all Placeholder operations. + +//FCK.Events.AttachEvent( 'OnSelectionChange', FCKImgAssist.Redraw ) ; + + +var imgAssistIcon= top.document.getElementById('img_assist-link-' + FCK.Config['TextareaID']); +if (imgAssistIcon){ + +var FCKImageAssistProcessor = FCKDocumentProcessor.AppendNew() ; +FCKImageAssistProcessor.ProcessDocument = function( document ) +{ + // get all elements in FCK document + var elements = document.getElementsByTagName( '*' ) ; + + // check every element for childNodes + var i = 0; + while (element = elements[i++]) { + var nodes = element.childNodes; + + var j = 0; + while (node = nodes[j++]) { + if (node.nodeName == '#text') { + var index = 0; + while (aPlaholders = node.nodeValue.match( /\[img_assist[^\[\]]+\]/g )) { + index = node.nodeValue.indexOf(aPlaholders[0]); + if (index != -1) { + var oImgAs = FCKTools.ImageAssistDecode ( aPlaholders[0] ); + + var substr1 = FCK.EditorDocument.createTextNode( node.nodeValue.substring(0, index) ); + var substr2 = FCK.EditorDocument.createTextNode( node.nodeValue.substring(index + aPlaholders[0].length) ); + + node.parentNode.insertBefore( substr1, node ) ; + node.parentNode.insertBefore( oImgAs, node ) ; + node.parentNode.insertBefore( substr2, node ) ; + + node.parentNode.removeChild( node ) ; + if (node) node.nodeValue=''; + } + } + } + } + } +} + +// Open the image_assis dialog on double click. +FCKImageAssistProcessor.OnDoubleClick = function( span ) { + if ( span.tagName == 'IMG' && span._fckimgassist_fckimgassist ) { + FCKCommands.GetCommand( 'Img_Assist' ).Execute() ; + } +} + +//Save reference to the internal FCKeditor TagProcessor +//It must be called to process _fcksavedurl [#352704] +var FCKXHtml_TagProcessors_Img = FCKXHtml.TagProcessors['img']; + +// We must process the IMG tags, change to [img_assist...] +FCKXHtml.TagProcessors['img'] = function( node, htmlNode ) +{ + node = FCKXHtml_TagProcessors_Img( node, htmlNode ) ; + + if ( htmlNode.getAttribute('nid') ) { + var IAString = FCKTools.ImageAssistCode ( htmlNode ); + if( IAString ) + node = FCKXHtml.XML.createTextNode(IAString) ; + } + else{ + FCKXHtml._AppendChildNodes( node, htmlNode, false ) ; + } + return node ; +} + +FCKImageAssistProcessor.Redraw = function( document ) +{ + FCKImageAssistProcessor.ProcessDocument(FCK.EditorDocument); +} + +// Context menu for templates. +FCK.ContextMenu.RegisterListener({ + AddItems : function( contextMenu, tag, tagName ) + { + if ( tagName == 'IMG' || tagName == 'img') { + if ( tag.getAttribute( '_fckimgassist' ) ) { + contextMenu.RemoveAllItems(); + contextMenu.AddItem( 'Img_Assist', 'Image Assist' , FCKConfig.PluginsPath + 'imgassist/imgassist_small.gif') ; + } + } + } +}); + +FCKTools.ImageAssistDecode = function( IAString ) +{ + var IAObj = FCK.EditorDocument.createElement( 'img' ) ; + var IAarg = IAString.match( /\[img_assist\s*([^\]]*?)\]/ ); + IAarg=IAarg[1].toString().split("|"); + var order = new Array(); + for (var k=0;k