Browse Source

Feature #2132 - "asciisvg" plug-in: Testing and corrections.

Ivan Tcholakov 14 years ago
parent
commit
cce64ec44f

+ 0 - 8
main/inc/lib/fckeditor/editor/plugins/asciisvg/d.svg

@@ -1,8 +0,0 @@
-<?xml version="1.0" standalone="no"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
-  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
-<svg id="root" xml:space="preserve" width="100%" height="100%"
-  preserveAspectRatio="xMidYMid meet"
-  xmlns="http://www.w3.org/2000/svg"
-  xmlns:xlink="http:///www.w3.org/1999/xlink">
-</svg>

+ 1 - 1
main/inc/lib/fckeditor/editor/plugins/asciisvg/fck_asciisvg.html

@@ -116,7 +116,7 @@ Graphs: <select id="graphs" onchange="javascript: LoadEquation();"></select>
 
 <hr/>
 
-<div id="preview" style="overflow: auto;">
+<div id="preview">
 <script type="text/javascript">
 //if ( noSVG )
 //{

+ 2 - 2
main/inc/lib/fckeditor/editor/plugins/asciisvg/fckplugin.js

@@ -36,7 +36,7 @@ FCKToolbarItems.RegisterItem( 'asciisvg', oAsciiSvgItem ) ;
 FCK.ContextMenu.RegisterListener( {
     AddItems : function( menu, tag, tagName )
     {
-        if ( FCK.IsAsciiSvg( tag ) )
+        if ( tag.tagName == 'IMG' && tag.getAttribute( '_fckasciisvg' ) )
         {
             menu.AddSeparator() ;
             menu.AddItem( 'asciisvg', FCKLang['DlgAsciiSvg'], oAsciiSvgItem.IconPath ) ;
@@ -48,7 +48,7 @@ FCK.ContextMenu.RegisterListener( {
 FCK.RegisterDoubleClickHandler(
     function ( tag )
     {
-        if ( FCK.IsAsciiSvg( tag ) )
+        if ( tag.tagName == 'IMG' && tag.getAttribute( '_fckasciisvg' ) )
         {
             FCKCommands.GetCommand( 'asciisvg' ).Execute() ;
         }

+ 1 - 1
main/inc/lib/fckeditor/editor/plugins/asciisvg/fckplugin_compressed.js

@@ -1 +1 @@
-if (typeof AMprocessNode!='function'){LoadScript(FCKConfig.ScriptASCIIMathML);};var notifyIfNoMathML=false;var alertIfNoMathML=false;var notifyIfNoSVG=false;var alertIfNoSVG=false;var translateASCIIMath=false;FCKCommands.RegisterCommand('asciisvg',new FCKDialogCommand(FCKLang['DlgAsciiSvg'],FCKLang['DlgAsciiSvgGraphEditor'],FCKConfig.PluginsPath+'asciisvg/fck_asciisvg.html',700,600));var oAsciiSvgItem=new FCKToolbarButton('asciisvg',FCKLang['DlgAsciiSvg']);oAsciiSvgItem.IconPath=FCKConfig.PluginsPath+'asciisvg/asciisvg.gif';FCKToolbarItems.RegisterItem('asciisvg',oAsciiSvgItem);FCK.ContextMenu.RegisterListener({AddItems:function(A,B,C){if (FCK.IsAsciiSvg(B)){A.AddSeparator();A.AddItem('asciisvg',FCKLang['DlgAsciiSvg'],oAsciiSvgItem.IconPath);}}});FCK.RegisterDoubleClickHandler(function (A){if (FCK.IsAsciiSvg(A)){FCKCommands.GetCommand('asciisvg').Execute();}},null);
+if (typeof AMprocessNode!='function'){LoadScript(FCKConfig.ScriptASCIIMathML);};var notifyIfNoMathML=false;var alertIfNoMathML=false;var notifyIfNoSVG=false;var alertIfNoSVG=false;var translateASCIIMath=false;FCKCommands.RegisterCommand('asciisvg',new FCKDialogCommand(FCKLang['DlgAsciiSvg'],FCKLang['DlgAsciiSvgGraphEditor'],FCKConfig.PluginsPath+'asciisvg/fck_asciisvg.html',700,600));var oAsciiSvgItem=new FCKToolbarButton('asciisvg',FCKLang['DlgAsciiSvg']);oAsciiSvgItem.IconPath=FCKConfig.PluginsPath+'asciisvg/asciisvg.gif';FCKToolbarItems.RegisterItem('asciisvg',oAsciiSvgItem);FCK.ContextMenu.RegisterListener({AddItems:function(A,B,C){if (B.tagName=='IMG'&&B.getAttribute('_fckasciisvg')){A.AddSeparator();A.AddItem('asciisvg',FCKLang['DlgAsciiSvg'],oAsciiSvgItem.IconPath);}}});FCK.RegisterDoubleClickHandler(function (A){if (A.tagName=='IMG'&&A.getAttribute('_fckasciisvg')){FCKCommands.GetCommand('asciisvg').Execute();}},null);

+ 42 - 97
main/inc/lib/fckeditor/editor/plugins/customizations/fckplugin.js

@@ -1146,53 +1146,51 @@ FCK.ResizeToFit = function( width, height, max_width, max_height )
 // This is a modification of the original function.
 FCKDocumentProcessor_CreateFakeImage = function( fakeClass, realElement )
 {
+    // Premature detection of fake image type is needed here.
+    if ( fakeClass = 'FCK__UnknownObject' )
+    {
+        if ( FCK.IsVideo( realElement ) )
+        {
+            fakeClass = 'FCK__Video' ;
+        }
+        else if ( FCK.IsAsciiSvg( realElement ) )
+        {
+            fakeClass = 'FCK__AsciiSvg' ;
+        }
+    }
+
+    // The original code fragment.
     var oImg = FCKTools.GetElementDocument( realElement ).createElement( 'IMG' ) ;
     oImg.className = fakeClass ;
     oImg.src = FCKConfig.BasePath + 'images/spacer.gif' ;
     oImg.setAttribute( '_fckfakelement', 'true', 0 ) ;
     oImg.setAttribute( '_fckrealelement', FCKTempBin.AddElement( realElement ), 0 ) ;
-    if ( fakeClass == 'FCK__Video' )
+
+    // Setting width and height for relevant types of fake images.
+    if ( fakeClass == 'FCK__Video' && realElement.nodeName.IEquals( 'div' ) )
     {
         // Specific to flv player, SWFObject attaching technique.
-        if ( realElement.nodeName.IEquals( 'div' ) )
-        {
-            for ( var i = 0; i < realElement.childNodes.length; i++ )
-            {
-                if ( realElement.childNodes[i].nodeName.IEquals( 'div' ) )
-                {
-                    oImg.style.width = realElement.childNodes[i].style.width ;
-                    oImg.style.height = realElement.childNodes[i].style.height ;
-                    break ;
-                }
-            }
-        }
-        // For embedded video.
-        else
+        for ( var i = 0; i < realElement.childNodes.length; i++ )
         {
-            var width = realElement.width ;
-            var height = realElement.height ;
-            if ( width )
-            {
-                oImg.style.width = width.toString().indexOf('%') != -1 ? width : ( width + 'px' ) ;
-            }
-            if ( height )
+            if ( realElement.childNodes[i].nodeName.IEquals( 'div' ) )
             {
-                oImg.style.height = height.toString().indexOf('%') != -1 ? height : ( height + 'px' ) ;
+                oImg.style.width = realElement.childNodes[i].style.width ;
+                oImg.style.height = realElement.childNodes[i].style.height ;
+                break ;
             }
         }
     }
-    // For AsciiSvg graphs.
-    else if ( fakeClass == 'FCK__AsciiSvg' )
+    else if ( fakeClass == 'FCK__Video' || fakeClass == 'FCK__AsciiSvg' )
     {
         var width = realElement.width ;
         var height = realElement.height ;
         if ( width )
         {
-            oImg.style.width = width.toString().indexOf('%') != -1 ? width : ( width + 'px' ) ;
+            oImg.style.width = FCKTools.ConvertHtmlSizeToStyle( width.toString() ) ;
         }
         if ( height )
         {
-            oImg.style.height = height.toString().indexOf('%') != -1 ? height : ( height + 'px' ) ;
+            oImg.style.height = FCKTools.ConvertHtmlSizeToStyle( height.toString() ) ;
         }
         if ( realElement.style.width ) {
             oImg.style.width = realElement.style.width ;
@@ -1200,13 +1198,22 @@ FCKDocumentProcessor_CreateFakeImage = function( fakeClass, realElement )
         if ( realElement.style.height ) {
             oImg.style.height = realElement.style.height ;
         }
-        var sscr = realElement.getAttribute( 'sscr' ) ;
-        oImg.setAttribute( 'sscr', sscr, 0 ) ;
     }
+
+    // Setting attributes for detection purpose.
+    if ( fakeClass == 'FCK__Video' )
+    {
+        oImg.setAttribute( '_fckvideo', 'true', 0 ) ;
+    }
+    else if ( fakeClass == 'FCK__AsciiSvg' )
+    {
+        oImg.setAttribute( '_fckasciisvg', 'true', 0 ) ;
+    }
+
     return oImg ;
 }
 
-// A custom handler for audio files when a new tag has been added.
+// A fake image handler for audio files.
 FCKEmbedAndObjectProcessor.AddCustomHandler( function ( el, fakeImg )
     {
         if ( !FCK.IsAudio( el ) )
@@ -1218,25 +1225,7 @@ FCKEmbedAndObjectProcessor.AddCustomHandler( function ( el, fakeImg )
         fakeImg.setAttribute( '_fckmp3', 'true', 0 ) ;
     } ) ;
 
-// Fake images for audio files when the document has been opened.
-FCKDocumentProcessor.AppendNew().ProcessDocument = function ( document )
-    {
-        var embeds = document.getElementsByTagName( 'embed' ) ;
-        var embed ;
-        var i = embeds.length - 1 ;
-        while ( i >= 0 && ( embed = embeds[i--] ) )
-        {
-            if ( FCK.IsAudio( embed ) )
-            {
-                var oImg = FCKDocumentProcessor_CreateFakeImage( 'FCK__MP3', embed.cloneNode(true) ) ;
-                oImg.setAttribute( '_fckmp3', 'true', 0 ) ;
-                embed.parentNode.insertBefore( oImg, embed ) ;
-                embed.parentNode.removeChild( embed ) ;
-            }
-        }
-    } ;
-
-// A custom handler for video when a new tag has been added.
+// A fake image handler for video files.
 FCKEmbedAndObjectProcessor.AddCustomHandler( function ( el, fakeImg )
     {
         if ( !FCK.IsVideo( el ) )
@@ -1248,23 +1237,9 @@ FCKEmbedAndObjectProcessor.AddCustomHandler( function ( el, fakeImg )
         fakeImg.setAttribute( '_fckvideo', 'true', 0 ) ;
     } ) ;
 
-// Fake images for video when the document has been opened.
+// Fake image support for flv video files.
 FCKDocumentProcessor.AppendNew().ProcessDocument = function ( document )
     {
-        var embeds = document.getElementsByTagName( 'embed' ) ;
-        var embed;
-        var i = embeds.length - 1 ;
-        while ( i >= 0 && ( embed = embeds[i--] ) )
-        {
-            if ( FCK.IsVideo( embed ) )
-            {
-                var oImg = FCKDocumentProcessor_CreateFakeImage( 'FCK__Video', embed.cloneNode(true) ) ;
-                oImg.setAttribute( '_fckvideo', 'true', 0 ) ;
-                embed.parentNode.insertBefore( oImg, embed ) ;
-                embed.parentNode.removeChild( embed ) ;
-            }
-        }
-
         // For flv player, SWFObject attaching tecnique.
         var divs = document.getElementsByTagName( 'div' ) ;
         var div;
@@ -1281,36 +1256,6 @@ FCKDocumentProcessor.AppendNew().ProcessDocument = function ( document )
         }
     } ;
 
- // A custom handler for AsciiSvg graphs when a new tag has been added.
-FCKEmbedAndObjectProcessor.AddCustomHandler( function ( el, fakeImg )
-    {
-        if ( !FCK.IsAsciiSvg( el ) )
-        {
-            return ;
-        }
-
-        fakeImg.className = 'FCK__AsciiSvg' ;
-        fakeImg.setAttribute( '_fckasciisvg', 'true', 0 ) ;
-    } ) ;
-
-// Fake images for AsciiSvg graphs when the document has been opened.
-FCKDocumentProcessor.AppendNew().ProcessDocument = function ( document )
-    {
-        var embeds = document.getElementsByTagName( 'embed' ) ;
-        var embed ;
-        var i = embeds.length - 1 ;
-        while ( i >= 0 && ( embed = embeds[i--] ) )
-        {
-            if ( FCK.IsAsciiSvg( embed ) )
-            {
-                var oImg = FCKDocumentProcessor_CreateFakeImage( 'FCK__AsciiSvg', embed.cloneNode(true) ) ;
-                oImg.setAttribute( '_fckasciisvg', 'true', 0 ) ;
-                embed.parentNode.insertBefore( oImg, embed ) ;
-                embed.parentNode.removeChild( embed ) ;
-            }
-        }
-    } ;
-
 
 /*
  **************************************************************************************
@@ -1543,7 +1488,6 @@ FCK.IsRealImage = function ( tag )
             || tag.getAttribute( '_fckmp3' )
             || tag.getAttribute( '_fckvideo' )
             || tag.getAttribute( 'MapNumber' )
-            || FCK.IsAsciiSvg( tag )
             )
         {
             return false ;
@@ -1551,7 +1495,7 @@ FCK.IsRealImage = function ( tag )
 
         if ( tag.getAttribute( 'src' ) )
         {
-            var src = tag.getAttribute( 'src' ).toString() ;
+            var src = tag.getAttribute( 'src' ).toString().toLowerCase() ;
             return ( src.indexOf( 'mimetex?' ) == -1
                     && src.indexOf( 'mimetex.cgi?' ) == -1
                     && src.indexOf( 'mimetex.exe?' ) == -1
@@ -1561,6 +1505,7 @@ FCK.IsRealImage = function ( tag )
                     && src.indexOf( 'mathtran?' ) == -1
                     && src.indexOf( 'google.com/chart?' ) == -1
                     && src.indexOf( 'latex?' ) == -1
+                    && src.indexOf( 'sscr=' ) == -1
                 ) ? true : false ;
         }
         else
@@ -1735,7 +1680,7 @@ FCK.IsAsciiSvg = function ( tag )
         return false ;
     }
 
-    if ( tag.nodeName.IEquals( 'img' ) || tag.nodeName.IEquals( 'embed' ) )
+    if ( tag.nodeName.IEquals( 'embed' ) )
     {
         if ( FCKDomTools.HasAttribute( tag, 'sscr' ) )
         {

File diff suppressed because it is too large
+ 0 - 0
main/inc/lib/fckeditor/editor/plugins/customizations/fckplugin_compressed.js


Some files were not shown because too many files changed in this diff