Left-to-right/Right-to-left support for Chatzilla. Bug 250864, patch by Asaf Romano (bugs.mano@mail-central.com), r=silver.
git-svn-id: svn://10.0.0.236/trunk@159408 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -95,6 +95,7 @@ function initCommands()
|
||||
["help", cmdHelp, CMD_CONSOLE],
|
||||
["hide-view", cmdHideView, CMD_CONSOLE],
|
||||
["ignore", cmdIgnore, CMD_NEED_NET | CMD_CONSOLE],
|
||||
["input-text-direction", cmdInputTextDirection, 0],
|
||||
["invite", cmdInvite, CMD_NEED_SRV | CMD_CONSOLE],
|
||||
["join", cmdJoin, CMD_NEED_SRV | CMD_CONSOLE],
|
||||
["join-charset", cmdJoin, CMD_NEED_SRV | CMD_CONSOLE],
|
||||
@@ -136,6 +137,7 @@ function initCommands()
|
||||
["sync-timestamps", cmdSync, 0],
|
||||
["sync-windows", cmdSync, 0],
|
||||
["testdisplay", cmdTestDisplay, CMD_CONSOLE],
|
||||
["text-direction", cmdTextDirection, 0],
|
||||
["timestamps", cmdTimestamps, CMD_CONSOLE],
|
||||
["timestamp-format", cmdTimestampFormat, CMD_CONSOLE],
|
||||
["toggle-ui", cmdToggleUI, CMD_CONSOLE],
|
||||
@@ -186,8 +188,14 @@ function initCommands()
|
||||
["userlist", "toggle-ui userlist", CMD_CONSOLE],
|
||||
["tabstrip", "toggle-ui tabstrip", CMD_CONSOLE],
|
||||
["statusbar", "toggle-ui status", CMD_CONSOLE],
|
||||
["header", "toggle-ui header", CMD_CONSOLE]
|
||||
|
||||
["header", "toggle-ui header", CMD_CONSOLE],
|
||||
|
||||
// text-direction aliases
|
||||
["rtl", "text-direction rtl", CMD_CONSOLE],
|
||||
["ltr", "text-direction ltr", CMD_CONSOLE],
|
||||
["toggle-text-dir", "text-direction toggle", 0],
|
||||
["irtl", "input-text-direction rtl", CMD_CONSOLE],
|
||||
["iltr", "input-text-direction ltr", CMD_CONSOLE]
|
||||
];
|
||||
|
||||
// set the stringbundle associated with these commands.
|
||||
@@ -2700,3 +2708,47 @@ function cmdDCCDecline(e)
|
||||
display(MSG_DCC_MATCHES_HELP);
|
||||
return true;
|
||||
}
|
||||
|
||||
function cmdTextDirection(e)
|
||||
{
|
||||
var direction;
|
||||
|
||||
switch (e.dir)
|
||||
{
|
||||
case "toggle":
|
||||
sourceObject = e.sourceObject.frame.contentDocument.body;
|
||||
if (window.getComputedStyle(sourceObject, null).direction == "ltr")
|
||||
direction = 'rtl';
|
||||
else
|
||||
direction = 'ltr';
|
||||
break;
|
||||
case "rtl":
|
||||
direction = 'rtl';
|
||||
break;
|
||||
default:
|
||||
// that is "case "ltr":",
|
||||
// but even if !e.dir OR e.dir is an invalid value -> set to default direction
|
||||
direction = 'ltr';
|
||||
}
|
||||
client.input.style.direction = direction;
|
||||
e.sourceObject.frame.contentDocument.body.style.direction = direction;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function cmdInputTextDirection(e)
|
||||
{
|
||||
var direction;
|
||||
|
||||
switch (e.dir)
|
||||
{
|
||||
case "rtl":
|
||||
client.input.style.direction = 'rtl';
|
||||
break
|
||||
default:
|
||||
// that is "case "ltr":", but even if !e.dir OR e.dir is an invalid value -> set to default direction
|
||||
client.input.style.direction = 'ltr';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -296,7 +296,9 @@ function initMenus()
|
||||
["-"],
|
||||
["leave", {visibleif: "cx.TYPE == 'IRCChannel'"}],
|
||||
["delete-view", {visibleif: "cx.TYPE != 'IRCChannel'"}],
|
||||
["disconnect"]
|
||||
["disconnect"],
|
||||
["-"],
|
||||
["toggle-text-dir"]
|
||||
]
|
||||
};
|
||||
|
||||
@@ -312,7 +314,9 @@ function initMenus()
|
||||
["-"],
|
||||
["leave", {visibleif: "cx.TYPE == 'IRCChannel'"}],
|
||||
["delete-view", {visibleif: "cx.TYPE != 'IRCChannel'"}],
|
||||
["disconnect"]
|
||||
["disconnect"],
|
||||
["-"],
|
||||
["toggle-text-dir"]
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
@@ -1865,6 +1865,9 @@ function multilineInputMode (state)
|
||||
singleInputBox.setAttribute ("collapsed", "true");
|
||||
splitter.setAttribute ("collapsed", "false");
|
||||
multiInputBox.setAttribute ("collapsed", "false");
|
||||
// muliInput should have the same direction as singleInput
|
||||
var direction = window.getComputedStyle(singleInput, null).direction;
|
||||
multiInput.style.direction = direction;
|
||||
client.input = multiInput;
|
||||
}
|
||||
else /* turn off multiline input mode */
|
||||
@@ -1876,6 +1879,9 @@ function multilineInputMode (state)
|
||||
splitter.setAttribute ("collapsed", "true");
|
||||
multiInputBox.setAttribute ("collapsed", "true");
|
||||
singleInputBox.setAttribute ("collapsed", "false");
|
||||
// singleInput should have the same direction as multiInput
|
||||
var direction = window.getComputedStyle(multiInput,'').direction;
|
||||
singleInput.style.direction = direction;
|
||||
client.input = singleInput;
|
||||
}
|
||||
|
||||
@@ -2024,6 +2030,10 @@ function setCurrentObject (obj)
|
||||
if (client.PRINT_DIRECTION == 1)
|
||||
scrollDown(obj.frame, false);
|
||||
|
||||
// Input area should have the same direction as the output area
|
||||
var contentArea = client.currentObject.frame.contentDocument.body;
|
||||
var direction = window.getComputedStyle(contentArea, null).direction;
|
||||
client.input.style.direction = direction;
|
||||
client.input.focus();
|
||||
}
|
||||
|
||||
|
||||
@@ -237,6 +237,18 @@ cmd.statusbar.key = accel shift S
|
||||
cmd.header.label = Header
|
||||
cmd.header.key = accel shift H
|
||||
|
||||
cmd.input-text-direction.params = <dir>
|
||||
cmd.text-direction.params = <dir>
|
||||
|
||||
cmd.rtl.help = Switches text direction to Right-to-Left.
|
||||
cmd.ltr.help = Switches text direction to Left-to-Right.
|
||||
|
||||
cmd.irtl.help = Switches input area direction to Right-to-Left.
|
||||
cmd.iltr.help = Switches input area direction to Left-to-Right.
|
||||
|
||||
cmd.toggle-text-dir.label = S&witch Text Direction
|
||||
cmd.toggle-text-dir.key = accel shift E
|
||||
|
||||
cmd.toggle-pref.params = <pref-name>
|
||||
cmd.toggle-pref.help = Toggles the boolean preference specified by <pref-name>.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user