Commit 1d768fd2 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Coloring scorecards option is now remembered using HTML5 local storage

parent 671118ff
num = (s) -> if s == '' or isNaN(parseInt(s)) then 0 else parseInt(s)
$ ->
$('.match').each ->
$('.match-editable').each ->
table = $(@)
match_total = table.find('.match-total')
match_avg = table.find('.match-avg')
......@@ -45,7 +45,6 @@ $ ->
cell = $(@).closest('td')
cls = cell.attr('class').replace(/\s*val-\d+\s*/, '')
console.log cell.attr('class'), cls
cell.attr('class', cls).addClass('val-' + $(@).val())
inputs.filter('[value=""]:first').focus()
......@@ -62,3 +61,13 @@ $ ->
$('#toggle-colored').on 'click', ->
$(@).toggleClass('active').blur()
$('#match').toggleClass('colored')
if $('#match').hasClass('colored') and window.hasOwnProperty('localStorage')
localStorage.setItem('colored-scores', true)
console.log localStorage.getItem('colored-scores')
else
localStorage.removeItem('colored-scores')
if window.hasOwnProperty('localStorage') and localStorage.getItem('colored-scores')
$('#match').addClass('colored')
$('#toggle-colored').addClass('active')
......@@ -18,7 +18,8 @@
<form method="post" action="match/{$match->id}/scores">
<table id="match" class="table table-bordered table-condensed match {$match->discipline}">
<table id="match" class="table table-bordered table-condensed match
{$match->discipline} match-editable">
<thead>
<tr>
<th class="separator"></th>
......
......@@ -99,10 +99,5 @@
{/block}
{block scripts}
<script type="text/javascript">
$('#toggle-colored').click(function() {
$(this).toggleClass('active').blur();
$('#match').toggleClass('colored');
});
</script>
<script src="js/scores.js"></script>
{/block}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment