summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/static/js/main.js
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2013-12-11 16:40:05 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-01-10 15:20:25 +0000
commitc2fc6ca2fa68aca17235cac306b6df4b882fe9ff (patch)
treeed53d90f51759a9b56d4439b489452133486f371 /bitbake/lib/toaster/toastergui/static/js/main.js
parent47621ecb24eedd803f17a551230a524193089c9a (diff)
downloadpoky-c2fc6ca2fa68aca17235cac306b6df4b882fe9ff.tar.gz
bitbake: toaster: update static media for Toaster GUI
In the process of making the GUI more usable, we bring in the static assets used during the design phase into the application. Licenses used: Bootstrap 2.3.2 under Apache License 2.0 Font Awesome under SIL OFL 1.1 (GPL compatible) and MIT licence GLYPHICONS Halflings released with Bootstrap, CC BY 3.0 jQuery 2.0.3 under MIT licence prettify.js under Apache Licence 2.0 (Bitbake rev: 0b3d2000c0bcd2bb5a3af5d49a514a90f001a7d2) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static/js/main.js')
-rwxr-xr-xbitbake/lib/toaster/toastergui/static/js/main.js497
1 files changed, 497 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/main.js b/bitbake/lib/toaster/toastergui/static/js/main.js
new file mode 100755
index 0000000000..4c236689d4
--- /dev/null
+++ b/bitbake/lib/toaster/toastergui/static/js/main.js
@@ -0,0 +1,497 @@
1// Create a namespace
2var yocto = yocto || {};
3
4
5// Utilities
6yocto.utils = function() {
7 return {
8 document: jQuery(document),
9 window: jQuery(window),
10 body: jQuery('body')
11 };
12}();
13
14// Links opening file browsers
15yocto.files = function() {
16 var links = jQuery('.file-type');
17 return {
18 init: function() {
19 links.each(this.each);
20 links.click(this.click);
21 },
22 each: function() {
23 var form = jQuery(this.hash);
24 var file = form.find('[type=file]');
25 file.change(function() {
26 form.trigger('submit');
27 });
28 },
29 click: function(e) {
30 var form = jQuery(this.hash);
31 var file = form.find('[type=file]');
32 file.trigger('click');
33 e.preventDefault();
34 }
35 };
36}();
37
38yocto.users = function() {
39 var table = jQuery('#user-list');
40 return {
41 init: function() {
42 this.permissions.init();
43 },
44 permissions: {
45 init: function() {
46 var inputs = table.find('[type=checkbox]');
47 inputs.removeAttr('disabled').removeAttr('checked');
48 inputs.click(this.click);
49 },
50 click: function() {
51 var checkbox = jQuery(this);
52 var siblings = checkbox.parents('tr').find('[name=' + this.name + ']');
53 var chain = jQuery('[class^="' + this.className + '"]');
54
55 if (checkbox.is(':checked')) {
56 siblings.removeAttr('checked');
57 chain.prop('checked', true);
58 chain.prop('disabled', true);
59 checkbox.prop('disabled', false);
60 }
61 else {
62 siblings.removeAttr('disabled').removeAttr('checked');
63 }
64 }
65 }
66 };
67}();
68
69yocto.branches = function() {
70 var modal = jQuery('#branchModal');
71 var triggers = jQuery('a.branchModal');
72 var branches = modal.find('table a');
73 var current = triggers.filter(':first');
74 return {
75 init: function() {
76 triggers.click(this.click);
77 branches.click(this.close);
78 },
79 click: function(e) {
80 current = jQuery(this);
81 modal.modal('show');
82 },
83 close: function() {
84 current.text(this.text);
85 modal.modal('hide');
86 }
87 };
88}();
89
90yocto.dependencies = function() {
91 var images = jQuery('.dependencies-graph');
92 var table = jQuery('.dependencies-table');
93 var input = jQuery('#recommended-show');
94 return {
95 init: function() {
96 input.removeAttr('checked');
97 input.click(this.click);
98 images.hover(this.in, this.out);
99 },
100 click: function() {
101 if (input.is(':checked')) {
102 images.addClass(this.id);
103 table.addClass(this.id);
104 }
105 else {
106 images.removeClass(this.id);
107 table.removeClass(this.id);
108 }
109 },
110 in: function() {
111 table.addClass('hover');
112 },
113 out: function() {
114 table.removeClass('hover');
115 }
116 }
117}();
118
119$('.dropdown-toggle').dropdown();
120$('.popover-toggle').popover();
121$('.alert').alert();
122
123// Initialise all
124yocto.init = function() {
125 yocto.files.init();
126 yocto.users.init();
127 yocto.dependencies.init();
128 yocto.branches.init();
129}();
130
131
132$(document).ready(function() {
133 /*
134 * Table filtering.
135 *
136 */
137 // Enable table filtering using the search input
138 /*$('.filter').on('keyup', function() {
139 var $this = $(this);
140 var target = $this.attr('data-filter');
141 var filter = $this.val().toLowerCase();
142 if (target) {
143 // Retrieve array of td's that this input provides filtering for
144 var candidates = $('td[data-filter=' + target + ']');
145 candidates.each(function() {
146 if (filter) {
147 var innerText = $(this).text().toLowerCase();
148 if (innerText.indexOf(filter) === -1) {
149 $(this).closest('tr').hide();
150 }
151 } else {
152 // Restore hidden rows
153 $(this).closest('tr').show();
154 }
155 });
156 }
157 });*/
158
159 /*
160 * Table sorting
161 *
162 */
163 // Init tablesorter plugin
164 //$('.tablesorter').tablesorter();
165
166 // Append sort icon to each table header
167 //$('.tablesorter th').append('&nbsp;<i class="sort icon-sort"></i>');
168
169 // Update/change sort icon (up or down) when sort happens
170 $('.tablesorter').on('sortEnd', function() {
171 $(this).find('th').each(function() {
172 var $this = $(this);
173 // sort icon for this th
174 var $icon = $(this).find('.sort');
175 // switch icon depending on current sort status
176 if ($this.hasClass('headerSortUp')) {
177 $icon.attr('class', 'sort icon-caret-up');
178 } else if ($this.hasClass('headerSortDown')) {
179 $icon.attr('class', 'sort icon-caret-down');
180 } else {
181 $icon.attr('class', 'sort');
182 }
183 });
184 });
185
186 /*
187 * Collapse plugin.
188 *
189 */
190 $('.collapse').on('hide', function() {
191 $(this).siblings('[class="icon-caret-down"]').attr('class', 'icon-caret-right');
192 $(this).parent().find('[class="icon-caret-down"]').attr('class', 'icon-caret-right');
193 });
194 $('.collapse').on('show', function() {
195 $(this).siblings('[class="icon-caret-right"]').attr('class', 'icon-caret-down');
196 $(this).parent().find('[class="icon-caret-right"]').attr('class', 'icon-caret-down');
197 });
198
199 /*
200 * PrettyPrint plugin.
201 *
202 */
203 // Init
204 prettyPrint();
205
206 /*
207 * Misc
208 *
209 */
210 // Prevent clicking on muted (disabled) link
211 /* $('a.muted, div.muted').click(function() {
212 return false;
213
214 // Show tooltip for disabled links
215 }).tooltip({
216 title: 'Link is not functional in this demo.',
217 delay: {
218 show: 400,
219 hide: 0
220 }
221 });*/
222
223 /*$('table').tooltip({
224 title: 'Sorting disabled',
225 delay: {
226 show: 400,
227 hide: 0
228 }
229 });*/
230
231 $('.info').tooltip();
232
233 // Box functions on project-build page
234 $('.box-close').click(function() {
235 $(this).closest('.box').hide(100);
236 });
237
238 $('[name=highlight-row]').click(function() {
239 var parent = jQuery(this).parents('tr:first');
240 if (this.type == 'radio') {
241 parent.siblings().removeClass('selected');
242 }
243 if (this.checked) {
244 parent.addClass('selected');
245 }
246 else {
247 parent.removeClass('selected');
248 }
249 });
250
251 /*$('a.error, a.warning').each(function() {
252 this.href = 'all-tasks.html?filter=' + this.className;
253 });
254
255 $('.icon-minus-sign.warning').each(function() {
256 jQuery(this).next('a').attr('href', 'all-tasks.html?filter=warning');
257 });
258
259 $('.icon-minus-sign.error').each(function() {
260 jQuery(this).next('a').attr('href', 'all-tasks.html?filter=error');
261 });
262
263 $('#failedbuild').each(function() {
264 this.href = '#';
265 });
266
267 if (location.href.search('filter=') > -1) {
268 var filter = location.href.split('filter=')[1];
269 var cells = jQuery('.' + filter);
270 //jQuery('tr').hide();
271 $("tbody > tr").hide();
272 cells.each(function() {
273 if($(this).is('a')) {
274 jQuery(this).parents('tr').show();
275 }
276 });
277 }*/
278
279 // Prevent invalid links from jumping page scroll
280 $('a[href=#]').click(function() {
281 return false;
282 });
283
284 jQuery('#project-project-files-search-results').each(function() {
285 jQuery('input.' + this.id).val(jQuery(this).text());
286 });
287
288 jQuery('.bar.building').each(function() {
289 var bar = jQuery(this);
290 bar.animate({
291 width: '100%'
292 }, {
293 duration: parseInt(bar.attr('data-time')),
294 complete: function() {
295 location.href = bar.attr('data-url');
296 }
297 });
298 });
299
300 jQuery('#project-build-packages').each(function() {
301 var link = this;
302 var size = jQuery('[href=#size]');
303 var dependencies = jQuery('[href=#dependencies]');
304 size.click(function() {
305 link.href = 'project-build-packages.html';
306 });
307 dependencies.click(function() {
308 link.href = 'project-build-packages-dependencies.html';
309 });
310 });
311
312 if (location.href.search('tab') !== -1) {
313 jQuery('[href=#' + location.href.split('tab=')[1] + ']').trigger('click');
314 }
315
316 jQuery('.tree a').each(function() {
317 var link = jQuery(this);
318 var parent = link.parents('li:first');
319 var child = parent.find('ul');
320 var prev = link.prev('i:first');
321 link.click(function() {
322 if (prev.attr('class') == 'icon-caret-down') {
323 child.slideUp('fast');
324 prev.attr('class', 'icon-caret-right');
325 }
326 else {
327 child.slideDown('fast');
328 prev.attr('class', 'icon-caret-down');
329 }
330 return false;
331 });
332 });
333
334 /*jQuery('#nav').each(function() {
335 var links = jQuery(this).find('a');
336 var split = location.href.split('/');
337 var file = split[split.length - 1].split('?')[0];
338 if (file == 'project-build-packages-busybox.html') {
339 file = 'project-build-packages.html';
340 }
341 else if (file == 'project-build-packages-dependencies.html') {
342 file = 'project-build-packages.html';
343 }
344 links.filter('[href="' + file + '"]').parent().addClass('active');
345 });*/
346
347 //Belen's additions
348
349 //make help tooltip and popovers work on click, mutually exclusive and dismiss them when clicking outside their area
350 //from http://fuzzytolerance.info/blog/quick-hack-one-bootstarp-popover-at-a-time/
351 //one problem: clicking inside the tooltip or popover should not dismiss it, but it currently does
352
353 // Global variables - cringe
354 var visibleTooltip;
355
356 //show help information
357 $(".get-help").tooltip({ container: 'body', html: true, delay: {show: 300} /* trigger: 'hover'*/});
358
359 //show help for task outcome on hover
360 $(".hover-help").hide();
361 $("tr").hover(function () {
362 $(this).find(".hover-help").show();
363 });
364 $("tr").mouseleave(function () {
365 $(this).find(".hover-help").hide();
366 });
367
368 /*
369 //only allow one tooltip at a time
370 $(".get-help").on('click', function(e) {
371 // don't fall through
372 e.stopPropagation();
373 var $this = $(this);
374 // check if the one clicked is now shown
375 if ($this.data('tooltip').tip().hasClass('in')) {
376 // if another was showing, hide it
377 visibleTooltip && visibleTooltip.tooltip('hide');
378 // then store the current tooltip
379 visibleTooltip = $this;
380 } else {
381 // if it was hidden, then nothing must be showing
382 visibleTooltip = '';
383 }
384 // dismiss tooltips when you click outside them
385 $('body').on("click", function (e) {
386 var $target = $(e.target),
387 inTooltip = $(e.target).closest('.popover').length > 0
388 //hide only if clicked on button or inside popover
389 if (!inTooltip) {
390 visibleTooltip.tooltip('hide');
391 visibleTooltip = '';
392 }
393 });
394 });
395 */
396
397 // Global variables - cringe
398 var visiblePopover;
399
400 // enable popovers
401 $('.depends > a , .brought_in_by > a, .recommends > a, .layer_commit > a').popover({html:true, container:'body', placement: 'left'});
402
403 // make sure on hover elements do not disappear while the pointer is inside them
404 // buggy: doesn't work if you hover over the same popover twice in a row
405
406 /*$('.depends > a , .brought_in_by > a, .recommends > a, .layer_commit').popover({
407 offset: 10,
408 trigger: 'manual',
409 animate: false,
410 html: true,
411 placement: 'left',
412 container: 'body',
413 template: '<div class="popover" onmouseover="$(this).mouseleave(function() {$(this).hide(); });"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
414
415 }).click(function(e) {
416 $(this).popover('show');
417 });*/
418
419 /*
420 // only allow 1 tooltip at a time
421 $('.get-help').on('click', function(e) {
422 // don't fall through
423 e.stopPropagation();
424 var $this = $(this);
425 // check if the one clicked is now shown
426 if ($this.data('tooltip').tip().hasClass('in')) {
427 // if another was showing, hide it
428 visibleTooltip && visibleTooltip.tooltip('hide');
429 // then store the current popover
430 visibleTooltip = $this;
431 } else {
432 // if it was hidden, then nothing must be showing
433 visibleToolitp = '';
434 }
435 });
436 */
437
438 //only allow 1 popover at a time
439 $('.depends > a , .brought_in_by > a, .recommends > a, .layer_commit > a').on('click', function(e) {
440 // don't fall through
441 e.stopPropagation();
442 var $this = $(this);
443 // check if the one hovered over is now shown
444 if ($this.data('popover').tip().hasClass('in')) {
445 // if another was showing, hide it
446 visiblePopover && visiblePopover.popover('hide');
447 // then store the current popover
448 visiblePopover = $this;
449 } else {
450 // if it was hidden, then nothing must be showing
451 visiblePopover = '';
452 }
453 // dismiss popovers when you click outside them
454 $('body').on("click", function (e) {
455 var $target = $(e.target),
456 inPopover = $(e.target).closest('.popover').length > 0
457 //hide only if clicked on button or inside popover
458 if (!inPopover) {
459 visiblePopover.popover('hide');
460 visiblePopover = '';
461 }
462 });
463 });
464
465
466 /*
467 // hide all tooltips if any non-tooltip part of the body is clicked
468 // this does not work properly: clicking the tooltip will also dismiss the tootlip
469 $("body").on('click', function () {
470 $(".get-help").tooltip('hide');
471 visibleTootlip = '';
472 });*/
473
474
475
476 // hide all popovers if any non-popover part of the body is clicked
477 // this does not work properly: clicking the popover will also dismiss the popover
478 /*$("body").on('click', function () {
479 $('.depends > a , .brought_in_by > a, .recommends > a, .layer_commit > a').popover('hide');
480 visiblePopover = '';
481 });*/
482
483 //linking directly to tabs
484 $(function(){
485 var hash = window.location.hash;
486 hash && $('ul.nav a[href="' + hash + '"]').tab('show');
487
488 $('.nav-tabs a').click(function (e) {
489 $(this).tab('show');
490 //var scrollmem = $('body').scrollTop();
491 //window.location.hash = this.hash;
492 //$('html,body').scrollTop(scrollmem);
493 });
494 });
495
496
497});