public
Rubygem
Description: A popular and flexible JavaScript DatePicker for RubyOnRails (and others)
Homepage: http://code.google.com/p/calendardateselect/
Clone URL: git://github.com/timcharper/calendar_date_select.git
Add Clear button on pop up calendar. The button is shown by default. To 
remove it, add ":clear_button => false" to options.
htanata (author)
Tue Aug 26 00:24:46 -0700 2008
commit  9fc02986e4d9ba7410043134922fce167933829f
tree    61185855509d9768daa42b52a59fb1dc2f0dedd0
parent  06520f660d3f2913cfb7110f57c152483511382c
...
113
114
115
116
 
117
118
119
...
113
114
115
 
116
117
118
119
0
@@ -113,7 +113,7 @@ class CalendarDateSelect
0
     def calendar_date_select_process_options(options)
0
       calendar_options = {}
0
       callbacks = [:before_show, :before_close, :after_show, :after_close, :after_navigate]
0
- for key in [:time, :valid_date_check, :embedded, :buttons, :format, :year_range, :month_year, :popup, :hidden, :minute_interval] + callbacks
0
+ for key in [:time, :valid_date_check, :embedded, :buttons, :clear_button, :format, :year_range, :month_year, :popup, :hidden, :minute_interval] + callbacks
0
         calendar_options[key] = options.delete(key) if options.has_key?(key)
0
       end
0
       
...
47
48
49
50
 
 
51
52
53
...
82
83
84
 
85
86
87
...
235
236
237
 
 
 
 
238
239
240
...
337
338
339
 
 
 
 
340
341
342
...
47
48
49
 
50
51
52
53
54
...
83
84
85
86
87
88
89
...
237
238
239
240
241
242
243
244
245
246
...
343
344
345
346
347
348
349
350
351
352
0
@@ -47,7 +47,8 @@ window.f_scrollTop = function() { return ([window.pageYOffset ? window.pageYOffs
0
 _translations = {
0
   "OK": "OK",
0
   "Now": "Now",
0
- "Today": "Today"
0
+ "Today": "Today",
0
+ "Clear": "Clear"
0
 }
0
 SelectBox = Class.create();
0
 SelectBox.prototype = {
0
@@ -82,6 +83,7 @@ CalendarDateSelect.prototype = {
0
       popup: nil,
0
       time: false,
0
       buttons: true,
0
+ clear_button: true,
0
       year_range: 10,
0
       close_on_click: nil,
0
       minute_interval: 5,
0
@@ -235,6 +237,10 @@ CalendarDateSelect.prototype = {
0
       {
0
         buttons_div.build("span", {innerHTML: " "});
0
         buttons_div.build("a", { innerHTML: _translations["OK"], href: "#", onclick: function() {this.close(); return false;}.bindAsEventListener(this) });
0
+ buttons_div.build("span", {innerHTML: " "});
0
+ if (this.options.get('clear_button')) {
0
+ buttons_div.build("a", { innerHTML: _translations["Clear"], href: "#", onclick: function() {this.clearDate(); this.close(); return false;}.bindAsEventListener(this) });
0
+ }
0
       }
0
     }
0
   },
0
@@ -337,6 +343,10 @@ CalendarDateSelect.prototype = {
0
     this.date.setDate(1);
0
   },
0
   updateFooter:function(text) { if (!text) text = this.dateString(); this.footer_div.purgeChildren(); this.footer_div.build("span", {innerHTML: text }); },
0
+ clearDate:function() {
0
+ if ((this.target_element.disabled || this.target_element.readOnly) && this.options.get("popup") != "force") return false;
0
+ this.target_element.value = "";
0
+ },
0
   updateSelectedDate:function(partsOrElement, via_click) {
0
     var parts = $H(partsOrElement);
0
     if ((this.target_element.disabled || this.target_element.readOnly) && this.options.get("popup") != "force") return false;

Comments

    No one has commented yet.