-
Notifications
You must be signed in to change notification settings - Fork 10
Support for moderator tools #4
Description
For moderators, up to two additional items are added to the topbar. They are added in a group after the site switcher, with a little separator icon added via an additional CSS class.
Broadly, everything is the same as the user-level tools, just like you were probably hoping. There are just a couple of complications.
The two moderator-specific items are:
-
A diamond that displays inbox items in a drop-down menu. This works almost identically to the normal user inbox. The diamond link has the classes
-linkandjs-mod-inbox-button. The drop-down menu that it displays has the classestopbar-dialog,modInbox-dialog, anddno. So...immediately you see a problem: your slick regex won't work, because the naming of these two things diverges slightly. -
To the right of the diamond, displayed only if there are any pending flags, is a simple count link. This links to the flag list, but doesn't display any drop-down menus or do anything else but navigate away from the page when you click on it. It doesn't live-update like other notifications. Thing is, it doesn't really have any identifying classes, so you will probably have to end up matching either by position or by the
hrefcontent (/admin/dashboard).
Most likely, my description above is cumbersome and unhelpful. Here's the relevant section of the HTML:
<nav class="secondary-nav">
<div class="-dialog-container js-topbar-dialog-corral">
<div class="topbar-dialog siteSwitcher-dialog dno">
... <!-- same stuff here -->
</div>
<div class="topbar-dialog modInbox-dialog dno">
<div class="header">
... <!-- redacted (but, same as all the others) -->
</div>
<div class="modal-content">
... <!-- redacted (but, same as all the others) -->
</div>
</div>
<ol class="-list">
... <!-- same stuff here -->
<!-- site switcher -->
<li class="-item">
<a href="https://stackexchange.com" class="-link js-site-switcher-button js-gps-track" data-gps-track="site_switcher.show" title="A list of all 171 Stack Exchange sites">
<svg aria-hidden="true" class="svg-icon iconStackExchange" width="18" height="18" viewBox="0 0 18 18"><path d="M1 13c0 1.1.9 2 2 2h8v3l3-3h1a2 2 0 0 0 2-2v-2H1v2zM15 1H3a2 2 0 0 0-2 2v2h16V3a2 2 0 0 0-2-2zM1 6h16v4H1V6z"></path></svg>
</a>
</li>
<!-- begin mod tools -->
<!-- mod-inbox/modInbox (always present) -->
<li class="-item _has-divider">
<a href="#" class="-link js-mod-inbox-button" data-url="/topbar/mod-inbox" data-unread-class="" title="Moderator inbox">
<svg aria-hidden="true" class="svg-icon iconModerator" width="18" height="18" viewBox="0 0 18 18"><path d="M8.4.78c.33-.43.87-.43 1.2 0l5.8 7.44c.33.43.33 1.13 0 1.56l-5.8 7.44c-.33.43-.87.43-1.2 0L2.6 9.78a1.34 1.34 0 0 1 0-1.56L8.4.78z"></path></svg>
</a>
</li>
<!-- mod pending flag count (THIS IS NOT IN THE HTML IF THE FLAG COUNT IS ZERO) -->
<li class="-item">
<a href="/admin/dashboard" class="-link _text-only" title="1024 posts flagged for moderator attention">
<span class="indicator-badge _regular">1024</span>
</a>
</li>
</ol>
</nav>My recommendation would probably be to add explicit support for moderator tools, but leave the "other" (unknown) category there, just in case the team gets a wild hair and decides to add some kind of never-before-seen craziness into the topbar.
That should be everything you need, without me inadvertently revealing any major seekrits. If you need anything else, let me know.