mirror of
https://github.com/jketterl/openwebrx.git
synced 2026-04-19 21:35:13 +00:00
implement tab drag & drop
This commit is contained in:
parent
94c4a901a2
commit
1fefc13310
4 changed files with 37 additions and 2 deletions
32
htdocs/lib/settings/ProfileList.js
Normal file
32
htdocs/lib/settings/ProfileList.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
$.fn.profileList = function() {
|
||||
this.each(function () {
|
||||
var $profileList = $(this);
|
||||
var $profiles = $profileList.find('.profile');
|
||||
$profiles.attr('draggable', 'true');
|
||||
$profiles.find('a').attr('draggable', 'false');
|
||||
var $profileEl;
|
||||
var originalIndex;
|
||||
$profileList.on('dragstart', '.profile', function(event){
|
||||
$profileEl = $(event.originalEvent.target);
|
||||
originalIndex = $profileEl.index();
|
||||
event.originalEvent.dataTransfer.effectAllowed = 'move';
|
||||
event.originalEvent.dataTransfer.setData('application/x-profile', $profileEl.data('profile-id'));
|
||||
}).on('dragenter', function(event) {
|
||||
event.preventDefault();
|
||||
var $target = $(event.target).closest('.profile');
|
||||
if ($profileEl.index() < $target.index()) {
|
||||
$profileEl.insertAfter($target);
|
||||
} else {
|
||||
$profileEl.insertBefore($target);
|
||||
}
|
||||
}).on('dragover', function(event) {
|
||||
event.preventDefault();
|
||||
}).on('dragend', function(event) {
|
||||
if (event.originalEvent.dataTransfer.dropEffect === 'none') {
|
||||
// drag was aborted - restore original position
|
||||
$profileEl.remove().insertBefore($profileList.children().eq(originalIndex));
|
||||
}
|
||||
$profileEl = undefined;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -9,4 +9,5 @@ $(function(){
|
|||
$('#scheduler').schedulerInput();
|
||||
$('.exponential-input').exponentialInput();
|
||||
$('.device-log-messages').logMessages();
|
||||
$('.profile-tabs').profileList();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue