Bug 134814 - Add pref for collapsing actions, and make different message types not collapse unless the motif asks for it.

ChatZilla only.
r=silver
p=gijskruitbosch+bugs@gmail.com (Gijs Kruitbosch)
This commit is contained in:
silver%warwickcompsoc.co.uk 2005-09-05 21:12:03 +00:00
Родитель b69ab62c9b
Коммит 8cccf41469
5 изменённых файлов: 84 добавлений и 10 удалений

Просмотреть файл

@ -1014,6 +1014,8 @@ function cmdSync(e)
fun = function ()
{
view.changeCSS(view.prefs["motif.current"]);
// Refresh the motif settings.
view.updateMotifSettings();
};
break;

Просмотреть файл

@ -130,7 +130,8 @@ function stock_initOutputWindow(newClient, newView, newClickHandler)
}
changeCSS(view.prefs["motif.current"]);
updateMotifSettings();
var output = document.getElementById("output");
output.appendChild(view.messages);
@ -250,6 +251,46 @@ function changeCSS(url, id)
window.scrollTo(0, window.document.height);
}
function updateMotifSettings(existingTimeout)
{
// Try... catch with a repeat to cope with the style sheet not being loaded
const TIMEOUT = 100;
try
{
existingTimeout += TIMEOUT;
view.motifSettings = getMotifSettings();
}
catch(ex)
{
if (existingTimeout >= 30000) // Stop after trying for 30 seconds
return;
if (ex.name == "NS_ERROR_DOM_INVALID_ACCESS_ERR") //not ready, try again
setTimeout(updateMotifSettings, TIMEOUT, existingTimeout);
else // something else, panic!
dd(ex);
}
}
function getMotifSettings()
{
var re = new RegExp("czsettings\\.(\\w*)", "i");
var rules = document.getElementById("main-css").sheet.cssRules;
var rv = new Object();
var ary;
// Copy any settings, which are available in the motif using the
// "CZSETTINGS" selector. We only store the regexp match after checking
// the rule type because selectorText is not defined on other rule types.
for (var i = 0; i < rules.length; i++)
{
if ((rules[i].type == CSSRule.STYLE_RULE) &&
((ary = rules[i].selectorText.match(re)) != null))
{
rv[ary[1]] = true;
}
}
return rv;
}
function setText(field, text, checkCondition)
{
if (!header[field].firstChild)

Просмотреть файл

@ -125,6 +125,7 @@ function initPrefs()
["channelMaxLines", 500, "global.maxLines"],
["charset", "utf-8", ".connect"],
["clientMaxLines", 200, "global.maxLines"],
["collapseActions", true, "appearance.misc"],
["collapseMsgs", false, "appearance.misc"],
["connectTries", 5, ".connect"],
["copyMessages", true, "global"],
@ -383,6 +384,7 @@ function getNetworkPrefManager(network)
["awayNick", defer, ".ident"],
["bugURL", defer, "appearance.misc"],
["charset", defer, ".connect"],
["collapseActions", defer, "appearance.misc"],
["collapseMsgs", defer, "appearance.misc"],
["connectTries", defer, ".connect"],
["dcc.useServerIP", defer, "dcc"],
@ -468,6 +470,7 @@ function getChannelPrefManager(channel)
["autoRejoin", defer, ".connect"],
["bugURL", defer, "appearance.misc"],
["charset", defer, ".connect"],
["collapseActions", defer, "appearance.misc"],
["collapseMsgs", defer, "appearance.misc"],
["displayHeader", client.prefs["channelHeader"],
"appearance.misc"],
@ -521,6 +524,7 @@ function getUserPrefManager(user)
var prefs =
[
["charset", defer, ".connect"],
["collapseActions", defer, "appearance.misc"],
["collapseMsgs", defer, "appearance.misc"],
["displayHeader", client.prefs["userHeader"], "appearance.misc"],
["font.family", defer, "appearance.misc"],

Просмотреть файл

@ -174,6 +174,7 @@ function init()
importFromFrame("updateHeader");
importFromFrame("setHeaderState");
importFromFrame("changeCSS");
importFromFrame("updateMotifSettings");
importFromFrame("addUsers");
importFromFrame("updateUsers");
importFromFrame("removeUsers");
@ -3763,17 +3764,41 @@ function addHistory (source, obj, mergeData)
var rowExtents = ci.extents;
var nickColumnCount = nickColumns.length;
// Are we the same user as last time?
var sameNick = (nickColumnCount > 0 &&
nickColumns[nickColumnCount - 1].parentNode.
getAttribute("msg-user") ==
thisUserCol.parentNode.getAttribute("msg-user"));
var lastRowSpan, sameNick, sameDest, haveSameType, needSameType;
var isAction, collapseActions;
if (nickColumnCount == 0) // No message to collapse to.
{
sameNick = sameDest = needSameType = haveSameType = false;
lastRowSpan = 0;
}
else // 1 or more messages, check for doubles
{
var lastRow = nickColumns[nickColumnCount - 1].parentNode;
// What was the span last time?
lastRowSpan = Number(nickColumns[0].getAttribute("rowspan"));
// Are we the same user as last time?
sameNick = (lastRow.getAttribute("msg-user") ==
inobj.getAttribute("msg-user"));
// Do we have the same destination as last time?
sameDest = (lastRow.getAttribute("msg-dest") ==
inobj.getAttribute("msg-dest"));
// Is this message the same type as the last one?
haveSameType = (lastRow.getAttribute("msg-type") ==
inobj.getAttribute("msg-type"));
// Is either of the messages an action? We may not want to collapse
// depending on the collapseActions pref
isAction = ((inobj.getAttribute("msg-type") == "ACTION") ||
(lastRow.getAttribute("msg-type") == "ACTION"));
// Do we collapse actions?
collapseActions = source.prefs["collapseActions"];
// What was the span last time?
var lastRowSpan = (nickColumnCount > 0) ?
Number(nickColumns[0].getAttribute("rowspan")) : 0;
// Does the motif collapse everything, regardless of type?
// NOTE: the collapseActions pref can override this for actions
needSameType = !("collapsemore" in source.motifSettings);
}
if (sameNick)
if (sameNick && sameDest && (haveSameType || !needSameType) &&
(!isAction || collapseActions))
{
obj = inobj;
if (ci.nested)

Просмотреть файл

@ -1164,6 +1164,8 @@ pref.charset.label = Character encoding
pref.charset.help = For multiple clients to correctly read messages with non-ASCII characters on IRC, they need to use the same character encoding.
pref.collapseMsgs.label = Collapse messages
pref.collapseMsgs.help = Makes multiple messages from one person only show their nickname against the first, which can look cleaner than having the nickname repeated.
pref.collapseActions.label = Collapse actions when collapsing messages
pref.collapseActions.help = Makes multiple actions from one person only show their nickname against the first, which can look cleaner than having the nickname repeated.
pref.connectTries.label = Connection attempts
pref.connectTries.help = The number of times Chatzilla attempts to connect to a server or network.
pref.copyMessages.label = Copy important messages