зеркало из https://github.com/mozilla/gecko-dev.git
Add UI for changing direction of the document and input fields. Bug 85420, patch by Asaf Romano <bugs.mano@mail-central.com>, r=smontagu, sr=neil
This commit is contained in:
Родитель
227212ecea
Коммит
fc35abf648
|
@ -660,6 +660,14 @@ function Startup()
|
|||
gClickSelectsAll = pref.getBoolPref("browser.urlbar.clickSelectsAll");
|
||||
gClickAtEndSelects = pref.getBoolPref("browser.urlbar.clickAtEndSelects");
|
||||
|
||||
// BiDi UI
|
||||
gShowBiDi = isBidiEnabled();
|
||||
if (gShowBiDi) {
|
||||
document.getElementById("documentDirection-swap").hidden = false;
|
||||
document.getElementById("textfieldDirection-separator").hidden = false;
|
||||
document.getElementById("textfieldDirection-swap").hidden = false;
|
||||
}
|
||||
|
||||
// now load bookmarks after a delay
|
||||
setTimeout(LoadBookmarksCallback, 0);
|
||||
}
|
||||
|
@ -2507,3 +2515,47 @@ function updateFileUploadItem()
|
|||
else
|
||||
item.setAttribute('disabled', 'true');
|
||||
}
|
||||
|
||||
function isBidiEnabled()
|
||||
{
|
||||
var rv = false;
|
||||
|
||||
var systemLocale;
|
||||
try {
|
||||
var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"]
|
||||
.getService(Components.interfaces.nsILocaleService);
|
||||
systemLocale = localeService.getSystemLocale().getCategory("NSILOCALE_CTYPE");
|
||||
rv = /^(he|ar|syr|fa|ur)-/.test(systemLocale);
|
||||
} catch (e) {}
|
||||
|
||||
if (!rv) {
|
||||
// check the overriding pref
|
||||
try {
|
||||
rv = pref.getBoolPref("bidi.browser.ui");
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
function SwitchDocumentDirection(aWindow)
|
||||
{
|
||||
aWindow.document.dir = (aWindow.document.dir == "ltr" ? "rtl" : "ltr");
|
||||
|
||||
for (var run = 0; run < aWindow.frames.length; run++)
|
||||
SwitchDocumentDirection(aWindow.frames[run]);
|
||||
}
|
||||
|
||||
function SwitchFocusedTextEntryDirection()
|
||||
{
|
||||
// The keybinding shoudn't work if the menu item is hidden
|
||||
if (gShowBiDi) {
|
||||
var focusedElement = document.commandDispatcher.focusedElement;
|
||||
if (focusedElement)
|
||||
if (window.getComputedStyle(focusedElement, "").direction == "ltr")
|
||||
focusedElement.style.direction = "rtl";
|
||||
else
|
||||
focusedElement.style.direction = "ltr";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,11 @@
|
|||
<key id="key_paste"/>
|
||||
<key id="key_delete"/>
|
||||
<key id="key_selectAll"/>
|
||||
|
||||
<key id="key_SwitchTextDirection"
|
||||
key="&bidiSwitchTextDirectionItem.commandkey;"
|
||||
command="cmd_SwitchTextDirection"
|
||||
modifiers="accel,shift" />
|
||||
|
||||
<!-- View Menu -->
|
||||
<key id="key_reload" key="&reloadCmd.commandkey;" oncommand="BrowserReload();" modifiers="accel"/>
|
||||
<key key="&reloadCmd.commandkey;" oncommand="BrowserReloadSkipCache();" modifiers="accel,shift"/>
|
||||
|
@ -154,6 +158,7 @@
|
|||
<command id="cmd_paste"/>
|
||||
<command id="cmd_delete"/>
|
||||
<command id="cmd_selectAll" observes="isImage"/>
|
||||
<command id="cmd_SwitchTextDirection" oncommand="SwitchFocusedTextEntryDirection();" disabled="true" />
|
||||
|
||||
<!-- Content area context menu -->
|
||||
<command id="cmd_copyLink"/>
|
||||
|
@ -164,7 +169,8 @@
|
|||
<command id="View:PageSource" oncommand="BrowserViewSourceOfDocument(content.document);" observes="isImage"/>
|
||||
<command id="View:PageInfo" oncommand="BrowserPageInfo();"/>
|
||||
<command id="View:FullScreen" oncommand="BrowserFullScreen();"/>
|
||||
|
||||
<command id="cmd_SwitchDocumentDirection" oncommand="SwitchDocumentDirection(window.content);" />
|
||||
|
||||
<!-- Search Menu -->
|
||||
<command id="Browser:Find" oncommand="BrowserFind();" observes="isImage"/>
|
||||
<command id="Browser:FindAgain" oncommand="BrowserFindAgain(false);" observes="isImage"/>
|
||||
|
@ -374,6 +380,13 @@
|
|||
<menuitem id="menu_findTypeLinks"/>
|
||||
<menuitem id="menu_findTypeText"/>
|
||||
|
||||
<menuseparator hidden="true" id="textfieldDirection-separator"/>
|
||||
<menuitem hidden="true" id="textfieldDirection-swap"
|
||||
label="&bidiSwitchTextDirectionItem.label;"
|
||||
key="key_SwitchTextDirection"
|
||||
accesskey="&bidiSwitchTextDirectionItem.accesskey;"
|
||||
command="cmd_SwitchTextDirection"/>
|
||||
|
||||
<menuseparator id="menu_PrefsSeparator"/>
|
||||
<menuitem id="menu_preferences" oncommand="goPreferences('navigator', 'chrome://communicator/content/pref/pref-navigator.xul', 'navigator')"/>
|
||||
</menupopup>
|
||||
|
@ -409,6 +422,10 @@
|
|||
</menupopup>
|
||||
</menu>
|
||||
<menu id="charsetMenu" observes="isImage"/>
|
||||
<menuitem hidden="true" id="documentDirection-swap"
|
||||
label="&bidiSwitchPageDirectionItem.label;"
|
||||
accesskey="&bidiSwitchPageDirectionItem.accesskey;"
|
||||
command="cmd_SwitchDocumentDirection"/>
|
||||
<menuseparator />
|
||||
<menuitem accesskey="&pageSourceCmd.accesskey;" label="&pageSourceCmd.label;" key="key_viewSource" command="View:PageSource"/>
|
||||
<menuitem accesskey="&pageInfoCmd.accesskey;" label="&pageInfoCmd.label;" key="key_viewInfo" command="View:PageInfo"/>
|
||||
|
|
|
@ -198,3 +198,8 @@
|
|||
|
||||
<!ENTITY popupIcon.tooltiptext "Unblock this site's popups">
|
||||
|
||||
<!ENTITY bidiSwitchPageDirectionItem.label "Switch Page Direction">
|
||||
<!ENTITY bidiSwitchPageDirectionItem.accesskey "g">
|
||||
<!ENTITY bidiSwitchTextDirectionItem.label "Switch Text Direction">
|
||||
<!ENTITY bidiSwitchTextDirectionItem.accesskey "w">
|
||||
<!ENTITY bidiSwitchTextDirectionItem.commandkey "X">
|
||||
|
|
Загрузка…
Ссылка в новой задаче