From b867c5bcb0f26412eb6faa8d369c7c661283d79a Mon Sep 17 00:00:00 2001 From: Smudge Date: Tue, 21 Jul 2009 14:38:09 -0400 Subject: [PATCH 01/59] working on huzza the time slotz --- app/views/time_slots/_form.html.erb | 26 +++++++++++++++++---- app/views/time_slots/index.html.erb | 36 ----------------------------- 2 files changed, 22 insertions(+), 40 deletions(-) diff --git a/app/views/time_slots/_form.html.erb b/app/views/time_slots/_form.html.erb index 60a9ac3d..b85374b2 100644 --- a/app/views/time_slots/_form.html.erb +++ b/app/views/time_slots/_form.html.erb @@ -6,12 +6,30 @@

<%= f.label :start %>
- <%= f.datetime_select :start %> + <%= time_select :start_in_minutes, {:minute_step => 15} %>

<%= f.label :end %>
- <%= f.datetime_select :end %> + <%= time_select :end, {:minute_step => 15} %>

-

<%= f.submit "Submit" %>

+ <% @department.loc_groups.each do |loc_group| %> + <% unless loc_group.locations.empty? %> +

+ <%= loc_group.name %>
+ <% loc_group.locations.each do |loc| %> + <%= check_box_tag "location_ids[]", loc.id, false, {:id => "location_#{loc.id}"} %> + <%= loc.short_name %> + <% end %> +

+ <% end %> + <%- end -%> +

+

+ Days:
+ <% WEEK_DAYS.each_with_index do |day, i| %> + <%= check_box_tag "days[]", i, false, {:id => "days_#{i}"} %> + <%= day %> + <% end %> +

+

<%= f.submit "Add" %>

<% end %> - diff --git a/app/views/time_slots/index.html.erb b/app/views/time_slots/index.html.erb index 02983d5f..b038c685 100644 --- a/app/views/time_slots/index.html.erb +++ b/app/views/time_slots/index.html.erb @@ -12,42 +12,6 @@ -
- <% form_for :mass_create do |f|%> -
- Add new time slots to the week (TODO: make this work) - -

- Start: <%= f.time_select :start_in_minute, {:minute_step => 15} %><%#= f.select :start_in_minute, @time_choices_select %> - End: <%= f.time_select :start_in_minute, {:minute_step => 15} %><%#= f.select :end_in_minute, @time_choices_select, {:selected => @time_choices_select.last[1]} %> -

- -

in Locations: - <% @department.loc_groups.each do |loc_group| %> -

- <%= loc_group.name %> - <% loc_group.locations.each do |loc| %> - <%= check_box_tag "location_ids[]", loc.id, false, {:id => "location_#{loc.id}"} %> - <%= loc.short_name %> - <% end %> -
- <%- end -%> -

- -

for Days: - <% WEEK_DAYS.each_with_index do |day, i| %> - <%= check_box_tag "days[]", i, false, {:id => "days_#{i}"} %> <%#>, :disabled => i < Date.today} %> - <%= day %> - <% end %> -

- - <%= hidden_field_tag :date, params[:date]%> - <%= submit_tag 'Add' %> - - <% end %> -
-
-
<%= render :partial => 'shifts/schedule/header' %> From b33c062f516fe8559842666cf27d2e8e41799633 Mon Sep 17 00:00:00 2001 From: Smudge Date: Tue, 21 Jul 2009 16:20:50 -0400 Subject: [PATCH 02/59] hmm --- app/controllers/time_slots_controller.rb | 23 +++++++++------------- app/views/shifts/schedule/_header.html.erb | 4 ++-- app/views/time_slots/_form.html.erb | 8 ++------ app/views/time_slots/index.html.erb | 4 +--- 4 files changed, 14 insertions(+), 25 deletions(-) diff --git a/app/controllers/time_slots_controller.rb b/app/controllers/time_slots_controller.rb index 854f31f7..ac813dd4 100644 --- a/app/controllers/time_slots_controller.rb +++ b/app/controllers/time_slots_controller.rb @@ -4,9 +4,7 @@ class TimeSlotsController < ApplicationController def index @time_slots = TimeSlot.all - #TODO: figure out where this should go... - @period_start = Time.parse("last Sunday") - @days_per_period = 7 + @period_start = params[:date].blank? ? Date.parse("last Sunday") : Date.parse(params[:date]) end def show @@ -18,12 +16,14 @@ def new end def create - @time_slot = TimeSlot.new(params[:time_slot]) - if @time_slot.save - flash[:notice] = "Successfully created timeslot." - redirect_to @time_slot - else - render :action => 'new' + @time_slot = TimeSlot.new + for date in params[:days] + if @time_slot.save + flash[:notice] = "Successfully created timeslot." + redirect_to @time_slot + else + render :action => 'new' + end end end @@ -41,11 +41,6 @@ def update end end -#TODO We probably don't need this, it'll be handled by templates.... -# def mass_create -# TimeSlot.mass_create(slot_start, slot_end, days, locations, range_start, range_end) -# end - def destroy @time_slot = TimeSlot.find(params[:id]) @time_slot.destroy diff --git a/app/views/shifts/schedule/_header.html.erb b/app/views/shifts/schedule/_header.html.erb index b63107a7..2b3b3f0b 100644 --- a/app/views/shifts/schedule/_header.html.erb +++ b/app/views/shifts/schedule/_header.html.erb @@ -8,6 +8,6 @@
- <%= @period_start.to_s(:just_date_long) %> to <%= (@period_start + 6).to_s(:just_date_long) %> + <%= @period_start.to_s(:just_date_long) %> to <%= (@period_start + 6.days).to_s(:just_date_long) %>
- \ No newline at end of file + diff --git a/app/views/time_slots/_form.html.erb b/app/views/time_slots/_form.html.erb index b85374b2..96a3fb3d 100644 --- a/app/views/time_slots/_form.html.erb +++ b/app/views/time_slots/_form.html.erb @@ -1,16 +1,12 @@ <% form_for @time_slot do |f| %> <%= f.error_messages %> -

- <%= f.label :location %>
- <%= select_tag 'time_slot[location_id]', option_groups_from_collection_for_select(@department.loc_groups, :locations, :name, :id, :name, @time_slot.location ? @time_slot.location.id : nil)%>
-

<%= f.label :start %>
- <%= time_select :start_in_minutes, {:minute_step => 15} %> + <%= select_time Time.now, :minute_step => current_department.department_config.time_increment, :ignore_date => true %>

<%= f.label :end %>
- <%= time_select :end, {:minute_step => 15} %> + <%= select_time Time.now+1.hour, :minute_step => current_department.department_config.time_increment, :ignore_date => true %>

<% @department.loc_groups.each do |loc_group| %> <% unless loc_group.locations.empty? %> diff --git a/app/views/time_slots/index.html.erb b/app/views/time_slots/index.html.erb index b038c685..6d858a2e 100644 --- a/app/views/time_slots/index.html.erb +++ b/app/views/time_slots/index.html.erb @@ -1,8 +1,6 @@ <% title "Time Slots" %> -

<%= link_to "New Time Slot", new_time_slot_path %>

- -

Nothing Below Here Works. Use the link above

+

<%= link_to "

New Time Slot

", new_time_slot_path %>

Notes From fd4097d0cf321ac1868d481ab961cd12badf3f11 Mon Sep 17 00:00:00 2001 From: Smudge Date: Tue, 21 Jul 2009 17:23:05 -0400 Subject: [PATCH 03/59] time slots work --- app/controllers/time_slots_controller.rb | 1 + app/helpers/shifts_helper.rb | 2 +- app/views/dashboard/_mini_payform.html.erb | 40 +++++++------- app/views/layouts/dashboard.html.erb | 2 +- app/views/layouts/payforms.html.erb | 14 ++--- app/views/layouts/shifts.html.erb | 2 +- app/views/notices/_form.html.erb | 4 +- .../reports/_new_report_item_form.html.erb | 17 ++++++ app/views/reports/_report.html.erb | 55 +++++-------------- app/views/reports/show.html.erb | 28 +++++----- app/views/restrictions/_form.html.erb | 8 +-- app/views/shifts/tooltips/_edit.html.erb | 4 +- app/views/shifts/tooltips/_new.html.erb | 4 +- app/views/sub_requests/_form.html.erb | 8 +-- app/views/time_slots/_form.html.erb | 4 +- features/payform_admin_test.feature | 8 +-- public/stylesheets/application.css | 14 ++--- 17 files changed, 103 insertions(+), 112 deletions(-) diff --git a/app/controllers/time_slots_controller.rb b/app/controllers/time_slots_controller.rb index ac813dd4..3f504c71 100644 --- a/app/controllers/time_slots_controller.rb +++ b/app/controllers/time_slots_controller.rb @@ -17,6 +17,7 @@ def new def create @time_slot = TimeSlot.new + for date in params[:days] if @time_slot.save flash[:notice] = "Successfully created timeslot." diff --git a/app/helpers/shifts_helper.rb b/app/helpers/shifts_helper.rb index 2a688e1d..648f05d1 100644 --- a/app/helpers/shifts_helper.rb +++ b/app/helpers/shifts_helper.rb @@ -254,7 +254,7 @@ def print_cell(type,from,to,shift=nil,content = "", render_pass = -1, overflow = link_name = "view" #view_action = shift_report_path(shift)#"view_float" #TODO: render without layout - url_options = {:controller => 'reports', :action => 'popup', :id => shift.report, :TB_iframe => true, :popup => true, :width => 450} + url_options = {:controller => 'reports', :action => 'popup', :id => shift.report, :TB_iframe => true, :width => 450} html_options = {:class => 'thickbox', :rel => 'shift_reports'} end diff --git a/app/views/dashboard/_mini_payform.html.erb b/app/views/dashboard/_mini_payform.html.erb index 713e1eff..de4c6614 100644 --- a/app/views/dashboard/_mini_payform.html.erb +++ b/app/views/dashboard/_mini_payform.html.erb @@ -1,22 +1,20 @@ - - - - - -<% mini_payform.payform_items.each do |item| %> -<% if item.active %> - - - - - -<% end %> -<% end %> - - - -
DateDescriptionHours
<%= item.date.strftime('%b %d') %><%= item.description %><%= item.hours.to_s %>
Total: - - <%= mini_payform.hours %>
- + + Date + Description + Hours + + <% mini_payform.payform_items.each do |item| %> + <% if item.active %> + + <%= item.date.strftime('%b %d') %> + <%= item.description %> + <%= item.hours.round(1).to_s %> + + <% end %> + <% end %> + + Total: + <%= mini_payform.hours.round(1) %> + + \ No newline at end of file diff --git a/app/views/layouts/dashboard.html.erb b/app/views/layouts/dashboard.html.erb index acdd3fe4..21adf7c4 100644 --- a/app/views/layouts/dashboard.html.erb +++ b/app/views/layouts/dashboard.html.erb @@ -1,6 +1,6 @@ <% content_for :head do %> <%= stylesheet_link_tag 'shift', 'report', 'notice', 'tokeninput-facebook', 'thickbox' %> - <%= javascript_include_tag 'thickbox-compressed', 'jquery.tokeninput', 'checkboxtest' %> + <%= javascript_include_tag 'jquery.tokeninput', 'checkboxtest' %> <% end %> <% content_for :left_nav do %> diff --git a/app/views/layouts/payforms.html.erb b/app/views/layouts/payforms.html.erb index 90cda9a6..fc4d8e42 100644 --- a/app/views/layouts/payforms.html.erb +++ b/app/views/layouts/payforms.html.erb @@ -1,10 +1,10 @@ -<% content_for :head do %> - <%= javascript 'jquery', 'jquery-ui', 'jrails', 'thickbox-compressed' %> - <%= stylesheet 'thickbox', 'payforms' %> +<% content_for :head do %> + <%= javascript 'jquery', 'jquery-ui', 'jrails' %> + <%= stylesheet 'thickbox', 'payforms' %> <% end %> - - + + <% if current_user.is_admin_of?(current_department) %> <% content_for :left_nav do %>
\ No newline at end of file diff --git a/app/views/reports/show.html.erb b/app/views/reports/show.html.erb index 77614fb9..5bd9d26e 100644 --- a/app/views/reports/show.html.erb +++ b/app/views/reports/show.html.erb @@ -1,21 +1,21 @@ <% stylesheet 'report', 'notice' %> <% title "Shift Report at the #{@report.shift.location.name}" %> -
-Message Center -<%= render :partial => 'notices/notice', :collection => @report.get_notices %> -
-
- <%= link_to_post_a_new_notice %> -
-
-
-

+<% unless @report.departed || current_user != @report.user %>

- Data Objects - <%= render :partial => 'data_objects/report_form', :collection => @report.get_data_objects %> + Message Center + <%= render :partial => 'notices/notice', :collection => @report.get_notices %> +
+
+ <%= link_to_post_a_new_notice %> +
+
-

-<% unless @report.departed || current_user!=@report.user %> + +
+ Data Objects + <%= render :partial => 'data_objects/report_form', :collection => @report.get_data_objects %> +
+ <%= render :partial => 'new_report_item_form' %> <% end %>

Report:

diff --git a/app/views/restrictions/_form.html.erb b/app/views/restrictions/_form.html.erb index eadf0d30..ed89d264 100644 --- a/app/views/restrictions/_form.html.erb +++ b/app/views/restrictions/_form.html.erb @@ -1,12 +1,12 @@ <% form_for @restriction do |f| %> <%= f.error_messages %>

- <%= f.label :starts %>
- <%= f.datetime_select :starts %> + <%= f.label :starts, :minute_step => @department.department_config.time_increment, :twelve_hour => true %>
+ <%= f.datetime_select :starts, :minute_step => @department.department_config.time_increment, :twelve_hour => true %>

- <%= f.label :expires %>
- <%= f.datetime_select :expires %> + <%= f.label :expires, :minute_step => @department.department_config.time_increment, :twelve_hour => true %>
+ <%= f.datetime_select :expires, :minute_step => @department.department_config.time_increment, :twelve_hour => true %>

<%= f.label :max_subs %>
diff --git a/app/views/shifts/tooltips/_edit.html.erb b/app/views/shifts/tooltips/_edit.html.erb index f46854ef..1dcfea7b 100644 --- a/app/views/shifts/tooltips/_edit.html.erb +++ b/app/views/shifts/tooltips/_edit.html.erb @@ -3,11 +3,11 @@ <%= f.error_messages %>

<%= f.label :start %>
- <%= f.datetime_select :start, :minute_step => 15 %> + <%= f.datetime_select :start, :minute_step => @department.department_config.time_increment, :twelve_hour => true %>

<%= f.label :end %>
- <%= f.datetime_select :end, :minute_step => 15 %> + <%= f.datetime_select :end, :minute_step => @department.department_config.time_increment, :twelve_hour => true %>

<% if current_user.is_admin_of?(@department) %>

diff --git a/app/views/shifts/tooltips/_new.html.erb b/app/views/shifts/tooltips/_new.html.erb index 4d739d20..9fe96fc1 100644 --- a/app/views/shifts/tooltips/_new.html.erb +++ b/app/views/shifts/tooltips/_new.html.erb @@ -11,12 +11,12 @@ $(this).prev().prev().datepicker() alert($(this).prev().class); --> - <%= f.time_select :start, :minute_step => 15, :twelve_hour => true %> + <%= f.time_select :start, :minute_step => @department.department_config.time_increment, :twelve_hour => true %>

<%= f.label :end %>
<%= f.text_field :end, :value => ( @shift.end ? (Time.parse(params[:shift][:end]).strftime("%m/%d/%Y") or @shift.end.strftime("%m/%d/%Y")) : Time.now.strftime("%m/%d/%Y")), :size => 10 %> - <%= f.time_select :end, :minute_step => 15, :twelve_hour => true %> + <%= f.time_select :end, :minute_step => @department.department_config.time_increment, :twelve_hour => true %>

<% if current_user.is_admin_of?(@department) %>

diff --git a/app/views/sub_requests/_form.html.erb b/app/views/sub_requests/_form.html.erb index 2173885a..c64e7d5f 100644 --- a/app/views/sub_requests/_form.html.erb +++ b/app/views/sub_requests/_form.html.erb @@ -4,20 +4,20 @@

Time that you need someone to take for this sub request:

<%= f.label "Start" %>
- <%= f.datetime_select :mandatory_start, :default => @sub_request.shift.start %> + <%= f.datetime_select :mandatory_start, :default => @sub_request.shift.start, :minute_step => @department.department_config.time_increment, :twelve_hour => true %>

<%= f.label "End" %>
- <%= f.datetime_select :mandatory_end, :default => @sub_request.shift.end %> + <%= f.datetime_select :mandatory_end, :default => @sub_request.shift.end, :minute_step => @department.department_config.time_increment, :twelve_hour => true %>

Maximum amount of time you're willing to give up (bribe):

<%= f.label :start %>
- <%= f.datetime_select :start, :default => @sub_request.shift.start %> + <%= f.datetime_select :start, :default => @sub_request.shift.start, :minute_step => @department.department_config.time_increment, :twelve_hour => true %>

<%= f.label :end %>
- <%= f.datetime_select :end, :default => @sub_request.shift.end %> + <%= f.datetime_select :end, :default => @sub_request.shift.end, :minute_step => @department.department_config.time_increment, :twelve_hour => true %>

<%= label_tag "People/groups eligible for this sub" %>
diff --git a/app/views/time_slots/_form.html.erb b/app/views/time_slots/_form.html.erb index 96a3fb3d..6f88a387 100644 --- a/app/views/time_slots/_form.html.erb +++ b/app/views/time_slots/_form.html.erb @@ -2,11 +2,11 @@ <%= f.error_messages %>

<%= f.label :start %>
- <%= select_time Time.now, :minute_step => current_department.department_config.time_increment, :ignore_date => true %> + <%= select_time Time.now, :minute_step => current_department.department_config.time_increment, :ignore_date => true, :twelve_hour => true %>

<%= f.label :end %>
- <%= select_time Time.now+1.hour, :minute_step => current_department.department_config.time_increment, :ignore_date => true %> + <%= select_time Time.now+1.hour, :minute_step => current_department.department_config.time_increment, :ignore_date => true, :twelve_hour => true %>

<% @department.loc_groups.each do |loc_group| %> <% unless loc_group.locations.empty? %> diff --git a/features/payform_admin_test.feature b/features/payform_admin_test.feature index dfb05bbf..ebceef94 100644 --- a/features/payform_admin_test.feature +++ b/features/payform_admin_test.feature @@ -104,10 +104,10 @@ Feature: payform admin Then I should have a pdf with "This payform was approved by #{@current_user} at" in it @passing Scenario: Pruning Empty Payforms - Given I have the following payform items - | category | user_login | hours | description | date | - | Magic | hg9 | 2 | fighting Voldemort | May 18, 2009 | - | Quidditch | hp123 | 1.5 | caught the snitch | June 10, 2009 | + Given I have the following payform items + | category | user_login | hours | description | date | payform.date | + | Magic | hg9 | 2 | fighting Voldemort | May 18, 2009 | 2009-05-23 | + | Quidditch | hp123 | 1.5 | caught the snitch | June 10, 2009 | 2009-06-13 | When I follow "Prune all empty payforms" Then I should see "Successfully pruned empty payforms." And I should see "2009-06-13" diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 0a97ecc9..d257ef3f 100755 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -42,12 +42,12 @@ a { /*this is used for the department_config form*/ -.shift_admin_form label { - width: 30em; - float: left; - text-align: right; - margin-right: 0.5em; - display: block; +.shift_admin_form label { + width: 30em; + float: left; + text-align: right; + margin-right: 0.5em; + display: block; } @@ -485,7 +485,7 @@ fieldset#warning { } fieldset.index { - width: 75%; + width: 90%; padding: 5px; background-color:#DDDDFF } From c5f2b38dc985b9c2db33c683ace4822923accc19 Mon Sep 17 00:00:00 2001 From: rofreg Date: Wed, 22 Jul 2009 12:18:42 -0400 Subject: [PATCH 04/59] not working yet... --- app/helpers/form_helper.rb | 18 +++++++++++++++--- app/views/shifts/_form.html.erb | 11 ++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb index f2a9bca2..ce4db337 100644 --- a/app/helpers/form_helper.rb +++ b/app/helpers/form_helper.rb @@ -1,5 +1,5 @@ module FormHelper - def text_field(*args) + def date_select(*args) #args[0] == the name of the object #args[1] == the name of the field #args[2] == datepicker: true/false @@ -11,10 +11,22 @@ def text_field(*args) end end - def datetime_picker(*args) + def timepicker(field_name) + time_choices = (0..1440).step(@department.department_config.time_increment).map{|t| [t.min_to_am_pm, t.min_to_am_pm]} + select(field_name.symbolize, time_choices) #args[0] == the name of the object #args[1] == the name of the field #args[2] == datepicker: true/false - + end + + def select(*args) + if args[2] == :timepicker + time_choices = (0..1440).step(@department.department_config.time_increment).map{|t| [t.min_to_am_pm, t.min_to_am_pm]} + args[2] = time_choices + #args.to_json + super(*args) + else + super(*args) + end end end \ No newline at end of file diff --git a/app/views/shifts/_form.html.erb b/app/views/shifts/_form.html.erb index 5e3f9288..3c75fba1 100644 --- a/app/views/shifts/_form.html.erb +++ b/app/views/shifts/_form.html.erb @@ -1,17 +1,18 @@ -<% javascript 'jquery', 'jquery-ui', 'jquery.timepicker' %> +<% javascript 'jquery', 'jquery-ui' %> <% stylesheet 'ui.datepicker' %> <% form_for @shift do |f| %> <%= f.error_messages %>

<%= f.label :start %>
- <%= f.text_field :start, :datepicker => true, :value => ((@shift.start.strftime("%m/%d/%Y") or params[:shift][:start]) if @shift.start) %> - <%#= f.text_field :start, :value => ((@shift.start.strftime("%I:%M%p") or params[:shift][:start]) if @shift.start) %> - <%= f.time_select :start, :minute_step => @department.department_config.time_increment, :twelve_hour => true, :ignore_date => true %> (specify a start time) + <%= f.text_field :start, :datepicker => true %><%#, :value => ((@shift.start.strftime("%m/%d/%Y") or params[:shift][:start]) if @shift.start) %> + <%#= f.select :start, :timepicker %> + <%= f.datetime_select :start, :datepicker => true, :minute_step => @department.department_config.time_increment, :twelve_hour => true %> (specify a start time)

<%= f.label :end %>
- <%= f.text_field :end, :datepicker => true, :value => ( @shift.end ? (@shift.end.strftime("%m/%d/%Y") or params[:shift][:end]) : Time.now.strftime("%m/%d/%Y")) %> + <%= f.text_field :end, :datepicker => true %><%#, :value => ( @shift.end ? (@shift.end.strftime("%m/%d/%Y") or params[:shift][:end]) : Time.now.strftime("%m/%d/%Y")) %> + <%#= f.select :end, :timepicker %> <%= f.time_select :end, :minute_step => @department.department_config.time_increment, :twelve_hour => true, :ignore_date => true %> (specify an end time)

<% if current_user.is_admin_of?(@department) %> From 0260df8d94a9ca50502fdf312e6c05f70af5e9fc Mon Sep 17 00:00:00 2001 From: Derek Zhao Date: Wed, 22 Jul 2009 13:58:48 -0400 Subject: [PATCH 05/59] notice form improvements --- app/controllers/notices_controller.rb | 10 +++---- app/helpers/application_helper.rb | 5 ---- app/models/notice.rb | 14 +++++---- app/views/layouts/dashboard.html.erb | 4 +-- app/views/layouts/shifts.html.erb | 11 +++---- app/views/notices/_advanced_options.html.erb | 9 +++--- app/views/notices/_form.html.erb | 31 ++++++++++++++------ app/views/notices/create.js.erb | 3 +- public/javascripts/checkboxtest.js | 17 ++++++++++- public/stylesheets/application.css | 4 ++- 10 files changed, 68 insertions(+), 40 deletions(-) diff --git a/app/controllers/notices_controller.rb b/app/controllers/notices_controller.rb index 351e9135..fa4a1788 100644 --- a/app/controllers/notices_controller.rb +++ b/app/controllers/notices_controller.rb @@ -27,15 +27,14 @@ def edit end def create + raise params.to_yaml @notice = Notice.new(params[:notice]) @notice.is_sticky = true unless current_user.is_admin_of?(current_department) @notice.author = current_user @notice.department = current_department - @notice.start_time = Time.now if @notice.is_sticky - @notice.active_sticky = true if @notice.is_sticky - @notice.end_time = nil if params[:indefinite] || @notice.is_sticky - @notice.active = true - @notice.save + @notice.start_time = Time.now if params[:start_time_choice] == 'now' || @notice.is_sticky + @notice.end_time = nil if params[:end_time_choice] == "indefinite" || @notice.is_sticky + @notice.save(false) set_sources respond_to do |format| if @notice.save @@ -86,7 +85,6 @@ def destroy protected def set_sources -# raise params.to_yaml if params[:for_users] params[:for_users].split(",").each do |l| if l == l.split("||").first #This is for if javascript is disabled diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 698818f1..d18ccf09 100755 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -5,11 +5,6 @@ def link_to_post_a_new_notice link_to_unless_current('Post a new notice', new_notice_path(:height => 530, :width => 530), :class => "thickbox") end - def make_popup(hash) - hash[:width] ||= 600 - "Modalbox.show(this.href, {title: '#{hash[:title]}', width: #{hash[:width]}}); return false;" - end - def link_toggle(id, name, speed = "medium") # "%s" % [id, name] link_to_function name, "$('##{id}').slideToggle('#{speed}')" diff --git a/app/models/notice.rb b/app/models/notice.rb index f626fda1..bda15aab 100644 --- a/app/models/notice.rb +++ b/app/models/notice.rb @@ -6,8 +6,8 @@ class Notice < ActiveRecord::Base belongs_to :department validates_presence_of :content - validate :presence_of_locations_or_viewers, :unless => :new_record? validate_on_create :proper_time + validate :presence_of_locations_or_viewers named_scope :inactive, lambda {{ :conditions => ["end_time < ?", Time.now] }} named_scope :active_with_end, lambda {{ :conditions => ["start_time < ? and end_time > ?", Time.now, Time.now]}} @@ -21,7 +21,7 @@ def self.active def display_for display_for = [] display_for.push "for users #{self.viewers.collect{|n| n.name}.to_sentence}" unless self.viewers.empty? - display_for.push "for locations #{self.display_locations.collect{|l| l.short_name}.to_sentence}" unless self.display_locatidons.empty? + display_for.push "for locations #{self.display_locations.collect{|l| l.short_name}.to_sentence}" unless self.display_locations.empty? display_for.join "
" end @@ -34,11 +34,11 @@ def is_current? end def viewers - self.user_sources.collect{|s| s.users}.flatten.uniq + self.user_sources.collect{|us| us.users}.flatten.uniq end def display_locations - self.location_sources.collect{|s| s.locations}.flatten.uniq + self.location_sources.collect{|ls| ls.locations}.flatten.uniq end def remove(user) @@ -51,11 +51,13 @@ def remove(user) private #Validations def presence_of_locations_or_viewers - errors.add_to_base "Your notice must display somewhere or for someone." if self.locations.empty? && self.viewers.empty? + unless self.new_record? + errors.add_to_base "Your notice must display somewhere or for someone." if self.location_sources.empty? && self.user_sources.empty? + end end def proper_time - errors.add_to_base "Start/end time combination is invalid." if self.start_time > self.end_time if self.end_time || Time.now > self.end_time if self.end_time + errors.add_to_base "Start/end time combination is invalid." if self.start_time >= self.end_time if self.end_time || Time.now >= self.end_time if self.end_time end end diff --git a/app/views/layouts/dashboard.html.erb b/app/views/layouts/dashboard.html.erb index acdd3fe4..5a664a36 100644 --- a/app/views/layouts/dashboard.html.erb +++ b/app/views/layouts/dashboard.html.erb @@ -1,6 +1,6 @@ <% content_for :head do %> - <%= stylesheet_link_tag 'shift', 'report', 'notice', 'tokeninput-facebook', 'thickbox' %> - <%= javascript_include_tag 'thickbox-compressed', 'jquery.tokeninput', 'checkboxtest' %> + <%= stylesheet_link_tag 'shift', 'report', 'notice', 'thickbox' %> + <%= javascript_include_tag 'checkboxtest' %> <% end %> <% content_for :left_nav do %> diff --git a/app/views/layouts/shifts.html.erb b/app/views/layouts/shifts.html.erb index cfcdbea0..5ed7d0d1 100644 --- a/app/views/layouts/shifts.html.erb +++ b/app/views/layouts/shifts.html.erb @@ -1,6 +1,6 @@ <% content_for :head do %> <% stylesheet 'shift', 'report', 'notice', 'thickbox' %> - <% javascript 'sortable', 'jrails', 'jquery', 'jquery-ui', 'thickbox-compressed', 'jquery.simpletip-1.3.1' %> + <% javascript 'sortable', 'jquery.simpletip-1.3.1' %> <% end %> @@ -21,7 +21,7 @@
  • <%= link_to_unless_current "Activate Templates", { :controller => '/shift_admin', :action => 'activate_templates' } %>
<%# if @user.authorized?("shift_admin/@" + @department.name.decamelize + "/department_admin")%> -
  • <%#= link_to_unless_current "Edit Configuration", { :controller => '/shift_admin', :action => 'config' } %>
  • +
  • <%#= link_to_unless_current "Edit Configuration", { :controller => '/shift_admin', :action => 'config' } %>
  • <%# end %>

    View Options

    @@ -31,18 +31,19 @@
  • <%= link_to_unless_current "Data Objects", data_objects_path %>
  • <%#= link_to "Shift Stats", stats_path %>
  • <%#= link_to "Missed Shifts", {:controller => '/shift_admin', :action => 'view_missed_shifts'} %>
  • - + - +
    <% end %> <% end %> <% content_for :body do %> - + <%= yield %>
    <% end -%> <%= render :file => "layouts/application.html.erb" %> + diff --git a/app/views/notices/_advanced_options.html.erb b/app/views/notices/_advanced_options.html.erb index 354da947..73e4af80 100644 --- a/app/views/notices/_advanced_options.html.erb +++ b/app/views/notices/_advanced_options.html.erb @@ -1,4 +1,4 @@ -
    <%= tokenized_users_autocomplete(@notice, "user_sources", "for_users") %> +
    <%= tokenized_users_autocomplete(@notice, "user_sources", "for_users") %>
    For locations:
      @@ -6,9 +6,9 @@ For locations:
      <%= check_box_tag :department_wide_locations %> (all locations) <% end %> - +
      <% for loc_group in current_department.loc_groups do %> -
    • +
    • <%= check_box_tag "for_location_groups[]", loc_group.id, false %> <%= label_tag "location_group_#{loc_group.id}", text = loc_group.name %>: @@ -17,7 +17,8 @@ For locations:
      <%= label_tag "location_#{location.id}", text = location.name %> <% unless location == loc_group.locations.last %> , <%end%> <% end %> -
    • + <% end %> +
    diff --git a/app/views/notices/_form.html.erb b/app/views/notices/_form.html.erb index d04bbfdc..94743689 100644 --- a/app/views/notices/_form.html.erb +++ b/app/views/notices/_form.html.erb @@ -1,3 +1,4 @@ + <% form_remote_for @notice do |f| %> <%= f.error_messages %> @@ -6,19 +7,29 @@

    <% if current_user.is_admin_of?(current_department) %> + + + + Type of notice:

    - Post as sticky? (start/end time preferences will be ignored) - <%= f.check_box :is_sticky %> + <%= radio_button_tag 'type', :is_sticky %> Sticky
    + <%= radio_button_tag 'type', 'announcement', true %> Announcement

    +
    + Start time:

    - Specify a start time: + <%= radio_button_tag 'start_time_choice', 'now', true %> Now
    + <%= radio_button_tag 'start_time_choice', 'date' %> <%= f.datetime_select :start_time %>

    +
    + End time:

    - Specify an end time: - <%= f.datetime_select :end_time %>
    or check here to make it indefinite: - <%= check_box_tag :indefinite -%> + <%= radio_button_tag 'end_time_choice', 'indefinite', true %> Never
    + <%= radio_button_tag 'end_time_choice', 'date' %> + <%= f.datetime_select :end_time %>

    +
    <% end %> <% unless current_user.is_admin_of?(current_department) %> @@ -31,10 +42,12 @@ <%= render :partial => 'advanced_options'%>
    -

    - <%= f.submit 'Save' %> -

    +

    + <%= f.submit 'Save' %> +

    + <% end %> + <% unless current_user.is_admin_of?(current_department) %> " - else - super(*args) - end - end - - def timepicker(field_name) - time_choices = (0..1440).step(@department.department_config.time_increment).map{|t| [t.min_to_am_pm, t.min_to_am_pm]} - select(field_name.symbolize, time_choices) - #args[0] == the name of the object - #args[1] == the name of the field - #args[2] == datepicker: true/false - end - - def select(*args) - if args[2] == :timepicker - time_choices = (0..1440).step(@department.department_config.time_increment).map{|t| [t.min_to_am_pm, t.min_to_am_pm]} - args[2] = time_choices - #args.to_json - super(*args) - else - super(*args) - end - end -end \ No newline at end of file diff --git a/app/models/shift.rb b/app/models/shift.rb index e4368b53..28b3c487 100644 --- a/app/models/shift.rb +++ b/app/models/shift.rb @@ -189,5 +189,12 @@ def adjust_sub_requests end end end + + + class << columns_hash['start'] + def type + :datetime + end + end end diff --git a/app/views/notices/_form.html.erb b/app/views/notices/_form.html.erb index bf6acc76..1ddab0a6 100644 --- a/app/views/notices/_form.html.erb +++ b/app/views/notices/_form.html.erb @@ -1,3 +1,5 @@ +<% unobtrusive_datepicker_includes %> + <% form_remote_for @notice do |f| %> <%= f.error_messages %> @@ -12,11 +14,12 @@

    Specify a start time: - <%= f.datetime_select :start_time, :minute_step => @department.department_config.time_increment, :twelve_hour => true %> + + <%= f.unobtrusive_datetime_picker :start_time, :minute_step => @department.department_config.time_increment %>

    Specify an end time: - <%= f.datetime_select :end_time, :minute_step => @department.department_config.time_increment, :twelve_hour => true %>
    or check here to make it indefinite: + <%= f.unobtrusive_datetime_picker :end_time, :minute_step => @department.department_config.time_increment %>
    or check here to make it indefinite: <%= check_box_tag :indefinite -%>

    <% end %> @@ -40,5 +43,4 @@ $("#advanced_options_div").hide(); $("#advanced_link").show(); -<% end %> - +<% end %> \ No newline at end of file diff --git a/app/views/restrictions/_form.html.erb b/app/views/restrictions/_form.html.erb index ed89d264..468aef4b 100644 --- a/app/views/restrictions/_form.html.erb +++ b/app/views/restrictions/_form.html.erb @@ -1,12 +1,14 @@ +<% unobtrusive_datepicker_includes %> + <% form_for @restriction do |f| %> <%= f.error_messages %>

    <%= f.label :starts, :minute_step => @department.department_config.time_increment, :twelve_hour => true %>
    - <%= f.datetime_select :starts, :minute_step => @department.department_config.time_increment, :twelve_hour => true %> + <%= f.unobtrusive_datetime_picker :starts, :minute_step => @department.department_config.time_increment %>

    <%= f.label :expires, :minute_step => @department.department_config.time_increment, :twelve_hour => true %>
    - <%= f.datetime_select :expires, :minute_step => @department.department_config.time_increment, :twelve_hour => true %> + <%= f.unobtrusive_datetime_picker :expires, :minute_step => @department.department_config.time_increment %>

    <%= f.label :max_subs %>
    diff --git a/app/views/shifts/_form.html.erb b/app/views/shifts/_form.html.erb index 3c75fba1..d05cb978 100644 --- a/app/views/shifts/_form.html.erb +++ b/app/views/shifts/_form.html.erb @@ -1,19 +1,14 @@ -<% javascript 'jquery', 'jquery-ui' %> -<% stylesheet 'ui.datepicker' %> +<%= unobtrusive_datepicker_include_tags %> <% form_for @shift do |f| %> <%= f.error_messages %>

    - <%= f.label :start %>
    - <%= f.text_field :start, :datepicker => true %><%#, :value => ((@shift.start.strftime("%m/%d/%Y") or params[:shift][:start]) if @shift.start) %> - <%#= f.select :start, :timepicker %> - <%= f.datetime_select :start, :datepicker => true, :minute_step => @department.department_config.time_increment, :twelve_hour => true %> (specify a start time) + <%= f.label :start_time %>
    + <%= f.unobtrusive_datetime_picker :start, :minute_step => @department.department_config.time_increment %>

    - <%= f.label :end %>
    - <%= f.text_field :end, :datepicker => true %><%#, :value => ( @shift.end ? (@shift.end.strftime("%m/%d/%Y") or params[:shift][:end]) : Time.now.strftime("%m/%d/%Y")) %> - <%#= f.select :end, :timepicker %> - <%= f.time_select :end, :minute_step => @department.department_config.time_increment, :twelve_hour => true, :ignore_date => true %> (specify an end time) + <%= f.label :end_time %>
    + <%= f.unobtrusive_datetime_picker :end, :minute_step => @department.department_config.time_increment %>

    <% if current_user.is_admin_of?(@department) %>

    diff --git a/app/views/shifts/power_sign_up.html.erb b/app/views/shifts/power_sign_up.html.erb index d5e230e2..5a7572b5 100644 --- a/app/views/shifts/power_sign_up.html.erb +++ b/app/views/shifts/power_sign_up.html.erb @@ -1,17 +1,14 @@ -<% javascript 'jquery', 'jquery-ui' %> -<% stylesheet 'ui.datepicker' %> +<% unobtrusive_datepicker_includes %> <% form_for @shift do |f| %> <%= f.error_messages %>

    <%= f.label :start %>
    - <%= f.text_field :start, :value => ( @shift.start ? (params[:shift][:start] or @shift.start.strftime("%m/%d/%Y")) : Time.now.strftime("%m/%d/%Y")), :size => 10 %> - <%= f.time_select :start, :minute_step => @department.department_config.time_increment, :twelve_hour => true, :order => [:hour, :minute] %> (specify a start time) + <%= f.unobtrusive_datetime_picker :start, :minute_step => @department.department_config.time_increment %>

    <%= f.label :end %>
    - <%= f.text_field :end, :value => ( @shift.end ? (params[:shift][:end] or @shift.end.strftime("%m/%d/%Y")) : Time.now.strftime("%m/%d/%Y")), :size => 10 %> - <%#= f.time_select :end, :minute_step => @department.department_config.time_increment, :twelve_hour => true, :order => [:hour, :minute] %> (specify an end time) + <%= f.unobtrusive_datetime_picker :end, :minute_step => @department.department_config.time_increment %>

    <%= f.label :user %>
    @@ -23,9 +20,4 @@

    <%= f.hidden_field :power_signed_up, :value => :true %>

    <%= f.submit "Submit" %>

    -<% end %> - - +<% end %> \ No newline at end of file diff --git a/app/views/sub_requests/_form.html.erb b/app/views/sub_requests/_form.html.erb index c64e7d5f..58327465 100644 --- a/app/views/sub_requests/_form.html.erb +++ b/app/views/sub_requests/_form.html.erb @@ -1,23 +1,25 @@ +<% unobtrusive_datepicker_includes %> + <% form_for (params[:id] ? @sub_request : [:shift, @sub_request]) do |f| %> <%= f.error_messages %>

    Time that you need someone to take for this sub request:

    <%= f.label "Start" %>
    - <%= f.datetime_select :mandatory_start, :default => @sub_request.shift.start, :minute_step => @department.department_config.time_increment, :twelve_hour => true %> + <%= f.unobtrusive_datetime_picker :mandatory_start, :minute_step => @department.department_config.time_increment %>

    <%= f.label "End" %>
    - <%= f.datetime_select :mandatory_end, :default => @sub_request.shift.end, :minute_step => @department.department_config.time_increment, :twelve_hour => true %> + <%= f.unobtrusive_datetime_picker :mandatory_end, :minute_step => @department.department_config.time_increment %>

    Maximum amount of time you're willing to give up (bribe):

    <%= f.label :start %>
    - <%= f.datetime_select :start, :default => @sub_request.shift.start, :minute_step => @department.department_config.time_increment, :twelve_hour => true %> + <%= f.unobtrusive_datetime_picker :start, :minute_step => @department.department_config.time_increment %>

    <%= f.label :end %>
    - <%= f.datetime_select :end, :default => @sub_request.shift.end, :minute_step => @department.department_config.time_increment, :twelve_hour => true %> + <%= f.unobtrusive_datetime_picker :end, :minute_step => @department.department_config.time_increment %>

    <%= label_tag "People/groups eligible for this sub" %>
    diff --git a/app/views/time_slots/_form.html.erb b/app/views/time_slots/_form.html.erb index 9a045604..b8054e9e 100644 --- a/app/views/time_slots/_form.html.erb +++ b/app/views/time_slots/_form.html.erb @@ -1,3 +1,5 @@ +<% unobtrusive_datepicker_includes %> + <% form_for @time_slot do |f| %> <%= f.error_messages %>

    @@ -6,11 +8,11 @@

    <%= f.label :start %>
    - <%= f.datetime_select :start, :minute_step => @department.department_config.time_increment, :twelve_hour => true %> + <%= f.unobtrusive_datetime_picker :start, :minute_step => @department.department_config.time_increment %>

    <%= f.label :end %>
    - <%= f.datetime_select :end, :minute_step => @department.department_config.time_increment, :twelve_hour => true %> + <%= f.unobtrusive_datetime_picker :end, :minute_step => @department.department_config.time_increment %>

    <%= f.submit "Submit" %>

    <% end %> diff --git a/public/images/datepicker/backstripes.gif b/public/images/datepicker/backstripes.gif new file mode 100644 index 0000000000000000000000000000000000000000..63f14035142b4ba489635a75c9907ed7e5173f51 GIT binary patch literal 234 zcmVMOLc**Mu zTYR$8d#1J<^Y2|?M~-GVoh7Qa4-2odo5u8QJNTUQTE7dzgg&Ch2uzZc$YQ7o%|)G5 z3G-TgVy7s9hQxeut|7Z^A=xTjM{h{y6RJQ$+ijji8tC5N?H1qN_Ps`y0%L6iWqxUD>mzytGdg2sd$SM ktkjD%+*XX0YR-tZb|xz{bJG4g_o*9GqNST$~&{V890g0&u{{ z%)-LP#>T_J!6U@S!zUyHk`WOE%L_s%0VoC6gTnZKfI*OhL79nznNg5|Nsy6Qkn#T! zh6)BoFaWv}1{hhGnK&V$j4&}E&Bz3FumDgw2P4q^KzWFqFk|9HCg#a3q9KNkjf#P+ zf`t)sdG=REXwFh_;TAQ zXY)=|Jzv2yau2kvUJji!pLXA=q# zNMMr@An8Peb^1T51_NnswV^_~Ae`iI1OxVTk@iz-zyHKj>DQM=&A;uNE#Hy+cK&z! zZKZKh#T(PRbV3((i&iW;8m9r`L_X>k{g$!l=sYkl6vz{aSbbDX3&s@#s*HlEgmMC1 zyMU%V>IQN5R)Gx^`|=8#BB1FYML?^Exrgc z9M0AG=-Ra>FliCY7`XHA)rBp;{M1Mzz3ie$yp%lf$F~l zWgLvaYQw6Vj@CNn-Pirk5N-bV)qjRuwfzG3!G7SiRG+}}`U-nl!zb2H3>>U)SQwu$ zTQR)7!ahNpL(%yJ8)F3H0tepT4fzflg7XVB1Q-~2Ua@8fFxNeZPf(vA=di%v&SA|v zmiz`y7L7`Va}Cy|j8C|L1|ca~`+|kx{tmtaL5wb+80S_syt`mlv;A+*{qL*)ZaKGK z;N`df48^~vIr}+ture__FuY-4PwM=^G{IVggMmr?!Kx)p4GiiJxGn*0X1v3|_f~^} z;Q|8(gKdNH0tN=jJB!Q@h;TxcGcbJ9FkxU~;7{Or!MKz`wnMgy#bK2}Lx95nn*d13 B)&>9o literal 0 HcmV?d00001 diff --git a/public/images/datepicker/bullet1.gif b/public/images/datepicker/bullet1.gif new file mode 100644 index 0000000000000000000000000000000000000000..ae352c2b697b3309d21f667749a7fd4a2d695655 GIT binary patch literal 55 zcmZ?wbhEHb zn7DSR*ytGc7%6$hIB9taREfFC38UEw8fx+>T53van%aq~+G@$_8tVuvTU$tLo9lFKS96bdsUA;tYoh^i|-QC0O9bO|&URQqJ1dhHQ$nKu? M9{(**KT`kzJ6L&uY5)KL literal 0 HcmV?d00001 diff --git a/public/images/datepicker/cal.gif b/public/images/datepicker/cal.gif new file mode 100644 index 0000000000000000000000000000000000000000..8526cf5d19a915aa8073cf344873c4505491970d GIT binary patch literal 127 zcmZ?wbhEHb6krfwSj51v)Yr?)cd3`J*V1K6uU)?O9}E~67!-f9FfuT(G3WrDe9t*l+9<3>gnm}=;-L@=jZ0;=H=z( z|Ns900000000000A^8LW000~SEC2ui044xi000I5;3ke_X`X1Ru59bRa4gSSZQppV z?|kq7z#uO}EEin3mE$jQpf%+1ct4$;!n)YaD4(GA+$+}+;a z;Njxq;tb~J=;`X~?CtLF?hEqs^!4`l`1$(#`U?L400RmfNU)&6g9Z~QT*$DY!-o(f zN}MPWfyIj$Giuz(v7^V29uJ5dNwTELlPFV*s$9vkrOT8CV#=IJv!>0PICJXES)ixS zpFo2O9ZIyQ(V_&BDqYI7sne%Wqe`7hwJOvBShH%~%C)Q4uVBN99ZUABfU{`Rs$I*r zt=qS7(BTJr4xw7TUm@{kM Q%(=7Y&!9t#P8 49 && kc < 56) || (kc > 97 && kc < 104)) { + if (kc > 96) kc -= (96-48); + kc -= 49; + o.firstDayOfWeek = (o.firstDayOfWeek + kc) % 7; + o.updateTable(); + return o.killEvent(e); + }; + + if ( kc < 37 || kc > 40 ) return true; + + var d = new Date( o.date ).valueOf(); + + if ( kc == 37 ) { + // ctrl + left = previous month + if( e.ctrlKey ) { + d = new Date( o.date ); + d.setDate( Math.min(d.getDate(), datePicker.getDaysPerMonth(d.getMonth() - 1,d.getFullYear())) ); + d.setMonth( d.getMonth() - 1 ); + } else { + d = new Date( o.date.getFullYear(), o.date.getMonth(), o.date.getDate() - 1 ); + }; + } else if ( kc == 39 ) { + // ctrl + right = next month + if( e.ctrlKey ) { + d = new Date( o.date ); + d.setDate( Math.min(d.getDate(), datePicker.getDaysPerMonth(d.getMonth() + 1,d.getFullYear())) ); + d.setMonth( d.getMonth() + 1 ); + } else { + d = new Date( o.date.getFullYear(), o.date.getMonth(), o.date.getDate() + 1 ); + }; + } else if ( kc == 38 ) { + // ctrl + up = next year + if( e.ctrlKey ) { + d = new Date( o.date ); + d.setDate( Math.min(d.getDate(), datePicker.getDaysPerMonth(d.getMonth(),d.getFullYear() + 1)) ); + d.setFullYear( d.getFullYear() + 1 ); + } else { + d = new Date( o.date.getFullYear(), o.date.getMonth(), o.date.getDate() - 7 ); + }; + } else if ( kc == 40 ) { + // ctrl + down = prev year + if( e.ctrlKey ) { + d = new Date( o.date ); + d.setDate( Math.min(d.getDate(), datePicker.getDaysPerMonth(d.getMonth(),d.getFullYear() - 1)) ); + d.setFullYear( d.getFullYear() - 1 ); + } else { + d = new Date( o.date.getFullYear(), o.date.getMonth(), o.date.getDate() + 7 ); + }; + }; + + var tmpDate = new Date(d); + + if(o.outOfRange(tmpDate)) return o.killEvent(e); + + var cacheDate = new Date(o.date); + o.date = tmpDate; + + if(cacheDate.getFullYear() != o.date.getFullYear() || cacheDate.getMonth() != o.date.getMonth()) o.updateTable(); + else { + o.disableTodayButton(); + var tds = o.table.getElementsByTagName('td'); + var txt; + var start = o.date.getDate() - 6; + if(start < 0) start = 0; + + for(var i = start, td; td = tds[i]; i++) { + txt = Number(td.firstChild.nodeValue); + if(isNaN(txt) || txt != o.date.getDate()) continue; + o.removeHighlight(); + td.id = o.id + "-date-picker-hover"; + td.className = td.className.replace(/date-picker-hover/g, "") + " date-picker-hover"; + }; + }; + return o.killEvent(e); + }, + gotoToday: function(e) { + o.date = new Date(); + o.updateTable(); + return o.killEvent(e); + }, + onmousedown: function(e) { + if ( e == null ) e = document.parentWindow.event; + var el = e.target != null ? e.target : e.srcElement; + + var found = false; + while(el.parentNode) { + if(el.id && (el.id == "fd-"+o.id || el.id == "fd-but-"+o.id)) { + found = true; + break; + }; + try { + el = el.parentNode; + } catch(err) { + break; + }; + }; + if(found) return true; + o.stopTimer(); + datePickerController.hideAll(); + }, + onmouseover: function(e) { + o.stopTimer(); + var txt = this.firstChild.nodeValue; + if(this.className == "out-of-range" || txt.search(/^[\d]+$/) == -1) return; + + o.removeHighlight(); + + this.id = o.id+"-date-picker-hover"; + this.className = this.className.replace(/date-picker-hover/g, "") + " date-picker-hover"; + + o.date.setDate(this.firstChild.nodeValue); + o.disableTodayButton(); + }, + onclick: function(e) { + if(o.opacity != o.opacityTo || this.className.search(/out-of-range|day-disabled/) != -1) return false; + if ( e == null ) e = document.parentWindow.event; + var el = e.target != null ? e.target : e.srcElement; + while ( el.nodeType != 1 ) el = el.parentNode; + var d = new Date( o.date ); + var txt = el.firstChild.data; + if(txt.search(/^[\d]+$/) == -1) return; + var n = Number( txt ); + if(isNaN(n)) { return true; }; + d.setDate( n ); + o.date = d; + o.returnFormattedDate(); + if(!o.staticPos) o.hide(); + o.stopTimer(); + return o.killEvent(e); + }, + incDec: function(e) { + if ( e == null ) e = document.parentWindow.event; + var el = e.target != null ? e.target : e.srcElement; + + if(el && el.className && el.className.search('fd-disabled') != -1) { return false; } + datePickerController.addEvent(document, "mouseup", o.events.clearTimer); + o.timerInc = 800; + o.dayInc = arguments[1]; + o.yearInc = arguments[2]; + o.monthInc = arguments[3]; + o.timerSet = true; + + o.updateTable(); + return true; + }, + clearTimer: function(e) { + o.stopTimer(); + o.timerInc = 1000; + o.yearInc = 0; + o.monthInc = 0; + o.dayInc = 0; + datePickerController.removeEvent(document, "mouseup", o.events.clearTimer); + } + }; + o.stopTimer = function() { + o.timerSet = false; + window.clearTimeout(o.timer); + }; + o.removeHighlight = function() { + if(document.getElementById(o.id+"-date-picker-hover")) { + document.getElementById(o.id+"-date-picker-hover").className = document.getElementById(o.id+"-date-picker-hover").className.replace("date-picker-hover", ""); + document.getElementById(o.id+"-date-picker-hover").id = ""; + }; + }; + o.reset = function() { + for(def in o.defaults) { o[def] = o.defaults[def]; }; + }; + o.setOpacity = function(op) { + o.div.style.opacity = op/100; + o.div.style.filter = 'alpha(opacity=' + op + ')'; + o.opacity = op; + }; + o.fade = function() { + window.clearTimeout(o.fadeTimer); + o.fadeTimer = null; + delete(o.fadeTimer); + + var diff = Math.round(o.opacity + ((o.opacityTo - o.opacity) / 4)); + + o.setOpacity(diff); + + if(Math.abs(o.opacityTo - diff) > 3 && !o.noTransparency) { + o.fadeTimer = window.setTimeout(o.fade, 50); + } else { + o.setOpacity(o.opacityTo); + if(o.opacityTo == 0) { + o.div.style.display = "none"; + o.visible = false; + } else { + o.visible = true; + }; + }; + }; + o.killEvent = function(e) { + e = e || document.parentWindow.event; + + if(e.stopPropagation) { + e.stopPropagation(); + e.preventDefault(); + }; + + /*@cc_on + @if(@_win32) + e.cancelBubble = true; + e.returnValue = false; + @end + @*/ + return false; + }; + o.getElem = function() { + return document.getElementById(o.id.replace(/^fd-/, '')) || false; + }; + o.setRangeLow = function(range) { + if(String(range).search(/^(\d\d?\d\d)(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$/) == -1) range = ''; + o.low = o.defaults.low = range; + if(o.staticPos) o.updateTable(true); + }; + o.setRangeHigh = function(range) { + if(String(range).search(/^(\d\d?\d\d)(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$/) == -1) range = ''; + o.high = o.defaults.high = range; + if(o.staticPos) o.updateTable(true); + }; + o.setDisabledDays = function(dayArray) { + o.disableDays = o.defaults.disableDays = dayArray; + if(o.staticPos) o.updateTable(true); + }; + o.setDisabledDates = function(dateArray) { + var fin = []; + for(var i = dateArray.length; i-- ;) { + if(dateArray[i].match(/^(\d\d\d\d|\*\*\*\*)(0[1-9]|1[012]|\*\*)(0[1-9]|[12][0-9]|3[01])$/) != -1) fin[fin.length] = dateArray[i]; + }; + if(fin.length) { + o.disabledDates = fin; + o.enabledDates = []; + if(o.staticPos) o.updateTable(true); + }; + }; + o.setEnabledDates = function(dateArray) { + var fin = []; + for(var i = dateArray.length; i-- ;) { + if(dateArray[i].match(/^(\d\d\d\d|\*\*\*\*)(0[1-9]|1[012]|\*\*)(0[1-9]|[12][0-9]|3[01]|\*\*)$/) != -1 && dateArray[i] != "********") fin[fin.length] = dateArray[i]; + }; + if(fin.length) { + o.disabledDates = []; + o.enabledDates = fin; + if(o.staticPos) o.updateTable(true); + }; + }; + o.getDisabledDates = function(y, m) { + if(o.enabledDates.length) return o.getEnabledDates(y, m); + var obj = {}; + var d = datePicker.getDaysPerMonth(m - 1, y); + m = m < 10 ? "0" + String(m) : m; + for(var i = o.disabledDates.length; i-- ;) { + var tmp = o.disabledDates[i].replace("****", y).replace("**", m); + if(tmp < Number(String(y)+m+"01") || tmp > Number(y+String(m)+d)) continue; + obj[tmp] = 1; + }; + return obj; + }; + o.getEnabledDates = function(y, m) { + var obj = {}; + var d = datePicker.getDaysPerMonth(m - 1, y); + m = m < 10 ? "0" + String(m) : m; + var day,tmp,de,me,ye,disabled; + for(var dd = 1; dd <= d; dd++) { + day = dd < 10 ? "0" + String(dd) : dd; + disabled = true; + for(var i = o.enabledDates.length; i-- ;) { + tmp = o.enabledDates[i]; + ye = String(o.enabledDates[i]).substr(0,4); + me = String(o.enabledDates[i]).substr(4,2); + de = String(o.enabledDates[i]).substr(6,2); + + if(ye == y && me == m && de == day) { + disabled = false; + break; + } + + if(ye == "****" || me == "**" || de == "**") { + if(ye == "****") tmp = tmp.replace(/^\*\*\*\*/, y); + if(me == "**") tmp = tmp = tmp.substr(0,4) + String(m) + tmp.substr(6,2); + if(de == "**") tmp = tmp.replace(/\*\*/, day); + + if(tmp == String(y + String(m) + day)) { + disabled = false; + break; + }; + }; + }; + if(disabled) obj[String(y + String(m) + day)] = 1; + }; + return obj; + }; + o.setFirstDayOfWeek = function(e) { + if ( e == null ) e = document.parentWindow.event; + var elem = e.target != null ? e.target : e.srcElement; + if(elem.tagName.toLowerCase() != "th") { + while(elem.tagName.toLowerCase() != "th") elem = elem.parentNode; + }; + var cnt = 0; + while(elem.previousSibling) { + elem = elem.previousSibling; + if(elem.tagName.toLowerCase() == "th") cnt++; + }; + o.firstDayOfWeek = (o.firstDayOfWeek + cnt) % 7; + o.updateTableHeaders(); + return o.killEvent(e); + }; + o.truePosition = function(element) { + var pos = o.cumulativeOffset(element); + if(window.opera) { return pos; } + var iebody = (document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body; + var dsocleft = document.all ? iebody.scrollLeft : window.pageXOffset; + var dsoctop = document.all ? iebody.scrollTop : window.pageYOffset; + var posReal = o.realOffset(element); + return [pos[0] - posReal[0] + dsocleft, pos[1] - posReal[1] + dsoctop]; + }; + o.realOffset = function(element) { + var t = 0, l = 0; + do { + t += element.scrollTop || 0; + l += element.scrollLeft || 0; + element = element.parentNode; + } while (element); + return [l, t]; + }; + o.cumulativeOffset = function(element) { + var t = 0, l = 0; + do { + t += element.offsetTop || 0; + l += element.offsetLeft || 0; + element = element.offsetParent; + } while (element); + return [l, t]; + }; + o.resize = function() { + if(!o.created || !o.getElem()) return; + + o.div.style.visibility = "hidden"; + if(!o.staticPos) { o.div.style.left = o.div.style.top = "0px"; } + o.div.style.display = "block"; + + var osh = o.div.offsetHeight; + var osw = o.div.offsetWidth; + + o.div.style.visibility = "visible"; + o.div.style.display = "none"; + + if(!o.staticPos) { + var elem = document.getElementById('fd-but-' + o.id); + var pos = o.truePosition(elem); + var trueBody = (document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body; + var scrollTop = window.devicePixelRatio || window.opera ? 0 : trueBody.scrollTop; + var scrollLeft = window.devicePixelRatio || window.opera ? 0 : trueBody.scrollLeft; + + if(parseInt(trueBody.clientWidth+scrollLeft) < parseInt(osw+pos[0])) { + o.div.style.left = Math.abs(parseInt((trueBody.clientWidth+scrollLeft) - osw)) + "px"; + } else { + o.div.style.left = pos[0] + "px"; + }; + + if(parseInt(trueBody.clientHeight+scrollTop) < parseInt(osh+pos[1]+elem.offsetHeight+2)) { + o.div.style.top = Math.abs(parseInt(pos[1] - (osh + 2))) + "px"; + } else { + o.div.style.top = Math.abs(parseInt(pos[1] + elem.offsetHeight + 2)) + "px"; + }; + }; + /*@cc_on + @if(@_jscript_version <= 5.6) + if(o.staticPos) return; + o.iePopUp.style.top = o.div.style.top; + o.iePopUp.style.left = o.div.style.left; + o.iePopUp.style.width = osw + "px"; + o.iePopUp.style.height = (osh - 2) + "px"; + @end + @*/ + }; + o.equaliseDates = function() { + var clearDayFound = false; + var tmpDate; + for(var i = o.low; i <= o.high; i++) { + tmpDate = String(i); + if(!o.disableDays[new Date(tmpDate.substr(0,4), tmpDate.substr(6,2), tmpDate.substr(4,2)).getDay() - 1]) { + clearDayFound = true; + break; + }; + }; + if(!clearDayFound) o.disableDays = o.defaults.disableDays = [0,0,0,0,0,0,0]; + }; + o.outOfRange = function(tmpDate) { + if(!o.low && !o.high) return false; + + var level = false; + if(!tmpDate) { + level = true; + tmpDate = o.date; + }; + + var d = (tmpDate.getDate() < 10) ? "0" + tmpDate.getDate() : tmpDate.getDate(); + var m = ((tmpDate.getMonth() + 1) < 10) ? "0" + (tmpDate.getMonth() + 1) : tmpDate.getMonth() + 1; + var y = tmpDate.getFullYear(); + var dt = String(y)+String(m)+String(d); + + if(o.low && parseInt(dt) < parseInt(o.low)) { + if(!level) return true; + o.date = new Date(o.low.substr(0,4), o.low.substr(4,2)-1, o.low.substr(6,2), 5, 0, 0); + return false; + }; + if(o.high && parseInt(dt) > parseInt(o.high)) { + if(!level) return true; + o.date = new Date( o.high.substr(0,4), o.high.substr(4,2)-1, o.high.substr(6,2), 5, 0, 0); + }; + return false; + }; + o.createButton = function() { + if(o.staticPos) { return; }; + + var but; + + if(!document.getElementById("fd-but-" + o.id)) { + var inp = o.getElem(); + + but = document.createElement('a'); + but.href = "#"; + + var span = document.createElement('span'); + span.appendChild(document.createTextNode(String.fromCharCode( 160 ))); + + but.className = "date-picker-control"; + but.title = (typeof(fdLocale) == "object" && options.locale && fdLocale.titles.length > 5) ? fdLocale.titles[5] : ""; + + but.id = "fd-but-" + o.id; + but.appendChild(span); + + if(inp.nextSibling) { + inp.parentNode.insertBefore(but, inp.nextSibling); + } else { + inp.parentNode.appendChild(but); + }; + } else { + but = document.getElementById("fd-but-" + o.id); + }; + + but.onclick = but.onpress = function(e) { + e = e || window.event; + var inpId = this.id.replace('fd-but-',''); + try { var dp = datePickerController.getDatePicker(inpId); } catch(err) { return false; }; + + if(e.type == "press") { + var kc = e.keyCode != null ? e.keyCode : e.charCode; + if(kc != 13) { return true; }; + if(dp.visible) { + hideAll(); + return false; + }; + }; + + if(!dp.visible) { + datePickerController.hideAll(inpId); + dp.show(); + } else { + datePickerController.hideAll(); + }; + return false; + }; + but = null; + }, + o.create = function() { + + function createTH(details) { + var th = document.createElement('th'); + if(details.thClassName) th.className = details.thClassName; + if(details.colspan) { + /*@cc_on + /*@if (@_win32) + th.setAttribute('colSpan',details.colspan); + @else @*/ + th.setAttribute('colspan',details.colspan); + /*@end + @*/ + }; + /*@cc_on + /*@if (@_win32) + th.unselectable = "on"; + /*@end@*/ + return th; + }; + + function createThAndButton(tr, obj) { + for(var i = 0, details; details = obj[i]; i++) { + var th = createTH(details); + tr.appendChild(th); + var but = document.createElement('span'); + but.className = details.className; + but.id = o.id + details.id; + but.appendChild(document.createTextNode(details.text)); + but.title = details.title || ""; + if(details.onmousedown) but.onmousedown = details.onmousedown; + if(details.onclick) but.onclick = details.onclick; + if(details.onmouseout) but.onmouseout = details.onmouseout; + th.appendChild(but); + }; + }; + + /*@cc_on + @if(@_jscript_version <= 5.6) + if(!document.getElementById("iePopUpHack")) { + o.iePopUp = document.createElement('iframe'); + o.iePopUp.src = "javascript:'';"; + o.iePopUp.setAttribute('className','iehack'); + o.iePopUp.scrolling="no"; + o.iePopUp.frameBorder="0"; + o.iePopUp.name = o.iePopUp.id = "iePopUpHack"; + document.body.appendChild(o.iePopUp); + } else { + o.iePopUp = document.getElementById("iePopUpHack"); + }; + @end + @*/ + + if(typeof(fdLocale) == "object" && o.locale) { + datePicker.titles = fdLocale.titles; + datePicker.months = fdLocale.months; + datePicker.fullDay = fdLocale.fullDay; + // Optional parameters + if(fdLocale.dayAbbr) datePicker.dayAbbr = fdLocale.dayAbbr; + if(fdLocale.firstDayOfWeek) o.firstDayOfWeek = o.defaults.firstDayOfWeek = fdLocale.firstDayOfWeek; + }; + + o.div = document.createElement('div'); + o.div.style.zIndex = 9999; + o.div.id = "fd-"+o.id; + o.div.className = "datePicker"; + + if(!o.staticPos) { + document.getElementsByTagName('body')[0].appendChild(o.div); + } else { + elem = o.getElem(); + if(!elem) { + o.div = null; + return; + }; + o.div.className += " staticDP"; + o.div.setAttribute("tabIndex", "0"); + o.div.onfocus = o.events.onfocus; + o.div.onblur = o.events.onblur; + elem.parentNode.insertBefore(o.div, elem.nextSibling); + if(o.hideInput && elem.type && elem.type == "text") elem.setAttribute("type", "hidden"); + }; + + //var nbsp = String.fromCharCode( 160 ); + var tr, row, col, tableHead, tableBody; + + o.table = document.createElement('table'); + o.div.appendChild( o.table ); + + tableHead = document.createElement('thead'); + o.table.appendChild( tableHead ); + + tr = document.createElement('tr'); + tableHead.appendChild(tr); + + // Title Bar + o.titleBar = createTH({thClassName:"date-picker-title", colspan:7}); + tr.appendChild( o.titleBar ); + tr = null; + + var span = document.createElement('span'); + span.className = "month-display"; + o.titleBar.appendChild(span); + + span = document.createElement('span'); + span.className = "year-display"; + o.titleBar.appendChild(span); + + span = null; + + tr = document.createElement('tr'); + tableHead.appendChild(tr); + + createThAndButton(tr, [{className:"prev-but", id:"-prev-year-but", text:"\u00AB", title:datePicker.titles[2], onmousedown:function(e) { o.events.incDec(e,0,-1,0); }, onmouseout:o.events.clearTimer },{className:"prev-but", id:"-prev-month-but", text:"\u2039", title:datePicker.titles[0], onmousedown:function(e) { o.events.incDec(e,0,0,-1); }, onmouseout:o.events.clearTimer },{colspan:3, className:"today-but", id:"-today-but", text:datePicker.titles.length > 4 ? datePicker.titles[4] : "Today", onclick:o.events.gotoToday},{className:"next-but", id:"-next-month-but", text:"\u203A", title:datePicker.titles[1], onmousedown:function(e) { o.events.incDec(e,0,0,1); }, onmouseout:o.events.clearTimer },{className:"next-but", id:"-next-year-but", text:"\u00BB", title:datePicker.titles[3], onmousedown:function(e) { o.events.incDec(e,0,1,0); }, onmouseout:o.events.clearTimer }]); + + tableBody = document.createElement('tbody'); + o.table.appendChild( tableBody ); + + for(var rows = 0; rows < 7; rows++) { + row = document.createElement('tr'); + + if(rows != 0) tableBody.appendChild(row); + else tableHead.appendChild(row); + + for(var cols = 0; cols < 7; cols++) { + col = (rows == 0) ? document.createElement('th') : document.createElement('td'); + + row.appendChild(col); + if(rows != 0) { + col.appendChild(document.createTextNode(o.nbsp)); + col.onmouseover = o.events.onmouseover; + col.onclick = o.events.onclick; + } else { + col.className = "date-picker-day-header"; + col.scope = "col"; + }; + col = null; + }; + row = null; + }; + + // Table headers + var but; + var ths = o.table.getElementsByTagName('thead')[0].getElementsByTagName('tr')[2].getElementsByTagName('th'); + for ( var y = 0; y < 7; y++ ) { + if(y > 0) { + but = document.createElement("span"); + but.className = "fd-day-header"; + but.onclick = ths[y].onclick = o.setFirstDayOfWeek; + but.appendChild(document.createTextNode(o.nbsp)); + ths[y].appendChild(but); + but = null; + } else { + ths[y].appendChild(document.createTextNode(o.nbsp)); + }; + }; + + o.ths = o.table.getElementsByTagName('thead')[0].getElementsByTagName('tr')[2].getElementsByTagName('th'); + o.trs = o.table.getElementsByTagName('tbody')[0].getElementsByTagName('tr'); + + o.updateTableHeaders(); + + tableBody = tableHead = tr = createThAndButton = createTH = null; + + if(o.low && o.high && (o.high - o.low < 7)) { o.equaliseDates(); }; + + o.created = true; + + if(o.staticPos) { + var yyN = document.getElementById(o.id); + datePickerController.addEvent(yyN, "change", o.changeHandler); + if(o.splitDate) { + var mmN = document.getElementById(o.id+'-mm'); + var ddN = document.getElementById(o.id+'-dd'); + datePickerController.addEvent(mmN, "change", o.changeHandler); + datePickerController.addEvent(ddN, "change", o.changeHandler); + }; + + o.show(); + } else { + o.createButton(); + o.resize(); + o.fade(); + }; + }; + o.changeHandler = function() { + o.setDateFromInput(); + o.updateTable(); + }; + o.setDateFromInput = function() { + function m2c(val) { + return String(val).length < 2 ? "00".substring(0, 2 - String(val).length) + String(val) : val; + }; + + o.dateSet = null; + + var elem = o.getElem(); + if(!elem) return; + + if(!o.splitDate) { + var date = datePickerController.dateFormat(elem.value, o.format.search(/m-d-y/i) != -1); + } else { + var mmN = document.getElementById(o.id+'-mm'); + var ddN = document.getElementById(o.id+'-dd'); + var tm = parseInt(mmN.tagName.toLowerCase() == "input" ? mmN.value : mmN.options[mmN.selectedIndex].value, 10); + var td = parseInt(ddN.tagName.toLowerCase() == "input" ? ddN.value : ddN.options[ddN.selectedIndex].value, 10); + var ty = parseInt(elem.tagName.toLowerCase() == "input" ? elem.value : elem.options[elem.selectedIndex || 0].value, 10); + var date = datePickerController.dateFormat(tm + "/" + td + "/" + ty, true); + }; + + var badDate = false; + if(!date) { + badDate = true; + date = String(new Date().getFullYear()) + m2c(new Date().getMonth()+1) + m2c(new Date().getDate()); + }; + + var d,m,y; + y = Number(date.substr(0, 4)); + m = Number(date.substr(4, 2)) - 1; + d = Number(date.substr(6, 2)); + + var dpm = datePicker.getDaysPerMonth(m, y); + if(d > dpm) d = dpm; + + if(new Date(y, m, d) == 'Invalid Date' || new Date(y, m, d) == 'NaN') { + badDate = true; + o.date = new Date(); + o.date.setHours(5); + return; + }; + + o.date = new Date(y, m, d); + o.date.setHours(5); + + if(!badDate) o.dateSet = new Date(o.date); + m2c = null; + }; + o.setSelectIndex = function(elem, indx) { + var len = elem.options.length; + indx = Number(indx); + for(var opt = 0; opt < len; opt++) { + if(elem.options[opt].value == indx) { + elem.selectedIndex = opt; + return; + }; + }; + }, + o.returnFormattedDate = function() { + + var elem = o.getElem(); + if(!elem) return; + + var d = (o.date.getDate() < 10) ? "0" + o.date.getDate() : o.date.getDate(); + var m = ((o.date.getMonth() + 1) < 10) ? "0" + (o.date.getMonth() + 1) : o.date.getMonth() + 1; + var yyyy = o.date.getFullYear(); + var disabledDates = o.getDisabledDates(yyyy, m); + var weekDay = ( o.date.getDay() + 6 ) % 7; + + if(!(o.disableDays[weekDay] || String(yyyy)+m+d in disabledDates)) { + + if(o.splitDate) { + var ddE = document.getElementById(o.id+"-dd"); + var mmE = document.getElementById(o.id+"-mm"); + + if(ddE.tagName.toLowerCase() == "input") { ddE.value = d; } + else { o.setSelectIndex(ddE, d); /*ddE.selectedIndex = d - 1;*/ }; + + if(mmE.tagName.toLowerCase() == "input") { mmE.value = m; } + else { o.setSelectIndex(mmE, m); /*mmE.selectedIndex = m - 1;*/ }; + + if(elem.tagName.toLowerCase() == "input") elem.value = yyyy; + else { + o.setSelectIndex(elem, yyyy); /* + for(var opt = 0; opt < elem.options.length; opt++) { + if(elem.options[opt].value == yyyy) { + elem.selectedIndex = opt; + break; + }; + }; + */ + }; + } else { + elem.value = o.format.replace('y',yyyy).replace('m',m).replace('d',d).replace(/-/g,o.divider); + }; + if(!elem.type || elem.type && elem.type != "hidden"){ elem.focus(); } + if(o.staticPos) { + o.dateSet = new Date( o.date ); + o.updateTable(); + }; + + // Programmatically fire the onchange event + if(document.createEvent) { + var onchangeEvent = document.createEvent('HTMLEvents'); + onchangeEvent.initEvent('change', true, false); + elem.dispatchEvent(onchangeEvent); + } else if(document.createEventObject) { + elem.fireEvent('onchange'); + }; + }; + }; + o.disableTodayButton = function() { + var today = new Date(); + document.getElementById(o.id + "-today-but").className = document.getElementById(o.id + "-today-but").className.replace("fd-disabled", ""); + if(o.outOfRange(today) || (o.date.getDate() == today.getDate() && o.date.getMonth() == today.getMonth() && o.date.getFullYear() == today.getFullYear())) { + document.getElementById(o.id + "-today-but").className += " fd-disabled"; + document.getElementById(o.id + "-today-but").onclick = null; + } else { + document.getElementById(o.id + "-today-but").onclick = o.events.gotoToday; + }; + }; + o.updateTableHeaders = function() { + var d, but; + var ths = o.ths; + for ( var y = 0; y < 7; y++ ) { + d = (o.firstDayOfWeek + y) % 7; + ths[y].title = datePicker.fullDay[d]; + + if(y > 0) { + but = ths[y].getElementsByTagName("span")[0]; + but.removeChild(but.firstChild); + but.appendChild(document.createTextNode(datePicker.dayAbbr ? datePicker.dayAbbr[d] : datePicker.fullDay[d].charAt(0))); + but.title = datePicker.fullDay[d]; + but = null; + } else { + ths[y].removeChild(ths[y].firstChild); + ths[y].appendChild(document.createTextNode(datePicker.dayAbbr ? datePicker.dayAbbr[d] : datePicker.fullDay[d].charAt(0))); + }; + }; + o.updateTable(); + }; + + o.updateTable = function(noCallback) { + + if(o.timerSet) { + var d = new Date(o.date); + d.setDate( Math.min(d.getDate()+o.dayInc, datePicker.getDaysPerMonth(d.getMonth()+o.monthInc,d.getFullYear()+o.yearInc)) ); + d.setMonth( d.getMonth() + o.monthInc ); + d.setFullYear( d.getFullYear() + o.yearInc ); + o.date = d; + }; + + if(!noCallback && "onupdate" in datePickerController && typeof(datePickerController.onupdate) == "function") datePickerController.onupdate(o); + + o.outOfRange(); + o.disableTodayButton(); + + // Set the tmpDate to the second day of this month (to avoid daylight savings time madness on Windows) + var tmpDate = new Date( o.date.getFullYear(), o.date.getMonth(), 2 ); + tmpDate.setHours(5); + + var tdm = tmpDate.getMonth(); + var tdy = tmpDate.getFullYear(); + + // Do the disableDates for this year and month + var disabledDates = o.getDisabledDates(o.date.getFullYear(), o.date.getMonth() + 1); + + var today = new Date(); + + // Previous buttons out of range + var b = document.getElementById(o.id + "-prev-year-but"); + b.className = b.className.replace("fd-disabled", ""); + if(o.outOfRange(new Date((tdy - 1), Number(tdm), datePicker.getDaysPerMonth(Number(tdm), tdy-1)))) { + b.className += " fd-disabled"; + if(o.yearInc == -1) o.stopTimer(); + }; + + b = document.getElementById(o.id + "-prev-month-but") + b.className = b.className.replace("fd-disabled", ""); + if(o.outOfRange(new Date(tdy, (Number(tdm) - 1), datePicker.getDaysPerMonth(Number(tdm)-1, tdy)))) { + b.className += " fd-disabled"; + if(o.monthInc == -1) o.stopTimer(); + }; + + // Next buttons out of range + b= document.getElementById(o.id + "-next-year-but") + b.className = b.className.replace("fd-disabled", ""); + if(o.outOfRange(new Date((tdy + 1), Number(tdm), 1))) { + b.className += " fd-disabled"; + if(o.yearInc == 1) o.stopTimer(); + }; + + b = document.getElementById(o.id + "-next-month-but") + b.className = b.className.replace("fd-disabled", ""); + if(o.outOfRange(new Date(tdy, Number(tdm) + 1, 1))) { + b.className += " fd-disabled"; + if(o.monthInc == 1) o.stopTimer(); + }; + + b = null; + + var cd = o.date.getDate(); + var cm = o.date.getMonth(); + var cy = o.date.getFullYear(); + + // Title Bar + var span = o.titleBar.getElementsByTagName("span"); + while(span[0].firstChild) span[0].removeChild(span[0].firstChild); + while(span[1].firstChild) span[1].removeChild(span[1].firstChild); + span[0].appendChild(document.createTextNode(datePicker.months[cm] + o.nbsp)); + span[1].appendChild(document.createTextNode(cy)); + + tmpDate.setDate( 1 ); + + var dt, cName, td, tds, i; + var weekDay = ( tmpDate.getDay() + 6 ) % 7; + var firstColIndex = (( (weekDay - o.firstDayOfWeek) + 7 ) % 7) - 1; + var dpm = datePicker.getDaysPerMonth(cm, cy); + + var todayD = today.getDate(); + var todayM = today.getMonth(); + var todayY = today.getFullYear(); + + var c = "class"; + /*@cc_on + @if(@_win32) + c = "className"; + @end + @*/ + + var stub = String(tdy) + (String(tdm+1).length < 2 ? "0" + (tdm+1) : tdm+1); + + for(var row = 0; row < 6; row++) { + + tds = o.trs[row].getElementsByTagName('td'); + + for(var col = 0; col < 7; col++) { + + td = tds[col]; + td.removeChild(td.firstChild); + + td.setAttribute("id", ""); + td.setAttribute("title", ""); + + i = (row * 7) + col; + + if(i > firstColIndex && i <= (firstColIndex + dpm)) { + dt = i - firstColIndex; + + tmpDate.setDate(dt); + td.appendChild(document.createTextNode(dt)); + + if(o.outOfRange(tmpDate)) { + td.setAttribute(c, "out-of-range"); + } else { + + cName = []; + weekDay = ( tmpDate.getDay() + 6 ) % 7; + + if(dt == todayD && tdm == todayM && tdy == todayY) { + cName.push("date-picker-today"); + }; + + if(o.dateSet != null && o.dateSet.getDate() == dt && o.dateSet.getMonth() == tdm && o.dateSet.getFullYear() == tdy) { + cName.push("date-picker-selected-date"); + }; + + if(o.disableDays[weekDay] || stub + String(dt < 10 ? "0" + dt : dt) in disabledDates) { + cName.push("day-disabled"); + } else if(o.highlightDays[weekDay]) { + cName.push("date-picker-highlight"); + }; + + if(cd == dt) { + td.setAttribute("id", o.id + "-date-picker-hover"); + cName.push("date-picker-hover"); + }; + + cName.push("dm-" + dt + '-' + (tdm + 1) + " " + " dmy-" + dt + '-' + (tdm + 1) + '-' + tdy); + td.setAttribute(c, cName.join(' ')); + td.setAttribute("title", datePicker.months[cm] + o.nbsp + dt + "," + o.nbsp + cy); + }; + } else { + td.appendChild(document.createTextNode(o.nbsp)); + td.setAttribute(c, "date-picker-unused"); + }; + }; + }; + + if(o.timerSet) { + o.timerInc = 50 + Math.round(((o.timerInc - 50) / 1.8)); + o.timer = window.setTimeout(o.updateTable, o.timerInc); + }; + }; + o.addKeyboardEvents = function() { + datePickerController.addEvent(document, "keypress", o.events.onkeydown); + /*@cc_on + @if(@_win32) + datePickerController.removeEvent(document, "keypress", o.events.onkeydown); + datePickerController.addEvent(document, "keydown", o.events.onkeydown); + @end + @*/ + if(window.devicePixelRatio) { + datePickerController.removeEvent(document, "keypress", o.events.onkeydown); + datePickerController.addEvent(document, "keydown", o.events.onkeydown); + }; + }; + o.removeKeyboardEvents =function() { + datePickerController.removeEvent(document, "keypress", o.events.onkeydown); + datePickerController.removeEvent(document, "keydown", o.events.onkeydown); + }; + o.show = function() { + var elem = o.getElem(); + if(!elem || o.visible || elem.disabled) return; + + o.reset(); + o.setDateFromInput(); + o.updateTable(); + + if(!o.staticPos) o.resize(); + + datePickerController.addEvent(o.staticPos ? o.table : document, "mousedown", o.events.onmousedown); + + if(!o.staticPos) { o.addKeyboardEvents(); }; + + o.opacityTo = o.noTransparency ? 99 : 90; + o.div.style.display = "block"; + /*@cc_on + @if(@_jscript_version <= 5.6) + if(!o.staticPos) o.iePopUp.style.display = "block"; + @end + @*/ + + o.fade(); + o.visible = true; + }; + o.hide = function() { + if(!o.visible) return; + o.stopTimer(); + if(o.staticPos) return; + + datePickerController.removeEvent(document, "mousedown", o.events.onmousedown); + datePickerController.removeEvent(document, "mouseup", o.events.clearTimer); + o.removeKeyboardEvents(); + + /*@cc_on + @if(@_jscript_version <= 5.6) + o.iePopUp.style.display = "none"; + @end + @*/ + + o.opacityTo = 0; + o.fade(); + o.visible = false; + var elem = o.getElem(); + if(!elem.type || elem.type && elem.type != "hidden") { elem.focus(); }; + }; + o.destroy = function() { + // Cleanup for Internet Explorer + datePickerController.removeEvent(o.staticPos ? o.table : document, "mousedown", o.events.onmousedown); + datePickerController.removeEvent(document, "mouseup", o.events.clearTimer); + o.removeKeyboardEvents(); + + if(o.staticPos) { + var yyN = document.getElementById(o.id); + datePickerController.removeEvent(yyN, "change", o.changeHandler); + if(o.splitDate) { + var mmN = document.getElementById(o.id+'-mm'); + var ddN = document.getElementById(o.id+'-dd'); + + datePickerController.removeEvent(mmN, "change", o.changeHandler); + datePickerController.removeEvent(ddN, "change", o.changeHandler); + }; + o.div.onfocus = o.div.onblur = null; + }; + + var ths = o.table.getElementsByTagName("th"); + for(var i = 0, th; th = ths[i]; i++) { + th.onmouseover = th.onmouseout = th.onmousedown = th.onclick = null; + }; + + var tds = o.table.getElementsByTagName("td"); + for(var i = 0, td; td = tds[i]; i++) { + td.onmouseover = td.onclick = null; + }; + + var butts = o.table.getElementsByTagName("span"); + for(var i = 0, butt; butt = butts[i]; i++) { + butt.onmousedown = butt.onclick = butt.onkeypress = null; + }; + + o.ths = o.trs = null; + + clearTimeout(o.fadeTimer); + clearTimeout(o.timer); + o.fadeTimer = o.timer = null; + + /*@cc_on + @if(@_jscript_version <= 5.6) + o.iePopUp = null; + @end + @*/ + + if(!o.staticPos && document.getElementById(o.id.replace(/^fd-/, 'fd-but-'))) { + var butt = document.getElementById(o.id.replace(/^fd-/, 'fd-but-')); + butt.onclick = butt.onpress = null; + }; + + if(o.div && o.div.parentNode) { + o.div.parentNode.removeChild(o.div); + }; + + o.titleBar = o.table = o.div = null; + o = null; + }; + o.create(); +}; + +datePickerController = function() { + var datePickers = {}; + var uniqueId = 0; + + var addEvent = function(obj, type, fn) { + if( obj.attachEvent ) { + obj["e"+type+fn] = fn; + obj[type+fn] = function(){obj["e"+type+fn]( window.event );}; + obj.attachEvent( "on"+type, obj[type+fn] ); + } else { + obj.addEventListener( type, fn, true ); + }; + }; + var removeEvent = function(obj, type, fn) { + try { + if( obj.detachEvent ) { + obj.detachEvent( "on"+type, obj[type+fn] ); + obj[type+fn] = null; + } else { + obj.removeEventListener( type, fn, true ); + }; + } catch(err) {}; + }; + var hideAll = function(exception) { + var dp; + for(dp in datePickers) { + if(!datePickers[dp].created || datePickers[dp].staticPos) continue; + if(exception && exception == datePickers[dp].id) { continue; }; + if(document.getElementById(datePickers[dp].id)) { datePickers[dp].hide(); }; + }; + }; + var cleanUp = function() { + var dp; + for(dp in datePickers) { + if(!document.getElementById(datePickers[dp].id)) { + if(!datePickers[dp].created) continue; + datePickers[dp].destroy(); + datePickers[dp] = null; + delete datePickers[dp]; + }; + }; + }; + var destroy = function() { + for(dp in datePickers) { + if(!datePickers[dp].created) continue; + datePickers[dp].destroy(); + datePickers[dp] = null; + delete datePickers[dp]; + }; + datePickers = null; + /*@cc_on + @if(@_jscript_version <= 5.6) + if(document.getElementById("iePopUpHack")) { + document.body.removeChild(document.getElementById("iePopUpHack")); + }; + @end + @*/ + datePicker.script = null; + removeEvent(window, 'load', datePickerController.create); + removeEvent(window, 'unload', datePickerController.destroy); + }; + var dateFormat = function(dateIn, favourMDY) { + var dateTest = [ + { regExp:/^(0?[1-9]|[12][0-9]|3[01])([- \/.])(0?[1-9]|1[012])([- \/.])((\d\d)?\d\d)$/, d:1, m:3, y:5 }, // dmy + { regExp:/^(0?[1-9]|1[012])([- \/.])(0?[1-9]|[12][0-9]|3[01])([- \/.])((\d\d)?\d\d)$/, d:3, m:1, y:5 }, // mdy + { regExp:/^(\d\d\d\d)([- \/.])(0?[1-9]|1[012])([- \/.])(0?[1-9]|[12][0-9]|3[01])$/, d:5, m:3, y:1 } // ymd + ]; + + var start; + var cnt = 0; + while(cnt < 3) { + start = (cnt + (favourMDY ? 4 : 3)) % 3; + if(dateIn.match(dateTest[start].regExp)) { + res = dateIn.match(dateTest[start].regExp); + y = res[dateTest[start].y]; + m = res[dateTest[start].m]; + d = res[dateTest[start].d]; + if(m.length == 1) m = "0" + m; + if(d.length == 1) d = "0" + d; + if(y.length != 4) y = (parseInt(y) < 50) ? '20' + y : '19' + y; + return String(y)+m+d; + }; + cnt++; + }; + return 0; + }; + var joinNodeLists = function() { + if(!arguments.length) { return []; } + var nodeList = []; + for (var i = 0; i < arguments.length; i++) { + for (var j = 0, item; item = arguments[i][j]; j++) { + nodeList[nodeList.length] = item; + }; + }; + return nodeList; + }; + var addDatePicker = function(inpId, options) { + if(!(inpId in datePickers)) { + datePickers[inpId] = new datePicker(options); + }; + }; + var getDatePicker = function(inpId) { + if(!(inpId in datePickers)) { throw "No datePicker has been created for the form element with an id of '" + inpId.toString() + "'"; }; + return datePickers[inpId]; + }; + var grepRangeLimits = function(sel) { + var range = []; + for(var i = 0; i < sel.options.length; i++) { + if(sel.options[i].value.search(/^\d\d\d\d$/) == -1) { continue; }; + if(!range[0] || Number(sel.options[i].value) < range[0]) { range[0] = Number(sel.options[i].value); }; + if(!range[1] || Number(sel.options[i].value) > range[1]) { range[1] = Number(sel.options[i].value); }; + }; + return range; + }; + var create = function(inp) { + if(!(typeof document.createElement != "undefined" && typeof document.documentElement != "undefined" && typeof document.documentElement.offsetWidth == "number")) return; + + var inputs = (inp && inp.tagName) ? [inp] : joinNodeLists(document.getElementsByTagName('input'), document.getElementsByTagName('select')); + var regExp1 = /disable-days-([1-7]){1,6}/g; // the days to disable + var regExp2 = /no-transparency/g; // do not use transparency effects + var regExp3 = /highlight-days-([1-7]){1,7}/g; // the days to highlight in red + var regExp4 = /range-low-(\d\d\d\d-\d\d-\d\d)/g; // the lowest selectable date + var regExp5 = /range-high-(\d\d\d\d-\d\d-\d\d)/g; // the highest selectable date + var regExp6 = /format-(d-m-y|m-d-y|y-m-d)/g; // the input/output date format + var regExp7 = /divider-(dot|slash|space|dash)/g; // the character used to divide the date + var regExp8 = /no-locale/g; // do not attempt to detect the browser language + var regExp9 = /no-fade/g; // always show the datepicker + var regExp10 = /hide-input/g; // hide the input + + for(var i=0, inp; inp = inputs[i]; i++) { + if(inp.className && (inp.className.search(regExp6) != -1 || inp.className.search(/split-date/) != -1) && ((inp.tagName.toLowerCase() == "input" && (inp.type == "text" || inp.type == "hidden")) || inp.tagName.toLowerCase() == "select")) { + + if(inp.id && document.getElementById('fd-'+inp.id)) { continue; }; + + if(!inp.id) { inp.id = "fdDatePicker-" + uniqueId++; }; + + var options = { + id:inp.id, + low:"", + high:"", + divider:"/", + format:"d-m-y", + highlightDays:[0,0,0,0,0,1,1], + disableDays:[0,0,0,0,0,0,0], + locale:inp.className.search(regExp8) == -1, + splitDate:0, + noTransparency:inp.className.search(regExp2) != -1, + staticPos:inp.className.search(regExp9) != -1, + hideInput:inp.className.search(regExp10) != -1 + }; + + if(!options.staticPos) { + options.hideInput = false; + } else { + options.noTransparency = true; + }; + + // Split the date into three parts ? + if(inp.className.search(/split-date/) != -1) { + if(document.getElementById(inp.id+'-dd') && document.getElementById(inp.id+'-mm') && document.getElementById(inp.id+'-dd').tagName.search(/input|select/i) != -1 && document.getElementById(inp.id+'-mm').tagName.search(/input|select/i) != -1) { + options.splitDate = 1; + }; + }; + + // Date format(variations of d-m-y) + if(inp.className.search(regExp6) != -1) { + options.format = inp.className.match(regExp6)[0].replace('format-',''); + }; + + // What divider to use, a "/", "-", "." or " " + if(inp.className.search(regExp7) != -1) { + var dividers = { dot:".", space:" ", dash:"-", slash:"/" }; + options.divider = (inp.className.search(regExp7) != -1 && inp.className.match(regExp7)[0].replace('divider-','') in dividers) ? dividers[inp.className.match(regExp7)[0].replace('divider-','')] : "/"; + }; + + // The days to highlight + if(inp.className.search(regExp3) != -1) { + var tmp = inp.className.match(regExp3)[0].replace(/highlight-days-/, ''); + options.highlightDays = [0,0,0,0,0,0,0]; + for(var j = 0; j < tmp.length; j++) { + options.highlightDays[tmp.charAt(j) - 1] = 1; + }; + }; + + // The days to disable + if(inp.className.search(regExp1) != -1) { + var tmp = inp.className.match(regExp1)[0].replace(/disable-days-/, ''); + options.disableDays = [0,0,0,0,0,0,0]; + for(var j = 0; j < tmp.length; j++) { + options.disableDays[tmp.charAt(j) - 1] = 1; + }; + }; + + // The lower limit + if(inp.className.search(/range-low-today/i) != -1) { + options.low = datePickerController.dateFormat((new Date().getMonth() + 1) + "/" + new Date().getDate() + "/" + new Date().getFullYear(), true); + } else if(inp.className.search(regExp4) != -1) { + options.low = datePickerController.dateFormat(inp.className.match(regExp4)[0].replace(/range-low-/, ''), false); + if(!options.low) { + options.low = ''; + }; + }; + + // The higher limit + if(inp.className.search(/range-high-today/i) != -1 && inp.className.search(/range-low-today/i) == -1) { + options.high = datePickerController.dateFormat((new Date().getMonth() + 1) + "/" + new Date().getDate() + "/" + new Date().getFullYear(), true); + } else if(inp.className.search(regExp5) != -1) { + options.high = datePickerController.dateFormat(inp.className.match(regExp5)[0].replace(/range-high-/, ''), false); + if(!options.high) { + options.high = ''; + }; + }; + + // Always round lower & higher limits if a selectList involved + if(inp.tagName.search(/select/i) != -1) { + var range = grepRangeLimits(inp); + options.low = options.low ? range[0] + String(options.low).substr(4,4) : datePickerController.dateFormat(range[0] + "/01/01"); + options.high = options.high ? range[1] + String(options.low).substr(4,4) : datePickerController.dateFormat(range[1] + "/12/31"); + }; + + addDatePicker(inp.id, options); + }; + }; + } + + return { + addEvent:addEvent, + removeEvent:removeEvent, + create:create, + destroy:destroy, + cleanUp:cleanUp, + addDatePicker:addDatePicker, + getDatePicker:getDatePicker, + dateFormat:dateFormat, + datePickers:datePickers, + hideAll:hideAll + }; +}(); + +})(); + +datePickerController.addEvent(window, 'load', datePickerController.create); +datePickerController.addEvent(window, 'unload', datePickerController.destroy); diff --git a/public/javascripts/lang/af.js b/public/javascripts/lang/af.js new file mode 100644 index 00000000..1e2e21e1 --- /dev/null +++ b/public/javascripts/lang/af.js @@ -0,0 +1,40 @@ +var fdLocale = { + months:[ + "Januarie", + "Februarie", + "Maart", + "April", + "Mei", + "Junie", + "Julie", + "Augustus", + "September", + "Oktober", + "November", + "Desember" + ], + fullDay:[ + "Maandag", + "Dinsdag", + "Woensdag", + "Donderdag", + "Vrydag", + "Saterdag", + "Sondag" + ], + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + + dayAbbr:[], + */ + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + titles:[ + "Vorige maand", + "Volgende maand", + "Vorige jaar", + "Volgende jaar" + ] +}; diff --git a/public/javascripts/lang/ar.js b/public/javascripts/lang/ar.js new file mode 100644 index 00000000..602091a0 --- /dev/null +++ b/public/javascripts/lang/ar.js @@ -0,0 +1,50 @@ +var fdLocale = { + months:[ + "يناير", + "فبراير", + "مارس", + "أبريل", + "مايو", + "يونيو", + "يوليو", + "أغسطس", + "سبتمبر", + "أكتوبر", + "نوٿمبر", + "ديسمبر" + ], + fullDay:[ + "الاثنين", + "الثلاثاء", + "الأربعاء", + "الخميس", + "الجمعة", + "السبت", + "الأحد" + ], + + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice */ + + + dayAbbr:[ + "الاثنين", + "الثلاثاء", + "الأربعاء", + "الخميس", + "الجمعة", + "السبت", + "الأحد" + ], + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + + titles:[ + "الشهر السابق", + "الشهر المقبل", + "السنة السابقة", + "السنة المقبلة" + ] +}; diff --git a/public/javascripts/lang/de.js b/public/javascripts/lang/de.js new file mode 100644 index 00000000..f13de395 --- /dev/null +++ b/public/javascripts/lang/de.js @@ -0,0 +1,40 @@ +var fdLocale = { + months:[ + "Januar", + "Februar", + "M\u00e4rz", + "April", + "Mai", + "Juni", + "Juli", + "August", + "September", + "Oktober", + "November", + "Dezember" + ], + fullDay:[ + "Montag", + "Dienstag", + "Mittwoch", + "Donnerstag", + "Freitag", + "Samstag", + "Sonntag" + ], + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + + dayAbbr:[], + */ + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + titles:[ + "Voriger Monat", + "N\u00e4chst. Monat", + "Voriges Jahr", + "N\u00e4chst. Jahr" + ] +}; diff --git a/public/javascripts/lang/du.js b/public/javascripts/lang/du.js new file mode 100644 index 00000000..5d77b6b9 --- /dev/null +++ b/public/javascripts/lang/du.js @@ -0,0 +1,40 @@ +var fdLocale = { + months:[ + "Januari", + "Februari", + "Maart", + "April", + "Mei", + "Juni", + "Juli", + "Augustus", + "September", + "Oktober", + "November", + "December" + ], + fullDay:[ + "Maandag", + "Dinsdag", + "Woensdag", + "Donderdag", + "Vrijdag", + "Zaterdag", + "Zondag" + ], + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + + dayAbbr:[], + */ + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + titles:[ + "Vorige Maand", + "Volgende Maand", + "Vorig jaar", + "Volgend jaar" + ] +}; diff --git a/public/javascripts/lang/en.js b/public/javascripts/lang/en.js new file mode 100644 index 00000000..fe5eec40 --- /dev/null +++ b/public/javascripts/lang/en.js @@ -0,0 +1,42 @@ +var fdLocale = { + months:[ + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December" + ], + fullDay:[ + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", + "Sunday" + ], + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + + dayAbbr:[], + */ + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + titles:[ + "Previous month", + "Next month", + "Previous year", + "Next year", + "Today", + "Show Calendar" + ] +}; diff --git a/public/javascripts/lang/es.js b/public/javascripts/lang/es.js new file mode 100644 index 00000000..4aecdcd6 --- /dev/null +++ b/public/javascripts/lang/es.js @@ -0,0 +1,41 @@ +var fdLocale = { + months:[ + "Enero", + "Febrero", + "Marzo", + "Abril", + "Mayo", + "Junio", + "Julio", + "Agosto", + "Septiembre", + "Octubre", + "Noviembre", + "Diciembre" + ], + fullDay:[ + "Lunes", + "Martes", + "Mi\u00e9rcoles", + "Jueves", + "Viernes", + "S\u00e1bado", + "Domingo" + ], + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + + dayAbbr:[], + */ + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + titles:[ + "Mes Anterior", + "Mes Siguiente", + "A\u00f1o anterior", + "A\u00f1o Siguiente", + "Hoy" + ] +}; diff --git a/public/javascripts/lang/fi.js b/public/javascripts/lang/fi.js new file mode 100644 index 00000000..1e204f3b --- /dev/null +++ b/public/javascripts/lang/fi.js @@ -0,0 +1,40 @@ +var fdLocale = { + months:[ + "Tammikuu", + "Helmikuu", + "Maaliskuu", + "Huhtikuu", + "Toukokuu", + "Kes\u00e4kuu", + "Hein\u00e4kuu", + "Elokuu", + "Syyskuu", + "Lokakuu", + "Marraskuu", + "Joulukuu" + ], + fullDay:[ + "Maanantai", + "Tiistai", + "Keskiviikko", + "Torstai", + "Perjantai", + "Lauantai", + "Sunnuntai" + ], + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + + dayAbbr:[], + */ + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + titles:[ + "Edellinen kuukausi", + "Seuraava kuukausi", + "Edellinen vuosi", + "Seuraava vuosi" + ] +}; diff --git a/public/javascripts/lang/fr.js b/public/javascripts/lang/fr.js new file mode 100644 index 00000000..fb524a30 --- /dev/null +++ b/public/javascripts/lang/fr.js @@ -0,0 +1,44 @@ +var fdLocale = { + months:[ + "Janvier", + "F\u00E9vrier", + "Mars", + "Avril", + "Mai", + "Juin", + "Juillet", + "Ao\u00FBt", + "Septembre", + "Octobre", + "Novembre", + "D\u00E9cembre" + ], + fullDay:[ + "Lundi", + "Mardi", + "Mercredi", + "Jeudi", + "Vendredi", + "Samedi", + "Dimanche" + ], + + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + + dayAbbr:[], + */ + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + + titles:[ + "Mois pr\u00E9cedent", + "Mois suivant", + "Ann\u00E9e pr\u00E9cedente", + "Ann\u00E9e suivante", + "Aujourd\u2019hui", + "Voir Calendrier" + ] +}; diff --git a/public/javascripts/lang/gr.js b/public/javascripts/lang/gr.js new file mode 100644 index 00000000..8f52c108 --- /dev/null +++ b/public/javascripts/lang/gr.js @@ -0,0 +1,40 @@ +var fdLocale = { + months:[ + "Ιανουάριος", + "Φεβρουάριος", + "Μάρτιος", + "Απρίλιος", + "Μάιος", + "Ιούνιος", + "Ιούλιος", + "Αύγουστος", + "Σεπτέμβριος", + "Οκτώβριος", + "Νοέμβριος", + "Δεκέμβριος" + ], + fullDay:[ + "Δευτέρα", + "Τρίτη", + "Τετάρτη", + "Πέμπτη", + "Παρασκευή", + "Σάββατο", + "Κυριακή" + ], + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + + dayAbbr:[], + */ + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + titles:[ + "Προηγούμενος μήνας", + "Επόμενος μήνας", + "Προηγούμενη χρόνιά", + "Επόμενη χρονιά" + ] +}; \ No newline at end of file diff --git a/public/javascripts/lang/he.js b/public/javascripts/lang/he.js new file mode 100644 index 00000000..8b1167a3 --- /dev/null +++ b/public/javascripts/lang/he.js @@ -0,0 +1,49 @@ +var fdLocale = { + months:[ + "ינואר", + "פברואר", + "מרץ", + "אפריל", + "מאי", + "יוני", + "יולי", + "אוגוסט", + "ספטמבר", + "אוקטובר", + "נובמבר", + "דצמבר" + ], + fullDay:[ + "שני", + "שלישי", + "רביעי", + "חמישי", + "שישי", + "שבת", + "ראשון" + ], + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + */ + dayAbbr:[ + 'ב', + 'ג', + 'ד', + 'ה', + 'ו', + 'ש', + 'א' + ], + + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + */ + firstDayOfWeek:6, + + titles:[ + "חודש קודם", + "חודש הבא", + "שנה קודמת", + "שנה הבאה", + "היום" + ] +}; diff --git a/public/javascripts/lang/it.js b/public/javascripts/lang/it.js new file mode 100644 index 00000000..828f21fc --- /dev/null +++ b/public/javascripts/lang/it.js @@ -0,0 +1,13 @@ +// italian translation by raf + +var fdLocale = { + months:[ "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre" ], + fullDay:[ "Luned\u00ec", "Marted\u00ec", "Mercoled\u00ec", "Gioved\u00ec", "Venerd\u00ec", "Sabato", "Domenica" ], + /* + Only stipulate the dayAbbr should the first letter of the fullDay not suffice + dayAbbr:[], + Only stipulate the firstDayOfWeek should the first day not be Monday + firstDayOfWeek:0, + */ + titles:[ "Mese Precedente", "Mese Successivo", "Anno Precedente", "Anno Successivo", "Oggi" ] +}; diff --git a/public/javascripts/lang/nl.js b/public/javascripts/lang/nl.js new file mode 100644 index 00000000..5d77b6b9 --- /dev/null +++ b/public/javascripts/lang/nl.js @@ -0,0 +1,40 @@ +var fdLocale = { + months:[ + "Januari", + "Februari", + "Maart", + "April", + "Mei", + "Juni", + "Juli", + "Augustus", + "September", + "Oktober", + "November", + "December" + ], + fullDay:[ + "Maandag", + "Dinsdag", + "Woensdag", + "Donderdag", + "Vrijdag", + "Zaterdag", + "Zondag" + ], + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + + dayAbbr:[], + */ + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + titles:[ + "Vorige Maand", + "Volgende Maand", + "Vorig jaar", + "Volgend jaar" + ] +}; diff --git a/public/javascripts/lang/no.js b/public/javascripts/lang/no.js new file mode 100644 index 00000000..1a1186ab --- /dev/null +++ b/public/javascripts/lang/no.js @@ -0,0 +1,40 @@ +var fdLocale = { + months:[ + "Januar", + "Februar", + "Mars", + "April", + "Mai", + "Juni", + "Juli", + "August", + "September", + "Oktober", + "November", + "Desember" + ], + fullDay:[ + "Mandag", + "Tirsdag", + "Onsdag", + "Torsdag", + "Fredag", + "L\u00f8rdag", + "S\u00f8ndag" + ], + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + + dayAbbr:[], + */ + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + titles:[ + "Forrige m\u00e5ned", + "Neste m\u00e5ned", + "Forrige \u00e5r", + "Neste \u00e5r" + ] +}; diff --git a/public/javascripts/lang/pt.js b/public/javascripts/lang/pt.js new file mode 100644 index 00000000..ccd77337 --- /dev/null +++ b/public/javascripts/lang/pt.js @@ -0,0 +1,50 @@ +var fdLocale = { + months:[ + "Janeiro", + "Fevereiro", + "Mar\u00E7o", + "Abril", + "Maio", + "Junho", + "Julho", + "Agosto", + "Setembro", + "Outubro", + "Novembro", + "Dezembro" + ], + fullDay:[ + "Segunda", + "Ter\u00E7a", + "Quarta", + "Quinta", + "Sexta", + "S\u00E1bado", + "Domingo" + ], + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + + dayAbbr:[], + */ + dayAbbr:["Seg", + "Ter", + "Qua", + "Qui", + "Sex", + "Sab", + "Dom"], + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + firstDayOfWeek:6, + titles:[ + "M\u00EAs anterior", + "Pr\u00F3ximo m\u00EAs", + "Ano anterior", + "Pr\u00F3ximo ano", + "Hoje", + "Exibir calend\u00E1rio" + ] +}; diff --git a/public/javascripts/lang/ro.js b/public/javascripts/lang/ro.js new file mode 100644 index 00000000..6d801612 --- /dev/null +++ b/public/javascripts/lang/ro.js @@ -0,0 +1,40 @@ +var fdLocale = { + months:[ + "Ianuarie", + "Februarie", + "Martie", + "Aprilie", + "Mai", + "Iunie", + "Iulie", + "August", + "Septembrie", + "Octombrie", + "Noiembrie", + "Decembrie" + ], + fullDay:[ + "Luni", + "Mar\u0163i", + "Miercuri", + "Joi", + "Vineri", + "S\u00e2mb\u00e3t\u00e3", + "Duminic\u00e3" + ], + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + + dayAbbr:[], + */ + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + titles:[ + "Luna anterioar\u00e3", + "Luna urm\u00e3toare", + "Anul anterior", + "Anul urm\u00e3tor" + ] +}; diff --git a/public/javascripts/lang/ru.js b/public/javascripts/lang/ru.js new file mode 100644 index 00000000..d45f224f --- /dev/null +++ b/public/javascripts/lang/ru.js @@ -0,0 +1,40 @@ +var fdLocale = { + months:[ + "Январь", + "Февраль", + "Март", + "Апрель", + "Май", + "Июнь", + "Июль", + "Август", + "Сентябрь", + "Октябрь", + "Ноябрь", + "Декабрь" + ], + fullDay:[ + "Понедельник", + "Вторник", + "Среда", + "Четверг", + "Пятница", + "Суббота", + "Воскресенье" + ], + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + + dayAbbr:[], + */ + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + titles:[ + "Предыдущий месяц", + "Следующий месяц", + "Предыдущий год", + "Следующий год" + ] +}; diff --git a/public/javascripts/lang/sp.js b/public/javascripts/lang/sp.js new file mode 100644 index 00000000..ecfd7dcf --- /dev/null +++ b/public/javascripts/lang/sp.js @@ -0,0 +1,40 @@ +var fdLocale = { + months:[ + "Enero", + "Febrero", + "Marzo", + "Abril", + "Mayo", + "Junio", + "Julio", + "Agosto", + "Septiembre", + "Octubre", + "Noviembre", + "Diciembre" + ], + fullDay:[ + "Lunes", + "Martes", + "Mi\u00e9rcoles", + "Jueves", + "Viernes", + "S\u00e1bado", + "Domingo" + ], + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + + dayAbbr:[], + */ + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + titles:[ + "Mes Anterior", + "Mes Siguiente", + "A\u00f1o Anterior", + "A\u00f1o Siguiente" + ] +}; diff --git a/public/javascripts/lang/sv.js b/public/javascripts/lang/sv.js new file mode 100644 index 00000000..3c5c2a14 --- /dev/null +++ b/public/javascripts/lang/sv.js @@ -0,0 +1,41 @@ +// Swedish +var fdLocale = { + months:[ + "Januari", + "Februari", + "Mars", + "April", + "Maj", + "Juni", + "Juli", + "Augusti", + "September", + "Oktober", + "November", + "December" + ], + fullDay:[ + "M\u00e5ndag", + "Tisdag", + "Onsdag", + "Torsdag", + "Fredag", + "L\u00f6rdag", + "S\u00f6ndag" + ], + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + + dayAbbr:[], + */ + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + titles:[ + "F\u00f6reg\u00e5ende m\u00e5nad", + "N\u00e4sta m\u00e5nad", + "F\u00f6reg\u00e5ende \u00e5r", + "N\u00e4sta \u00e5r" + ] +}; diff --git a/public/javascripts/lang/ua.js b/public/javascripts/lang/ua.js new file mode 100644 index 00000000..9aa2fb63 --- /dev/null +++ b/public/javascripts/lang/ua.js @@ -0,0 +1,40 @@ +var fdLocale = { + months:[ + "Січень", + "Лютий", + "Березень", + "Квітень", + "Травень", + "Червень", + "Липень", + "Серпень", + "Вересень", + "Жовтень", + "Листопад", + "Грудень" + ], + fullDay:[ + "Понеділок", + "Вівторок", + "Середа", + "Четвер", + "П'ятниця", + "Субота", + "Неділя" + ], + /* Only stipulate the dayAbbr should the first letter of the fullDay not suffice + + dayAbbr:[], + */ + + /* Only stipulate the firstDayOfWeek should the first day not be Monday + + firstDayOfWeek:0, + */ + titles:[ + "Попередній місяць", + "Наступний місяць", + "Попередній рік", + "Наступний рік" + ] +}; \ No newline at end of file diff --git a/public/stylesheets/datepicker.css b/public/stylesheets/datepicker.css new file mode 100644 index 00000000..015b551d --- /dev/null +++ b/public/stylesheets/datepicker.css @@ -0,0 +1,263 @@ +/* This is a very basic stylesheet for the date-picker. Feel free to create your own. */ + +/* The wrapper div */ +div.datePicker + { + position:absolute; + min-width:24em; + width:24em; + z-index:9999; + text-align:center; + + /* Change the font-size to suit your design's CSS. The following line is for the demo that has a 12px font-size defined on the body tag */ + font:900 0.8em/0.8em Verdana, Sans-Serif; + + /* For Example: If using the YUI font CSS, uncomment the following line to get a 10px font-size within the datePicker */ + /* font:900 77%/77% Verdana; */ + + background:transparent; + + /* Mozilla & Webkit extensions to stop text-selection. Remove if you wish to validate the CSS */ + -moz-user-select:none; + -khtml-user-select:none; + } +/* Styles for the static datePickers */ +div.staticDP + { + position:relative; + top:5px; + left:0; + } +/* The iframe hack to cover selectlists in Internet Explorer <= v6 */ +iframe.iehack + { + position:absolute; + background:#fff; + z-index:9998; + padding:0; + border:0; + display:none; + margin:0; + } +/* The "button" created beside each input for non-static datePickers */ +a.date-picker-control:link, +a.date-picker-control:visited, +a.date-picker-control:hover, +a.date-picker-control:active, +a.date-picker-control:focus + { + /*position:relative;*/ + /* Moz & FF */ + display: -moz-inline-stack; + border:0 none; + padding:0; + margin:0 0 0 4px; + background:transparent url(/images/datepicker/cal.gif) no-repeat 50% 50%; + min-width:16px; + line-height:1; + cursor:pointer; + visibility:visible; + text-decoration:none; + vertical-align:middle; + } +/* Feed IE6 the following rule, IE7 should handle the min-width declared above */ +* html a.date-picker-control + { + width:16px; + } +a.date-picker-control + { + /* IE, Safari & Opera. Seperate CSS rule seems to be required. */ + display:inline-block; + } +a.date-picker-control span + { + display:block; + width:16px; + height:16px; + margin:auto 0; + } +/* The next & previous buttons */ +div.datePicker th span + { + display:inline; + padding:0; + margin:0; + color:#000; + text-align:center; + line-height:1em; + border-width:0; + font-family: georgia, times new roman, palatino, times, bookman, serif; + background:transparent; + font-weight:bold; + cursor:pointer; + } +div.datePicker th span.month-display, +div.datePicker th span.year-display + { + text-transform:uppercase; + letter-spacing:1px; + font:normal 1.2em Verdana, Sans-Serif; + cursor:default; + } +div.datePicker th span.prev-but, +div.datePicker th span.next-but + { + font-size:1.8em; + cursor:pointer !important; + } + +div.datePicker th span.today-but + { + text-align:center; + margin:0 auto; + font:normal 1em Verdana, Sans-Serif; + width:100%; + text-decoration:none; + line-height:1.6em; + text-transform:uppercase; + cursor:pointer !important + } +div.datePicker thead th span.fd-disabled + { + color:#aaa; + cursor:default !important; + } +/* The mon, tue, wed etc day buttons */ +div.datePicker th span.fd-day-header + { + text-align:center; + margin:0 auto; + font:900 1em Verdana, Sans-Serif; + height:1.4em; + width:2em; + text-decoration:none; + text-transform:lowercase; + line-height:1.4em; + } +/* The table */ +div.datePicker table + { + position:relative; + margin:0; + padding:0; + border:1px solid #ccc; + background:#fff url(/images/datepicker/gradient-e5e5e5-ffffff.gif) repeat-x 0 -20px; + text-align:center; + width:100%; + border-spacing:2px; + table-layout:fixed; + border-collapse:separate; + } +/* Common TD & TH styling */ +div.datePicker table td + { + border:1px solid #ccc; + padding:0; + text-align:center; + vertical-align:middle; + /* Opera requires a line-height bigger than 1em in order to redraw properly */ + line-height:1.2em; + cursor:pointer; + background:#fff url(/images/datepicker/gradient-e5e5e5-ffffff.gif) repeat-x 0 -40px; + width:3em; + height:3em !important; + height:2.8em; + outline:none; + } +div.datePicker table th + { + border:0 none; + padding:0; + line-height:1em; + font-weight:bold; + color:#222; + text-align:center; + vertical-align:middle; + } +div.datePicker table td.date-picker-unused + { + background:#fff url(/images/datepicker/backstripes.gif); + border-color:#dcdcdc; + padding:0; + cursor:default !important; + } +div.datePicker table thead th.date-picker-title + { + width:auto; + height:auto; + padding:0.4em 0; + } +/* The "mon tue wed etc" day header button styles */ +div.datePicker table th.date-picker-day-header + { + text-transform:lowercase; + width:3em; + } +div.datePicker table th.date-picker-day-header span + { + display:block; + } +/* The "todays date" style */ +div.datePicker table td.date-picker-today + { + background:#fff url(/images/datepicker/bullet2.gif) no-repeat 0 0; + color:rgb(100,100,100) !important; + } +/* The "selected date" style */ +div.datePicker table td.date-picker-selected-date + { + color:#333 !important; + border-color:#333 !important; + } +/* the "highlight days" style */ +td.date-picker-highlight + { + color:#a86666; + } +/* The date "out of range" style */ +div.datePicker table td.out-of-range + { + color:#ccc !important; + font-style:oblique; + background:#fcfcfc !important; + cursor:default !important; + } +/* The "disabled days" style */ +div.datePicker table td.day-disabled + { + color:#aaa !important; + background:transparent !important; + cursor:default !important; + } +/* The "active cursor" style */ +div.datePicker table tbody td.date-picker-hover + { + background:#fff url(/images/datepicker/bg_header.jpg) no-repeat 0 0; + cursor:pointer; + border-color:rgb(100,130,170); + color:rgb(100,130,170); + } +/* + Quirksmode necessity? + --------------------- + + If your HTML document renders in quirksmode (i.e. has no doctype declaration) + then uncomment the following CSS rule to set a less drastic font-size in IE + +div.datePicker table th, +div.datePicker table td + { + font-size:100%; + } +*/ + +/* Remove the images for Internet Explorer <= v6 using the "* html" hack */ +* html div.datePicker table td + { + background-image:none; + } +* html div.datePicker table td.date-picker-unused + { + background:#f2f2f2; + } diff --git a/public/stylesheets/ui.datepicker.css b/public/stylesheets/ui.datepicker.css deleted file mode 100644 index 65640e0a..00000000 --- a/public/stylesheets/ui.datepicker.css +++ /dev/null @@ -1,62 +0,0 @@ -/* Datepicker -----------------------------------*/ -.ui-datepicker { width: 17em; padding: .2em .2em 0; background: white; border:1px solid black; padding:0 5px; z-index:5;} -.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; } -.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; } -.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; } -.ui-datepicker .ui-datepicker-prev { left:2px; } -.ui-datepicker .ui-datepicker-next { right:2px; } -.ui-datepicker .ui-datepicker-prev-hover { left:1px; } -.ui-datepicker .ui-datepicker-next-hover { right:1px; } -.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; } -.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; } -.ui-datepicker .ui-datepicker-title select { float:left; font-size:1em; margin:1px 0; } -.ui-datepicker select.ui-datepicker-month-year {width: 100%;} -.ui-datepicker select.ui-datepicker-month, -.ui-datepicker select.ui-datepicker-year { width: 49%;} -.ui-datepicker .ui-datepicker-title select.ui-datepicker-year { float: right; } -.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; } -.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; } -.ui-datepicker td { border: 0; padding: 1px; } -.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; } -.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; } -.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; } -.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; } - -/* with multiple calendars */ -.ui-datepicker.ui-datepicker-multi { width:auto; } -.ui-datepicker-multi .ui-datepicker-group { float:left; } -.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; } -.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; } -.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; } -.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; } -.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; } -.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; } -.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; } -.ui-datepicker-row-break { clear:both; width:100%; } - -/* RTL support */ -.ui-datepicker-rtl { direction: rtl; } -.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; } -.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; } -.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; } -.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; } -.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; } -.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; } -.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; } -.ui-datepicker-rtl .ui-datepicker-group { float:right; } -.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; } -.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; } - -/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */ -.ui-datepicker-cover { - display: none; /*sorry for IE5*/ - display/**/: block; /*sorry for IE5*/ - position: absolute; /*must have*/ - z-index: -1; /*must have*/ - filter: mask(); /*must have*/ - top: -4px; /*must have*/ - left: -4px; /*must have*/ - width: 200px; /*must have*/ - height: 200px; /*must have*/ -} \ No newline at end of file diff --git a/vendor/plugins/unobtrusive_date_picker/MIT-LICENSE b/vendor/plugins/unobtrusive_date_picker/MIT-LICENSE new file mode 100644 index 00000000..e3eeaa04 --- /dev/null +++ b/vendor/plugins/unobtrusive_date_picker/MIT-LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2007 Brian J. Landau, + +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. diff --git a/vendor/plugins/unobtrusive_date_picker/README.rdoc b/vendor/plugins/unobtrusive_date_picker/README.rdoc new file mode 100644 index 00000000..545fd8f1 --- /dev/null +++ b/vendor/plugins/unobtrusive_date_picker/README.rdoc @@ -0,0 +1,165 @@ += Unobtrusive Date-Picker Widget Plugin + +This is a helper for creating a date or date-time picker that uses the +Unobtrusive Date-Picker Widget(sic) +(http://www.frequency-decoder.com/2006/10/02/unobtrusive-date-picker-widgit-update) +to add a clickable calendar image that will bring up a calendar picker if +javascript is available. It replicates as much of the API of the Rails +`date_select`, and `datetime_select` form helpers. + +It also uses the 12 Hour Time plugin +(http://code.google.com/p/rails-twelve-hour-time-plugin/) so that 12 Hour times +can be processed by Active Record. + +You may want to consider compressing the javascript files with Dean Edward's +Packer (http://dean.edwards.name/packer/) or Douglas Crockford's JSMin +(http://www.crockford.com/javascript/jsmin.html) before deploying your +application. + +== Install + + `script/plugin install git://github.com/brianjlandau/unobtrusive_date_picker.git` + +== Usage + +To be able to use the date-picker methods below you need to include the +javascript library file and CSS stylesheet in the of your layout +template. You can do this either by manually including the files via a +`javascript_include_tag` and a `stylesheet_link_tag` (the files are both named +"datepicker"), OR by using the included `unobtrusive_datepicker_includes` helper +method, which will do this for you. + +There are 4 main methods: + - unobtrusive_date_picker + - unobtrusive_datetime_picker + - unobtrusive_date_picker_tags + - unobtrusive_datetime_picker_tags + - unobtrusive_date_text_picker + - unobtrusive_date_text_picker_tag + +Options (* indicates same functionality as is in Rails Date helpers): + - *:order => the order the selects should be positioned in + - *:include_blank => include a blank option at the top of every select + - *:start_year => year that the year select should start on (defaults to 5 + below either the year of the date value or current year) + - *:end_year => year that the year select should end on (defaults to 5 above + either the year of the date value or current year) + - *:minute_step => how many minutes apart each minute option should be + - example: (:minute_step => 5) would result in [0, 15, 30, 45] as options + - *:use_short_month => use short month names (Jan, Feb, etc.) instead of long + names (January) for option text + - *:use_month_numbers => use month numbers instead of names for option text + - *:add_month_numbers => add month numbers to names for option text ("1 - January") + - :highlight_days => which days of the week should be highlighted in the datepicker (by default Saturday and Sunday) + - Excepts either a string of number representing days of the week (0 = Monday, 1 = Tuesday ... 6 = Sunday) + - Or a singular symbol for one day of the week + - Or an array of symbols representing days of the week, i.e. [:Monday, :Sunday] + - :range_low => the low range of acceptable dates (not times) for this input + - managed by the Javascript, thus should be enforced with your own validations + - Excepts: + - One of the following symbols: :today, :tomorrow, :yesterday + - A string representation of a date + - A Date, DateTime, or Time object + - :range_high => the high range of acceptable dates (not times) for this input + - Excepts same options as :range_low; also managed by javascript + - :disable_days => days of the week that may not be selected + - Excepts the same format as :highlight_days + - Also managed by javascript + - :no_transparency => if set to true it disables the fade in/out + visual effect of the datepicker + +The `unobtrusive_date_text_picker` and `unobtrusive_date_text_picker_tag` methods +don't except the ":order", ":include_blank", ":start_year", ":end_year", ":minute_step", ":use_short_month", +":use_month_numbers", and ":add_month_numbers" options. +It does use these options though: + - :format => the format the date should be in + - m-d-y + - d-m-y + - y-m-d + - :divider => the divider used between the dates + - "slash" or "/" + - "dash" or "-" + - "dot" or "." + - "space" or " " + + +==== RJS Method + +There is an additional RJS method to re initialize the Date Pickers when an AJAX +response is supplied to the client: + + - unobtrusive_date_picker_create + - This method can accept the DOM ID of a year select element to turn into + a date picker widget or if none is provided it will create all based on + the appropriate class name. + + +==== Rake task + +There is also a rake task that can be executed by running `rake +datepicker:update` in your Rails apps root directory. This task will update your +datepicker javascripts, stylesheets, and images. This is useful if you are using +an old version of the plugin that had an older version of the Unobtrusive +Date-Picker Widget Javascript library, or in the future when new version are +release and I update the plugin with them. + + + +=== Example: + <% form_for :article, :url => { :action => @form_action, :id => @article } do |f| %> +
    + ... +
    + ... +
    + <% end %> + +=== Produces (Current date when output: 12/6/07): +
    +
    + +
    + +
    +
    + + + +== LICENSE + +See MIT-LICENSE file for copyright and licensing information for this plugin. + +Unobtrusive Date-Picker Widget is provided under the Creative Commons Attribution-ShareAlike 2.5 license (http://creativecommons.org/licenses/by-sa/2.5/) by frequency-decoder.com + diff --git a/vendor/plugins/unobtrusive_date_picker/about.yml b/vendor/plugins/unobtrusive_date_picker/about.yml new file mode 100644 index 00000000..5e0d2d4b --- /dev/null +++ b/vendor/plugins/unobtrusive_date_picker/about.yml @@ -0,0 +1,7 @@ +name: Unobtrusive Date-Picker Widget +author: Brian Landau +version: 2.0 +description: Helper to create a set of Date/Time selects that use the Unobtrusive Date Picker Widget. +url: http://github.com/brianjlandau/unobtrusive_date_picker/ +install: git@github.com:brianjlandau/unobtrusive_date_picker.git +license: MIT diff --git a/vendor/plugins/unobtrusive_date_picker/init.rb b/vendor/plugins/unobtrusive_date_picker/init.rb new file mode 100644 index 00000000..c33c05e4 --- /dev/null +++ b/vendor/plugins/unobtrusive_date_picker/init.rb @@ -0,0 +1,7 @@ +require 'unobtrusive_date_picker' + +# Include all the necessary functions in to the appropriate point in the Rails framework +ActionView::Base.send :include, UnobtrusiveDatePicker::UnobtrusiveDatePickerHelper +ActionView::Helpers::DateHelper.send :include, UnobtrusiveDatePicker::UnobtrusiveDatePickerHelper +ActionView::Base.send :include, UnobtrusiveDatePicker::AssetTagHelper +ActionView::Helpers::AssetTagHelper.send :include, UnobtrusiveDatePicker::AssetTagHelper diff --git a/vendor/plugins/unobtrusive_date_picker/install.rb b/vendor/plugins/unobtrusive_date_picker/install.rb new file mode 100644 index 00000000..a68d7b43 --- /dev/null +++ b/vendor/plugins/unobtrusive_date_picker/install.rb @@ -0,0 +1,14 @@ +require 'fileutils' + +# Install all the needed support files (CSS and JavaScript) + +js_dir = File.dirname(__FILE__) + '/../../../public/javascripts/' +datepicker_js = js_dir + 'datepicker.js' +lang_dir = js_dir + 'lang' +datepicker_css = File.dirname(__FILE__) + '/../../../public/stylesheets/datepicker.css' +images_dir = File.dirname(__FILE__) + '/../../../public/images/datepicker' + +FileUtils.cp File.dirname(__FILE__) + '/public/javascripts/datepicker.js', datepicker_js unless File.exists?(datepicker_js) +FileUtils.cp_r File.dirname(__FILE__) + '/public/javascripts/lang/', lang_dir unless File.exists?(lang_dir) +FileUtils.cp File.dirname(__FILE__) + '/public/stylesheets/datepicker.css', datepicker_css unless File.exists?(datepicker_css) +FileUtils.cp_r File.dirname(__FILE__) + '/public/images/', images_dir unless File.exists?(images_dir) diff --git a/vendor/plugins/unobtrusive_date_picker/lib/unobtrusive_date_picker.rb b/vendor/plugins/unobtrusive_date_picker/lib/unobtrusive_date_picker.rb new file mode 100644 index 00000000..9754c942 --- /dev/null +++ b/vendor/plugins/unobtrusive_date_picker/lib/unobtrusive_date_picker.rb @@ -0,0 +1,405 @@ +module UnobtrusiveDatePicker + + DATEPICKER_DEFAULT_NAME_ID_SUFFIXES = { :year => {:id => '', :name => 'year'}, + :month => {:id => 'mm', :name => 'month'}, + :day => {:id => 'dd', :name => 'day'} } + + DATEPICKER_DAYS_OF_WEEK = { :Monday => '0', + :Tuesday => '1', + :Wednesday => '2', + :Thursday => '3', + :Friday => '4', + :Saturday => '5', + :Sunday => '6'} + + DATEPICKER_DIVIDERS = { 'slash' => '/', + 'dash' => '-', + 'dot' => '.', + 'space' => ' ' } + + RANGE_DATE_FORMAT = '%Y-%m-%d' + + # == Unobtrusive Date-Picker Helper + # + # This Module helps to create date and date-time fields that use the + # Unobtrusive Date-Picker Javascript Widget. + # + # They also use the 12-hour AM/PM time format. + # + module UnobtrusiveDatePickerHelper + + ## + # Creates the date picker with the calendar widget. + # + def unobtrusive_date_picker(object_name, method, options = {}, html_options = {}) + ActionView::Helpers::InstanceTag.new(object_name, method, self, options.delete(:object)).to_datepicker_date_select_tag(options, html_options) + end + + ## + # Creates the date-time picker with the calendar widget, and AM/PM select. + # + def unobtrusive_datetime_picker(object_name, method, options = {}, html_options = {}) + ActionView::Helpers::InstanceTag.new(object_name, method, self, options.delete(:object)).to_datepicker_datetime_select_tag(options, html_options) + end + + ## + # Creates the date picker with the calendar widget. + # + def unobtrusive_date_text_picker(object_name, method, options = {}, html_options = {}) + ActionView::Helpers::InstanceTag.new(object_name, method, self, options.delete(:object)).to_datepicker_text_tag(options, html_options) + end + + def unobtrusive_datetime_picker_tags(datetime = Time.current, options = {}, html_options = {}) + datetime ||= Time.current + DateTimePickerSelector.new(datetime, options.merge(:twelve_hour => true), html_options).select_datetime + end + + def unobtrusive_date_picker_tags(date = Date.current, options = {}, html_options = {}) + date ||= Date.current + DateTimePickerSelector.new(date, options, html_options).select_date + end + + ## + # Creates the text field based date picker with the calendar widget without a model object. + # + def unobtrusive_date_text_picker_tag(name, date = Date.current, options = {}, html_options = {}) + date ||= Date.current + options = merge_defaults_for_text_picker(options) + DateTimePickerSelector.new(date, options, html_options).text_date_picker(name) + end + + private + def merge_defaults_for_text_picker(options) + defaults = {:format => 'm-d-y', :divider => 'slash'} + options = defaults.merge(options) + end + + end + + module AssetTagHelper + ## + # This will add the necessary and -<% end %> +<%= javascript_include_tag 'notices' %> diff --git a/public/javascripts/notices.js b/public/javascripts/notices.js index 36e9497a..faa6b223 100644 --- a/public/javascripts/notices.js +++ b/public/javascripts/notices.js @@ -1,18 +1,17 @@ jQuery(document).ready(function(){ - $("#department_wide_locations").click(function(){ - var check_status = $(this).attr('checked'); + var check_status = $(this).attr('checked'); $("ul#notice_ul :checkbox").each(function(){ $(this).attr('checked', check_status); }); }); - $("div#loc_groups :checkbox").click(function(){ + $(".loc_group_checkboxes :checkbox").click(function(){ var locgroup_status = $(this).attr('checked'); $(this).siblings('input[type=checkbox]').attr('checked', locgroup_status); }); - $("#type_is_sticky").click(function(){ + $("#type_sticky").click(function(){ $("#start_time_choice_date").attr('checked', false); $("#start_time_choice_now, #end_time_choice_indefinite").attr('checked', true); $("#start_time_choice_date, #notice_start_time_1i, #notice_start_time_2i, #notice_start_time_3i, #notice_start_time_4i, #notice_start_time_5i, #notice_start_time_7i, #notice_end_time_1i, #end_time_choice_date, #notice_end_time_2i, #notice_end_time_3i, #notice_end_time_4i, #notice_end_time_5i, #notice_end_time_7i").attr("disabled", "disabled"); @@ -21,16 +20,5 @@ jQuery(document).ready(function(){ $("#type_announcement").click(function(){ $("#start_time_choice_date, #notice_start_time_1i, #notice_start_time_2i, #notice_start_time_3i, #notice_start_time_4i, #notice_start_time_5i, #notice_start_time_7i, #notice_end_time_1i, #end_time_choice_date, #notice_end_time_2i, #notice_end_time_3i, #notice_end_time_4i, #notice_end_time_5i, #notice_end_time_7i").removeAttr("disabled"); }); -/* - $(".group input[type='checkbox']").each(function(){ - - alert("hi?"); - /*$(this).click(function(){ - var check_status = $(this).attr('checked'); - alert(check_status); - $(this).siblings().attr('checked', check_status); - }); - });*/ - }); diff --git a/public/stylesheets/notice.css b/public/stylesheets/notice.css index d9b2ecc6..cb0d8790 100644 --- a/public/stylesheets/notice.css +++ b/public/stylesheets/notice.css @@ -1,6 +1,3 @@ -p { - margin: 0; -} ul#notice_ul { list-style-type: none; } From 8518a19e707a5687e093a65be13c1ae5a0b2841f Mon Sep 17 00:00:00 2001 From: somanyrobots Date: Wed, 22 Jul 2009 20:17:38 -0400 Subject: [PATCH 09/59] data pbjects index page woot --- app/controllers/data_objects_controller.rb | 42 ++++++--------- .../data_objects/_data_objects_table.html.erb | 4 +- app/views/data_objects/index.html.erb | 54 +++++++++++++++---- 3 files changed, 62 insertions(+), 38 deletions(-) diff --git a/app/controllers/data_objects_controller.rb b/app/controllers/data_objects_controller.rb index ad495557..d0ba36fe 100644 --- a/app/controllers/data_objects_controller.rb +++ b/app/controllers/data_objects_controller.rb @@ -1,35 +1,26 @@ class DataObjectsController < ApplicationController - #User admin methods will need to be rewritten in move to other codebase - #Not yet permission-locked!!! - - # not at all sure what's going on here anymore, will ask ryan about it -ben + #Not yet secured! + def index @data_objects = get_allowed_data_objects @group_type_options = options_for_group_type @group_by_options = [] - # if params[:view_options] - # @selected_type = params[:view_options][:group_type] - # if params[:view_options][:group_by] - # unless (@selected_by = params[:view_options][:group_by]).blank? - # @data_objects = @selected_type.classify.constantize.find(@selected_by).data_objects - # end - # end - # @group_by_options = options_for_group_by(@selected_type) - # end - if params[:group_by] - @selected_type = params[:group_by] - if params[:group_by] == "data_types" - @types_objects_hash = @data_objects.group_by(&:data_type) - elsif params[:group_by] == "locations" - @types_objects_hash = @data_objects.group_by{|object| object.locations[0]} - elsif params[:group_by] == "loc_groups" - @types_objects_hash = @data_objects.group_by(&:data_type) + @selected_type = "departments" + if params[:group_type] + @selected_type = params[:group_type] + if params[:group_by] && !params[:group_by].blank? + @selected_by = params[:group_by] + @data_objects &= @selected_type.classify.constantize.find(@selected_by).data_objects end - else #default - @types_objects_hash = @data_objects.group_by &:data_type + @group_by_options = options_for_group_by(@selected_type) + end + @types_objects_hash = @data_objects.group_by &:data_type + respond_to do |format| + format.html + format.js end end - + # This needs its views rewritten to enable viewing a subset of all entries -ben def show @data_object = DataObject.find(params[:id]) @@ -80,7 +71,8 @@ def destroy private -# Returns all the data objects that the user is permitted to administer +# Returns all the data objects that the user is permitted to administer +# other methods should grab these objects, and narrow them down def get_allowed_data_objects return @department.data_objects if current_user.is_admin_of?(@department) unless (@loc_groups = current_user.loc_groups_to_admin(@department)).empty? diff --git a/app/views/data_objects/_data_objects_table.html.erb b/app/views/data_objects/_data_objects_table.html.erb index a05232ad..7a42bb75 100644 --- a/app/views/data_objects/_data_objects_table.html.erb +++ b/app/views/data_objects/_data_objects_table.html.erb @@ -1,4 +1,4 @@ -
    +
    >

    <%= link_to data_objects_table.first.name.pluralize, data_objects_table.first %>

    @@ -25,4 +25,4 @@ <% end %>
    -
    \ No newline at end of file +
    diff --git a/app/views/data_objects/index.html.erb b/app/views/data_objects/index.html.erb index 0af7a300..4d697a3b 100644 --- a/app/views/data_objects/index.html.erb +++ b/app/views/data_objects/index.html.erb @@ -1,24 +1,56 @@ <% javascript 'sorttable' %> <% title "Data Objects" %> -<% form_tag '/data_objects/index' do %> - - Group by +<% form_tag '/data_objects/index', :id => "view_options" do %> +
    + Group by + +
    + <%= select_tag "view_options[group_type]", options_for_select(@group_type_options, @group_type_options.select{|a|a.include?@selected_type}) %> +      + + <%= observe_field('view_options_group_type', + :url => { :controller => :data_objects, + :action => :index, + :layout => false}, + :method => :get, + :with => "'group_type=' + escape(value)", + :on => "change") %> +
    + + + + <%# @selected_type = "wibble" %> + <%#= observe_field('view_options_group_by', + :url => { :controller => :data_objects, + :action => :index, + :layout => false}, + :method => :get, + :with => "'group_by='+escape(value) + '&group_type=' + escape(#{@selected_type})", + :on => "change") %> + + <%= submit_tag "Update" %> +
    + + + +<%#= render :partial => "data_objects_form_observer" %> + + + + <% end -%>
    <% if DataType.first %> - <%= render(:partial => "data_objects_table" , :collection => @types_objects_hash) %> + <%= render :partial => "data_objects" %>
    <%= link_to "New Data Object", new_data_object_path %> <% else %> You must set up a <%= link_to "data type", new_data_type_path %> before you can create any data objects. -<% end %> \ No newline at end of file +<% end %> From c70de076e5a31da7322f416506004cc1577a4108 Mon Sep 17 00:00:00 2001 From: Derek Zhao Date: Thu, 23 Jul 2009 02:23:57 -0400 Subject: [PATCH 10/59] more notice bug fixes, added upcoming notices --- app/models/notice.rb | 5 ++++- app/views/notices/_all_notices.html.erb | 9 +++++++++ app/views/notices/_announcement.html.erb | 2 +- app/views/notices/_sticky.html.erb | 2 +- public/javascripts/notices.js | 4 ++-- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/models/notice.rb b/app/models/notice.rb index 430d2564..e33eb6b8 100644 --- a/app/models/notice.rb +++ b/app/models/notice.rb @@ -13,9 +13,12 @@ class Notice < ActiveRecord::Base named_scope :active_with_end, lambda {{ :conditions => ["start_time < ? and end_time > ?", Time.now.utc, Time.now.utc]}} named_scope :active_without_end, lambda {{ :conditions => ["start_time < ?", Time.now.utc]}} named_scope :upcoming, lambda {{ :conditions => ["start_time > ?", Time.now.utc]}} + named_scope :stickies, lambda {{ :conditions => ["is_sticky = ?", true]}} + named_scope :announcements, lambda {{ :conditions => ["is_sticky = ?", false]}} def self.active - (self.active_with_end + self.active_without_end).uniq.sort_by{|n| n.start_time}.reverse + (self.announcements.active_with_end + self.announcements.active_without_end).uniq.sort_by{|n| n.start_time}.reverse + + (self.stickies.active_with_end + self.stickies.active_without_end).uniq.sort_by{|n| n.start_time}.reverse end def display_for diff --git a/app/views/notices/_all_notices.html.erb b/app/views/notices/_all_notices.html.erb index 85b86e07..bfafa5fe 100644 --- a/app/views/notices/_all_notices.html.erb +++ b/app/views/notices/_all_notices.html.erb @@ -1,3 +1,12 @@ +<% if current_user.is_admin_of?(current_department) %> +
    +
    + Upcoming + <%= render :partial => 'notice', :collection => Notice.upcoming %> +
    +
    +<% end %> +
    <%= render :partial => 'for_you' %>
    diff --git a/app/views/notices/_announcement.html.erb b/app/views/notices/_announcement.html.erb index 633f0411..a944be1b 100644 --- a/app/views/notices/_announcement.html.erb +++ b/app/views/notices/_announcement.html.erb @@ -9,7 +9,7 @@ <% end %> <%= announcement.content %>
    - + <%= " TESTING PURPOSES: notice id: #{announcement.id}, is_current?: #{announcement.is_current?} Start time: #{announcement.start_time}"%>
    <%= "by #{(announcement.author.name )}" -%>
    diff --git a/app/views/notices/_sticky.html.erb b/app/views/notices/_sticky.html.erb index 2563b688..5856bc5f 100644 --- a/app/views/notices/_sticky.html.erb +++ b/app/views/notices/_sticky.html.erb @@ -6,7 +6,7 @@ <%= sticky.content %>
    - <%= " TESTING PURPOSES: notice id: #{sticky.id}, is_current?: #{sticky.is_current?}"%> + <%= " TESTING PURPOSES: notice id: #{sticky.id}, is_current?: #{sticky.is_current?} Start time: #{sticky.start_time}"%>
    <%= "by #{sticky.author.name} #{distance_of_time_in_words(sticky.start_time, Time.now, true)} ago" %>
    diff --git a/public/javascripts/notices.js b/public/javascripts/notices.js index faa6b223..18b5d2da 100644 --- a/public/javascripts/notices.js +++ b/public/javascripts/notices.js @@ -14,11 +14,11 @@ jQuery(document).ready(function(){ $("#type_sticky").click(function(){ $("#start_time_choice_date").attr('checked', false); $("#start_time_choice_now, #end_time_choice_indefinite").attr('checked', true); - $("#start_time_choice_date, #notice_start_time_1i, #notice_start_time_2i, #notice_start_time_3i, #notice_start_time_4i, #notice_start_time_5i, #notice_start_time_7i, #notice_end_time_1i, #end_time_choice_date, #notice_end_time_2i, #notice_end_time_3i, #notice_end_time_4i, #notice_end_time_5i, #notice_end_time_7i").attr("disabled", "disabled"); + $("#start_time_choice_date, #notice_start_time, #notice_start_time-mm, #notice_start_time-dd, #notice_start_time_4i, #notice_start_time_5i, #notice_start_time_7i, #notice_end_time, #end_time_choice_date, #notice_end_time-mm, #notice_end_time-dd, #notice_end_time_4i, #notice_end_time_5i, #notice_end_time_7i").attr("disabled", "disabled"); }); $("#type_announcement").click(function(){ - $("#start_time_choice_date, #notice_start_time_1i, #notice_start_time_2i, #notice_start_time_3i, #notice_start_time_4i, #notice_start_time_5i, #notice_start_time_7i, #notice_end_time_1i, #end_time_choice_date, #notice_end_time_2i, #notice_end_time_3i, #notice_end_time_4i, #notice_end_time_5i, #notice_end_time_7i").removeAttr("disabled"); + $("#start_time_choice_date, #notice_start_time, #notice_start_time-mm, #notice_start_time-dd, #notice_start_time_4i, #notice_start_time_5i, #notice_start_time_7i, #notice_end_time, #end_time_choice_date, #notice_end_time-mm, #notice_end_time-dd, #notice_end_time_4i, #notice_end_time_5i, #notice_end_time_7i").removeAttr("disabled"); }); }); From 956746eae9373bd7925b9410269a0ec17e386d7f Mon Sep 17 00:00:00 2001 From: Derek Zhao Date: Thu, 23 Jul 2009 12:23:28 -0400 Subject: [PATCH 11/59] fixed several bugs in notices, linked notice index view to userconfig settings --- app/controllers/notices_controller.rb | 14 ++++++++++++++ app/helpers/application_helper.rb | 4 ++-- app/views/notices/_all_notices.html.erb | 24 +++++++++++++++--------- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/app/controllers/notices_controller.rb b/app/controllers/notices_controller.rb index ea02e208..38609035 100644 --- a/app/controllers/notices_controller.rb +++ b/app/controllers/notices_controller.rb @@ -37,6 +37,19 @@ def create @notice.end_time = nil if params[:end_time_choice] == "indefinite" || @notice.is_sticky @notice.save(false) set_sources + if params[:for_users] + params[:for_users].split(",").each do |l| + if l == l.split("||").first #This is for if javascript is disabled + l = l.strip + @notice.user_sources << Department.find_by_name(l) + @notice.user_sources << User.find_by_names(l).first + @notice.user_sources << User.find_by_login(l) + else + l = l.split("||") + @notice.user_sources << l[0].constantize.find(l[1]) if l.length == 2 + end + end + end respond_to do |format| if @notice.save format.html { @@ -90,6 +103,7 @@ def set_sources params[:for_users].split(",").each do |l| if l == l.split("||").first #This is for if javascript is disabled l = l.strip + @notice.save(false) @notice.user_sources << Department.find_by_name(l) @notice.user_sources << User.find_by_names(l).first @notice.user_sources << User.find_by_login(l) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ff9f2db2..e7f97378 100755 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -62,12 +62,12 @@ def select_integer (object, column, start, stop, default = nil) end output + "" end - + def unobtrusive_datepicker_includes javascript 'datepicker' stylesheet 'datepicker' end - + def unobtrusive_datepicker_include_tags (javascript_include_tag 'datepicker') + (stylesheet_link_tag 'datepicker') end diff --git a/app/views/notices/_all_notices.html.erb b/app/views/notices/_all_notices.html.erb index bfafa5fe..24353f69 100644 --- a/app/views/notices/_all_notices.html.erb +++ b/app/views/notices/_all_notices.html.erb @@ -10,16 +10,22 @@
    <%= render :partial => 'for_you' %>
    +<% if current_user.user_config.view_loc_groups.blank? %> +

    You have not selected any location groups to view! Fix that in your + <%= link_to "User settings", edit_user_config_path(current_user.user_config) %>.

    +<% end %>
    -<% current_department.locations.each do |loc| %> - <% @loc_current_notices = loc.current_notices %> - <% unless @loc_current_notices.empty? %> -
    - <%= loc.name %> - <%= render :partial => 'notice', :collection => @loc_current_notices%> -
    -
    + <% current_user.user_config.view_loc_groups.split(",").map{|lg| LocGroup.find(lg)}.each do |loc_group| %> + <% loc_group.locations.each do |loc| %> + <% @loc_current_notices = loc.current_notices %> + <% unless @loc_current_notices.empty? || current_user.user_config.view_loc_groups.include?(loc.id) %> +
    + <%= loc.name %> + <%= render :partial => 'notice', :collection => @loc_current_notices%> +
    +
    + <% end %> + <% end %> <% end %> -<% end %>
    From e191311b024798b27fdc051f98a1d1a0838f7236 Mon Sep 17 00:00:00 2001 From: Michael Libertin Date: Thu, 23 Jul 2009 12:40:02 -0400 Subject: [PATCH 12/59] Made the whole LDAP bit optional --- app/controllers/app_configs_controller.rb | 3 ++- app/controllers/first_run_controller.rb | 1 + app/views/app_configs/_form.html.erb | 4 ++++ app/views/first_run/_form.html.erb | 2 ++ app/views/first_run/new_app_config.html.erb | 4 ++++ app/views/first_run/new_user.html.erb | 2 ++ app/views/users/_new_form.html.erb | 2 ++ app/views/users/new.html.erb | 2 ++ db/migrate/20090701211925_create_app_configs.rb | 1 + preload_data/app_configs.yml | 1 + 10 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/controllers/app_configs_controller.rb b/app/controllers/app_configs_controller.rb index 2fba85b1..1e3701aa 100644 --- a/app/controllers/app_configs_controller.rb +++ b/app/controllers/app_configs_controller.rb @@ -7,7 +7,8 @@ def edit def update @app_config = AppConfig.first - if @app_config.update_attributes(params[:app_config]) + use_ldap = params[:use_ldap] ? true : false + if @app_config.update_attributes(params[:app_config].merge({:use_ldap=>use_ldap})) flash[:notice] = "Successfully updated appconfig." end render :action => 'edit' diff --git a/app/controllers/first_run_controller.rb b/app/controllers/first_run_controller.rb index a3fc8ca6..0ec88f64 100644 --- a/app/controllers/first_run_controller.rb +++ b/app/controllers/first_run_controller.rb @@ -9,6 +9,7 @@ def new_app_config def create_app_config AppConfig.first.destroy if AppConfig.first @app_config=AppConfig.new(params[:app_config]) + @appconfig.use_ldap = params[:use_ldap] ? true : false if @app_config.save flash[:notice] = "App Settings have been configured." redirect_to first_department_path diff --git a/app/views/app_configs/_form.html.erb b/app/views/app_configs/_form.html.erb index 77033db2..1b6a6ad6 100644 --- a/app/views/app_configs/_form.html.erb +++ b/app/views/app_configs/_form.html.erb @@ -6,6 +6,10 @@ or you may produce broken pages.
    <%= f.text_area :footer, {:class => "settings", :size => "80x10"} %>

    +

    + <%= f.label "Use LDAP?" %>
    + <%= f.check_box :use_ldap %> +

    <%= f.label :ldap_host_address %>
    diff --git a/app/views/first_run/_form.html.erb b/app/views/first_run/_form.html.erb index 37e42dba..8426aecc 100644 --- a/app/views/first_run/_form.html.erb +++ b/app/views/first_run/_form.html.erb @@ -45,5 +45,7 @@

    After clicking "Submit", you be redirected to a login page, after which you may use the app normally.

    <%= f.submit "Submit" %>

    <% end %> +<% if $appconfig.use_ldap %> <%= observe_form :first_user_form, :url => { :action => 'ldap_search' }, :frequency => 0.25, :loading=> "$('#loading_icon').css({'display' : 'inline'})"%> +<% end %> diff --git a/app/views/first_run/new_app_config.html.erb b/app/views/first_run/new_app_config.html.erb index 71d42c7b..df9a772c 100644 --- a/app/views/first_run/new_app_config.html.erb +++ b/app/views/first_run/new_app_config.html.erb @@ -6,6 +6,10 @@ <%= f.label :auth_types, text = "Login Options" %> <%= multiple_select :app_config, :auth_types, AppConfig::LOGIN_OPTIONS %>

    +

    + <%= f.label "Use LDAP?" %>
    + <%= f.check_box :use_ldap %> +

    <%= f.label :ldap_host_address %>
    <%= f.text_field :ldap_host_address %> diff --git a/app/views/first_run/new_user.html.erb b/app/views/first_run/new_user.html.erb index 4fdf16f2..8e9970bb 100644 --- a/app/views/first_run/new_user.html.erb +++ b/app/views/first_run/new_user.html.erb @@ -3,9 +3,11 @@

    <%= render :partial => 'form'%>
    +<% if $appconfig.use_ldap %>
    <%= render :partial => 'users/result_list' %>
    +<% end %> - -
    -

    +

    +

    <%= f.label :values %>
    - <%= f.select :values, options=(DataField::DISPLAY_TYPE_OPTIONS) %> - For text field display types, values - should be either "integer", "decimal", or "text"
    - For a list of options, entries should be comma-separated
    -

    -
    - + <%= f.text_field :values %>
    + Value should be either 'integer', 'decimal', or 'text' +
    +

    <%= f.submit "Save and add another field", :name => "add_another" %> <%= f.submit "Save and finish", :name => "submit" %> diff --git a/app/views/data_types/_data_field.html.erb b/app/views/data_types/_data_field.html.erb index f6a1471f..d1df10ce 100644 --- a/app/views/data_types/_data_field.html.erb +++ b/app/views/data_types/_data_field.html.erb @@ -2,32 +2,7 @@

    <% fields_for_data_field(data_field) do |df_form| %> - + <%= javascript_include_tag 'data_field_input'%>
    - -
    +
    +
    Data Objects <%= render :partial => 'data_objects/report_form', :collection => @report.get_data_objects %>
    diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 37a5689c..96c83d93 100755 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -485,6 +485,7 @@ fieldset#warning { fieldset.index { width: 90%; padding: 5px; + border: 1px solid gray; background-color:#DDDDFF } diff --git a/public/stylesheets/notice.css b/public/stylesheets/notice.css index 7e3eefcd..88e0755a 100644 --- a/public/stylesheets/notice.css +++ b/public/stylesheets/notice.css @@ -8,16 +8,16 @@ li#notice_li { fieldset.sticky { padding: 5px; - margin: 0 0 0 0; + margin: 0 0 0 0; + border:1px solid gray; background-color:#FFFF99; - } fieldset.announcement { padding: 5px; - margin:0 0 0 0; + margin:0 0 0 0; + border:1px solid gray; background-color:#ADD8E6; - } fieldset.sticky .grayleft, fieldset.announcement .grayleft{ @@ -38,4 +38,5 @@ fieldset.sticky .grayleft, fieldset.sticky .grayright { fieldset.announcement .grayleft, fieldset.announcement .grayright { color:DarkRed; font-size: 90%; -} \ No newline at end of file +} + From a8b0c5177e5fd17ca2ca041f7f334627a0ca627e Mon Sep 17 00:00:00 2001 From: rofreg Date: Fri, 24 Jul 2009 17:54:44 -0400 Subject: [PATCH 56/59] valign hack --- app/views/time_slots/_location.html.erb | 6 ++---- app/views/time_slots/_time_slot.html.erb | 8 ++++++-- app/views/time_slots/_time_slot_day.html.erb | 2 +- public/stylesheets/timeline.css | 11 +++++++++++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/views/time_slots/_location.html.erb b/app/views/time_slots/_location.html.erb index c73b90a1..458b9419 100644 --- a/app/views/time_slots/_location.html.erb +++ b/app/views/time_slots/_location.html.erb @@ -1,8 +1,6 @@ -<% height = 300 %> -

    <%= link_toggle location.short_name, location.name %>

    -
    +
    <%= render :partial => "left_day", :collection => (@period_start.beginning_of_week-1.day)...@period_start.end_of_week %> @@ -11,6 +9,6 @@
      <%= render :partial => "hour", :collection => @dept_start_hour.to_i...@dept_end_hour.to_i %>
    - <%= render :partial => "time_slot_day", :collection => (@period_start.beginning_of_week-1.day)...@period_start.end_of_week, :locals => {:location => location, :height => height} %> + <%= render :partial => "time_slot_day", :collection => (@period_start.beginning_of_week-1.day)...@period_start.end_of_week, :locals => {:location => location} %>
    diff --git a/app/views/time_slots/_time_slot.html.erb b/app/views/time_slots/_time_slot.html.erb index 31294872..9722b82c 100644 --- a/app/views/time_slots/_time_slot.html.erb +++ b/app/views/time_slots/_time_slot.html.erb @@ -1,6 +1,10 @@
  • - <%= link_to "x", time_slot, :confirm => 'Are you sure?', :method => :delete, :style => "float:right;margin-right:3px" %> - <%= link_to "#{time_slot.start.strftime("%l:%M%p")} - #{time_slot.end.strftime("%l:%M%p")}", edit_time_slot_path(time_slot) %> +
    +
    + <%= link_to "x", time_slot, :confirm => 'Are you sure?', :method => :delete, :style => "float:right;margin-right:3px" %> + <%= link_to "#{time_slot.start.strftime("%l:%M%p")} - #{time_slot.end.strftime("%l:%M%p")}", edit_time_slot_path(time_slot) %> +
    +
  • diff --git a/app/views/time_slots/_time_slot_day.html.erb b/app/views/time_slots/_time_slot_day.html.erb index 347fabd4..89e198b9 100644 --- a/app/views/time_slots/_time_slot_day.html.erb +++ b/app/views/time_slots/_time_slot_day.html.erb @@ -1,5 +1,5 @@ <%# we can vertically center text by changing the line-height %> -
      +
        <% timeslots = TimeSlot.all(:conditions => ['start > ? and start < ? and location_id = ?',time_slot_day.beginning_of_day,time_slot_day.end_of_day,location.id]) -%> <%= render :partial => "time_slot", :collection => timeslots -%>
      diff --git a/public/stylesheets/timeline.css b/public/stylesheets/timeline.css index e72ab2a1..9c36e856 100644 --- a/public/stylesheets/timeline.css +++ b/public/stylesheets/timeline.css @@ -104,6 +104,17 @@ ul.events li div.time-slot { height: 100%; border-right: 1px solid #ccc; } +/* hack for vertical centering*/ +div.center_container { + display: table; + width: 100%; + height: 100%; +} +div.center_content { + display: table-cell; + vertical-align: middle; + width: 100%; +} ul.events li a { color: #999; } From 99dcda8f897b3ccb4ba4c907db86d802b3551a08 Mon Sep 17 00:00:00 2001 From: Smudge Date: Fri, 24 Jul 2009 18:18:53 -0400 Subject: [PATCH 57/59] more centering --- app/views/time_slots/_hour.html.erb | 8 +++++++- app/views/time_slots/_left_day.html.erb | 8 +++++++- app/views/time_slots/_location.html.erb | 2 +- public/stylesheets/timeline.css | 23 ++++++++++++----------- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/app/views/time_slots/_hour.html.erb b/app/views/time_slots/_hour.html.erb index d7039828..e5dc42c4 100644 --- a/app/views/time_slots/_hour.html.erb +++ b/app/views/time_slots/_hour.html.erb @@ -1,4 +1,10 @@
    • -
      <%=(Time.now.beginning_of_day + hour.hours).strftime("%l:%M%p")%>
      +
      +
      +
      + <%=(Time.now.beginning_of_day + hour.hours).strftime("%l:%M%p")%> +
      +
      +
      <%= render :partial => "minutes", :collection => 0...(@blocks_per_hour-1) %>
    • diff --git a/app/views/time_slots/_left_day.html.erb b/app/views/time_slots/_left_day.html.erb index 202b2d93..d16ede0e 100644 --- a/app/views/time_slots/_left_day.html.erb +++ b/app/views/time_slots/_left_day.html.erb @@ -1 +1,7 @@ -
      <%= left_day.strftime("%a:") %>
      +
      +
      +
      + <%= left_day.strftime("%a:") %> +
      +
      +
      diff --git a/app/views/time_slots/_location.html.erb b/app/views/time_slots/_location.html.erb index 458b9419..cc68a799 100644 --- a/app/views/time_slots/_location.html.erb +++ b/app/views/time_slots/_location.html.erb @@ -1,6 +1,6 @@

      <%= link_toggle location.short_name, location.name %>

      -
      +
      <%= render :partial => "left_day", :collection => (@period_start.beginning_of_week-1.day)...@period_start.end_of_week %> diff --git a/public/stylesheets/timeline.css b/public/stylesheets/timeline.css index 9c36e856..f0d00b17 100644 --- a/public/stylesheets/timeline.css +++ b/public/stylesheets/timeline.css @@ -104,17 +104,6 @@ ul.events li div.time-slot { height: 100%; border-right: 1px solid #ccc; } -/* hack for vertical centering*/ -div.center_container { - display: table; - width: 100%; - height: 100%; -} -div.center_content { - display: table-cell; - vertical-align: middle; - width: 100%; -} ul.events li a { color: #999; } @@ -127,3 +116,15 @@ ul.events li:hover { ul.events li:hover a { color: #707070; } + +/* hack for vertical centering*/ +div.center_container { + display: table; + width: 100%; + height: 100%; +} +div.center_content { + display: table-cell; + vertical-align: middle; + width: 100%; +} From 7a65ba1394d0ec6635957d1bc8631538a7ef7a64 Mon Sep 17 00:00:00 2001 From: rofreg Date: Fri, 24 Jul 2009 18:20:22 -0400 Subject: [PATCH 58/59] started working on time_slot view ajax --- app/views/time_slots/_time_slot.html.erb | 2 +- app/views/time_slots/tooltips/show.html.erb | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 app/views/time_slots/tooltips/show.html.erb diff --git a/app/views/time_slots/_time_slot.html.erb b/app/views/time_slots/_time_slot.html.erb index 9722b82c..9579b453 100644 --- a/app/views/time_slots/_time_slot.html.erb +++ b/app/views/time_slots/_time_slot.html.erb @@ -1,4 +1,4 @@ -
    • +
    • diff --git a/app/views/time_slots/tooltips/show.html.erb b/app/views/time_slots/tooltips/show.html.erb new file mode 100644 index 00000000..d01403c8 --- /dev/null +++ b/app/views/time_slots/tooltips/show.html.erb @@ -0,0 +1,20 @@ +

      + Location: + <%=h @time_slot.location.name %> +

      +

      + Start: + <%=h @time_slot.start.to_s(:short_name) %> +

      +

      + End: + <%=h @time_slot.end.to_s(:short_name) %> +

      + +

      + <%= link_to "Edit", edit_time_slot_path(@time_slot) %> | + <%= link_to "Destroy", @time_slot, :confirm => 'Are you sure?', :method => :delete %> +

      + + +<%# TODO: jEditable? %> \ No newline at end of file From 5ea97190f80350f299e41719370c2b4114a79a49 Mon Sep 17 00:00:00 2001 From: ckildow Date: Fri, 24 Jul 2009 21:08:29 -0400 Subject: [PATCH 59/59] added pdf-inspector to git thingy --- vendor/plugins/pdf-inspector | 1 - .../pdf-inspector/lib/pdf/inspector.rb | 25 ++++++ .../lib/pdf/inspector/graphics.rb | 80 +++++++++++++++++++ .../pdf-inspector/lib/pdf/inspector/page.rb | 16 ++++ .../pdf-inspector/lib/pdf/inspector/text.rb | 31 +++++++ .../lib/pdf/inspector/xobject.rb | 19 +++++ 6 files changed, 171 insertions(+), 1 deletion(-) delete mode 160000 vendor/plugins/pdf-inspector create mode 100644 vendor/plugins/pdf-inspector/lib/pdf/inspector.rb create mode 100644 vendor/plugins/pdf-inspector/lib/pdf/inspector/graphics.rb create mode 100644 vendor/plugins/pdf-inspector/lib/pdf/inspector/page.rb create mode 100644 vendor/plugins/pdf-inspector/lib/pdf/inspector/text.rb create mode 100644 vendor/plugins/pdf-inspector/lib/pdf/inspector/xobject.rb diff --git a/vendor/plugins/pdf-inspector b/vendor/plugins/pdf-inspector deleted file mode 160000 index 021fbbf4..00000000 --- a/vendor/plugins/pdf-inspector +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 021fbbf4cd121673bdf5310834eac038cc6aa080 diff --git a/vendor/plugins/pdf-inspector/lib/pdf/inspector.rb b/vendor/plugins/pdf-inspector/lib/pdf/inspector.rb new file mode 100644 index 00000000..d2e18bce --- /dev/null +++ b/vendor/plugins/pdf-inspector/lib/pdf/inspector.rb @@ -0,0 +1,25 @@ +require "rubygems" +require "pdf/reader" +require "pdf/inspector/text" +require "pdf/inspector/xobject" +require "pdf/inspector/graphics" +require "pdf/inspector/page" + +module PDF + class Inspector + def self.analyze(output,*args,&block) + obs = self.new(*args, &block) + PDF::Reader.string(output,obs) + obs + end + + def self.analyze_file(filename,*args,&block) + analyze(File.open(filename, "rb") { |f| f.read },*args,&block) + end + + def self.parse(obj) + PDF::Reader::Parser.new( + PDF::Reader::Buffer.new(StringIO.new(obj)), nil).parse_token + end + end +end \ No newline at end of file diff --git a/vendor/plugins/pdf-inspector/lib/pdf/inspector/graphics.rb b/vendor/plugins/pdf-inspector/lib/pdf/inspector/graphics.rb new file mode 100644 index 00000000..d2d51398 --- /dev/null +++ b/vendor/plugins/pdf-inspector/lib/pdf/inspector/graphics.rb @@ -0,0 +1,80 @@ +module PDF + class Inspector + module Graphics + class Line < Inspector + attr_accessor :points, :widths + + def initialize + @points = [] + @widths = [] + end + + def append_line(*params) + @points << params + end + + def begin_new_subpath(*params) + @points << params + end + + def set_line_width(params) + @widths << params + end + + end + + class Rectangle < Inspector + attr_reader :rectangles + + def initialize + @rectangles = [] + end + + def append_rectangle(*params) + @rectangles << { :point => params[0..1], + :width => params[2], + :height => params[3] } + end + end + + class Curve < Inspector + + attr_reader :coords + + def initialize + @coords = [] + end + + def begin_new_subpath(*params) + @coords += params + end + + def append_curved_segment(*params) + @coords += params + end + + end + + class Color < Inspector + attr_reader :stroke_color, :fill_color, :stroke_color_count, + :fill_color_count + + def initialize + @stroke_color_count = 0 + @fill_color_count = 0 + end + + def set_rgb_color_for_stroking(*params) + @stroke_color_count += 1 + @stroke_color = params + end + + def set_rgb_color_for_nonstroking(*params) + @fill_color_count += 1 + @fill_color = params + end + end + + end + end +end \ No newline at end of file diff --git a/vendor/plugins/pdf-inspector/lib/pdf/inspector/page.rb b/vendor/plugins/pdf-inspector/lib/pdf/inspector/page.rb new file mode 100644 index 00000000..b7f4c800 --- /dev/null +++ b/vendor/plugins/pdf-inspector/lib/pdf/inspector/page.rb @@ -0,0 +1,16 @@ +module PDF + class Inspector + class Page < Inspector + attr_reader :pages + + def initialize + @pages = [] + end + + def begin_page(params) + @pages << {:size => params[:MediaBox][-2..-1]} + end + + end + end +end \ No newline at end of file diff --git a/vendor/plugins/pdf-inspector/lib/pdf/inspector/text.rb b/vendor/plugins/pdf-inspector/lib/pdf/inspector/text.rb new file mode 100644 index 00000000..e7897fe1 --- /dev/null +++ b/vendor/plugins/pdf-inspector/lib/pdf/inspector/text.rb @@ -0,0 +1,31 @@ +module PDF + class Inspector + class Text < Inspector + attr_accessor :font_settings, :size, :strings + + def initialize + @font_settings = [] + @fonts = {} + @strings = [] + end + + def resource_font(*params) + @fonts[params[0]] = params[1].basefont + end + + def set_text_font_and_size(*params) + @font_settings << { :name => @fonts[params[0]], :size => params[1] } + end + + def show_text(*params) + @strings << params[0] + end + + def show_text_with_positioning(*params) + # ignore kerning information + @strings << params[0].reject { |e| Numeric === e }.join + end + + end + end +end \ No newline at end of file diff --git a/vendor/plugins/pdf-inspector/lib/pdf/inspector/xobject.rb b/vendor/plugins/pdf-inspector/lib/pdf/inspector/xobject.rb new file mode 100644 index 00000000..f7b0ca1c --- /dev/null +++ b/vendor/plugins/pdf-inspector/lib/pdf/inspector/xobject.rb @@ -0,0 +1,19 @@ +module PDF + class Inspector + class XObject < Inspector + attr_accessor :page_xobjects + + def initialize + @page_xobjects = [] + end + + def resource_xobject(*params) + @page_xobjects.last << params.first + end + + def begin_page(*params) + @page_xobjects << [] + end + end + end +end \ No newline at end of file