Closed Bug 953927 Opened 11 years ago Closed 11 years ago

Use a Class for Each Buddy

Categories

(Instantbird Graveyard :: Conversation, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: clokep, Assigned: florian)

Details

*** Original post on bio 490 at 2010-09-05 14:59:00 UTC ***

It would be very useful for a variety of extensions if each buddy was given a unique class name for a conversation (e.g. a sanitized name or a hash of it, or whatever is necessary to make it a valid class name) and inserting the associated class-style into the DOM tree/stylesheet of the HTML document.

Sample extensions: 
* Mic wishes this for "dimming other conversations" in which for example the style-rules for all buddies that you're not interested would be changed so that their messages are be greyed out and only the people you're interested in stand out
* I wish to use it for highlighting users (i.e. if I mouse over a user's name in a chat, all of their messages are highlighted, allowing me to quickly view all their messages)

I'm not sure of the exact structure of the HTML that is generated in the message window, but if there is a container over each message the class could be applied to, or if a separate class need be applied to the username and the message.

I hope we've explained this better, let me know if its still unclear.
*** Original post on bio 490 at 2010-09-06 09:45:32 UTC ***

(In reply to comment #0)

> I'm not sure of the exact structure of the HTML that is generated in the
> message window, but if there is a container over each message the class could
> be applied to, or if a separate class need be applied to the username and the
> message.

The structure of the generated HTML is almost entirely up to the message theme author, so there isn't much we can do there.

I guess the best solution here would be to add it to the messageClasses replacement, but if we do that, there's no guaranty that it will work on all message styles. (I would be surprised if a message style didn't use %messageClasses% at all though, as this is the only way to make a style difference between incoming, outgoing and system messages.)
*** Original post on bio 490 at 2010-09-08 19:59:09 UTC ***

So we take the HTML files given by the message theme and do direct text replacements on it to generate the file HTML that will get inserted as a new message?  That's kind of unfortunate for what we want then.

Although it could possibly be done /just/ using message themes by doing something like user_%sender%, but it'd be impossible to force people to use this so its not helpful to extensions unless they provide their own message style as well.

Is there any unique way of doing this without looping through every node to check if it refers to a particular sender (which is I believe what both Mic and I want).
*** Original post on bio 490 at 2010-09-08 21:15:08 UTC ***

What about encapsulating the messages in <span>s?
Descendants could still overwrite any style set on the user-span, but maybe something like 

 .hashOfUserName * {
   attribute: value !important; 
 }

could force an attribute on all descendants if necessary.
I'm aware that this might lead to problems though.
*** Original post on bio 490 at 2010-09-09 13:17:05 UTC ***

(In reply to comment #3)
> What about encapsulating the messages in <span>s?

There's already a <span class="ib-msg-txt"> around the text of the message. I would like to avoid adding one around the whole HTML inserted for the message as much as possible. In addition to polluting the DOM tree, it could cause unfortunate issues when messages are nested.

Let's suppose that a theme currently produces this HTML:
<div class="message">
 <em>Username</em><br>
 <p><span ib-msg-txt">Message1 from username</span></p>
 <hr>
 <p><span ib-msg-txt">Message2 from username</span></p>
</div>

If we add a span node around each message, the resulting HTML code would be:
<span class="username"><div class="message">
 <em>Username</em><br>
 <p><span ib-msg-txt">Message1 from username</span></p>
 <span class="username"><hr>
 <p><span ib-msg-txt">Message2 from username</span></p></span>
</div></span>

.message>p CSS selectors wouldn't work anymore, for a reason that is totally not relevant to the theme author.


My suggestion from comment 1 would cause the following HTML to be produced in this case:

<div class="message username">
 <em>Username</em><br>
 <p><span ib-msg-txt">Message1 from username</span></p>
 <hr>
 <p><span ib-msg-txt">Message2 from username</span></p>
</div>

As I've explained, there's no guarantee that it would always work.
*** Original post on bio 490 at 2012-11-16 13:03:59 UTC ***

This was fixed with bug 954993 (bio 1562). If there is a more specific need, we should file a new bug.
Assignee: nobody → florian
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.