Permalink
Browse files

First Commit

  • Loading branch information...
elandesign committed Oct 16, 2009
0 parents commit 12ccd7b4267b3f9be173c29ce15e974ea7786a05
@@ -0,0 +1,20 @@
+Copyright (c) 2009 Paul Smith
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,40 @@
+h1. FormtasticEnum
+
+An extension for Formtastic[1] to generate lightweight javascript calendar date inputs using the Rails Date Kit[2]
+
+h2. Example
+
+Where Task#due_date is a :date field
+
+<pre><code><% semantic_form_for @task do |form| %>
+ <% form.inputs do %>
+ <%= form.input :due_date, :as => :calendar
+ <% end %>
+<% end %></code></pre>
+
+h2. Dependencies
+
+You must have the formtastic gem/plugin added to your application.
+
+Required images, javascript and stylesheet can be installed using the generator:
+
+<pre><code>./script/generate formtastic_calendar</code></pre>
+
+Don't forget to add them to your application layout
+
+<pre><code><%= stylesheet_link_tag 'calendar' %>
+<%= javascript_include_tag 'calendar' %></code></pre>
+
+h2. Todo
+
+Test, test, test...
+
+Attempt to port this to unobtrusive javascript, and provide graceful degradation if possible.
+
+h2. References
+
+fn1. "Formtastic @ GitHub":http://github.com/justinfrench/formtastic
+
+fn2. "Rails Date Kit":http://www.methods.co.nz/rails_date_kit/rails_date_kit.html
+
+Copyright (c) 2009 Paul Smith, released under the MIT license
@@ -0,0 +1,23 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the formtastic_calendar plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.libs << 'test'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the formtastic_calendar plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'FormtasticCalendar'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
@@ -0,0 +1,15 @@
+class FormtasticCalendarGenerator < Rails::Generator::Base
+
+ def manifest
+ record do |m|
+ m.directory 'public/images'
+ m.file 'calendar_prev.png', 'public/images/calendar_prev.png'
+ m.file 'calendar_next.png', 'public/images/calendar_next.png'
+ m.directory 'public/stylesheets'
+ m.file 'calendar.css', 'public/stylesheets/calendar.css'
+ m.directory 'public/javascripts'
+ m.file 'calendar.js', 'public/javascripts/calendar.js'
+ m.readme 'README'
+ end
+ end
+end
@@ -0,0 +1,6 @@
+
+
+Don't forget to include the javascript and stylesheet in your application.html.erb
+<%= stylesheet_link_tag 'calendar' %>
+<%= javascript_include_tag 'calendar' %>
+
@@ -0,0 +1,16 @@
+/* formtastic_calendar.js stylesheet */
+form.formtastic table#calendar_control{z-index:10;font-family:Arial;position:absolute;border-collapse:collapse;background:white;border:1px solid silver;cursor:default;}
+form.formtastic table#calendar_control td{text-align:center;vertical-align:middle;padding:2px;}
+form.formtastic td#calendar_prev_month,td#calendar_next_month,
+form.formtastic td#calendar_prev_year,td#calendar_next_year{cursor:pointer;}
+form.formtastic table#calendar_control td#calendar_prev_month{text-align:left;}
+form.formtastic table#calendar_control td#calendar_next_month{text-align:right;}
+form.formtastic td#calendar_header{font-size:13px;font-weight:bold;}
+form.formtastic table#calendar_control td.day_letter{font-size:10px;background:gainsboro;}
+form.formtastic table#calendar_control td.day_number{width:22px;height:20px;font-size:12px;color:#333333;text-align:center;border:1px solid #6487ae;cursor:pointer;}
+form.formtastic table#calendar_control td.normal{background:#c4d3ea;}
+form.formtastic table#calendar_control td.blank{background:aliceblue;background:#d4e3fa;}
+form.formtastic table#calendar_control td.hover{background:#fff799;}
+form.formtastic table#calendar_control td.selected{background:#ffcc66;}
+form.formtastic table#calendar_control td.weekend{color:blue;}
+form.formtastic table#calendar_control td.today{color:red;}
Oops, something went wrong.

0 comments on commit 12ccd7b

Please sign in to comment.