Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
archery
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
archery
Commits
553ce358
Commit
553ce358
authored
Jan 27, 2015
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed jQuery dependency
parent
f88a38bb
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
198 additions
and
168 deletions
+198
-168
coffee/forms.coffee
coffee/forms.coffee
+110
-83
coffee/scores.coffee
coffee/scores.coffee
+77
-72
templates/layout.latte
templates/layout.latte
+0
-3
templates/match/list.latte
templates/match/list.latte
+2
-2
templates/match/scores.latte
templates/match/scores.latte
+2
-2
templates/user/plot.latte
templates/user/plot.latte
+7
-6
No files found.
coffee/forms.coffee
View file @
553ce358
#window.Nette.addError = (elem, message) ->
mkelem
=
(
elemtype
,
classname
=
''
,
attrs
=
{})
->
# elem.focus() if elem.focus
elem
=
document
.
createElement
elemtype
#
elem
.
className
=
classname
# if message
elem
[
attr
]
=
value
for
own
attr
,
value
of
attrs
# elem.setCustomValidity(message)
elem
# elem.valid = 0
# elem.checkValidity()
# replace an input element with an addon group
create_addon
=
(
input
)
->
$
->
group
=
mkelem
'div'
,
'input-group'
$
(
'form:not(.nofocus):first input:first'
).
focus
()
input
.
parentNode
.
replaceChild
group
,
input
group
.
appendChild
input
create_addon
=
(
input
)
->
addon
=
mkelem
'div'
,
'input-group-addon'
group
=
$
(
'<div class="input-group">'
).
insertBefore
(
input
)
group
.
appendChild
addon
$
(
input
).
remove
().
appendTo
(
group
)
addon
$
(
'<div class="input-group-addon">'
).
appendTo
(
group
)
# focus on first input field in first form
$
(
'input[type=range]'
).
each
->
document
.
querySelector
(
'form:not(.nofocus)'
)
?
.
querySelector
(
'input'
)
?
.
focus
()
create_addon
(
@
)
$
(
@
).
on
'change input'
,
->
# add an addon to range inputs displaying the currently selected value
$
(
@
).
next
(
'.input-group-addon'
).
text
(
$
(
@
).
val
())
for
e
in
document
.
querySelectorAll
'input[type=range]'
$
(
@
).
change
()
create_addon
e
$
(
'input[type^=date]'
).
each
->
cb
=
->
@
.
nextElementSibling
.
innerHTML
=
@
.
value
create_addon
(
@
)
e
.
addEventListener
'change'
,
cb
.
html
(
'<span class="glyphicon glyphicon-calendar"></span>'
)
e
.
addEventListener
'input'
,
cb
.
on
'click'
,
->
$
(
@
).
prev
(
'input'
).
focus
()
cb
.
call
e
$
(
'input[type=number]'
).
on
(
'focus'
,
->
$
(
@
).
select
())
# add a calender addon to date inputs, and focus on input on addon click
$
(
'input[type=radio][data-inline]'
).
each
->
for
e
in
document
.
querySelectorAll
'input[type^=date]'
group
=
$
(
'<label class="radio-inline">'
)
addon
=
create_addon
e
.
append
(
$
(
@
).
parent
(
'label'
).
html
())
addon
.
innerHTML
=
'<span class="glyphicon glyphicon-calendar"></span>'
$
(
@
).
closest
(
'.radio'
).
replaceWith
(
group
)
addon
.
addEventListener
'click'
,
->
@
.
previousElementSibling
.
focus
()
if
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i
.
test
(
navigator
.
userAgent
)
# always select the whole number on a number type input to avoid backspacing
$
(
'abbr'
).
on
'click'
,
->
for
e
in
document
.
querySelectorAll
'input[type=number]'
alert
(
$
(
@
).
attr
(
'title'
))
e
.
addEventListener
'focus'
,
->
@
.
select
()
$
(
'tr'
).
on
'click'
,
->
# inline radio labels
href
=
$
(
this
).
data
(
'href'
)
for
e
in
document
.
querySelectorAll
'.radio > label > input[type=radio][data-inline]'
document
.
location
=
href
if
href
?
group
=
mkelem
'label'
,
'radio-inline'
group
.
innerHTML
=
e
.
parentNode
.
innerHTML
$
(
'select[multiple]'
).
addClass
(
'form-control'
)
label
=
e
.
parentNode
.
parentNode
label
.
parentNode
.
replaceChild
group
,
label
$
(
'.tags-control'
).
each
->
container
=
$
(
@
)
# make abbreviations clickable on mobile devices (since there is no hover)
tag_list
=
container
.
children
(
'.tags'
)
if
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i
.
test
navigator
.
userAgent
text_input
=
container
.
find
(
'input[type=text]'
)
for
e
in
document
.
getElementsByTagName
'abbr'
submit_btn
=
text_input
.
next
().
find
(
'.btn'
)
e
.
addEventListener
'click'
,
->
alert
@
.
getAttribute
'title'
# allow table rows to be links through the data-href attribute
for
e
in
document
.
querySelectorAll
'[data-href]'
e
.
addEventListener
'click'
,
->
document
.
location
=
@
.
getAttribute
'data-href'
# fix class names on select boxes with multiple="multiple"
for
e
in
document
.
querySelectorAll
'select[multiple]'
e
.
classList
.
add
'form-control'
# tag list controls on score add/edit pages
if
container
=
document
.
querySelector
'.tags-control'
tag_list
=
container
.
querySelector
'.tags'
text_input
=
container
.
querySelector
'input[type=text]'
submit_btn
=
text_input
.
nextElementSibling
.
querySelector
'.btn'
generate_inputs
=
->
generate_inputs
=
->
container
.
children
(
'input[type=hidden]'
).
remove
()
for
e
in
container
.
querySelectorAll
'input[type=hidden]'
container
.
find
(
'.tag .text'
).
each
->
e
.
parentNode
.
removeChild
e
$
(
'<input type="hidden" name="tags[]">'
)
.
appendTo
(
container
)
.
val
(
$
(
@
).
text
())
submit_tag
=
->
for
e
in
container
.
querySelectorAll
'.tag .text'
tag
=
text_input
.
val
().
trim
()
console
.
log
e
,
e
.
textContent
container
.
appendChild
mkelem
'input'
,
''
,
type
:
'hidden'
,
name
:
'tags[]'
,
value
:
e
.
textContent
if
tag
==
''
submit_tag
=
->
return
tag
=
text_input
.
value
.
trim
()
return
if
tag
==
''
text_input
.
value
=
''
text_input
.
val
(
''
)
link
=
tag_list
.
appendChild
mkelem
'a'
,
'tag'
,
href
:
'javascript:void(0)'
title
:
'Click to remove tag'
link
=
$
(
'<a href="javascript:void(0)" class="tag"
label
=
link
.
appendChild
mkelem
'span'
,
'label label-default'
title="Click to remove tag">'
).
appendTo
(
tag_list
)
label
.
innerHTML
=
$
(
'<span class="label label-default">'
)
'<span class="text"></span>
.
append
(
$
(
'<span class="text">'
).
text
(
tag
))
<span class="glyphicon glyphicon-remove"></span>'
.
append
(
' '
)
label
.
firstElementChild
.
textContent
=
tag
.
append
(
$
(
'<span class="glyphicon glyphicon-remove">'
))
.
appendTo
(
link
)
generate_inputs
()
generate_inputs
()
text_input
.
focus
()
text_input
.
focus
()
text_input
.
on
'keydown'
,
(
e
)
->
text_input
.
addEventListener
'keydown'
,
(
e
)
->
if
e
.
which
==
13
if
e
.
keyCode
==
13
e
.
preventDefault
()
e
.
preventDefault
()
submit_tag
()
submit_tag
()
submit_btn
.
on
'click'
,
submit_tag
submit_btn
.
addEventListener
'click'
,
submit_tag
container
.
on
'click'
,
'.tag'
,
->
container
.
addEventListener
'click'
,
(
e
)
->
$
(
@
).
remove
()
if
e
.
target
.
classList
.
contains
'glyphicon-remove'
label
=
e
.
target
.
parentNode
label
.
parentNode
.
removeChild
label
generate_inputs
()
generate_inputs
()
# add show/hide event to collapse targets (normally handled by Bootstrap)
for
e
in
document
.
querySelectorAll
'[data-toggle=collapse][data-target]'
((
target
)
->
if
target
e
.
addEventListener
'click'
,
(
e
)
->
e
.
preventDefault
()
target
.
classList
.
toggle
'in'
)(
document
.
querySelector
e
.
getAttribute
'data-target'
)
coffee/scores.coffee
View file @
553ce358
num
=
(
s
)
->
if
s
==
''
or
isNaN
(
parseInt
(
s
))
then
0
else
parseInt
(
s
)
if
table
=
document
.
querySelector
'.match-editable'
inputs
=
table
.
getElementsByTagName
'input'
$
->
rows
=
table
.
children
[
1
].
children
$
(
'.match-editable'
).
each
->
match_total
=
table
.
querySelector
'.match-total'
table
=
$
(
@
)
match_avg
=
table
.
querySelector
'.match-avg'
match_total
=
table
.
find
(
'.match-total'
)
match_avg
=
table
.
find
(
'.match-avg'
)
w
=
table
.
querySelector
(
'tbody tr'
).
getElementsByTagName
(
'input'
).
length
inputs
=
table
.
find
(
'input'
)
h
=
inputs
.
length
/
w
scores
=
[]
sum_row
=
(
row
)
->
row_total
=
0
sub
=
(
row
)
->
rows
[
row
].
children
[
w
+
1
]
prev_total
=
0
tot
=
(
row
)
->
rows
[
row
].
children
[
w
+
2
]
incomplete
=
false
num
=
(
s
)
->
if
s
==
''
or
isNaN
parseInt
s
then
0
else
parseInt
s
timer
=
0
row
.
find
(
'input'
).
each
->
if
$
(
@
).
val
()
==
''
set_score
=
(
col
,
row
,
score
)
->
incomplete
=
true
if
score
!=
scores
[
row
*
w
+
col
]
return
false
scores
[
row
*
w
+
col
]
=
score
clearTimeout
timer
row_total
+=
num
(
$
(
@
).
val
())
timer
=
setTimeout
(
->
render
row
),
50
true
if
incomplete
return
if
prev_row
=
row
.
prev
(
'tr'
)
prev_total
=
num
(
prev_row
.
children
(
'.total'
).
text
())
row
.
children
(
'.row-total'
).
text
(
row_total
)
row
.
children
(
'.total'
).
text
(
prev_total
+
row_total
)
row
.
children
(
'.total'
).
text
(
prev_total
+
row_total
)
inputs
.
on
'change keyup'
,
->
sum
=
0
count
=
0
inputs
.
each
->
if
$
(
@
).
val
()
!=
''
sum
+=
num
(
$
(
@
).
val
())
count
++
sum_row
(
$
(
@
).
closest
(
'tr'
))
match_total
.
text
(
sum
)
match_avg
.
text
(
Math
.
round
(
sum
/ count * 10) /
10
)
cell
=
$
(
@
).
closest
(
'td'
)
cls
=
cell
.
attr
(
'class'
).
replace
(
/\s*val-\d+\s*/
,
''
)
cell
.
attr
(
'class'
,
cls
).
addClass
(
'val-'
+
$
(
@
).
val
())
inputs
.
filter
(
'[value=""]:first'
).
focus
()
$
(
'textarea'
).
on
'keyup'
,
->
$
(
@
).
height
(
0
).
height
(
$
(
@
).
prop
(
'scrollHeight'
))
desired_scroll
=
$
(
@
).
offset
().
top
-
60
if
$
(
document
).
scrollTop
()
<
desired_scroll
$
(
window
).
scrollTop
(
desired_scroll
)
.
keyup
()
$
(
'#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
else
localStorage
.
removeItem
(
'colored-scores'
)
false
if
window
.
hasOwnProperty
(
'localStorage'
)
and
localStorage
.
getItem
(
'colored-scores'
)
render
=
(
dirty_row
)
->
$
(
'#match'
).
addClass
(
'colored'
)
subtotal
=
0
$
(
'#toggle-colored'
).
addClass
(
'active'
)
subtotal
+=
scores
[
dirty_row
*
w
+
col
]
for
col
in
[
0
...
w
]
sub
(
dirty_row
).
innerHTML
=
subtotal
total
=
if
dirty_row
then
num
tot
(
dirty_row
-
1
).
innerHTML
else
0
for
row
in
[
dirty_row
...
h
]
total
+=
num
sub
(
row
).
innerHTML
tot
(
row
).
innerHTML
=
total
match_total
.
innerHTML
=
total
match_avg
.
innerHTML
=
Math
.
round
(
total
/ inputs.length * 10) /
10
for
input
,
i
in
inputs
scores
.
push
num
input
.
value
((
col
,
row
)
->
cell
=
input
.
parentNode
cb
=
->
value
=
num
@
.
value
if
set_score
col
,
row
,
value
cell
.
className
=
cell
.
className
.
replace
/val-\d+/
,
'val-'
+
value
input
.
addEventListener
'change'
,
cb
input
.
addEventListener
'keyup'
,
cb
)(
i
%
w
,
Math
.
floor
i
/
w
)
render
0
table
.
querySelector
(
'input[value=""]'
)
?
.
focus
()
# notes area grows automatically with each added line
if
notes
=
document
.
getElementById
(
'notes'
)
cb
=
->
@
.
style
.
height
=
0
@
.
style
.
height
=
@
.
scrollHeight
+
'px'
notes
.
addEventListener
'keyup'
,
cb
cb
.
call
notes
# color toggling + persistence in local storage
match
=
document
.
getElementById
'match'
toggle_color
=
document
.
getElementById
(
'toggle-colored'
)
if
'localStorage'
of
window
and
localStorage
.
getItem
'colored-scores'
match
.
classList
.
add
'colored'
toggle_color
.
classList
.
add
'active'
toggle_color
.
addEventListener
'click'
,
->
@
.
classList
.
toggle
'active'
@
.
blur
()
match
.
classList
.
toggle
'colored'
if
'localStorage'
of
window
if
match
.
classList
.
contains
'colored'
localStorage
.
setItem
'colored-scores'
,
true
else
localStorage
.
removeItem
'colored-scores'
templates/layout.latte
View file @
553ce358
...
@@ -46,9 +46,6 @@
...
@@ -46,9 +46,6 @@
<div
class=
"container"
>
<div
class=
"container"
>
{include content}
{include content}
</div>
</div>
<script
src=
"//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"
></script>
<script
src=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"
></script>
{*
<script
src=
"js/netteForms.js"
></script>
*}
<script
src=
"js/forms.js"
></script>
<script
src=
"js/forms.js"
></script>
{ifset #scripts}
{ifset #scripts}
{include scripts}
{include scripts}
...
...
templates/match/list.latte
View file @
553ce358
...
@@ -19,8 +19,8 @@
...
@@ -19,8 +19,8 @@
<a href="match" class="btn btn-sm btn-default" title="{_'Add new match'}">
<a href="match" class="btn btn-sm btn-default" title="{_'Add new match'}">
<span class="glyphicon glyphicon-plus"></span>
<span class="glyphicon glyphicon-plus"></span>
</a>
</a>
<a
data-toggle="collapse" href="#filter
" title="{_'Filter'}"
<a
href="#filter" class="btn btn-sm btn-default
" title="{_'Filter'}"
class="btn btn-sm btn-default
">
data-toggle="collapse" data-target="#filter
">
<span class="glyphicon glyphicon-filter"></span>
<span class="glyphicon glyphicon-filter"></span>
</a>
</a>
</div>
</div>
...
...
templates/match/scores.latte
View file @
553ce358
...
@@ -60,8 +60,8 @@
...
@@ -60,8 +60,8 @@
<h3 class="panel-title">{_'Notes'}</h3>
<h3 class="panel-title">{_'Notes'}</h3>
</div>
</div>
<div class="panel-body">
<div class="panel-body">
<textarea
name="notes" wrap="hard" placeholder="{_'Click here to make a note'}
"
<textarea
id="notes" name="notes" wrap="hard
"
>{$match->notes}</textarea>
placeholder="{_'Click here to make a note'}"
>{$match->notes}</textarea>
</div>
</div>
</div>
</div>
...
...
templates/user/plot.latte
View file @
553ce358
...
@@ -10,11 +10,12 @@
...
@@ -10,11 +10,12 @@
{/block}
{/block}
{block scripts}
{block scripts}
<script type="text/javascript" src="jqplot/jquery.jqplot.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="jqplot/plugins/jqplot.highlighter.min.js"></script>
<script src="jqplot/jquery.jqplot.min.js"></script>
<script type="text/javascript" src="jqplot/plugins/jqplot.dateAxisRenderer.min.js"></script>
<script src="jqplot/plugins/jqplot.highlighter.min.js"></script>
<script type="text/javascript" src="jqplot/plugins/jqplot.canvasOverlay.min.js"></script>
<script src="jqplot/plugins/jqplot.dateAxisRenderer.min.js"></script>
<script type="text/javascript">
<script src="jqplot/plugins/jqplot.canvasOverlay.min.js"></script>
<script>
window.data = [
window.data = [
{foreach $matches as $match}
{foreach $matches as $match}
[{$match->created_at|date:'%Y-%m-%d %H:%M'}, {match_avg_score($match)}],
[{$match->created_at|date:'%Y-%m-%d %H:%M'}, {match_avg_score($match)}],
...
@@ -24,5 +25,5 @@
...
@@ -24,5 +25,5 @@
title: {_'Average arrow score over time'}
title: {_'Average arrow score over time'}
};
};
</script>
</script>
<script
type="text/javascript"
src="js/plot.js"></script>
<script src="js/plot.js"></script>
{/block}
{/block}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment