corrade-nucleus-nucleons

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 24  →  ?path2? @ 25
/base/000_base/js/wm/wm.js
@@ -0,0 +1,65 @@
// Retrieve the top-most window z-index.
function getTopWindowIndex() {
return Math.max.apply(null,
$.map($('.draggable'), function(e, n) {
if ($(e).css('position') != 'static')
return parseInt($(e).css('z-index')) || 1;
})
);
}
 
// 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')
.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 }
},*/
// enable autoScroll
autoScroll: true,
onmove: dragMoveListener,
onend: function (event) {
event.target.style.opacity = 1;
},
onstart: function(event) {
// Move windows to top on drag.
event.target.style.zIndex = getTopWindowIndex() + 1;
event.target.style.opacity = 0.5;
}
})
.allowFrom('.panel-heading')
.ignoreFrom('a, input, button, textarea');
 
function dragMoveListener (event) {
var target = event.target,
// keep the dragged position in the data-x/data-y attributes
x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx,
y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
 
// translate the element
target.style.webkitTransform =
target.style.transform =
'translate(' + x + 'px, ' + y + 'px)';
 
// update the posiion attributes
target.setAttribute('data-x', x);
target.setAttribute('data-y', y);
}
 
// this is used later in the resizing and gesture demos
window.dragMoveListener = dragMoveListener;
});