diff options
author | Michael Wood <michael.g.wood@intel.com> | 2015-11-13 13:48:37 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-11-16 11:55:07 +0000 |
commit | 4677d8b4fb9ab00970ccc6c07d4e75a103dce3f5 (patch) | |
tree | c15efa307a141d84b43cdbe32151f3c8a7887bca /bitbake/lib/toaster/toastergui | |
parent | 55f44943d7374886634a0b385df79935333620a8 (diff) | |
download | poky-4677d8b4fb9ab00970ccc6c07d4e75a103dce3f5.tar.gz |
bitbake: toaster: Remove the new-build-input button widget
The button required a lot of state maintenance to make sure it
showed up when the project was configured properly, showed correctly
according to the projects known to Toaster, displayed correctly
according to the mode Toaster was in, and was able to be
used to change the current project.
(Bitbake rev: b644514a96f3947ad3f307a26301c064c8ae18f8)
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui')
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/projecttopbar.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js b/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js new file mode 100644 index 0000000000..b6ad380c19 --- /dev/null +++ b/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js | |||
@@ -0,0 +1,81 @@ | |||
1 | 'use strict'; | ||
2 | |||
3 | function projectTopBarInit(ctx) { | ||
4 | |||
5 | var projectNameForm = $("#project-name-change-form"); | ||
6 | var projectNameContainer = $("#project-name-container"); | ||
7 | var projectName = $("#project-name"); | ||
8 | var projectNameFormToggle = $("#project-change-form-toggle"); | ||
9 | var projectNameChangeCancel = $("#project-name-change-cancel"); | ||
10 | var newBuildTargetInput = $("#build-input"); | ||
11 | var newBuildTargetBuildBtn = $("#build-button"); | ||
12 | var selectedTarget; | ||
13 | |||
14 | /* Project name change functionality */ | ||
15 | projectNameFormToggle.click(function(e){ | ||
16 | e.preventDefault(); | ||
17 | projectNameContainer.hide(); | ||
18 | projectNameForm.fadeIn(); | ||
19 | }); | ||
20 | |||
21 | projectNameChangeCancel.click(function(e){ | ||
22 | e.preventDefault(); | ||
23 | projectNameForm.hide(); | ||
24 | projectNameContainer.fadeIn(); | ||
25 | }); | ||
26 | |||
27 | $("#project-name-change-btn").click(function(){ | ||
28 | var newProjectName = $("#project-name-change-input").val(); | ||
29 | |||
30 | libtoaster.editCurrentProject({ projectName: newProjectName }, function (){ | ||
31 | projectName.html(newProjectName); | ||
32 | libtoaster.ctx.projectName = newProjectName; | ||
33 | projectNameChangeCancel.click(); | ||
34 | }); | ||
35 | }); | ||
36 | |||
37 | /* Nav bar activate state switcher */ | ||
38 | $("#project-topbar .nav li a").each(function(){ | ||
39 | if (window.location.pathname === $(this).attr('href')) | ||
40 | $(this).parent().addClass('active'); | ||
41 | else | ||
42 | $(this).parent().removeClass('active'); | ||
43 | }); | ||
44 | |||
45 | /* Recipe build input functionality */ | ||
46 | if (ctx.numProjectLayers > 0 && ctx.machine){ | ||
47 | newBuildTargetInput.removeAttr("disabled"); | ||
48 | } | ||
49 | |||
50 | libtoaster.makeTypeahead(newBuildTargetInput, | ||
51 | libtoaster.ctx.recipesTypeAheadUrl, {}, function (item) { | ||
52 | selectedTarget = item; | ||
53 | newBuildTargetBuildBtn.removeAttr("disabled"); | ||
54 | }); | ||
55 | |||
56 | newBuildTargetInput.on('input', function () { | ||
57 | if ($(this).val().length === 0) { | ||
58 | newBuildTargetBuildBtn.attr("disabled", "disabled"); | ||
59 | } else { | ||
60 | newBuildTargetBuildBtn.removeAttr("disabled"); | ||
61 | } | ||
62 | }); | ||
63 | |||
64 | newBuildTargetBuildBtn.click(function (e) { | ||
65 | e.preventDefault(); | ||
66 | if (!newBuildTargetInput.val()) { | ||
67 | return; | ||
68 | } | ||
69 | /* We use the value of the input field so as to maintain any command also | ||
70 | * added e.g. core-image-minimal:clean and because we can build targets | ||
71 | * that toaster doesn't yet know about | ||
72 | */ | ||
73 | selectedTarget = { name: newBuildTargetInput.val() }; | ||
74 | |||
75 | /* Fire off the build */ | ||
76 | libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl, | ||
77 | null, selectedTarget.name, function(){ | ||
78 | window.location.replace(libtoaster.ctx.projectBuildsUrl); | ||
79 | }, null); | ||
80 | }); | ||
81 | } | ||