corrade-nucleus-nucleons – Diff between revs 25 and 29
?pathlinks?
Rev 25 | Rev 29 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | // Retrieve the top-most window z-index. |
1 | // Retrieve the top-most window z-index. |
|
2 | function getTopWindowIndex() { |
2 | function getTopWindowIndex() { |
|
3 | return Math.max.apply(null, |
3 | return Math.max.apply(null, |
|
4 | $.map($('.draggable'), function(e, n) { |
4 | $.map($('.window-manager-window'), function(e, n) { |
|
5 | if ($(e).css('position') != 'static') |
5 | if ($(e).css('position') != 'static') |
|
6 | return parseInt($(e).css('z-index')) || 1; |
6 | return parseInt($(e).css('z-index')) || 1; |
|
7 | }) |
7 | }) |
|
8 | ); |
8 | ); |
|
9 | } |
9 | } |
|
Line 10... | Line 10... | |||
10 | |
10 | |
|
11 | // Draggable and moveable windows. |
11 | // Draggable and moveable windows. |
|
12 | $(document).ready(() => { |
12 | $(document).ready(() => { |
|
13 | // Move windows to top on click. |
- | ||
14 | $('.draggable').click(function() { |
- | ||
15 | $(this).css('z-index', getTopWindowIndex() + 1); |
- | ||
16 | }); |
- | ||
17 | |
- | ||
18 | // target elements with the "draggable" class |
13 | // Window manager windows. |
|
19 | interact('.draggable') |
14 | interact('.window-manager-window') |
|
20 | .draggable({ |
15 | .draggable({ |
|
21 | // enable inertial throwing |
16 | // enable inertial throwing |
|
22 | inertia: true, |
17 | inertia: true, |
|
23 | // keep the element within the area of it's parent |
18 | // keep the element within the area of it's parent |
|
24 | /*restrict: { |
- | ||
25 | // Let the user move the windows freely. |
19 | restrict: { |
|
26 | restriction: "self", |
20 | restriction: $('#window-manager-desktop').get(0), |
|
27 | endOnly: true//, |
21 | endOnly: true, |
|
28 | //elementRect: { top: 0, left: 0, bottom: 1, right: 1 } |
22 | elementRect: { top: 0, left: 0, bottom: 1, right: 1 } |
|
Line 29... | Line 23... | |||
29 | },*/ |
23 | }, |
|
30 | |
24 | |
|
Line 31... | Line 25... | |||
31 | // enable autoScroll |
25 | // enable autoScroll |
|
Line 39... | Line 33... | |||
39 | // Move windows to top on drag. |
33 | // Move windows to top on drag. |
|
40 | event.target.style.zIndex = getTopWindowIndex() + 1; |
34 | event.target.style.zIndex = getTopWindowIndex() + 1; |
|
41 | event.target.style.opacity = 0.5; |
35 | event.target.style.opacity = 0.5; |
|
42 | } |
36 | } |
|
43 | }) |
37 | }) |
|
44 | .allowFrom('.panel-heading') |
38 | .allowFrom('.panel-heading'); |
|
45 | .ignoreFrom('a, input, button, textarea'); |
- | ||
Line -... | Line 39... | |||
- | 39 | |
||
- | 40 | // Closing windows. |
||
- | 41 | $(document).on('click', '.window-manager-close-button', function(event) { |
||
- | 42 | $('#' + $(this).data('target')).detach(); |
||
- | 43 | }); |
||
- | 44 | |
||
- | 45 | // Windows clicking brings to front. |
||
- | 46 | $(document).on('click', '.window-manager-window', function(event) { |
||
- | 47 | $(this).attr('z-index', getTopWindowIndex() + 1); |
||
- | 48 | }); |
||
46 | |
49 | |
|
47 | function dragMoveListener (event) { |
50 | function dragMoveListener (event) { |
|
48 | var target = event.target, |
51 | var target = event.target, |
|
49 | // keep the dragged position in the data-x/data-y attributes |
52 | // keep the dragged position in the data-x/data-y attributes |
|
50 | x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx, |
53 | x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx, |
|
Line 53... | Line 56... | |||
53 | // translate the element |
56 | // translate the element |
|
54 | target.style.webkitTransform = |
57 | target.style.webkitTransform = |
|
55 | target.style.transform = |
58 | target.style.transform = |
|
56 | 'translate(' + x + 'px, ' + y + 'px)'; |
59 | 'translate(' + x + 'px, ' + y + 'px)'; |
|
Line 57... | Line 60... | |||
57 | |
60 | |
|
58 | // update the posiion attributes |
61 | // update the position attributes |
|
59 | target.setAttribute('data-x', x); |
62 | target.setAttribute('data-x', x); |
|
60 | target.setAttribute('data-y', y); |
63 | target.setAttribute('data-y', y); |
|
Line 61... | Line 64... | |||
61 | } |
64 | } |