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

Renaming toggle to toggleVisibility because it was conflicting with sidebar and breaking it #7855

Merged
merged 4 commits into from
Mar 2, 2017
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
4 changes: 2 additions & 2 deletions examples/standard-actions.amp.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
<h3>amp-img:</h3>
<button on="tap:img-on-viewport.show">Show</button>
<button on="tap:img-on-viewport.hide">Hide</button>
<button on="tap:img-on-viewport.toggle">Toggle</button>
<button on="tap:img-on-viewport.toggleVisibility">Toggle Visibility</button>
</div>

<div class="button-set">
<h3>Normal element:</h3>
<button on="tap:normal-element.show">Show</button>
<button on="tap:normal-element.hide">Hide</button>
<button on="tap:normal-element.toggle">Toggle</button>
<button on="tap:normal-element.toggleVisibility">Toggle Visibility</button>
</div>

<amp-img src="https://ampbyexample.com/img/amp.jpg" layout="responsive" width="1080" height="610" id="img-on-viewport"></amp-img>
Expand Down
4 changes: 2 additions & 2 deletions spec/amp-actions-and-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ Example: `on="tap:target1.actionA,target2.actionB"`
## Globally defined Events and Actions
Currently AMP defines `tap` event globally that you can listen to on any HTML element (including amp-elements).

AMP also defines `hide`, `show` and `toggle` actions globally that you can trigger on any HTML element.
AMP also defines `hide`, `show` and `toggleVisibility` actions globally that you can trigger on any HTML element.

{% call callout('Note', type='note') %}Note: {% endcall %} An element can only be shown if it was previously hidden by a `hide` or `toggle` action, or by using the [`hidden`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden) attribute. `show` does not support elements hidden by CSS `display:none` or AMP's `layout=nodisplay`
{% call callout('Note', type='note') %}Note: {% endcall %} An element can only be shown if it was previously hidden by a `hide` or `toggleVisibility` action, or by using the [`hidden`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden) attribute. `show` does not support elements hidden by CSS `display:none` or AMP's `layout=nodisplay`

For example, the following is possible in AMP.

Expand Down
6 changes: 3 additions & 3 deletions src/service/standard-actions-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class StandardActions {
actionService.addGlobalMethodHandler('hide', this.handleHide.bind(this));
actionService.addGlobalMethodHandler('show', this.handleShow.bind(this));
actionService.addGlobalMethodHandler(
'toggle', this.handleToggle.bind(this));
'toggleVisibility', this.handleToggle.bind(this));
}

/**
Expand Down Expand Up @@ -138,7 +138,7 @@ export class StandardActions {
if (target.classList.contains(getLayoutClass(Layout.NODISPLAY))) {
user().warn(
'STANDARD-ACTIONS',
'Elements with layout=nodisplay cannot be dynamically shown. %s',
'Elements with layout=nodisplay cannot be dynamically shown.',
target);

return;
Expand All @@ -151,7 +151,7 @@ export class StandardActions {
user().warn(
'STANDARD-ACTIONS',
'Elements can only be dynamically shown when they have the ' +
'"hidden" attribute set or when they were dynamically hidden. %s',
'"hidden" attribute set or when they were dynamically hidden.',
target);
}
});
Expand Down
3 changes: 2 additions & 1 deletion test/functional/test-standard-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ describes.sandboxed('StandardActions', {}, () => {
expect(embedActions.addGlobalMethodHandler.args[0][1]).to.be.function;
expect(embedActions.addGlobalMethodHandler.args[1][0]).to.equal('show');
expect(embedActions.addGlobalMethodHandler.args[1][1]).to.be.function;
expect(embedActions.addGlobalMethodHandler.args[2][0]).to.equal('toggle');
expect(embedActions.addGlobalMethodHandler.args[2][0]).to
.equal('toggleVisibility');
expect(embedActions.addGlobalMethodHandler.args[2][1]).to.be.function;
embedActions.addGlobalMethodHandler.args[0][1]();
expect(hideStub).to.be.calledOnce;
Expand Down