diff --git a/tdx-enhanced.js b/tdx-enhanced.js index 7ea02b3..50cd670 100644 --- a/tdx-enhanced.js +++ b/tdx-enhanced.js @@ -163,6 +163,7 @@ calendar.parentElement.append(newCal) }); } + //change tab title if (header) { let ticketTitle = header.childNodes[0].textContent @@ -194,19 +195,21 @@ header.appendChild(newBox) } - //handle button links - update for now - let buttons = document.querySelectorAll("#btnUpdateTicket, #liAddTicketTask") - console.log("Buttons:",buttons) - for (const button of buttons) { - /* - let id = button.id - switch(id) { - case "btnUpdateTicket": - handleLink("update",button) - } - */ - handleLink("update",button) - } + //handle button links - updates/tasks for now + //update buttons + [...document.querySelectorAll("#btnUpdateTicket, #divUpdateFromActions>a")].forEach(button=>{ + handleLink("Update",button) + }); + + //task button + [...document.querySelectorAll("#liAddTicketTask>a")].forEach(button=>{ + handleLink("TicketTaskNew",button) + }); + + //task template button + [...document.querySelectorAll("#divAddTaskTemplate>a")].forEach(button=>{ + handleLink("TicketAddTaskTemplate",button) + }); //color the feed if darkmode var feedItems @@ -452,6 +455,10 @@ function handleLink(source,link) { let behavior = settings('get','linkBehavior') + + let relL = window.screenLeft != undefined ? window.screenLeft : screen.left + let relT = window.screenTop != undefined ? window.screenTop : screen.top + if (behavior=="tabs") { switch(source) { @@ -460,6 +467,27 @@ link.target = "_blank" break } + + case 'Update': + case 'TicketTaskNew': + case 'TicketAddTaskTemplate': { + link.onclick = (event)=>{ + event.preventDefault() + let w = (window.screen.width / 1.75) + let h = (window.screen.height / 1.25) + let l = ((window.screen.width / 2) - (w/2)) + relL + let t = ((window.screen.height / 2) - (h/2)) + relT + + //restructure url for updating + let location = window.location.pathname + let baseHref = location.substr(0, location.lastIndexOf('/')) + let href = `${baseHref}/${source}${window.location.search}` + + let params = `width=${w}px,height=${h}px,left=${l}px,top=${t}px` + return window.open(href,'_blank',params) + } + break + } } } else { @@ -469,8 +497,8 @@ var href let w = (window.screen.width / 2.1) let h = (window.screen.height / 1.25) - let l = 20 - let t = 50 + let l = 20 + relL + let t = 50 + relT switch(source) { case 'report': { @@ -478,13 +506,15 @@ break } - case 'update': { + case 'Update': + case 'TicketTaskNew': + case 'TicketAddTaskTemplate': { l = (window.screen.width / 2) + l //restructure url for updating let location = window.location.pathname let baseHref = location.substr(0, location.lastIndexOf('/')) - href = `${baseHref}/Update${window.location.search}` + href = `${baseHref}/${source}${window.location.search}` break } } @@ -493,6 +523,11 @@ return window.open(href,'_blank',params) } } + + } + + function generatePopup(href,w,h,l,t,source) { + } function injectOtherStyles(element) {