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

Show/Hide a Module via Javascript

4 Answers 130 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 05 Mar 2010, 02:51 PM
We'd have a system custom module for the editor that would contain large save/close buttons (not toolbar sizes) we'd like to show only when the editor is in full screen.  I can detect the full screen toggling, but need a way to show/hide the module via javascript.  Basically the same functionality that the Module Manager button does without the user clicking on that button and selecting/deselecting our module.

Any way to do this?

4 Answers, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 05 Mar 2010, 03:18 PM
Hi,

Here is an example demonstrating how to toggle the visibility of the RadEditor modules with javascript:

<telerik:RadEditor ID="RadEditor1" runat="server">
    <Tools>
        <telerik:EditorToolGroup>
            <telerik:EditorTool Name="RadEditorStatistics" />
            <telerik:EditorTool Name="RadEditorHtmlInspector" />
        </telerik:EditorToolGroup>
    </Tools>
    <Modules>
        <telerik:EditorModule Name="RadEditorDomInspector" />
        <telerik:EditorModule Name="RadEditorHtmlInspector" />
        <telerik:EditorModule Name="RadEditorNodeInspector" />
        <telerik:EditorModule Name="RadEditorStatistics" />
    </Modules>
</telerik:RadEditor> 
<script type="text/javascript">
    Telerik.Web.UI.Editor.CommandList["RadEditorStatistics"] = function(commandName, editor, args) {
        ToggleModuleVisibility("RadEditorStatistics", editor);
    };
 
    Telerik.Web.UI.Editor.CommandList["RadEditorHtmlInspector"] = function(commandName, editor, args) {
        ToggleModuleVisibility("RadEditorHtmlInspector", editor);
    };
 
    function ToggleModuleVisibility(moduleName, editor) {
        var moduleManager = editor.get_modulesManager();
        if (!moduleManager) return false;
 
        var module = moduleManager.getModuleByName(moduleName);
        if (module) {
            module.toggleVisibility();
        }
 
        return false;
    
</script>

Greetings,
Rumen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Steve
Top achievements
Rank 1
answered on 05 Mar 2010, 03:58 PM
Need to check for the full screen button in OnClientCommandExecuting instead of OnClientCommandExecuted, but that works perfectly. 

Thanks.

0
Trevor
Top achievements
Rank 1
answered on 14 Apr 2011, 09:16 PM
This works greate, however I would like to know how to Hide the module without toggling.
Can I test if the module is visible first? if so then I will toggle.

Regards,

Trevor
0
Rumen
Telerik team
answered on 18 Apr 2011, 12:40 PM
Hi Todd,

You can use the get_visible() and set_visible(boolean) methods of the module object:

var module = moduleManager.getModuleByName(moduleName);
if (module) {
    //module.toggleVisibility();
    if (module.get_visible()) { module.set_visible(false); }
}



Kind regards,
Rumen
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Editor
Asked by
Steve
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Steve
Top achievements
Rank 1
Trevor
Top achievements
Rank 1
Share this question
or