was.wm.js – Diff between revs 8 and 9
?pathlinks?
Rev 8 | Rev 9 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | class wasWM { |
1 | class wasWM { |
|
2 | constructor(path) { |
- | ||
3 | // Window manager windows. |
- | ||
4 | interact('.window-manager-window') |
- | ||
5 | .draggable({ |
- | ||
6 | // enable inertial throwing |
- | ||
7 | inertia: true, |
- | ||
8 | // keep the element within the area of it's parent |
- | ||
9 | restrict: { |
- | ||
10 | restriction: $('#window-manager-desktop').get(0), |
- | ||
11 | endOnly: true, |
- | ||
12 | elementRect: { top: 0, left: 0, bottom: 1, right: 1 } |
- | ||
13 | }, |
- | ||
14 | |
- | ||
15 | // enable autoScroll |
- | ||
16 | autoScroll: true, |
- | ||
17 | |
- | ||
18 | onmove: wasWM.dragMoveListener, |
- | ||
19 | onend: function (event) { |
- | ||
20 | event.target.style.opacity = 1; |
- | ||
21 | }, |
- | ||
22 | onstart: function(event) { |
- | ||
23 | // Move windows to top on drag. |
- | ||
24 | event.target.style.zIndex = wasWM.getTopWindowIndex() + 1; |
- | ||
25 | event.target.style.opacity = 0.5; |
- | ||
26 | } |
- | ||
27 | }) |
- | ||
28 | .allowFrom('.panel-heading'); |
- | ||
29 | |
- | ||
30 | // Window manager icons. |
- | ||
31 | interact('.window-manager-icon') |
- | ||
32 | .draggable({ |
- | ||
33 | // enable inertial throwing |
- | ||
34 | inertia: false, |
- | ||
35 | // keep the element within the area of it's parent |
- | ||
36 | restrict: { |
- | ||
37 | restriction: $('#window-manager-desktop').get(0), |
- | ||
38 | endOnly: true, |
- | ||
39 | elementRect: { top: 0, left: 0, bottom: 1, right: 1 } |
- | ||
40 | }, |
- | ||
41 | snap: { |
- | ||
42 | targets: [ |
- | ||
43 | //createSnapGrid({ x: 64, y: 64 }) |
- | ||
44 | ], |
- | ||
45 | range: Infinity, |
- | ||
46 | relativePoints: [ { x: 0, y: 0 } ] |
- | ||
47 | }, |
- | ||
48 | // enable autoScroll |
- | ||
49 | autoScroll: true, |
- | ||
50 | |
- | ||
51 | onmove: wasWM.dragMoveListener, |
- | ||
52 | onend: function (event) { |
- | ||
53 | event.target.style.opacity = 1; |
- | ||
54 | }, |
- | ||
55 | onstart: function(event) { |
- | ||
56 | event.target.style.opacity = 0.5; |
- | ||
57 | } |
- | ||
58 | }); |
- | ||
59 | |
- | ||
60 | // Closing windows. |
- | ||
61 | $(document).on('click', '.window-manager-close-button', function(event) { |
- | ||
62 | var wm = $('#' + $(this).data('target')); |
- | ||
63 | wm.fadeOut(750, function() { |
- | ||
64 | wm.remove(); |
- | ||
65 | }); |
- | ||
66 | }); |
- | ||
67 | |
- | ||
68 | // Windows clicking brings to front. |
- | ||
69 | $(document).on('click', '.window-manager-window', function(event) { |
- | ||
70 | $(event.target) |
- | ||
71 | .closest('.window-manager-window') |
- | ||
72 | .css('z-index', wasWM.getTopWindowIndex() + 1); |
- | ||
73 | }); |
- | ||
74 | |
- | ||
75 | // this is used later in the resizing and gesture demos |
- | ||
76 | window.dragMoveListener = wasWM.dragMoveListener; |
- | ||
77 | |
- | ||
78 | // Load the window manager icons. |
- | ||
79 | return wasWM.loadWindowManagerIcons(path); |
- | ||
80 | } |
- | ||
81 | |
- | ||
82 | // Load the window manager desktop icons. |
2 | // Load the window manager desktop icons. |
|
83 | static loadWindowManagerIcons(path) { |
3 | loadWindowManagerIcons(path) { |
|
84 | // Reset the current icon store. |
4 | // Reset the current icon store. |
|
- | 5 | var wasWM = this; |
||
85 | wasWM.icons = []; |
6 | wasWM.icons = []; |
|
86 | // Search and load all nucleons. |
7 | // Search and load all nucleons. |
|
87 | $.get(path, function(nucleons) { |
8 | $.get(path, function(nucleons) { |
|
88 | var ix = 0, iy = 0; |
9 | var ix = 0, iy = 0; |
|
89 | var states = {}; |
10 | var states = {}; |
|
Line 273... | Line 194... | |||
273 | }; |
194 | }; |
|
Line 274... | Line 195... | |||
274 | |
195 | |
|
275 | Cookies.set('window-manager-icons', states, { path: '' }); |
196 | Cookies.set('window-manager-icons', states, { path: '' }); |
|
276 | } |
197 | } |
|
- | 198 | } |
||
- | 199 | |
||
- | 200 | constructor(path) { |
||
- | 201 | this.icons = []; |
||
- | 202 | // Window manager windows. |
||
- | 203 | interact('.window-manager-window') |
||
- | 204 | .draggable({ |
||
- | 205 | // enable inertial throwing |
||
- | 206 | inertia: true, |
||
- | 207 | // keep the element within the area of it's parent |
||
- | 208 | restrict: { |
||
- | 209 | restriction: $('#window-manager-desktop').get(0), |
||
- | 210 | endOnly: true, |
||
- | 211 | elementRect: { top: 0, left: 0, bottom: 1, right: 1 } |
||
- | 212 | }, |
||
- | 213 | |
||
- | 214 | // enable autoScroll |
||
- | 215 | autoScroll: true, |
||
- | 216 | |
||
- | 217 | onmove: wasWM.dragMoveListener, |
||
- | 218 | onend: function (event) { |
||
- | 219 | event.target.style.opacity = 1; |
||
- | 220 | }, |
||
- | 221 | onstart: function(event) { |
||
- | 222 | // Move windows to top on drag. |
||
- | 223 | event.target.style.zIndex = wasWM.getTopWindowIndex() + 1; |
||
- | 224 | event.target.style.opacity = 0.5; |
||
- | 225 | } |
||
- | 226 | }) |
||
- | 227 | .allowFrom('.panel-heading'); |
||
- | 228 | |
||
- | 229 | // Window manager icons. |
||
- | 230 | interact('.window-manager-icon') |
||
- | 231 | .draggable({ |
||
- | 232 | // enable inertial throwing |
||
- | 233 | inertia: false, |
||
- | 234 | // keep the element within the area of it's parent |
||
- | 235 | restrict: { |
||
- | 236 | restriction: $('#window-manager-desktop').get(0), |
||
- | 237 | endOnly: true, |
||
- | 238 | elementRect: { top: 0, left: 0, bottom: 1, right: 1 } |
||
- | 239 | }, |
||
- | 240 | snap: { |
||
- | 241 | targets: [ |
||
- | 242 | //createSnapGrid({ x: 64, y: 64 }) |
||
- | 243 | ], |
||
- | 244 | range: Infinity, |
||
- | 245 | relativePoints: [ { x: 0, y: 0 } ] |
||
- | 246 | }, |
||
- | 247 | // enable autoScroll |
||
- | 248 | autoScroll: true, |
||
- | 249 | |
||
- | 250 | onmove: wasWM.dragMoveListener, |
||
- | 251 | onend: function (event) { |
||
- | 252 | event.target.style.opacity = 1; |
||
- | 253 | }, |
||
- | 254 | onstart: function(event) { |
||
- | 255 | event.target.style.opacity = 0.5; |
||
- | 256 | } |
||
- | 257 | }); |
||
- | 258 | |
||
- | 259 | // Closing windows. |
||
- | 260 | $(document).on('click', '.window-manager-close-button', function(event) { |
||
- | 261 | var wm = $('#' + $(this).data('target')); |
||
- | 262 | wm.fadeOut(750, function() { |
||
- | 263 | wm.remove(); |
||
- | 264 | }); |
||
- | 265 | }); |
||
- | 266 | |
||
- | 267 | // Windows clicking brings to front. |
||
- | 268 | $(document).on('click', '.window-manager-window', function(event) { |
||
- | 269 | $(event.target) |
||
- | 270 | .closest('.window-manager-window') |
||
- | 271 | .css('z-index', wasWM.getTopWindowIndex() + 1); |
||
- | 272 | }); |
||
- | 273 | |
||
- | 274 | // this is used later in the resizing and gesture demos |
||
- | 275 | window.dragMoveListener = wasWM.dragMoveListener; |
||
- | 276 | |
||
- | 277 | // Load the window manager icons. |
||
- | 278 | this.loadWindowManagerIcons(path); |
||
277 | } |
279 | } |
|
Line 278... | Line -... | |||
278 | } |
- | ||
279 | |
280 | } |
|
- | 281 | |