diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static/js/layerBtn.js')
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/layerBtn.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/layerBtn.js b/bitbake/lib/toaster/toastergui/static/js/layerBtn.js new file mode 100644 index 0000000000..6a1d4b1606 --- /dev/null +++ b/bitbake/lib/toaster/toastergui/static/js/layerBtn.js | |||
@@ -0,0 +1,63 @@ | |||
1 | "use strict"; | ||
2 | |||
3 | function layerBtnsInit(ctx) { | ||
4 | |||
5 | $(".layerbtn").click(function (){ | ||
6 | var layerObj = $(this).data("layer"); | ||
7 | var add = ($(this).data('directive') === "add"); | ||
8 | var thisBtn = $(this); | ||
9 | |||
10 | libtoaster.addRmLayer(layerObj, add, function (layerDepsList){ | ||
11 | var alertMsg = $("#alert-msg"); | ||
12 | alertMsg.html(libtoaster.makeLayerAddRmAlertMsg(layerObj, layerDepsList, add)); | ||
13 | |||
14 | /* In-cell notification */ | ||
15 | var notification = $('<div id="temp-inline-notify" style="display: none; font-size: 11px; line-height: 1.3;" class="tooltip-inner"></div>'); | ||
16 | thisBtn.parent().append(notification); | ||
17 | |||
18 | if (add){ | ||
19 | if (layerDepsList.length > 0) | ||
20 | notification.text(String(layerDepsList.length + 1) + " layers added"); | ||
21 | else | ||
22 | notification.text("1 layer added"); | ||
23 | |||
24 | var layerBtnsFadeOut = $(); | ||
25 | var layerExistsBtnFadeIn = $(); | ||
26 | |||
27 | layerBtnsFadeOut = layerBtnsFadeOut.add(".layer-add-" + layerObj.id); | ||
28 | layerExistsBtnFadeIn = layerExistsBtnFadeIn.add(".layer-exists-" + layerObj.id); | ||
29 | |||
30 | for (var i in layerDepsList){ | ||
31 | layerBtnsFadeOut = layerBtnsFadeOut.add(".layer-add-" + layerDepsList[i].id); | ||
32 | layerExistsBtnFadeIn = layerExistsBtnFadeIn.add(".layer-exists-" + layerDepsList[i].id); | ||
33 | } | ||
34 | |||
35 | layerBtnsFadeOut.fadeOut().promise().done(function(){ | ||
36 | notification.fadeIn().delay(500).fadeOut(function(){ | ||
37 | /* Fade in the buttons */ | ||
38 | layerExistsBtnFadeIn.fadeIn(); | ||
39 | notification.remove(); | ||
40 | }); | ||
41 | }); | ||
42 | } else { | ||
43 | notification.text("1 layer deleted"); | ||
44 | /* Deleting a layer we only hanlde the one button */ | ||
45 | thisBtn.fadeOut(function(){ | ||
46 | notification.fadeIn().delay(500).fadeOut(function(){ | ||
47 | $(".layer-add-" + layerObj.id).fadeIn(); | ||
48 | notification.remove(); | ||
49 | }); | ||
50 | }); | ||
51 | } | ||
52 | |||
53 | $("#zone1alerts, #zone1alerts *").fadeIn(); | ||
54 | }); | ||
55 | }); | ||
56 | |||
57 | /* Setup the initial state of the buttons */ | ||
58 | |||
59 | for (var i in ctx.projectLayers){ | ||
60 | $(".layer-exists-" + ctx.projectLayers[i]).show(); | ||
61 | $(".layer-add-" + ctx.projectLayers[i]).hide(); | ||
62 | } | ||
63 | } | ||