Project

General

Profile

« Previous | Next » 

Revision 65a0e193

Added by Stephen Beaver almost 10 years ago

Completed #5356
Refactor row toggle javascript

View differences:

src/usr/local/www/firewall_rules.php
688 688

  
689 689
?>
690 690

  
691
<script>
692
function stripe_table() {
693
	$("tr:odd").addClass('active');
694
	$("tr:even").removeClass('active');
695
}
696

  
697
function fr_toggle(id, prefix) {
698
	if (!prefix)
699
		prefix = 'fr';
700

  
701
	var checkbox = document.getElementById(prefix + 'c' + id);
702
	checkbox.checked = !checkbox.checked;
703
	fr_bgcolor(id, prefix);
704
}
705

  
706
// Change background color based on state of checkbox
707
// On resetting background, reapply table striping
708
function fr_bgcolor(id, prefix) {
709
	if (!prefix)
710
		prefix = 'fr';
711

  
712
	var row = $('#' + prefix + id);
713

  
714
	if ($('#' + prefix + 'c' + id).prop('checked') ) {
715
		row.css("background-color", "#DDF4FF");
716
		row.removeClass('active');
717
	} else {
718
		row.css("background-color", "#FFFFFF");
719
		stripe_table();
720
	}
721
}
722

  
723
</script>
724

  
725 691
<script>
726 692

  
727 693
events.push(function() {
......
741 707
	$('#order-store').click(function () {
742 708
	   $('[id^=frc]').prop('checked', true);
743 709
	});
744

  
745
	// Replace direct delete with quicker front-end action
746
/*FIXME: event ordering
747
	$('.btn-danger').on('click', function(e){
748
		$(this).parents('tr').remove();
749

  
750
		$('#order-store').removeAttr('disabled');
751
	});
752
*/});
710
});
753 711
</script>
754 712
<?php include("foot.inc");?>

Also available in: Unified diff