Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonyThorpe committed Jan 17, 2018
0 parents commit 5474904
Show file tree
Hide file tree
Showing 1,151 changed files with 189,451 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["env"]
}
24 changes: 24 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"es6": true,
"mocha": true
},
"rules": {
"valid-jsdoc": ["error", {
"requireReturn": false,
"requireReturnType": true,
"requireParamDescription": true,
"requireReturnDescription": true
}],
"require-jsdoc": ["error", {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true
}
}]
}
}
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/dist export-ignore
/node_modules export-ignore
/src/spec.js export-ignore
/thirdparty export-ignore
.babelrc.json export-ignore
.eslintrc export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.npmignore export-ignore
.prettierrc export-ignore
index.html export-ignore
LICENCE export-ignore
webpack.config.js export-ignore
13 changes: 13 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/dist
/node_modules
/src/spec.js
/thirdparty
.babelrc.json
.eslintrc
.gitattributes
.gitignore
.npmignore
.prettierrc
index.html
LICENCE
webpack.config.js
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"bracketSpacing": true,
"semi": true,
"singleQuote": false,
"trailingComma": none
}
21 changes: 21 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Antony Thorpe

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
70 changes: 70 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Date Input Field Reader for jQuery UI Datepicker
Sneaky shortcuts for date input field data entry with jQuery UI datepicker in any locale. Provides a better UX by allowing the user to select either the input field or the datepicker.

## Usage
The user can enter:
* `23`
* `23/1`
* `23 1`
* `23-1`
* `23.1`
* `23 Jan`
* or `23/1/18`(short year length)
to generate `Wed Jan 03 2018 00:00:00 GMT+1300 (NZDT)` date string.

If you are from a funny country that places the month first then this will work too:
* `1/23`
* `1 23`
* `1-23`
* `1.23`
* `Jan 23`

Also with year-first regions like Korea.
* `18 Jan 23`

## Installation
```javascript
npm install dateinputfieldreader
```

## How to use
* ensure that jQuery UI Datepicker is loaded first
* import the function:
```javascript
import extractDateFromInput from "dateinputfieldreader";
```
and within the change event of the datepicker run the data entry through this function. Below is some `knockoutjs` code you can modify:
```javascript
//handle the field changing update observable and excluded dates for beforeShowDay
ko.utils.registerEventHandler(element, "change", function(event) {
var enteredDate = (event.target.value).trim();
var extractedDate = extractDateFromInput(enteredDate);

if (extractedDate){
// next update the variable
observable(extractedDate);

// and update the datepicker
$(element).datepicker("setDate", extractedDate);
}
});
```

## Requirements
* [jQuery UI Datepicker](https://jqueryui.com/datepicker/)

## Tests
Run online [here](http://antonythorpe.github.io/dateInputFieldReader/index.html).
Locally `npm test` to launch in Chrome.

## Contributions
Pull requests are most welcome!

## Support
None sorry.

## Change Log
[File](changelog.md)

## Licence
[MIT](LICENCE)
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Changelog of Date Input Field Reader

#### 1.0.0
* Initial commit
Loading

0 comments on commit 5474904

Please sign in to comment.