Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id ECCC6E00473 for ; Mon, 27 Jan 2014 06:16:10 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 27 Jan 2014 06:12:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,729,1384329600"; d="scan'208";a="445200360" Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by orsmga001.jf.intel.com with ESMTP; 27 Jan 2014 06:16:07 -0800 Received: from irsmsx106.ger.corp.intel.com ([169.254.8.96]) by IRSMSX102.ger.corp.intel.com ([169.254.2.210]) with mapi id 14.03.0123.003; Mon, 27 Jan 2014 14:16:05 +0000 From: "Barros Pena, Belen" To: "toaster@yoctoproject.org" Thread-Topic: [PATCH] bitbake: toaster: Clean up main.js Thread-Index: AQHPG2pQEv/SCEpKQUWkOeSqXNcadw== Date: Mon, 27 Jan 2014 14:16:05 +0000 Message-ID: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/14.3.9.131030 x-originating-ip: [10.237.224.31] MIME-Version: 1.0 Subject: [PATCH] bitbake: toaster: Clean up main.js X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jan 2014 14:16:19 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-ID: <45FCFD93384694429E8BE39D9569F900@intel.com> Content-Transfer-Encoding: quoted-printable Clean up main.js to leave only what is being used in the design prototype. Signed-off-by: Belen Barros --- bitbake/lib/toaster/toastergui/static/js/main.js | 485 ++-------------------- 1 file changed, 35 insertions(+), 450 deletions(-) mode change 100755 =3D> 100644 bitbake/lib/toaster/toastergui/static/js/main.js diff --git a/bitbake/lib/toaster/toastergui/static/js/main.js b/bitbake/lib/toaster/toastergui/static/js/main.js old mode 100755 new mode 100644 index 4c23668..10ac92d --- a/bitbake/lib/toaster/toastergui/static/js/main.js +++ b/bitbake/lib/toaster/toastergui/static/js/main.js @@ -1,200 +1,4 @@ -// Create a namespace -var yocto =3D yocto || {}; - - -// Utilities -yocto.utils =3D function() { - return { - document: jQuery(document), - window: jQuery(window), - body: jQuery('body') - }; -}(); - -// Links opening file browsers -yocto.files =3D function() { - var links =3D jQuery('.file-type'); - return { - init: function() { - links.each(this.each); - links.click(this.click); - }, - each: function() { - var form =3D jQuery(this.hash); - var file =3D form.find('[type=3Dfile]'); - file.change(function() { - form.trigger('submit'); - }); - }, - click: function(e) { - var form =3D jQuery(this.hash); - var file =3D form.find('[type=3Dfile]'); - file.trigger('click'); - e.preventDefault(); - } - }; -}(); - -yocto.users =3D function() { - var table =3D jQuery('#user-list'); - return { - init: function() { - this.permissions.init(); - }, - permissions: { - init: function() { - var inputs =3D table.find('[type=3Dcheckbox]'); - inputs.removeAttr('disabled').removeAttr('checked'); - inputs.click(this.click); - }, - click: function() { - var checkbox =3D jQuery(this); - var siblings =3D checkbox.parents('tr').find('[name=3D' + this.name + ']'); - var chain =3D jQuery('[class^=3D"' + this.className + '"]'= ); - - if (checkbox.is(':checked')) { - siblings.removeAttr('checked'); - chain.prop('checked', true); - chain.prop('disabled', true); - checkbox.prop('disabled', false); - } - else { - siblings.removeAttr('disabled').removeAttr('checked'); - } - } - } - }; -}(); - -yocto.branches =3D function() { - var modal =3D jQuery('#branchModal'); - var triggers =3D jQuery('a.branchModal'); - var branches =3D modal.find('table a'); - var current =3D triggers.filter(':first'); - return { - init: function() { - triggers.click(this.click); - branches.click(this.close); - }, - click: function(e) { - current =3D jQuery(this); - modal.modal('show'); - }, - close: function() { - current.text(this.text); - modal.modal('hide'); - } - }; -}(); - -yocto.dependencies =3D function() { - var images =3D jQuery('.dependencies-graph'); - var table =3D jQuery('.dependencies-table'); - var input =3D jQuery('#recommended-show'); - return { - init: function() { - input.removeAttr('checked'); - input.click(this.click); - images.hover(this.in, this.out); - }, - click: function() { - if (input.is(':checked')) { - images.addClass(this.id); - table.addClass(this.id); - } - else { - images.removeClass(this.id); - table.removeClass(this.id); - } - }, - in: function() { - table.addClass('hover'); - }, - out: function() { - table.removeClass('hover'); - } - } -}(); - -$('.dropdown-toggle').dropdown(); -$('.popover-toggle').popover(); -$('.alert').alert(); - -// Initialise all -yocto.init =3D function() { - yocto.files.init(); - yocto.users.init(); - yocto.dependencies.init(); - yocto.branches.init(); -}(); - - $(document).ready(function() { - /* - * Table filtering. - * - */ - // Enable table filtering using the search input - /*$('.filter').on('keyup', function() { - var $this =3D $(this); - var target =3D $this.attr('data-filter'); - var filter =3D $this.val().toLowerCase(); - if (target) { - // Retrieve array of td's that this input provides filtering for - var candidates =3D $('td[data-filter=3D' + target + ']'); - candidates.each(function() { - if (filter) { - var innerText =3D $(this).text().toLowerCase(); - if (innerText.indexOf(filter) =3D=3D=3D -1) { - $(this).closest('tr').hide(); - } - } else { - // Restore hidden rows - $(this).closest('tr').show(); - } - }); - } - });*/ - - /* - * Table sorting - * - */ - // Init tablesorter plugin - //$('.tablesorter').tablesorter(); - - // Append sort icon to each table header - //$('.tablesorter th').append(' '= ); - - // Update/change sort icon (up or down) when sort happens - $('.tablesorter').on('sortEnd', function() { - $(this).find('th').each(function() { - var $this =3D $(this); - // sort icon for this th - var $icon =3D $(this).find('.sort'); - // switch icon depending on current sort status - if ($this.hasClass('headerSortUp')) { - $icon.attr('class', 'sort icon-caret-up'); - } else if ($this.hasClass('headerSortDown')) { - $icon.attr('class', 'sort icon-caret-down'); - } else { - $icon.attr('class', 'sort'); - } - }); - }); - - /* - * Collapse plugin. - * - */ - $('.collapse').on('hide', function() { - $(this).siblings('[class=3D"icon-caret-down"]').attr('class', 'icon-caret-right'); - $(this).parent().find('[class=3D"icon-caret-down"]').attr('class', 'icon-caret-right'); - }); - $('.collapse').on('show', function() { - $(this).siblings('[class=3D"icon-caret-right"]').attr('class', 'icon-caret-down'); - $(this).parent().find('[class=3D"icon-caret-right"]').attr('class'= , 'icon-caret-down'); - }); =20 /* * PrettyPrint plugin. @@ -202,241 +6,54 @@ $(document).ready(function() { */ // Init prettyPrint(); - - /* - * Misc - * - */ - // Prevent clicking on muted (disabled) link - /* $('a.muted, div.muted').click(function() { - return false; - - // Show tooltip for disabled links - }).tooltip({ - title: 'Link is not functional in this demo.', - delay: { - show: 400, - hide: 0 - } - });*/ - - /*$('table').tooltip({ - title: 'Sorting disabled', - delay: { - show: 400, - hide: 0 - } - });*/ - - $('.info').tooltip(); - - // Box functions on project-build page - $('.box-close').click(function() { - $(this).closest('.box').hide(100); - }); - - $('[name=3Dhighlight-row]').click(function() { - var parent =3D jQuery(this).parents('tr:first'); - if (this.type =3D=3D 'radio') { - parent.siblings().removeClass('selected'); - } - if (this.checked) { - parent.addClass('selected'); - } - else { - parent.removeClass('selected'); - } - }); - - /*$('a.error, a.warning').each(function() { - this.href =3D 'all-tasks.html?filter=3D' + this.className; - }); - - $('.icon-minus-sign.warning').each(function() { - jQuery(this).next('a').attr('href', 'all-tasks.html?filter=3Dwarning'); - }); - - $('.icon-minus-sign.error').each(function() { - jQuery(this).next('a').attr('href', 'all-tasks.html?filter=3Derror'); - }); =20 - $('#failedbuild').each(function() { - this.href =3D '#'; - }); - - if (location.href.search('filter=3D') > -1) { - var filter =3D location.href.split('filter=3D')[1]; - var cells =3D jQuery('.' + filter); - //jQuery('tr').hide(); - $("tbody > tr").hide(); - cells.each(function() { - if($(this).is('a')) { - jQuery(this).parents('tr').show(); - } - }); - }*/ - // Prevent invalid links from jumping page scroll $('a[href=3D#]').click(function() { return false; - }); - - jQuery('#project-project-files-search-results').each(function() { - jQuery('input.' + this.id).val(jQuery(this).text()); - }); - - jQuery('.bar.building').each(function() { - var bar =3D jQuery(this); - bar.animate({ - width: '100%' - }, { - duration: parseInt(bar.attr('data-time')), - complete: function() { - location.href =3D bar.attr('data-url'); - } - }); - }); - - jQuery('#project-build-packages').each(function() { - var link =3D this; - var size =3D jQuery('[href=3D#size]'); - var dependencies =3D jQuery('[href=3D#dependencies]'); - size.click(function() { - link.href =3D 'project-build-packages.html'; - }); - dependencies.click(function() { - link.href =3D 'project-build-packages-dependencies.html'; - }); - }); - - if (location.href.search('tab') !=3D=3D -1) { - jQuery('[href=3D#' + location.href.split('tab=3D')[1] + ']').trigger('click'); - } - - jQuery('.tree a').each(function() { - var link =3D jQuery(this); - var parent =3D link.parents('li:first'); - var child =3D parent.find('ul'); - var prev =3D link.prev('i:first'); - link.click(function() { - if (prev.attr('class') =3D=3D 'icon-caret-down') { - child.slideUp('fast'); - prev.attr('class', 'icon-caret-right'); - } - else { - child.slideDown('fast'); - prev.attr('class', 'icon-caret-down'); - } - return false; - }); - }); - - /*jQuery('#nav').each(function() { - var links =3D jQuery(this).find('a'); - var split =3D location.href.split('/'); - var file =3D split[split.length - 1].split('?')[0]; - if (file =3D=3D 'project-build-packages-busybox.html') { - file =3D 'project-build-packages.html'; - } - else if (file =3D=3D 'project-build-packages-dependencies.html') { - file =3D 'project-build-packages.html'; - } - links.filter('[href=3D"' + file + '"]').parent().addClass('active'= ); - });*/ + }); =20 + =20 =20 - //Belen's additions + /* Belen's additions */ =20 - //make help tooltip and popovers work on click, mutually exclusive and dismiss them when clicking outside their area - //from=20 http://fuzzytolerance.info/blog/quick-hack-one-bootstarp-popover-at-a-time/ - //one problem: clicking inside the tooltip or popover should not dismiss it, but it currently does + // enable popovers in any table cells that contain an anchor with the + // .btn class applied + $('td > a.btn').popover({html:true, container:'body', placement: 'left'}); =20 - // Global variables - cringe - var visibleTooltip; - =20 - //show help information - $(".get-help").tooltip({ container: 'body', html: true, delay: {show: 300} /* trigger: 'hover'*/}); + // enable help information tooltip + $(".get-help").tooltip({ container: 'body', html: true, delay: {show: 300} }); =20 - //show help for task outcome on hover - $(".hover-help").hide(); - $("tr").hover(function () { - $(this).find(".hover-help").show(); + // show help bubble only on hover inside tables + $(".hover-help").css("visibility","hidden"); + $("th, td").hover(function () { + $(this).find(".hover-help").css("visibility","visible"); }); - $("tr").mouseleave(function () { - $(this).find(".hover-help").hide(); - });=09 - =20 - /* - //only allow one tooltip at a time - $(".get-help").on('click', function(e) { - // don't fall through - e.stopPropagation(); - var $this =3D $(this); - // check if the one clicked is now shown - if ($this.data('tooltip').tip().hasClass('in')) { - // if another was showing, hide it - visibleTooltip && visibleTooltip.tooltip('hide'); - // then store the current tooltip - visibleTooltip =3D $this; - } else { - // if it was hidden, then nothing must be showing - visibleTooltip =3D ''; - } - // dismiss tooltips when you click outside them - $('body').on("click", function (e) { - var $target =3D $(e.target), - inTooltip =3D $(e.target).closest('.popover').length > 0 - //hide only if clicked on button or inside popover - if (!inTooltip) { - visibleTooltip.tooltip('hide'); - visibleTooltip =3D ''; - } - }); - }); - */ - =20 - // Global variables - cringe - var visiblePopover; - - // enable popovers - $('.depends > a , .brought_in_by > a, .recommends > a, .layer_commit > a').popover({html:true, container:'body', placement: 'left'}); + $("th, td").mouseleave(function () { + $(this).find(".hover-help").css("visibility","hidden"); + }); =20 =20 - // make sure on hover elements do not disappear while the pointer is inside them=20 - // buggy: doesn't work if you hover over the same popover twice in a row - - /*$('.depends > a , .brought_in_by > a, .recommends > a, .layer_commit').popover({ - offset: 10, - trigger: 'manual', - animate: false, - html: true, - placement: 'left', - container: 'body', - template: '

' - - }).click(function(e) { - $(this).popover('show'); - });*/ + // show task type and outcome in task details pages + $(".task-info").tooltip({ container: 'body', html: true, delay: {show: 200}, placement: 'right' }); + =20 + // linking directly to tabs + $(function(){ + var hash =3D window.location.hash; + hash && $('ul.nav a[href=3D"' + hash + '"]').tab('show'); =20 - /* - // only allow 1 tooltip at a time - $('.get-help').on('click', function(e) { - // don't fall through - e.stopPropagation(); - var $this =3D $(this); - // check if the one clicked is now shown - if ($this.data('tooltip').tip().hasClass('in')) { - // if another was showing, hide it - visibleTooltip && visibleTooltip.tooltip('hide'); - // then store the current popover - visibleTooltip =3D $this; - } else { - // if it was hidden, then nothing must be showing - visibleToolitp =3D ''; - } - }); - */ + $('.nav-tabs a').click(function (e) { + $(this).tab('show'); + $('body').scrollTop(); =09 + }); + }); =20 + =20 + /* Make help tooltip and popovers work on click, mutually exclusive and dismiss them when clicking outside their area + from=20 http://fuzzytolerance.info/blog/quick-hack-one-bootstarp-popover-at-a-time/ */ + =20 + // Global variables - cringe + var visibleTooltip; + var visiblePopover; =09 //only allow 1 popover at a time - $('.depends > a , .brought_in_by > a, .recommends > a, .layer_commit > a').on('click', function(e) { + $('.depends > a , .brought_in_by > a, .layer_commit > a').on('click', function(e) { // don't fall through e.stopPropagation(); var $this =3D $(this); @@ -462,36 +79,4 @@ $(document).ready(function() { }); }); =09 -=09 - /* - // hide all tooltips if any non-tooltip part of the body is clicked - // this does not work properly: clicking the tooltip will also dismiss the tootlip - $("body").on('click', function () { - $(".get-help").tooltip('hide'); - visibleTootlip =3D ''; - });*/ -=09 - -=09 - // hide all popovers if any non-popover part of the body is clicked - // this does not work properly: clicking the popover will also dismiss the popover - /*$("body").on('click', function () { - $('.depends > a , .brought_in_by > a, .recommends > a, .layer_commit > a').popover('hide'); - visiblePopover =3D ''; - });*/ -=09 - //linking directly to tabs - $(function(){ - var hash =3D window.location.hash; - hash && $('ul.nav a[href=3D"' + hash + '"]').tab('show'); - - $('.nav-tabs a').click(function (e) { - $(this).tab('show'); - //var scrollmem =3D $('body').scrollTop(); - //window.location.hash =3D this.hash; - //$('html,body').scrollTop(scrollmem); - }); - }); - - }); --=20 1.7.9.5