/base/000_base/js/nucleus/load-nucleons.js |
@@ -0,0 +1,14 @@ |
$(document).ready(function() { |
// Search and load all nucleons. |
$.get('/nucleons', function(data) { |
var nucleons = wasCSVToArray(data); |
$.each(nucleons, function(index, value) { |
// Skip files starting with full stop (POSIX). |
if (/^\./.test(value)) return; |
$.get('/nucleons/' + value, function(doc) { |
var div = $('<div class="col-xs-6 col-md-3">').html(doc); |
$('#nucleons').append(div); |
}); |
}); |
}); |
}); |
/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; |
}); |