/base/000_base/js/wm/wm.js |
@@ -1,7 +1,7 @@ |
// Retrieve the top-most window z-index. |
function getTopWindowIndex() { |
return Math.max.apply(null, |
$.map($('.draggable'), function(e, n) { |
$.map($('.window-manager-window'), function(e, n) { |
if ($(e).css('position') != 'static') |
return parseInt($(e).css('z-index')) || 1; |
}) |
@@ -10,23 +10,17 @@ |
|
// Draggable and moveable windows. |
$(document).ready(() => { |
// Move windows to top on click. |
$('.draggable').click(function() { |
$(this).css('z-index', getTopWindowIndex() + 1); |
}); |
|
// target elements with the "draggable" class |
interact('.draggable') |
// Window manager windows. |
interact('.window-manager-window') |
.draggable({ |
// enable inertial throwing |
inertia: true, |
// keep the element within the area of it's parent |
/*restrict: { |
// Let the user move the windows freely. |
restriction: "self", |
endOnly: true//, |
//elementRect: { top: 0, left: 0, bottom: 1, right: 1 } |
},*/ |
restrict: { |
restriction: $('#window-manager-desktop').get(0), |
endOnly: true, |
elementRect: { top: 0, left: 0, bottom: 1, right: 1 } |
}, |
|
// enable autoScroll |
autoScroll: true, |
@@ -41,9 +35,18 @@ |
event.target.style.opacity = 0.5; |
} |
}) |
.allowFrom('.panel-heading') |
.ignoreFrom('a, input, button, textarea'); |
.allowFrom('.panel-heading'); |
|
// Closing windows. |
$(document).on('click', '.window-manager-close-button', function(event) { |
$('#' + $(this).data('target')).detach(); |
}); |
|
// Windows clicking brings to front. |
$(document).on('click', '.window-manager-window', function(event) { |
$(this).attr('z-index', getTopWindowIndex() + 1); |
}); |
|
function dragMoveListener (event) { |
var target = event.target, |
// keep the dragged position in the data-x/data-y attributes |
@@ -55,7 +58,7 @@ |
target.style.transform = |
'translate(' + x + 'px, ' + y + 'px)'; |
|
// update the posiion attributes |
// update the position attributes |
target.setAttribute('data-x', x); |
target.setAttribute('data-y', y); |
} |