1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

switch polymer to bower

This commit is contained in:
Luke Pulverenti 2015-06-19 12:36:51 -04:00
parent b9598ffaa1
commit 8f6cbe8de2
348 changed files with 40895 additions and 310 deletions

View file

@ -0,0 +1,46 @@
{
"name": "paper-dialog-behavior",
"version": "1.0.2",
"description": "Implements a behavior used for material design dialogs",
"authors": "The Polymer Authors",
"keywords": [
"web-components",
"polymer",
"dialog",
"overlay",
"behavior"
],
"main": [
"paper-dialog-behavior.html"
],
"private": true,
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/paper-dialog-behavior"
},
"license": "http://polymer.github.io/LICENSE.txt",
"homepage": "https://github.com/PolymerElements/paper-dialog-behavior",
"ignore": [],
"dependencies": {
"iron-overlay-behavior": "PolymerElements/iron-overlay-behavior#^1.0.0",
"paper-styles": "PolymerElements/paper-styles#^1.0.4",
"polymer": "Polymer/polymer#^1.0.0"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"paper-button": "PolymerElements/paper-button#^1.0.0",
"paper-dialog-scrollable": "PolymerElements/paper-dialog-scrollable#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"web-component-tester": "*",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
},
"_release": "1.0.2",
"_resolution": {
"type": "version",
"tag": "v1.0.2",
"commit": "156945a20318c11bb65d0bc83ef402262c3071ca"
},
"_source": "git://github.com/PolymerElements/paper-dialog-behavior.git",
"_target": "^1.0.0",
"_originalSource": "PolymerElements/paper-dialog-behavior"
}

View file

@ -0,0 +1 @@
bower_components

View file

@ -0,0 +1,37 @@
{
"name": "paper-dialog-behavior",
"version": "1.0.2",
"description": "Implements a behavior used for material design dialogs",
"authors": "The Polymer Authors",
"keywords": [
"web-components",
"polymer",
"dialog",
"overlay",
"behavior"
],
"main": [
"paper-dialog-behavior.html"
],
"private": true,
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/paper-dialog-behavior"
},
"license": "http://polymer.github.io/LICENSE.txt",
"homepage": "https://github.com/PolymerElements/paper-dialog-behavior",
"ignore": [],
"dependencies": {
"iron-overlay-behavior": "PolymerElements/iron-overlay-behavior#^1.0.0",
"paper-styles": "PolymerElements/paper-styles#^1.0.4",
"polymer": "Polymer/polymer#^1.0.0"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"paper-button": "PolymerElements/paper-button#^1.0.0",
"paper-dialog-scrollable": "PolymerElements/paper-dialog-scrollable#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"web-component-tester": "*",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
}
}

View file

@ -0,0 +1,96 @@
<!doctype html>
<!--
@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
-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<title>paper-dialog-behavior demo</title>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="simple-dialog.html">
<link rel="import" href="../../paper-styles/demo-pages.html">
<link rel="import" href="../../paper-button/paper-button.html">
<link rel="import" href="../../paper-dialog-scrollable/paper-dialog-scrollable.html">
<style is="custom-style">
.centered {
text-align: center;
}
</style>
</head>
<body unresolved onclick="clickHandler(event)">
<div class="vertical-section centered">
<button data-dialog="dialog">dialog</button>
<simple-dialog id="dialog">
<h2>Dialog Title</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</simple-dialog>
<button data-dialog="alert">modal alert</button>
<simple-dialog id="alert" modal role="alertdialog">
<h2>Alert</h2>
<p>Discard draft?</p>
<div class="buttons">
<paper-button dialog-dismiss>Cancel</paper-button>
<paper-button dialog-confirm autofocus>Discard</paper-button>
</div>
</simple-dialog>
<button data-dialog="scrolling">scrolling</button>
<simple-dialog id="scrolling">
<h2>Scrolling</h2>
<paper-dialog-scrollable>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</paper-dialog-scrollable>
<div class="buttons">
<paper-button dialog-dismiss>Cancel</paper-button>
<paper-button dialog-confirm>OK</paper-button>
</div>
</simple-dialog>
</div>
<script>
function clickHandler(e) {
if (!e.target.hasAttribute('data-dialog')) {
return;
}
var id = e.target.getAttribute('data-dialog');
var dialog = document.getElementById(id);
if (dialog) {
dialog.toggle();
e.target.toggleAttribute && e.target.toggleAttribute('data-dialog-opened', dialog.opened);
}
}
</script>
</body>
</html>

View file

@ -0,0 +1,42 @@
<!--
@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
-->
<link rel="import" href="../../polymer/polymer.html">
<link rel="import" href="../../paper-styles/paper-styles.html">
<link rel="import" href="../paper-dialog-behavior.html">
<dom-module id="simple-dialog">
<link rel="import" type="css" href="../paper-dialog-common.css">
<template>
<content></content>
</template>
</dom-module>
<script>
(function() {
Polymer({
is: 'simple-dialog',
behaviors: [
Polymer.PaperDialogBehavior
]
});
})();
</script>

View file

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 225 126" enable-background="new 0 0 225 126" xml:space="preserve">
<g id="background" display="none">
<rect display="inline" fill="#B0BEC5" width="225" height="126"/>
</g>
<g id="label">
</g>
<g id="art">
<g>
<polygon points="76.7,98 79.2,98 74,91.1 74,94.4 "/>
<polygon points="74,81.4 74,84.7 84.1,98 86.6,98 "/>
<polygon points="74,71.7 74,75 91.5,98 94,98 "/>
<polygon points="74,62 74,65.3 98.9,98 101.4,98 "/>
<polygon points="94.3,79 92,79 92,76 74,52.3 74,55.6 106.2,98 108.7,98 "/>
<polygon points="92,69.6 92,66.3 74,42.6 74,45.9 "/>
<polygon points="101.7,79 99.2,79 113.6,98 116.1,98 "/>
<polygon points="92,59.9 92,56.6 74,32.9 74,36.2 "/>
<polygon points="109.1,79 106.5,79 121,98 123.5,98 "/>
<polygon points="92,50.2 92,47 92.1,47 77.7,28 75.2,28 "/>
<polygon points="116.4,79 113.9,79 128.4,98 130.9,98 "/>
<polygon points="97,47 99.5,47 85,28 82.5,28 "/>
<polygon points="123.8,79 121.3,79 135.7,98 138.2,98 "/>
<polygon points="104.4,47 106.9,47 92.4,28 89.9,28 "/>
<polygon points="131.2,79 128.7,79 143.1,98 145.6,98 "/>
<polygon points="132,70.4 132,73.7 150,97.4 150,94.1 "/>
<polygon points="111.7,47 114.2,47 99.8,28 97.3,28 "/>
<polygon points="132,60.7 132,64 150,87.7 150,84.3 "/>
<polygon points="119.1,47 121.6,47 107.2,28 104.7,28 "/>
<polygon points="132,51 132,54.3 150,77.9 150,74.6 "/>
<polygon points="114.6,28 112,28 126.5,47 129,47 "/>
<polygon points="121.9,28 119.4,28 150,68.2 150,64.9 "/>
<polygon points="129.3,28 126.8,28 150,58.5 150,55.2 "/>
<polygon points="136.7,28 134.2,28 150,48.8 150,45.5 "/>
<polygon points="144.1,28 141.5,28 150,39.1 150,35.8 "/>
<polygon points="150,29.4 150,28 148.9,28 "/>
</g>
<path d="M133,80H91V46h42V80z M93,78h38V48H93V78z"/>
<path d="M151,99H73V27h78V99z M75,97h74V29H75V97z"/>
<circle cx="74" cy="28" r="4"/>
<circle cx="150" cy="28" r="4"/>
<circle cx="150" cy="98" r="4"/>
<circle cx="74" cy="98" r="4"/>
<g id="ic_x5F_add_x0D_">
</g>
</g>
<g id="Guides">
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -0,0 +1,30 @@
<!doctype html>
<!--
@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
-->
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>paper-dialog-behavior</title>
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-component-page/iron-component-page.html">
</head>
<body>
<iron-component-page></iron-component-page>
</body>
</html>

View file

@ -0,0 +1,237 @@
<!--
@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
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-overlay-behavior/iron-overlay-behavior.html">
<link rel="import" href="../paper-styles/paper-styles.html">
<script>
/**
Use `Polymer.PaperDialogBehavior` and `paper-dialog-common.css` to implement a Material Design
dialog.
For example, if `<paper-dialog-impl>` implements this behavior:
<paper-dialog-impl>
<h2>Header</h2>
<div>Dialog body</div>
<div class="buttons">
<paper-button dialog-dismiss>Cancel</paper-button>
<paper-button dialog-confirm>Accept</paper-button>
</div>
</paper-dialog-impl>
`paper-dialog-common.css` provide styles for a header, content area, and an action area for buttons.
Use the `<h2>` tag for the header and the `buttons` class for the action area. You can use the
`paper-dialog-scrollable` element (in its own repository) if you need a scrolling content area.
Use the `dialog-dismiss` and `dialog-confirm` attributes on interactive controls to close the
dialog. If the user dismisses the dialog with `dialog-confirm`, the `closingReason` will update
to include `confirmed: true`.
### Styling
The following custom properties and mixins are available for styling.
Custom property | Description | Default
----------------|-------------|----------
`--paper-dialog-background-color` | Dialog background color | `--primary-background-color`
`--paper-dialog-color` | Dialog foreground color | `--primary-text-color`
`--paper-dialog` | Mixin applied to the dialog | `{}`
`--paper-dialog-title` | Mixin applied to the title (`<h2>`) element | `{}`
`--paper-dialog-button-color` | Button area foreground color | `--default-primary-color`
### Accessibility
This element has `role="dialog"` by default. Depending on the context, it may be more appropriate
to override this attribute with `role="alertdialog"`. The header (a `<h2>` element) will
If `modal` is set, the element will set `aria-modal` and prevent the focus from exiting the element.
It will also ensure that focus remains in the dialog.
The `aria-labelledby` attribute will be set to the header element, if one exists.
@hero hero.svg
@demo demo/index.html
@polymerBehavior Polymer.PaperDialogBehavior
*/
Polymer.PaperDialogBehaviorImpl = {
hostAttributes: {
'role': 'dialog',
'tabindex': '-1'
},
properties: {
/**
* If `modal` is true, this implies `no-cancel-on-outside-click` and `with-backdrop`.
*/
modal: {
observer: '_modalChanged',
type: Boolean,
value: false
},
/** @type {?Node} */
_lastFocusedElement: {
type: Object
},
_boundOnFocus: {
type: Function,
value: function() {
return this._onFocus.bind(this);
}
},
_boundOnBackdropClick: {
type: Function,
value: function() {
return this._onBackdropClick.bind(this);
}
}
},
listeners: {
'click': '_onDialogClick',
'iron-overlay-opened': '_onIronOverlayOpened',
'iron-overlay-closed': '_onIronOverlayClosed'
},
attached: function() {
this._observer = this._observe(this);
this._updateAriaLabelledBy();
},
detached: function() {
if (this._observer) {
this._observer.disconnect();
}
},
_observe: function(node) {
var observer = new MutationObserver(function() {
this._updateAriaLabelledBy();
}.bind(this));
observer.observe(node, {
childList: true,
subtree: true
});
return observer;
},
_modalChanged: function() {
if (this.modal) {
this.setAttribute('aria-modal', 'true');
} else {
this.setAttribute('aria-modal', 'false');
}
// modal implies noCancelOnOutsideClick and withBackdrop if true, don't overwrite
// those properties otherwise.
if (this.modal) {
this.noCancelOnOutsideClick = true;
this.withBackdrop = true;
}
},
_updateAriaLabelledBy: function() {
var header = Polymer.dom(this).querySelector('h2');
if (!header) {
this.removeAttribute('aria-labelledby');
return;
}
var headerId = header.getAttribute('id');
if (headerId && this.getAttribute('aria-labelledby') === headerId) {
return;
}
// set aria-describedBy to the header element
var labelledById;
if (headerId) {
labelledById = headerId;
} else {
labelledById = 'paper-dialog-header-' + new Date().getUTCMilliseconds();
header.setAttribute('id', labelledById);
}
this.setAttribute('aria-labelledby', labelledById);
},
_updateClosingReasonConfirmed: function(confirmed) {
this.closingReason = this.closingReason || {};
this.closingReason.confirmed = confirmed;
},
_onDialogClick: function(event) {
var target = event.target;
while (target !== this) {
if (target.hasAttribute('dialog-dismiss')) {
this._updateClosingReasonConfirmed(false);
this.close();
break;
} else if (target.hasAttribute('dialog-confirm')) {
this._updateClosingReasonConfirmed(true);
this.close();
break;
}
target = target.parentNode;
}
},
_onIronOverlayOpened: function() {
if (this.modal) {
document.body.addEventListener('focus', this._boundOnFocus, true);
this.backdropElement.addEventListener('click', this._boundOnBackdropClick);
}
},
_onIronOverlayClosed: function() {
document.body.removeEventListener('focus', this._boundOnFocus, true);
this.backdropElement.removeEventListener('click', this._boundOnBackdropClick);
},
_onFocus: function(event) {
if (this.modal) {
var target = event.target;
while (target && target !== this && target !== document.body) {
target = target.parentNode;
}
if (target) {
if (target === document.body) {
if (this._lastFocusedElement) {
this._lastFocusedElement.focus();
} else {
this._focusNode.focus();
}
} else {
this._lastFocusedElement = event.target;
}
}
}
},
_onBackdropClick: function() {
if (this.modal) {
if (this._lastFocusedElement) {
this._lastFocusedElement.focus();
} else {
this._focusNode.focus();
}
}
}
};
/** @polymerBehavior */
Polymer.PaperDialogBehavior = [Polymer.IronOverlayBehavior, Polymer.PaperDialogBehaviorImpl];
</script>

View file

@ -0,0 +1,58 @@
/*
@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
*/
:host {
display: block;
margin: 24px 40px;
background: var(--paper-dialog-background-color, --primary-background-color);
color: var(--paper-dialog-color, --primary-text-color);
@apply(--layout-scroll);
@apply(--paper-font-body1);
@apply(--shadow-elevation-16dp);
@apply(--paper-dialog);
}
:host > ::content > * {
margin-top: 20px;
padding: 0 24px;
}
:host > ::content > .no-padding {
padding: 0;
};
:host > ::content > *:first-child {
margin-top: 24px;
}
:host > ::content > *:last-child {
margin-bottom: 24px;
}
:host > ::content h2 {
position: relative;
margin: 0;
@apply(--paper-font-title);
@apply(--paper-dialog-title);
}
:host > ::content .buttons {
position: relative;
padding: 8px 8px 8px 24px;
margin: 0;
color: var(--paper-dialog-button-color, --default-primary-color);
@apply(--layout-horizontal);
@apply(--layout-end-justified);
}

View file

@ -0,0 +1,34 @@
<!doctype html>
<!--
@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
-->
<html>
<head>
<title>paper-dialog tests</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="../../web-component-tester/browser.js"></script>
</head>
<body>
<script>
WCT.loadSuites([
'paper-dialog-behavior.html'
]);
</script>
</body>
</html>

View file

@ -0,0 +1,217 @@
<!doctype html>
<!--
@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
-->
<html>
<head>
<title>paper-dialog-behavior tests</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../test-fixture/test-fixture-mocha.js"></script>
<link rel="import" href="../../test-fixture/test-fixture.html">
<link rel="import" href="test-dialog.html">
</head>
<body>
<test-fixture id="basic">
<template>
<test-dialog>
<p>Dialog</p>
<div class="buttons">
<button dialog-dismiss>dismiss</button>
<button dialog-confirm>confirm</button>
</div>
</test-dialog>
</template>
</test-fixture>
<test-fixture id="modal">
<template>
<test-dialog modal>
<p>Dialog</p>
<div class="buttons">
<button dialog-dismiss>dismiss</button>
<button dialog-confirm autofocus>confirm</button>
</div>
</test-dialog>
</template>
</test-fixture>
<test-fixture id="backdrop">
<template>
<test-dialog with-backdrop>
<p>Dialog</p>
<div class="buttons">
<button dialog-dismiss>dismiss</button>
<button dialog-confirm autofocus>confirm</button>
</div>
</test-dialog>
</template>
</test-fixture>
<test-fixture id="header">
<template>
<test-dialog>
<h2>Dialog</h2>
<div class="buttons">
<button dialog-dismiss>dismiss</button>
<button dialog-confirm autofocus>confirm</button>
</div>
</test-dialog>
</template>
</test-fixture>
<test-fixture id="header-with-id">
<template>
<test-dialog>
<h2 id="header">Dialog</h2>
<div class="buttons">
<button dialog-dismiss>dismiss</button>
<button dialog-confirm autofocus>confirm</button>
</div>
</test-dialog>
</template>
</test-fixture>
<script>
function runAfterOpen(dialog, cb) {
dialog.addEventListener('iron-overlay-opened', function() {
cb();
});
dialog.open();
}
suite('basic', function() {
test('clicking dialog does not cancel the dialog', function(done) {
var dialog = fixture('basic');
runAfterOpen(dialog, function() {
dialog.addEventListener('iron-overlay-closed', function() {
assert('dialog should not close');
});
dialog.click();
setTimeout(function() {
done();
}, 100);
});
});
test('clicking dialog-dismiss button closes the dialog without confirmation', function(done) {
var dialog = fixture('basic');
runAfterOpen(dialog, function() {
dialog.addEventListener('iron-overlay-closed', function(event) {
assert.isFalse(event.detail.canceled, 'dialog is not canceled');
assert.isFalse(event.detail.confirmed, 'dialog is not confirmed');
done();
});
Polymer.dom(dialog).querySelector('[dialog-dismiss]').click();
});
});
test('clicking dialog-confirm button closes the dialog with confirmation', function(done) {
var dialog = fixture('basic');
runAfterOpen(dialog, function() {
dialog.addEventListener('iron-overlay-closed', function(event) {
assert.isFalse(event.detail.canceled, 'dialog is not canceled');
assert.isTrue(event.detail.confirmed, 'dialog is confirmed');
done();
});
Polymer.dom(dialog).querySelector('[dialog-confirm]').click();
});
});
test('with-backdrop works', function() {
var dialog = fixture('backdrop');
runAfterOpen(dialog, function() {
assert.isTrue(dialog.backdropElement.opened, 'backdrop is open');
});
});
test('modal dialog has backdrop', function() {
var dialog = fixture('modal');
assert.isTrue(dialog.withBackdrop, 'withBackdrop is true');
});
test('modal dialog has no-cancel-on-outside-click', function() {
var dialog = fixture('modal');
assert.isTrue(dialog.noCancelOnOutsideClick, 'noCancelOnOutsideClick is true');
});
test('clicking outside a modal dialog does not move focus from dialog', function(done) {
var dialog = fixture('modal');
runAfterOpen(dialog, function() {
dialog.backdropElement.click();
setTimeout(function() {
assert.equal(document.activeElement, Polymer.dom(dialog).querySelector('[autofocus]'), 'document.activeElement is the autofocused button');
done();
}, 10);
});
});
});
suite('a11y', function() {
test('dialog has role="dialog"', function() {
var dialog = fixture('basic');
assert.equal(dialog.getAttribute('role'), 'dialog', 'has role="dialog"');
});
test('dialog has aria-modal=false', function() {
var dialog = fixture('basic');
assert.equal(dialog.getAttribute('aria-modal'), 'false', 'has aria-modal="false"');
});
test('modal dialog has aria-modal=true', function() {
var dialog = fixture('modal');
assert.equal(dialog.getAttribute('aria-modal'), 'true', 'has aria-modal="true"');
});
test('dialog with header has aria-labelledby', function() {
var dialog = fixture('header');
var header = Polymer.dom(dialog).querySelector('h2');
assert.ok(header.getAttribute('id'), 'header has auto-generated id');
assert.equal(dialog.getAttribute('aria-labelledby'), header.getAttribute('id'), 'aria-labelledby is set to header id');
});
test('dialog with lazily created header has aria-labelledby', function(done) {
var dialog = fixture('basic');
var header = document.createElement('h2');
Polymer.dom(dialog).appendChild(header);
Polymer.dom.flush();
setTimeout(function() {
assert.ok(header.getAttribute('id'), 'header has auto-generated id');
assert.equal(dialog.getAttribute('aria-labelledby'), header.getAttribute('id'), 'aria-labelledby is set to header id');
done();
}, 10);
});
test('dialog with header with id preserves id and has aria-labelledby', function() {
var dialog = fixture('header-with-id');
var header = Polymer.dom(dialog).querySelector('h2');
assert.equal(header.getAttribute('id'), 'header', 'header has preset id');
assert.equal(dialog.getAttribute('aria-labelledby'), 'header', 'aria-labelledby is set to header id');
});
});
</script>
</body>
</html>

View file

@ -0,0 +1,42 @@
<!--
@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
-->
<link rel="import" href="../../polymer/polymer.html">
<link rel="import" href="../../paper-styles/paper-styles.html">
<link rel="import" href="../paper-dialog-behavior.html">
<dom-module id="test-dialog">
<link rel="import" type="css" href="../paper-dialog-common.css">
<template>
<content></content>
</template>
</dom-module>
<script>
(function() {
Polymer({
is: 'test-dialog',
behaviors: [
Polymer.PaperDialogBehavior
]
});
})();
</script>