datatable.directory codebase https://datatable.directory/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
datatable.directory/resources/assets/js/modules/block-collapse.js

21 lines
693 B

// toggle collapse when clicked outside link, without drag
$(document)
.on('mousedown', '.block-collapse', function (e) {
let $bc = $(e.target).closest('.block-collapse')
$bc.data('mx', e.screenX)
$bc.data('my', e.screenY)
})
.on('mouseup', '.block-collapse', function (e) {
if (e.target.nodeName === 'A') return
let $bc = $(e.target).closest('.block-collapse')
if (typeof $bc.data('mx') !== 'undefined') {
let x0 = +$bc.data('mx')
let y0 = +$bc.data('my')
if (Math.abs(x0 - e.screenX) > 5 || Math.abs(y0 - e.screenY) > 5) {
// drag
} else {
$(e.target).closest('.block-collapse').toggleClass('reveal')
}
}
})