/base/000_base/js/wm/wm.js |
@@ -1,9 +1,60 @@ |
// Retrieve the top-most window z-index. |
// Load the window manager desktop icons. |
function loadWindowManagerIcons(path) { |
// Search and load all nucleons. |
$.get(path, function(data) { |
var nucleons = wasCSVToArray(data); |
var x = 0, y = 0; |
$.each(nucleons, function(index, value) { |
// Skip files starting with full stop (POSIX). |
if (/^\./.test(value)) return; |
$.get(path + '/' + value, function(doc) { |
var button = $(doc).get(0); |
// Translate the desktop icons so they do not overlap. |
button.style.webkitTransform = |
button.style.transform = |
'translate(' + x + 'px, ' + y + 'px)'; |
|
// Update the position attributes |
button.setAttribute('data-x', x); |
button.setAttribute('data-y', y); |
|
$('#window-manager-desktop').append(button); |
// Translate by the desktop icon size. |
x += 64; |
}); |
}); |
}); |
} |
|
// Open a window manager window. |
function openWindowManagerWindow(nucleon) { |
// If the nucleon already exists, then do not append the content again. |
if($('#' + nucleon).length) |
return; |
|
// Change the nucleon icon to a loading icon. |
$('#' + nucleon + '-window-manager-button-icon').attr('src', '/img/loader.gif'); |
|
// Disable button for successive clicks. |
$('#' + nucleon + '-window-manager-button').prop('disabled', true); |
|
// Load the nucleon. |
$.get('/' + nucleon + '/index.html', function(data) { |
$(data).hide().appendTo('#window-manager-desktop').fadeIn(750); |
}).done(function(data) { |
// Change the nucleon icon back. |
$('#' + nucleon + '-window-manager-button-icon').attr('src', '/' + nucleon + '/img/' + nucleon + '.png'); |
// Enable the button. |
$('#' + nucleon + '-window-manager-button').prop('disabled', false); |
}); |
} |
|
// Retrieve the top-most window manager window z-index. |
function getTopWindowIndex() { |
return Math.max.apply(null, |
$.map($('.window-manager-window'), function(e, n) { |
if ($(e).css('position') != 'static') |
return parseInt($(e).css('z-index')) || 2; |
return parseInt($(e).css('z-index')) || 1; |
}) |
); |
} |
@@ -69,7 +120,10 @@ |
|
// Closing windows. |
$(document).on('click', '.window-manager-close-button', function(event) { |
$('#' + $(this).data('target')).detach(); |
var wm = $('#' + $(this).data('target')); |
wm.fadeOut(750, function() { |
wm.remove(); |
}); |
}); |
|
// Windows clicking brings to front. |