Sha256: ad92b33374ce10320234ba40dc1ade64c133a877a4c70454ad9db74b5000a694

Contents?: true

Size: 926 Bytes

Versions: 7

Compression:

Stored size: 926 Bytes

Contents

module Effective
  module FormInputs
    class PhoneField < Effective::FormInput

      DEFAULT_TEL_MASK = '(999) 999-9999? x99999'
      DEFAULT_CELL_MASK = '(999) 999-9999'

      def input_html_options
        { class: 'form-control effective_phone', placeholder: '(555) 555-5555' }
      end

      def input_js_options
        { mask: ((cell? || fax?) ? DEFAULT_CELL_MASK : DEFAULT_TEL_MASK), placeholder: '_' }
      end

      def input_group_options
        { input_group: { class: 'input-group' }, prepend: content_tag(:span, icon('phone'), class: 'input-group-text') }
      end

      private

      def fax?
        return @fax unless @fax.nil?
        @fax = options.key?(:fax) ? options.delete(:fax) : name.to_s.include?('fax')
      end

      def cell?
        return @cell unless @cell.nil?
        @cell = options.key?(:cell) ? options.delete(:cell) : name.to_s.include?('cell')
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
effective_bootstrap-0.0.7 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.0.6 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.0.5 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.0.4 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.0.3 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.0.2 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.0.1 app/models/effective/form_inputs/phone_field.rb