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

align center is used but doesn't work with Firefox

1 Answer 46 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Xavier
Top achievements
Rank 1
Xavier asked on 10 Oct 2010, 10:44 AM
Hi,

We are using the RadEditor for Sharepoint, version 5.7.3.0.
The customer wants to be able to center a table horizontally. Changing the alignment in the table properties adds a align="center" attribute to the table tag. Unfortunately, it seems that Firefox doesn't take the align attribute into account.

I've found a workaround which is to add a style="margin-left:auto;margin-right:auto" to the table.
I want to use this workaround in a way that is as user-friendly as possible. The best would be to have it used when the user selects the alignment.

For now, I've created a CSS class which can be applied through the "CSS Class" drop down list under the "Layout" section :
.halign {margin-right:auto;margin-left:auto;}
It works unless I also need a complete table layout (as described here). If I select different classes in the "CSS Class" and "CSS Class layout" drop down lists, the last selected is applied. It would be nice if both were applied (like <table class="halign table_layout" ...>).

I hope you can help.

Kind regards,
Xavier Stévenne.

1 Answer, 1 is accepted

Sort by
0
Stanimir
Telerik team
answered on 13 Oct 2010, 08:29 AM
Hi Xavier,

Here is one solution of the problem:

1. Add the following element in the respective ConfigFile.xml or ListConifgFile.xml, which is located in the /Program Files/Common Files/Microsoft Shared/web server extensions/wpresources/RadEditorSharePoint/5.x.x.0__1f131a624888eeed/Resources/ folder:
<property name="OnClientCommandExecuting">OnClientCommandExecuting</property>

2. Add the following javascript method in the MOSSEditorTools.js file, which is located in the mentioned above folder:
function OnClientCommandExecuting(editor, args)
{
    if (args.get_commandName() == "JustifyCenter")
    {
        var selectedElement = editor.getSelectedElement();
        if (selectedElement && selectedElement.tagName == "TABLE")
        {
            selectedElement.style.marginLeft = "auto";
            selectedElement.style.marginRight = "auto";
        }
    }
}


Feel free to modify the javascript so it will fit you scenario.

All the best,
Stanimir
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
Tags
Editor
Asked by
Xavier
Top achievements
Rank 1
Answers by
Stanimir
Telerik team
Share this question
or