Created
January 21, 2016 21:16
-
-
Save keif/3aadb415979b93ef9f61 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// variables for panel splitter; | |
var panelSplitterWidth = { | |
defaultW: null, | |
currentW: null | |
}; | |
// fires on mousedown on panel splitter draggable area | |
var panelSplitterClick = function(event) { | |
var $dragPanel = $(event.Event.target).closest("td:not('.af_panelSplitter_horizontal-icon-container')"); | |
// set width on initial click after pageload only | |
panelSplitter.defaultW = (panelSplitter.defaultW) ? panelSplitter.defaultW : $dragPanel.prev().width(); | |
panelSplitter.currentW = $dragPanel.prev().width(); | |
}; | |
// fires whenever the panel splitter is moved | |
var panelSplitterPropertyChange = function (event) { | |
var panelObj = propertyChange(event); | |
// toggle resize cursor based on sidepanel width | |
$(document.getElementById(panelObj.componentId + "::d"))[(panelSplitter.currentW >= panelSplitter.defaultW) ? "removeClass" : "addClass"]("resize"); | |
}; | |
// domready from jQuery | |
$(function() { | |
/** | |
* extend AdfDhtmlPanelSplitterBasePeer.prototype._handleDrag | |
* | |
* In order to enforce a max width on the left panel, we have to check the drag distance | |
* and prevent it from overextending beyond the set width of the sidePanel | |
*/ | |
(function(drag) { | |
AdfDhtmlPanelSplitterBasePeer.prototype._handleDrag = function (event, xDist, yDist) { | |
var slideLeft = xDist < 0; | |
panelSplitter.currentW = panelSplitter.currentW + xDist; // sidebar width +/- proposed change | |
// pass xDist if we can widen the panel or if sliding left | |
xDist = (panelSplitter.currentW <= panelSplitter.defaultW || slideLeft) ? xDist : 0; | |
// call original ADF function | |
drag.call(this, event, xDist, yDist); | |
}; | |
}(AdfDhtmlPanelSplitterBasePeer.prototype._handleDrag)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment