Skip to content

Instantly share code, notes, and snippets.

@IanWhalen
Created February 10, 2017 16:19
Show Gist options
  • Save IanWhalen/79aad402601ef4f3f9ec761c02a5df39 to your computer and use it in GitHub Desktop.
Save IanWhalen/79aad402601ef4f3f9ec761c02a5df39 to your computer and use it in GitHub Desktop.
javascript: { var dragBar = document.getElementById("ghx-detail-head"); var detailView = document.getElementById("ghx-detail-view"); var headerGroup = document.getElementById("ghx-column-header-group"); var controlGroup = document.getElementById("ghx-detail-head"); var tmpElem = document.createElement('div'); tmpElem.innerHTML = '<span style="display: block;" id="js-sizer" class="ghx-sizer ui-resizable-handle ui-resizable-w" data-tooltip="Resize Detail View" original-title=""><span class="ghx-icon ghx-icon-sizer"></span></span>'; var dragElem = tmpElem.childNodes[0]; controlGroup.insertBefore(dragElem,controlGroup.childNodes[0]); var currentWidth = localStorage.getItem('jiraWidth') || '400px'; currentStylesheet = document.createElement('style'); currentStylesheet.innerHTML = '#ghx-detail-view { width: ' + currentWidth + ' !important;} '; document.body.insertBefore(currentStylesheet, document.body.childNodes[0]); dragBar.addEventListener ("mousedown" , startJiraDrag , false); var stateMouseDown = false; var mouseStartX = 0; var jiraStartWidth, jiraHeaderWidth; var currentStylesheet; function startJiraDrag (ev) { if (currentStylesheet) { document.body.removeChild(currentStylesheet); } stateMouseDown = true; mouseStartX = ev.pageX; jiraStartWidth = detailView.clientWidth; jiraHeaderWidth = headerGroup.clientWidth; document.addEventListener ("mousemove" , continueJiraDrag , false); document.addEventListener ("mouseup" , endJiraDrag , false); } function continueJiraDrag (ev) { var pX = ev.pageX; detailView.style.width = (jiraStartWidth + mouseStartX - pX) + "px"; headerGroup.style.width = (jiraHeaderWidth - mouseStartX + pX) + "px"; } function endJiraDrag () { currentStylesheet = document.createElement('style'); currentStylesheet.innerHTML = '#ghx-detail-view { width: ' + detailView.style.width + ' !important;} '; document.body.insertBefore(currentStylesheet, document.body.childNodes[0]); localStorage.setItem('jiraWidth',detailView.style.width); document.removeEventListener ("mousemove" , continueJiraDrag , false); document.removeEventListener ("mouseup" , endJiraDrag , false); } };void(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment