corrade-nucleus-nucleons – Diff between revs 30 and 31
?pathlinks?
Rev 30 | Rev 31 | |||
---|---|---|---|---|
Line -... | Line 1... | |||
- | 1 | // Load the window manager desktop icons. |
||
- | 2 | function loadWindowManagerIcons(path) { |
||
- | 3 | // Search and load all nucleons. |
||
- | 4 | $.get(path, function(data) { |
||
- | 5 | var nucleons = wasCSVToArray(data); |
||
- | 6 | var x = 0, y = 0; |
||
- | 7 | $.each(nucleons, function(index, value) { |
||
- | 8 | // Skip files starting with full stop (POSIX). |
||
- | 9 | if (/^\./.test(value)) return; |
||
- | 10 | $.get(path + '/' + value, function(doc) { |
||
- | 11 | var button = $(doc).get(0); |
||
- | 12 | // Translate the desktop icons so they do not overlap. |
||
- | 13 | button.style.webkitTransform = |
||
- | 14 | button.style.transform = |
||
- | 15 | 'translate(' + x + 'px, ' + y + 'px)'; |
||
- | 16 | |
||
- | 17 | // Update the position attributes |
||
- | 18 | button.setAttribute('data-x', x); |
||
- | 19 | button.setAttribute('data-y', y); |
||
- | 20 | |
||
- | 21 | $('#window-manager-desktop').append(button); |
||
- | 22 | // Translate by the desktop icon size. |
||
- | 23 | x += 64; |
||
- | 24 | }); |
||
- | 25 | }); |
||
- | 26 | }); |
||
- | 27 | } |
||
- | 28 | |
||
- | 29 | // Open a window manager window. |
||
- | 30 | function openWindowManagerWindow(nucleon) { |
||
- | 31 | // If the nucleon already exists, then do not append the content again. |
||
- | 32 | if($('#' + nucleon).length) |
||
- | 33 | return; |
||
- | 34 | |
||
- | 35 | // Change the nucleon icon to a loading icon. |
||
- | 36 | $('#' + nucleon + '-window-manager-button-icon').attr('src', '/img/loader.gif'); |
||
- | 37 | |
||
- | 38 | // Disable button for successive clicks. |
||
- | 39 | $('#' + nucleon + '-window-manager-button').prop('disabled', true); |
||
- | 40 | |
||
- | 41 | // Load the nucleon. |
||
- | 42 | $.get('/' + nucleon + '/index.html', function(data) { |
||
- | 43 | $(data).hide().appendTo('#window-manager-desktop').fadeIn(750); |
||
- | 44 | }).done(function(data) { |
||
- | 45 | // Change the nucleon icon back. |
||
- | 46 | $('#' + nucleon + '-window-manager-button-icon').attr('src', '/' + nucleon + '/img/' + nucleon + '.png'); |
||
- | 47 | // Enable the button. |
||
- | 48 | $('#' + nucleon + '-window-manager-button').prop('disabled', false); |
||
- | 49 | }); |
||
- | 50 | } |
||
- | 51 | |
||
1 | // Retrieve the top-most window z-index. |
52 | // Retrieve the top-most window manager window z-index. |
|
2 | function getTopWindowIndex() { |
53 | function getTopWindowIndex() { |
|
3 | return Math.max.apply(null, |
54 | return Math.max.apply(null, |
|
4 | $.map($('.window-manager-window'), function(e, n) { |
55 | $.map($('.window-manager-window'), function(e, n) { |
|
5 | if ($(e).css('position') != 'static') |
56 | if ($(e).css('position') != 'static') |
|
6 | return parseInt($(e).css('z-index')) || 2; |
57 | return parseInt($(e).css('z-index')) || 1; |
|
7 | }) |
58 | }) |
|
8 | ); |
59 | ); |
|
9 | } |
60 | } |
|
Line 10... | Line 61... | |||
10 | |
61 | |
|
Line 67... | Line 118... | |||
67 | } |
118 | } |
|
68 | }); |
119 | }); |
|
Line 69... | Line 120... | |||
69 | |
120 | |
|
70 | // Closing windows. |
121 | // Closing windows. |
|
71 | $(document).on('click', '.window-manager-close-button', function(event) { |
122 | $(document).on('click', '.window-manager-close-button', function(event) { |
|
- | 123 | var wm = $('#' + $(this).data('target')); |
||
- | 124 | wm.fadeOut(750, function() { |
||
- | 125 | wm.remove(); |
||
72 | $('#' + $(this).data('target')).detach(); |
126 | }); |
|
Line 73... | Line 127... | |||
73 | }); |
127 | }); |
|
74 | |
128 | |
|
75 | // Windows clicking brings to front. |
129 | // Windows clicking brings to front. |