summaryrefslogtreecommitdiff
path: root/static/js/kosten.ls
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2016-01-19 01:06:57 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2016-01-19 01:09:13 +0100
commit7963d41a8bef65205e7507b36c11383ce68298ed (patch)
treeaf456b859cdc5279a8d4cfc75470a857d85066b6 /static/js/kosten.ls
parenta6489752e2151aab72ce814a3a5652dbdfe22b1a (diff)
downloadkosten-7963d41a8bef65205e7507b36c11383ce68298ed.tar.gz
kosten-7963d41a8bef65205e7507b36c11383ce68298ed.tar.bz2
kosten-7963d41a8bef65205e7507b36c11383ce68298ed.zip
Allow to put in the date in short format
Diffstat (limited to '')
-rw-r--r--static/js/kosten.ls33
1 files changed, 30 insertions, 3 deletions
diff --git a/static/js/kosten.ls b/static/js/kosten.ls
index e3a60d2..163d670 100644
--- a/static/js/kosten.ls
+++ b/static/js/kosten.ls
@@ -1,6 +1,12 @@
jQuery.fn.extend do
copy : -> @clone!remove-attr 'id class'
+String::splitAt = (pos) -> return
+ @slice 0 pos
+ @slice pos
+
+Date::format = -> $.datepicker.formatDate \dd.mm.yy @
+
jq = (f) -> !-> $ f
# Call this to localize Highcharts
@@ -20,6 +26,25 @@ set-lang = !->
range-selector-to: \bis
range-selector-zoom: null
+extend-date = (input) !->
+ if input.val! is //^
+ ([12][0-9]|3[01]|0?[1-9]) # day
+ (?:
+ (0?[1-9]|1[0-2]) # month
+ ((?:20)?[0-9][0-9])? # year
+ )?
+ $//
+ then
+ now = new Date!
+ [_, day, month, year] = that
+ year ?= now.get-full-year!
+ month ?= now.get-month! + 1
+
+ year = "20" + year unless year > 99
+
+ new Date year, month - 1, day .format! |> input.val
+
+
# The Search Stuff
$ !->
$ \form.search .hide!
@@ -34,9 +59,11 @@ $ !->
# Add
export addJS = jq !->
- $ 'input[name=date]' .datepicker do
- date-format: \dd.mm.yy
- first-day: 1
+ $ 'input[name=date]'
+ .. .datepicker do
+ date-format: \dd.mm.yy
+ first-day: 1
+ .. .blur !-> extend-date ..
# Show
export showJS = jq !->