From 84ca20994569257b04f4353ada22ca80701e572d Mon Sep 17 00:00:00 2001 From: Lukas Beaton Date: Thu, 7 Jun 2012 11:44:31 -0400 Subject: [PATCH 01/10] adds a prototype function for setting the dropdown menu hour, which can now be easily overriden for I18n --- .../javascripts/calendar_date_select/calendar_date_select.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/javascripts/calendar_date_select/calendar_date_select.js b/public/javascripts/calendar_date_select/calendar_date_select.js index f22d521..0986434 100644 --- a/public/javascripts/calendar_date_select/calendar_date_select.js +++ b/public/javascripts/calendar_date_select/calendar_date_select.js @@ -29,6 +29,7 @@ Date.padded2 = function(hour) { var padded2 = parseInt(hour, 10); if (hour < 10) Date.prototype.getPaddedMinutes = function() { return Date.padded2(this.getMinutes()); } Date.prototype.getAMPMHour = function() { var hour = this.getHours(); return (hour == 0) ? 12 : (hour > 12 ? hour - 12 : hour ) } Date.prototype.getAMPM = function() { return (this.getHours() < 12) ? "AM" : "PM"; } +Date.prototype.getHourForDropdown = function() { return this.getAMPMHour()+ " " + this.getAMPM(); } Date.prototype.stripTime = function() { return new Date(this.getFullYear(), this.getMonth(), this.getDate());}; Date.prototype.daysDistance = function(compare_date) { return Math.round((compare_date - this) / Date.one_day); }; Date.prototype.toFormattedString = function(include_time){ @@ -209,7 +210,7 @@ CalendarDateSelect.prototype = { var t = new Date(); this.hour_select = new SelectBox(buttons_div, - blank_time.concat($R(0,23).map(function(x) {t.setHours(x); return $A([t.getAMPMHour()+ " " + t.getAMPM(),x])} )), + blank_time.concat($R(0,23).map(function(x) {t.setHours(x); return $A([t.getHourForDropdown(),x])} )), { calendar_date_select: this, onchange: function() { this.calendar_date_select.updateSelectedDate( { hour: this.value });}, @@ -456,4 +457,4 @@ CalendarDateSelect.prototype = { if (e.keyCode==Event.KEY_ESC) this.close(); }, callback: function(name, param) { if (this.options.get(name)) { this.options.get(name).bind(this.target_element)(param); } } -} \ No newline at end of file +} From 381d13bc3f2bdbaa56aeb367ecd1447cc8e59728 Mon Sep 17 00:00:00 2001 From: Lukas Beaton Date: Thu, 7 Jun 2012 11:45:41 -0400 Subject: [PATCH 02/10] allows the user to select a time ONLY and still have the field update --- .../calendar_date_select/calendar_date_select.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/public/javascripts/calendar_date_select/calendar_date_select.js b/public/javascripts/calendar_date_select/calendar_date_select.js index 0986434..8fb60c4 100644 --- a/public/javascripts/calendar_date_select/calendar_date_select.js +++ b/public/javascripts/calendar_date_select/calendar_date_select.js @@ -381,8 +381,16 @@ CalendarDateSelect.prototype = { this.selection_made = true; } - if (!isNaN(parts.get("hour"))) this.selected_date.setHours(parts.get("hour")); - if (!isNaN(parts.get("minute"))) this.selected_date.setMinutes( Math.floor_to_interval(parts.get("minute"), this.options.get("minute_interval")) ); + if (!isNaN(parts.get("hour"))){ + this.selected_date.setHours(parts.get("hour")); + this.selection_made = true; + } + + if (!isNaN(parts.get("minute"))){ + this.selected_date.setMinutes( Math.floor_to_interval(parts.get("minute"), this.options.get("minute_interval")) ); + this.selection_made = true; + } + if (parts.get("hour") === "" || parts.get("minute") === "") this.setUseTime(false); else if (!isNaN(parts.get("hour")) || !isNaN(parts.get("minute"))) From 9919c97cd704f6246b3d45db0c336acf6010fdb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Azimi?= Date: Tue, 12 Jun 2012 15:13:18 +0200 Subject: [PATCH 03/10] assets moved to add a Rails 3 asset pipeline path. --- VERSION | 2 +- calendar_date_select.gemspec | 60 +++++++++--------- .../images/calendar_date_select/calendar.gif | Bin .../javascripts}/calendar_date_select.js | 0 .../calendar_date_select/format_american.js | 0 .../calendar_date_select/format_danish.js | 0 .../calendar_date_select/format_db.js | 0 .../calendar_date_select/format_euro_24hr.js | 0 .../format_euro_24hr_ymd.js | 0 .../calendar_date_select/format_finnish.js | 0 .../format_hyphen_ampm.js | 0 .../calendar_date_select/format_iso_date.js | 0 .../calendar_date_select/format_italian.js | 0 .../calendar_date_select/locale/ar.js | 0 .../calendar_date_select/locale/cs.js | 0 .../calendar_date_select/locale/da.js | 0 .../calendar_date_select/locale/de.js | 0 .../calendar_date_select/locale/es.js | 0 .../calendar_date_select/locale/fi.js | 0 .../calendar_date_select/locale/fr.js | 0 .../calendar_date_select/locale/it.js | 0 .../calendar_date_select/locale/ja.js | 0 .../calendar_date_select/locale/nl.js | 0 .../calendar_date_select/locale/pl.js | 0 .../calendar_date_select/locale/pt.js | 0 .../calendar_date_select/locale/ru.js | 0 .../calendar_date_select/locale/sl.js | 0 .../calendar_date_select/locale/sv.js | 0 .../stylesheets/calendar_date_select/blue.css | 0 .../calendar_date_select/default.css | 0 .../calendar_date_select/green.css | 0 .../calendar_date_select/plain.css | 0 .../stylesheets/calendar_date_select/red.css | 0 .../calendar_date_select/silver.css | 0 lib/calendar_date_select.rb | 17 +++-- .../calendar_date_select.rb | 2 +- lib/calendar_date_select/version.rb | 5 ++ 37 files changed, 48 insertions(+), 38 deletions(-) rename {public => lib/assets}/images/calendar_date_select/calendar.gif (100%) rename {public/javascripts/calendar_date_select => lib/assets/javascripts}/calendar_date_select.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/format_american.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/format_danish.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/format_db.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/format_euro_24hr.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/format_euro_24hr_ymd.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/format_finnish.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/format_hyphen_ampm.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/format_iso_date.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/format_italian.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/locale/ar.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/locale/cs.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/locale/da.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/locale/de.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/locale/es.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/locale/fi.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/locale/fr.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/locale/it.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/locale/ja.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/locale/nl.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/locale/pl.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/locale/pt.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/locale/ru.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/locale/sl.js (100%) rename {public => lib/assets}/javascripts/calendar_date_select/locale/sv.js (100%) rename {public => lib/assets}/stylesheets/calendar_date_select/blue.css (100%) rename {public => lib/assets}/stylesheets/calendar_date_select/default.css (100%) rename {public => lib/assets}/stylesheets/calendar_date_select/green.css (100%) rename {public => lib/assets}/stylesheets/calendar_date_select/plain.css (100%) rename {public => lib/assets}/stylesheets/calendar_date_select/red.css (100%) rename {public => lib/assets}/stylesheets/calendar_date_select/silver.css (100%) create mode 100644 lib/calendar_date_select/version.rb diff --git a/VERSION b/VERSION index 4a02d2c..c807441 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.16.2 +1.16.3 diff --git a/calendar_date_select.gemspec b/calendar_date_select.gemspec index 49b0065..64e1186 100644 --- a/calendar_date_select.gemspec +++ b/calendar_date_select.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = %q{calendar_date_select} - s.version = "1.16.2" + s.version = "1.16.3" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Shih-gian Lee", "Enrique Garcia Cota (kikito)", "Tim Charper", "Lars E. Hoeg"] @@ -36,35 +36,35 @@ Gem::Specification.new do |s| "lib/calendar_date_select/form_helpers.rb", "lib/calendar_date_select/includes_helper.rb", "public/blank_iframe.html", - "public/images/calendar_date_select/calendar.gif", - "public/javascripts/calendar_date_select/calendar_date_select.js", - "public/javascripts/calendar_date_select/format_american.js", - "public/javascripts/calendar_date_select/format_danish.js", - "public/javascripts/calendar_date_select/format_db.js", - "public/javascripts/calendar_date_select/format_euro_24hr.js", - "public/javascripts/calendar_date_select/format_euro_24hr_ymd.js", - "public/javascripts/calendar_date_select/format_finnish.js", - "public/javascripts/calendar_date_select/format_hyphen_ampm.js", - "public/javascripts/calendar_date_select/format_iso_date.js", - "public/javascripts/calendar_date_select/format_italian.js", - "public/javascripts/calendar_date_select/locale/ar.js", - "public/javascripts/calendar_date_select/locale/da.js", - "public/javascripts/calendar_date_select/locale/de.js", - "public/javascripts/calendar_date_select/locale/es.js", - "public/javascripts/calendar_date_select/locale/fi.js", - "public/javascripts/calendar_date_select/locale/fr.js", - "public/javascripts/calendar_date_select/locale/it.js", - "public/javascripts/calendar_date_select/locale/nl.js", - "public/javascripts/calendar_date_select/locale/pl.js", - "public/javascripts/calendar_date_select/locale/pt.js", - "public/javascripts/calendar_date_select/locale/ru.js", - "public/javascripts/calendar_date_select/locale/sl.js", - "public/stylesheets/calendar_date_select/blue.css", - "public/stylesheets/calendar_date_select/default.css", - "public/stylesheets/calendar_date_select/green.css", - "public/stylesheets/calendar_date_select/plain.css", - "public/stylesheets/calendar_date_select/red.css", - "public/stylesheets/calendar_date_select/silver.css", + "lib/assets/images/calendar.gif", + "lib/assets/javascripts/calendar_date_select.js", + "lib/assets/javascripts/format_american.js", + "lib/assets/javascripts/format_danish.js", + "lib/assets/javascripts/format_db.js", + "lib/assets/javascripts/format_euro_24hr.js", + "lib/assets/javascripts/format_euro_24hr_ymd.js", + "lib/assets/javascripts/format_finnish.js", + "lib/assets/javascripts/format_hyphen_ampm.js", + "lib/assets/javascripts/format_iso_date.js", + "lib/assets/javascripts/format_italian.js", + "lib/assets/javascripts/locale/ar.js", + "lib/assets/javascripts/locale/da.js", + "lib/assets/javascripts/locale/de.js", + "lib/assets/javascripts/locale/es.js", + "lib/assets/javascripts/locale/fi.js", + "lib/assets/javascripts/locale/fr.js", + "lib/assets/javascripts/locale/it.js", + "lib/assets/javascripts/locale/nl.js", + "lib/assets/javascripts/locale/pl.js", + "lib/assets/javascripts/locale/pt.js", + "lib/assets/javascripts/locale/ru.js", + "lib/assets/javascripts/locale/sl.js", + "lib/assets/stylesheets/blue.css", + "lib/assets/stylesheets/default.css", + "lib/assets/stylesheets/green.css", + "lib/assets/stylesheets/plain.css", + "lib/assets/stylesheets/red.css", + "lib/assets/stylesheets/silver.css", "spec/calendar_date_select/calendar_date_select_spec.rb", "spec/calendar_date_select/form_helpers_spec.rb", "spec/calendar_date_select/includes_helper_spec.rb", diff --git a/public/images/calendar_date_select/calendar.gif b/lib/assets/images/calendar_date_select/calendar.gif similarity index 100% rename from public/images/calendar_date_select/calendar.gif rename to lib/assets/images/calendar_date_select/calendar.gif diff --git a/public/javascripts/calendar_date_select/calendar_date_select.js b/lib/assets/javascripts/calendar_date_select.js similarity index 100% rename from public/javascripts/calendar_date_select/calendar_date_select.js rename to lib/assets/javascripts/calendar_date_select.js diff --git a/public/javascripts/calendar_date_select/format_american.js b/lib/assets/javascripts/calendar_date_select/format_american.js similarity index 100% rename from public/javascripts/calendar_date_select/format_american.js rename to lib/assets/javascripts/calendar_date_select/format_american.js diff --git a/public/javascripts/calendar_date_select/format_danish.js b/lib/assets/javascripts/calendar_date_select/format_danish.js similarity index 100% rename from public/javascripts/calendar_date_select/format_danish.js rename to lib/assets/javascripts/calendar_date_select/format_danish.js diff --git a/public/javascripts/calendar_date_select/format_db.js b/lib/assets/javascripts/calendar_date_select/format_db.js similarity index 100% rename from public/javascripts/calendar_date_select/format_db.js rename to lib/assets/javascripts/calendar_date_select/format_db.js diff --git a/public/javascripts/calendar_date_select/format_euro_24hr.js b/lib/assets/javascripts/calendar_date_select/format_euro_24hr.js similarity index 100% rename from public/javascripts/calendar_date_select/format_euro_24hr.js rename to lib/assets/javascripts/calendar_date_select/format_euro_24hr.js diff --git a/public/javascripts/calendar_date_select/format_euro_24hr_ymd.js b/lib/assets/javascripts/calendar_date_select/format_euro_24hr_ymd.js similarity index 100% rename from public/javascripts/calendar_date_select/format_euro_24hr_ymd.js rename to lib/assets/javascripts/calendar_date_select/format_euro_24hr_ymd.js diff --git a/public/javascripts/calendar_date_select/format_finnish.js b/lib/assets/javascripts/calendar_date_select/format_finnish.js similarity index 100% rename from public/javascripts/calendar_date_select/format_finnish.js rename to lib/assets/javascripts/calendar_date_select/format_finnish.js diff --git a/public/javascripts/calendar_date_select/format_hyphen_ampm.js b/lib/assets/javascripts/calendar_date_select/format_hyphen_ampm.js similarity index 100% rename from public/javascripts/calendar_date_select/format_hyphen_ampm.js rename to lib/assets/javascripts/calendar_date_select/format_hyphen_ampm.js diff --git a/public/javascripts/calendar_date_select/format_iso_date.js b/lib/assets/javascripts/calendar_date_select/format_iso_date.js similarity index 100% rename from public/javascripts/calendar_date_select/format_iso_date.js rename to lib/assets/javascripts/calendar_date_select/format_iso_date.js diff --git a/public/javascripts/calendar_date_select/format_italian.js b/lib/assets/javascripts/calendar_date_select/format_italian.js similarity index 100% rename from public/javascripts/calendar_date_select/format_italian.js rename to lib/assets/javascripts/calendar_date_select/format_italian.js diff --git a/public/javascripts/calendar_date_select/locale/ar.js b/lib/assets/javascripts/calendar_date_select/locale/ar.js similarity index 100% rename from public/javascripts/calendar_date_select/locale/ar.js rename to lib/assets/javascripts/calendar_date_select/locale/ar.js diff --git a/public/javascripts/calendar_date_select/locale/cs.js b/lib/assets/javascripts/calendar_date_select/locale/cs.js similarity index 100% rename from public/javascripts/calendar_date_select/locale/cs.js rename to lib/assets/javascripts/calendar_date_select/locale/cs.js diff --git a/public/javascripts/calendar_date_select/locale/da.js b/lib/assets/javascripts/calendar_date_select/locale/da.js similarity index 100% rename from public/javascripts/calendar_date_select/locale/da.js rename to lib/assets/javascripts/calendar_date_select/locale/da.js diff --git a/public/javascripts/calendar_date_select/locale/de.js b/lib/assets/javascripts/calendar_date_select/locale/de.js similarity index 100% rename from public/javascripts/calendar_date_select/locale/de.js rename to lib/assets/javascripts/calendar_date_select/locale/de.js diff --git a/public/javascripts/calendar_date_select/locale/es.js b/lib/assets/javascripts/calendar_date_select/locale/es.js similarity index 100% rename from public/javascripts/calendar_date_select/locale/es.js rename to lib/assets/javascripts/calendar_date_select/locale/es.js diff --git a/public/javascripts/calendar_date_select/locale/fi.js b/lib/assets/javascripts/calendar_date_select/locale/fi.js similarity index 100% rename from public/javascripts/calendar_date_select/locale/fi.js rename to lib/assets/javascripts/calendar_date_select/locale/fi.js diff --git a/public/javascripts/calendar_date_select/locale/fr.js b/lib/assets/javascripts/calendar_date_select/locale/fr.js similarity index 100% rename from public/javascripts/calendar_date_select/locale/fr.js rename to lib/assets/javascripts/calendar_date_select/locale/fr.js diff --git a/public/javascripts/calendar_date_select/locale/it.js b/lib/assets/javascripts/calendar_date_select/locale/it.js similarity index 100% rename from public/javascripts/calendar_date_select/locale/it.js rename to lib/assets/javascripts/calendar_date_select/locale/it.js diff --git a/public/javascripts/calendar_date_select/locale/ja.js b/lib/assets/javascripts/calendar_date_select/locale/ja.js similarity index 100% rename from public/javascripts/calendar_date_select/locale/ja.js rename to lib/assets/javascripts/calendar_date_select/locale/ja.js diff --git a/public/javascripts/calendar_date_select/locale/nl.js b/lib/assets/javascripts/calendar_date_select/locale/nl.js similarity index 100% rename from public/javascripts/calendar_date_select/locale/nl.js rename to lib/assets/javascripts/calendar_date_select/locale/nl.js diff --git a/public/javascripts/calendar_date_select/locale/pl.js b/lib/assets/javascripts/calendar_date_select/locale/pl.js similarity index 100% rename from public/javascripts/calendar_date_select/locale/pl.js rename to lib/assets/javascripts/calendar_date_select/locale/pl.js diff --git a/public/javascripts/calendar_date_select/locale/pt.js b/lib/assets/javascripts/calendar_date_select/locale/pt.js similarity index 100% rename from public/javascripts/calendar_date_select/locale/pt.js rename to lib/assets/javascripts/calendar_date_select/locale/pt.js diff --git a/public/javascripts/calendar_date_select/locale/ru.js b/lib/assets/javascripts/calendar_date_select/locale/ru.js similarity index 100% rename from public/javascripts/calendar_date_select/locale/ru.js rename to lib/assets/javascripts/calendar_date_select/locale/ru.js diff --git a/public/javascripts/calendar_date_select/locale/sl.js b/lib/assets/javascripts/calendar_date_select/locale/sl.js similarity index 100% rename from public/javascripts/calendar_date_select/locale/sl.js rename to lib/assets/javascripts/calendar_date_select/locale/sl.js diff --git a/public/javascripts/calendar_date_select/locale/sv.js b/lib/assets/javascripts/calendar_date_select/locale/sv.js similarity index 100% rename from public/javascripts/calendar_date_select/locale/sv.js rename to lib/assets/javascripts/calendar_date_select/locale/sv.js diff --git a/public/stylesheets/calendar_date_select/blue.css b/lib/assets/stylesheets/calendar_date_select/blue.css similarity index 100% rename from public/stylesheets/calendar_date_select/blue.css rename to lib/assets/stylesheets/calendar_date_select/blue.css diff --git a/public/stylesheets/calendar_date_select/default.css b/lib/assets/stylesheets/calendar_date_select/default.css similarity index 100% rename from public/stylesheets/calendar_date_select/default.css rename to lib/assets/stylesheets/calendar_date_select/default.css diff --git a/public/stylesheets/calendar_date_select/green.css b/lib/assets/stylesheets/calendar_date_select/green.css similarity index 100% rename from public/stylesheets/calendar_date_select/green.css rename to lib/assets/stylesheets/calendar_date_select/green.css diff --git a/public/stylesheets/calendar_date_select/plain.css b/lib/assets/stylesheets/calendar_date_select/plain.css similarity index 100% rename from public/stylesheets/calendar_date_select/plain.css rename to lib/assets/stylesheets/calendar_date_select/plain.css diff --git a/public/stylesheets/calendar_date_select/red.css b/lib/assets/stylesheets/calendar_date_select/red.css similarity index 100% rename from public/stylesheets/calendar_date_select/red.css rename to lib/assets/stylesheets/calendar_date_select/red.css diff --git a/public/stylesheets/calendar_date_select/silver.css b/lib/assets/stylesheets/calendar_date_select/silver.css similarity index 100% rename from public/stylesheets/calendar_date_select/silver.css rename to lib/assets/stylesheets/calendar_date_select/silver.css diff --git a/lib/calendar_date_select.rb b/lib/calendar_date_select.rb index d0336db..f5e64ae 100644 --- a/lib/calendar_date_select.rb +++ b/lib/calendar_date_select.rb @@ -8,20 +8,25 @@ module CalendarDateSelect Files = [ - '/public', - '/public/javascripts/calendar_date_select', - '/public/stylesheets/calendar_date_select', - '/public/images/calendar_date_select', - '/public/javascripts/calendar_date_select/locale' + '/lib/assets', + '/lib/assets/javascripts/calendar_date_select', + '/lib/assets/stylesheets/calendar_date_select', + '/lib/assets/images/calendar_date_select', + '/lib/assets/javascripts/calendar_date_select/locale' ] + module Rails + class Engine < ::Rails::Engine + end + end + class Railtie < ::Rails::Railtie initializer 'calendardateselect.initialize', :after => :action_view do ActionView::Helpers::FormHelper.send(:include, CalendarDateSelect::FormHelpers) ActionView::Base.send(:include, CalendarDateSelect::FormHelpers) ActionView::Base.send(:include, CalendarDateSelect::IncludesHelper) - + ActionView::Helpers::InstanceTag.class_eval do class << self; alias new_with_backwards_compatibility new; end #TODO: singleton_class.class_eval end diff --git a/lib/calendar_date_select/calendar_date_select.rb b/lib/calendar_date_select/calendar_date_select.rb index 36b5b68..907c4ae 100644 --- a/lib/calendar_date_select/calendar_date_select.rb +++ b/lib/calendar_date_select/calendar_date_select.rb @@ -1,5 +1,5 @@ module CalendarDateSelect - VERSION = '1.16.2' + VERSION = '1.16.3' FORMATS = { :natural => { diff --git a/lib/calendar_date_select/version.rb b/lib/calendar_date_select/version.rb new file mode 100644 index 0000000..92591c8 --- /dev/null +++ b/lib/calendar_date_select/version.rb @@ -0,0 +1,5 @@ +module CalendarDateSelect + module Rails + VERSION = "1.16.3" + end +end From 12cadca0e3ea4d70f1a9c3773faa56d991974175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Azimi?= Date: Tue, 12 Jun 2012 16:23:09 +0200 Subject: [PATCH 04/10] gemspec paths fixed and Rails 3 asset install added to README. --- README.mkd | 36 ++++++++++++++++++++++ README.txt | 17 ----------- calendar_date_select.gemspec | 58 ++++++++++++++++++------------------ 3 files changed, 65 insertions(+), 46 deletions(-) create mode 100644 README.mkd delete mode 100644 README.txt diff --git a/README.mkd b/README.mkd new file mode 100644 index 0000000..7718b5b --- /dev/null +++ b/README.mkd @@ -0,0 +1,36 @@ +# CalendarDateSelect + +http://code.google.com/p/calendardateselect/ + +This project is looking for a new maintainer. Please contact me if you have sufficient interest in this project to move it forward. + +## Examples + +"See a demo here":http://electronicholas.com/calendar + +## Assets in Rails 3.1 or greater (with asset pipeline *enabled*) + +The asset files will be added to the asset pipeline and available for you to use. Add these lines in `app/assets/javascripts/application.js`: + +```js +//= require calendar_date_select +``` +*Optional*: Include your locale: +```js +//= require calendar_date_select/locale/fr +``` + +And add in your `app/assets/stylesheets/application.css`: +```css +/* + *= require calendar_date_select/default + */ +``` + +## Submitting patches + +Please take care to do the following: + +* Clean up your patch (don't send a patch bomb with a hundred features in one) +* Write test cases! +* As a general rule of thumb, think of ways to make things more general purpose than specific. diff --git a/README.txt b/README.txt deleted file mode 100644 index 5ee1dbd..0000000 --- a/README.txt +++ /dev/null @@ -1,17 +0,0 @@ -= CalendarDateSelect - -http://code.google.com/p/calendardateselect/ - -* This project is looking for a new maintainer. Please contact me if you have sufficient interest in this project to move it forward. - -== Examples - -"See a demo here":http://electronicholas.com/calendar - -== Submitting patches - -Please take care to do the following: - -* Clean up your patch (don't send a patch bomb with a hundred features in one) -* Write test cases! -* As a general rule of thumb, think of ways to make things more general purpose than specific. diff --git a/calendar_date_select.gemspec b/calendar_date_select.gemspec index 64e1186..fc98e70 100644 --- a/calendar_date_select.gemspec +++ b/calendar_date_select.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |s| "History.txt", "MIT-LICENSE", "Manifest.txt", - "README.txt", + "README.mkd", "Rakefile", "VERSION", "calendar_date_select.gemspec", @@ -36,35 +36,35 @@ Gem::Specification.new do |s| "lib/calendar_date_select/form_helpers.rb", "lib/calendar_date_select/includes_helper.rb", "public/blank_iframe.html", - "lib/assets/images/calendar.gif", + "lib/assets/images/calendar_date_select/calendar.gif", "lib/assets/javascripts/calendar_date_select.js", - "lib/assets/javascripts/format_american.js", - "lib/assets/javascripts/format_danish.js", - "lib/assets/javascripts/format_db.js", - "lib/assets/javascripts/format_euro_24hr.js", - "lib/assets/javascripts/format_euro_24hr_ymd.js", - "lib/assets/javascripts/format_finnish.js", - "lib/assets/javascripts/format_hyphen_ampm.js", - "lib/assets/javascripts/format_iso_date.js", - "lib/assets/javascripts/format_italian.js", - "lib/assets/javascripts/locale/ar.js", - "lib/assets/javascripts/locale/da.js", - "lib/assets/javascripts/locale/de.js", - "lib/assets/javascripts/locale/es.js", - "lib/assets/javascripts/locale/fi.js", - "lib/assets/javascripts/locale/fr.js", - "lib/assets/javascripts/locale/it.js", - "lib/assets/javascripts/locale/nl.js", - "lib/assets/javascripts/locale/pl.js", - "lib/assets/javascripts/locale/pt.js", - "lib/assets/javascripts/locale/ru.js", - "lib/assets/javascripts/locale/sl.js", - "lib/assets/stylesheets/blue.css", - "lib/assets/stylesheets/default.css", - "lib/assets/stylesheets/green.css", - "lib/assets/stylesheets/plain.css", - "lib/assets/stylesheets/red.css", - "lib/assets/stylesheets/silver.css", + "lib/assets/javascripts/calendar_date_select/format_american.js", + "lib/assets/javascripts/calendar_date_select/format_danish.js", + "lib/assets/javascripts/calendar_date_select/format_db.js", + "lib/assets/javascripts/calendar_date_select/format_euro_24hr.js", + "lib/assets/javascripts/calendar_date_select/format_euro_24hr_ymd.js", + "lib/assets/javascripts/calendar_date_select/format_finnish.js", + "lib/assets/javascripts/calendar_date_select/format_hyphen_ampm.js", + "lib/assets/javascripts/calendar_date_select/format_iso_date.js", + "lib/assets/javascripts/calendar_date_select/format_italian.js", + "lib/assets/javascripts/calendar_date_select/locale/ar.js", + "lib/assets/javascripts/calendar_date_select/locale/da.js", + "lib/assets/javascripts/calendar_date_select/locale/de.js", + "lib/assets/javascripts/calendar_date_select/locale/es.js", + "lib/assets/javascripts/calendar_date_select/locale/fi.js", + "lib/assets/javascripts/calendar_date_select/locale/fr.js", + "lib/assets/javascripts/calendar_date_select/locale/it.js", + "lib/assets/javascripts/calendar_date_select/locale/nl.js", + "lib/assets/javascripts/calendar_date_select/locale/pl.js", + "lib/assets/javascripts/calendar_date_select/locale/pt.js", + "lib/assets/javascripts/calendar_date_select/locale/ru.js", + "lib/assets/javascripts/calendar_date_select/locale/sl.js", + "lib/assets/stylesheets/calendar_date_select/blue.css", + "lib/assets/stylesheets/calendar_date_select/default.css", + "lib/assets/stylesheets/calendar_date_select/green.css", + "lib/assets/stylesheets/calendar_date_select/plain.css", + "lib/assets/stylesheets/calendar_date_select/red.css", + "lib/assets/stylesheets/calendar_date_select/silver.css", "spec/calendar_date_select/calendar_date_select_spec.rb", "spec/calendar_date_select/form_helpers_spec.rb", "spec/calendar_date_select/includes_helper_spec.rb", From b49097bcde8d5b511bd02e13a9a0b59c6f9a7d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Azimi?= Date: Tue, 12 Jun 2012 17:28:50 +0200 Subject: [PATCH 05/10] gemspec extra_rdoc_file removed. --- calendar_date_select.gemspec | 3 --- 1 file changed, 3 deletions(-) diff --git a/calendar_date_select.gemspec b/calendar_date_select.gemspec index fc98e70..83f8405 100644 --- a/calendar_date_select.gemspec +++ b/calendar_date_select.gemspec @@ -12,9 +12,6 @@ Gem::Specification.new do |s| s.date = %q{2010-03-29} s.description = %q{Calendar date picker for rails} s.email = %q{} - s.extra_rdoc_files = [ - "README.txt" - ] s.files = [ ".gitignore", "History.txt", From c80b6a2e940a6ada7f302ee244046731eb0c8c35 Mon Sep 17 00:00:00 2001 From: Brian Cheung Date: Wed, 9 Apr 2014 07:27:44 -0400 Subject: [PATCH 06/10] Updating CalendarDateSelect::FormHelpers to be rails 4 compliant --- lib/calendar_date_select/form_helpers.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/calendar_date_select/form_helpers.rb b/lib/calendar_date_select/form_helpers.rb index 4b6f995..6bb59ad 100644 --- a/lib/calendar_date_select/form_helpers.rb +++ b/lib/calendar_date_select/form_helpers.rb @@ -143,9 +143,13 @@ def calendar_date_select(object, method, options={}) end end - tag = ActionView::Helpers::InstanceTag.new_with_backwards_compatibility(object, method, self, options.delete(:object)) + + options.delete(:object) + options.merge(:type => (javascript_options[:hidden] || javascript_options[:embedded]) ? "hidden" : "text") + tag = ActionView::Helpers::Tags::TextField.new(object, method, self, options).render + calendar_date_select_output( - tag.to_input_field_tag( (javascript_options[:hidden] || javascript_options[:embedded]) ? "hidden" : "text", options), + tag, image, options, javascript_options @@ -202,16 +206,17 @@ def calendar_date_select_process_options(options) end def calendar_date_select_output(input, image, options = {}, javascript_options = {}) - out = input + out = [input] + if javascript_options[:embedded] uniq_id = "cds_placeholder_#{(rand*100000).to_i}" # we need to be able to locate the target input element, so lets stick an invisible span tag here we can easily locate out << content_tag(:span, nil, :style => "display: none; position: absolute;", :id => uniq_id) - out << javascript_tag("new CalendarDateSelect( $('#{uniq_id}').previous(), #{options_for_javascript(javascript_options)} ); ") + out << javascript_tag("new CalendarDateSelect( $('#{uniq_id}').previous(), #{"{#{javascript_options.keys.map { |k| "#{k}:#{javascript_options[k]}" }.sort.join(', ')}}"} ); ") else out << " " out << image_tag(image, - :onclick => "new CalendarDateSelect( $(this).previous(), #{options_for_javascript(javascript_options)} );", + :onclick => "new CalendarDateSelect( $(this).previous(), #{"{#{javascript_options.keys.map { |k| "#{k}:#{javascript_options[k]}" }.sort.join(', ')}}"} );", :style => 'border:0px; cursor:pointer;', :class=>'calendar_date_select_popup_icon') end From 728d38b964ef7124ae2f54650f7ab867e2258ad8 Mon Sep 17 00:00:00 2001 From: Brian Cheung Date: Wed, 9 Apr 2014 07:39:33 -0400 Subject: [PATCH 07/10] Fixing form helpers for rails 4 compatibility --- lib/calendar_date_select/form_helpers.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/calendar_date_select/form_helpers.rb b/lib/calendar_date_select/form_helpers.rb index 6bb59ad..e53fb25 100644 --- a/lib/calendar_date_select/form_helpers.rb +++ b/lib/calendar_date_select/form_helpers.rb @@ -206,7 +206,8 @@ def calendar_date_select_process_options(options) end def calendar_date_select_output(input, image, options = {}, javascript_options = {}) - out = [input] + + out = input if javascript_options[:embedded] uniq_id = "cds_placeholder_#{(rand*100000).to_i}" From 1eeaad9b95877a122e85e94a76e0bb09c87a6b58 Mon Sep 17 00:00:00 2001 From: Brian Cheung Date: Wed, 23 Apr 2014 12:59:04 -0400 Subject: [PATCH 08/10] Adding prototype-rails to gem dependencies --- calendar_date_select.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/calendar_date_select.gemspec b/calendar_date_select.gemspec index 49b0065..8cb469e 100644 --- a/calendar_date_select.gemspec +++ b/calendar_date_select.gemspec @@ -81,6 +81,7 @@ Gem::Specification.new do |s| "spec/calendar_date_select/includes_helper_spec.rb", "spec/spec_helper.rb" ] + s.add_dependency 'prototype-rails' if s.respond_to? :specification_version then current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION From fda11a0362fa9ac543fe533c5059a88376264a22 Mon Sep 17 00:00:00 2001 From: Brian Cheung Date: Tue, 6 May 2014 13:01:43 -0400 Subject: [PATCH 09/10] Updating gemspec --- calendar_date_select.gemspec | 65 +++++++++++++++-------------- lib/calendar_date_select/version.rb | 2 +- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/calendar_date_select.gemspec b/calendar_date_select.gemspec index 8e6724d..8cb469e 100644 --- a/calendar_date_select.gemspec +++ b/calendar_date_select.gemspec @@ -5,19 +5,22 @@ Gem::Specification.new do |s| s.name = %q{calendar_date_select} - s.version = "1.16.3" + s.version = "1.16.2" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Shih-gian Lee", "Enrique Garcia Cota (kikito)", "Tim Charper", "Lars E. Hoeg"] s.date = %q{2010-03-29} s.description = %q{Calendar date picker for rails} s.email = %q{} + s.extra_rdoc_files = [ + "README.txt" + ] s.files = [ ".gitignore", "History.txt", "MIT-LICENSE", "Manifest.txt", - "README.mkd", + "README.txt", "Rakefile", "VERSION", "calendar_date_select.gemspec", @@ -33,35 +36,35 @@ Gem::Specification.new do |s| "lib/calendar_date_select/form_helpers.rb", "lib/calendar_date_select/includes_helper.rb", "public/blank_iframe.html", - "lib/assets/images/calendar_date_select/calendar.gif", - "lib/assets/javascripts/calendar_date_select.js", - "lib/assets/javascripts/calendar_date_select/format_american.js", - "lib/assets/javascripts/calendar_date_select/format_danish.js", - "lib/assets/javascripts/calendar_date_select/format_db.js", - "lib/assets/javascripts/calendar_date_select/format_euro_24hr.js", - "lib/assets/javascripts/calendar_date_select/format_euro_24hr_ymd.js", - "lib/assets/javascripts/calendar_date_select/format_finnish.js", - "lib/assets/javascripts/calendar_date_select/format_hyphen_ampm.js", - "lib/assets/javascripts/calendar_date_select/format_iso_date.js", - "lib/assets/javascripts/calendar_date_select/format_italian.js", - "lib/assets/javascripts/calendar_date_select/locale/ar.js", - "lib/assets/javascripts/calendar_date_select/locale/da.js", - "lib/assets/javascripts/calendar_date_select/locale/de.js", - "lib/assets/javascripts/calendar_date_select/locale/es.js", - "lib/assets/javascripts/calendar_date_select/locale/fi.js", - "lib/assets/javascripts/calendar_date_select/locale/fr.js", - "lib/assets/javascripts/calendar_date_select/locale/it.js", - "lib/assets/javascripts/calendar_date_select/locale/nl.js", - "lib/assets/javascripts/calendar_date_select/locale/pl.js", - "lib/assets/javascripts/calendar_date_select/locale/pt.js", - "lib/assets/javascripts/calendar_date_select/locale/ru.js", - "lib/assets/javascripts/calendar_date_select/locale/sl.js", - "lib/assets/stylesheets/calendar_date_select/blue.css", - "lib/assets/stylesheets/calendar_date_select/default.css", - "lib/assets/stylesheets/calendar_date_select/green.css", - "lib/assets/stylesheets/calendar_date_select/plain.css", - "lib/assets/stylesheets/calendar_date_select/red.css", - "lib/assets/stylesheets/calendar_date_select/silver.css", + "public/images/calendar_date_select/calendar.gif", + "public/javascripts/calendar_date_select/calendar_date_select.js", + "public/javascripts/calendar_date_select/format_american.js", + "public/javascripts/calendar_date_select/format_danish.js", + "public/javascripts/calendar_date_select/format_db.js", + "public/javascripts/calendar_date_select/format_euro_24hr.js", + "public/javascripts/calendar_date_select/format_euro_24hr_ymd.js", + "public/javascripts/calendar_date_select/format_finnish.js", + "public/javascripts/calendar_date_select/format_hyphen_ampm.js", + "public/javascripts/calendar_date_select/format_iso_date.js", + "public/javascripts/calendar_date_select/format_italian.js", + "public/javascripts/calendar_date_select/locale/ar.js", + "public/javascripts/calendar_date_select/locale/da.js", + "public/javascripts/calendar_date_select/locale/de.js", + "public/javascripts/calendar_date_select/locale/es.js", + "public/javascripts/calendar_date_select/locale/fi.js", + "public/javascripts/calendar_date_select/locale/fr.js", + "public/javascripts/calendar_date_select/locale/it.js", + "public/javascripts/calendar_date_select/locale/nl.js", + "public/javascripts/calendar_date_select/locale/pl.js", + "public/javascripts/calendar_date_select/locale/pt.js", + "public/javascripts/calendar_date_select/locale/ru.js", + "public/javascripts/calendar_date_select/locale/sl.js", + "public/stylesheets/calendar_date_select/blue.css", + "public/stylesheets/calendar_date_select/default.css", + "public/stylesheets/calendar_date_select/green.css", + "public/stylesheets/calendar_date_select/plain.css", + "public/stylesheets/calendar_date_select/red.css", + "public/stylesheets/calendar_date_select/silver.css", "spec/calendar_date_select/calendar_date_select_spec.rb", "spec/calendar_date_select/form_helpers_spec.rb", "spec/calendar_date_select/includes_helper_spec.rb", diff --git a/lib/calendar_date_select/version.rb b/lib/calendar_date_select/version.rb index 92591c8..fb3a94a 100644 --- a/lib/calendar_date_select/version.rb +++ b/lib/calendar_date_select/version.rb @@ -1,5 +1,5 @@ module CalendarDateSelect module Rails - VERSION = "1.16.3" + VERSION = "1.2.0" end end From 56ac24ea6912b54567bd04ef5c8bdc40eb18c570 Mon Sep 17 00:00:00 2001 From: Brian Cheung Date: Mon, 13 Jul 2015 09:21:38 -0400 Subject: [PATCH 10/10] Modifies the input tag to fire off the helper modal onclick. Ruby 1.9 and greater changed the manner in which slashed numerical dates are parsed. 1.8.7 parsed slashed dates as mm/dd/yyyy, 1.9.1+ parses them as dd/mm/yyyy. As a result, users who bypass the calendar_date_select helper modal and manually enter dates into the form input with American format (mm/dd/yyyy) could result in incorrect data being written to the database or an ArgumentError: argument out of range. --- lib/calendar_date_select/form_helpers.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/calendar_date_select/form_helpers.rb b/lib/calendar_date_select/form_helpers.rb index e53fb25..24a5f1e 100644 --- a/lib/calendar_date_select/form_helpers.rb +++ b/lib/calendar_date_select/form_helpers.rb @@ -102,6 +102,7 @@ def calendar_date_select_tag( name, value = nil, options = {}) javascript_options.delete(:format) options[:id] ||= name + options.merge!(:onclick => "new CalendarDateSelect( $(this), #{"{#{javascript_options.keys.map { |k| "#{k}:#{javascript_options[k]}" }.sort.join(', ')}}"} );") tag = javascript_options[:hidden] || javascript_options[:embedded] ? hidden_field_tag(name, value, options) : text_field_tag(name, value, options) @@ -145,9 +146,10 @@ def calendar_date_select(object, method, options={}) options.delete(:object) - options.merge(:type => (javascript_options[:hidden] || javascript_options[:embedded]) ? "hidden" : "text") + options.merge!(:type => (javascript_options[:hidden] || javascript_options[:embedded]) ? "hidden" : "text") + options.merge!(:onclick => "new CalendarDateSelect( $(this), #{"{#{javascript_options.keys.map { |k| "#{k}:#{javascript_options[k]}" }.sort.join(', ')}}"} );") tag = ActionView::Helpers::Tags::TextField.new(object, method, self, options).render - + calendar_date_select_output( tag, image, @@ -206,7 +208,6 @@ def calendar_date_select_process_options(options) end def calendar_date_select_output(input, image, options = {}, javascript_options = {}) - out = input if javascript_options[:embedded]