0.0.15 • Published 5 years ago

@esscorp/gphone v0.0.15

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

wphone

gphone is a wrapper around the following:

It exposes the following:

  • 3 view helpers to format and display phone numbers. format - which formats phone numbers in either E164 or INTERNATIONAL format. viewer - which converts from E164 to INTERNATIONAL format. * dialer - which converts from E164 to INTERNATIONAL format and wraps in a link.
  • 1 jQuery plugin $.fn.phone() to simplify the inputting of phone numbers.
  • 1 jQuery plugin $.fn.provePhone to validate phone numbers using the jQuery provejs.

gphone does not include google-libphonenumber, intl-tel-input, or jquery-prove. It is expected that you will include these dependencies in your build process.

Introduction

Regarding the storage and transport of phone numbers:

  • We want to store all phone numbers in E164 format in the database.
  • Convert to E164 format as early as possible.
  • Convert away from E164 as late as possible.
  • The phone number and phone extension are stored in separate columns.
  • Phone numbers should be displayed to users in international format.

View Helpers

Use format to format phone numbers.

{{format phone 'E164'}} //+15124510100
{{format phone 'INTERNATIONAL'}} //+1 512-451-0100

Use dialer for users who need to dial numbers.

{{dialer phone extension}}

Use viewer for users who don't need to dial their own number

{{viewer phone extension}}

Note: is expected that when integrating these view helpers with Handlebars you will namespace them as:

  • {{phoneformat ...}}
  • {{phoneViewer ...}}
  • {{phoneDialer ...}}

You can also use the helpers in Node.js code:

var Phone = require('@esscorp/gphone');
var e164 = Phone.format(data.phone, 'E164');
var intl = Phone.format(data.phone, 'INTERNATIONAL');

jQuery Plugin

Regarding the input of phone numbers by users:

  • Display in international formation +1 512-451-0100
  • Use $.fn.phone() phone number picker which helps select country code and phone extension.
// We store phone number in E164, but just incase convert again to E164
// because the phone plugin will error if phone number is not in E164.
telphone.phone({
  number: '{{phoneFormat user.phone 'E164'}}',
  extension: '{{user.phone_ext}}'
});

todo

  • Code telphone.phone('destroy')
  • Remove Handlebars dependencies.
  • Fix $.fn.phone() to not throw an error if not in #164 format.
0.0.15

5 years ago

0.0.14

6 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago