Skip to content

Commit

Permalink
begind restructure of popup windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mart2070 committed Aug 28, 2024
1 parent e3242ff commit dc9d966
Showing 1 changed file with 52 additions and 17 deletions.
69 changes: 52 additions & 17 deletions tdx-enhanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
calendar.parentElement.append(newCal)
});
}

//change tab title
if (header) {
let ticketTitle = header.childNodes[0].textContent
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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 {
Expand All @@ -469,22 +497,24 @@
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': {
href = link.href
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
}
}
Expand All @@ -493,6 +523,11 @@
return window.open(href,'_blank',params)
}
}

}

function generatePopup(href,w,h,l,t,source) {

}

function injectOtherStyles(element) {
Expand Down

0 comments on commit dc9d966

Please sign in to comment.