diff --git a/src/opnsense/www/js/opnsense_bootgrid_plugin.js b/src/opnsense/www/js/opnsense_bootgrid_plugin.js index 441fa1702..5bd8ae23a 100644 --- a/src/opnsense/www/js/opnsense_bootgrid_plugin.js +++ b/src/opnsense/www/js/opnsense_bootgrid_plugin.js @@ -268,12 +268,38 @@ $.fn.UIBootgrid = function (params) { $('.selectpicker').selectpicker('refresh'); // clear validation errors (if any) clearFormValidation('frm_' + editDlg); - if ($('#'+editDlg).hasClass('modal')) { - // show dialog - $('#'+editDlg).modal({backdrop: 'static', keyboard: false}); + let target = $('#'+editDlg); + if (target.hasClass('modal')) { + // show dialog and hook draggable event on first show + target.modal({backdrop: 'static', keyboard: false}); + if (!target.hasClass('modal_draggable')) { + target.addClass('modal_draggable'); + let height=0, width=0, ypos=0, xpos=0; + let this_header = target.find('.modal-header'); + this_header.css("cursor","move"); + this_header.on('mousedown', function(e){ + this_header.addClass("drag"); + height = target.outerHeight(); + width = target.outerWidth(); + ypos = target.offset().top + height - e.pageY; + xpos = target.offset().left + width - e.pageX; + }); + $(document.body).on('mousemove', function(e){ + let itop = e.pageY + ypos - height; + let ileft = e.pageX + xpos - width; + if (this_header.hasClass("drag")){ + target.offset({top: itop, left: ileft}); + } + }).on('mouseup mouseleave', function(e){ + this_header.removeClass("drag"); + }); + } else { + // reset to starting position (remove drag distance) + target.css('top', '').css('left', ''); + } } else { // when edit dialog isn't a modal, fire click event - $('#'+editDlg).click(); + target.click(); } if (this_grid.onBeforeRenderDialog) {