Created
November 25, 2009 15:12
-
-
Save ArnaudD/242771 to your computer and use it in GitHub Desktop.
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
;(function($) { | |
$.fn.resizable = function () { | |
var mouseStartY = null; | |
var startHeight = null; | |
var resizableObject = $(this); | |
var columnsCount = $('tr:eq(0) th, tr:eq(0) td', resizableObject).length; | |
resizableObject.append ('<tfoot><tr><td colspan="'+columnsCount+'" class="resize_bar"></tr></tfoot>'); | |
resizableObject.find ('.resize_bar').mousedown (function (event) { | |
if(event.preventDefault) // Prevent FF default d'n'drop | |
event.preventDefault(); | |
mouseStartY = event.pageY; | |
startHeight = _getViewport ().height (); | |
$(document).mousemove (_drag).one ('mouseup', null, _drop); | |
}); | |
function _drag (event) { | |
var deltaY = event.pageY - mouseStartY; | |
_getViewport ().height (startHeight + deltaY) | |
} | |
function _drop (event) { | |
$(document).unbind ('mousemove', _drag); | |
} | |
function _getViewport () { | |
return $('tbody', resizableObject); | |
} | |
return resizableObject; | |
}; | |
})(jQuery); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment