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

Add empty amp-form service to kick off work on validation part #3470

Merged
merged 2 commits into from
Jun 6, 2016
Merged
Show file tree
Hide file tree
Changes from all 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
32 changes: 32 additions & 0 deletions extensions/amp-form/0.1/amp-form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright 2016 The AMP HTML Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {isExperimentOn} from '../../../src/experiments';
import {getService} from '../../../src/service';

/** @type {string} */
const TAG = 'amp-form';

function installAmpForm(win) {
return getService(win, 'amp-form', () => {
if (isExperimentOn(win, TAG)) {
// TODO: Write the implementation of the service.
}
return {};
});
}

installAmpForm(AMP.win);
18 changes: 18 additions & 0 deletions extensions/amp-form/0.1/test/test-amp-form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright 2016 The AMP HTML Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

describe('amp-form', () => {
});
81 changes: 81 additions & 0 deletions extensions/amp-form/amp-form.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!---
Copyright 2016 The AMP HTML Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# <a name="`amp-form`"></a> `amp-form`

<table>
<tr>
<td width="40%"><strong>Description</strong></td>
<td>Allow usage of `<form>` and input tags.</td>
</tr>
<tr>
<td width="40%"><strong>Availability</strong></td>
<td>Experimental</td>
</tr>
<tr>
<td width="40%"><strong>Required Script</strong></td>
<td><code>&lt;script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js">&lt;/script></code></td>
</tr>
<tr>
<td class="col-fourty"><strong><a href="https://www.ampproject.org/docs/guides/responsive/control_layout.html">Supported Layouts</a></strong></td>
<td>N/A</td>
</tr>
<tr>
<td width="40%"><strong>Examples</strong></td>
<td><a href="https://github.com/ampproject/amphtml/blob/master/examples/forms.amp.html">forms.amp.html</a></td>
</tr>
</table>

## Behavior

The `amp-form` extension allows the usage of forms and input fields in an AMP document. The extension allows polyfilling
some of the missing behaviors in browsers.

The `amp-form` extension **MUST** be loaded if you're using `<form>` or any input tags, otherwise your document will be invalid!

Example:
```html
<form method="post" action="https://example.com/subscribe" target="_blank">
<fieldset>
<label>
<span>Your name</span>
<input type="text" name="name" required>
</label>
<label>
<span>Your email</span>
<input type="email" name="email" required>
</label>
<input type="submit" value="Subscribe">
</fieldset>
</form>
```

## Attributes

**target**
__required__

Target attribute of the `<form>` must be either `_blank` or `_top`.

**action**
__required__

Action must be provided, `https` and is non-cdn link (does **NOT** link to https://cdn.ampproject.org).

All other [form attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) are optional.

## Inputs
Both `<input type=file>` and `<input type=password>` are not allowed. (This might be reconsidered in the future - please let us know if you require these and use cases).
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function buildExtensions(options) {
buildExtension('amp-fit-text', '0.1', true, options);
buildExtension('amp-fx-flying-carpet', '0.1', true, options);
buildExtension('amp-font', '0.1', false, options);
buildExtension('amp-form', '0.1', false, options);
buildExtension('amp-iframe', '0.1', false, options);
buildExtension('amp-image-lightbox', '0.1', true, options);
buildExtension('amp-instagram', '0.1', false, options);
Expand Down
5 changes: 5 additions & 0 deletions tools/experiments/experiments.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ const EXPERIMENTS = [
name: 'Global document form submit handler',
spec: 'https://github.com/ampproject/amphtml/issues/3343',
},
{
id: 'amp-form',
name: 'AMP Form Extension',
spec: 'https://github.com/ampproject/amphtml/issues/3343',
},
];


Expand Down