Module: Jquids::FormHelpers
- Defined in:
- lib/jquids/form_helpers.rb
Instance Method Summary collapse
- #jquids(model, method, options = {}) ⇒ Object
- #jquids_class(options) ⇒ Object
- #jquids_tag(name, value = nil, options = {}) ⇒ Object
- #jsonify_opts(options) ⇒ Object
Instance Method Details
#jquids(model, method, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/jquids/form_helpers.rb', line 16 def jquids(model, method, ={}) obj = [:object] || instance_variable_get("@#{model}") Jquids.() jsonify_opts [:value] ||= begin obj.send(method).strftime(Jquids.date_format_string(false)) rescue nil end [:class] ? [:class] += " #{jquids_class()}" : [:class] = jquids_class() text_field(model, method, ) end |
#jquids_class(options) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/jquids/form_helpers.rb', line 51 def jquids_class() result = "jquids_" result << "d" unless .delete(:calendar) == false result << "t" if .delete(:time) == true result << "p" end |
#jquids_tag(name, value = nil, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/jquids/form_helpers.rb', line 4 def jquids_tag(name, value=nil, = {}) Jquids.() jsonify_opts value = Jquids.format_time(value) [:class] ? [:class] += " #{jquids_class()}" : [:class] = jquids_class() text_field_tag(name, value, ) end |
#jsonify_opts(options) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/jquids/form_helpers.rb', line 34 def jsonify_opts() unless [:datepicker_options].nil? and [:timepicker_options].nil? [:datepicker_options] ||= {} [:datepicker_options] = [:datepicker_options].merge(.delete(:timepicker_options)) unless [:timepicker_options].nil? ["data-jquipicker"] = if [:datepicker_options].respond_to?(:to_json) .delete(:datepicker_options).to_json else begin JSON.unparse(.delete(:datepicker_options)) rescue "" end end end end |