corrade-nucleus-nucleons – Diff between revs 29 and 30

Subversion Repositories:
Rev:
Only display areas with differencesRegard whitespace
Rev 29 Rev 30
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($('.window-manager-window'), 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')) || 2;
7 }) 7 })
8 ); 8 );
9 } 9 }
10   10  
11 // Draggable and moveable windows. 11 // Draggable and moveable windows.
12 $(document).ready(() => { 12 $(document).ready(() => {
13 // Window manager windows. 13 // Window manager windows.
14 interact('.window-manager-window') 14 interact('.window-manager-window')
15 .draggable({ 15 .draggable({
16 // enable inertial throwing 16 // enable inertial throwing
17 inertia: true, 17 inertia: true,
18 // keep the element within the area of it's parent 18 // keep the element within the area of it's parent
19 restrict: { 19 restrict: {
20 restriction: $('#window-manager-desktop').get(0), 20 restriction: $('#window-manager-desktop').get(0),
21 endOnly: true, 21 endOnly: true,
22 elementRect: { top: 0, left: 0, bottom: 1, right: 1 } 22 elementRect: { top: 0, left: 0, bottom: 1, right: 1 }
23 }, 23 },
24 24
25 // enable autoScroll 25 // enable autoScroll
26 autoScroll: true, 26 autoScroll: true,
27 27
28 onmove: dragMoveListener, 28 onmove: dragMoveListener,
29 onend: function (event) { 29 onend: function (event) {
30 event.target.style.opacity = 1; 30 event.target.style.opacity = 1;
31 }, 31 },
32 onstart: function(event) { 32 onstart: function(event) {
33 // Move windows to top on drag. 33 // Move windows to top on drag.
34 event.target.style.zIndex = getTopWindowIndex() + 1; 34 event.target.style.zIndex = getTopWindowIndex() + 1;
35 event.target.style.opacity = 0.5; 35 event.target.style.opacity = 0.5;
36 } 36 }
37 }) 37 })
38 .allowFrom('.panel-heading'); 38 .allowFrom('.panel-heading');
-   39
-   40 // Window manager icons.
-   41 interact('.window-manager-icon')
-   42 .draggable({
-   43 // enable inertial throwing
-   44 inertia: false,
-   45 // keep the element within the area of it's parent
-   46 restrict: {
-   47 restriction: $('#window-manager-desktop').get(0),
-   48 endOnly: true,
-   49 elementRect: { top: 0, left: 0, bottom: 1, right: 1 }
-   50 },
-   51 snap: {
-   52 targets: [
-   53 interact.createSnapGrid({ x: 64, y: 64 })
-   54 ],
-   55 range: Infinity,
-   56 relativePoints: [ { x: 0, y: 0 } ]
-   57 },
-   58 // enable autoScroll
-   59 autoScroll: true,
-   60
-   61 onmove: dragMoveListener,
-   62 onend: function (event) {
-   63 event.target.style.opacity = 1;
-   64 },
-   65 onstart: function(event) {
-   66 event.target.style.opacity = 0.5;
-   67 }
-   68 });
39   69  
40 // Closing windows. 70 // Closing windows.
41 $(document).on('click', '.window-manager-close-button', function(event) { 71 $(document).on('click', '.window-manager-close-button', function(event) {
42 $('#' + $(this).data('target')).detach(); 72 $('#' + $(this).data('target')).detach();
43 }); 73 });
44 74
45 // Windows clicking brings to front. 75 // Windows clicking brings to front.
46 $(document).on('click', '.window-manager-window', function(event) { 76 $(document).on('click', '.window-manager-window', function(event) {
47 $(this).attr('z-index', getTopWindowIndex() + 1); 77 $(this).attr('z-index', getTopWindowIndex() + 1);
48 }); 78 });
49 79
50 function dragMoveListener (event) { 80 function dragMoveListener (event) {
51 var target = event.target, 81 var target = event.target,
52 // keep the dragged position in the data-x/data-y attributes 82 // keep the dragged position in the data-x/data-y attributes
53 x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx, 83 x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx,
54 y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy; 84 y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
55   85  
56 // translate the element 86 // translate the element
57 target.style.webkitTransform = 87 target.style.webkitTransform =
58 target.style.transform = 88 target.style.transform =
59 'translate(' + x + 'px, ' + y + 'px)'; 89 'translate(' + x + 'px, ' + y + 'px)';
60   90  
61 // update the position attributes 91 // update the position attributes
62 target.setAttribute('data-x', x); 92 target.setAttribute('data-x', x);
63 target.setAttribute('data-y', y); 93 target.setAttribute('data-y', y);
64 } 94 }
65   95  
66 // this is used later in the resizing and gesture demos 96 // this is used later in the resizing and gesture demos
67 window.dragMoveListener = dragMoveListener; 97 window.dragMoveListener = dragMoveListener;
68 }); 98 });
69   99  
70
Generated by GNU Enscript 1.6.5.90.
100
Generated by GNU Enscript 1.6.5.90.
71   101  
72   102  
73   103