Module: Galakei::InputMode
- Defined in:
- lib/galakei/input_mode.rb
Overview
Galakei support switching between different input modes (alphabetic, hiragana, hankaku, and numeric). The input mode will be automatically changed based on the HTML5 input type. The following summarizes the mapping:
- alphabetic
-
url,email - numeric
-
tel,datetime,date,month,week,time,number,color
Additionally, the input mode can be explicitly specified by setting the inputmode attribute to one of alphabet, hiragana, hankaku_kana, or number.
Constant Summary collapse
- INPUT_MODES =
:stopdoc:
{ "alphabet" => { :docomo_wap_input_format => "en", :other_wap_input_format => 'm', :mode => 'alphabet', :istyle => '3' }, "hiragana" => { :docomo_wap_input_format => 'h', :other_wap_input_format => 'M', :mode => 'hiragana', :istyle => '1' }, "hankaku_kana" => { :docomo_wap_input_format => 'hk', :other_wap_input_format => 'M', :mode => 'hankakukana', :istyle => '2' }, "number" => { :docomo_wap_input_format => 'n', :other_wap_input_format => 'N', :mode => 'numeric', :istyle => '4' } }
Instance Method Summary collapse
Instance Method Details
#text_field(object_name, method, options = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/galakei/input_mode.rb', line 38 def text_field(object_name, method, = {}) if request.galakei? inputmode = if [:type] == "number" .delete(:type) elsif %w[tel date datetime date month week time color].include?([:type]) .delete(:type) "number" elsif %w[email url].include?([:type]) .delete(:type) "alphabet" else .delete(:inputmode) end if inputmode = INPUT_MODES[inputmode] if request.docomo? style = inputmode[:docomo_wap_input_format] [:style] = %Q{-wap-input-format:"*<ja:#{style}>"} else [:istyle] = inputmode[:istyle] [:mode] = inputmode[:mode] [:style] ||= %Q{-wap-input-format:*#{inputmode[:other_wap_input_format]}} end end end super(object_name, method, ) end |