RadEditor Custom Dialogs Query

8 posts, 0 answers
  1. Platinum
    Platinum avatar
    31 posts
    Member since:
    Jan 2008

    Posted 09 Mar 2009 Link to this post

    Hi,

    I am using the RadControl for SharePoint 2007. I would like to check the following things

    • Currently i am using a custom radEditor dialog to open a Form page and when closed this form, the values will be populated to the RadEditor. Is it possible to open a Form without using a RadEditor Dialog. If yes, how can we pass back the values from the form to the RadEditor ?
    • Current are having two custom buttons to the RadEditor, these two buttons functionalities are added to the following js located in C:\Program Files\Common Files\Microsoft Shared\web server extensions\wpresources\RadEditorSharePoint\4.5.1.0__1f131a624888eeed\RadControls\Editor\Scripts\7_3_2\MOSSEditorTools.js. Is it possible to have these button functionality as a separate js file instead of touching the MossEditorTools.js. For your reference i have put below the code that we added in the js

    var RadEditor1ClientObject = null;  
     RadEditorCommandList["AddNewVideo"] =  
        function CustomDialogCommand(commandName, editor, oTool)  
        {                
                RadEditor1ClientObject = editor;  
            editor.ShowDialog(  
                "/_layouts/Videos/Videos.aspx" 
                , null  
                , 1000
                , 450  
                , CustomDialogCallback  
                , null 
                , "Add New Video");

         };  
     
        function CustomDialogCallback(returnValue)  
        {  
            if (returnValue)  
            {         
                var flashContent ="<object codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\""+
                                   " type=\"application/x-oleobject\" height=\""+returnValue.height+"\" standby=\"Loading Microsoft® Windows® Media Player components...\""+
                                   " width=\""+returnValue.width+"\" align=\"middle\" classid=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\">"+
                                "<param name=\"FileName\" value=\"" + returnValue.url + "\">"+
                                "<param name=\"ShowStatusBar\" value=\"True\">"+
                                "<param name=\"DefaultFrame\" value=\"mainFrame\">"+
                                "<param name=\"autostart\" value=\"true\">" +
                                "<embed type=\"application/x-mplayer2\""+
                                    " pluginspage = \"http://www.microsoft.com/Windows/MediaPlayer//""+
                                    " src=\"" + returnValue.url + "\" align=\"middle\""+
                                    " width="+returnValue.height+""+
                                    " height="+returnValue.width+""+
                                    " autostart=0"+
                                    " showcontrols=0 >"+
                                 "</embed>"+
                                "</object>";
           
               var filterIE = RadEditor1ClientObject.FiltersManager.GetFilterByName("IEKeepObjectParamsFilter"); 
             
               flashContent = (filterIE)?filterIE.GetDesignContent(flashContent):flashContent; 
               RadEditor1ClientObject.PasteHtml(flashContent);  
            }   
        } 
    RadEditorCommandList["AddExistingVideo"] =  
        function CustomDialogCommand(commandName, editor, oTool)  
        {      
            RadEditor1ClientObject = editor;  
            editor.ShowDialog(  
                "/_layouts/Videos/Search/SearchVideo.aspx?ValidOpener=True" 
                , null  
                , 1000
                , 450  
                , CustomDialogAddExistingVideoCallback  
                , null 
                , "Add Existing Video");
        };  
     
        function CustomDialogAddExistingVideoCallback(returnValue)  
        {  
            if (returnValue)  
            {         
                var flashContent ="<object codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\""+
                                   " type=\"application/x-oleobject\" height=\""+returnValue.height+"\" standby=\"Loading Microsoft® Windows® Media Player components...\""+
                                   " width=\""+returnValue.width+"\" align=\"middle\" classid=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\">"+
                                "<param name=\"FileName\" value=\"" + returnValue.url + "\">"+
                                "<param name=\"ShowStatusBar\" value=\"True\">"+
                                "<param name=\"DefaultFrame\" value=\"mainFrame\">"+
                                "<param name=\"autostart\" value=\"true\">" +
                                "<embed type=\"application/x-mplayer2\""+
                                    " pluginspage = \"http://www.microsoft.com/Windows/MediaPlayer//""+
                                    " src=\"" + returnValue.url + "\" align=\"middle\""+
                                    " width="+returnValue.height+""+
                                    " height="+returnValue.width+""+
                                    " autostart=0"+
                                    " showcontrols=0 >"+
                                 "</embed>"+
                                "</object>";
           
               var filterIE = RadEditor1ClientObject.FiltersManager.GetFilterByName("IEKeepObjectParamsFilter"); 
             
               flashContent = (filterIE)?filterIE.GetDesignContent(flashContent):flashContent; 
               RadEditor1ClientObject.PasteHtml(flashContent);  
            }  
        } 

    Kindly Advise,
  2. Stanimir
    Admin
    Stanimir avatar
    1653 posts

    Posted 11 Mar 2009 Link to this post

    Hello Platinum,

    Regarding you first question you can use the window.showModalDialog(sURL[, vArguments][, sFeatures]); The second argument, vArguments, is a variant that specifies the arguments to use when displaying the document. You can pass the editor through this argument and then extract the values passed by the caller from the dialogArguments property of the window object of the dialogue page. This way you do not need a callback function and you can handle the pasting of the code in the dialogue window. You can find more information on window.showModalDialog in the following article http://www.webreference.com/js/tutorial1/dialog.html

    Regarding your second question, by using SharePoint designer or some other tool,  You can put your javascript code in the page where you are using the RadEditor or even at the bottom of your master page. What I suggest to you is to check if you have the RadEditorNamespace registered though. This way you will not load the script if you have no RadEditor on the page. You can make the following check:
    if (typeof(RadEditorNamespace) != "undefined"
        //enter your code here. 


    Greetings,
    Stanimir
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

  3. Archana
    Archana avatar
    18 posts
    Member since:
    May 2009

    Posted 04 Feb 2010 Link to this post

    Hi

    I am using a custom radEditor dialog to open an aspx form.
    I want to refer the url of the page in which this radEditor is present i.e. calling page url in the aspx form code.
    I have tried -  Request.UrlReferrer.ToString();
    but it throws error.
    How do i achieve it??

    Regards,
    Archana

  4. Stanimir
    Admin
    Stanimir avatar
    1653 posts

    Posted 04 Feb 2010 Link to this post

    Hi Archana,
    Review the following forum thread http://forums.asp.net/t/1383898.aspx.

    Regards,
    Stanimir
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  5. Archana
    Archana avatar
    18 posts
    Member since:
    May 2009

    Posted 04 Feb 2010 Link to this post

    Hi Stanimir

    Thanx for the quick reply.
    I tried the approaches from the forum you suggested but they are giving the absolute url of the current aspx form.

    Here is the situation.

    I have radEditor control in a sharepoint page called say page1.aspx.
    In a custom button of this radEditor control i am calling a another page called page2.aspx.
    The solution you suggested gives me the url of page2.aspx.
    The problem is i want to have absolute url of page1.aspx in the code of page2.aspx.
    How do I achieve this??

    Regards,
    Archana
  6. Stanimir
    Admin
    Stanimir avatar
    1653 posts

    Posted 08 Feb 2010 Link to this post

    Hello Archana,
    Review the following online help article How to: Pass Values Between ASP.NET Web Pages. Also could you please provide me with the code which is opening the dialog form?

    Sincerely yours,
    Stanimir
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  7. Archana
    Archana avatar
    18 posts
    Member since:
    May 2009

    Posted 08 Feb 2010 Link to this post

    Hi Stanimir,

    The code which thru which i m opening the custom dialog is as follows:

    Telerik.Web.UI.Editor.CommandList["ExternalLink"] = function(commandName, editor, args)
    {
        var editorSelection = editor.getSelection();
        var selTitle = "";
        var selTooltip = "";
        var selLink = "";
        var selClass = "";
        var selTarget = "";
        var linkElement = null;
        if(editorSelection.getParentElement().tagName == "A")
        {
     linkElement = editorSelection.getParentElement();
     selTitle = linkElement.innerText;
     selTooltip = linkElement.getAttribute("title");
     selLink = linkElement.getAttribute("href");
     selClass = linkElement.getAttribute("className"); 
     selTarget = linkElement.getAttribute("target");
        }  
        else
        {
     selTitle = editorSelection.getText();
        }

       var url = "/_layouts/InfosysCMS/Infosys_WebTrendsLinks.aspx?SelTitle="+selTitle+"&SelTooltip="+selTooltip+"&SelLink="+selLink+"&SelClass="+selClass+"&SelTarget="+selTarget;
        var selectedFile = window.showModalDialog(url, selectedFile);
        if(selectedFile != null)
       {
         if(linkElement != null)
      linkElement.parentNode.removeChild(linkElement);
     var selectedfile_array = selectedFile.split("~");
     var linkname = selectedfile_array[0];
     var scriptavalue = selectedfile_array[1];
     var scriptacall = selectedfile_array[2]
     editor.pasteHtml('<span>'+linkname + '<script type="text/javascript">document.getElementById("' + scriptavalue  + 
    '").onclick=function(){'+scriptacall+';}</script></span>');
       }
    };


    Thanks & Regards,
    Archana

  8. Stanimir
    Admin
    Stanimir avatar
    1653 posts

    Posted 09 Feb 2010 Link to this post

    Hello Archana,
    You are using the following string for creating the url:
    var url = "/_layouts/InfosysCMS/Infosys_WebTrendsLinks.aspx?SelTitle="+selTitle+"&SelTooltip="+selTooltip+"&SelLink="+selLink+"&SelClass="+selClass+"&SelTarget="+selTarget;

    You can add one more query sting variable for example OpenerLocation:
    var url = "/_layouts/InfosysCMS/Infosys_WebTrendsLinks.aspx?SelTitle="+selTitle+"&SelTooltip="+selTooltip+"&SelLink="+selLink+"&SelClass="+selClass+"&SelTarget="+selTarget + "&OpenerLocation=" + encodeURIComponent(window.location);

    Review the article about encodeURIComponent http://www.w3schools.com/jsref/jsref_encodeURIComponent.asp.

    Here is the article where you can find information of how to decode the uri http://briancaos.wordpress.com/2009/03/31/decodeuricomponent-equivalent-in-c/.

    Best wishes,
    Stanimir
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Back to Top