Sha256: 96d1c032d8cdf49343c3ee54cd93d1ed55625992a52cddb9283b70f8bffa745e

Contents?: true

Size: 1019 Bytes

Versions: 130

Compression:

Stored size: 1019 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

      # This has gotta be a valid pattern
      def validated?(name)
        true
      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

130 entries across 130 versions & 1 rubygems

Version Path
effective_bootstrap-0.7.4 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.7.3 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.7.2 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.7.1 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.7.0 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.6.31 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.6.30 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.6.29 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.6.28 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.6.27 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.6.26 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.6.25 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.6.24 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.6.23 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.6.22 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.6.21 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.6.20 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.6.19 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.6.18 app/models/effective/form_inputs/phone_field.rb
effective_bootstrap-0.6.17 app/models/effective/form_inputs/phone_field.rb