(function(exports) { if (location != 'chrome://messenger/content/messenger.xhtml') return; //Das Folgende verhindert, das title Attribute auf Zellen //der Nachrichtenliste gesetzt werden, sofern der Inhalt nicht //verkürzt wurde // doc.l10n.setAttributes: // https://searchfox.org/firefox-main/source/dom/webidl/DOMLocalization.webidl#83 // https://searchfox.org/firefox-main/source/dom/l10n/DOMLocalization.cpp#140 const doc=gTabmail.tabInfo[0].chromeBrowser.contentWindow.document; doc.l10n.easyPeasy_l10nSetAttributes=(elem, label, props)=>{ //console.log('cell: '+label+' '+elem.outerHTML+' props='+JSON.stringify(props)); if (props?.hasOwnProperty('title') && elem.hasAttribute('data-column-name') && //role="gridcell" not on Mac elem.parentNode.getAttribute('is')=='thread-row' //messages list ) { //remove title attribute from props if content is not overflown let cont=elem.querySelector('span')?.parentNode; let overflow; if (cont) { //subject col overflow=cont.scrollWidth>cont.clientWidth; //const box=cont.getBoxQuads()[0]; //console.log('cell: '+elem.className+' overflow='+overflow+' '+cont.scrollWidth+'>'+cont.clientWidth+' '+JSON.stringify(box)); } else { //all other cols are pure td //for td the scrollWidth is always equal to clientWidth :-( cont=elem.firstChild; //The TEXT node const box=cont.getBoxQuads()[0]; const sw=box.p2.x-box.p1.x; let delta=9; //9px padding if (elem.dataset.columnName=='correspondentcol') delta+=18; //text-indent style overflow=sw>elem.clientWidth-delta; //console.log('cell: '+elem.className+' overflow='+overflow+' '+sw+'>'+elem.clientWidth+' '+JSON.stringify(box)); } if (!overflow) props.title=''; } //Call saved original function try { doc.l10n.easyPeasy_savedL10nSetAttributes(elem, label, props); } catch(e) { console.log('throws: '+e); } }; //Save original function for later use (if not already saved) if (typeof doc.l10n.easyPeasy_savedL10nSetAttributes=='undefined') { console.log('saving l10.setAttributes'); doc.l10n.easyPeasy_savedL10nSetAttributes=doc.l10n.setAttributes; } else console.log('already saved l10.setAttributes'); //replace original function with our function doc.l10n.setAttributes=doc.l10n.easyPeasy_l10nSetAttributes //////////////////////////////////// // Load tooltip definitions exports.easyPeasy.loadFile('tooltips.def', exports.easyPeasy); //console.log('tooltips: '+JSON.stringify(exports.easyPeasy.tooltips)); //setzen von Tooltips/Labels exports.easyPeasy.setButtons=() => { const ut=document.getElementById('unifiedToolbarContent'); ut.style.flexWrap='wrap'; for (const tt of exports.easyPeasy.tooltips) { switch (tt.typ) { case 'toolbar': const tb=ut.querySelector('li[item-id="'+tt.id+'"] button '); if (tb) { if (tt.hasOwnProperty('title')) tb.title=tt.title; if (tt.hasOwnProperty('label')) tb.lastElementChild.textContent=tt.label; } else { console.error('Toolbar button "'+tt.id+'" nicht gefunden'); } break; case 'liste': //console.log('search '+tt.id); const lb=gTabmail.currentAbout3Pane.document.getElementById(tt.id); if (lb) { //console.log('have '+tt.id+' '+lb+' '+lb.title+'|'+lb.textContent); if (tt.hasOwnProperty('title')) lb.title=tt.title; if (tt.hasOwnProperty('label')) lb.textContent=tt.label; //console.log('now '+tt.id+' '+lb+' '+lb.title+'|'+lb.textContent); } else { console.error('Spalte "'+tt.id+'" nicht gefunden'); } break; case 'filter': const qfb=gTabmail.currentAbout3Pane.document.getElementById(tt.id); if (qfb) { //console.log('have '+tt.id+' '+qfb+' '+qfb.title+'|'+qfb.textContent); if (tt.hasOwnProperty('title')) qfb.title=tt.title; if (tt.hasOwnProperty('label')) qfb.textContent=tt.label; //console.log('now '+tt.id+' '+qfb+' '+qfb.title+'|'+qfb.textContent); } else { console.error('Schnellfilter Button "'+tt.id+'" nicht gefunden'); } break; default: console.error('Tooltip Typ "'+tt.typ+'" ist nicht bekannt'); } } } //redo tooltips/labels after a switch of folders // folderURIChanged comes too early gTabmail.tabInfo[0].chromeBrowser.contentWindow.addEventListener("allMessagesLoaded", (event)=>{ //console.log('allMessagesLoaded to '+event.detail); exports.easyPeasy.setButtons(); } ); //redo tooltips/labels after tabs has been switched const tabMonitor={ monitorName: "eaysPeasy_setTooltips", onTabTitleChanged(tab) {}, onTabClosing(tab) {}, onTabPersist(tab) {}, onTabRestored(tab, state) {}, onTabOpened(tab) {}, onTabSwitched(newTab, oldTab) { //console.log('tabMonitor setTooltips '+newTab.mode.name); if (newTab.mode.name=='mail3PaneTab') { //Die unified Toolbar kann noch die Buttons des alten Tabs enthalten. //Daher die Ausführung etwas verzögern setTimeout(exports.easyPeasy.setButtons, 200); } }, }; //gTabmail.unregisterTabMonitor(tabMonitor); gTabmail.registerTabMonitor(tabMonitor); // redo tooltips/labels after toolbar has been customized if (!exports.easyPeasy.tooltip_observer) { exports.easyPeasy.tooltip_observer={ observe() { setTimeout(()=>exports.easyPeasy.setButtons(), 200); } }; // try { Services.obs.removeObserver(exports.easyPeasy.tooltip_observer, 'unified-toolbar-state-change'); } // catch(e) { console.log('removing observer throws: '+e); } Services.obs.addObserver(exports.easyPeasy.tooltip_observer, 'unified-toolbar-state-change'); } })(this);