Created
September 27, 2012 21:26
-
-
Save DownRangeDevOps/3796567 to your computer and use it in GitHub Desktop.
Collapse div script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Collapse Kayako Response | |
// @namespace http://my.chiromatrixbase.com/fisher.chiromatrix.com/collaps_div.js | |
// @include http://imatrixsupport.com/staff/* | |
// ==/UserScript== | |
window.addEventListener('load', function(e) { | |
var threshold = [100,100]; | |
var skipthreshold = [1000,1000]; | |
var toCollapse = []; | |
addTo('ul'); | |
addTo('div'); | |
addTo('p'); | |
addTo('tr'); | |
addTo('table'); | |
for(var i=0,j=toCollapse.length;i<j;i++){ | |
var cur = toCollapse[i]; | |
var a = document.createElement('a'); | |
styleLink(a); | |
a.appendChild(document.createTextNode('-')); | |
a.addEventListener('click',function(e){ | |
if(this.firstChild.nodeValue === '-'){ | |
this.nextSibling.style.display = 'none'; | |
this.firstChild.nodeValue = '+'; | |
} else { | |
this.nextSibling.style.display = 'block'; | |
this.firstChild.nodeValue = '-'; | |
} | |
e.preventDefault(); | |
},false); | |
cur.style.borderLeft = '1px solid #ccc'; | |
cur.parentNode.insertBefore(a,cur); | |
} | |
function addTo(elm){ | |
var elms = document.getElementsByClassName('ticketpostcontainer'); | |
for(i in elms){ | |
toCollapse.push(elms[i]); | |
} | |
} | |
function styleLink(a){ | |
a.href = '#'; | |
a.style.fontWeight = 'bold'; | |
a.style.background = '#ffffff'; | |
a.style.border = '2px solid #cccccc'; | |
a.style.color = '#B24C58'; | |
a.style.padding = '0 4px'; | |
a.style.textDecoration = 'none'; | |
a.style.width = '1em'; | |
a.style.height = '1em'; | |
a.style.textAlign = 'center'; | |
a.style.fontSize = '100%'; | |
a.style.margin = '0 0 0 8px'; | |
} | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you got rid of the href setting in the link, then the browser wouldn't go back to the top of the page every time one of them is clicked.
At least, this is more or less what I've observed happening in chrome.