Custom Dialogs

4 posts, 0 answers
  1. Dan Lewis
    Dan Lewis avatar
    13 posts
    Member since:
    Feb 2005

    Posted 12 Jun 2007 Link to this post

    Hi,

    Is it possible to add a custom dialog and use this to insert values into the Rad Editor for MOSS?

    Regards,

    Dan Lewis
  2. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 12 Jun 2007 Link to this post

    Hi Dan,

    What do you mean by custom dialog? do you want to have the whole editor in a dialog window or you want to create your own custom dialog and add it in the editor's toolbar? If you are talking about the latter, then this example might be useful to you - http://www.telerik.com/demos/aspnet/Editor/Examples/CustomDialogs/DefaultCS.aspx.


    Kind regards,
    Lini
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  3. Dan Lewis
    Dan Lewis avatar
    13 posts
    Member since:
    Feb 2005

    Posted 12 Jun 2007 Link to this post

    I was talking about the latter (create my own custom dialog and add it to the toolbar).

    I have managed to do this using the following approach:

    Added this line to C:\Program Files\Common Files\Microsoft Shared\web server extensions\wpresources\RadEditorSharePoint\4.1.0.0__1f131a624888eeed\RadControls\Editor\ToolFile.xml:
    <tool name="CustomDialog" /> 

    Added the following to the bottom of C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\GLOBAL\default.master (so it is available on all pages in the farm)

                <script type="text/javascript"
                //<![CDATA[ 
                var RadEditor1ClientObject = null
                RadEditorCommandList["CustomDialog"] = 
                    function CustomDialogCommand(commandName, editor, oTool) 
                    { 
        
                        RadEditor1ClientObject = editor; 
                        editor.ShowDialog( 
                            "/_layouts/InsertLinkDialog.html" 
                            , null 
                            , 300 
                            , 180 
                            , CustomDialogCallback 
                            , null 
                            , "Insert Document Link"); 
                    }; 
     
                    function CustomDialogCallback(returnValue) 
                    { 
                        if (returnValue) 
                        { 
                            RadEditor1ClientObject.PasteHtml("<a href=\"" + returnValue.url + "\">" + returnValue.text + "</a>"); 
                        } 
                    } 
    </script> 

    I put my custom dialog file into C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS

    The custom dialog looks like this:

    <html> 
    <head runat="server"
        <title> 
            The Custom Dialog 
        </title> 
    <link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/core.css /> 
    <link rel="stylesheet" type="text/css" href="/_wpresources/RadEditorSharePoint/4.1.0.0__1f131a624888eeed/RadControls/Editor/Skins/Default/Dialogs.css"></link> 
    </head> 
    <body> 
    <script type="text/javascript" src="/_wpresources/RadEditorSharePoint/4.1.0.0__1f131a624888eeed/RadControls/Editor/Scripts/7_1_1/RadWindow.js"></script> 
    <script type="text/javascript"
        InitializeRadWindow(); 
    </script> 
     
     
            <table border="0" cellpadding="0" cellspacing="0"
                <tr> 
                    <td>Database <font color="#FF0000">*</font></td
                    <td> 
                        <select id="databaseName" style="width:145px;"
                            ... 
                        </select> 
                    </td> 
                </tr> 
                <tr> 
                    <td>Document Number <font color="#FF0000">*</font></td
                    <td> 
                        <input type="text" id="documentNumber"</input> 
                    </td> 
                </tr> 
                <tr> 
                    <td title="This is optional, if blank the latest version will be returned...">Version</td> 
                    <td> 
                        <input type="text" id="documentVersion"</input> 
                    </td> 
                </tr> 
                <tr> 
                    <td title="This is the link text the user will click...">Description <font color="#FF0000">*</font></td
                    <td> 
                        <input type="text" id="description"</input> 
                    </td> 
                </tr> 
                <tr> 
                    <td> 
                        <button class="Button" onclick="javascript:insertLink();" id="Button1" type="button"
                        Insert 
                    </button> 
                    </td> 
                    <td><font style="color:#FF0000;font-size:8pt;">* = Please Supply</font></td
                </tr> 
            </table> 
     
            <script language="javascript"
     
            function insertLink() 
            { 
                var returnValue =  
                { 
                    url:"...", 
                    text:description.value 
                }; 
                CloseDlg(returnValue); 
            } 
            </script> 
    </body> 
    </html> 

    The key was using _layouts and _wpresources in the correct places when referencing scripts/css/files etc.

    Does anyone know of an easier way to achieve this?

    Regards,

    Dan.

  4. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 12 Jun 2007 Link to this post

    Hi Dan,

    I think that this approach is fine. I have only one remark - if the master page is modified with SharePoint Designer, MOSS will no longer use the version from disk and will create a new copy in the database just for the current web. This means that you can run into some problems, if there are sites in your farm with a customized master page.

    Best wishes,
    Lini
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top