OnClientPasteHtml FlashManager

14 posts, 0 answers
  1. ido nahmias
    ido nahmias avatar
    64 posts
    Member since:
    May 2006

    Posted 12 Feb 2013 Link to this post

    hello,

    i have a few questions:
    1. my flash file has a resource folder where it is stored.
    how i can change the flash object so i will be able to add the "base" param to it
    2. i want to add a "allowFullScreen=true" how do i do that?
    3. is it possible to make the width and height to be working with percentages?

    thank you
  2. Rumen
    Admin
    Rumen avatar
    14106 posts

    Posted 13 Feb 2013 Link to this post

    Hi,

    The value returned by the args.get_value() method of the OnClientPasteHtml event is a standard string. It is up to the developer working with the control to modify it using String or DOM methods according to the specific project requirements.

    Greetings,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. ido nahmias
    ido nahmias avatar
    64 posts
    Member since:
    May 2006

    Posted 19 Feb 2013 Link to this post

    function OnClientPasteHtml(sender, args) {
        var commandName = args.get_commandName();
        var value = args.get_value();
        if (commandName == "FlashManager") {
            // adds the base attribute to the flash object
            var div = document.createElement("DIV");
     
            //Do not use div.innerHTML as in IE this would cause the image's src or the link's href to be converted to absolute path.
            //This is a severe IE quirk.
            Telerik.Web.UI.Editor.Utils.setElementInnerHtml(div, value);
     
            //Now check if there is alt attribute
            var obj = div.firstChild;
            var srcString = obj.getElementsByTagName("embed")[0].getAttribute("src");
            tempPathpos = srcString.lastIndexOf("/");
            tempPath = srcString.substring(0, tempPathpos + 1);
            var newBaseParam = document.createElement("param");
            newBaseParam.setAttribute("name", "base");
            newBaseParam.setAttribute("value", tempPath);
            obj.insertBefore(newBaseParam, obj.getElementsByTagName("embed")[0]);       
            obj.getElementsByTagName("embed")[0].setAttribute("base", tempPath);
            //Set new content to be pasted into the editor
            args.set_value(div.innerHTML);       
        }

    the code works perfectly on chrome but it doesn't work on explorer at all.
    i can see that the string changes when i debug the code
    but the explorer doesn't accepts the strings changes as it reaches the editor.

    any suggestions?
  4. Rumen
    Admin
    Rumen avatar
    14106 posts

    Posted 20 Feb 2013 Link to this post

    Hi,

    Try to replace this line

    var newBaseParam = document.createElement("param");

    with this one

    var newBaseParam = document.createElement("rade_param");

    All the best,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. ido nahmias
    ido nahmias avatar
    64 posts
    Member since:
    May 2006

    Posted 24 Feb 2013 Link to this post

    hi,
    the "rade_param" works well in the explorer but it doesnt work on chrome.
    is there a solution that will work on both browsers?
  6. Rumen
    Admin
    Rumen avatar
    14106 posts

    Posted 27 Feb 2013 Link to this post

    Hello,

    You can add a check for IE, e.g.

    <telerik:RadEditor ID="RadEditor1" runat="server" OnClientPasteHtml="OnClientPasteHtml">
        <FlashManager ViewPaths="~/" UploadPaths="~/" />
    </telerik:RadEditor>
    <script>
        function OnClientPasteHtml(sender, args) {
            var commandName = args.get_commandName();
            var value = args.get_value();
            if (commandName == "FlashManager") {
                // adds the base attribute to the flash object
                var div = document.createElement("DIV");
     
                //Do not use div.innerHTML as in IE this would cause the image's src or the link's href to be converted to absolute path.
                //This is a severe IE quirk.
                Telerik.Web.UI.Editor.Utils.setElementInnerHtml(div, value);
     
                //Now check if there is alt attribute
                var obj = div.firstChild;
                var srcString = obj.getElementsByTagName("embed")[0].getAttribute("src");
                tempPathpos = srcString.lastIndexOf("/");
                tempPath = srcString.substring(0, tempPathpos + 1);
     
                //New Telerik
                var newBaseParam = null;
                if ($telerik.isIE) {
                    newBaseParam = document.createElement("rade_param");
                }
                else {
                    newBaseParam = document.createElement("param");
                }
                newBaseParam.setAttribute("name", "base");
                 
                newBaseParam.setAttribute("value", tempPath);
                obj.insertBefore(newBaseParam, obj.getElementsByTagName("embed")[0]);
                obj.getElementsByTagName("embed")[0].setAttribute("base", tempPath);
                //Set new content to be pasted into the editor
                 
                args.set_value(div.innerHTML);
            }
        }
    </script>


    Greetings,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  7. ido nahmias
    ido nahmias avatar
    64 posts
    Member since:
    May 2006

    Posted 28 Feb 2013 Link to this post

    thank you that solved the problem.
    about my question regarding the percentages.
    is it possible to do the width and the height with percentages in the window selection?
    (i know i can change it in html view)
  8. Rumen
    Admin
    Rumen avatar
    14106 posts

    Posted 28 Feb 2013 Link to this post

    Hello,

    Did you try to apply the width and height attributes to the inserted via the Flash Manager string? What is the markup that you want to generate and insert via the Flash Manager dialog?

    Regards,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  9. ido nahmias
    ido nahmias avatar
    64 posts
    Member since:
    May 2006

    Posted 28 Feb 2013 Link to this post

    hi,
    i want to let the user insert width and height as desired and to allow him the option to put % next to that width and height.
    in the flash manager u can set the width and the height but if u add % the flash manager ignores it.
    i tried to change the value string on the OnClientPasteHTML but i cant tell if the user inserted % or not because the send button remove it. any suggestions how i can allow the user to add width and height as pixel and as %?


  10. Rumen
    Admin
    Rumen avatar
    14106 posts

    Posted 05 Mar 2013 Link to this post

    Hi,

    The width and height values are hardcoded in the FlashManager.ascx file located in the EditorDialogs folder. You can see how to register the external dialogs of RadEditor and edit them in the following live demo: Customize Built-in Dialogs. You should copy and paste the EditorDialogs folder to the root of your application and set the ExternalDialogsPath property to point to it:

    <telerik:RadEditor runat="server" ExternalDialogsPath="~/EditorDialogs" ID="RadEditor1" OnClientPasteHtml="OnClientPasteHtml">

    I made a test and by changing all 150 values to 150% percents in the FlashManager.ascx file and the updated values were applied to the inserted flash content in the editor.

    Greetings,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  11. ido nahmias
    ido nahmias avatar
    64 posts
    Member since:
    May 2006

    Posted 17 Mar 2013 Link to this post

    hi again... 
    i told you before that the solution you suggested is working fine for chrome and explorer 9.
    today i tested it on explorer 8 and i get an error on that line:
    obj.getElementsByTagName("embed")[0]
    that says that it is undefined or null.
    any suggestions how to make it work with explorer 8 as well?
  12. Nikolay
    Admin
    Nikolay avatar
    94 posts

    Posted 20 Mar 2013 Link to this post

    Hi,

    It looks like the DIV element does not have firstChild property in Internet Explorer 8. Instead of the firstChild property, you could also use div.children[0], which is supported.

    Best regards,
    Nikolay
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  13. ido nahmias
    ido nahmias avatar
    64 posts
    Member since:
    May 2006

    Posted 28 Mar 2013 Link to this post

    hi thank you again for your help.
    i tried your suggestion and i still have the bug i debugged it and find out that 
    obj.getElementsByTagName("embed")
    seems to be empty, meaning it cant find any tag name embed inside.
    when i tried param instead it worked. i guess its something with the explorer 8.
    i looked for a solution and didn't find one.
    any chance you have a suggestion?
    i looked in the obj.children and he had no children and i looked for the embed tag in the "childNodes" property and still couldn't find it.
  14. Rumen
    Admin
    Rumen avatar
    14106 posts

    Posted 02 Apr 2013 Link to this post

    Hi,

    This is IE8 limitation when working with object tags in the DOM. The div.children[0].innerHTML line returns the HTML content of the object and embed tags as a string and you can modify it the string as you wish using the JavaScript replace method.

    Best regards,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top