Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

squash changes v1.0 #1

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 14 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,41 @@
# js-telephone-input
# jsTelephoneInput

## Overview
Input with telephone mask and validations for each country.
Vanilla JS library to validate international telephones. It uses a precompiled and express version of the [google's libphonenumber](https://github.com/googlei18n/libphonenumber) called [awesome-phonenumber](https://github.com/grantila/awesome-phonenumber).

## Demo
[URL here!](http://mercadolibre.github.io/js-telephone-input)
![enjzuhgyk8](https://cloud.githubusercontent.com/assets/16105726/18643322/fe9a2380-7e7a-11e6-8033-fe5226085690.gif)

## How to use
[Demo Standalone](https://fallemand.github.io/js-telephone-input/demo/demo-standalone.html)
[Documentation](https://fallemand.github.io/js-telephone-input/documentation/)

### Install

[Instructions to install and use]

## Contribute
This is the way you can contribute with this project:

### Development
#### Install
## Development
Download this repository, and install node dependencies from the root:

```
npm install
```

Run build task for generate development assets:
```
npm run build
```

Run the following command for browse the demo at [http://localhost:3000](http://localhost:3000):
```
npm start
```

Run dist task for generate production assets:
```
npm run dist
```

##### Tests

**Unit**

Run test command for run unit tests:
```
npm test
```

**End to End**

Just once run install-selenium task for preapare the enviroment for run e2e tests:
```
npm run install-selenium
```

Then run nightwatch every time you want to run e2e tests:
```
npm run nightwatch
```

If you need to pass parameters to the task you can do it so:
```
npm run nightwatch -- --verbose
```
Look at all the options [here](http://nightwatchjs.org/guide#command-line-options).

##### Deploy

Run swift command for upload static files to swift server (assuming that we upload the v1.0.0 release):
```
npm run swift -- --release v1.0.0
```

Run gh-pages command for deploy site to gh-pages:
```
npm run gh-pages
```


## Maintenance

Front-End team ([email protected])
Facundo Allemand ([email protected])

## Change log
[See releases](https://github.com/mercadolibre/js-telephone-input/releases)
[See releases](https://github.com/fallemand/js-telephone-input/releases)

## TO-DO
[See the issue tracker](https://github.com/mercadolibre/js-telephone-input/issues)

## Browser support
[See the issue tracker](https://github.com/fallemand/js-telephone-input/issues)
-Improve documentation webpage
-Add tests.
-Add new methods.
-Define as parameter the countries you want
-Document with [jsDocs](http://usejsdoc.org/)
15 changes: 15 additions & 0 deletions config/bundles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Bundles
*/
exports.scripts = {
'js-telephone-input': ['./src/scripts/js-telephone-input.js']
};

exports.styles = {
'js-telephone-input': ['./src/styles/js-telephone-input.scss'],
'js-telephone-input-chico1.1': ['./src/styles/js-telephone-input-chico1.1.scss']
};

exports.images = {
'images': './src/images/**/*.{png,jpg,ico,svg,gif}'
};
33 changes: 33 additions & 0 deletions demo/demo-standalone.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!doctype html>
<html class="no-js" lang="es">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Telephone </title>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si el lang es "es", no debería decir "Teléfono"? O podría ser algo más descriptivo onda "Validación internacional de Teléfono con JS"

<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="../ui-build/css/js-telephone-input.css">

</head>

<body>
<form>
<div class="ui-telephone">
<div class="ui-telephone__number">
<input id="telephone" type="text" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ojo con los selectores #id. Siempre es preferible (para componentes UI especialmente) utilizar [data-js] como selector para integraciones con JavaScript, como sugiere este artículo.

</div>
<div id="tel-validations" class="ui-telephone__validations"></div>
</div>
</form>

<h3>Resultado</h3>
Copy link

@HGARZON HGARZON Sep 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ojo que no existen ni el <h1> ni el <h2>. Para que el contenido sea accesibilidad es necesario que el orden de los headings sea natural (<h1>, <h2>, <h3>, etc...).

Copy link

@francomanzmeli francomanzmeli Sep 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agrego, tiene que haber solamente un h1 por template, el resto lo podes manejar.

<span class="result">Código Área: </span> <input id="telephoneAreaCode" type="text" /> <br />
<span class="result">Teléfono: </span> <input id="telephoneNumber" type="text" />

<script src="../ui-build/js/js-telephone-input.js"></script>
<script src="./demo-standalone.js"></script>
</body>

</html>
31 changes: 31 additions & 0 deletions demo/demo-standalone.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
window.onload = function () {
//Define parameters
var messages = {
'required': 'Completa este dato.',
'valid': 'El teléfono es correcto.',
'min': 'Este teléfono tiene menos dígitos de los requeridos.',
'invalidDefaultNumber': 'El teléfono cargado en tu cuenta no es válido. Verifícalo por favor.',
'max': 'Este teléfono excede el máximo de dígitos posible.',
'numbers': 'Sólo puedes ingresar números.',
'possible': 'Revisa tu teléfono.',
'notANumber': 'El teléfono no es un número.',
'zero': 'Ingrésalo siguiendo el formato de este ejemplo: ##example##'
},
parameters = {
required: true,
withFlag: true,
country: 'ar',
messages: messages,
validations : 'tel-validations',
areaCode : "telephoneAreaCode",
number : "telephoneNumber"
};

var telephoneInput = document.getElementById('telephone');

//Initialize component
telephoneInput = new jsTelephoneInput(telephoneInput, parameters);

//Call method
console.log(telephoneInput.isValid());
};
123 changes: 123 additions & 0 deletions documentation/documentation.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/* --------------------------------------------------------
Demo HTML - This is not part of the component
-------------------------------------------------------- */

body {
margin: 30px auto;
background-color: #eee;
color: #888;
font-family: 'Lato', sans-serif;
font-weight: 300;
max-width: 1050px;
}

h1, h2, h3, h4 {
font-weight: 300;
}

b, strong {
font-weight: 400;
}

a:visited {
color: #03B;
}

/* Demo Section
------------------------------------------------------------*/

.demo {
width: 380px;
display: inline-block;
}

.demo .ch-box-lite {
padding: 15px 20px;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 2px;
-webkit-box-shadow: 0 0 7px 0 rgba(0,0,0,.2);
-moz-box-shadow: 0 0 7px 0 rgba(0,0,0,.2);
box-shadow: 0 0 7px 0 rgba(0,0,0,.2);
}

.demo-telephone {
min-height: 100px;
}

.demo-title {
font-weight: 300;
}

.demo-result {
display: inline-block;
width: 90px;
}


.demo-value {
margin-top: 4px;
height: 15px;
width: 100px;
padding: 1px 2px;
font-size: 12px;
}

select.demo-value {
margin-top: 3px;
height: 15px;
width: 60px;
padding: 1px 2px;
font-size: 12px;
}

.demo .ch-btn {
margin-top: 5px;
}

/* Documentation Section
------------------------------------------------------------*/

.documentation {
margin-left: 20px;
padding: 20px 20px 15px;
width: 600px;
height: 500px;
overflow-y: scroll;
display: inline-block;
vertical-align: top;
}

.documentation-title {
font-size: 28px;
text-align: center;
margin: 100px 0 20px;
}

.documentation-title small {
font-size: 16px;
}

.documentation-article {
margin-top: 20px;
padding-top: 20px;
margin-bottom: 10px;
border-top: 1px dashed #ccc;
}

.documentation-article h2 {
margin-bottom: 20px;
}

.documentation-article-step {
margin-top: 15px;
}

.documentation pre {
margin-top: 15px;
}

.documentation xmp {
margin: -25px 0 -40px;
}

67 changes: 67 additions & 0 deletions documentation/documentation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
window.onload = function () {
initializeComponent();

initializeDemo();
};

function initializeComponent() {
//Define parameters
var messages = {
'required': 'Completa este dato.',
'valid': 'El teléfono es correcto.',
'min': 'Este teléfono tiene menos dígitos de los requeridos.',
'invalidDefaultNumber': 'El teléfono cargado en tu cuenta no es válido. Verifícalo por favor.',
'max': 'Este teléfono excede el máximo de dígitos posible.',
'numbers': 'Sólo puedes ingresar números.',
'possible': 'Revisa tu teléfono.',
'notANumber': 'El teléfono no es un número.',
'zero': 'Ingrésalo siguiendo el formato de este ejemplo: ##example##'
},
parameters = {
required: (document.getElementById('required').value == 'Yes'),
withFlag: (document.getElementById('withFlag').value == 'Yes'),
canChangeCountry: (document.getElementById('canChangeCountry').value == 'Yes'),
messages: messages
};

//Initialize component
var telephoneInput = document.getElementById('telephone');
telephoneInput = new jsTelephoneInput(telephoneInput, parameters);

}

function initializeDemo() {

//Fill select with countries
var countries = [
"ar","bo","br","cl","co","do","ec","sv","gt","hn","mx","ni","pa","py","pe","pt","uy","ve"
];
var countrySelect = document.getElementById('country');
var option;
for(var country in countries) {
option = document.createElement('option');
option.innerText = countries[country];
countrySelect.appendChild(option);
}

//Button event
var saveButton = document.getElementById('saveParameters');
saveButton.onclick = function() {changeParameters()};
}

function changeParameters() {
var initialValue = document.getElementById('initialValue').value;
var tel = document.getElementById('demo-telephone');
tel.className = 'ui-telephone';
var telNumber = document.createElement('div');
telNumber.className = 'ui-telephone__number';
telNumber.innerHTML = '<input id="telephone" type="text" value="' + initialValue + '" data-validations="tel-validations" data-country="' + document.getElementById('country').value + '" data-area-code="telephoneAreaCode" data-full-number="telephoneFullNumber" data-number="telephoneNumber" />';
var telValidations = document.createElement('div');
telValidations.id = 'tel-validations';
telValidations.className = 'ui-telephone__validations';
tel.innerHTML = '';
tel.appendChild(telNumber);
tel.appendChild(telValidations);

initializeComponent();
}
Loading