diff --git a/scp/css/scp.css b/scp/css/scp.css index 5955c0304daeb063f3ab6af12bd602ae4a5d851e..59964d4e61561ba78bc704e3e6ddb2d1a73af964 100644 --- a/scp/css/scp.css +++ b/scp/css/scp.css @@ -411,6 +411,11 @@ table.list tbody td { background: #fff; padding: 1px; padding-left:2px; vertical table.list tbody tr.odd td { background-color: #f0faff; } table.list tbody tr:hover td { background: #ffe; } table.list tbody tr.odd:hover td { background: #ffd; } +/* row highlighting on hover + select */ +table.list tbody tr:hover td, table.list tbody tr.highlight td { background: #FFFFDD; } +/* disabled highlighting on nohover */ +table.list tbody tr:hover td.nohover, table.list tbody tr.highlight td.nohover {} + table.list tfoot td { background:#eee; diff --git a/scp/js/scp.js b/scp/js/scp.js index 78fdbe43dd03cda4fac30c0adf92f2c13b2140e2..a841d96cd8edc817c44d147200ca3019428c6181 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -43,10 +43,11 @@ function toogle_all(formObj,highlight){ -function checkbox_checker(formObj, min,max) { +function checkbox_checker(formObj, min, max) { - - var checked=$("input[type=checkbox]:checked").length; + var max = max || 0; + var min = min || 1; + var checked=$('input:checkbox:checked', formObj).length; var action= action?action:"process"; if (max>0 && checked > max ){ msg="You're limited to only " + max + " selections.\n" @@ -69,6 +70,73 @@ $(document).ready(function(){ $("input:not(.dp):visible:enabled:first").focus(); $('table.list tbody tr:odd').addClass('odd'); + $('table.list input:checkbox').bind('click, change', function() { + $(this) + .parents("tr:first") + .toggleClass("highlight", this.checked); + }); + + $('#selectAll').click(function(e) { + e.preventDefault(); + var target = $(this).attr('href').substr(1, $(this).attr('href').length); + $(this).closest('form') + .find('input:checkbox.'+target) + .prop('checked', true) + .trigger('change'); + + return false; + }); + + + $('#selectNone').click(function(e) { + e.preventDefault(); + var target = $(this).attr('href').substr(1, $(this).attr('href').length); + $(this).closest('form') + .find('input:checkbox.'+target) + .prop('checked', false) + .trigger('change'); + return false; + }); + + $('#selectToggle').click(function(e) { + e.preventDefault(); + var target = $(this).attr('href').substr(1, $(this).attr('href').length); + $(this).closest('form') + .find('input:checkbox.'+target) + .each(function() { + $(this) + .prop('checked', !$(this).is(':checked')) + .trigger('change'); + }); + return false; + }); + + $('#buttons input:submit.button').bind('click', function(e) { + + var formObj = $(this).closest('form'); + e.preventDefault(); + if($('.dialog#confirm-action p#'+this.name+'-confirm').length == 0) { + alert('Unknown action '+this.name+' - get technical help.'); + } else if(checkbox_checker(formObj, 1)) { + var action = this.name; + $('.dialog#confirm-action').undelegate('.confirm'); + $('.dialog#confirm-action').delegate('input.confirm', 'click.confirm', function(e) { + e.preventDefault(); + $('.dialog#confirm-action').hide(); + $('#overlay').hide(); + $('input#action', formObj).val(action); + formObj.submit(); + return false; + }); + $('#overlay').show(); + $('.dialog#confirm-action .confirm-action').hide(); + $('.dialog#confirm-action p#'+this.name+'-confirm') + .show() + .parent('div').show().trigger('click'); + } + + return false; + }); if($.browser.msie) { $('.inactive').mouseenter(function() { @@ -294,17 +362,9 @@ $(document).ready(function(){ left : ($(window).width() / 2 - 300) }); - $('.dialog').delegate('a.close', 'click', function(e) { - e.preventDefault(); - $(this).parent().hide() - $('#overlay').hide(); - - return false; - }); - - $('.dialog').delegate('input.close', 'click', function(e) { + $('.dialog').delegate('input.close, a.close', 'click', function(e) { e.preventDefault(); - $(this).closest('form').parent().hide() + $(this).parents('div.dialog').hide() $('#overlay').hide(); return false;