-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add parse-form, fix build issues
- Loading branch information
Showing
42 changed files
with
10,993 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": [ | ||
"airbnb-base" | ||
], | ||
"rules": { | ||
"indent": ["error", 4], | ||
"no-var": "error", | ||
"comma-dangle": ["error", "never"], | ||
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }], | ||
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }] | ||
}, | ||
"env": { | ||
"jasmine": true | ||
}, | ||
"globals": { | ||
"window": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
node_modules/ | ||
*.log | ||
.directory | ||
coverage | ||
.coveralls.yml | ||
npm | ||
bundle | ||
/index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
bundle | ||
coverage | ||
test | ||
.eslintrc.json | ||
.gitignore | ||
.travis.yml | ||
src.js | ||
webpack.config.js | ||
.coveralls.yml | ||
.babelrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2016 Seemple.js | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# seemple-parse-form [![npm version](https://badge.fury.io/js/seemple-parse-form.svg)](https://badge.fury.io/js/seemple-parse-form) [![Coverage Status](https://coveralls.io/repos/github/seemplejs/seemple-parse-form/badge.svg?branch=master)](https://coveralls.io/github/seemplejs/seemple-parse-form?branch=master) [![Build Status](https://travis-ci.org/seemplejs/seemple-parse-form.svg?branch=master)](https://travis-ci.org/seemplejs/seemple-parse-form) | ||
|
||
The function binds named HTML form fields (input, select, textarea etc) contained at given HTML form to corresponding properties. | ||
|
||
```html | ||
<form class="my-form"> | ||
<input type="text" value="foo" name="x"> | ||
</form> | ||
``` | ||
|
||
```js | ||
const object = {}; | ||
parseForm(object, '.my-form'); | ||
|
||
// ... | ||
console.log(object.x); // 'foo' | ||
object.x = 'bar'; // changes input value to 'bar' | ||
``` | ||
|
||
## Usage | ||
|
||
In **browser environment** (or whatever environment where ``Seemple`` is global variable) ``Seemple`` is extended. | ||
```html | ||
<script src="path/to/seemple-parse-form.min.js"></script> | ||
``` | ||
|
||
```js | ||
Seemple.parseForm(object, form); | ||
``` | ||
|
||
The bundle can be downloaded at [gh-pages branch](https://github.com/seemplejs/seemple-parse-form/tree/gh-pages) | ||
|
||
------------- | ||
|
||
In **CJS environment** ``Seemple`` is not extended. | ||
|
||
``` | ||
npm install --save seemple-parse-form | ||
``` | ||
|
||
```js | ||
const parseForm = require('seemple-parse-form'); | ||
``` | ||
|
||
|
||
## API | ||
|
||
The function accepts 4 arguments: | ||
- ``object`` - an object (required) | ||
- ``form`` - a selector, DOM node etc. of given form (custom selectors ``:sandbox`` and ``:bound(XXX)`` also acceptable) (required) | ||
- ``callback`` - a function which will be called on every found field; accepts field name and field element itself | ||
- ``eventOptions`` - event options which will be passed to every internal call of ``bindNode``. | ||
|
||
Returns: parsed form element. | ||
|
||
|
||
The third argument is usable when ``parseForm`` is used with ``Seemple.Object``: you can call ``addDataKeys`` method there. | ||
```js | ||
const form = parseForm(this, ':sandbox .foo', key => this.addDataKeys(key), { | ||
getValueOnBind: false | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
"presets": ["@babel/preset-env"] | ||
} |
Oops, something went wrong.