This is a migrated thread and some comments may be shown as answers.

OnClientPasteHtml FlashManager

13 Answers 66 Views
Editor
This is a migrated thread and some comments may be shown as answers.
ido nahmias
Top achievements
Rank 1
ido nahmias asked on 12 Feb 2013, 12:23 PM
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

13 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 13 Feb 2013, 06:11 PM
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.
0
ido nahmias
Top achievements
Rank 1
answered on 19 Feb 2013, 08:52 AM
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?
0
Rumen
Telerik team
answered on 20 Feb 2013, 04:58 PM
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.
0
ido nahmias
Top achievements
Rank 1
answered on 24 Feb 2013, 03:10 PM
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?
0
Rumen
Telerik team
answered on 27 Feb 2013, 11:23 AM
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.
0
ido nahmias
Top achievements
Rank 1
answered on 28 Feb 2013, 11:16 AM
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)
0
Rumen
Telerik team
answered on 28 Feb 2013, 11:58 AM
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.
0
ido nahmias
Top achievements
Rank 1
answered on 28 Feb 2013, 12:51 PM
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 %?


0
Rumen
Telerik team
answered on 05 Mar 2013, 09:42 AM
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.
0
ido nahmias
Top achievements
Rank 1
answered on 17 Mar 2013, 03:56 PM
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?
0
Nikolay
Telerik team
answered on 20 Mar 2013, 11:04 AM
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.
0
ido nahmias
Top achievements
Rank 1
answered on 28 Mar 2013, 12:54 PM
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.
0
Rumen
Telerik team
answered on 02 Apr 2013, 12:43 PM
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.
Tags
Editor
Asked by
ido nahmias
Top achievements
Rank 1
Answers by
Rumen
Telerik team
ido nahmias
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or