We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Total Complexity | 4 |
Complexity/F | 1 |
Lines of Code | 48 |
Function Count | 4 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | "use strict"; |
||
2 | |||
3 | // Install drag & drop handlers once the page has finished loading |
||
4 | window.onload = function() { |
||
5 | setupDragDrop(); |
||
6 | }; |
||
7 | |||
8 | /** |
||
9 | * Allows locations to be dragged and dropped to different sectors |
||
10 | * with an AJAX update. |
||
11 | * |
||
12 | * This needs to be called every time the elements in the sector map |
||
13 | * update, to install new handlers on the updated elements. |
||
14 | */ |
||
15 | function setupDragDrop() { |
||
16 | |||
17 | // Make the Location images draggable elements |
||
18 | $(".drag_loc").draggable({ |
||
19 | addClasses: false, |
||
20 | revert: "invalid", |
||
21 | cursor: "move", |
||
22 | }); |
||
23 | |||
24 | // The draggable elements can be dropped into any sector |
||
25 | $(".lm_sector").droppable({ |
||
26 | addClasses: false, |
||
27 | accept: ".drag_loc", |
||
28 | drop: function(event, ui) { |
||
29 | var href = ui.draggable.data("href"); |
||
30 | var data = { |
||
31 | TargetSectorID: $(this).find(".lmsector").text(), |
||
32 | OrigSectorID: ui.draggable.data("sector"), |
||
33 | LocationTypeID: ui.draggable.data("loc"), |
||
34 | }; |
||
35 | ajaxLink(href, {callback: setupDragDrop, params: data}); |
||
36 | }, |
||
37 | }); |
||
38 | |||
39 | } |
||
40 | |||
41 | window.toggleLink = function(elem) { |
||
42 | var href = elem.dataset.href; |
||
43 | var data = { |
||
44 | SectorID: elem.dataset.sector, |
||
45 | Dir: elem.dataset.dir, |
||
46 | }; |
||
47 | ajaxLink(href, {callback: setupDragDrop, params: data}); |
||
48 | } |
||
49 |