summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorBelen Barros <belen.barros.pena@intel.com>2014-01-27 14:05:54 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-02-17 15:38:52 +0000
commit985017af3dd73c58ff6fa6e6e7cc630e56ba9445 (patch)
tree7b43f8215f27f9df2e2d9c1ae2c603e7d432902a /bitbake/lib
parentb4416e324fa982db305e7bd1a23ce4677d4355aa (diff)
downloadpoky-985017af3dd73c58ff6fa6e6e7cc630e56ba9445.tar.gz
bitbake: toaster: Clean up main.js
Clean up main.js to leave only what is being used in the design prototype. Initialise the Bootstrap tooltips for any anchor tag inside a table heading with the btn-primary class applied. This effectively styles the title attribute of the applied filters to look like all other Toaster tooltips. (Bitbake rev: 71a07268c3a2e969c088ef9f6bcf4c54254b3600) Signed-off-by: Belen Barros <belen.barros.pena@intel.com> Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--[-rwxr-xr-x]bitbake/lib/toaster/toastergui/static/js/main.js476
1 files changed, 32 insertions, 444 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/main.js b/bitbake/lib/toaster/toastergui/static/js/main.js
index 4c236689d4..52e0084095 100755..100644
--- a/bitbake/lib/toaster/toastergui/static/js/main.js
+++ b/bitbake/lib/toaster/toastergui/static/js/main.js
@@ -1,200 +1,4 @@
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() { 1$(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 2
199 /* 3 /*
200 * PrettyPrint plugin. 4 * PrettyPrint plugin.
@@ -203,240 +7,56 @@ $(document).ready(function() {
203 // Init 7 // Init
204 prettyPrint(); 8 prettyPrint();
205 9
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 10 // Prevent invalid links from jumping page scroll
280 $('a[href=#]').click(function() { 11 $('a[href=#]').click(function() {
281 return false; 12 return false;
282 }); 13 });
283 14
284 jQuery('#project-project-files-search-results').each(function() {
285 jQuery('input.' + this.id).val(jQuery(this).text());
286 });
287 15
288 jQuery('.bar.building').each(function() { 16 /* Belen's additions */
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 17
300 jQuery('#project-build-packages').each(function() { 18 // enable popovers in any table cells that contain an anchor with the
301 var link = this; 19 // .btn class applied
302 var size = jQuery('[href=#size]'); 20 $('td > a.btn').popover({html:true, container:'body', placement:'left'});
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 21
312 if (location.href.search('tab') !== -1) { 22 // enable tooltips for applied filters
313 jQuery('[href=#' + location.href.split('tab=')[1] + ']').trigger('click'); 23 $('th a.btn-primary').tooltip({container:'body', html:true, placement:'bottom'});
314 }
315 24
316 jQuery('.tree a').each(function() { 25 // enable help information tooltip
317 var link = jQuery(this); 26 $(".get-help").tooltip({container:'body', html:true, delay:{show:300}});
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 27
334 /*jQuery('#nav').each(function() { 28 // show help bubble only on hover inside tables
335 var links = jQuery(this).find('a'); 29 $(".hover-help").css("visibility","hidden");
336 var split = location.href.split('/'); 30 $("th, td").hover(function () {
337 var file = split[split.length - 1].split('?')[0]; 31 $(this).find(".hover-help").css("visibility","visible");
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 }); 32 });
364 $("tr").mouseleave(function () { 33 $("th, td").mouseleave(function () {
365 $(this).find(".hover-help").hide(); 34 $(this).find(".hover-help").css("visibility","hidden");
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 }); 35 });
395 */
396
397 // Global variables - cringe
398 var visiblePopover;
399 36
400 // enable popovers 37 // show task type and outcome in task details pages
401 $('.depends > a , .brought_in_by > a, .recommends > a, .layer_commit > a').popover({html:true, container:'body', placement: 'left'}); 38 $(".task-info").tooltip({ container: 'body', html: true, delay: {show: 200}, placement: 'right' });
402 39
403 // make sure on hover elements do not disappear while the pointer is inside them 40 // linking directly to tabs
404 // buggy: doesn't work if you hover over the same popover twice in a row 41 $(function(){
42 var hash = window.location.hash;
43 hash && $('ul.nav a[href="' + hash + '"]').tab('show');
405 44
406 /*$('.depends > a , .brought_in_by > a, .recommends > a, .layer_commit').popover({ 45 $('.nav-tabs a').click(function (e) {
407 offset: 10, 46 $(this).tab('show');
408 trigger: 'manual', 47 $('body').scrollTop();
409 animate: false, 48 });
410 html: true, 49 });
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 50
415 }).click(function(e) { 51 /* Make help tooltip and popovers work on click, mutually exclusive and dismiss them when clicking outside their area
416 $(this).popover('show'); 52 from http://fuzzytolerance.info/blog/quick-hack-one-bootstarp-popover-at-a-time/ */
417 });*/ 53
54 // Global variables - cringe
55 var visibleTooltip;
56 var visiblePopover;
418 57
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 58 //only allow 1 popover at a time
439 $('.depends > a , .brought_in_by > a, .recommends > a, .layer_commit > a').on('click', function(e) { 59 $('.depends > a , .brought_in_by > a, .layer_commit > a').on('click', function(e) {
440 // don't fall through 60 // don't fall through
441 e.stopPropagation(); 61 e.stopPropagation();
442 var $this = $(this); 62 var $this = $(this);
@@ -461,37 +81,5 @@ $(document).ready(function() {
461 } 81 }
462 }); 82 });
463 }); 83 });
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 84
497}); 85});