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_nat.php
352 352
							<?=htmlspecialchars($natent['descr'])?>
353 353
						</td>
354 354
						<td>
355
							<a class="btn btn-xs btn-info"	title="<?=gettext("Edit rule"); ?>" href="firewall_nat_edit.php?id=<?=$i?>"><?=gettext("Edit"); ?></a>
356
							<a class="btn btn-xs btn-danger"  title="<?=gettext("Delete rule")?>" href="firewall_nat.php?act=del&amp;id=<?=$i?>"><?=gettext("Del")?></a>
357
							<a class="btn btn-xs btn-success"	  title="<?=gettext("Add a new NAT based on this one")?>" href="firewall_nat_edit.php?dup=<?=$i?>"><?=gettext("Clone")?></a>
355
							<a class="fa fa-pencil" title="<?=gettext("Edit rule"); ?>" href="firewall_nat_edit.php?id=<?=$i?>"></a>
356
							<a class="fa fa-clone"	  title="<?=gettext("Add a new NAT based on this one")?>" href="firewall_nat_edit.php?dup=<?=$i?>"></a>
357
							<a class="fa fa-trash"	title="<?=gettext("Delete rule")?>" href="firewall_nat.php?act=del&amp;id=<?=$i?>" onclick="return confirm('<?=gettext("Are you sure you want to delete this rule?")?>')"></a>
358 358
						</td>
359 359
					</tr>
360 360
<?php
......
375 375
</form>
376 376

  
377 377
<script>
378
function fr_toggle(id, prefix) {
379
	if (!prefix)
380
		prefix = 'fr';
381

  
382
	var checkbox = document.getElementById(prefix + 'c' + id);
383
	checkbox.checked = !checkbox.checked;
384
	fr_bgcolor(id, prefix);
385
}
386

  
387
function fr_bgcolor(id, prefix) {
388
	if (!prefix)
389
		prefix = 'fr';
390

  
391
	var row = document.getElementById(prefix + id);
392
	var checkbox = document.getElementById(prefix + 'c' + id);
393
	var cells = row.getElementsByTagName('td');
394
	var cellcnt = cells.length;
378
events.push(function() {
395 379

  
396
	for (i = 0; i < cellcnt-1; i++) {
397
		cells[i].style.backgroundColor = checkbox.checked ? "#DDF4FF" : "#FFFFFF";
398
	}
399
}
400
</script>
380
	stripe_table();
401 381

  
402
<script>
403
events.push(function() {
404
	// Make rules draggable/sortable
382
	// Make rules sortable
405 383
	$('table tbody.user-entries').sortable({
406 384
		cursor: 'grabbing',
407 385
		update: function(event, ui) {
408 386
			$('#order-store').removeAttr('disabled');
387
			stripe_table();
409 388
		}
410 389
	});
411 390

  

Also available in: Unified diff