corrade-nucleus-nucleons – Blame information for rev 30

Subversion Repositories:
Rev:
Rev Author Line No. Line
25 office 1 // Retrieve the top-most window z-index.
2 function getTopWindowIndex() {
3 return Math.max.apply(null,
29 office 4 $.map($('.window-manager-window'), function(e, n) {
25 office 5 if ($(e).css('position') != 'static')
30 office 6 return parseInt($(e).css('z-index')) || 2;
25 office 7 })
8 );
9 }
10  
11 // Draggable and moveable windows.
12 $(document).ready(() => {
29 office 13 // Window manager windows.
14 interact('.window-manager-window')
25 office 15 .draggable({
16 // enable inertial throwing
17 inertia: true,
18 // keep the element within the area of it's parent
29 office 19 restrict: {
20 restriction: $('#window-manager-desktop').get(0),
21 endOnly: true,
22 elementRect: { top: 0, left: 0, bottom: 1, right: 1 }
23 },
25 office 24  
25 // enable autoScroll
26 autoScroll: true,
27  
28 onmove: dragMoveListener,
29 onend: function (event) {
30 event.target.style.opacity = 1;
31 },
32 onstart: function(event) {
33 // Move windows to top on drag.
34 event.target.style.zIndex = getTopWindowIndex() + 1;
35 event.target.style.opacity = 0.5;
36 }
37 })
29 office 38 .allowFrom('.panel-heading');
30 office 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 });
25 office 69  
29 office 70 // Closing windows.
71 $(document).on('click', '.window-manager-close-button', function(event) {
72 $('#' + $(this).data('target')).detach();
73 });
74  
75 // Windows clicking brings to front.
76 $(document).on('click', '.window-manager-window', function(event) {
77 $(this).attr('z-index', getTopWindowIndex() + 1);
78 });
79  
25 office 80 function dragMoveListener (event) {
81 var target = event.target,
82 // keep the dragged position in the data-x/data-y attributes
83 x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx,
84 y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
85  
86 // translate the element
87 target.style.webkitTransform =
88 target.style.transform =
89 'translate(' + x + 'px, ' + y + 'px)';
90  
29 office 91 // update the position attributes
25 office 92 target.setAttribute('data-x', x);
93 target.setAttribute('data-y', y);
94 }
95  
96 // this is used later in the resizing and gesture demos
97 window.dragMoveListener = dragMoveListener;
98 });