corrade-nucleus-nucleons – Blame information for rev 29

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')
6 return parseInt($(e).css('z-index')) || 1;
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');
25 office 39  
29 office 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 });
49  
25 office 50 function dragMoveListener (event) {
51 var target = event.target,
52 // keep the dragged position in the data-x/data-y attributes
53 x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx,
54 y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
55  
56 // translate the element
57 target.style.webkitTransform =
58 target.style.transform =
59 'translate(' + x + 'px, ' + y + 'px)';
60  
29 office 61 // update the position attributes
25 office 62 target.setAttribute('data-x', x);
63 target.setAttribute('data-y', y);
64 }
65  
66 // this is used later in the resizing and gesture demos
67 window.dragMoveListener = dragMoveListener;
68 });