Swap position of Recent/Favorites using userChromeJS ?

User Help for Mozilla Thunderbird
Post Reply
kswartz
Posts: 85
Joined: August 18th, 2004, 4:54 pm

Swap position of Recent/Favorites using userChromeJS ?

Post by kswartz »

Okay, simple question with what may be a hard answer.

In Thunderbird 102, is it possible, using the userChromeJS extension, to swap the position of the Recent and Favorites menu items that appear when right-clicking a message and selecting "Move To"? I can see the code responsible for displaying these in messenger.xhtml, but there are no id's on those <menu> items, so I can't figure out if there's a way to control them via JS or CSS.

I suspect not, but I am constantly surprised at the versatility of this ecosystem, and figured I would throw it out there.

Thanks,
Keith
- Keith
Software & Compliance Architect
morat
Posts: 6432
Joined: February 3rd, 2009, 6:29 pm

Re: Swap position of Recent/Favorites using userChromeJS ?

Post by morat »

Try using the userChrome.css file to swap the position.

Code: Select all

/* Thunderbird userChrome.css */

@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");

menuitem#menu_FileQuitItem           { -moz-box-ordinal-group: 1000 !important; } /* File > Exit  */
menuseparator#menu_FileQuitSeparator { -moz-box-ordinal-group: 2000 !important; }
menuitem#printMenuItem               { -moz-box-ordinal-group: 3000 !important; } /* File > Print */

menupopup#mailContext-fileHereMenu > menuseparator                          { -moz-box-ordinal-group: 1000 !important; }
menupopup#mailContext-fileHereMenu > menu.folderMenuItem[label="Favorites"] { -moz-box-ordinal-group: 2000 !important; }
menupopup#mailContext-fileHereMenu > menu.folderMenuItem[label="Recent"]    { -moz-box-ordinal-group: 3000 !important; }
"Move To" uses the menupopup#mailContext-fileHereMenu selector, not the menupopup#mailContext-moveHereMenu selector, oddly.
"Copy To" uses the menupopup#mailContext-copyHereMenu selector.
kswartz
Posts: 85
Joined: August 18th, 2004, 4:54 pm

Re: Swap position of Recent/Favorites using userChromeJS ?

Post by kswartz »

morat wrote:Try using the userChrome.css file to swap the position.
Okay, that almost does it -- this changes the order, but it puts them below the account menus, instead of above. Is there a way to fix that without having to specify a -moz-box-ordinal-group setting for every one of the accounts, too? Not the most future-proof way of doing it, but also not a big deal if that's the only option, given I add a new mail account about once every three years, and this will probably break long before then. :)

Also, tip for anyone else reading this -- don't forget to set toolkit.legacyUserProfileCustomizations.stylesheets to true (which I did, at first). That stumped me for a solid hour.
- Keith
Software & Compliance Architect
kswartz
Posts: 85
Joined: August 18th, 2004, 4:54 pm

Re: Swap position of Recent/Favorites using userChromeJS ?

Post by kswartz »

By the way, with or without also using -moz-box-ordinal-group on all of the account menus, visually, this solution works. However, that introduces a new problem: keyboard navigation.

When using the keyboard and selecting "Move To", it initially focuses on Recent, even though it appears below Favorites. Then hitting the down arrow causes the focus to move UP to Favorites, and after that, the Down Arrow skips down two. My ultimate goal is to have the focus initially on Favorites, too, so I'm guessing there's an additional attribute I need to set to control navigation order?
- Keith
Software & Compliance Architect
morat
Posts: 6432
Joined: February 3rd, 2009, 6:29 pm

Re: Swap position of Recent/Favorites using userChromeJS ?

Post by morat »

Sorry, I don't know another solution.

The developers add the top level menu items in the folder-menupopup.js file.

Reference
http://searchfox.org/comm-esr102/search ... lMenuItems

Code: Select all

customElements.define("folder-menupopup", MozFolderMenuPopup, {
  extends: "menupopup",
});
I don't know how to redefine a custom element using the userChromeJS extension.

Comments on custom elements
http://gitter.im/more-snooze/community? ... 24c74c2c18
kswartz
Posts: 85
Joined: August 18th, 2004, 4:54 pm

Re: Swap position of Recent/Favorites using userChromeJS ?

Post by kswartz »

Okay, thanks. This is still 90% of the solution, which is farther than I could have gotten. I'll keep looking around, as I imagine there must be some way to control the order of navigation with the arrows -- something like tabindex but for menu entries.
- Keith
Software & Compliance Architect
morat
Posts: 6432
Joined: February 3rd, 2009, 6:29 pm

Re: Swap position of Recent/Favorites using userChromeJS ?

Post by morat »

You can ask for help in the addon developers forum.

Thunderbird Addon Developers
http://thunderbird.topicbox.com/groups/addons

The developer gersdorf asked a similar question, but there was no reply.

Extend the customElement 'folder-menupopup'
http://thunderbird.topicbox.com/groups/ ... e7984b7c5f
Post Reply