public
Description: Date Input is a no frills date picker plugin for jQuery
Homepage:
Clone URL: git://github.com/jonleighton/date_input.git
Insert the date picker directly after the input, so that the links in it can be
tabbed through. Listen for the Esc key and hide the date picker if it's pressed 
(#2276)
jonleighton (author)
Sat Nov 01 13:23:43 -0700 2008
commit  49c3acb67628d91e68ccee3a17b361e5110a509d
tree    eda90f381bbef59951d6f74a39ac652e4c0961b2
parent  babb08bf699c66ce4adb057c0a1746aa11009489
...
3
4
5
 
 
6
7
8
...
3
4
5
6
7
8
9
10
0
@@ -3,6 +3,8 @@ Version 1.1.7
0
 
0
  * Solve weird issue with duplicate and missing days in certain time zones (#2984,
0
    thanks to Arsenicus)
0
+ * Insert the date picker directly after the input, so that the links in it can be
0
+   tabbed through. Listen for the Esc key and hide the date picker if it's pressed (#2276)
0
 
0
 Version 1.1.6
0
 -------------
...
5
6
7
8
 
9
10
11
...
32
33
34
35
 
36
37
38
...
101
102
103
104
 
 
105
106
107
108
109
 
 
110
111
112
...
116
117
118
 
 
 
 
 
 
119
120
121
...
5
6
7
 
8
9
10
11
...
32
33
34
 
35
36
37
38
...
101
102
103
 
104
105
106
107
108
109
 
110
111
112
113
114
...
118
119
120
121
122
123
124
125
126
127
128
129
0
@@ -5,7 +5,7 @@ function DateInput(el, opts) {
0
   $.extend(this, DateInput.DEFAULT_OPTS, opts);
0
   
0
   this.input = $(el);
0
-  this.bindMethodsToObj("show", "hide", "hideIfClickOutside", "selectDate", "prevMonth", "nextMonth");
0
+  this.bindMethodsToObj("show", "hide", "hideIfClickOutside", "hideOnEsc", "selectDate", "prevMonth", "nextMonth");
0
   
0
   this.build();
0
   this.selectDate();
0
@@ -32,7 +32,7 @@ DateInput.prototype = {
0
     });
0
     tableShell += "</tr></thead><tbody></tbody></table>";
0
     
0
-    this.dateSelector = this.rootLayers = $('<div class="date_selector"></div>').append(monthNav, tableShell).appendTo(document.body);
0
+    this.dateSelector = this.rootLayers = $('<div class="date_selector"></div>').append(monthNav, tableShell).insertAfter(this.input);
0
     
0
     if ($.browser.msie && $.browser.version < 7) {
0
       this.ieframe = $('<iframe class="date_selector_ieframe" frameborder="0" src="#"></iframe>').insertBefore(this.dateSelector);
0
@@ -101,12 +101,14 @@ DateInput.prototype = {
0
     this.rootLayers.css("display", "block");
0
     this.setPosition();
0
     this.input.unbind("focus", this.show);
0
-    $([window, document.body]).click(this.hideIfClickOutside);
0
+    $("a:last", this.dateSelector).blur(this.hide);
0
+    $([window, document.body]).click(this.hideIfClickOutside).keyup(this.hideOnEsc);
0
   },
0
   
0
   hide: function() {
0
     this.rootLayers.css("display", "none");
0
-    $([window, document.body]).unbind("click", this.hideIfClickOutside);
0
+    $([window, document.body]).unbind("click", this.hideIfClickOutside).unbind("keyup", this.hideOnEsc);
0
+    $("a:last", this.dateSelector).unbind("blur", this.hide);
0
     this.input.focus(this.show);
0
   },
0
   
0
@@ -116,6 +118,12 @@ DateInput.prototype = {
0
     };
0
   },
0
   
0
+  hideOnEsc: function(event) {
0
+    if (event.keyCode == 27) {
0
+      this.hide();
0
+    };
0
+  },
0
+  
0
   stringToDate: function(string) {
0
     var matches;
0
     if (matches = string.match(/^(\d{1,2}) ([^\s]+) (\d{4,4})$/)) {

Comments