Class: JqueryDatepick::InstanceTag
- Inherits:
-
ActionView::Helpers::InstanceTag
- Object
- ActionView::Helpers::InstanceTag
- JqueryDatepick::InstanceTag
- Defined in:
- lib/jquery_datepick/form_helper.rb
Constant Summary collapse
- FORMAT_REPLACEMENTES =
{ "yy" => "%Y", "mm" => "%m", "dd" => "%d", "d" => "%-d", "m" => "%-m", "y" => "%y", "M" => "%b"}
Instance Method Summary collapse
- #available_datepicker_options ⇒ Object
- #format_date(tb_formatted, format) ⇒ Object
-
#get_name_and_id(options = {}) ⇒ Object
Extending ActionView::Helpers::InstanceTag module to make Rails build the name and id Just returns the options before generate the HTML in order to use the same id and name (see to_input_field_tag mehtod).
- #split_options(options) ⇒ Object
-
#translate_format(format) ⇒ Object
Method that translates the datepicker date formats, defined in (docs.jquery.com/UI/Datepicker/formatDate) to the ruby standard format (www.ruby-doc.org/core-1.9.3/Time.html#method-i-strftime).
Instance Method Details
#available_datepicker_options ⇒ Object
40 41 42 |
# File 'lib/jquery_datepick/form_helper.rb', line 40 def [:disabled, :altField, :altFormat, :appendText, :autoSize, :buttonImage, :buttonImageOnly, :buttonText, :calculateWeek, :changeMonth, :changeYear, :closeText, :constrainInput, :currentText, :dateFormat, :dayNames, :dayNamesMin, :dayNamesShort, :defaultDate, :duration, :firstDay, :gotoCurrent, :hideIfNoPrevNext, :isRTL, :maxDate, :minDate, :monthNames, :monthNamesShort, :navigationAsDateFormat, :nextText, :numberOfMonths, :prevText, :selectOtherMonths, :shortYearCutoff, :showAnim, :showButtonPanel, :showCurrentAtPos, :showMonthAfterYear, :showOn, :showOptions, :showOtherMonths, :showWeek, :stepMonths, :weekHeader, :yearRange, :yearSuffix] end |
#format_date(tb_formatted, format) ⇒ Object
49 50 51 52 |
# File 'lib/jquery_datepick/form_helper.rb', line 49 def format_date(tb_formatted, format) new_format = translate_format(format) Date.parse(tb_formatted).strftime(new_format) end |
#get_name_and_id(options = {}) ⇒ Object
Extending ActionView::Helpers::InstanceTag module to make Rails build the name and id Just returns the options before generate the HTML in order to use the same id and name (see to_input_field_tag mehtod)
35 36 37 38 |
# File 'lib/jquery_datepick/form_helper.rb', line 35 def get_name_and_id( = {}) add_default_name_and_id() end |
#split_options(options) ⇒ Object
44 45 46 47 |
# File 'lib/jquery_datepick/form_helper.rb', line 44 def () = .slice!(*) return , end |
#translate_format(format) ⇒ Object
Method that translates the datepicker date formats, defined in (docs.jquery.com/UI/Datepicker/formatDate) to the ruby standard format (www.ruby-doc.org/core-1.9.3/Time.html#method-i-strftime). This gem is not going to support all the options, just the most used.
58 59 60 |
# File 'lib/jquery_datepick/form_helper.rb', line 58 def translate_format(format) format.gsub!(/#{FORMAT_REPLACEMENTES.keys.join("|")}/) { |match| FORMAT_REPLACEMENTES[match] } end |