Custom Button Questions

Last post 04-11-2008, 1:15 PM by Aaron Edwards. 8 replies.
Sort Posts: Previous Next
  •  04-08-2008, 1:26 PM 38877

    Custom Button Questions

    Hi,
     
    I'm trying to create an 'Insert Silverlight Video' button and form, similar to 'Insert Flash' and 'Insert Media'.
     
    When the user clicks the button, a gallery of WMV files is brought up, as well as a couple of radio buttons and a dropdown list.  When the user selects one of the WMV files, a bunch of JavaScripts are then inserted into the HTML content, similar to the following...
     
    <script type='text/javascript' src="Silverlight/MicrosoftAjax.js"></script>

    <script type='text/javascript' src="Silverlight/Silverlight.js"></script>

    <script type='text/javascript' src="Silverlight/BasePlayer.js"></script>

    <script type='text/javascript' src="Silverlight/PlayerStrings.js"></script>

    <script type='text/javascript' src="Silverlight/player.js"></script>

    <script type='text/javascript' src="Silverlight/StartPlayer.js"></script>

    <div id="divPlayer_0" style="width: 350px; height: 300px;">

    <script type='text/javascript'>

          var player = new StartPlayer_0('FileName', 'AutoStart', 'SkinToUse');

    </script>

    </div>
     
    Obviously, in order to accomodate this, we need to set EnableStripScriptTags to false.  I also need to to be able to paste this content into the appropriate place in the editor, i.e. where the cursor was when the gallery was opened.  Not sure how to do that.  I know there's some JavaScript involved.
     
    Also, what is the mechanism that CuteEditor uses to communicate between forms (in my case, the main editor form and the gallery that comes up when the user clicks the 'Insert Silverlight' button)? 
     
    Thanks!
  •  04-08-2008, 3:54 PM 38880 in reply to 38877

    Re: Custom Button Questions

    Please check the following example:
     
    Add a Cross Browser Modal Dialog Box to Cute Editor

    How to create a custom button(client side) which displays a dialog?( C# | VB )

    This example demonstrates how easy it can be to add your own client side buttons to the CuteEditor by creating a Cross Browser Modal Dialog Box.

     
    The source code of this example can be found in the download package.

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  04-09-2008, 2:57 PM 38969 in reply to 38880

    Re: Custom Button Questions

    Thanks Adam,
     
    That helped a lot.  Now I need to be able to paste back in to the main editor, but keep the <script> tags in place.  I'm using the code from the example:
     
    function button_click()
    {
    var editor=Window_GetDialogArguments(window);
    var ta=document.getElementById("ta");
    editor.PasteHTML(ta.value);
    }
     
    But PasteHTML is stripping out the script tags.  Unfortunately, a Silverlight video object looks like the following:
     
    <div id="SilverlightVideo1" style="background-image: url(Silverlight/GenericThumbnail.jpg); width: 260px; height: 255px">
       <script  type='text/javascript'>
            initializePlayer("MyVideo.wmv", "MyVideo_Thumb.jpg", 'Silverlight/player_blitz.xaml', true);
            var player = new StartPlayer_0("SilverlightVideo1");
       </script>
    </div>
    Is there another method I can use?  Thanks.
     
    Aaron
  •  04-09-2008, 8:08 PM 38974 in reply to 38969

    Re: Custom Button Questions

    Aaron,
     
    Please set the following property to false.
     

    Editor.EnableStripScriptTags Property

    Specifies whether to remove inject script before write the string into the db. When this property is set to true (the default) Cute Editor strips all script elements and script contents from the html.


    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  04-10-2008, 12:31 PM 39052 in reply to 38974

    Re: Custom Button Questions

    Hi Adam,
     
    Yes, I had done that.  My problem is that scripts are being stripped not by the editor, but by the PasteHTML function itself.
     
    Here's a quick test you can run to see what I mean: 
    1. Open up HowTo/AddDialogs/vb/create_a_custom_dialog.aspx.
    2. Modify the Editor by adding "EnableStripScriptTags=false"
    3. Run it.
    4. Click the "Insert my Custom Text" button.
    5. Type in the following:  Test 123 <script type='text/javascript'></script> Test 456
    6. Click "Insert It"
    7. What you'll get in the Editor is "Test 123 Test 456"
    If the PasteHTML fucntion is in fact stripping out the script tags, perhaps there is an overload of the function which tells it not to do that.  Or maybe a configuration setting?  Or perhaps there is a quick workaround using some custom JavaScript?
     
    Thanks so much for your help!
     
    Aaron
  •  04-10-2008, 1:16 PM 39055 in reply to 39052

    Re: Custom Button Questions

  •  04-10-2008, 3:03 PM 39058 in reply to 39055

    Re: Custom Button Questions

    It works.
     
    I'm such a fool.  It had already been working on my system, I was just so dazed from staring at the code for so long I didn't see it (didn't switch to HTML view).  Argh!
     
    Anyway, thanks for your help Adam.
     
    Aaron
  •  04-10-2008, 3:38 PM 39059 in reply to 39058

    Re: Custom Button Questions

    No, wait.  I spoke too soon.  It still isn't working for me.
     
    Testing it with just...
     
       <script type='text/javascript'></script>
     
    ...was a detour.  It works just fine with that, but what I really need to be able to paste is something like this:
     
          <div id="SilverlightVideo1" style="background-image: url(Silverlight/GenericThumbnail.jpg); width: 256px; height: 255px">
             <script  type='text/javascript'>
              initializePlayer("uploads/Videos/GlideDonor1.wmv", "uploads/GlideDonor1_Thumb.jpg", 'Silverlight/player_blitz.xaml', true);
              var player = new StartPlayer_0("SilverlightVideo1");
            </script>
         </div>
     
    But it keeps eating the script tags.
     
    Notice this is a script with inline Javascript, not just a reference to an external script.  But even stripping those commands out I can't get it to work.  Very strange.  Perhaps it's because it's inside a div?
     
    The problem occurs using the link you sent me as well as my own local version.
     
    Thanks for your help.
     
    Aaron
  •  04-11-2008, 1:15 PM 39109 in reply to 39059

    Re: Custom Button Questions

    Any ideas on this yet?
     
    I tried to find the definition of PasteHTML in the implementation files, to see if maybe I could disable JavaScript destruction, but it's too scary.  Not a world I want to live in if I can avoid it.
     
    I was also thinking I could cheat, and use and use an Ajax call to put the script back in if, from the popup, I can identify the current cursor position in the Editor.
     
    Any advice is welcome.  Thanks.
     
    Aaron
View as RSS news feed in XML