Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added initializer javascript

  • Loading branch information...
commit e9d21c5b601175e89e79a644dac34c261ddee76d 1 parent ce30bad
@juzna authored
Showing with 28 additions and 1 deletion.
  1. +1 −1  composer.json
  2. +27 −0 date-picker.js
View
2  composer.json
@@ -25,7 +25,7 @@
"extra": {
"nette": {
"assets": {
-
+ "js": [ "date-picker.js" ]
},
"assets-optional": {
View
27 date-picker.js
@@ -0,0 +1,27 @@
+$(document).ready(function () {
+ $("input.date").each(function () { // input[type=date] does not work in IE
+ var el = $(this);
+ var value = el.val();
+ var date = (value ? $.datepicker.parseDate($.datepicker.W3C, value) : null);
+
+ var minDate = el.attr("min") || null;
+ if (minDate) minDate = $.datepicker.parseDate($.datepicker.W3C, minDate);
+ var maxDate = el.attr("max") || null;
+ if (maxDate) maxDate = $.datepicker.parseDate($.datepicker.W3C, maxDate);
+
+ // input.attr("type", "text") throws exception
+ if (el.attr("type") == "date") {
+ var tmp = $("<input/>");
+ $.each("class,disabled,id,maxlength,name,readonly,required,size,style,tabindex,title,value".split(","), function(i, attr) {
+ tmp.attr(attr, el.attr(attr));
+ });
+ el.replaceWith(tmp);
+ el = tmp;
+ }
+ el.datepicker({
+ minDate: minDate,
+ maxDate: maxDate
+ });
+ el.val($.datepicker.formatDate(el.datepicker("option", "dateFormat"), date));
+ });
+});
Please sign in to comment.
Something went wrong with that request. Please try again.