Skip to content

Commit

Permalink
Formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
keanulee committed Jul 3, 2018
1 parent 3c45aef commit 435ecf1
Show file tree
Hide file tree
Showing 18 changed files with 1,947 additions and 1,953 deletions.
18 changes: 10 additions & 8 deletions demo/simple-overlay.js
@@ -1,17 +1,19 @@
/**
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
This code may only be used under the BSD style license found at
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
part of the polymer project is also subject to an additional IP rights grant
found at http://polymer.github.io/PATENTS.txt
*/
import '@polymer/polymer/polymer-legacy.js';

import { IronOverlayBehavior } from '../iron-overlay-behavior.js';
import { Polymer } from '@polymer/polymer/lib/legacy/polymer-fn.js';
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
import {Polymer} from '@polymer/polymer/lib/legacy/polymer-fn.js';
import {html} from '@polymer/polymer/lib/utils/html-tag.js';

import {IronOverlayBehavior} from '../iron-overlay-behavior.js';

Polymer({
_template: html`
Expand Down
13 changes: 7 additions & 6 deletions iron-focusables-helper.js
@@ -1,15 +1,16 @@
/**
@license
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
This code may only be used under the BSD style license found at
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
part of the polymer project is also subject to an additional IP rights grant
found at http://polymer.github.io/PATENTS.txt
*/
import '@polymer/polymer/polymer-legacy.js';

import { dom } from '@polymer/polymer/lib/legacy/polymer.dom.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';

var p = Element.prototype;
var matches = p.matches || p.matchesSelector || p.mozMatchesSelector ||
Expand Down
31 changes: 17 additions & 14 deletions iron-overlay-backdrop.js
@@ -1,32 +1,35 @@
/**
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
This code may only be used under the BSD style license found at
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
part of the polymer project is also subject to an additional IP rights grant
found at http://polymer.github.io/PATENTS.txt
*/
import '@polymer/polymer/polymer-legacy.js';

import { Polymer } from '@polymer/polymer/lib/legacy/polymer-fn.js';
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
import { dom } from '@polymer/polymer/lib/legacy/polymer.dom.js';
import {Polymer} from '@polymer/polymer/lib/legacy/polymer-fn.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
import {html} from '@polymer/polymer/lib/utils/html-tag.js';

/*
`iron-overlay-backdrop` is a backdrop used by `Polymer.IronOverlayBehavior`. It should be a
singleton.
`iron-overlay-backdrop` is a backdrop used by `Polymer.IronOverlayBehavior`. It
should be a singleton.
### Styling
The following custom properties and mixins are available for styling.
Custom property | Description | Default
-------------------------------------------|------------------------|---------
`--iron-overlay-backdrop-background-color` | Backdrop background color | #000
`--iron-overlay-backdrop-opacity` | Backdrop opacity | 0.6
`--iron-overlay-backdrop` | Mixin applied to `iron-overlay-backdrop`. | {}
`--iron-overlay-backdrop-opened` | Mixin applied to `iron-overlay-backdrop` when it is displayed | {}
`--iron-overlay-backdrop-background-color` | Backdrop background color | #000
`--iron-overlay-backdrop-opacity` | Backdrop opacity | 0.6
`--iron-overlay-backdrop` | Mixin applied to
`iron-overlay-backdrop`. | {}
`--iron-overlay-backdrop-opened` | Mixin applied to
`iron-overlay-backdrop` when it is displayed | {}
*/
Polymer({
_template: html`
Expand Down
79 changes: 39 additions & 40 deletions iron-overlay-behavior.js
@@ -1,21 +1,23 @@
/**
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
This code may only be used under the BSD style license found at
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
part of the polymer project is also subject to an additional IP rights grant
found at http://polymer.github.io/PATENTS.txt
*/
import '@polymer/polymer/polymer-legacy.js';

import { IronFitBehavior } from '@polymer/iron-fit-behavior/iron-fit-behavior.js';
import { IronResizableBehavior } from '@polymer/iron-resizable-behavior/iron-resizable-behavior.js';
import { IronOverlayManager } from './iron-overlay-manager.js';
import { removeScrollLock, pushScrollLock } from './iron-scroll-manager.js';
import { IronFocusablesHelper } from './iron-focusables-helper.js';
import { dom } from '@polymer/polymer/lib/legacy/polymer.dom.js';
import { useShadow } from '@polymer/polymer/lib/utils/settings.js';
import {IronFitBehavior} from '@polymer/iron-fit-behavior/iron-fit-behavior.js';
import {IronResizableBehavior} from '@polymer/iron-resizable-behavior/iron-resizable-behavior.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
import {useShadow} from '@polymer/polymer/lib/utils/settings.js';

import {IronFocusablesHelper} from './iron-focusables-helper.js';
import {IronOverlayManager} from './iron-overlay-manager.js';
import {pushScrollLock, removeScrollLock} from './iron-scroll-manager.js';

/** @polymerBehavior */
export const IronOverlayBehaviorImpl = {
Expand Down Expand Up @@ -155,8 +157,7 @@ export const IronOverlayBehaviorImpl = {
* @return {!Node}
*/
get _focusNode() {
return this._focusedChild ||
dom(this).querySelector('[autofocus]') || this;
return this._focusedChild || dom(this).querySelector('[autofocus]') || this;
},

/**
Expand Down Expand Up @@ -752,10 +753,10 @@ export const IronOverlayBehaviorImpl = {
};

/**
Use `Polymer.IronOverlayBehavior` to implement an element that can be hidden or
shown, and displays on top of other content. It includes an optional backdrop,
and can be used to implement a variety of UI controls including dialogs and drop
downs. Multiple overlays may be displayed at once.
Use `Polymer.IronOverlayBehavior` to implement an element that can be hidden
or shown, and displays on top of other content. It includes an optional
backdrop, and can be used to implement a variety of UI controls including
dialogs and drop downs. Multiple overlays may be displayed at once.
See the [demo source
code](https://github.com/PolymerElements/iron-overlay-behavior/blob/master/demo/simple-overlay.html)
Expand All @@ -764,14 +765,15 @@ export const IronOverlayBehaviorImpl = {
### Closing and canceling
An overlay may be hidden by closing or canceling. The difference between close
and cancel is user intent. Closing generally implies that the user acknowledged
the content on the overlay. By default, it will cancel whenever the user taps
outside it or presses the escape key. This behavior is configurable with the
`no-cancel-on-esc-key` and the `no-cancel-on-outside-click` properties.
`close()` should be called explicitly by the implementer when the user interacts
with a control in the overlay element. When the dialog is canceled, the overlay
fires an 'iron-overlay-canceled' event. Call `preventDefault` on this event to
prevent the overlay from closing.
and cancel is user intent. Closing generally implies that the user
acknowledged the content on the overlay. By default, it will cancel whenever
the user taps outside it or presses the escape key. This behavior is
configurable with the `no-cancel-on-esc-key` and the
`no-cancel-on-outside-click` properties. `close()` should be called explicitly
by the implementer when the user interacts with a control in the overlay
element. When the dialog is canceled, the overlay fires an
'iron-overlay-canceled' event. Call `preventDefault` on this event to prevent
the overlay from closing.
### Positioning
Expand All @@ -781,30 +783,27 @@ export const IronOverlayBehaviorImpl = {
### Backdrop
Set the `with-backdrop` attribute to display a backdrop behind the overlay. The
backdrop is appended to `<body>` and is of type `<iron-overlay-backdrop>`. See
its doc page for styling options.
Set the `with-backdrop` attribute to display a backdrop behind the overlay.
The backdrop is appended to `<body>` and is of type `<iron-overlay-backdrop>`.
See its doc page for styling options.
In addition, `with-backdrop` will wrap the focus within the content in the light
DOM. Override the [`_focusableNodes`
In addition, `with-backdrop` will wrap the focus within the content in the
light DOM. Override the [`_focusableNodes`
getter](#Polymer.IronOverlayBehavior:property-_focusableNodes) to achieve a
different behavior.
### Limitations
The element is styled to appear on top of other content by setting its `z-index`
property. You must ensure no element has a stacking context with a higher
`z-index` than its parent stacking context. You should place this element as a
child of `<body>` whenever possible.
The element is styled to appear on top of other content by setting its
`z-index` property. You must ensure no element has a stacking context with a
higher `z-index` than its parent stacking context. You should place this
element as a child of `<body>` whenever possible.
@demo demo/index.html
@polymerBehavior
*/
export const IronOverlayBehavior = [
IronFitBehavior,
IronResizableBehavior,
IronOverlayBehaviorImpl
];
export const IronOverlayBehavior =
[IronFitBehavior, IronResizableBehavior, IronOverlayBehaviorImpl];

/**
* Fired after the overlay opens.
Expand Down
20 changes: 10 additions & 10 deletions iron-overlay-manager.js
@@ -1,18 +1,19 @@
/**
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
This code may only be used under the BSD style license found at
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
part of the polymer project is also subject to an additional IP rights grant
found at http://polymer.github.io/PATENTS.txt
*/
import '@polymer/polymer/polymer-legacy.js';

import { IronA11yKeysBehavior } from '@polymer/iron-a11y-keys-behavior/iron-a11y-keys-behavior.js';
import './iron-overlay-backdrop.js';

import {IronA11yKeysBehavior} from '@polymer/iron-a11y-keys-behavior/iron-a11y-keys-behavior.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
import * as gestures from '@polymer/polymer/lib/utils/gestures.js';
import { dom } from '@polymer/polymer/lib/legacy/polymer.dom.js';

/**
* @struct
Expand Down Expand Up @@ -366,8 +367,7 @@ IronOverlayManagerClass.prototype = {
if (overlay) {
if (IronA11yKeysBehavior.keyboardEventMatchesKeys(event, 'esc')) {
overlay._onCaptureEsc(event);
} else if (IronA11yKeysBehavior.keyboardEventMatchesKeys(
event, 'tab')) {
} else if (IronA11yKeysBehavior.keyboardEventMatchesKeys(event, 'tab')) {
overlay._onCaptureTab(event);
}
}
Expand Down
37 changes: 15 additions & 22 deletions iron-scroll-manager.js
@@ -1,15 +1,16 @@
/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
This code may only be used under the BSD style license found at
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
part of the polymer project is also subject to an additional IP rights grant
found at http://polymer.github.io/PATENTS.txt
*/
import '@polymer/polymer/polymer-legacy.js';

import { dom } from '@polymer/polymer/lib/legacy/polymer.dom.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
/**
* Used to calculate the scroll direction during touch events.
* @type {!Object}
Expand Down Expand Up @@ -58,7 +59,7 @@ and this string can then be deleted`;
*
* @return {!Node|undefined}
*/
export { currentLockingElement };
export {currentLockingElement};

/**
* Returns true if the provided element is "scroll locked", which is to
Expand Down Expand Up @@ -117,8 +118,7 @@ export function pushScrollLock(element) {
}

_lockingElements.push(element);
currentLockingElement =
_lockingElements[_lockingElements.length - 1];
currentLockingElement = _lockingElements[_lockingElements.length - 1];

_lockedElementCache = [];
_unlockedElementCache = [];
Expand All @@ -141,8 +141,7 @@ export function removeScrollLock(element) {
}

_lockingElements.splice(index, 1);
currentLockingElement =
_lockingElements[_lockingElements.length - 1];
currentLockingElement = _lockingElements[_lockingElements.length - 1];

_lockedElementCache = [];
_unlockedElementCache = [];
Expand Down Expand Up @@ -184,8 +183,7 @@ export function _composedTreeContains(element, child) {

for (contentIndex = 0; contentIndex < contentElements.length;
++contentIndex) {
distributedNodes =
dom(contentElements[contentIndex]).getDistributedNodes();
distributedNodes = dom(contentElements[contentIndex]).getDistributedNodes();

for (nodeIndex = 0; nodeIndex < distributedNodes.length; ++nodeIndex) {
// Polymer 2.x returns slot.assignedNodes which can contain text nodes.
Expand Down Expand Up @@ -218,7 +216,7 @@ export function _scrollInteractionHandler(event) {
/**
* @private
*/
export { _boundScrollHandler };
export {_boundScrollHandler};

export function _lockScrollInteractions() {
_boundScrollHandler =
Expand All @@ -227,9 +225,7 @@ export function _lockScrollInteractions() {
// NOTE: browsers that don't support objects as third arg will
// interpret it as boolean, hence useCapture = true in this case.
document.addEventListener(
scrollEvents[i],
_boundScrollHandler,
{capture: true, passive: false});
scrollEvents[i], _boundScrollHandler, {capture: true, passive: false});
}
}

Expand All @@ -238,9 +234,7 @@ export function _unlockScrollInteractions() {
// NOTE: browsers that don't support objects as third arg will
// interpret it as boolean, hence useCapture = true in this case.
document.removeEventListener(
scrollEvents[i],
_boundScrollHandler,
{capture: true, passive: false});
scrollEvents[i], _boundScrollHandler, {capture: true, passive: false});
}
}

Expand Down Expand Up @@ -273,8 +267,7 @@ export function _shouldPreventScrolling(event) {
// Get deltaX/Y.
var info = _getScrollInfo(event);
// Prevent if there is no child that can scroll.
return !_getScrollingNode(
lastScrollableNodes, info.deltaX, info.deltaY);
return !_getScrollingNode(lastScrollableNodes, info.deltaX, info.deltaY);
}

/**
Expand Down

0 comments on commit 435ecf1

Please sign in to comment.