Permalink
Browse files

Replace the JS calendar with a jQueryUI version.

  • Loading branch information...
1 parent cb9ac28 commit ff9471679199ff173169dee265a4d29b06aa2a10 @EspadaV8 EspadaV8 committed with thegcat Mar 25, 2012
Showing with 1,673 additions and 7,525 deletions.
  1. +19 −26 app/helpers/application_helper.rb
  2. +10 −0 app/views/queries/_filters.rhtml
  3. +2 −0 config/locales/sr-YU.yml
  4. +3 −0 config/locales/zh-TW.yml
  5. +2 −0 config/locales/zh.yml
  6. +5 −0 public/javascripts/application.js
  7. +0 −200 public/javascripts/calendar/calendar-setup.js
  8. +0 −1,818 public/javascripts/calendar/calendar.js
  9. +0 −127 public/javascripts/calendar/lang/calendar-bg.js
  10. +0 −129 public/javascripts/calendar/lang/calendar-bs.js
  11. +0 −127 public/javascripts/calendar/lang/calendar-ca.js
  12. +0 −69 public/javascripts/calendar/lang/calendar-cs.js
  13. +0 −128 public/javascripts/calendar/lang/calendar-da.js
  14. +0 −128 public/javascripts/calendar/lang/calendar-de.js
  15. +0 −127 public/javascripts/calendar/lang/calendar-en-gb.js
  16. +0 −127 public/javascripts/calendar/lang/calendar-en.js
  17. +0 −129 public/javascripts/calendar/lang/calendar-es.js
  18. +0 −128 public/javascripts/calendar/lang/calendar-eu.js
  19. +0 −127 public/javascripts/calendar/lang/calendar-fa.js
  20. +0 −127 public/javascripts/calendar/lang/calendar-fi.js
  21. +0 −129 public/javascripts/calendar/lang/calendar-fr.js
  22. +0 −128 public/javascripts/calendar/lang/calendar-gl.js
  23. +0 −127 public/javascripts/calendar/lang/calendar-he.js
  24. +0 −128 public/javascripts/calendar/lang/calendar-hr.js
  25. +0 −127 public/javascripts/calendar/lang/calendar-hu.js
  26. +0 −130 public/javascripts/calendar/lang/calendar-id.js
  27. +0 −130 public/javascripts/calendar/lang/calendar-it.js
  28. +0 −87 public/javascripts/calendar/lang/calendar-ja.js
  29. +0 −127 public/javascripts/calendar/lang/calendar-ko.js
  30. +0 −128 public/javascripts/calendar/lang/calendar-lt.js
  31. +0 −127 public/javascripts/calendar/lang/calendar-lv.js
  32. +0 −128 public/javascripts/calendar/lang/calendar-mk.js
  33. +0 −127 public/javascripts/calendar/lang/calendar-mn.js
  34. +0 −127 public/javascripts/calendar/lang/calendar-nl.js
  35. +0 −86 public/javascripts/calendar/lang/calendar-no.js
  36. +0 −127 public/javascripts/calendar/lang/calendar-pl.js
  37. +0 −129 public/javascripts/calendar/lang/calendar-pt-br.js
  38. +0 −128 public/javascripts/calendar/lang/calendar-pt.js
  39. +0 −127 public/javascripts/calendar/lang/calendar-ro.js
  40. +0 −127 public/javascripts/calendar/lang/calendar-ru.js
  41. +0 −68 public/javascripts/calendar/lang/calendar-sk.js
  42. +0 −127 public/javascripts/calendar/lang/calendar-sl.js
  43. +0 −127 public/javascripts/calendar/lang/calendar-sr-yu.js
  44. +0 −127 public/javascripts/calendar/lang/calendar-sr.js
  45. +0 −84 public/javascripts/calendar/lang/calendar-sv.js
  46. +0 −127 public/javascripts/calendar/lang/calendar-th.js
  47. +0 −127 public/javascripts/calendar/lang/calendar-tr.js
  48. +0 −127 public/javascripts/calendar/lang/calendar-uk.js
  49. +0 −126 public/javascripts/calendar/lang/calendar-vi.js
  50. +0 −127 public/javascripts/calendar/lang/calendar-zh-tw.js
  51. +0 −127 public/javascripts/calendar/lang/calendar-zh.js
  52. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-af.js
  53. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-ar-DZ.js
  54. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-ar.js
  55. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-az.js
  56. +24 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-bg.js
  57. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-bs.js
  58. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-ca.js
  59. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-cs.js
  60. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-cy-GB.js
  61. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-da.js
  62. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-de.js
  63. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-el.js
  64. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-en-AU.js
  65. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-en-GB.js
  66. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-en-NZ.js
  67. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-eo.js
  68. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-es.js
  69. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-et.js
  70. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-eu.js
  71. +59 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-fa.js
  72. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-fi.js
  73. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-fo.js
  74. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-fr-CH.js
  75. +25 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-fr.js
  76. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-gl.js
  77. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-he.js
  78. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-hi.js
  79. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-hr.js
  80. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-hu.js
  81. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-hy.js
  82. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-id.js
  83. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-is.js
  84. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-it.js
  85. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-ja.js
  86. +21 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-ka.js
  87. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-kk.js
  88. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-km.js
  89. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-ko.js
  90. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-lb.js
  91. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-lt.js
  92. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-lv.js
  93. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-mk.js
  94. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-ml.js
  95. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-mn.js
  96. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-ms.js
  97. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-nl-BE.js
  98. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-nl.js
  99. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-no.js
  100. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-pl.js
  101. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-pt-BR.js
  102. +22 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-pt.js
  103. +21 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-rm.js
  104. +26 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-ro.js
  105. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-ru.js
  106. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-sk.js
  107. +24 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-sl.js
  108. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-sq.js
  109. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-sr-SR.js
  110. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-sr.js
  111. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-sv.js
  112. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-ta.js
  113. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-th.js
  114. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-tj.js
  115. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-tr.js
  116. +24 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-uk.js
  117. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-vi.js
  118. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-zh-CN.js
  119. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-zh-HK.js
  120. +23 −0 public/javascripts/libs/ui/i18n/jquery.ui.datepicker-zh-TW.js
  121. +6 −0 public/stylesheets/application.css
  122. +0 −240 public/stylesheets/calendar.css
@@ -916,33 +916,25 @@ def context_menu_link(name, url, options={})
end
def calendar_for(field_id)
- include_calendar_headers_tags
- image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
- javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });")
- end
-
- def include_calendar_headers_tags
- unless @calendar_headers_tags_included
- @calendar_headers_tags_included = true
- content_for :header_tags do
- start_of_week = case Setting.start_of_week.to_i
- when 1
- 'Calendar._FD = 1;' # Monday
- when 7
- 'Calendar._FD = 0;' # Sunday
- when 6
- 'Calendar._FD = 6;' # Saturday
- else
- '' # use language
- end
-
- javascript_include_tag('calendar/calendar') +
- javascript_include_tag("calendar/lang/calendar-#{current_language.to_s.downcase}.js") +
- javascript_tag(start_of_week) +
- javascript_include_tag('calendar/calendar-setup') +
- stylesheet_link_tag('calendar')
- end
+ javascript_tag("jQuery('##{field_id}').datepicker(datepickerSettings)")
+ end
+
+ def jquery_datepicker_settings
+ start_of_week = Setting.start_of_week.to_s
+ start_of_week_string = start_of_week.present? ? "firstDay: '#{start_of_week}', " : ''
+ script = javascript_tag("var datepickerSettings = {" +
+ start_of_week_string +
+ "showOn: 'both', " +
+ "buttonImage: '" + path_to_image('/images/calendar.png') + "', " +
+ "buttonImageOnly: true, " +
+ "showButtonPanel: true, " +
+ "dateFormat: 'yy-mm-dd' " +
+ "}")
+ unless current_language == :en
+ jquery_locale = l("jquery.ui", :default => current_language.to_s)
+ script << javascript_include_tag("libs/ui/i18n/jquery.ui.datepicker-#{jquery_locale}.js")
end
+ script
end
def content_for(name, content = nil, &block)
@@ -997,6 +989,7 @@ def javascript_heads
unless User.current.pref.warn_on_leaving_unsaved == '0'
tags << "\n" + javascript_tag("Event.observe(window, 'load', function(){ new WarnLeavingUnsaved('#{escape_javascript( l(:text_warn_on_leaving_unsaved) )}'); });")
end
+ tags << jquery_datepicker_settings
tags
end
@@ -42,10 +42,17 @@ function enableValues(field, indexes) {
f[i].up('span').hide();
}
}
+ var hasDateFields = ((jQuery("#div_values_" + field).find('input[type="date"]').size() > 0) && (Modernizr.inputtypes.date === false));
if (indexes.length > 0) {
Element.show("div_values_" + field);
+ if(hasDateFields) {
+ jQuery("#div_values_" + field).find('input[type="date"]').datepicker('enable');
+ }
} else {
Element.hide("div_values_" + field);
+ if(hasDateFields) {
+ jQuery("#div_values_" + field).find('input[type="date"]').datepicker('disable');
+ }
}
}
@@ -95,6 +102,9 @@ function apply_filters_observer() {
:complete => "e.stop(); apply_filters_observer()") %>
}
});
+ if(Modernizr.inputtypes.date === false) {
+ jQuery('#query_form input[type="date"]').datepicker(datepickerSettings);
+ }
}
Event.observe(document,"dom:loaded", apply_filters_observer);
//]]>
View
@@ -2,6 +2,8 @@
# by Vladimir Medarović (vlada@medarovic.com)
sr-YU:
direction: ltr
+ jquery:
+ ui: "sr-SR"
date:
formats:
# Use the strftime parameters for formats.
View
@@ -4,6 +4,9 @@
"zh-TW":
direction: ltr
+ jquery:
+ # Falls back to the value in zh.yml if not set
+ ui: "zh-TW"
date:
formats:
# Use the strftime parameters for formats.
View
@@ -3,6 +3,8 @@
zh:
direction: ltr
+ jquery:
+ ui: "zh-CN"
date:
formats:
default: "%Y-%m-%d"
@@ -658,4 +658,9 @@ jQuery(document).ready(function($) {
}
setUpDialogWindow();
+
+ if(Modernizr.inputtypes.date === false) {
+ $('input[type="date"]').datepicker(datepickerSettings)
+ .filter('[disabled="disabled"]').datepicker('disable');
+ }
});
@@ -1,200 +0,0 @@
-/* Copyright Mihai Bazon, 2002, 2003 | http://dynarch.com/mishoo/
- * ---------------------------------------------------------------------------
- *
- * The DHTML Calendar
- *
- * Details and latest version at:
- * http://dynarch.com/mishoo/calendar.epl
- *
- * This script is distributed under the GNU Lesser General Public License.
- * Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
- *
- * This file defines helper functions for setting up the calendar. They are
- * intended to help non-programmers get a working calendar on their site
- * quickly. This script should not be seen as part of the calendar. It just
- * shows you what one can do with the calendar, while in the same time
- * providing a quick and simple method for setting it up. If you need
- * exhaustive customization of the calendar creation process feel free to
- * modify this code to suit your needs (this is recommended and much better
- * than modifying calendar.js itself).
- */
-
-// $Id: calendar-setup.js,v 1.25 2005/03/07 09:51:33 mishoo Exp $
-
-/**
- * This function "patches" an input field (or other element) to use a calendar
- * widget for date selection.
- *
- * The "params" is a single object that can have the following properties:
- *
- * prop. name | description
- * -------------------------------------------------------------------------------------------------
- * inputField | the ID of an input field to store the date
- * displayArea | the ID of a DIV or other element to show the date
- * button | ID of a button or other element that will trigger the calendar
- * eventName | event that will trigger the calendar, without the "on" prefix (default: "click")
- * ifFormat | date format that will be stored in the input field
- * daFormat | the date format that will be used to display the date in displayArea
- * singleClick | (true/false) wether the calendar is in single click mode or not (default: true)
- * firstDay | numeric: 0 to 6. "0" means display Sunday first, "1" means display Monday first, etc.
- * align | alignment (default: "Br"); if you don't know what's this see the calendar documentation
- * range | array with 2 elements. Default: [1900, 2999] -- the range of years available
- * weekNumbers | (true/false) if it's true (default) the calendar will display week numbers
- * flat | null or element ID; if not null the calendar will be a flat calendar having the parent with the given ID
- * flatCallback | function that receives a JS Date object and returns an URL to point the browser to (for flat calendar)
- * disableFunc | function that receives a JS Date object and should return true if that date has to be disabled in the calendar
- * onSelect | function that gets called when a date is selected. You don't _have_ to supply this (the default is generally okay)
- * onClose | function that gets called when the calendar is closed. [default]
- * onUpdate | function that gets called after the date is updated in the input field. Receives a reference to the calendar.
- * date | the date that the calendar will be initially displayed to
- * showsTime | default: false; if true the calendar will include a time selector
- * timeFormat | the time format; can be "12" or "24", default is "12"
- * electric | if true (default) then given fields/date areas are updated for each move; otherwise they're updated only on close
- * step | configures the step of the years in drop-down boxes; default: 2
- * position | configures the calendar absolute position; default: null
- * cache | if "true" (but default: "false") it will reuse the same calendar object, where possible
- * showOthers | if "true" (but default: "false") it will show days from other months too
- *
- * None of them is required, they all have default values. However, if you
- * pass none of "inputField", "displayArea" or "button" you'll get a warning
- * saying "nothing to setup".
- */
-Calendar.setup = function (params) {
- function param_default(pname, def) { if (typeof params[pname] == "undefined") { params[pname] = def; } };
-
- param_default("inputField", null);
- param_default("displayArea", null);
- param_default("button", null);
- param_default("eventName", "click");
- param_default("ifFormat", "%Y/%m/%d");
- param_default("daFormat", "%Y/%m/%d");
- param_default("singleClick", true);
- param_default("disableFunc", null);
- param_default("dateStatusFunc", params["disableFunc"]); // takes precedence if both are defined
- param_default("dateText", null);
- param_default("firstDay", null);
- param_default("align", "Br");
- param_default("range", [1900, 2999]);
- param_default("weekNumbers", true);
- param_default("flat", null);
- param_default("flatCallback", null);
- param_default("onSelect", null);
- param_default("onClose", null);
- param_default("onUpdate", null);
- param_default("date", null);
- param_default("showsTime", false);
- param_default("timeFormat", "24");
- param_default("electric", true);
- param_default("step", 2);
- param_default("position", null);
- param_default("cache", false);
- param_default("showOthers", false);
- param_default("multiple", null);
-
- var tmp = ["inputField", "displayArea", "button"];
- for (var i in tmp) {
- if (typeof params[tmp[i]] == "string") {
- params[tmp[i]] = document.getElementById(params[tmp[i]]);
- }
- }
- if (!(params.flat || params.multiple || params.inputField || params.displayArea || params.button)) {
- alert("Calendar.setup:\n Nothing to setup (no fields found). Please check your code");
- return false;
- }
-
- function onSelect(cal) {
- var p = cal.params;
- var update = (cal.dateClicked || p.electric);
- if (update && p.inputField) {
- p.inputField.value = cal.date.print(p.ifFormat);
- if (typeof p.inputField.onchange == "function")
- p.inputField.onchange();
- }
- if (update && p.displayArea)
- p.displayArea.innerHTML = cal.date.print(p.daFormat);
- if (update && typeof p.onUpdate == "function")
- p.onUpdate(cal);
- if (update && p.flat) {
- if (typeof p.flatCallback == "function")
- p.flatCallback(cal);
- }
- if (update && p.singleClick && cal.dateClicked)
- cal.callCloseHandler();
- };
-
- if (params.flat != null) {
- if (typeof params.flat == "string")
- params.flat = document.getElementById(params.flat);
- if (!params.flat) {
- alert("Calendar.setup:\n Flat specified but can't find parent.");
- return false;
- }
- var cal = new Calendar(params.firstDay, params.date, params.onSelect || onSelect);
- cal.showsOtherMonths = params.showOthers;
- cal.showsTime = params.showsTime;
- cal.time24 = (params.timeFormat == "24");
- cal.params = params;
- cal.weekNumbers = params.weekNumbers;
- cal.setRange(params.range[0], params.range[1]);
- cal.setDateStatusHandler(params.dateStatusFunc);
- cal.getDateText = params.dateText;
- if (params.ifFormat) {
- cal.setDateFormat(params.ifFormat);
- }
- if (params.inputField && typeof params.inputField.value == "string") {
- cal.parseDate(params.inputField.value);
- }
- cal.create(params.flat);
- cal.show();
- return false;
- }
-
- var triggerEl = params.button || params.displayArea || params.inputField;
- triggerEl["on" + params.eventName] = function() {
- var dateEl = params.inputField || params.displayArea;
- var dateFmt = params.inputField ? params.ifFormat : params.daFormat;
- var mustCreate = false;
- var cal = window.calendar;
- if (dateEl)
- params.date = Date.parseDate(dateEl.value || dateEl.innerHTML, dateFmt);
- if (!(cal && params.cache)) {
- window.calendar = cal = new Calendar(params.firstDay,
- params.date,
- params.onSelect || onSelect,
- params.onClose || function(cal) { cal.hide(); });
- cal.showsTime = params.showsTime;
- cal.time24 = (params.timeFormat == "24");
- cal.weekNumbers = params.weekNumbers;
- mustCreate = true;
- } else {
- if (params.date)
- cal.setDate(params.date);
- cal.hide();
- }
- if (params.multiple) {
- cal.multiple = {};
- for (var i = params.multiple.length; --i >= 0;) {
- var d = params.multiple[i];
- var ds = d.print("%Y%m%d");
- cal.multiple[ds] = d;
- }
- }
- cal.showsOtherMonths = params.showOthers;
- cal.yearStep = params.step;
- cal.setRange(params.range[0], params.range[1]);
- cal.params = params;
- cal.setDateStatusHandler(params.dateStatusFunc);
- cal.getDateText = params.dateText;
- cal.setDateFormat(dateFmt);
- if (mustCreate)
- cal.create();
- cal.refresh();
- if (!params.position)
- cal.showAtElement(params.button || params.displayArea || params.inputField);
- else
- cal.showAt(params.position[0], params.position[1]);
- return false;
- };
-
- return cal;
-};
Oops, something went wrong.

0 comments on commit ff94716

Please sign in to comment.