commit
ef829a6235
177 changed files with 178 additions and 49069 deletions
|
@ -15,7 +15,7 @@
|
|||
</li>
|
||||
<li>
|
||||
<paper-input id="txtWatchFolder" label="${LabelWatchFolder}" style="width:85%;display:inline-block;"></paper-input>
|
||||
<paper-icon-button id="btnSelectWatchFolder" icon="search"></paper-icon-button>
|
||||
<button type="button" is="paper-icon-button-light" id="btnSelectWatchFolder" title="${ButtonSelectDirectory}"><iron-icon icon="search"></iron-icon></button>
|
||||
<div class="fieldDescription">
|
||||
<div>${LabelWatchFolderHelp}</div>
|
||||
</div>
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
{
|
||||
"name": "alameda",
|
||||
"version": "1.0.0",
|
||||
"ignore": [
|
||||
".gitignore",
|
||||
".npmignore",
|
||||
"node_modules",
|
||||
"package.json",
|
||||
"README.md",
|
||||
"tests",
|
||||
"tests-requirejs",
|
||||
"copyrequirejstests.sh",
|
||||
"testBaseUrl.js"
|
||||
],
|
||||
"homepage": "https://github.com/requirejs/alameda",
|
||||
"authors": [
|
||||
"jrburke.com"
|
||||
],
|
||||
"description": "AMD loader, like requirejs, but with promises and for modern browsers",
|
||||
"main": "alameda.js",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"_release": "1.0.0",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "1.0.0",
|
||||
"commit": "f09e80862f0e40b4018531f360f5336c5ca8eaa2"
|
||||
},
|
||||
"_source": "git://github.com/requirejs/alameda.git",
|
||||
"_target": "^1.0.0",
|
||||
"_originalSource": "alameda",
|
||||
"_direct": true
|
||||
}
|
45
dashboard-ui/bower_components/alameda/LICENSE
vendored
45
dashboard-ui/bower_components/alameda/LICENSE
vendored
|
@ -1,45 +0,0 @@
|
|||
Copyright jQuery Foundation and other contributors, https://jquery.org/
|
||||
|
||||
This software consists of voluntary contributions made by many
|
||||
individuals. For exact contribution history, see the revision history
|
||||
available at https://github.com/requirejs/alameda
|
||||
|
||||
The following license applies to all parts of this software except as
|
||||
documented below:
|
||||
|
||||
====
|
||||
|
||||
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.
|
||||
|
||||
====
|
||||
|
||||
Copyright and related rights for sample code are waived via CC0. Sample
|
||||
code is defined as all source code displayed within the prose of the
|
||||
documentation.
|
||||
|
||||
CC0: http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
====
|
||||
|
||||
Files located in the node_modules directory, and certain utilities used
|
||||
to build or test the software in the tests and tests-requirejs directories, are
|
||||
externally maintained libraries used by this software which have their own
|
||||
licenses; we recommend you read them, as their terms may differ from the
|
||||
terms above.
|
1253
dashboard-ui/bower_components/alameda/alameda.js
vendored
1253
dashboard-ui/bower_components/alameda/alameda.js
vendored
File diff suppressed because it is too large
Load diff
24
dashboard-ui/bower_components/alameda/bower.json
vendored
24
dashboard-ui/bower_components/alameda/bower.json
vendored
|
@ -1,24 +0,0 @@
|
|||
{
|
||||
"name": "alameda",
|
||||
"version": "1.0.0",
|
||||
"ignore": [
|
||||
".gitignore",
|
||||
".npmignore",
|
||||
"node_modules",
|
||||
"package.json",
|
||||
"README.md",
|
||||
"tests",
|
||||
"tests-requirejs",
|
||||
"copyrequirejstests.sh",
|
||||
"testBaseUrl.js"
|
||||
],
|
||||
"homepage": "https://github.com/requirejs/alameda",
|
||||
"authors": [
|
||||
"jrburke.com"
|
||||
],
|
||||
"description": "AMD loader, like requirejs, but with promises and for modern browsers",
|
||||
"main": "alameda.js",
|
||||
"license": [
|
||||
"MIT"
|
||||
]
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
rm alameda.min.js.gz
|
||||
ls -la alameda.js
|
||||
uglifyjs -c -m -o alameda.min.js alameda.js
|
||||
ls -la alameda.min.js
|
||||
gzip alameda.min.js
|
||||
ls -la alameda.min.js.gz
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
<script>
|
||||
|
||||
require(['imageFetcher'], function (imageFetcher) {
|
||||
window.ImageFetcherLazyloadImage = imageFetcher;
|
||||
});
|
||||
|
||||
/**
|
||||
* <lazyload-image>
|
||||
* HTMLImageElement extension for lazy loading.
|
||||
* http://github.com/1000ch/lazyload-image
|
||||
*
|
||||
* Copyright 1000ch
|
||||
* licensed under the MIT license.
|
||||
*/
|
||||
window.LazyloadImage = (function () {
|
||||
'use strict';
|
||||
|
||||
var FALLBACK_IMAGE = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAEElEQVR42gEFAPr/AP///wAI/AL+Sr4t6gAAAABJRU5ErkJggg==';
|
||||
|
||||
// create prototype from HTMLImageElement
|
||||
var LazyloadImagePrototype = Object.create(HTMLImageElement.prototype);
|
||||
|
||||
// lifecycle callbacks
|
||||
//LazyloadImagePrototype.createdCallback = function () {
|
||||
|
||||
//};
|
||||
|
||||
//LazyloadImagePrototype.attachedCallback = function () {
|
||||
|
||||
// var original = this.currentSrc || this.src;
|
||||
|
||||
// if (original && window.ImageFetcherLazyloadImage) {
|
||||
// //console.log(original);
|
||||
// this.src = FALLBACK_IMAGE;
|
||||
// console.log('loading ' + original);
|
||||
// ImageFetcherLazyloadImage.loadImage(this, original);
|
||||
// }
|
||||
//};
|
||||
|
||||
return document.registerElement('lazyload-image', {
|
||||
prototype: LazyloadImagePrototype,
|
||||
extends: 'img'
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
|
@ -29,14 +29,14 @@
|
|||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
},
|
||||
"ignore": [],
|
||||
"homepage": "https://github.com/polymerelements/iron-behaviors",
|
||||
"homepage": "https://github.com/PolymerElements/iron-behaviors",
|
||||
"_release": "1.0.15",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.0.15",
|
||||
"commit": "f91583bfae24235401a21a1d67bde8cacce13030"
|
||||
},
|
||||
"_source": "git://github.com/polymerelements/iron-behaviors.git",
|
||||
"_source": "git://github.com/PolymerElements/iron-behaviors.git",
|
||||
"_target": "^1.0.0",
|
||||
"_originalSource": "polymerelements/iron-behaviors"
|
||||
"_originalSource": "PolymerElements/iron-behaviors"
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
{
|
||||
"name": "iron-dropdown",
|
||||
"version": "1.4.0",
|
||||
"description": "An unstyled element that works similarly to a native browser select",
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
],
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"web-component",
|
||||
"polymer"
|
||||
],
|
||||
"main": "iron-dropdown.html",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/PolymerElements/iron-dropdown"
|
||||
},
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"homepage": "https://github.com/PolymerElements/iron-dropdown",
|
||||
"dependencies": {
|
||||
"polymer": "polymer/polymer#^1.0.0",
|
||||
"iron-behaviors": "polymerelements/iron-behaviors#^1.0.0",
|
||||
"iron-overlay-behavior": "polymerelements/iron-overlay-behavior#^1.0.0",
|
||||
"iron-resizable-behavior": "polymerelements/iron-resizable-behavior#^1.0.0",
|
||||
"neon-animation": "polymerelements/neon-animation#^1.0.0",
|
||||
"iron-a11y-keys-behavior": "polymerelements/iron-a11y-keys-behavior#^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"iron-component-page": "polymerelements/iron-component-page#^1.0.0",
|
||||
"test-fixture": "polymerelements/test-fixture#^1.0.0",
|
||||
"iron-test-helpers": "polymerelements/iron-test-helpers#^1.0.0",
|
||||
"paper-styles": "polymerelements/paper-styles#^1.0.0",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0",
|
||||
"web-component-tester": "^4.0.0",
|
||||
"iron-image": "polymerelements/iron-image#^1.0.0"
|
||||
},
|
||||
"ignore": [],
|
||||
"_release": "1.4.0",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.4.0",
|
||||
"commit": "8e14da0aaeb791983ee4b254890c7263644f7851"
|
||||
},
|
||||
"_source": "git://github.com/PolymerElements/iron-dropdown.git",
|
||||
"_target": "^1.0.0",
|
||||
"_originalSource": "PolymerElements/iron-dropdown"
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<!-- Instructions: https://github.com/PolymerElements/iron-dropdown/CONTRIBUTING.md#filing-issues -->
|
||||
### Description
|
||||
<!-- Example: The `paper-foo` element causes the page to turn pink when clicked. -->
|
||||
|
||||
### Expected outcome
|
||||
|
||||
<!-- Example: The page stays the same color. -->
|
||||
|
||||
### Actual outcome
|
||||
|
||||
<!-- Example: The page turns pink. -->
|
||||
|
||||
### Live Demo
|
||||
<!-- Example: https://jsbin.com/cagaye/edit?html,output -->
|
||||
|
||||
### Steps to reproduce
|
||||
|
||||
<!-- Example
|
||||
1. Put a `paper-foo` element in the page.
|
||||
2. Open the page in a web browser.
|
||||
3. Click the `paper-foo` element.
|
||||
-->
|
||||
|
||||
### Browsers Affected
|
||||
<!-- Check all that apply -->
|
||||
- [ ] Chrome
|
||||
- [ ] Firefox
|
||||
- [ ] Safari 9
|
||||
- [ ] Safari 8
|
||||
- [ ] Safari 7
|
||||
- [ ] Edge
|
||||
- [ ] IE 11
|
||||
- [ ] IE 10
|
|
@ -1 +0,0 @@
|
|||
bower_components
|
|
@ -1,23 +0,0 @@
|
|||
language: node_js
|
||||
sudo: required
|
||||
before_script:
|
||||
- npm install -g bower polylint web-component-tester
|
||||
- bower install
|
||||
- polylint
|
||||
env:
|
||||
global:
|
||||
- secure: Nd7sbgkYVekuQRB4K3svNCL3veA6t6aGopNP2FUxlJvQuzRV1vKV67angPvMUAFelEA7/rTzrFPBMfNbsz9C2wInLLLPux4wEk1MQX+2KYZVeXKMHjgl8iQKMXnodaL7XXwBPg0L7053TWtYkIt8wZ/vN0JGPQFKhlQkSrduztkPCJQfkFsMPJ7SudPG3Ld0UPBVxo8TwH/d44p8VhLGiI0oEWw3GnGZZ1T7RJLDAVBwj1BiVHAOaS0SSeOR3ngpZyXbk8OItgzw4o/bbAt2yrHMfwymBy0Xv9v3G0QLFJnMi/gE2lWnN4+IttUPI8gVyr1TuiTgtFxdwteLO3R5iFe+qlQjq0VGssmAHcPwtLhvrT4wEkGMc8ZeyW11z+GdkIw4XHGACWj+9Jz9f19mJd9xU3fkJ+f5mFiB8vEkzjsUI9pswgd3RoHt2WewcVdHnCED2wRdQCw9H34dX7d2ieWKPl/pv+EKZOgEJJ8UNZMyKnj57Y25WRrTpIQBt6p9uVv5MsiZQm7Sd1pYQnJKPQ+BxvvL5fsoT1YkFSjyz9gwijtftXhfL8KLB6i04V3mra3f9d5hc20wAOt+ad+mTOkaM/aGxE/I3Ko13BceMvRSNzuz+N2WE6FEJj1NuOCW/AeSh5/6n9nnlDeu7Nu7VeM9kjk4dyBGNRDWLNcSCEk=
|
||||
- secure: aFsYKL6Sw8/r57wzj3pnzEwBE1mnTajJasHAbXgQMd336S2Sq/f39DCNTXgKBA4AKZGvWKe8w9nzaocQoMa4l9bLWEBJMCMPQFawOhTkuEjsLjpU3g74b46/EhjBP5zixR32xoyF5o9FTzC6UyrDjt2XpKwIQJYxaEfoyIW1vTPdoasWdaG5rXvWFTsmXtaMDpCKFH9aQ1DHn9Sbi9NZlR4izdULsbv9GZwg53xvuH4xYEkGtB29KKy04uK1nJ+9SmRWTAnu4Q/ivYWlbwBArjiYTTi0wclvDNvT1iaFNAaeK2pJea8CnoyJJ0pg9NcuzZtStGUvP00kGUpJQ4lqkr+gBCHDPYtoZ17XCz59cg6LrhG1q//vPi7Yz0xW51GHuwmcVs+PsjmWaRuO/1UFreDCQYf+GU4I1pQZf2q1R4m8noe4i5CcFXLKTrC4udBzPmzVB4As2LsxRc3HCIXmhaMxI8MJwdkQBA22u4vCwU2xpqBawJocj0Gvbeme6wG99PW7+XSkijQDk2cTJ5/CJtY22nAECvn4tve3OVvybSTjQ1yipLxJm/dtjgEXFWtknFZr++tId88wPd3EBtrwEhliD3zD/TyLPO2RPZGuI0i6oD3O89P5d8qp66T/eByDr1IEm0+FIQjgiCEMbhmaIuUKGG2GCfwPglI3uR0kbg0=
|
||||
node_js: stable
|
||||
addons:
|
||||
firefox: latest
|
||||
apt:
|
||||
sources:
|
||||
- google-chrome
|
||||
packages:
|
||||
- google-chrome-stable
|
||||
sauce_connect: true
|
||||
script:
|
||||
- xvfb-run wct
|
||||
- "if [ \"${TRAVIS_PULL_REQUEST}\" = \"false\" ]; then wct -s 'default'; fi"
|
||||
dist: trusty
|
|
@ -1,77 +0,0 @@
|
|||
|
||||
<!--
|
||||
This file is autogenerated based on
|
||||
https://github.com/PolymerElements/ContributionGuide/blob/master/CONTRIBUTING.md
|
||||
|
||||
If you edit that file, it will get updated everywhere else.
|
||||
If you edit this file, your changes will get overridden :)
|
||||
|
||||
You can however override the jsbin link with one that's customized to this
|
||||
specific element:
|
||||
|
||||
jsbin=https://jsbin.com/cagaye/edit?html,output
|
||||
-->
|
||||
# Polymer Elements
|
||||
## Guide for Contributors
|
||||
|
||||
Polymer Elements are built in the open, and the Polymer authors eagerly encourage any and all forms of community contribution. When contributing, please follow these guidelines:
|
||||
|
||||
### Filing Issues
|
||||
|
||||
**If you are filing an issue to request a feature**, please provide a clear description of the feature. It can be helpful to describe answers to the following questions:
|
||||
|
||||
1. **Who will use the feature?** _“As someone filling out a form…”_
|
||||
2. **When will they use the feature?** _“When I enter an invalid value…”_
|
||||
3. **What is the user’s goal?** _“I want to be visually notified that the value needs to be corrected…”_
|
||||
|
||||
**If you are filing an issue to report a bug**, please provide:
|
||||
|
||||
1. **A clear description of the bug and related expectations.** Consider using the following example template for reporting a bug:
|
||||
|
||||
```markdown
|
||||
The `paper-foo` element causes the page to turn pink when clicked.
|
||||
|
||||
## Expected outcome
|
||||
|
||||
The page stays the same color.
|
||||
|
||||
## Actual outcome
|
||||
|
||||
The page turns pink.
|
||||
|
||||
## Steps to reproduce
|
||||
|
||||
1. Put a `paper-foo` element in the page.
|
||||
2. Open the page in a web browser.
|
||||
3. Click the `paper-foo` element.
|
||||
```
|
||||
|
||||
2. **A reduced test case that demonstrates the problem.** If possible, please include the test case as a JSBin. Start with this template to easily import and use relevant Polymer Elements: [https://jsbin.com/cagaye/edit?html,output](https://jsbin.com/cagaye/edit?html,output).
|
||||
|
||||
3. **A list of browsers where the problem occurs.** This can be skipped if the problem is the same across all browsers.
|
||||
|
||||
### Submitting Pull Requests
|
||||
|
||||
**Before creating a pull request**, please ensure that an issue exists for the corresponding change in the pull request that you intend to make. **If an issue does not exist, please create one per the guidelines above**. The goal is to discuss the design and necessity of the proposed change with Polymer authors and community before diving into a pull request.
|
||||
|
||||
When submitting pull requests, please provide:
|
||||
|
||||
1. **A reference to the corresponding issue** or issues that will be closed by the pull request. Please refer to these issues in the pull request description using the following syntax:
|
||||
|
||||
```markdown
|
||||
(For a single issue)
|
||||
Fixes #20
|
||||
|
||||
(For multiple issues)
|
||||
Fixes #32, fixes #40
|
||||
```
|
||||
|
||||
2. **A succinct description of the design** used to fix any related issues. For example:
|
||||
|
||||
```markdown
|
||||
This fixes #20 by removing styles that leaked which would cause the page to turn pink whenever `paper-foo` is clicked.
|
||||
```
|
||||
|
||||
3. **At least one test for each bug fixed or feature added** as part of the pull request. Pull requests that fix bugs or add features without accompanying tests will not be considered.
|
||||
|
||||
If a proposed change contains multiple commits, please [squash commits](https://www.google.com/url?q=http://blog.steveklabnik.com/posts/2012-11-08-how-to-squash-commits-in-a-github-pull-request) to as few as is necessary to succinctly express the change. A Polymer author can help you squash commits, so don’t be afraid to ask us if you need help with that!
|
|
@ -1,39 +0,0 @@
|
|||
{
|
||||
"name": "iron-dropdown",
|
||||
"version": "1.4.0",
|
||||
"description": "An unstyled element that works similarly to a native browser select",
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
],
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"web-component",
|
||||
"polymer"
|
||||
],
|
||||
"main": "iron-dropdown.html",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/PolymerElements/iron-dropdown"
|
||||
},
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"homepage": "https://github.com/PolymerElements/iron-dropdown",
|
||||
"dependencies": {
|
||||
"polymer": "polymer/polymer#^1.0.0",
|
||||
"iron-behaviors": "polymerelements/iron-behaviors#^1.0.0",
|
||||
"iron-overlay-behavior": "polymerelements/iron-overlay-behavior#^1.0.0",
|
||||
"iron-resizable-behavior": "polymerelements/iron-resizable-behavior#^1.0.0",
|
||||
"neon-animation": "polymerelements/neon-animation#^1.0.0",
|
||||
"iron-a11y-keys-behavior": "polymerelements/iron-a11y-keys-behavior#^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"iron-component-page": "polymerelements/iron-component-page#^1.0.0",
|
||||
"test-fixture": "polymerelements/test-fixture#^1.0.0",
|
||||
"iron-test-helpers": "polymerelements/iron-test-helpers#^1.0.0",
|
||||
"paper-styles": "polymerelements/paper-styles#^1.0.0",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0",
|
||||
"web-component-tester": "^4.0.0",
|
||||
"iron-image": "polymerelements/iron-image#^1.0.0"
|
||||
},
|
||||
"ignore": []
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<!--
|
||||
@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="../../neon-animation/neon-animation-behavior.html">
|
||||
|
||||
<script>
|
||||
Polymer({
|
||||
is: 'expand-animation',
|
||||
|
||||
behaviors: [
|
||||
Polymer.NeonAnimationBehavior
|
||||
],
|
||||
|
||||
configure: function(config) {
|
||||
var node = config.node;
|
||||
|
||||
var height = node.getBoundingClientRect().height;
|
||||
|
||||
this._effect = new KeyframeEffect(node, [{
|
||||
height: (height / 2) + 'px'
|
||||
}, {
|
||||
height: height + 'px'
|
||||
}], this.timingFromConfig(config));
|
||||
|
||||
return this._effect;
|
||||
}
|
||||
});
|
||||
</script>
|
|
@ -1,160 +0,0 @@
|
|||
<!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>iron-dropdown</title>
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<link rel="import" href="../../iron-image/iron-image.html">
|
||||
<link rel="import" href="../../paper-styles/demo-pages.html">
|
||||
<link rel="import" href="x-select.html">
|
||||
<style>
|
||||
|
||||
.dropdown-content {
|
||||
background-color: white;
|
||||
line-height: 20px;
|
||||
border-radius: 3px;
|
||||
box-shadow: 0px 2px 6px #ccc;
|
||||
}
|
||||
|
||||
.random-content {
|
||||
padding: 1.5em 2em;
|
||||
max-width: 250px;
|
||||
}
|
||||
|
||||
button {
|
||||
border: 1px solid #ccc;
|
||||
background-color: #eee;
|
||||
padding: 1em;
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button:focus {
|
||||
outline: none;
|
||||
border-color: blue;
|
||||
}
|
||||
|
||||
ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
li {
|
||||
display: block;
|
||||
position: relative;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
display: block;
|
||||
position: relative;
|
||||
padding: 1em;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
li:not(:last-of-type) {
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
iron-image {
|
||||
padding: 1em;
|
||||
background-color: #fff;
|
||||
box-shadow: 0px 2px 6px #ccc;
|
||||
border-radius: 3px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<template is="dom-bind" id="Demo">
|
||||
<div class="vertical-section vertical-section-container ">
|
||||
<h1>iron-dropdown</h1>
|
||||
<p>Examples of vanilla elements.</p>
|
||||
<div>
|
||||
<x-select>
|
||||
<button class="dropdown-trigger">Basic</button>
|
||||
<div class="dropdown-content random-content">
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing 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.
|
||||
</div>
|
||||
</x-select>
|
||||
<x-select>
|
||||
<button class="dropdown-trigger">Overflowing</button>
|
||||
<div class="dropdown-content random-content">
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing 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>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</p>
|
||||
</div>
|
||||
</x-select>
|
||||
<x-select vertical-align="bottom">
|
||||
<button class="dropdown-trigger">Bottom-left Aligned</button>
|
||||
<div class="dropdown-content random-content">
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing 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.
|
||||
</div>
|
||||
</x-select>
|
||||
<x-select horizontal-align="right" vertical-align="top">
|
||||
<button class="dropdown-trigger">Top-right Aligned</button>
|
||||
<div class="dropdown-content random-content">
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing 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.
|
||||
</div>
|
||||
</x-select>
|
||||
<x-select horizontal-align="left" vertical-align="top">
|
||||
<button class="dropdown-trigger"> Content</button>
|
||||
<iron-image class="dropdown-content" src="../../iron-image/demo/polymer.svg"></iron-image>
|
||||
</x-select>
|
||||
<x-select horizontal-align="right" vertical-align="top">
|
||||
<button class="dropdown-trigger">Unordered list</button>
|
||||
<ul class="dropdown-content" tabindex="0">
|
||||
<template is="dom-repeat" items="[[dinosaurs]]">
|
||||
<li><a href="javascript:void(0)">[[item]]</a></li>
|
||||
</template>
|
||||
</ul>
|
||||
</x-select>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
Demo.dinosaurs = [
|
||||
'allosaurus',
|
||||
'brontosaurus',
|
||||
'carcharodontosaurus',
|
||||
'diplodocus',
|
||||
'ekrixinatosaurus',
|
||||
'fukuiraptor',
|
||||
'gallimimus',
|
||||
'hadrosaurus',
|
||||
'iguanodon',
|
||||
'jainosaurus',
|
||||
'kritosaurus',
|
||||
'liaoceratops',
|
||||
'megalosaurus',
|
||||
'nemegtosaurus',
|
||||
'ornithomimus',
|
||||
'protoceratops',
|
||||
'quetecsaurus',
|
||||
'rajasaurus',
|
||||
'stegosaurus',
|
||||
'triceratops',
|
||||
'utahraptor',
|
||||
'vulcanodon',
|
||||
'wannanosaurus',
|
||||
'xenoceratops',
|
||||
'yandusaurus',
|
||||
'zephyrosaurus'
|
||||
];
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,80 +0,0 @@
|
|||
<!--
|
||||
@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="../iron-dropdown.html">
|
||||
<link rel="import" href="../../neon-animation/neon-animations.html">
|
||||
<link rel="import" href="grow-height-animation.html">
|
||||
|
||||
<dom-module id="x-select">
|
||||
<style>
|
||||
:host {
|
||||
display: inline-block;
|
||||
margin: 1em;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div on-tap="open">
|
||||
<content select=".dropdown-trigger"></content>
|
||||
</div>
|
||||
<iron-dropdown id="dropdown"
|
||||
vertical-align="[[verticalAlign]]"
|
||||
horizontal-align="[[horizontalAlign]]"
|
||||
disabled="[[disabled]]"
|
||||
open-animation-config="[[openAnimationConfig]]"
|
||||
close-animation-config="[[closeAnimationConfig]]">
|
||||
<content select=".dropdown-content"></content>
|
||||
</iron-dropdown>
|
||||
</template>
|
||||
<script>
|
||||
Polymer({
|
||||
is: 'x-select',
|
||||
|
||||
properties: {
|
||||
verticalAlign: String,
|
||||
horizontalAlign: String,
|
||||
disabled: Boolean,
|
||||
openAnimationConfig: {
|
||||
type: Array,
|
||||
value: function() {
|
||||
return [{
|
||||
name: 'fade-in-animation',
|
||||
timing: {
|
||||
delay: 150,
|
||||
duration: 50
|
||||
}
|
||||
}, {
|
||||
name: 'expand-animation',
|
||||
timing: {
|
||||
delay: 150,
|
||||
duration: 200
|
||||
}
|
||||
}];
|
||||
}
|
||||
},
|
||||
|
||||
closeAnimationConfig: {
|
||||
type: Array,
|
||||
value: function() {
|
||||
return [{
|
||||
name: 'fade-out-animation',
|
||||
timing: {
|
||||
duration: 200
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
open: function() {
|
||||
this.$.dropdown.open();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</dom-module>
|
|
@ -1,24 +0,0 @@
|
|||
<!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
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
|
||||
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
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<title>iron-dropdown</title>
|
||||
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<link rel="import" href="../iron-component-page/iron-component-page.html">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<iron-component-page></iron-component-page>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,233 +0,0 @@
|
|||
<!--
|
||||
@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-a11y-keys-behavior/iron-a11y-keys-behavior.html">
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* The IronDropdownScrollManager is intended to provide a central source
|
||||
* of authority and control over which elements in a document are currently
|
||||
* allowed to scroll.
|
||||
*/
|
||||
|
||||
Polymer.IronDropdownScrollManager = {
|
||||
|
||||
/**
|
||||
* The current element that defines the DOM boundaries of the
|
||||
* scroll lock. This is always the most recently locking element.
|
||||
*/
|
||||
get currentLockingElement() {
|
||||
return this._lockingElements[this._lockingElements.length - 1];
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the provided element is "scroll locked," which is to
|
||||
* say that it cannot be scrolled via pointer or keyboard interactions.
|
||||
*
|
||||
* @param {HTMLElement} element An HTML element instance which may or may
|
||||
* not be scroll locked.
|
||||
*/
|
||||
elementIsScrollLocked: function(element) {
|
||||
var currentLockingElement = this.currentLockingElement;
|
||||
|
||||
if (currentLockingElement === undefined)
|
||||
return false;
|
||||
|
||||
var scrollLocked;
|
||||
|
||||
if (this._hasCachedLockedElement(element)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this._hasCachedUnlockedElement(element)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
scrollLocked = !!currentLockingElement &&
|
||||
currentLockingElement !== element &&
|
||||
!this._composedTreeContains(currentLockingElement, element);
|
||||
|
||||
if (scrollLocked) {
|
||||
this._lockedElementCache.push(element);
|
||||
} else {
|
||||
this._unlockedElementCache.push(element);
|
||||
}
|
||||
|
||||
return scrollLocked;
|
||||
},
|
||||
|
||||
/**
|
||||
* Push an element onto the current scroll lock stack. The most recently
|
||||
* pushed element and its children will be considered scrollable. All
|
||||
* other elements will not be scrollable.
|
||||
*
|
||||
* Scroll locking is implemented as a stack so that cases such as
|
||||
* dropdowns within dropdowns are handled well.
|
||||
*
|
||||
* @param {HTMLElement} element The element that should lock scroll.
|
||||
*/
|
||||
pushScrollLock: function(element) {
|
||||
// Prevent pushing the same element twice
|
||||
if (this._lockingElements.indexOf(element) >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._lockingElements.length === 0) {
|
||||
this._lockScrollInteractions();
|
||||
}
|
||||
|
||||
this._lockingElements.push(element);
|
||||
|
||||
this._lockedElementCache = [];
|
||||
this._unlockedElementCache = [];
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove an element from the scroll lock stack. The element being
|
||||
* removed does not need to be the most recently pushed element. However,
|
||||
* the scroll lock constraints only change when the most recently pushed
|
||||
* element is removed.
|
||||
*
|
||||
* @param {HTMLElement} element The element to remove from the scroll
|
||||
* lock stack.
|
||||
*/
|
||||
removeScrollLock: function(element) {
|
||||
var index = this._lockingElements.indexOf(element);
|
||||
|
||||
if (index === -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._lockingElements.splice(index, 1);
|
||||
|
||||
this._lockedElementCache = [];
|
||||
this._unlockedElementCache = [];
|
||||
|
||||
if (this._lockingElements.length === 0) {
|
||||
this._unlockScrollInteractions();
|
||||
}
|
||||
},
|
||||
|
||||
_lockingElements: [],
|
||||
|
||||
_lockedElementCache: null,
|
||||
|
||||
_unlockedElementCache: null,
|
||||
|
||||
_originalBodyStyles: {},
|
||||
|
||||
_isScrollingKeypress: function(event) {
|
||||
return Polymer.IronA11yKeysBehavior.keyboardEventMatchesKeys(
|
||||
event, 'pageup pagedown home end up left down right');
|
||||
},
|
||||
|
||||
_hasCachedLockedElement: function(element) {
|
||||
return this._lockedElementCache.indexOf(element) > -1;
|
||||
},
|
||||
|
||||
_hasCachedUnlockedElement: function(element) {
|
||||
return this._unlockedElementCache.indexOf(element) > -1;
|
||||
},
|
||||
|
||||
_composedTreeContains: function(element, child) {
|
||||
// NOTE(cdata): This method iterates over content elements and their
|
||||
// corresponding distributed nodes to implement a contains-like method
|
||||
// that pierces through the composed tree of the ShadowDOM. Results of
|
||||
// this operation are cached (elsewhere) on a per-scroll-lock basis, to
|
||||
// guard against potentially expensive lookups happening repeatedly as
|
||||
// a user scrolls / touchmoves.
|
||||
var contentElements;
|
||||
var distributedNodes;
|
||||
var contentIndex;
|
||||
var nodeIndex;
|
||||
|
||||
if (element.contains(child)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
contentElements = Polymer.dom(element).querySelectorAll('content');
|
||||
|
||||
for (contentIndex = 0; contentIndex < contentElements.length; ++contentIndex) {
|
||||
|
||||
distributedNodes = Polymer.dom(contentElements[contentIndex]).getDistributedNodes();
|
||||
|
||||
for (nodeIndex = 0; nodeIndex < distributedNodes.length; ++nodeIndex) {
|
||||
|
||||
if (this._composedTreeContains(distributedNodes[nodeIndex], child)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
_scrollInteractionHandler: function(event) {
|
||||
var scrolledElement =
|
||||
/** @type {HTMLElement} */(Polymer.dom(event).rootTarget);
|
||||
if (Polymer
|
||||
.IronDropdownScrollManager
|
||||
.elementIsScrollLocked(scrolledElement)) {
|
||||
if (event.type === 'keydown' &&
|
||||
!Polymer.IronDropdownScrollManager._isScrollingKeypress(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
},
|
||||
|
||||
_lockScrollInteractions: function() {
|
||||
// Memoize body inline styles:
|
||||
this._originalBodyStyles.overflow = document.body.style.overflow;
|
||||
this._originalBodyStyles.overflowX = document.body.style.overflowX;
|
||||
this._originalBodyStyles.overflowY = document.body.style.overflowY;
|
||||
|
||||
// Disable overflow scrolling on body:
|
||||
// TODO(cdata): It is technically not sufficient to hide overflow on
|
||||
// body alone. A better solution might be to traverse all ancestors of
|
||||
// the current scroll locking element and hide overflow on them. This
|
||||
// becomes expensive, though, as it would have to be redone every time
|
||||
// a new scroll locking element is added.
|
||||
document.body.style.overflow = 'hidden';
|
||||
document.body.style.overflowX = 'hidden';
|
||||
document.body.style.overflowY = 'hidden';
|
||||
|
||||
// Modern `wheel` event for mouse wheel scrolling:
|
||||
document.addEventListener('wheel', this._scrollInteractionHandler, true);
|
||||
// Older, non-standard `mousewheel` event for some FF:
|
||||
document.addEventListener('mousewheel', this._scrollInteractionHandler, true);
|
||||
// IE:
|
||||
document.addEventListener('DOMMouseScroll', this._scrollInteractionHandler, true);
|
||||
// Mobile devices can scroll on touch move:
|
||||
document.addEventListener('touchmove', this._scrollInteractionHandler, true);
|
||||
// Capture keydown to prevent scrolling keys (pageup, pagedown etc.)
|
||||
document.addEventListener('keydown', this._scrollInteractionHandler, true);
|
||||
},
|
||||
|
||||
_unlockScrollInteractions: function() {
|
||||
document.body.style.overflow = this._originalBodyStyles.overflow;
|
||||
document.body.style.overflowX = this._originalBodyStyles.overflowX;
|
||||
document.body.style.overflowY = this._originalBodyStyles.overflowY;
|
||||
|
||||
document.removeEventListener('wheel', this._scrollInteractionHandler, true);
|
||||
document.removeEventListener('mousewheel', this._scrollInteractionHandler, true);
|
||||
document.removeEventListener('DOMMouseScroll', this._scrollInteractionHandler, true);
|
||||
document.removeEventListener('touchmove', this._scrollInteractionHandler, true);
|
||||
document.removeEventListener('keydown', this._scrollInteractionHandler, true);
|
||||
}
|
||||
};
|
||||
})();
|
||||
</script>
|
|
@ -1,316 +0,0 @@
|
|||
<!--
|
||||
@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-resizable-behavior/iron-resizable-behavior.html">
|
||||
<link rel="import" href="../iron-a11y-keys-behavior/iron-a11y-keys-behavior.html">
|
||||
<link rel="import" href="../iron-behaviors/iron-control-state.html">
|
||||
<link rel="import" href="../iron-overlay-behavior/iron-overlay-behavior.html">
|
||||
<link rel="import" href="../neon-animation/neon-animation-runner-behavior.html">
|
||||
<link rel="import" href="../neon-animation/animations/opaque-animation.html">
|
||||
<link rel="import" href="iron-dropdown-scroll-manager.html">
|
||||
|
||||
<!--
|
||||
`<iron-dropdown>` is a generalized element that is useful when you have
|
||||
hidden content (`.dropdown-content`) that is revealed due to some change in
|
||||
state that should cause it to do so.
|
||||
|
||||
Note that this is a low-level element intended to be used as part of other
|
||||
composite elements that cause dropdowns to be revealed.
|
||||
|
||||
Examples of elements that might be implemented using an `iron-dropdown`
|
||||
include comboboxes, menubuttons, selects. The list goes on.
|
||||
|
||||
The `<iron-dropdown>` element exposes attributes that allow the position
|
||||
of the `.dropdown-content` relative to the `.dropdown-trigger` to be
|
||||
configured.
|
||||
|
||||
<iron-dropdown horizontal-align="right" vertical-align="top">
|
||||
<div class="dropdown-content">Hello!</div>
|
||||
</iron-dropdown>
|
||||
|
||||
In the above example, the `<div>` with class `.dropdown-content` will be
|
||||
hidden until the dropdown element has `opened` set to true, or when the `open`
|
||||
method is called on the element.
|
||||
|
||||
@demo demo/index.html
|
||||
-->
|
||||
|
||||
<dom-module id="iron-dropdown">
|
||||
<style>
|
||||
:host {
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
#contentWrapper ::content > * {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#contentWrapper.animating ::content > * {
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div id="contentWrapper">
|
||||
<content id="content" select=".dropdown-content"></content>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
Polymer({
|
||||
is: 'iron-dropdown',
|
||||
|
||||
behaviors: [
|
||||
Polymer.IronControlState,
|
||||
Polymer.IronA11yKeysBehavior,
|
||||
Polymer.IronOverlayBehavior,
|
||||
Polymer.NeonAnimationRunnerBehavior
|
||||
],
|
||||
|
||||
properties: {
|
||||
/**
|
||||
* The orientation against which to align the dropdown content
|
||||
* horizontally relative to the dropdown trigger.
|
||||
* Overridden from `Polymer.IronFitBehavior`.
|
||||
*/
|
||||
horizontalAlign: {
|
||||
type: String,
|
||||
value: 'left',
|
||||
reflectToAttribute: true
|
||||
},
|
||||
|
||||
/**
|
||||
* The orientation against which to align the dropdown content
|
||||
* vertically relative to the dropdown trigger.
|
||||
* Overridden from `Polymer.IronFitBehavior`.
|
||||
*/
|
||||
verticalAlign: {
|
||||
type: String,
|
||||
value: 'top',
|
||||
reflectToAttribute: true
|
||||
},
|
||||
|
||||
/**
|
||||
* An animation config. If provided, this will be used to animate the
|
||||
* opening of the dropdown.
|
||||
*/
|
||||
openAnimationConfig: {
|
||||
type: Object
|
||||
},
|
||||
|
||||
/**
|
||||
* An animation config. If provided, this will be used to animate the
|
||||
* closing of the dropdown.
|
||||
*/
|
||||
closeAnimationConfig: {
|
||||
type: Object
|
||||
},
|
||||
|
||||
/**
|
||||
* If provided, this will be the element that will be focused when
|
||||
* the dropdown opens.
|
||||
*/
|
||||
focusTarget: {
|
||||
type: Object
|
||||
},
|
||||
|
||||
/**
|
||||
* Set to true to disable animations when opening and closing the
|
||||
* dropdown.
|
||||
*/
|
||||
noAnimations: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
|
||||
/**
|
||||
* By default, the dropdown will constrain scrolling on the page
|
||||
* to itself when opened.
|
||||
* Set to true in order to prevent scroll from being constrained
|
||||
* to the dropdown when it opens.
|
||||
*/
|
||||
allowOutsideScroll: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
}
|
||||
},
|
||||
|
||||
listeners: {
|
||||
'neon-animation-finish': '_onNeonAnimationFinish'
|
||||
},
|
||||
|
||||
observers: [
|
||||
'_updateOverlayPosition(positionTarget, verticalAlign, horizontalAlign, verticalOffset, horizontalOffset)'
|
||||
],
|
||||
|
||||
/**
|
||||
* The element that is contained by the dropdown, if any.
|
||||
*/
|
||||
get containedElement() {
|
||||
return Polymer.dom(this.$.content).getDistributedNodes()[0];
|
||||
},
|
||||
|
||||
/**
|
||||
* The element that should be focused when the dropdown opens.
|
||||
* @deprecated
|
||||
*/
|
||||
get _focusTarget() {
|
||||
return this.focusTarget || this.containedElement;
|
||||
},
|
||||
|
||||
/**
|
||||
* Called when the value of `opened` changes.
|
||||
* Overridden from `IronOverlayBehavior`
|
||||
*/
|
||||
_openedChanged: function() {
|
||||
if (this.opened && this.disabled) {
|
||||
this.cancel();
|
||||
} else {
|
||||
this.cancelAnimation();
|
||||
this.sizingTarget = this.containedElement || this.sizingTarget;
|
||||
this._updateAnimationConfig();
|
||||
if (this.opened && !this.allowOutsideScroll) {
|
||||
Polymer.IronDropdownScrollManager.pushScrollLock(this);
|
||||
} else {
|
||||
Polymer.IronDropdownScrollManager.removeScrollLock(this);
|
||||
}
|
||||
Polymer.IronOverlayBehaviorImpl._openedChanged.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Overridden from `IronOverlayBehavior`.
|
||||
*/
|
||||
_renderOpened: function() {
|
||||
if (!this.noAnimations && this.animationConfig && this.animationConfig.open) {
|
||||
if (this.withBackdrop) {
|
||||
this.backdropElement.open();
|
||||
}
|
||||
this.$.contentWrapper.classList.add('animating');
|
||||
this.playAnimation('open');
|
||||
} else {
|
||||
Polymer.IronOverlayBehaviorImpl._renderOpened.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Overridden from `IronOverlayBehavior`.
|
||||
*/
|
||||
_renderClosed: function() {
|
||||
if (!this.noAnimations && this.animationConfig && this.animationConfig.close) {
|
||||
if (this.withBackdrop) {
|
||||
this.backdropElement.close();
|
||||
}
|
||||
this.$.contentWrapper.classList.add('animating');
|
||||
this.playAnimation('close');
|
||||
} else {
|
||||
Polymer.IronOverlayBehaviorImpl._renderClosed.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Called when animation finishes on the dropdown (when opening or
|
||||
* closing). Responsible for "completing" the process of opening or
|
||||
* closing the dropdown by positioning it or setting its display to
|
||||
* none.
|
||||
*/
|
||||
_onNeonAnimationFinish: function() {
|
||||
this.$.contentWrapper.classList.remove('animating');
|
||||
if (this.opened) {
|
||||
Polymer.IronOverlayBehaviorImpl._finishRenderOpened.apply(this);
|
||||
} else {
|
||||
Polymer.IronOverlayBehaviorImpl._finishRenderClosed.apply(this);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Constructs the final animation config from different properties used
|
||||
* to configure specific parts of the opening and closing animations.
|
||||
*/
|
||||
_updateAnimationConfig: function() {
|
||||
var animationConfig = {};
|
||||
var animations = [];
|
||||
|
||||
if (this.openAnimationConfig) {
|
||||
// NOTE(cdata): When making `display:none` elements visible in Safari,
|
||||
// the element will paint once in a fully visible state, causing the
|
||||
// dropdown to flash before it fades in. We prepend an
|
||||
// `opaque-animation` to fix this problem:
|
||||
animationConfig.open = [{
|
||||
name: 'opaque-animation',
|
||||
}].concat(this.openAnimationConfig);
|
||||
animations = animations.concat(animationConfig.open);
|
||||
}
|
||||
|
||||
if (this.closeAnimationConfig) {
|
||||
animationConfig.close = this.closeAnimationConfig;
|
||||
animations = animations.concat(animationConfig.close);
|
||||
}
|
||||
|
||||
animations.forEach(function(animation) {
|
||||
animation.node = this.containedElement;
|
||||
}, this);
|
||||
|
||||
this.animationConfig = animationConfig;
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the overlay position based on configured horizontal
|
||||
* and vertical alignment.
|
||||
*/
|
||||
_updateOverlayPosition: function() {
|
||||
if (this.isAttached) {
|
||||
// This triggers iron-resize, and iron-overlay-behavior will call refit if needed.
|
||||
this.notifyResize();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Useful to call this after the element, the window, or the `fitInfo`
|
||||
* element has been resized. Will maintain the scroll position.
|
||||
*/
|
||||
refit: function () {
|
||||
if (!this.opened) {
|
||||
return
|
||||
}
|
||||
var containedElement = this.containedElement;
|
||||
var scrollTop;
|
||||
var scrollLeft;
|
||||
|
||||
if (containedElement) {
|
||||
scrollTop = containedElement.scrollTop;
|
||||
scrollLeft = containedElement.scrollLeft;
|
||||
}
|
||||
Polymer.IronFitBehavior.refit.apply(this, arguments);
|
||||
|
||||
if (containedElement) {
|
||||
containedElement.scrollTop = scrollTop;
|
||||
containedElement.scrollLeft = scrollLeft;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Apply focus to focusTarget or containedElement
|
||||
*/
|
||||
_applyFocus: function () {
|
||||
var focusTarget = this.focusTarget || this.containedElement;
|
||||
if (focusTarget && this.opened && !this.noAutoFocus) {
|
||||
focusTarget.focus();
|
||||
} else {
|
||||
Polymer.IronOverlayBehaviorImpl._applyFocus.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</dom-module>
|
|
@ -1,28 +0,0 @@
|
|||
<!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>iron-dropdown tests</title>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
WCT.loadSuites([
|
||||
'iron-dropdown.html',
|
||||
'iron-dropdown-scroll-manager.html',
|
||||
'iron-dropdown.html?dom=shadow',
|
||||
'iron-dropdown-scroll-manager.html?dom=shadow'
|
||||
]);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,152 +0,0 @@
|
|||
<!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">
|
||||
<title>iron-dropdown-scroll-manager tests</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
<script src="../../test-fixture/test-fixture-mocha.js"></script>
|
||||
<script src="../../iron-test-helpers/mock-interactions.js"></script>
|
||||
|
||||
<link rel="import" href="../iron-dropdown-scroll-manager.html">
|
||||
<link rel="import" href="../../test-fixture/test-fixture.html">
|
||||
<link rel="import" href="x-scrollable-element.html">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<test-fixture id="DOMSubtree">
|
||||
<template>
|
||||
<x-scrollable-element id="Parent"></x-scrollable-element>
|
||||
</template>
|
||||
</test-fixture>
|
||||
<script>
|
||||
suite('IronDropdownScrollManager', function() {
|
||||
var parent;
|
||||
var childOne;
|
||||
var childTwo;
|
||||
var grandchildOne;
|
||||
var grandchildTwo;
|
||||
var ancestor;
|
||||
|
||||
setup(function() {
|
||||
parent = fixture('DOMSubtree');
|
||||
childOne = parent.$$('#ChildOne');
|
||||
childTwo = parent.$$('#ChildTwo');
|
||||
grandChildOne = parent.$$('#GrandchildOne');
|
||||
grandChildTwo = parent.$$('#GrandchildTwo');
|
||||
ancestor = document.body;
|
||||
});
|
||||
|
||||
suite('constraining scroll in the DOM', function() {
|
||||
setup(function() {
|
||||
Polymer.IronDropdownScrollManager.pushScrollLock(childOne);
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
Polymer.IronDropdownScrollManager.removeScrollLock(childOne);
|
||||
});
|
||||
|
||||
test('recognizes sibling as locked', function() {
|
||||
expect(Polymer.IronDropdownScrollManager.elementIsScrollLocked(childTwo))
|
||||
.to.be.equal(true);
|
||||
});
|
||||
|
||||
test('recognizes neice as locked', function() {
|
||||
expect(Polymer.IronDropdownScrollManager.elementIsScrollLocked(grandChildTwo))
|
||||
.to.be.equal(true);
|
||||
});
|
||||
|
||||
test('recognizes parent as locked', function() {
|
||||
expect(Polymer.IronDropdownScrollManager.elementIsScrollLocked(parent))
|
||||
.to.be.equal(true);
|
||||
});
|
||||
|
||||
test('recognizes ancestor as locked', function() {
|
||||
expect(Polymer.IronDropdownScrollManager.elementIsScrollLocked(ancestor))
|
||||
.to.be.equal(true);
|
||||
});
|
||||
|
||||
test('recognizes locking child as unlocked', function() {
|
||||
expect(Polymer.IronDropdownScrollManager.elementIsScrollLocked(childOne))
|
||||
.to.be.equal(false);
|
||||
});
|
||||
|
||||
test('recognizes descendant of locking child as unlocked', function() {
|
||||
expect(Polymer.IronDropdownScrollManager.elementIsScrollLocked(grandChildOne))
|
||||
.to.be.equal(false);
|
||||
});
|
||||
|
||||
test('unlocks locked elements when there are no locking elements', function() {
|
||||
Polymer.IronDropdownScrollManager.removeScrollLock(childOne);
|
||||
|
||||
expect(Polymer.IronDropdownScrollManager.elementIsScrollLocked(parent))
|
||||
.to.be.equal(false);
|
||||
});
|
||||
|
||||
test('does not check locked elements when there are no locking elements', function() {
|
||||
sinon.spy(Polymer.IronDropdownScrollManager, 'elementIsScrollLocked');
|
||||
childOne.dispatchEvent(new CustomEvent('wheel', {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
}));
|
||||
expect(Polymer.IronDropdownScrollManager
|
||||
.elementIsScrollLocked.callCount).to.be.eql(1);
|
||||
Polymer.IronDropdownScrollManager.removeScrollLock(childOne);
|
||||
childOne.dispatchEvent(new CustomEvent('wheel', {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
}));
|
||||
expect(Polymer.IronDropdownScrollManager
|
||||
.elementIsScrollLocked.callCount).to.be.eql(1);
|
||||
});
|
||||
|
||||
suite('various scroll events', function() {
|
||||
var scrollEvents;
|
||||
var events;
|
||||
|
||||
setup(function() {
|
||||
scrollEvents = [
|
||||
'wheel',
|
||||
'mousewheel',
|
||||
'DOMMouseScroll',
|
||||
'touchmove'
|
||||
];
|
||||
|
||||
events = scrollEvents.map(function(scrollEvent) {
|
||||
return new CustomEvent(scrollEvent, {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('prevents wheel events from locked elements', function() {
|
||||
events.forEach(function(event) {
|
||||
childTwo.dispatchEvent(event);
|
||||
expect(event.defaultPrevented).to.be.eql(true);
|
||||
});
|
||||
});
|
||||
|
||||
test('allows wheel events from unlocked elements', function() {
|
||||
events.forEach(function(event) {
|
||||
childOne.dispatchEvent(event);
|
||||
expect(event.defaultPrevented).to.be.eql(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,416 +0,0 @@
|
|||
<!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">
|
||||
<title>iron-dropdown basic tests</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
<script src="../../test-fixture/test-fixture-mocha.js"></script>
|
||||
<script src="../../iron-test-helpers/mock-interactions.js"></script>
|
||||
|
||||
<link rel="import" href="../iron-dropdown.html">
|
||||
<link rel="import" href="../../test-fixture/test-fixture.html">
|
||||
|
||||
</head>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: block;
|
||||
position: relative;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
.positioned {
|
||||
position: absolute;
|
||||
top: 40px;
|
||||
left: 40px;
|
||||
}
|
||||
|
||||
.dropdown-content {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
background-color: orange;
|
||||
}
|
||||
|
||||
.big {
|
||||
width: 3000px;
|
||||
height: 3000px;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
|
||||
<test-fixture id="TrivialDropdown">
|
||||
<template>
|
||||
<iron-dropdown>
|
||||
<div class="dropdown-content"></div>
|
||||
</iron-dropdown>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="NonLockingDropdown">
|
||||
<template>
|
||||
<iron-dropdown allow-outside-scroll>
|
||||
<div class="dropdown-content">I don't lock scroll!</div>
|
||||
</iron-dropdown>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="AlignedDropdown">
|
||||
<template>
|
||||
<div class="container">
|
||||
<iron-dropdown horizontal-align="right" vertical-align="top">
|
||||
<div class="dropdown-content big"></div>
|
||||
</iron-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<!-- Absolutely position the dropdown so that it has enough space to move around -->
|
||||
<test-fixture id="OffsetDropdownTopLeft">
|
||||
<template>
|
||||
<div class="container positioned">
|
||||
<iron-dropdown>
|
||||
<div class="dropdown-content"></div>
|
||||
</iron-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="OffsetDropdownBottomRight">
|
||||
<template>
|
||||
<div class="container positioned">
|
||||
<iron-dropdown horizontal-align="right" vertical-align="bottom">
|
||||
<div class="dropdown-content"></div>
|
||||
</iron-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="FocusableContentDropdown">
|
||||
<template>
|
||||
<iron-dropdown>
|
||||
<div class="dropdown-content" tabindex="0">
|
||||
<div class="subcontent" tabindex="0"></div>
|
||||
</div>
|
||||
</iron-dropdown>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="RTLDropdownLeft">
|
||||
<template>
|
||||
<div dir="rtl" class="container">
|
||||
<iron-dropdown>
|
||||
<div class="dropdown-content"></div>
|
||||
</iron-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="RTLDropdownRight">
|
||||
<template>
|
||||
<div dir="rtl" class="container">
|
||||
<iron-dropdown horizontal-align="right">
|
||||
<div class="dropdown-content"></div>
|
||||
</iron-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
function elementIsVisible(element) {
|
||||
var contentRect = element.getBoundingClientRect();
|
||||
var computedStyle = window.getComputedStyle(element);
|
||||
|
||||
return computedStyle.display !== 'none' &&
|
||||
contentRect.width > 0 &&
|
||||
contentRect.height > 0;
|
||||
}
|
||||
|
||||
function runAfterOpen(overlay, callback) {
|
||||
overlay.addEventListener('iron-overlay-opened', callback);
|
||||
overlay.open();
|
||||
}
|
||||
|
||||
suite('<iron-dropdown>', function() {
|
||||
var dropdown;
|
||||
var content;
|
||||
|
||||
suite('basic', function() {
|
||||
setup(function() {
|
||||
dropdown = fixture('TrivialDropdown');
|
||||
content = Polymer.dom(dropdown).querySelector('.dropdown-content');
|
||||
});
|
||||
|
||||
test('effectively hides the dropdown content', function() {
|
||||
expect(elementIsVisible(content)).to.be.equal(false);
|
||||
});
|
||||
|
||||
test('shows dropdown content when opened', function(done) {
|
||||
runAfterOpen(dropdown, function () {
|
||||
expect(elementIsVisible(content)).to.be.equal(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('hides dropdown content when outside is clicked', function(done) {
|
||||
runAfterOpen(dropdown, function () {
|
||||
expect(elementIsVisible(content)).to.be.equal(true);
|
||||
dropdown.addEventListener('iron-overlay-closed', function() {
|
||||
expect(elementIsVisible(content)).to.be.equal(false);
|
||||
done();
|
||||
});
|
||||
MockInteractions.tap(dropdown.parentNode);
|
||||
});
|
||||
});
|
||||
|
||||
suite('when content is focusable', function() {
|
||||
setup(function() {
|
||||
dropdown = fixture('FocusableContentDropdown');
|
||||
content = Polymer.dom(dropdown).querySelector('.dropdown-content');
|
||||
});
|
||||
test('focuses the content when opened', function(done) {
|
||||
runAfterOpen(dropdown, function () {
|
||||
expect(document.activeElement).to.be.equal(content);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('focuses a configured focus target', function(done) {
|
||||
var focusableChild = Polymer.dom(content).querySelector('div[tabindex]');
|
||||
dropdown.focusTarget = focusableChild;
|
||||
|
||||
runAfterOpen(dropdown, function () {
|
||||
expect(document.activeElement).to.not.be.equal(content);
|
||||
expect(document.activeElement).to.be.equal(focusableChild);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('locking scroll', function() {
|
||||
|
||||
setup(function() {
|
||||
dropdown = fixture('TrivialDropdown');
|
||||
});
|
||||
|
||||
test('should lock, only once', function(done) {
|
||||
var openCount = 0;
|
||||
runAfterOpen(dropdown, function() {
|
||||
expect(Polymer.IronDropdownScrollManager._lockingElements.length)
|
||||
.to.be.equal(1);
|
||||
expect(Polymer.IronDropdownScrollManager.elementIsScrollLocked(document.body))
|
||||
.to.be.equal(true);
|
||||
|
||||
if(openCount === 0) {
|
||||
// This triggers a second `pushScrollLock` with the same element, however
|
||||
// that should not add the element to the `_lockingElements` stack twice
|
||||
dropdown.close();
|
||||
dropdown.open();
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
openCount++;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('non locking scroll', function() {
|
||||
|
||||
setup(function() {
|
||||
dropdown = fixture('NonLockingDropdown');
|
||||
});
|
||||
|
||||
test('can be disabled with `allowOutsideScroll`', function(done) {
|
||||
runAfterOpen(dropdown, function() {
|
||||
expect(Polymer.IronDropdownScrollManager.elementIsScrollLocked(document.body))
|
||||
.to.be.equal(false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('aligned dropdown', function() {
|
||||
var parent;
|
||||
var parentRect;
|
||||
var dropdownRect;
|
||||
|
||||
setup(function() {
|
||||
parent = fixture('AlignedDropdown');
|
||||
dropdown = parent.querySelector('iron-dropdown');
|
||||
});
|
||||
|
||||
test('can be re-aligned to the right and the top', function(done) {
|
||||
runAfterOpen(dropdown, function () {
|
||||
dropdownRect = dropdown.getBoundingClientRect();
|
||||
parentRect = parent.getBoundingClientRect();
|
||||
assert.equal(dropdownRect.top, parentRect.top, 'top ok');
|
||||
assert.equal(dropdownRect.left, 0, 'left ok');
|
||||
assert.equal(dropdownRect.bottom, document.documentElement.clientHeight, 'bottom ok');
|
||||
assert.equal(dropdownRect.right, parentRect.right, 'right ok');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('can be re-aligned to the bottom', function(done) {
|
||||
dropdown.verticalAlign = 'bottom';
|
||||
runAfterOpen(dropdown, function () {
|
||||
parentRect = parent.getBoundingClientRect();
|
||||
dropdownRect = dropdown.getBoundingClientRect();
|
||||
assert.equal(dropdownRect.top, 0, 'top ok');
|
||||
assert.equal(dropdownRect.left, 0, 'left ok');
|
||||
assert.equal(dropdownRect.bottom, parentRect.bottom, 'bottom ok');
|
||||
assert.equal(dropdownRect.right, parentRect.right, 'right ok');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('handles parent\'s stacking context', function(done) {
|
||||
// This will create a new stacking context.
|
||||
parent.style.transform = 'translateZ(0)';
|
||||
runAfterOpen(dropdown, function () {
|
||||
dropdownRect = dropdown.getBoundingClientRect();
|
||||
parentRect = parent.getBoundingClientRect();
|
||||
assert.equal(dropdownRect.top, parentRect.top, 'top ok');
|
||||
assert.equal(dropdownRect.left, 0, 'left ok');
|
||||
assert.equal(dropdownRect.bottom, document.documentElement.clientHeight, 'bottom ok');
|
||||
assert.equal(dropdownRect.right, parentRect.right, 'right ok');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('when align is left/top, with an offset', function() {
|
||||
var dropdownRect;
|
||||
var offsetDropdownRect;
|
||||
setup(function() {
|
||||
var parent = fixture('OffsetDropdownTopLeft');
|
||||
dropdown = parent.querySelector('iron-dropdown');
|
||||
});
|
||||
|
||||
test('can be offset towards the bottom right', function(done) {
|
||||
runAfterOpen(dropdown, function () {
|
||||
dropdownRect = dropdown.getBoundingClientRect();
|
||||
dropdown.verticalOffset = 10;
|
||||
dropdown.horizontalOffset = 10;
|
||||
// Force refit instead of waiting for requestAnimationFrame.
|
||||
dropdown.refit();
|
||||
offsetDropdownRect = dropdown.getBoundingClientRect();
|
||||
// verticalAlign is top, so a positive offset moves down.
|
||||
assert.equal(dropdownRect.top + 10, offsetDropdownRect.top, 'top ok');
|
||||
// horizontalAlign is left, so a positive offset moves to the right.
|
||||
assert.equal(dropdownRect.left + 10, offsetDropdownRect.left, 'left ok');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('can be offset towards the top left', function(done) {
|
||||
runAfterOpen(dropdown, function () {
|
||||
dropdownRect = dropdown.getBoundingClientRect();
|
||||
dropdown.verticalOffset = -10;
|
||||
dropdown.horizontalOffset = -10;
|
||||
// Force refit instead of waiting for requestAnimationFrame.
|
||||
dropdown.refit();
|
||||
offsetDropdownRect = dropdown.getBoundingClientRect();
|
||||
// verticalAlign is top, so a negative offset moves up.
|
||||
assert.equal(dropdownRect.top - 10, offsetDropdownRect.top, 'top ok');
|
||||
// horizontalAlign is left, so a negative offset moves to the left.
|
||||
assert.equal(dropdownRect.left - 10, offsetDropdownRect.left, 'left ok');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('when align is right/bottom, with an offset', function() {
|
||||
var dropdownRect;
|
||||
var offsetDropdownRect;
|
||||
setup(function() {
|
||||
var parent = fixture('OffsetDropdownBottomRight');
|
||||
dropdown = parent.querySelector('iron-dropdown');
|
||||
});
|
||||
|
||||
test('can be offset towards the top left', function(done) {
|
||||
runAfterOpen(dropdown, function () {
|
||||
dropdownRect = dropdown.getBoundingClientRect();
|
||||
dropdown.verticalOffset = 10;
|
||||
dropdown.horizontalOffset = 10;
|
||||
// Force refit instead of waiting for requestAnimationFrame.
|
||||
dropdown.refit();
|
||||
offsetDropdownRect = dropdown.getBoundingClientRect();
|
||||
// verticalAlign is bottom, so a positive offset moves up.
|
||||
assert.equal(dropdownRect.bottom - 10, offsetDropdownRect.bottom, 'bottom ok');
|
||||
// horizontalAlign is right, so a positive offset moves to the left.
|
||||
assert.equal(dropdownRect.right - 10, offsetDropdownRect.right, 'right ok');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('can be offset towards the bottom right', function(done) {
|
||||
runAfterOpen(dropdown, function () {
|
||||
dropdownRect = dropdown.getBoundingClientRect();
|
||||
dropdown.verticalOffset = -10;
|
||||
dropdown.horizontalOffset = -10;
|
||||
// Force refit instead of waiting for requestAnimationFrame.
|
||||
dropdown.refit();
|
||||
offsetDropdownRect = dropdown.getBoundingClientRect();
|
||||
// verticalAlign is bottom, so a negative offset moves down.
|
||||
assert.equal(dropdownRect.bottom + 10, offsetDropdownRect.bottom, 'bottom ok');
|
||||
// horizontalAlign is right, so a positive offset moves to the right.
|
||||
assert.equal(dropdownRect.right + 10, offsetDropdownRect.right, 'right ok');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('RTL', function() {
|
||||
var dropdownRect;
|
||||
|
||||
test('with horizontalAlign=left', function(done) {
|
||||
var parent = fixture('RTLDropdownLeft');
|
||||
dropdown = parent.querySelector('iron-dropdown');
|
||||
runAfterOpen(dropdown, function () {
|
||||
// In RTL, if `horizontalAlign` is "left", that's the same as
|
||||
// being right-aligned in LTR. So the dropdown should be in the top
|
||||
// right corner.
|
||||
dropdownRect = dropdown.getBoundingClientRect();
|
||||
expect(dropdownRect.top).to.be.equal(0);
|
||||
expect(dropdownRect.right).to.be.equal(100);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('with horizontalAlign=right', function(done) {
|
||||
var parent = fixture('RTLDropdownRight');
|
||||
dropdown = parent.querySelector('iron-dropdown');
|
||||
runAfterOpen(dropdown, function () {
|
||||
// In RTL, if `horizontalAlign` is "right", that's the same as
|
||||
// being left-aligned in LTR. So the dropdown should be in the top
|
||||
// left corner.
|
||||
dropdownRect = dropdown.getBoundingClientRect();
|
||||
expect(dropdownRect.top).to.be.equal(0);
|
||||
expect(dropdownRect.left).to.be.equal(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,27 +0,0 @@
|
|||
<!--
|
||||
@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">
|
||||
|
||||
<dom-module id="x-scrollable-element">
|
||||
<template>
|
||||
<div id="ChildOne">
|
||||
<div id="GrandchildOne"></div>
|
||||
</div>
|
||||
<div id="ChildTwo">
|
||||
<div id="GrandchildTwo"></div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
Polymer({
|
||||
is: 'x-scrollable-element'
|
||||
});
|
||||
</script>
|
||||
</dom-module>
|
|
@ -1,41 +0,0 @@
|
|||
{
|
||||
"name": "iron-fit-behavior",
|
||||
"version": "1.1.1",
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"description": "Fits an element inside another element",
|
||||
"private": true,
|
||||
"main": "iron-fit-behavior.html",
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"polymer",
|
||||
"behavior"
|
||||
],
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/PolymerElements/iron-fit-behavior.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"polymer": "Polymer/polymer#^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
|
||||
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
|
||||
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
|
||||
"web-component-tester": "^4.0.0",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
},
|
||||
"ignore": [],
|
||||
"homepage": "https://github.com/PolymerElements/iron-fit-behavior",
|
||||
"_release": "1.1.1",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.1.1",
|
||||
"commit": "c87fd44553b9ce2c60f695146d667932a7be2f8f"
|
||||
},
|
||||
"_source": "git://github.com/PolymerElements/iron-fit-behavior.git",
|
||||
"_target": "^1.0.0",
|
||||
"_originalSource": "PolymerElements/iron-fit-behavior"
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<!-- Instructions: https://github.com/PolymerElements/iron-fit-behavior/CONTRIBUTING.md#filing-issues -->
|
||||
### Description
|
||||
<!-- Example: The `paper-foo` element causes the page to turn pink when clicked. -->
|
||||
|
||||
### Expected outcome
|
||||
|
||||
<!-- Example: The page stays the same color. -->
|
||||
|
||||
### Actual outcome
|
||||
|
||||
<!-- Example: The page turns pink. -->
|
||||
|
||||
### Live Demo
|
||||
<!-- Example: https://jsbin.com/cagaye/edit?html,output -->
|
||||
|
||||
### Steps to reproduce
|
||||
|
||||
<!-- Example
|
||||
1. Put a `paper-foo` element in the page.
|
||||
2. Open the page in a web browser.
|
||||
3. Click the `paper-foo` element.
|
||||
-->
|
||||
|
||||
### Browsers Affected
|
||||
<!-- Check all that apply -->
|
||||
- [ ] Chrome
|
||||
- [ ] Firefox
|
||||
- [ ] Safari 9
|
||||
- [ ] Safari 8
|
||||
- [ ] Safari 7
|
||||
- [ ] Edge
|
||||
- [ ] IE 11
|
||||
- [ ] IE 10
|
|
@ -1 +0,0 @@
|
|||
bower_components
|
|
@ -1,23 +0,0 @@
|
|||
language: node_js
|
||||
sudo: required
|
||||
before_script:
|
||||
- npm install -g bower polylint web-component-tester
|
||||
- bower install
|
||||
- polylint
|
||||
env:
|
||||
global:
|
||||
- secure: QL2j7nfSA/40iIPMKLMosv9hj8q7eGBbPQXVQmCL3uXD5qoMPTqo1qronKKX+bi3Rh7W104ufV4CzzbWvBwQh8gipx+4REGijzc77Fro2y3v3/wUp9H/UEWnbhAWPDsqEoAD8xQXFHkVv7874/VwOlubQyXDGlvqh0fzYbUNUQo=
|
||||
- secure: ajBo8YcSzi4kNuCHcmajCirWQKf5Mj4OZ3tQjNAcJJAy0UtyrAgTenayWN2ijKqD5V8wfTK66jUXGYMZkoJV4EpknrUliqRgRqKHHfULXYWRSC7lDGxf835ReFxstkPun4HmNtxraAWJgmgFz7mylntTVKm46Ce4INj3n8reWaY=
|
||||
node_js: stable
|
||||
addons:
|
||||
firefox: latest
|
||||
apt:
|
||||
sources:
|
||||
- google-chrome
|
||||
packages:
|
||||
- google-chrome-stable
|
||||
sauce_connect: true
|
||||
script:
|
||||
- xvfb-run wct
|
||||
- "if [ \"${TRAVIS_PULL_REQUEST}\" = \"false\" ]; then wct -s 'default'; fi"
|
||||
dist: trusty
|
|
@ -1,77 +0,0 @@
|
|||
|
||||
<!--
|
||||
This file is autogenerated based on
|
||||
https://github.com/PolymerElements/ContributionGuide/blob/master/CONTRIBUTING.md
|
||||
|
||||
If you edit that file, it will get updated everywhere else.
|
||||
If you edit this file, your changes will get overridden :)
|
||||
|
||||
You can however override the jsbin link with one that's customized to this
|
||||
specific element:
|
||||
|
||||
jsbin=https://jsbin.com/cagaye/edit?html,output
|
||||
-->
|
||||
# Polymer Elements
|
||||
## Guide for Contributors
|
||||
|
||||
Polymer Elements are built in the open, and the Polymer authors eagerly encourage any and all forms of community contribution. When contributing, please follow these guidelines:
|
||||
|
||||
### Filing Issues
|
||||
|
||||
**If you are filing an issue to request a feature**, please provide a clear description of the feature. It can be helpful to describe answers to the following questions:
|
||||
|
||||
1. **Who will use the feature?** _“As someone filling out a form…”_
|
||||
2. **When will they use the feature?** _“When I enter an invalid value…”_
|
||||
3. **What is the user’s goal?** _“I want to be visually notified that the value needs to be corrected…”_
|
||||
|
||||
**If you are filing an issue to report a bug**, please provide:
|
||||
|
||||
1. **A clear description of the bug and related expectations.** Consider using the following example template for reporting a bug:
|
||||
|
||||
```markdown
|
||||
The `paper-foo` element causes the page to turn pink when clicked.
|
||||
|
||||
## Expected outcome
|
||||
|
||||
The page stays the same color.
|
||||
|
||||
## Actual outcome
|
||||
|
||||
The page turns pink.
|
||||
|
||||
## Steps to reproduce
|
||||
|
||||
1. Put a `paper-foo` element in the page.
|
||||
2. Open the page in a web browser.
|
||||
3. Click the `paper-foo` element.
|
||||
```
|
||||
|
||||
2. **A reduced test case that demonstrates the problem.** If possible, please include the test case as a JSBin. Start with this template to easily import and use relevant Polymer Elements: [https://jsbin.com/cagaye/edit?html,output](https://jsbin.com/cagaye/edit?html,output).
|
||||
|
||||
3. **A list of browsers where the problem occurs.** This can be skipped if the problem is the same across all browsers.
|
||||
|
||||
### Submitting Pull Requests
|
||||
|
||||
**Before creating a pull request**, please ensure that an issue exists for the corresponding change in the pull request that you intend to make. **If an issue does not exist, please create one per the guidelines above**. The goal is to discuss the design and necessity of the proposed change with Polymer authors and community before diving into a pull request.
|
||||
|
||||
When submitting pull requests, please provide:
|
||||
|
||||
1. **A reference to the corresponding issue** or issues that will be closed by the pull request. Please refer to these issues in the pull request description using the following syntax:
|
||||
|
||||
```markdown
|
||||
(For a single issue)
|
||||
Fixes #20
|
||||
|
||||
(For multiple issues)
|
||||
Fixes #32, fixes #40
|
||||
```
|
||||
|
||||
2. **A succinct description of the design** used to fix any related issues. For example:
|
||||
|
||||
```markdown
|
||||
This fixes #20 by removing styles that leaked which would cause the page to turn pink whenever `paper-foo` is clicked.
|
||||
```
|
||||
|
||||
3. **At least one test for each bug fixed or feature added** as part of the pull request. Pull requests that fix bugs or add features without accompanying tests will not be considered.
|
||||
|
||||
If a proposed change contains multiple commits, please [squash commits](https://www.google.com/url?q=http://blog.steveklabnik.com/posts/2012-11-08-how-to-squash-commits-in-a-github-pull-request) to as few as is necessary to succinctly express the change. A Polymer author can help you squash commits, so don’t be afraid to ask us if you need help with that!
|
|
@ -1,31 +0,0 @@
|
|||
{
|
||||
"name": "iron-fit-behavior",
|
||||
"version": "1.1.1",
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"description": "Fits an element inside another element",
|
||||
"private": true,
|
||||
"main": "iron-fit-behavior.html",
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"polymer",
|
||||
"behavior"
|
||||
],
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/PolymerElements/iron-fit-behavior.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"polymer": "Polymer/polymer#^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
|
||||
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
|
||||
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
|
||||
"web-component-tester": "^4.0.0",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
},
|
||||
"ignore": []
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
<!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>iron-fit-behavior demo</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>
|
||||
<link rel="import" href="simple-fit.html">
|
||||
<link rel="import" href="../../iron-demo-helpers/demo-snippet.html">
|
||||
<link rel="import" href="../../iron-demo-helpers/demo-pages-shared-styles.html">
|
||||
|
||||
<style is="custom-style" include="demo-pages-shared-styles">
|
||||
demo-snippet {
|
||||
--demo-snippet-code: {
|
||||
max-height: 250px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body unresolved class="centered">
|
||||
<h3>
|
||||
An element with <code>IronFitBehavior</code> can be centered in
|
||||
<code>fitInto</code> or positioned around a <code>positionTarget</code>
|
||||
</h3>
|
||||
<demo-snippet>
|
||||
<template>
|
||||
<style>
|
||||
.target {
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid;
|
||||
width: 100px;
|
||||
padding: 20px 0;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
#myFit {
|
||||
z-index: 10;
|
||||
padding: 20px;
|
||||
overflow: auto;
|
||||
width: 220px;
|
||||
}
|
||||
</style>
|
||||
<template is="dom-bind">
|
||||
<template is="dom-repeat" items="[[containers]]">
|
||||
<div class="target" on-tap="updatePositionTarget">Target</div>
|
||||
</template>
|
||||
<simple-fit id="myFit" auto-fit-on-attach>
|
||||
<h2>Align</h2>
|
||||
<p>
|
||||
<button on-tap="updateAlign" vertical-align="top">top</button>
|
||||
<button on-tap="updateAlign" vertical-align="bottom">bottom</button>
|
||||
<button on-tap="updateAlign" vertical-align="auto">auto</button>
|
||||
<button on-tap="updateAlign" vertical-align>null</button>
|
||||
</p>
|
||||
<p>
|
||||
<button on-tap="updateAlign" horizontal-align="left">left</button>
|
||||
<button on-tap="updateAlign" horizontal-align="right">right</button>
|
||||
<button on-tap="updateAlign" horizontal-align="auto">auto</button>
|
||||
<button on-tap="updateAlign" horizontal-align>null</button>
|
||||
</p>
|
||||
<button on-tap="toggleNoOverlap">Toggle overlap</button>
|
||||
</simple-fit>
|
||||
<script>
|
||||
var defaultTarget = Polymer.dom(myFit).parentNode;
|
||||
var template = document.querySelector('template[is="dom-bind"]');
|
||||
|
||||
template.containers = new Array(30);
|
||||
|
||||
template.updatePositionTarget = function(e) {
|
||||
var target = Polymer.dom(e).rootTarget;
|
||||
target = myFit.positionTarget === target ? defaultTarget : target;
|
||||
myFit.positionTarget.style.backgroundColor = '';
|
||||
target.style.backgroundColor = 'orange';
|
||||
myFit.positionTarget = target;
|
||||
template.refit();
|
||||
};
|
||||
|
||||
template._raf = null;
|
||||
template.refit = function() {
|
||||
template._raf && window.cancelAnimationFrame(template._raf);
|
||||
template._raf = window.requestAnimationFrame(function() {
|
||||
template._raf = null;
|
||||
myFit.refit();
|
||||
});
|
||||
};
|
||||
|
||||
template.updateAlign = function(e) {
|
||||
var target = Polymer.dom(e).rootTarget;
|
||||
if (target.hasAttribute('horizontal-align')) {
|
||||
myFit.horizontalAlign = target.getAttribute('horizontal-align');
|
||||
}
|
||||
if (target.hasAttribute('vertical-align')) {
|
||||
myFit.verticalAlign = target.getAttribute('vertical-align');
|
||||
}
|
||||
template.refit();
|
||||
};
|
||||
|
||||
template.toggleNoOverlap = function() {
|
||||
myFit.noOverlap = !myFit.noOverlap;
|
||||
template.refit();
|
||||
};
|
||||
|
||||
// Listen for resize and scroll on window.
|
||||
window.addEventListener('resize', template.refit);
|
||||
window.addEventListener('scroll', template.refit);
|
||||
</script>
|
||||
</template>
|
||||
</template>
|
||||
</demo-snippet>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1,42 +0,0 @@
|
|||
<!--
|
||||
@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-fit-behavior.html">
|
||||
<link rel="import" href="../../paper-styles/color.html">
|
||||
|
||||
<dom-module id="simple-fit">
|
||||
|
||||
<style>
|
||||
:host {
|
||||
background-color: var(--paper-light-blue-500);
|
||||
color: white;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<content></content>
|
||||
</template>
|
||||
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
|
||||
Polymer({
|
||||
|
||||
is: 'simple-fit',
|
||||
|
||||
behaviors: [
|
||||
Polymer.IronFitBehavior
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
</script>
|
|
@ -1,30 +0,0 @@
|
|||
<!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>iron-fit-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>
|
|
@ -1,552 +0,0 @@
|
|||
<!--
|
||||
@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">
|
||||
|
||||
<script>
|
||||
/**
|
||||
`Polymer.IronFitBehavior` fits an element in another element using `max-height` and `max-width`, and
|
||||
optionally centers it in the window or another element.
|
||||
|
||||
The element will only be sized and/or positioned if it has not already been sized and/or positioned
|
||||
by CSS.
|
||||
|
||||
CSS properties | Action
|
||||
-----------------------------|-------------------------------------------
|
||||
`position` set | Element is not centered horizontally or vertically
|
||||
`top` or `bottom` set | Element is not vertically centered
|
||||
`left` or `right` set | Element is not horizontally centered
|
||||
`max-height` set | Element respects `max-height`
|
||||
`max-width` set | Element respects `max-width`
|
||||
|
||||
`Polymer.IronFitBehavior` can position an element into another element using
|
||||
`verticalAlign` and `horizontalAlign`. This will override the element's css position.
|
||||
|
||||
<div class="container">
|
||||
<iron-fit-impl vertical-align="top" horizontal-align="auto">
|
||||
Positioned into the container
|
||||
</iron-fit-impl>
|
||||
</div>
|
||||
|
||||
Use `noOverlap` to position the element around another element without overlapping it.
|
||||
|
||||
<div class="container">
|
||||
<iron-fit-impl no-overlap vertical-align="auto" horizontal-align="auto">
|
||||
Positioned around the container
|
||||
</iron-fit-impl>
|
||||
</div>
|
||||
|
||||
@demo demo/index.html
|
||||
@polymerBehavior
|
||||
*/
|
||||
|
||||
Polymer.IronFitBehavior = {
|
||||
|
||||
properties: {
|
||||
|
||||
/**
|
||||
* The element that will receive a `max-height`/`width`. By default it is the same as `this`,
|
||||
* but it can be set to a child element. This is useful, for example, for implementing a
|
||||
* scrolling region inside the element.
|
||||
* @type {!Element}
|
||||
*/
|
||||
sizingTarget: {
|
||||
type: Object,
|
||||
value: function() {
|
||||
return this;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The element to fit `this` into.
|
||||
*/
|
||||
fitInto: {
|
||||
type: Object,
|
||||
value: window
|
||||
},
|
||||
|
||||
/**
|
||||
* Will position the element around the positionTarget without overlapping it.
|
||||
*/
|
||||
noOverlap: {
|
||||
type: Boolean
|
||||
},
|
||||
|
||||
/**
|
||||
* The element that should be used to position the element. If not set, it will
|
||||
* default to the parent node.
|
||||
* @type {!Element}
|
||||
*/
|
||||
positionTarget: {
|
||||
type: Element
|
||||
},
|
||||
|
||||
/**
|
||||
* The orientation against which to align the element horizontally
|
||||
* relative to the `positionTarget`. Possible values are "left", "right", "auto".
|
||||
*/
|
||||
horizontalAlign: {
|
||||
type: String
|
||||
},
|
||||
|
||||
/**
|
||||
* The orientation against which to align the element vertically
|
||||
* relative to the `positionTarget`. Possible values are "top", "bottom", "auto".
|
||||
*/
|
||||
verticalAlign: {
|
||||
type: String
|
||||
},
|
||||
|
||||
/**
|
||||
* The same as setting margin-left and margin-right css properties.
|
||||
* @deprecated
|
||||
*/
|
||||
horizontalOffset: {
|
||||
type: Number,
|
||||
value: 0,
|
||||
notify: true
|
||||
},
|
||||
|
||||
/**
|
||||
* The same as setting margin-top and margin-bottom css properties.
|
||||
* @deprecated
|
||||
*/
|
||||
verticalOffset: {
|
||||
type: Number,
|
||||
value: 0,
|
||||
notify: true
|
||||
},
|
||||
|
||||
/**
|
||||
* Set to true to auto-fit on attach.
|
||||
*/
|
||||
autoFitOnAttach: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
|
||||
/** @type {?Object} */
|
||||
_fitInfo: {
|
||||
type: Object
|
||||
}
|
||||
},
|
||||
|
||||
get _fitWidth() {
|
||||
var fitWidth;
|
||||
if (this.fitInto === window) {
|
||||
fitWidth = this.fitInto.innerWidth;
|
||||
} else {
|
||||
fitWidth = this.fitInto.getBoundingClientRect().width;
|
||||
}
|
||||
return fitWidth;
|
||||
},
|
||||
|
||||
get _fitHeight() {
|
||||
var fitHeight;
|
||||
if (this.fitInto === window) {
|
||||
fitHeight = this.fitInto.innerHeight;
|
||||
} else {
|
||||
fitHeight = this.fitInto.getBoundingClientRect().height;
|
||||
}
|
||||
return fitHeight;
|
||||
},
|
||||
|
||||
get _fitLeft() {
|
||||
var fitLeft;
|
||||
if (this.fitInto === window) {
|
||||
fitLeft = 0;
|
||||
} else {
|
||||
fitLeft = this.fitInto.getBoundingClientRect().left;
|
||||
}
|
||||
return fitLeft;
|
||||
},
|
||||
|
||||
get _fitTop() {
|
||||
var fitTop;
|
||||
if (this.fitInto === window) {
|
||||
fitTop = 0;
|
||||
} else {
|
||||
fitTop = this.fitInto.getBoundingClientRect().top;
|
||||
}
|
||||
return fitTop;
|
||||
},
|
||||
|
||||
/**
|
||||
* The element that should be used to position the element,
|
||||
* if no position target is configured.
|
||||
*/
|
||||
get _defaultPositionTarget() {
|
||||
var parent = Polymer.dom(this).parentNode;
|
||||
|
||||
if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
||||
parent = parent.host;
|
||||
}
|
||||
|
||||
return parent;
|
||||
},
|
||||
|
||||
/**
|
||||
* The horizontal align value, accounting for the RTL/LTR text direction.
|
||||
*/
|
||||
get _localeHorizontalAlign() {
|
||||
if (this._isRTL) {
|
||||
// In RTL, "left" becomes "right".
|
||||
if (this.horizontalAlign === 'right') {
|
||||
return 'left';
|
||||
}
|
||||
if (this.horizontalAlign === 'left') {
|
||||
return 'right';
|
||||
}
|
||||
}
|
||||
return this.horizontalAlign;
|
||||
},
|
||||
|
||||
attached: function() {
|
||||
// Memoize this to avoid expensive calculations & relayouts.
|
||||
this._isRTL = window.getComputedStyle(this).direction == 'rtl';
|
||||
this.positionTarget = this.positionTarget || this._defaultPositionTarget;
|
||||
if (this.autoFitOnAttach) {
|
||||
if (window.getComputedStyle(this).display === 'none') {
|
||||
setTimeout(function() {
|
||||
this.fit();
|
||||
}.bind(this));
|
||||
} else {
|
||||
this.fit();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Positions and fits the element into the `fitInto` element.
|
||||
*/
|
||||
fit: function() {
|
||||
this._discoverInfo();
|
||||
this.position();
|
||||
this.constrain();
|
||||
this.center();
|
||||
},
|
||||
|
||||
/**
|
||||
* Memoize information needed to position and size the target element.
|
||||
*/
|
||||
_discoverInfo: function() {
|
||||
if (this._fitInfo) {
|
||||
return;
|
||||
}
|
||||
var target = window.getComputedStyle(this);
|
||||
var sizer = window.getComputedStyle(this.sizingTarget);
|
||||
|
||||
this._fitInfo = {
|
||||
inlineStyle: {
|
||||
top: this.style.top || '',
|
||||
left: this.style.left || '',
|
||||
position: this.style.position || ''
|
||||
},
|
||||
sizerInlineStyle: {
|
||||
maxWidth: this.sizingTarget.style.maxWidth || '',
|
||||
maxHeight: this.sizingTarget.style.maxHeight || '',
|
||||
boxSizing: this.sizingTarget.style.boxSizing || ''
|
||||
},
|
||||
positionedBy: {
|
||||
vertically: target.top !== 'auto' ? 'top' : (target.bottom !== 'auto' ?
|
||||
'bottom' : null),
|
||||
horizontally: target.left !== 'auto' ? 'left' : (target.right !== 'auto' ?
|
||||
'right' : null)
|
||||
},
|
||||
sizedBy: {
|
||||
height: sizer.maxHeight !== 'none',
|
||||
width: sizer.maxWidth !== 'none',
|
||||
minWidth: parseInt(sizer.minWidth, 10) || 0,
|
||||
minHeight: parseInt(sizer.minHeight, 10) || 0
|
||||
},
|
||||
margin: {
|
||||
top: parseInt(target.marginTop, 10) || 0,
|
||||
right: parseInt(target.marginRight, 10) || 0,
|
||||
bottom: parseInt(target.marginBottom, 10) || 0,
|
||||
left: parseInt(target.marginLeft, 10) || 0
|
||||
}
|
||||
};
|
||||
|
||||
// Support these properties until they are removed.
|
||||
if (this.verticalOffset) {
|
||||
this._fitInfo.margin.top = this._fitInfo.margin.bottom = this.verticalOffset;
|
||||
this._fitInfo.inlineStyle.marginTop = this.style.marginTop || '';
|
||||
this._fitInfo.inlineStyle.marginBottom = this.style.marginBottom || '';
|
||||
this.style.marginTop = this.style.marginBottom = this.verticalOffset + 'px';
|
||||
}
|
||||
if (this.horizontalOffset) {
|
||||
this._fitInfo.margin.left = this._fitInfo.margin.right = this.horizontalOffset;
|
||||
this._fitInfo.inlineStyle.marginLeft = this.style.marginLeft || '';
|
||||
this._fitInfo.inlineStyle.marginRight = this.style.marginRight || '';
|
||||
this.style.marginLeft = this.style.marginRight = this.horizontalOffset + 'px';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets the target element's position and size constraints, and clear
|
||||
* the memoized data.
|
||||
*/
|
||||
resetFit: function() {
|
||||
var info = this._fitInfo || {};
|
||||
for (var property in info.sizerInlineStyle) {
|
||||
this.sizingTarget.style[property] = info.sizerInlineStyle[property];
|
||||
}
|
||||
for (var property in info.inlineStyle) {
|
||||
this.style[property] = info.inlineStyle[property];
|
||||
}
|
||||
|
||||
this._fitInfo = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Equivalent to calling `resetFit()` and `fit()`. Useful to call this after
|
||||
* the element or the `fitInto` element has been resized, or if any of the
|
||||
* positioning properties (e.g. `horizontalAlign, verticalAlign`) is updated.
|
||||
*/
|
||||
refit: function() {
|
||||
this.resetFit();
|
||||
this.fit();
|
||||
},
|
||||
|
||||
/**
|
||||
* Positions the element according to `horizontalAlign, verticalAlign`.
|
||||
*/
|
||||
position: function() {
|
||||
if (!this.horizontalAlign && !this.verticalAlign) {
|
||||
// needs to be centered, and it is done after constrain.
|
||||
return;
|
||||
}
|
||||
|
||||
this.style.position = 'fixed';
|
||||
// Need border-box for margin/padding.
|
||||
this.sizingTarget.style.boxSizing = 'border-box';
|
||||
// Set to 0, 0 in order to discover any offset caused by parent stacking contexts.
|
||||
this.style.left = '0px';
|
||||
this.style.top = '0px';
|
||||
|
||||
var rect = this.getBoundingClientRect();
|
||||
var positionRect = this.__getNormalizedRect(this.positionTarget);
|
||||
var fitRect = this.__getNormalizedRect(this.fitInto);
|
||||
|
||||
// Consider the margin as part of the size for position calculations.
|
||||
var width = rect.width + this._fitInfo.margin.left + this._fitInfo.margin.right;
|
||||
var height = rect.height + this._fitInfo.margin.top + this._fitInfo.margin.bottom;
|
||||
|
||||
var alignRight = this.__isAlignRight(this._localeHorizontalAlign, width, positionRect, fitRect);
|
||||
var alignBottom = this.__isAlignBottom(this.verticalAlign, height, positionRect, fitRect);
|
||||
|
||||
var top = alignBottom ? positionRect.bottom - height : positionRect.top;
|
||||
var left = alignRight ? positionRect.right - width : positionRect.left;
|
||||
|
||||
if (this.noOverlap) {
|
||||
// We can overlap one of the dimensions, choose the one that minimizes the cropped area.
|
||||
var noOverlapLeft = left + positionRect.width * (alignRight ? -1 : 1);
|
||||
var noOverlapTop = top + positionRect.height * (alignBottom ? -1 : 1);
|
||||
var areaOverlapLeft = this.__getCroppedArea({
|
||||
top: noOverlapTop,
|
||||
left: left,
|
||||
width: width,
|
||||
height: height
|
||||
}, fitRect);
|
||||
var areaOverlapTop = this.__getCroppedArea({
|
||||
top: top,
|
||||
left: noOverlapLeft,
|
||||
width: width,
|
||||
height: height
|
||||
}, fitRect);
|
||||
if (areaOverlapLeft >= areaOverlapTop) {
|
||||
left = noOverlapLeft;
|
||||
} else {
|
||||
top = noOverlapTop;
|
||||
}
|
||||
}
|
||||
|
||||
left += this._fitInfo.margin.left;
|
||||
top += this._fitInfo.margin.top;
|
||||
|
||||
// Use original size (without margin)
|
||||
var right = left + rect.width;
|
||||
var bottom = top + rect.height;
|
||||
|
||||
left = Math.max(left, this._fitInfo.margin.left);
|
||||
top = Math.max(top, this._fitInfo.margin.top);
|
||||
|
||||
var maxWidth = Math.min(fitRect.right - this._fitInfo.margin.right, right) - left;
|
||||
var maxHeight = Math.min(fitRect.bottom - this._fitInfo.margin.bottom, bottom) - top;
|
||||
|
||||
var minWidth = this._fitInfo.sizedBy.minWidth;
|
||||
var minHeight = this._fitInfo.sizedBy.minHeight;
|
||||
|
||||
if (maxWidth < minWidth || right < minWidth) {
|
||||
left = -9999;
|
||||
maxWidth = 0;
|
||||
}
|
||||
if (maxHeight < minHeight || bottom < minHeight) {
|
||||
top = -9999;
|
||||
maxHeight = 0;
|
||||
}
|
||||
|
||||
this.sizingTarget.style.maxWidth = maxWidth + 'px';
|
||||
this.sizingTarget.style.maxHeight = maxHeight + 'px';
|
||||
|
||||
// Remove the offset caused by any stacking context.
|
||||
this.style.left = (left - rect.left) + 'px';
|
||||
this.style.top = (top - rect.top) + 'px';
|
||||
},
|
||||
|
||||
/**
|
||||
* Constrains the size of the element to `fitInto` by setting `max-height`
|
||||
* and/or `max-width`.
|
||||
*/
|
||||
constrain: function() {
|
||||
if (this.horizontalAlign || this.verticalAlign) {
|
||||
return;
|
||||
}
|
||||
var info = this._fitInfo;
|
||||
// position at (0px, 0px) if not already positioned, so we can measure the natural size.
|
||||
if (!info.positionedBy.vertically) {
|
||||
this.style.position = 'fixed';
|
||||
this.style.top = '0px';
|
||||
}
|
||||
if (!info.positionedBy.horizontally) {
|
||||
this.style.position = 'fixed';
|
||||
this.style.left = '0px';
|
||||
}
|
||||
|
||||
// need border-box for margin/padding
|
||||
this.sizingTarget.style.boxSizing = 'border-box';
|
||||
// constrain the width and height if not already set
|
||||
var rect = this.getBoundingClientRect();
|
||||
if (!info.sizedBy.height) {
|
||||
this.__sizeDimension(rect, info.positionedBy.vertically, 'top', 'bottom', 'Height');
|
||||
}
|
||||
if (!info.sizedBy.width) {
|
||||
this.__sizeDimension(rect, info.positionedBy.horizontally, 'left', 'right', 'Width');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @deprecated
|
||||
*/
|
||||
_sizeDimension: function(rect, positionedBy, start, end, extent) {
|
||||
this.__sizeDimension(rect, positionedBy, start, end, extent);
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
__sizeDimension: function(rect, positionedBy, start, end, extent) {
|
||||
var info = this._fitInfo;
|
||||
var fitRect = this.__getNormalizedRect(this.fitInto);
|
||||
var max = extent === 'Width' ? fitRect.width : fitRect.height;
|
||||
var flip = (positionedBy === end);
|
||||
var offset = flip ? max - rect[end] : rect[start];
|
||||
var margin = info.margin[flip ? start : end];
|
||||
var offsetExtent = 'offset' + extent;
|
||||
var sizingOffset = this[offsetExtent] - this.sizingTarget[offsetExtent];
|
||||
this.sizingTarget.style['max' + extent] = (max - margin - offset - sizingOffset) + 'px';
|
||||
},
|
||||
|
||||
/**
|
||||
* Centers horizontally and vertically if not already positioned. This also sets
|
||||
* `position:fixed`.
|
||||
*/
|
||||
center: function() {
|
||||
if (this.horizontalAlign || this.verticalAlign) {
|
||||
return;
|
||||
}
|
||||
var positionedBy = this._fitInfo.positionedBy;
|
||||
if (positionedBy.vertically && positionedBy.horizontally) {
|
||||
// Already positioned.
|
||||
return;
|
||||
}
|
||||
// Need position:fixed to center
|
||||
this.style.position = 'fixed';
|
||||
// Take into account the offset caused by parents that create stacking
|
||||
// contexts (e.g. with transform: translate3d). Translate to 0,0 and
|
||||
// measure the bounding rect.
|
||||
if (!positionedBy.vertically) {
|
||||
this.style.top = '0px';
|
||||
}
|
||||
if (!positionedBy.horizontally) {
|
||||
this.style.left = '0px';
|
||||
}
|
||||
// It will take in consideration margins and transforms
|
||||
var rect = this.getBoundingClientRect();
|
||||
var fitRect = this.__getNormalizedRect(this.fitInto);
|
||||
if (!positionedBy.vertically) {
|
||||
var top = fitRect.top - rect.top + (fitRect.height - rect.height) / 2;
|
||||
this.style.top = top + 'px';
|
||||
}
|
||||
if (!positionedBy.horizontally) {
|
||||
var left = fitRect.left - rect.left + (fitRect.width - rect.width) / 2;
|
||||
this.style.left = left + 'px';
|
||||
}
|
||||
},
|
||||
|
||||
__getNormalizedRect: function(target) {
|
||||
if (target === document.documentElement || target === window) {
|
||||
return {
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
right: window.innerWidth,
|
||||
bottom: window.innerHeight
|
||||
};
|
||||
}
|
||||
return target.getBoundingClientRect();
|
||||
},
|
||||
|
||||
__isAlignRight: function(hAlign, size, positionRect, fitRect) {
|
||||
if (hAlign === 'right') {
|
||||
return true;
|
||||
}
|
||||
if (hAlign === 'auto') {
|
||||
// We should align on the right if positionTarget is on the right of fitInto,
|
||||
// or if we can overlap and aligning on the left would cause more cropping
|
||||
// than aligning on the right.
|
||||
var positionTargetCenter = positionRect.left + positionRect.width/2;
|
||||
var fitIntoCenter = fitRect.left + fitRect.width/2;
|
||||
var croppedLeft = Math.abs(Math.min(0, positionRect.left));
|
||||
var croppedRight = Math.abs(Math.min(0, positionRect.right - size));
|
||||
return positionTargetCenter > fitIntoCenter ||
|
||||
(!this.noOverlap && croppedLeft > croppedRight);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
__isAlignBottom: function(vAlign, size, positionRect, fitRect) {
|
||||
if (vAlign === 'bottom') {
|
||||
return true;
|
||||
}
|
||||
if (vAlign === 'auto') {
|
||||
// We should align on the bottom if positionTarget is on the bottom of fitInto,
|
||||
// or if we can overlap and aligning on the top would cause more cropping
|
||||
// than aligning on the bottom.
|
||||
var positionTargetCenter = positionRect.top + positionRect.height/2;
|
||||
var fitIntoCenter = fitRect.top + fitRect.height/2;
|
||||
var croppedTop = Math.abs(Math.min(0, positionRect.top));
|
||||
var croppedBottom = Math.abs(Math.min(0, positionRect.bottom - size));
|
||||
return positionTargetCenter > fitIntoCenter ||
|
||||
(!this.noOverlap && croppedTop > croppedBottom);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
__getCroppedArea: function(rect, fitRect) {
|
||||
var verticalCrop = Math.min(0, rect.top) + Math.min(0, fitRect.bottom - (rect.top + rect.height));
|
||||
var horizontalCrop = Math.min(0, rect.left) + Math.min(0, fitRect.right - (rect.left + rect.width));
|
||||
return Math.abs(verticalCrop) * rect.width + Math.abs(horizontalCrop) * rect.height;
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
|
@ -1,31 +0,0 @@
|
|||
<!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>iron-fit-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="../../web-component-tester/browser.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script>
|
||||
WCT.loadSuites([
|
||||
'iron-fit-behavior.html',
|
||||
'iron-fit-behavior.html?dom=shadow'
|
||||
]);
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body></html>
|
|
@ -1,788 +0,0 @@
|
|||
<!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>iron-fit-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.js"></script>
|
||||
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
<link rel="import" href="test-fit.html">
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.absolute {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.scrolling {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.sized-x {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.sized-y {
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.positioned-left {
|
||||
position: absolute;
|
||||
left: 100px;
|
||||
}
|
||||
|
||||
.positioned-right {
|
||||
position: absolute;
|
||||
right: 100px;
|
||||
}
|
||||
|
||||
.positioned-top {
|
||||
position: absolute;
|
||||
top: 100px;
|
||||
}
|
||||
|
||||
.positioned-bottom {
|
||||
position: absolute;
|
||||
bottom: 100px;
|
||||
}
|
||||
|
||||
.with-max-width {
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
.with-max-height {
|
||||
max-height: 500px;
|
||||
}
|
||||
|
||||
.with-margin {
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
.constrain {
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
left: 20px;
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
border: 1px solid black;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="constrain"></div>
|
||||
|
||||
<test-fixture id="absolute">
|
||||
<template>
|
||||
<test-fit auto-fit-on-attach class="absolute">
|
||||
Absolutely positioned
|
||||
</test-fit>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="sized-xy">
|
||||
<template>
|
||||
<test-fit auto-fit-on-attach class="sized-x sized-y">
|
||||
Sized (x/y), auto center/center
|
||||
</test-fit>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="sized-x">
|
||||
<template>
|
||||
<test-fit auto-fit-on-attach class="sized-x">
|
||||
Sized (x), auto center/center
|
||||
</test-fit>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="positioned-xy">
|
||||
<template>
|
||||
<test-fit auto-fit-on-attach class="sized-x positioned-left positioned-top">
|
||||
Sized (x/y), positioned/positioned
|
||||
</test-fit>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="inline-positioned-xy">
|
||||
<template>
|
||||
<test-fit auto-fit-on-attach class="sized-x sized-y" style="position:absolute;left:100px;top:100px;">
|
||||
Sized (x/y), positioned/positioned
|
||||
</test-fit>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="sectioned">
|
||||
<template>
|
||||
<test-fit auto-fit-on-attach class="sized-x">
|
||||
<div>
|
||||
Sized (x), auto center/center with scrolling section
|
||||
</div>
|
||||
<div class="internal"></div>
|
||||
</test-fit>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="constrain-target">
|
||||
<template>
|
||||
<div class="constrain">
|
||||
<test-fit auto-fit-on-attach class="el sized-x sized-y">
|
||||
<div>
|
||||
Auto center/center to parent element
|
||||
</div>
|
||||
</test-fit>
|
||||
</div>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="offscreen-container">
|
||||
<template>
|
||||
<div style="position: fixed; top: -1px; left: 0;">
|
||||
<test-fit auto-fit-on-attach class="el sized-x">
|
||||
<div>
|
||||
Sized (x), auto center/center, container is offscreen
|
||||
</div>
|
||||
</test-fit>
|
||||
</div>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<template id="ipsum">
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing 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>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
function makeScrolling(el) {
|
||||
el.classList.add('scrolling');
|
||||
var template = document.getElementById('ipsum');
|
||||
for (var i = 0; i < 20; i++) {
|
||||
el.appendChild(template.content.cloneNode(true));
|
||||
}
|
||||
}
|
||||
|
||||
function intersects(r1, r2) {
|
||||
return !(r2.left >= r1.right || r2.right <= r1.left || r2.top >= r1.bottom || r2.bottom <= r1.top);
|
||||
}
|
||||
|
||||
suite('manual positioning', function() {
|
||||
|
||||
test('css positioned element is not re-positioned', function() {
|
||||
var el = fixture('positioned-xy');
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.top, 100, 'top is unset');
|
||||
assert.equal(rect.left, 100, 'left is unset');
|
||||
|
||||
});
|
||||
|
||||
test('inline positioned element is not re-positioned', function() {
|
||||
var el = fixture('inline-positioned-xy');
|
||||
var rect = el.getBoundingClientRect();
|
||||
// need to measure document.body here because mocha sets a min-width on html,body, and
|
||||
// the element is positioned wrt to that by css
|
||||
var bodyRect = document.body.getBoundingClientRect();
|
||||
assert.equal(rect.top, 100, 'top is unset');
|
||||
assert.equal(rect.left, 100, 'left is unset');
|
||||
|
||||
el.refit();
|
||||
|
||||
rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.top, 100, 'top is unset after refit');
|
||||
assert.equal(rect.left, 100, 'left is unset after refit');
|
||||
|
||||
});
|
||||
|
||||
test('position property is preserved after', function() {
|
||||
var el = fixture('absolute');
|
||||
assert.equal(getComputedStyle(el).position, 'absolute', 'position:absolute is preserved');
|
||||
});
|
||||
});
|
||||
|
||||
suite('fit to window', function() {
|
||||
|
||||
test('sized element is centered in viewport', function() {
|
||||
var el = fixture('sized-xy');
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.closeTo(rect.left - (window.innerWidth - rect.right), 0, 5, 'centered horizontally');
|
||||
assert.closeTo(rect.top - (window.innerHeight - rect.bottom), 0, 5, 'centered vertically');
|
||||
});
|
||||
|
||||
test('sized element with margin is centered in viewport', function() {
|
||||
var el = fixture('sized-xy');
|
||||
el.classList.add('with-margin');
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.closeTo(rect.left - (window.innerWidth - rect.right), 0, 5, 'centered horizontally');
|
||||
assert.closeTo(rect.top - (window.innerHeight - rect.bottom), 0, 5, 'centered vertically');
|
||||
});
|
||||
|
||||
test('sized element with transformed parent is centered in viewport', function() {
|
||||
var constrain = fixture('constrain-target');
|
||||
var el = Polymer.dom(constrain).querySelector('.el');
|
||||
var rectBefore = el.getBoundingClientRect();
|
||||
constrain.style.transform = 'translate3d(5px, 5px, 0)';
|
||||
el.center();
|
||||
var rectAfter = el.getBoundingClientRect();
|
||||
assert.equal(rectBefore.top, rectAfter.top, 'top ok');
|
||||
assert.equal(rectBefore.bottom, rectAfter.bottom, 'bottom ok');
|
||||
assert.equal(rectBefore.left, rectAfter.left, 'left ok');
|
||||
assert.equal(rectBefore.right, rectAfter.right, 'right ok');
|
||||
});
|
||||
|
||||
test('scrolling element is centered in viewport', function() {
|
||||
var el = fixture('sized-x');
|
||||
makeScrolling(el);
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.closeTo(rect.left - (window.innerWidth - rect.right), 0, 5, 'centered horizontally');
|
||||
assert.closeTo(rect.top - (window.innerHeight - rect.bottom), 0, 5, 'centered vertically');
|
||||
});
|
||||
|
||||
test('scrolling element is constrained to viewport height', function() {
|
||||
var el = fixture('sized-x');
|
||||
makeScrolling(el);
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isTrue(rect.height <= window.innerHeight, 'height is less than or equal to viewport height');
|
||||
});
|
||||
|
||||
test('scrolling element with offscreen container is constrained to viewport height', function() {
|
||||
var container = fixture('offscreen-container');
|
||||
var el = Polymer.dom(container).querySelector('.el')
|
||||
makeScrolling(el);
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isTrue(rect.height <= window.innerHeight, 'height is less than or equal to viewport height');
|
||||
});
|
||||
|
||||
test('scrolling element with max-height is centered in viewport', function() {
|
||||
var el = fixture('sized-x');
|
||||
el.classList.add('with-max-height');
|
||||
makeScrolling(el);
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.closeTo(rect.left - (window.innerWidth - rect.right), 0, 5, 'centered horizontally');
|
||||
assert.closeTo(rect.top - (window.innerHeight - rect.bottom), 0, 5, 'centered vertically');
|
||||
});
|
||||
|
||||
test('scrolling element with max-height respects max-height', function() {
|
||||
var el = fixture('sized-x');
|
||||
el.classList.add('with-max-height');
|
||||
makeScrolling(el);
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isTrue(rect.height <= 500, 'height is less than or equal to max-height');
|
||||
});
|
||||
|
||||
test('css positioned, scrolling element is constrained to viewport height (top,left)', function() {
|
||||
var el = fixture('positioned-xy');
|
||||
makeScrolling(el);
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isTrue(rect.height <= window.innerHeight - 100, 'height is less than or equal to viewport height');
|
||||
});
|
||||
|
||||
test('css positioned, scrolling element is constrained to viewport height (bottom, right)', function() {
|
||||
var el = fixture('sized-x');
|
||||
el.classList.add('positioned-bottom');
|
||||
el.classList.add('positioned-right');
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isTrue(rect.height <= window.innerHeight - 100, 'height is less than or equal to viewport height');
|
||||
});
|
||||
|
||||
test('sized, scrolling element with margin is centered in viewport', function() {
|
||||
var el = fixture('sized-x');
|
||||
el.classList.add('with-margin');
|
||||
makeScrolling(el);
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.closeTo(rect.left - (window.innerWidth - rect.right), 0, 5, 'centered horizontally');
|
||||
assert.closeTo(rect.top - (window.innerHeight - rect.bottom), 0, 5, 'centered vertically');
|
||||
});
|
||||
|
||||
test('sized, scrolling element is constrained to viewport height', function() {
|
||||
var el = fixture('sized-x');
|
||||
el.classList.add('with-margin');
|
||||
makeScrolling(el);
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isTrue(rect.height <= window.innerHeight - 20 * 2, 'height is less than or equal to viewport height');
|
||||
});
|
||||
|
||||
test('css positioned, scrolling element with margin is constrained to viewport height (top, left)', function() {
|
||||
var el = fixture('positioned-xy');
|
||||
el.classList.add('with-margin');
|
||||
makeScrolling(el);
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isTrue(rect.height <= window.innerHeight - 100 - 20 * 2, 'height is less than or equal to viewport height');
|
||||
});
|
||||
|
||||
test('css positioned, scrolling element with margin is constrained to viewport height (bottom, right)', function() {
|
||||
var el = fixture('sized-x');
|
||||
el.classList.add('positioned-bottom');
|
||||
el.classList.add('positioned-right');
|
||||
el.classList.add('with-margin')
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isTrue(rect.height <= window.innerHeight - 100 - 20 * 2, 'height is less than or equal to viewport height');
|
||||
});
|
||||
|
||||
test('scrolling sizingTarget is constrained to viewport height', function() {
|
||||
el = fixture('sectioned');
|
||||
var internal = Polymer.dom(el).querySelector('.internal');
|
||||
el.sizingTarget = internal;
|
||||
makeScrolling(internal);
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isTrue(rect.height <= window.innerHeight, 'height is less than or equal to viewport height');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite('fit to element', function() {
|
||||
|
||||
test('element fits in another element', function() {
|
||||
var constrain = fixture('constrain-target');
|
||||
var el = Polymer.dom(constrain).querySelector('.el')
|
||||
makeScrolling(el);
|
||||
el.fitInto = constrain;
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
var crect = constrain.getBoundingClientRect();
|
||||
assert.isTrue(rect.height <= crect.height, 'width is less than or equal to fitInto width');
|
||||
assert.isTrue(rect.height <= crect.height, 'height is less than or equal to fitInto height');
|
||||
});
|
||||
|
||||
test('element centers in another element', function() {
|
||||
var constrain = fixture('constrain-target');
|
||||
var el = Polymer.dom(constrain).querySelector('.el');
|
||||
makeScrolling(el);
|
||||
el.fitInto = constrain;
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
var crect = constrain.getBoundingClientRect();
|
||||
assert.closeTo(rect.left - crect.left - (crect.right - rect.right), 0, 5, 'centered horizontally in fitInto');
|
||||
assert.closeTo(rect.top - crect.top - (crect.bottom - rect.bottom), 0, 5, 'centered vertically in fitInto');
|
||||
});
|
||||
|
||||
test('element with max-width centers in another element', function() {
|
||||
var constrain = document.querySelector('.constrain');
|
||||
var el = fixture('sized-xy');
|
||||
el.classList.add('with-max-width');
|
||||
el.fitInto = constrain;
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
var crect = constrain.getBoundingClientRect();
|
||||
assert.closeTo(rect.left - crect.left - (crect.right - rect.right), 0, 5, 'centered horizontally in fitInto');
|
||||
assert.closeTo(rect.top - crect.top - (crect.bottom - rect.bottom), 0, 5, 'centered vertically in fitInto');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite('horizontal/vertical align', function() {
|
||||
var parent, parentRect;
|
||||
var el, elRect;
|
||||
var fitRect = {
|
||||
left: 0,
|
||||
top: 0,
|
||||
right: window.innerWidth,
|
||||
bottom: window.innerHeight,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight
|
||||
};
|
||||
|
||||
setup(function() {
|
||||
parent = fixture('constrain-target');
|
||||
parentRect = parent.getBoundingClientRect();
|
||||
el = Polymer.dom(parent).querySelector('.el');
|
||||
elRect = el.getBoundingClientRect();
|
||||
});
|
||||
|
||||
test('intersects works', function() {
|
||||
var base = {top: 0, bottom: 1, left:0, right: 1};
|
||||
assert.isTrue(intersects(base, base), 'intersects itself');
|
||||
assert.isFalse(intersects(base, {top:1, bottom: 2, left: 0, right: 1}), 'no intersect on edge');
|
||||
assert.isFalse(intersects(base, {top:-2, bottom: -1, left: 0, right: 1}), 'no intersect on edge (negative values)');
|
||||
assert.isFalse(intersects(base, {top:2, bottom: 3, left: 0, right: 1}), 'no intersect');
|
||||
});
|
||||
|
||||
suite('when verticalAlign is top', function() {
|
||||
test('element is aligned to the positionTarget top', function() {
|
||||
el.verticalAlign = 'top';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.top, parentRect.top, 'top ok');
|
||||
assert.equal(rect.height, elRect.height, 'no cropping');
|
||||
});
|
||||
|
||||
test('element is aligned to the positionTarget top without overlapping it', function() {
|
||||
// Allow enough space on the parent's bottom & right.
|
||||
parent.style.width = '10px';
|
||||
parent.style.height = '10px';
|
||||
parentRect = parent.getBoundingClientRect();
|
||||
el.verticalAlign = 'top';
|
||||
el.noOverlap = true;
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isFalse(intersects(rect, parentRect), 'no overlap');
|
||||
assert.equal(rect.height, elRect.height, 'no cropping');
|
||||
});
|
||||
|
||||
test('element margin is considered as offset', function() {
|
||||
el.verticalAlign = 'top';
|
||||
el.style.marginTop = '10px';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.top, parentRect.top + 10, 'top ok');
|
||||
assert.equal(rect.height, elRect.height, 'no cropping');
|
||||
|
||||
el.style.marginTop = '-10px';
|
||||
el.refit();
|
||||
rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.top, parentRect.top - 10, 'top ok');
|
||||
assert.equal(rect.height, elRect.height, 'no cropping');
|
||||
});
|
||||
|
||||
test('verticalOffset is applied', function() {
|
||||
el.verticalAlign = 'top';
|
||||
el.verticalOffset = 10;
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.top, parentRect.top + 10, 'top ok');
|
||||
assert.equal(rect.height, elRect.height, 'no cropping');
|
||||
});
|
||||
|
||||
test('max-height is updated', function() {
|
||||
parent.style.top = '-10px';
|
||||
el.verticalAlign = 'top';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.top, 0, 'top ok');
|
||||
assert.isBelow(rect.height, elRect.height, 'height ok');
|
||||
});
|
||||
|
||||
test('min-height is respected: element is hidden if does not have enough height', function() {
|
||||
parent.style.top = '-10px';
|
||||
el.verticalAlign = 'top';
|
||||
el.style.minHeight = elRect.height + 'px';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isFalse(intersects(rect, fitRect), 'not visible');
|
||||
});
|
||||
});
|
||||
|
||||
suite('when verticalAlign is bottom', function() {
|
||||
test('element is aligned to the positionTarget bottom', function() {
|
||||
el.verticalAlign = 'bottom';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.bottom, parentRect.bottom, 'bottom ok');
|
||||
assert.equal(rect.height, elRect.height, 'no cropping');
|
||||
});
|
||||
|
||||
test('element is aligned to the positionTarget bottom without overlapping it', function() {
|
||||
el.verticalAlign = 'bottom';
|
||||
el.noOverlap = true;
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isFalse(intersects(rect, parentRect), 'no overlap');
|
||||
assert.equal(rect.height, elRect.height, 'no cropping');
|
||||
});
|
||||
|
||||
test('element margin is considered as offset', function() {
|
||||
el.verticalAlign = 'bottom';
|
||||
el.style.marginBottom = '10px';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.bottom, parentRect.bottom - 10, 'bottom ok');
|
||||
assert.equal(rect.height, elRect.height, 'no cropping');
|
||||
|
||||
el.style.marginBottom = '-10px';
|
||||
el.refit();
|
||||
rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.bottom, parentRect.bottom + 10, 'bottom ok');
|
||||
assert.equal(rect.height, elRect.height, 'no cropping');
|
||||
});
|
||||
|
||||
test('verticalOffset is applied', function() {
|
||||
el.verticalAlign = 'bottom';
|
||||
el.verticalOffset = 10;
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.bottom, parentRect.bottom - 10, 'bottom ok');
|
||||
assert.equal(rect.height, elRect.height, 'no cropping');
|
||||
});
|
||||
|
||||
test('element max-height is updated', function() {
|
||||
parent.style.top = (100 - parentRect.height) + 'px';
|
||||
el.verticalAlign = 'bottom';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.bottom, 100, 'bottom ok');
|
||||
assert.equal(rect.height, 100, 'height ok');
|
||||
});
|
||||
|
||||
test('min-height is respected: element is hidden if does not have enough height', function() {
|
||||
parent.style.top = (elRect.height - 10 - parentRect.height) + 'px';
|
||||
el.verticalAlign = 'bottom';
|
||||
el.style.minHeight = elRect.height + 'px';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isFalse(intersects(rect, fitRect), 'not visible');
|
||||
});
|
||||
});
|
||||
|
||||
suite('when verticalAlign is auto', function() {
|
||||
test('element is aligned to the positionTarget top', function() {
|
||||
el.verticalAlign = 'auto';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.top, parentRect.top, 'auto aligned to top');
|
||||
assert.equal(rect.height, elRect.height, 'no cropping');
|
||||
});
|
||||
|
||||
test('element is aligned to the positionTarget top without overlapping it', function() {
|
||||
// Allow enough space on the parent's bottom & right.
|
||||
parent.style.width = '10px';
|
||||
parent.style.height = '10px';
|
||||
parentRect = parent.getBoundingClientRect();
|
||||
el.verticalAlign = 'auto';
|
||||
el.noOverlap = true;
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.height, elRect.height, 'no cropping');
|
||||
assert.isFalse(intersects(rect, parentRect), 'no overlap');
|
||||
});
|
||||
|
||||
test('bottom is preferred to top if it diminishes the cropped area', function() {
|
||||
// This would cause a cropping of the element, so it should automatically
|
||||
// align to the bottom to avoid it.
|
||||
parent.style.top = '-10px';
|
||||
parentRect = parent.getBoundingClientRect();
|
||||
el.verticalAlign = 'auto';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.bottom, parentRect.bottom, 'auto aligned to bottom');
|
||||
assert.equal(rect.height, elRect.height, 'no cropping');
|
||||
});
|
||||
|
||||
test('bottom is preferred to top if it diminishes the cropped area, without overlapping positionTarget', function() {
|
||||
// This would cause a cropping of the element, so it should automatically
|
||||
// align to the bottom to avoid it.
|
||||
parent.style.top = '-10px';
|
||||
parentRect = parent.getBoundingClientRect();
|
||||
el.verticalAlign = 'auto';
|
||||
el.noOverlap = true;
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.height, elRect.height, 'no cropping');
|
||||
assert.isFalse(intersects(rect, parentRect), 'no overlap');
|
||||
});
|
||||
});
|
||||
|
||||
suite('when horizontalAlign is left', function() {
|
||||
test('element is aligned to the positionTarget left', function() {
|
||||
el.horizontalAlign = 'left';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.left, parentRect.left, 'left ok');
|
||||
assert.equal(rect.width, elRect.width, 'no cropping');
|
||||
});
|
||||
|
||||
test('element is aligned to the positionTarget left without overlapping it', function() {
|
||||
// Make space at the parent's right.
|
||||
parent.style.width = '10px';
|
||||
parentRect = parent.getBoundingClientRect();
|
||||
el.horizontalAlign = 'left';
|
||||
el.noOverlap = true;
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isFalse(intersects(rect, parentRect), 'no overlap');
|
||||
assert.equal(rect.width, elRect.width, 'no cropping');
|
||||
});
|
||||
|
||||
test('element margin is considered as offset', function() {
|
||||
el.horizontalAlign = 'left';
|
||||
el.style.marginLeft = '10px';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.left, parentRect.left + 10, 'left ok');
|
||||
assert.equal(rect.width, elRect.width, 'no cropping');
|
||||
|
||||
el.style.marginLeft = '-10px';
|
||||
el.refit();
|
||||
rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.left, parentRect.left - 10, 'left ok');
|
||||
assert.equal(rect.width, elRect.width, 'no cropping');
|
||||
});
|
||||
|
||||
test('horizontalOffset is applied', function() {
|
||||
el.horizontalAlign = 'left';
|
||||
el.horizontalOffset = 10;
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.left, parentRect.left + 10, 'left ok');
|
||||
assert.equal(rect.width, elRect.width, 'no cropping');
|
||||
});
|
||||
|
||||
test('element max-width is updated', function() {
|
||||
parent.style.left = '-10px';
|
||||
el.horizontalAlign = 'left';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.left, 0, 'left ok');
|
||||
assert.isBelow(rect.width, elRect.width, 'width ok');
|
||||
});
|
||||
|
||||
test('min-width is respected: element is hidden if does not have enough width', function() {
|
||||
parent.style.left = '-10px';
|
||||
el.style.minWidth = elRect.width + 'px';
|
||||
el.horizontalAlign = 'left';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isFalse(intersects(rect, fitRect), 'not visible');
|
||||
});
|
||||
});
|
||||
|
||||
suite('when horizontalAlign is right', function() {
|
||||
test('element is aligned to the positionTarget right', function() {
|
||||
el.horizontalAlign = 'right';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.right, parentRect.right, 'right ok');
|
||||
assert.equal(rect.width, elRect.width, 'no cropping');
|
||||
});
|
||||
|
||||
test('element is aligned to the positionTarget right without overlapping it', function() {
|
||||
// Make space at the parent's left.
|
||||
parent.style.left = elRect.width + 'px';
|
||||
parentRect = parent.getBoundingClientRect();
|
||||
el.horizontalAlign = 'right';
|
||||
el.noOverlap = true;
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isFalse(intersects(rect, parentRect), 'no overlap');
|
||||
assert.equal(rect.width, elRect.width, 'no cropping');
|
||||
});
|
||||
|
||||
test('element margin is considered as offset', function() {
|
||||
el.horizontalAlign = 'right';
|
||||
el.style.marginRight = '10px';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.right, parentRect.right - 10, 'right ok');
|
||||
assert.equal(rect.width, elRect.width, 'no cropping');
|
||||
|
||||
el.style.marginRight = '-10px';
|
||||
el.refit();
|
||||
rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.right, parentRect.right + 10, 'right ok');
|
||||
assert.equal(rect.width, elRect.width, 'no cropping');
|
||||
});
|
||||
|
||||
test('horizontalOffset is applied', function() {
|
||||
el.horizontalAlign = 'right';
|
||||
el.horizontalOffset = 10;
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.right, parentRect.right - 10, 'right ok');
|
||||
assert.equal(rect.width, elRect.width, 'no cropping');
|
||||
});
|
||||
|
||||
test('element max-width is updated', function() {
|
||||
parent.style.left = (100 - parentRect.width) + 'px';
|
||||
el.horizontalAlign = 'right';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.right, 100, 'right ok');
|
||||
assert.equal(rect.width, 100, 'width ok');
|
||||
});
|
||||
|
||||
test('min-width is respected: element is hidden if does not have enough width', function() {
|
||||
parent.style.left = (elRect.width - 10 - parentRect.width) + 'px';
|
||||
el.horizontalAlign = 'right';
|
||||
el.style.minWidth = elRect.width + 'px';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.isFalse(intersects(rect, fitRect), 'not visible');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite('when horizontalAlign is auto', function() {
|
||||
test('element is aligned to the positionTarget left', function() {
|
||||
el.horizontalAlign = 'auto';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.left, parentRect.left, 'auto aligned to left');
|
||||
assert.equal(rect.width, elRect.width, 'no cropping');
|
||||
});
|
||||
|
||||
test('element is aligned to the positionTarget left without overlapping positionTarget', function() {
|
||||
// Make space at the parent's left.
|
||||
parent.style.left = elRect.width + 'px';
|
||||
parentRect = parent.getBoundingClientRect();
|
||||
el.horizontalAlign = 'auto';
|
||||
el.noOverlap = true;
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.width, elRect.width, 'no cropping');
|
||||
assert.isFalse(intersects(rect, parentRect), 'no overlap');
|
||||
});
|
||||
|
||||
test('right is preferred to left if it diminishes the cropped area', function() {
|
||||
// This would cause a cropping of the element, so it should automatically
|
||||
// align to the right to avoid it.
|
||||
parent.style.left = '-10px';
|
||||
parentRect = parent.getBoundingClientRect();
|
||||
el.horizontalAlign = 'auto';
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.right, parentRect.right, 'auto aligned to right');
|
||||
assert.equal(rect.width, elRect.width, 'no cropping');
|
||||
});
|
||||
|
||||
test('right is preferred to left if it diminishes the cropped area, without overlapping positionTarget', function() {
|
||||
// Make space at the parent's right.
|
||||
parent.style.width = '10px';
|
||||
parentRect = parent.getBoundingClientRect();
|
||||
el.horizontalAlign = 'auto';
|
||||
el.noOverlap = true;
|
||||
el.refit();
|
||||
var rect = el.getBoundingClientRect();
|
||||
assert.equal(rect.width, elRect.width, 'no cropping');
|
||||
assert.isFalse(intersects(rect, parentRect), 'no overlap');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,42 +0,0 @@
|
|||
<!--
|
||||
@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-fit-behavior.html">
|
||||
|
||||
<dom-module id="test-fit">
|
||||
|
||||
<style>
|
||||
:host {
|
||||
display: block;
|
||||
background: black;
|
||||
color: white;
|
||||
padding: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<content></content>
|
||||
</template>
|
||||
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
|
||||
Polymer({
|
||||
|
||||
is: 'test-fit',
|
||||
|
||||
behaviors: [
|
||||
Polymer.IronFitBehavior
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
</script>
|
|
@ -32,14 +32,14 @@
|
|||
"web-component-tester": "^4.0.0",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
},
|
||||
"homepage": "https://github.com/polymerelements/iron-icon",
|
||||
"homepage": "https://github.com/PolymerElements/iron-icon",
|
||||
"_release": "1.0.8",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.0.8",
|
||||
"commit": "f36b38928849ef3853db727faa8c9ef104d611eb"
|
||||
},
|
||||
"_source": "git://github.com/polymerelements/iron-icon.git",
|
||||
"_source": "git://github.com/PolymerElements/iron-icon.git",
|
||||
"_target": "^1.0.0",
|
||||
"_originalSource": "polymerelements/iron-icon"
|
||||
"_originalSource": "PolymerElements/iron-icon"
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
{
|
||||
"name": "iron-overlay-behavior",
|
||||
"version": "1.7.1",
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"description": "Provides a behavior for making an element an overlay",
|
||||
"private": true,
|
||||
"main": "iron-overlay-behavior.html",
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"polymer",
|
||||
"behavior",
|
||||
"overlay"
|
||||
],
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/PolymerElements/iron-overlay-behavior.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"iron-a11y-keys-behavior": "PolymerElements/iron-a11y-keys-behavior#^1.0.0",
|
||||
"iron-fit-behavior": "PolymerElements/iron-fit-behavior#^1.0.0",
|
||||
"iron-resizable-behavior": "PolymerElements/iron-resizable-behavior#^1.0.0",
|
||||
"polymer": "Polymer/polymer#^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
|
||||
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
|
||||
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0",
|
||||
"iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0",
|
||||
"paper-styles": "PolymerElements/paper-styles#^1.0.2",
|
||||
"web-component-tester": "^4.0.0",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
},
|
||||
"ignore": [],
|
||||
"homepage": "https://github.com/polymerelements/iron-overlay-behavior",
|
||||
"_release": "1.7.1",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.7.1",
|
||||
"commit": "4655445cb91e19ef3cdae247ded2ffc9f50b46a8"
|
||||
},
|
||||
"_source": "git://github.com/polymerelements/iron-overlay-behavior.git",
|
||||
"_target": "^1.0.0",
|
||||
"_originalSource": "polymerelements/iron-overlay-behavior"
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<!-- Instructions: https://github.com/PolymerElements/iron-overlay-behavior/CONTRIBUTING.md#filing-issues -->
|
||||
### Description
|
||||
<!-- Example: The `paper-foo` element causes the page to turn pink when clicked. -->
|
||||
|
||||
### Expected outcome
|
||||
|
||||
<!-- Example: The page stays the same color. -->
|
||||
|
||||
### Actual outcome
|
||||
|
||||
<!-- Example: The page turns pink. -->
|
||||
|
||||
### Live Demo
|
||||
<!-- Example: https://jsbin.com/cagaye/edit?html,output -->
|
||||
|
||||
### Steps to reproduce
|
||||
|
||||
<!-- Example
|
||||
1. Put a `paper-foo` element in the page.
|
||||
2. Open the page in a web browser.
|
||||
3. Click the `paper-foo` element.
|
||||
-->
|
||||
|
||||
### Browsers Affected
|
||||
<!-- Check all that apply -->
|
||||
- [ ] Chrome
|
||||
- [ ] Firefox
|
||||
- [ ] Safari 9
|
||||
- [ ] Safari 8
|
||||
- [ ] Safari 7
|
||||
- [ ] Edge
|
||||
- [ ] IE 11
|
||||
- [ ] IE 10
|
|
@ -1 +0,0 @@
|
|||
bower_components
|
|
@ -1,23 +0,0 @@
|
|||
language: node_js
|
||||
sudo: required
|
||||
before_script:
|
||||
- npm install -g bower polylint web-component-tester
|
||||
- bower install
|
||||
- polylint
|
||||
env:
|
||||
global:
|
||||
- secure: H8AA9JkWfG/vc3MiimoIoYi45KD10hKzitLJnExkomgzFI/f5o9SGtwjCii5P8Kvf4xndftDjYwRgbYyJpSg0IJeq8rm1WS89cY8O6/1dlI/tK1j5xbVRrhqmRQncxUb3K4MAT6Z9br1jwEeamRa+NKmq+v+VEpQY5vwuQ/BHJw=
|
||||
- secure: EaE1AUVgWyn0Y6kqkb54z5r39RvTJzAOmeM0lRl7wXzr5k0mq3VGlxTksJqCVd1PdJESXEhy8eldBnlkwZir/imDTNQxKm13k7ZiFC0000XAzpLZElkH2cLlYCRWcuM+vS7dA9hytV0UcGK2VGqbxfpcesB20dPSneDEUuc5X64=
|
||||
node_js: stable
|
||||
addons:
|
||||
firefox: latest
|
||||
apt:
|
||||
sources:
|
||||
- google-chrome
|
||||
packages:
|
||||
- google-chrome-stable
|
||||
sauce_connect: true
|
||||
script:
|
||||
- xvfb-run wct
|
||||
- "if [ \"${TRAVIS_PULL_REQUEST}\" = \"false\" ]; then wct -s 'default'; fi"
|
||||
dist: trusty
|
|
@ -1,77 +0,0 @@
|
|||
|
||||
<!--
|
||||
This file is autogenerated based on
|
||||
https://github.com/PolymerElements/ContributionGuide/blob/master/CONTRIBUTING.md
|
||||
|
||||
If you edit that file, it will get updated everywhere else.
|
||||
If you edit this file, your changes will get overridden :)
|
||||
|
||||
You can however override the jsbin link with one that's customized to this
|
||||
specific element:
|
||||
|
||||
jsbin=https://jsbin.com/cagaye/edit?html,output
|
||||
-->
|
||||
# Polymer Elements
|
||||
## Guide for Contributors
|
||||
|
||||
Polymer Elements are built in the open, and the Polymer authors eagerly encourage any and all forms of community contribution. When contributing, please follow these guidelines:
|
||||
|
||||
### Filing Issues
|
||||
|
||||
**If you are filing an issue to request a feature**, please provide a clear description of the feature. It can be helpful to describe answers to the following questions:
|
||||
|
||||
1. **Who will use the feature?** _“As someone filling out a form…”_
|
||||
2. **When will they use the feature?** _“When I enter an invalid value…”_
|
||||
3. **What is the user’s goal?** _“I want to be visually notified that the value needs to be corrected…”_
|
||||
|
||||
**If you are filing an issue to report a bug**, please provide:
|
||||
|
||||
1. **A clear description of the bug and related expectations.** Consider using the following example template for reporting a bug:
|
||||
|
||||
```markdown
|
||||
The `paper-foo` element causes the page to turn pink when clicked.
|
||||
|
||||
## Expected outcome
|
||||
|
||||
The page stays the same color.
|
||||
|
||||
## Actual outcome
|
||||
|
||||
The page turns pink.
|
||||
|
||||
## Steps to reproduce
|
||||
|
||||
1. Put a `paper-foo` element in the page.
|
||||
2. Open the page in a web browser.
|
||||
3. Click the `paper-foo` element.
|
||||
```
|
||||
|
||||
2. **A reduced test case that demonstrates the problem.** If possible, please include the test case as a JSBin. Start with this template to easily import and use relevant Polymer Elements: [https://jsbin.com/cagaye/edit?html,output](https://jsbin.com/cagaye/edit?html,output).
|
||||
|
||||
3. **A list of browsers where the problem occurs.** This can be skipped if the problem is the same across all browsers.
|
||||
|
||||
### Submitting Pull Requests
|
||||
|
||||
**Before creating a pull request**, please ensure that an issue exists for the corresponding change in the pull request that you intend to make. **If an issue does not exist, please create one per the guidelines above**. The goal is to discuss the design and necessity of the proposed change with Polymer authors and community before diving into a pull request.
|
||||
|
||||
When submitting pull requests, please provide:
|
||||
|
||||
1. **A reference to the corresponding issue** or issues that will be closed by the pull request. Please refer to these issues in the pull request description using the following syntax:
|
||||
|
||||
```markdown
|
||||
(For a single issue)
|
||||
Fixes #20
|
||||
|
||||
(For multiple issues)
|
||||
Fixes #32, fixes #40
|
||||
```
|
||||
|
||||
2. **A succinct description of the design** used to fix any related issues. For example:
|
||||
|
||||
```markdown
|
||||
This fixes #20 by removing styles that leaked which would cause the page to turn pink whenever `paper-foo` is clicked.
|
||||
```
|
||||
|
||||
3. **At least one test for each bug fixed or feature added** as part of the pull request. Pull requests that fix bugs or add features without accompanying tests will not be considered.
|
||||
|
||||
If a proposed change contains multiple commits, please [squash commits](https://www.google.com/url?q=http://blog.steveklabnik.com/posts/2012-11-08-how-to-squash-commits-in-a-github-pull-request) to as few as is necessary to succinctly express the change. A Polymer author can help you squash commits, so don’t be afraid to ask us if you need help with that!
|
|
@ -1,37 +0,0 @@
|
|||
{
|
||||
"name": "iron-overlay-behavior",
|
||||
"version": "1.7.1",
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"description": "Provides a behavior for making an element an overlay",
|
||||
"private": true,
|
||||
"main": "iron-overlay-behavior.html",
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"polymer",
|
||||
"behavior",
|
||||
"overlay"
|
||||
],
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/PolymerElements/iron-overlay-behavior.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"iron-a11y-keys-behavior": "PolymerElements/iron-a11y-keys-behavior#^1.0.0",
|
||||
"iron-fit-behavior": "PolymerElements/iron-fit-behavior#^1.0.0",
|
||||
"iron-resizable-behavior": "PolymerElements/iron-resizable-behavior#^1.0.0",
|
||||
"polymer": "Polymer/polymer#^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
|
||||
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
|
||||
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0",
|
||||
"iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0",
|
||||
"paper-styles": "PolymerElements/paper-styles#^1.0.2",
|
||||
"web-component-tester": "^4.0.0",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
},
|
||||
"ignore": []
|
||||
}
|
|
@ -1,179 +0,0 @@
|
|||
<!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>simple-overlay demo</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>
|
||||
|
||||
<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html">
|
||||
<link rel="import" href="simple-overlay.html">
|
||||
<link rel="import" href="../../iron-demo-helpers/demo-snippet.html">
|
||||
<link rel="import" href="../../iron-demo-helpers/demo-pages-shared-styles.html">
|
||||
|
||||
<style is="custom-style" include="demo-pages-shared-styles">
|
||||
demo-snippet {
|
||||
--demo-snippet-code: {
|
||||
max-height: 250px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body unresolved class="centered">
|
||||
|
||||
<h3>An element with <code>IronOverlayBehavior</code> can be opened, closed, toggled.</h3>
|
||||
<demo-snippet>
|
||||
<template>
|
||||
<button onclick="plain.open()">Plain overlay</button>
|
||||
<simple-overlay id="plain" tabindex=-1>
|
||||
<h2>Hello world!</h2>
|
||||
<p>This can be closed by pressing the ESC key too.</p>
|
||||
<button onclick="plain.close()">Close</button>
|
||||
</simple-overlay>
|
||||
</template>
|
||||
</demo-snippet>
|
||||
|
||||
<h3>Use <code>with-backdrop</code> to add a backdrop to your overlay. Tabbing will be trapped within the overlay.</h3>
|
||||
<demo-snippet>
|
||||
<template>
|
||||
<button onclick="backdrop.open()">Overlay with backdrop</button>
|
||||
<simple-overlay id="backdrop" with-backdrop>
|
||||
<p>Hello world!</p>
|
||||
<button>Button</button>
|
||||
<button onclick="backdrop.close()">Close</button>
|
||||
</simple-overlay>
|
||||
</template>
|
||||
</demo-snippet>
|
||||
|
||||
<h3>Use <code>restore-focus-on-close</code> to return the focus to the element that opened the overlay when it gets closed.</h3>
|
||||
<demo-snippet>
|
||||
<template>
|
||||
<button onclick="returnFocus.open()">Overlay that restores focus</button>
|
||||
<simple-overlay id="returnFocus" restore-focus-on-close>
|
||||
<p>Hello world!</p>
|
||||
<button onclick="returnFocus.close()">Close</button>
|
||||
</simple-overlay>
|
||||
</template>
|
||||
</demo-snippet>
|
||||
|
||||
<h3>The child with <code>autofocus</code> gets focused when opening the overlay.</h3>
|
||||
<demo-snippet>
|
||||
<template>
|
||||
<button onclick="withAutofocus.open()">Overlay with autofocus child</button>
|
||||
<simple-overlay id="withAutofocus">
|
||||
<p>Hello world!</p>
|
||||
<button autofocus>autofocus</button>
|
||||
<button onclick="withAutofocus.close()">Close</button>
|
||||
</simple-overlay>
|
||||
</template>
|
||||
</demo-snippet>
|
||||
|
||||
<h3>Multiple overlays can be opened.</h3>
|
||||
<demo-snippet>
|
||||
<template>
|
||||
<button onclick="multiple.open()">Open first overlay</button>
|
||||
<simple-overlay id="multiple" tabindex=-1>
|
||||
<p>click to open another overlay</p>
|
||||
<button onclick="multiple2.open()">Open second overlay</button>
|
||||
<button onclick="multiple.close()">Close this</button>
|
||||
</simple-overlay>
|
||||
<simple-overlay id="multiple2" tabindex=-1>
|
||||
<h2>Hi!</h2>
|
||||
<button onclick="multiple2.close()">Close</button>
|
||||
</simple-overlay>
|
||||
</template>
|
||||
</demo-snippet>
|
||||
|
||||
<h3>Use <code>always-on-top</code> to keep the overlay on top of others.</h3>
|
||||
<demo-snippet>
|
||||
<template>
|
||||
<button onclick="onTop.open()">Open always-on-top</button>
|
||||
<simple-overlay id="onTop" always-on-top tabindex=-1>
|
||||
<h2>Always on top</h2>
|
||||
<button onclick="backdrop2.open()">Open with backdrop</button>
|
||||
<button onclick="onTop.close()">Close this</button>
|
||||
</simple-overlay>
|
||||
<simple-overlay id="backdrop2" with-backdrop tabindex=-1>
|
||||
<h2>With backdrop</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>
|
||||
<button onclick="backdrop2.close()">Close</button>
|
||||
</simple-overlay>
|
||||
</template>
|
||||
</demo-snippet>
|
||||
|
||||
<h3>An element with <code>IronOverlayBehavior</code> can be scrollable or contain scrollable content.</h3>
|
||||
<demo-snippet>
|
||||
<template>
|
||||
<style>
|
||||
.with-margin {
|
||||
margin: 24px 40px;
|
||||
}
|
||||
.scrollable {
|
||||
max-height: 300px;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
<button onclick="scrolling.open()">Scrolling overlay</button>
|
||||
|
||||
<simple-overlay id="scrolling" class="with-margin scrollable" tabindex=-1>
|
||||
<h2>This dialog scrolls internally.</h2>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing 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 adipiscing 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 adipiscing 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 adipiscing 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 adipiscing 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>
|
||||
<button onclick="scrolling.close()">Close</button>
|
||||
</simple-overlay>
|
||||
|
||||
<button onclick="scrolling2.open()">Scrolling content</button>
|
||||
|
||||
<simple-overlay id="scrolling2" class="with-margin" tabindex=-1>
|
||||
<h2>This dialog has a scrolling child.</h2>
|
||||
<div class="scrollable">
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing 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 adipiscing 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 adipiscing 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 adipiscing 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 adipiscing 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>
|
||||
</div>
|
||||
<p>
|
||||
<button onclick="scrolling2.close()">Close</button>
|
||||
</p>
|
||||
|
||||
</simple-overlay>
|
||||
</template>
|
||||
</demo-snippet>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1,49 +0,0 @@
|
|||
<!--
|
||||
@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.html">
|
||||
|
||||
<dom-module id="simple-overlay">
|
||||
|
||||
<style>
|
||||
|
||||
:host {
|
||||
background: white;
|
||||
color: black;
|
||||
padding: 24px;
|
||||
box-shadow: rgba(0, 0, 0, 0.24) -2.3408942051048403px 5.524510324047423px 12.090680100755666px 0px, rgba(0, 0, 0, 0.12) 0px 0px 12px 0px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<content></content>
|
||||
</template>
|
||||
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
|
||||
(function() {
|
||||
|
||||
Polymer({
|
||||
|
||||
is: 'simple-overlay',
|
||||
|
||||
behaviors: [
|
||||
Polymer.IronOverlayBehavior
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
|
@ -1,30 +0,0 @@
|
|||
<!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>iron-overlay-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>
|
|
@ -1,168 +0,0 @@
|
|||
<!--
|
||||
@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">
|
||||
|
||||
<!--
|
||||
`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 | {}
|
||||
-->
|
||||
|
||||
<dom-module id="iron-overlay-backdrop">
|
||||
|
||||
<style>
|
||||
:host {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: var(--iron-overlay-backdrop-background-color, #000);
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s;
|
||||
pointer-events: none;
|
||||
@apply(--iron-overlay-backdrop);
|
||||
}
|
||||
|
||||
:host(.opened) {
|
||||
opacity: var(--iron-overlay-backdrop-opacity, 0.6);
|
||||
pointer-events: auto;
|
||||
@apply(--iron-overlay-backdrop-opened);
|
||||
}
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<content></content>
|
||||
</template>
|
||||
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
Polymer({
|
||||
|
||||
is: 'iron-overlay-backdrop',
|
||||
|
||||
properties: {
|
||||
|
||||
/**
|
||||
* Returns true if the backdrop is opened.
|
||||
*/
|
||||
opened: {
|
||||
reflectToAttribute: true,
|
||||
type: Boolean,
|
||||
value: false,
|
||||
observer: '_openedChanged'
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
listeners: {
|
||||
'transitionend': '_onTransitionend'
|
||||
},
|
||||
|
||||
created: function() {
|
||||
// Used to cancel previous requestAnimationFrame calls when opened changes.
|
||||
this.__openedRaf = null;
|
||||
},
|
||||
|
||||
attached: function() {
|
||||
this.opened && this._openedChanged(this.opened);
|
||||
},
|
||||
|
||||
/**
|
||||
* Appends the backdrop to document body if needed.
|
||||
*/
|
||||
prepare: function() {
|
||||
if (this.opened && !this.parentNode) {
|
||||
Polymer.dom(document.body).appendChild(this);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Shows the backdrop.
|
||||
*/
|
||||
open: function() {
|
||||
this.opened = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Hides the backdrop.
|
||||
*/
|
||||
close: function() {
|
||||
this.opened = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the backdrop from document body if needed.
|
||||
*/
|
||||
complete: function() {
|
||||
if (!this.opened && this.parentNode === document.body) {
|
||||
Polymer.dom(this.parentNode).removeChild(this);
|
||||
}
|
||||
},
|
||||
|
||||
_onTransitionend: function(event) {
|
||||
if (event && event.target === this) {
|
||||
this.complete();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {boolean} opened
|
||||
* @private
|
||||
*/
|
||||
_openedChanged: function(opened) {
|
||||
if (opened) {
|
||||
// Auto-attach.
|
||||
this.prepare();
|
||||
} else {
|
||||
// Animation might be disabled via the mixin or opacity custom property.
|
||||
// If it is disabled in other ways, it's up to the user to call complete.
|
||||
var cs = window.getComputedStyle(this);
|
||||
if (cs.transitionDuration === '0s' || cs.opacity == 0) {
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.isAttached) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Always cancel previous requestAnimationFrame.
|
||||
if (this.__openedRaf) {
|
||||
window.cancelAnimationFrame(this.__openedRaf);
|
||||
this.__openedRaf = null;
|
||||
}
|
||||
// Force relayout to ensure proper transitions.
|
||||
this.scrollTop = this.scrollTop;
|
||||
this.__openedRaf = window.requestAnimationFrame(function() {
|
||||
this.__openedRaf = null;
|
||||
this.toggleClass('opened', this.opened);
|
||||
}.bind(this));
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
|
@ -1,582 +0,0 @@
|
|||
<!--
|
||||
@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-fit-behavior/iron-fit-behavior.html">
|
||||
<link rel="import" href="../iron-resizable-behavior/iron-resizable-behavior.html">
|
||||
<link rel="import" href="iron-overlay-manager.html">
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
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.
|
||||
|
||||
### Closing and canceling
|
||||
|
||||
A dialog 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.
|
||||
|
||||
### Positioning
|
||||
|
||||
By default the element is sized and positioned to fit and centered inside the window. You can
|
||||
position and size it manually using CSS. See `Polymer.IronFitBehavior`.
|
||||
|
||||
### 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.
|
||||
|
||||
### 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.
|
||||
|
||||
@demo demo/index.html
|
||||
@polymerBehavior Polymer.IronOverlayBehavior
|
||||
*/
|
||||
|
||||
Polymer.IronOverlayBehaviorImpl = {
|
||||
|
||||
properties: {
|
||||
|
||||
/**
|
||||
* True if the overlay is currently displayed.
|
||||
*/
|
||||
opened: {
|
||||
observer: '_openedChanged',
|
||||
type: Boolean,
|
||||
value: false,
|
||||
notify: true
|
||||
},
|
||||
|
||||
/**
|
||||
* True if the overlay was canceled when it was last closed.
|
||||
*/
|
||||
canceled: {
|
||||
observer: '_canceledChanged',
|
||||
readOnly: true,
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Set to true to display a backdrop behind the overlay.
|
||||
*/
|
||||
withBackdrop: {
|
||||
observer: '_withBackdropChanged',
|
||||
type: Boolean
|
||||
},
|
||||
|
||||
/**
|
||||
* Set to true to disable auto-focusing the overlay or child nodes with
|
||||
* the `autofocus` attribute` when the overlay is opened.
|
||||
*/
|
||||
noAutoFocus: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Set to true to disable canceling the overlay with the ESC key.
|
||||
*/
|
||||
noCancelOnEscKey: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Set to true to disable canceling the overlay by clicking outside it.
|
||||
*/
|
||||
noCancelOnOutsideClick: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Contains the reason(s) this overlay was last closed (see `iron-overlay-closed`).
|
||||
* `IronOverlayBehavior` provides the `canceled` reason; implementers of the
|
||||
* behavior can provide other reasons in addition to `canceled`.
|
||||
*/
|
||||
closingReason: {
|
||||
// was a getter before, but needs to be a property so other
|
||||
// behaviors can override this.
|
||||
type: Object
|
||||
},
|
||||
|
||||
/**
|
||||
* Set to true to enable restoring of focus when overlay is closed.
|
||||
*/
|
||||
restoreFocusOnClose: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Set to true to keep overlay always on top.
|
||||
*/
|
||||
alwaysOnTop: {
|
||||
type: Boolean
|
||||
},
|
||||
|
||||
/**
|
||||
* Shortcut to access to the overlay manager.
|
||||
* @private
|
||||
* @type {Polymer.IronOverlayManagerClass}
|
||||
*/
|
||||
_manager: {
|
||||
type: Object,
|
||||
value: Polymer.IronOverlayManager
|
||||
},
|
||||
|
||||
/**
|
||||
* The node being focused.
|
||||
* @type {?Node}
|
||||
*/
|
||||
_focusedChild: {
|
||||
type: Object
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
listeners: {
|
||||
'iron-resize': '_onIronResize'
|
||||
},
|
||||
|
||||
/**
|
||||
* The backdrop element.
|
||||
* @type {Element}
|
||||
*/
|
||||
get backdropElement() {
|
||||
return this._manager.backdropElement;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the node to give focus to.
|
||||
* @type {Node}
|
||||
*/
|
||||
get _focusNode() {
|
||||
return this._focusedChild || Polymer.dom(this).querySelector('[autofocus]') || this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Array of nodes that can receive focus (overlay included), ordered by `tabindex`.
|
||||
* This is used to retrieve which is the first and last focusable nodes in order
|
||||
* to wrap the focus for overlays `with-backdrop`.
|
||||
*
|
||||
* If you know what is your content (specifically the first and last focusable children),
|
||||
* you can override this method to return only `[firstFocusable, lastFocusable];`
|
||||
* @type {Array<Node>}
|
||||
* @protected
|
||||
*/
|
||||
get _focusableNodes() {
|
||||
// Elements that can be focused even if they have [disabled] attribute.
|
||||
var FOCUSABLE_WITH_DISABLED = [
|
||||
'a[href]',
|
||||
'area[href]',
|
||||
'iframe',
|
||||
'[tabindex]',
|
||||
'[contentEditable=true]'
|
||||
];
|
||||
|
||||
// Elements that cannot be focused if they have [disabled] attribute.
|
||||
var FOCUSABLE_WITHOUT_DISABLED = [
|
||||
'input',
|
||||
'select',
|
||||
'textarea',
|
||||
'button'
|
||||
];
|
||||
|
||||
// Discard elements with tabindex=-1 (makes them not focusable).
|
||||
var selector = FOCUSABLE_WITH_DISABLED.join(':not([tabindex="-1"]),') +
|
||||
':not([tabindex="-1"]),' +
|
||||
FOCUSABLE_WITHOUT_DISABLED.join(':not([disabled]):not([tabindex="-1"]),') +
|
||||
':not([disabled]):not([tabindex="-1"])';
|
||||
|
||||
var focusables = Polymer.dom(this).querySelectorAll(selector);
|
||||
if (this.tabIndex >= 0) {
|
||||
// Insert at the beginning because we might have all elements with tabIndex = 0,
|
||||
// and the overlay should be the first of the list.
|
||||
focusables.splice(0, 0, this);
|
||||
}
|
||||
// Sort by tabindex.
|
||||
return focusables.sort(function (a, b) {
|
||||
if (a.tabIndex === b.tabIndex) {
|
||||
return 0;
|
||||
}
|
||||
if (a.tabIndex === 0 || a.tabIndex > b.tabIndex) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
});
|
||||
},
|
||||
|
||||
ready: function() {
|
||||
// Used to skip calls to notifyResize and refit while the overlay is animating.
|
||||
this.__isAnimating = false;
|
||||
// with-backdrop needs tabindex to be set in order to trap the focus.
|
||||
// If it is not set, IronOverlayBehavior will set it, and remove it if with-backdrop = false.
|
||||
this.__shouldRemoveTabIndex = false;
|
||||
// Used for wrapping the focus on TAB / Shift+TAB.
|
||||
this.__firstFocusableNode = this.__lastFocusableNode = null;
|
||||
// Used for requestAnimationFrame when opened changes.
|
||||
this.__openChangedAsync = null;
|
||||
// Used for requestAnimationFrame when iron-resize is fired.
|
||||
this.__onIronResizeAsync = null;
|
||||
this._ensureSetup();
|
||||
},
|
||||
|
||||
attached: function() {
|
||||
// Call _openedChanged here so that position can be computed correctly.
|
||||
if (this.opened) {
|
||||
this._openedChanged();
|
||||
}
|
||||
this._observer = Polymer.dom(this).observeNodes(this._onNodesChange);
|
||||
},
|
||||
|
||||
detached: function() {
|
||||
Polymer.dom(this).unobserveNodes(this._observer);
|
||||
this._observer = null;
|
||||
this.opened = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle the opened state of the overlay.
|
||||
*/
|
||||
toggle: function() {
|
||||
this._setCanceled(false);
|
||||
this.opened = !this.opened;
|
||||
},
|
||||
|
||||
/**
|
||||
* Open the overlay.
|
||||
*/
|
||||
open: function() {
|
||||
this._setCanceled(false);
|
||||
this.opened = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Close the overlay.
|
||||
*/
|
||||
close: function() {
|
||||
this._setCanceled(false);
|
||||
this.opened = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Cancels the overlay.
|
||||
* @param {Event=} event The original event
|
||||
*/
|
||||
cancel: function(event) {
|
||||
var cancelEvent = this.fire('iron-overlay-canceled', event, {cancelable: true});
|
||||
if (cancelEvent.defaultPrevented) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._setCanceled(true);
|
||||
this.opened = false;
|
||||
},
|
||||
|
||||
_ensureSetup: function() {
|
||||
if (this._overlaySetup) {
|
||||
return;
|
||||
}
|
||||
this._overlaySetup = true;
|
||||
this.style.outline = 'none';
|
||||
this.style.display = 'none';
|
||||
},
|
||||
|
||||
_openedChanged: function() {
|
||||
if (this.opened) {
|
||||
this.removeAttribute('aria-hidden');
|
||||
} else {
|
||||
this.setAttribute('aria-hidden', 'true');
|
||||
}
|
||||
|
||||
// wait to call after ready only if we're initially open
|
||||
if (!this._overlaySetup) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._manager.addOrRemoveOverlay(this);
|
||||
|
||||
if (this.__openChangedAsync) {
|
||||
window.cancelAnimationFrame(this.__openChangedAsync);
|
||||
}
|
||||
|
||||
// Defer any animation-related code on attached
|
||||
// (_openedChanged gets called again on attached).
|
||||
if (!this.isAttached) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.__isAnimating = true;
|
||||
|
||||
if (this.opened) {
|
||||
// requestAnimationFrame for non-blocking rendering
|
||||
this.__openChangedAsync = window.requestAnimationFrame(function() {
|
||||
this.__openChangedAsync = null;
|
||||
this._prepareRenderOpened();
|
||||
this._renderOpened();
|
||||
}.bind(this));
|
||||
} else {
|
||||
this._renderClosed();
|
||||
}
|
||||
},
|
||||
|
||||
_canceledChanged: function() {
|
||||
this.closingReason = this.closingReason || {};
|
||||
this.closingReason.canceled = this.canceled;
|
||||
},
|
||||
|
||||
_withBackdropChanged: function() {
|
||||
// If tabindex is already set, no need to override it.
|
||||
if (this.withBackdrop && !this.hasAttribute('tabindex')) {
|
||||
this.setAttribute('tabindex', '-1');
|
||||
this.__shouldRemoveTabIndex = true;
|
||||
} else if (this.__shouldRemoveTabIndex) {
|
||||
this.removeAttribute('tabindex');
|
||||
this.__shouldRemoveTabIndex = false;
|
||||
}
|
||||
if (this.opened) {
|
||||
this._manager.trackBackdrop();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* tasks which must occur before opening; e.g. making the element visible.
|
||||
* @protected
|
||||
*/
|
||||
_prepareRenderOpened: function() {
|
||||
|
||||
// Needed to calculate the size of the overlay so that transitions on its size
|
||||
// will have the correct starting points.
|
||||
this._preparePositioning();
|
||||
this.refit();
|
||||
this._finishPositioning();
|
||||
|
||||
// Safari will apply the focus to the autofocus element when displayed for the first time,
|
||||
// so we blur it. Later, _applyFocus will set the focus if necessary.
|
||||
if (this.noAutoFocus && document.activeElement === this._focusNode) {
|
||||
this._focusNode.blur();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Tasks which cause the overlay to actually open; typically play an animation.
|
||||
* @protected
|
||||
*/
|
||||
_renderOpened: function() {
|
||||
this._finishRenderOpened();
|
||||
},
|
||||
|
||||
/**
|
||||
* Tasks which cause the overlay to actually close; typically play an animation.
|
||||
* @protected
|
||||
*/
|
||||
_renderClosed: function() {
|
||||
this._finishRenderClosed();
|
||||
},
|
||||
|
||||
/**
|
||||
* Tasks to be performed at the end of open action. Will fire `iron-overlay-opened`.
|
||||
* @protected
|
||||
*/
|
||||
_finishRenderOpened: function() {
|
||||
// Focus the child node with [autofocus]
|
||||
this._applyFocus();
|
||||
|
||||
this.notifyResize();
|
||||
this.__isAnimating = false;
|
||||
this.fire('iron-overlay-opened');
|
||||
},
|
||||
|
||||
/**
|
||||
* Tasks to be performed at the end of close action. Will fire `iron-overlay-closed`.
|
||||
* @protected
|
||||
*/
|
||||
_finishRenderClosed: function() {
|
||||
// Hide the overlay and remove the backdrop.
|
||||
this.style.display = 'none';
|
||||
// Reset z-index only at the end of the animation.
|
||||
this.style.zIndex = '';
|
||||
|
||||
this._applyFocus();
|
||||
|
||||
this.notifyResize();
|
||||
this.__isAnimating = false;
|
||||
this.fire('iron-overlay-closed', this.closingReason);
|
||||
},
|
||||
|
||||
_preparePositioning: function() {
|
||||
this.style.transition = this.style.webkitTransition = 'none';
|
||||
this.style.transform = this.style.webkitTransform = 'none';
|
||||
this.style.display = '';
|
||||
},
|
||||
|
||||
_finishPositioning: function() {
|
||||
// First, make it invisible & reactivate animations.
|
||||
this.style.display = 'none';
|
||||
// Force reflow before re-enabling animations so that they don't start.
|
||||
// Set scrollTop to itself so that Closure Compiler doesn't remove this.
|
||||
this.scrollTop = this.scrollTop;
|
||||
this.style.transition = this.style.webkitTransition = '';
|
||||
this.style.transform = this.style.webkitTransform = '';
|
||||
// Now that animations are enabled, make it visible again
|
||||
this.style.display = '';
|
||||
// Force reflow, so that following animations are properly started.
|
||||
// Set scrollTop to itself so that Closure Compiler doesn't remove this.
|
||||
this.scrollTop = this.scrollTop;
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies focus according to the opened state.
|
||||
* @protected
|
||||
*/
|
||||
_applyFocus: function() {
|
||||
if (this.opened) {
|
||||
if (!this.noAutoFocus) {
|
||||
this._focusNode.focus();
|
||||
}
|
||||
} else {
|
||||
this._focusNode.blur();
|
||||
this._focusedChild = null;
|
||||
this._manager.focusOverlay();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Cancels (closes) the overlay. Call when click happens outside the overlay.
|
||||
* @param {!Event} event
|
||||
* @protected
|
||||
*/
|
||||
_onCaptureClick: function(event) {
|
||||
if (!this.noCancelOnOutsideClick) {
|
||||
this.cancel(event);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Keeps track of the focused child. If withBackdrop, traps focus within overlay.
|
||||
* @param {!Event} event
|
||||
* @protected
|
||||
*/
|
||||
_onCaptureFocus: function (event) {
|
||||
if (!this.withBackdrop) {
|
||||
return;
|
||||
}
|
||||
var path = Polymer.dom(event).path;
|
||||
if (path.indexOf(this) === -1) {
|
||||
event.stopPropagation();
|
||||
this._applyFocus();
|
||||
} else {
|
||||
this._focusedChild = path[0];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles the ESC key event and cancels (closes) the overlay.
|
||||
* @param {!Event} event
|
||||
* @protected
|
||||
*/
|
||||
_onCaptureEsc: function(event) {
|
||||
if (!this.noCancelOnEscKey) {
|
||||
this.cancel(event);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles TAB key events to track focus changes.
|
||||
* Will wrap focus for overlays withBackdrop.
|
||||
* @param {!Event} event
|
||||
* @protected
|
||||
*/
|
||||
_onCaptureTab: function(event) {
|
||||
// TAB wraps from last to first focusable.
|
||||
// Shift + TAB wraps from first to last focusable.
|
||||
var shift = event.shiftKey;
|
||||
var nodeToCheck = shift ? this.__firstFocusableNode : this.__lastFocusableNode;
|
||||
var nodeToSet = shift ? this.__lastFocusableNode : this.__firstFocusableNode;
|
||||
if (this.withBackdrop && this._focusedChild === nodeToCheck) {
|
||||
// We set here the _focusedChild so that _onCaptureFocus will handle the
|
||||
// wrapping of the focus (the next event after tab is focus).
|
||||
this._focusedChild = nodeToSet;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Refits if the overlay is opened and not animating.
|
||||
* @protected
|
||||
*/
|
||||
_onIronResize: function() {
|
||||
if (this.__onIronResizeAsync) {
|
||||
window.cancelAnimationFrame(this.__onIronResizeAsync);
|
||||
this.__onIronResizeAsync = null;
|
||||
}
|
||||
if (this.opened && !this.__isAnimating) {
|
||||
this.__onIronResizeAsync = window.requestAnimationFrame(function() {
|
||||
this.__onIronResizeAsync = null;
|
||||
this.refit();
|
||||
}.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Will call notifyResize if overlay is opened.
|
||||
* Can be overridden in order to avoid multiple observers on the same node.
|
||||
* @protected
|
||||
*/
|
||||
_onNodesChange: function() {
|
||||
if (this.opened && !this.__isAnimating) {
|
||||
this.notifyResize();
|
||||
}
|
||||
// Store it so we don't query too much.
|
||||
var focusableNodes = this._focusableNodes;
|
||||
this.__firstFocusableNode = focusableNodes[0];
|
||||
this.__lastFocusableNode = focusableNodes[focusableNodes.length - 1];
|
||||
}
|
||||
};
|
||||
|
||||
/** @polymerBehavior */
|
||||
Polymer.IronOverlayBehavior = [Polymer.IronFitBehavior, Polymer.IronResizableBehavior, Polymer.IronOverlayBehaviorImpl];
|
||||
|
||||
/**
|
||||
* Fired after the overlay opens.
|
||||
* @event iron-overlay-opened
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fired when the overlay is canceled, but before it is closed.
|
||||
* @event iron-overlay-canceled
|
||||
* @param {Event} event The closing of the overlay can be prevented
|
||||
* by calling `event.preventDefault()`. The `event.detail` is the original event that
|
||||
* originated the canceling (e.g. ESC keyboard event or click event outside the overlay).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fired after the overlay closes.
|
||||
* @event iron-overlay-closed
|
||||
* @param {Event} event The `event.detail` is the `closingReason` property
|
||||
* (contains `canceled`, whether the overlay was canceled).
|
||||
*/
|
||||
|
||||
})();
|
||||
</script>
|
|
@ -1,402 +0,0 @@
|
|||
<!--
|
||||
@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-a11y-keys-behavior/iron-a11y-keys-behavior.html">
|
||||
<link rel="import" href="iron-overlay-backdrop.html">
|
||||
|
||||
<script>
|
||||
|
||||
/**
|
||||
* @struct
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
Polymer.IronOverlayManagerClass = function() {
|
||||
/**
|
||||
* Used to keep track of the opened overlays.
|
||||
* @private {Array<Element>}
|
||||
*/
|
||||
this._overlays = [];
|
||||
|
||||
/**
|
||||
* iframes have a default z-index of 100,
|
||||
* so this default should be at least that.
|
||||
* @private {number}
|
||||
*/
|
||||
this._minimumZ = 101;
|
||||
|
||||
/**
|
||||
* Memoized backdrop element.
|
||||
* @private {Element|null}
|
||||
*/
|
||||
this._backdropElement = null;
|
||||
|
||||
// Listen to mousedown or touchstart to be sure to be the first to capture
|
||||
// clicks outside the overlay.
|
||||
var clickEvent = ('ontouchstart' in window) ? 'touchstart' : 'mousedown';
|
||||
document.addEventListener(clickEvent, this._onCaptureClick.bind(this), true);
|
||||
document.addEventListener('focus', this._onCaptureFocus.bind(this), true);
|
||||
document.addEventListener('keydown', this._onCaptureKeyDown.bind(this), true);
|
||||
};
|
||||
|
||||
Polymer.IronOverlayManagerClass.prototype = {
|
||||
|
||||
constructor: Polymer.IronOverlayManagerClass,
|
||||
|
||||
/**
|
||||
* The shared backdrop element.
|
||||
* @type {!Element} backdropElement
|
||||
*/
|
||||
get backdropElement() {
|
||||
if (!this._backdropElement) {
|
||||
this._backdropElement = document.createElement('iron-overlay-backdrop');
|
||||
}
|
||||
return this._backdropElement;
|
||||
},
|
||||
|
||||
/**
|
||||
* The deepest active element.
|
||||
* @type {!Element} activeElement the active element
|
||||
*/
|
||||
get deepActiveElement() {
|
||||
// document.activeElement can be null
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Document/activeElement
|
||||
// In case of null, default it to document.body.
|
||||
var active = document.activeElement || document.body;
|
||||
while (active.root && Polymer.dom(active.root).activeElement) {
|
||||
active = Polymer.dom(active.root).activeElement;
|
||||
}
|
||||
return active;
|
||||
},
|
||||
|
||||
/**
|
||||
* Brings the overlay at the specified index to the front.
|
||||
* @param {number} i
|
||||
* @private
|
||||
*/
|
||||
_bringOverlayAtIndexToFront: function(i) {
|
||||
var overlay = this._overlays[i];
|
||||
if (!overlay) {
|
||||
return;
|
||||
}
|
||||
var lastI = this._overlays.length - 1;
|
||||
var currentOverlay = this._overlays[lastI];
|
||||
// Ensure always-on-top overlay stays on top.
|
||||
if (currentOverlay && this._shouldBeBehindOverlay(overlay, currentOverlay)) {
|
||||
lastI--;
|
||||
}
|
||||
// If already the top element, return.
|
||||
if (i >= lastI) {
|
||||
return;
|
||||
}
|
||||
// Update z-index to be on top.
|
||||
var minimumZ = Math.max(this.currentOverlayZ(), this._minimumZ);
|
||||
if (this._getZ(overlay) <= minimumZ) {
|
||||
this._applyOverlayZ(overlay, minimumZ);
|
||||
}
|
||||
|
||||
// Shift other overlays behind the new on top.
|
||||
while (i < lastI) {
|
||||
this._overlays[i] = this._overlays[i + 1];
|
||||
i++;
|
||||
}
|
||||
this._overlays[lastI] = overlay;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds the overlay and updates its z-index if it's opened, or removes it if it's closed.
|
||||
* Also updates the backdrop z-index.
|
||||
* @param {!Element} overlay
|
||||
*/
|
||||
addOrRemoveOverlay: function(overlay) {
|
||||
if (overlay.opened) {
|
||||
this.addOverlay(overlay);
|
||||
} else {
|
||||
this.removeOverlay(overlay);
|
||||
}
|
||||
this.trackBackdrop();
|
||||
},
|
||||
|
||||
/**
|
||||
* Tracks overlays for z-index and focus management.
|
||||
* Ensures the last added overlay with always-on-top remains on top.
|
||||
* @param {!Element} overlay
|
||||
*/
|
||||
addOverlay: function(overlay) {
|
||||
var i = this._overlays.indexOf(overlay);
|
||||
if (i >= 0) {
|
||||
this._bringOverlayAtIndexToFront(i);
|
||||
return;
|
||||
}
|
||||
var insertionIndex = this._overlays.length;
|
||||
var currentOverlay = this._overlays[insertionIndex - 1];
|
||||
var minimumZ = Math.max(this._getZ(currentOverlay), this._minimumZ);
|
||||
var newZ = this._getZ(overlay);
|
||||
|
||||
// Ensure always-on-top overlay stays on top.
|
||||
if (currentOverlay && this._shouldBeBehindOverlay(overlay, currentOverlay)) {
|
||||
// This bumps the z-index of +2.
|
||||
this._applyOverlayZ(currentOverlay, minimumZ);
|
||||
insertionIndex--;
|
||||
// Update minimumZ to match previous overlay's z-index.
|
||||
var previousOverlay = this._overlays[insertionIndex - 1];
|
||||
minimumZ = Math.max(this._getZ(previousOverlay), this._minimumZ);
|
||||
}
|
||||
|
||||
// Update z-index and insert overlay.
|
||||
if (newZ <= minimumZ) {
|
||||
this._applyOverlayZ(overlay, minimumZ);
|
||||
}
|
||||
this._overlays.splice(insertionIndex, 0, overlay);
|
||||
|
||||
// Get focused node.
|
||||
var element = this.deepActiveElement;
|
||||
overlay.restoreFocusNode = this._overlayParent(element) ? null : element;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {!Element} overlay
|
||||
*/
|
||||
removeOverlay: function(overlay) {
|
||||
var i = this._overlays.indexOf(overlay);
|
||||
if (i === -1) {
|
||||
return;
|
||||
}
|
||||
this._overlays.splice(i, 1);
|
||||
|
||||
var node = overlay.restoreFocusOnClose ? overlay.restoreFocusNode : null;
|
||||
overlay.restoreFocusNode = null;
|
||||
// Focus back only if still contained in document.body
|
||||
if (node && Polymer.dom(document.body).deepContains(node)) {
|
||||
node.focus();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the current overlay.
|
||||
* @return {Element|undefined}
|
||||
*/
|
||||
currentOverlay: function() {
|
||||
var i = this._overlays.length - 1;
|
||||
return this._overlays[i];
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the current overlay z-index.
|
||||
* @return {number}
|
||||
*/
|
||||
currentOverlayZ: function() {
|
||||
return this._getZ(this.currentOverlay());
|
||||
},
|
||||
|
||||
/**
|
||||
* Ensures that the minimum z-index of new overlays is at least `minimumZ`.
|
||||
* This does not effect the z-index of any existing overlays.
|
||||
* @param {number} minimumZ
|
||||
*/
|
||||
ensureMinimumZ: function(minimumZ) {
|
||||
this._minimumZ = Math.max(this._minimumZ, minimumZ);
|
||||
},
|
||||
|
||||
focusOverlay: function() {
|
||||
var current = /** @type {?} */ (this.currentOverlay());
|
||||
// We have to be careful to focus the next overlay _after_ any current
|
||||
// transitions are complete (due to the state being toggled prior to the
|
||||
// transition). Otherwise, we risk infinite recursion when a transitioning
|
||||
// (closed) overlay becomes the current overlay.
|
||||
//
|
||||
// NOTE: We make the assumption that any overlay that completes a transition
|
||||
// will call into focusOverlay to kick the process back off. Currently:
|
||||
// transitionend -> _applyFocus -> focusOverlay.
|
||||
if (current && !current.transitioning) {
|
||||
current._applyFocus();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the backdrop z-index.
|
||||
*/
|
||||
trackBackdrop: function() {
|
||||
var overlay = this._overlayWithBackdrop();
|
||||
// Avoid creating the backdrop if there is no overlay with backdrop.
|
||||
if (!overlay && !this._backdropElement) {
|
||||
return;
|
||||
}
|
||||
this.backdropElement.style.zIndex = this._getZ(overlay) - 1;
|
||||
this.backdropElement.opened = !!overlay;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {Array<Element>}
|
||||
*/
|
||||
getBackdrops: function() {
|
||||
var backdrops = [];
|
||||
for (var i = 0; i < this._overlays.length; i++) {
|
||||
if (this._overlays[i].withBackdrop) {
|
||||
backdrops.push(this._overlays[i]);
|
||||
}
|
||||
}
|
||||
return backdrops;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the z-index for the backdrop.
|
||||
* @return {number}
|
||||
*/
|
||||
backdropZ: function() {
|
||||
return this._getZ(this._overlayWithBackdrop()) - 1;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the first opened overlay that has a backdrop.
|
||||
* @return {Element|undefined}
|
||||
* @private
|
||||
*/
|
||||
_overlayWithBackdrop: function() {
|
||||
for (var i = 0; i < this._overlays.length; i++) {
|
||||
if (this._overlays[i].withBackdrop) {
|
||||
return this._overlays[i];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Calculates the minimum z-index for the overlay.
|
||||
* @param {Element=} overlay
|
||||
* @private
|
||||
*/
|
||||
_getZ: function(overlay) {
|
||||
var z = this._minimumZ;
|
||||
if (overlay) {
|
||||
var z1 = Number(overlay.style.zIndex || window.getComputedStyle(overlay).zIndex);
|
||||
// Check if is a number
|
||||
// Number.isNaN not supported in IE 10+
|
||||
if (z1 === z1) {
|
||||
z = z1;
|
||||
}
|
||||
}
|
||||
return z;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {!Element} element
|
||||
* @param {number|string} z
|
||||
* @private
|
||||
*/
|
||||
_setZ: function(element, z) {
|
||||
element.style.zIndex = z;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {!Element} overlay
|
||||
* @param {number} aboveZ
|
||||
* @private
|
||||
*/
|
||||
_applyOverlayZ: function(overlay, aboveZ) {
|
||||
this._setZ(overlay, aboveZ + 2);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the overlay containing the provided node. If the node is an overlay,
|
||||
* it returns the node.
|
||||
* @param {Element=} node
|
||||
* @return {Element|undefined}
|
||||
* @private
|
||||
*/
|
||||
_overlayParent: function(node) {
|
||||
while (node && node !== document.body) {
|
||||
// Check if it is an overlay.
|
||||
if (node._manager === this) {
|
||||
return node;
|
||||
}
|
||||
// Use logical parentNode, or native ShadowRoot host.
|
||||
node = Polymer.dom(node).parentNode || node.host;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the deepest overlay in the path.
|
||||
* @param {Array<Element>=} path
|
||||
* @return {Element|undefined}
|
||||
* @private
|
||||
*/
|
||||
_overlayInPath: function(path) {
|
||||
path = path || [];
|
||||
for (var i = 0; i < path.length; i++) {
|
||||
if (path[i]._manager === this) {
|
||||
return path[i];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Ensures the click event is delegated to the right overlay.
|
||||
* @param {!Event} event
|
||||
* @private
|
||||
*/
|
||||
_onCaptureClick: function(event) {
|
||||
var overlay = /** @type {?} */ (this.currentOverlay());
|
||||
// Check if clicked outside of top overlay.
|
||||
if (overlay && this._overlayInPath(Polymer.dom(event).path) !== overlay) {
|
||||
if (overlay.withBackdrop) {
|
||||
// There's no need to stop the propagation as the backdrop element
|
||||
// already got this mousedown/touchstart event. Calling preventDefault
|
||||
// on this event ensures that click/tap won't be triggered at all.
|
||||
event.preventDefault();
|
||||
}
|
||||
overlay._onCaptureClick(event);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Ensures the focus event is delegated to the right overlay.
|
||||
* @param {!Event} event
|
||||
* @private
|
||||
*/
|
||||
_onCaptureFocus: function(event) {
|
||||
var overlay = /** @type {?} */ (this.currentOverlay());
|
||||
if (overlay) {
|
||||
overlay._onCaptureFocus(event);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Ensures TAB and ESC keyboard events are delegated to the right overlay.
|
||||
* @param {!Event} event
|
||||
* @private
|
||||
*/
|
||||
_onCaptureKeyDown: function(event) {
|
||||
var overlay = /** @type {?} */ (this.currentOverlay());
|
||||
if (overlay) {
|
||||
if (Polymer.IronA11yKeysBehavior.keyboardEventMatchesKeys(event, 'esc')) {
|
||||
overlay._onCaptureEsc(event);
|
||||
} else if (Polymer.IronA11yKeysBehavior.keyboardEventMatchesKeys(event, 'tab')) {
|
||||
overlay._onCaptureTab(event);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns if the overlay1 should be behind overlay2.
|
||||
* @param {!Element} overlay1
|
||||
* @param {!Element} overlay2
|
||||
* @return {boolean}
|
||||
* @private
|
||||
*/
|
||||
_shouldBeBehindOverlay: function(overlay1, overlay2) {
|
||||
var o1 = /** @type {?} */ (overlay1);
|
||||
var o2 = /** @type {?} */ (overlay2);
|
||||
return !o1.alwaysOnTop && o2.alwaysOnTop;
|
||||
}
|
||||
};
|
||||
|
||||
Polymer.IronOverlayManager = new Polymer.IronOverlayManagerClass();
|
||||
</script>
|
|
@ -1,31 +0,0 @@
|
|||
<!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>iron-overlay-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="../../web-component-tester/browser.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script>
|
||||
WCT.loadSuites([
|
||||
'iron-overlay-behavior.html',
|
||||
'iron-overlay-behavior.html?dom=shadow',
|
||||
'iron-overlay-backdrop.html',
|
||||
'iron-overlay-backdrop.html?dom=shadow',
|
||||
]);
|
||||
</script>
|
||||
|
||||
</body></html>
|
|
@ -1,94 +0,0 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
@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
|
||||
-->
|
||||
<html>
|
||||
|
||||
<head>
|
||||
|
||||
<title>iron-overlay-backdrop 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>
|
||||
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
|
||||
<link rel="import" href="test-overlay.html">
|
||||
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
.sizer {
|
||||
width: 4000px;
|
||||
height: 5000px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style is="custom-style">
|
||||
iron-overlay-backdrop {
|
||||
/* For quicker tests */
|
||||
--iron-overlay-backdrop: {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="sizer"></div>
|
||||
|
||||
<test-fixture id="backdrop">
|
||||
<template>
|
||||
<test-overlay with-backdrop>
|
||||
Overlay with backdrop
|
||||
</test-overlay>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
function runAfterOpen(overlay, callback) {
|
||||
overlay.addEventListener('iron-overlay-opened', callback);
|
||||
overlay.open();
|
||||
}
|
||||
|
||||
suite('overlay with backdrop', function() {
|
||||
var overlay;
|
||||
|
||||
setup(function() {
|
||||
overlay = fixture('backdrop');
|
||||
});
|
||||
|
||||
test('backdrop size matches parent size', function(done) {
|
||||
runAfterOpen(overlay, function() {
|
||||
Polymer.Base.async(function() {
|
||||
var backdrop = overlay.backdropElement;
|
||||
var parent = backdrop.parentElement;
|
||||
assert.strictEqual(backdrop.offsetWidth, parent.clientWidth, 'backdrop width matches parent width');
|
||||
assert.strictEqual(backdrop.offsetHeight, parent.clientHeight, 'backdrop height matches parent height');
|
||||
done();
|
||||
}, 1);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
File diff suppressed because it is too large
Load diff
|
@ -1,40 +0,0 @@
|
|||
<!--
|
||||
@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">
|
||||
|
||||
<dom-module id="test-buttons">
|
||||
|
||||
<style>
|
||||
|
||||
:host {
|
||||
border: 1px solid black;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<button id="button0">button0</button>
|
||||
<button id="button1">button1</button>
|
||||
<button id="button2">button2</button>
|
||||
</template>
|
||||
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
|
||||
(function() {
|
||||
Polymer({
|
||||
is: 'test-buttons'
|
||||
});
|
||||
})();
|
||||
|
||||
</script>
|
|
@ -1,36 +0,0 @@
|
|||
<!--
|
||||
@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
|
||||
-->
|
||||
|
||||
<link rel="import" href="../../polymer/polymer.html">
|
||||
<link rel="import" href="test-overlay.html">
|
||||
|
||||
<dom-module id="test-menu-button">
|
||||
|
||||
<template>
|
||||
<button id="trigger" on-click="toggle">Open</button>
|
||||
<test-overlay id="dropdown">
|
||||
<content></content>
|
||||
</test-overlay>
|
||||
</template>
|
||||
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
|
||||
(function() {
|
||||
Polymer({
|
||||
is: 'test-menu-button',
|
||||
toggle: function() {
|
||||
this.$.dropdown.toggle();
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
</script>
|
|
@ -1,102 +0,0 @@
|
|||
<!--
|
||||
@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.html">
|
||||
|
||||
<dom-module id="test-overlay">
|
||||
|
||||
<style>
|
||||
:host {
|
||||
background: white;
|
||||
color: black;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
:host([animated]) {
|
||||
-webkit-transition: -webkit-transform 0.3s;
|
||||
transition: transform 0.3s;
|
||||
-webkit-transform: translateY(300px);
|
||||
transform: translateY(300px);
|
||||
}
|
||||
|
||||
:host(.opened[animated]) {
|
||||
-webkit-transform: translateY(0px);
|
||||
transform: translateY(0px);
|
||||
}
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<content></content>
|
||||
</template>
|
||||
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
|
||||
Polymer({
|
||||
|
||||
is: 'test-overlay',
|
||||
|
||||
properties: {
|
||||
animated: {
|
||||
type: Boolean,
|
||||
reflectToAttribute: true
|
||||
}
|
||||
},
|
||||
|
||||
behaviors: [
|
||||
Polymer.IronOverlayBehavior
|
||||
],
|
||||
|
||||
listeners: {
|
||||
'transitionend': '__onTransitionEnd'
|
||||
},
|
||||
|
||||
_renderOpened: function() {
|
||||
if (this.animated) {
|
||||
if (this.withBackdrop) {
|
||||
this.backdropElement.open();
|
||||
}
|
||||
this.classList.add('opened');
|
||||
this.fire('simple-overlay-open-animation-start');
|
||||
} else {
|
||||
Polymer.IronOverlayBehaviorImpl._renderOpened.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
|
||||
_renderClosed: function() {
|
||||
if (this.animated) {
|
||||
if (this.withBackdrop) {
|
||||
this.backdropElement.close();
|
||||
}
|
||||
this.classList.remove('opened');
|
||||
this.fire('simple-overlay-close-animation-start');
|
||||
} else {
|
||||
Polymer.IronOverlayBehaviorImpl._renderClosed.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
|
||||
__onTransitionEnd: function(e) {
|
||||
if (e && e.target === this) {
|
||||
if (this.opened) {
|
||||
this._finishRenderOpened();
|
||||
} else {
|
||||
this._finishRenderClosed();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
})();
|
||||
</script>
|
|
@ -1,49 +0,0 @@
|
|||
<!--
|
||||
@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.html">
|
||||
|
||||
<dom-module id="test-overlay2">
|
||||
|
||||
<style>
|
||||
|
||||
:host {
|
||||
background: white;
|
||||
color: black;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<content></content>
|
||||
</template>
|
||||
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
|
||||
(function() {
|
||||
|
||||
Polymer({
|
||||
|
||||
is: 'test-overlay2',
|
||||
|
||||
behaviors: [
|
||||
Polymer.IronOverlayBehavior
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
|
@ -36,7 +36,7 @@
|
|||
"tag": "v1.5.1",
|
||||
"commit": "e3e34408fad8f7cde59c4255cf3fe90f7dcf91d8"
|
||||
},
|
||||
"_source": "git://github.com/PolymerElements/iron-selector.git",
|
||||
"_source": "git://github.com/polymerelements/iron-selector.git",
|
||||
"_target": "^1.0.0",
|
||||
"_originalSource": "PolymerElements/iron-selector"
|
||||
"_originalSource": "polymerelements/iron-selector"
|
||||
}
|
|
@ -55,7 +55,8 @@
|
|||
"tag": "v1.2.2",
|
||||
"commit": "67b614a9261c84be12293f1105bafc158a2f443c"
|
||||
},
|
||||
"_source": "git://github.com/polymerelements/neon-animation.git",
|
||||
"_target": "^1.0.0",
|
||||
"_originalSource": "polymerelements/neon-animation"
|
||||
"_source": "git://github.com/PolymerElements/neon-animation.git",
|
||||
"_target": "^1.2.2",
|
||||
"_originalSource": "PolymerElements/neon-animation",
|
||||
"_direct": true
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
{
|
||||
"name": "paper-dialog-behavior",
|
||||
"version": "1.2.6",
|
||||
"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.1.0",
|
||||
"polymer": "Polymer/polymer#^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
|
||||
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
|
||||
"iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0",
|
||||
"paper-button": "PolymerElements/paper-button#^1.0.0",
|
||||
"paper-dialog-scrollable": "PolymerElements/paper-dialog-scrollable#^1.0.0",
|
||||
"paper-dropdown-menu": "PolymerElements/paper-dropdown-menu#^1.0.0",
|
||||
"paper-icon-button": "PolymerElements/paper-icon-button#^1.0.0",
|
||||
"paper-item": "PolymerElements/paper-item#^1.0.0",
|
||||
"paper-listbox": "PolymerElements/paper-listbox#^1.0.0",
|
||||
"web-component-tester": "^4.0.0",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
},
|
||||
"_release": "1.2.6",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.2.6",
|
||||
"commit": "38bd4af9ee0d2f7a42cd1c6281c88d3f502f8500"
|
||||
},
|
||||
"_source": "git://github.com/PolymerElements/paper-dialog-behavior.git",
|
||||
"_target": "^1.0.0",
|
||||
"_originalSource": "PolymerElements/paper-dialog-behavior"
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<!-- Instructions: https://github.com/PolymerElements/paper-dialog-behavior/CONTRIBUTING.md#filing-issues -->
|
||||
### Description
|
||||
<!-- Example: The `paper-foo` element causes the page to turn pink when clicked. -->
|
||||
|
||||
### Expected outcome
|
||||
|
||||
<!-- Example: The page stays the same color. -->
|
||||
|
||||
### Actual outcome
|
||||
|
||||
<!-- Example: The page turns pink. -->
|
||||
|
||||
### Live Demo
|
||||
<!-- Example: https://jsbin.com/cagaye/edit?html,output -->
|
||||
|
||||
### Steps to reproduce
|
||||
|
||||
<!-- Example
|
||||
1. Put a `paper-foo` element in the page.
|
||||
2. Open the page in a web browser.
|
||||
3. Click the `paper-foo` element.
|
||||
-->
|
||||
|
||||
### Browsers Affected
|
||||
<!-- Check all that apply -->
|
||||
- [ ] Chrome
|
||||
- [ ] Firefox
|
||||
- [ ] Safari 9
|
||||
- [ ] Safari 8
|
||||
- [ ] Safari 7
|
||||
- [ ] Edge
|
||||
- [ ] IE 11
|
||||
- [ ] IE 10
|
|
@ -1 +0,0 @@
|
|||
bower_components
|
|
@ -1,23 +0,0 @@
|
|||
language: node_js
|
||||
sudo: required
|
||||
before_script:
|
||||
- npm install -g bower polylint web-component-tester
|
||||
- bower install
|
||||
- polylint
|
||||
env:
|
||||
global:
|
||||
- secure: ZBrrZGA8OWY95x8yHSsKUNrQfowhRe/s/pMZhHgnoppnZ1+bDfpoms+ggOdvH0TgURAAdF+1Wq1mTCgNp0FYLJ3Oe34XseDIxiA3wXSQO/E2m4Cfj/w4fRvaSy8ikdz5urQJET33SjDKdggm1FmWmnt6vSVgW/mg8M7AW2KWDcE=
|
||||
- secure: P5UKkTar39Q1k0VwtF5LhOphqNiW3r+DSnN1vRNA4oKZPrt6l3dJE1hpA9+1x1m6SryG856lLekPM6/fVZuC7nyDKFLz4vU/EWhiGdyWN1lHhE2MDh281TsCtzK56S0uJxdmlIpSiWTFWIrrEiiewN2b8dXy3FSPfy0Fo1sGn54=
|
||||
node_js: stable
|
||||
addons:
|
||||
firefox: latest
|
||||
apt:
|
||||
sources:
|
||||
- google-chrome
|
||||
packages:
|
||||
- google-chrome-stable
|
||||
sauce_connect: true
|
||||
script:
|
||||
- xvfb-run wct
|
||||
- "if [ \"${TRAVIS_PULL_REQUEST}\" = \"false\" ]; then wct -s 'default'; fi"
|
||||
dist: trusty
|
|
@ -1,77 +0,0 @@
|
|||
|
||||
<!--
|
||||
This file is autogenerated based on
|
||||
https://github.com/PolymerElements/ContributionGuide/blob/master/CONTRIBUTING.md
|
||||
|
||||
If you edit that file, it will get updated everywhere else.
|
||||
If you edit this file, your changes will get overridden :)
|
||||
|
||||
You can however override the jsbin link with one that's customized to this
|
||||
specific element:
|
||||
|
||||
jsbin=https://jsbin.com/cagaye/edit?html,output
|
||||
-->
|
||||
# Polymer Elements
|
||||
## Guide for Contributors
|
||||
|
||||
Polymer Elements are built in the open, and the Polymer authors eagerly encourage any and all forms of community contribution. When contributing, please follow these guidelines:
|
||||
|
||||
### Filing Issues
|
||||
|
||||
**If you are filing an issue to request a feature**, please provide a clear description of the feature. It can be helpful to describe answers to the following questions:
|
||||
|
||||
1. **Who will use the feature?** _“As someone filling out a form…”_
|
||||
2. **When will they use the feature?** _“When I enter an invalid value…”_
|
||||
3. **What is the user’s goal?** _“I want to be visually notified that the value needs to be corrected…”_
|
||||
|
||||
**If you are filing an issue to report a bug**, please provide:
|
||||
|
||||
1. **A clear description of the bug and related expectations.** Consider using the following example template for reporting a bug:
|
||||
|
||||
```markdown
|
||||
The `paper-foo` element causes the page to turn pink when clicked.
|
||||
|
||||
## Expected outcome
|
||||
|
||||
The page stays the same color.
|
||||
|
||||
## Actual outcome
|
||||
|
||||
The page turns pink.
|
||||
|
||||
## Steps to reproduce
|
||||
|
||||
1. Put a `paper-foo` element in the page.
|
||||
2. Open the page in a web browser.
|
||||
3. Click the `paper-foo` element.
|
||||
```
|
||||
|
||||
2. **A reduced test case that demonstrates the problem.** If possible, please include the test case as a JSBin. Start with this template to easily import and use relevant Polymer Elements: [https://jsbin.com/cagaye/edit?html,output](https://jsbin.com/cagaye/edit?html,output).
|
||||
|
||||
3. **A list of browsers where the problem occurs.** This can be skipped if the problem is the same across all browsers.
|
||||
|
||||
### Submitting Pull Requests
|
||||
|
||||
**Before creating a pull request**, please ensure that an issue exists for the corresponding change in the pull request that you intend to make. **If an issue does not exist, please create one per the guidelines above**. The goal is to discuss the design and necessity of the proposed change with Polymer authors and community before diving into a pull request.
|
||||
|
||||
When submitting pull requests, please provide:
|
||||
|
||||
1. **A reference to the corresponding issue** or issues that will be closed by the pull request. Please refer to these issues in the pull request description using the following syntax:
|
||||
|
||||
```markdown
|
||||
(For a single issue)
|
||||
Fixes #20
|
||||
|
||||
(For multiple issues)
|
||||
Fixes #32, fixes #40
|
||||
```
|
||||
|
||||
2. **A succinct description of the design** used to fix any related issues. For example:
|
||||
|
||||
```markdown
|
||||
This fixes #20 by removing styles that leaked which would cause the page to turn pink whenever `paper-foo` is clicked.
|
||||
```
|
||||
|
||||
3. **At least one test for each bug fixed or feature added** as part of the pull request. Pull requests that fix bugs or add features without accompanying tests will not be considered.
|
||||
|
||||
If a proposed change contains multiple commits, please [squash commits](https://www.google.com/url?q=http://blog.steveklabnik.com/posts/2012-11-08-how-to-squash-commits-in-a-github-pull-request) to as few as is necessary to succinctly express the change. A Polymer author can help you squash commits, so don’t be afraid to ask us if you need help with that!
|
|
@ -1,40 +0,0 @@
|
|||
{
|
||||
"name": "paper-dialog-behavior",
|
||||
"version": "1.2.6",
|
||||
"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.1.0",
|
||||
"polymer": "Polymer/polymer#^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
|
||||
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
|
||||
"iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0",
|
||||
"paper-button": "PolymerElements/paper-button#^1.0.0",
|
||||
"paper-dialog-scrollable": "PolymerElements/paper-dialog-scrollable#^1.0.0",
|
||||
"paper-dropdown-menu": "PolymerElements/paper-dropdown-menu#^1.0.0",
|
||||
"paper-icon-button": "PolymerElements/paper-icon-button#^1.0.0",
|
||||
"paper-item": "PolymerElements/paper-item#^1.0.0",
|
||||
"paper-listbox": "PolymerElements/paper-listbox#^1.0.0",
|
||||
"web-component-tester": "^4.0.0",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
}
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
<!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-button/paper-button.html">
|
||||
<link rel="import" href="../../paper-dropdown-menu/paper-dropdown-menu.html">
|
||||
<link rel="import" href="../../paper-item/paper-item.html">
|
||||
<link rel="import" href="../../paper-listbox/paper-listbox.html">
|
||||
<link rel="import" href="../../paper-dialog-scrollable/paper-dialog-scrollable.html">
|
||||
<link rel="import" href="../../iron-demo-helpers/demo-snippet.html">
|
||||
<link rel="import" href="../../iron-demo-helpers/demo-pages-shared-styles.html">
|
||||
|
||||
<style is="custom-style" include="demo-pages-shared-styles"></style>
|
||||
</head>
|
||||
<body unresolved class="centered">
|
||||
|
||||
<h3>An element with <code>PaperDialogBehavior</code> can be opened, closed, toggled. Use <code>h2</code> for the title</h3>
|
||||
<demo-snippet class="centered-demo">
|
||||
<template>
|
||||
<paper-button raised onclick="dialog.toggle()">dialog</paper-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>
|
||||
</template>
|
||||
</demo-snippet>
|
||||
|
||||
<h3>An element with <code>PaperDialogBehavior</code> can be modal. Use the attributes <code>dialog-dismiss</code> and <code>dialog-confirm</code> on the children to close it.</h3>
|
||||
<demo-snippet class="centered-demo">
|
||||
<template>
|
||||
<paper-button raised onclick="modalAlert.toggle()">modal alert</paper-button>
|
||||
<simple-dialog id="modalAlert" modal role="alertdialog">
|
||||
<h2>Alert</h2>
|
||||
<paper-dropdown-menu label="Draft to discard">
|
||||
<paper-listbox class="dropdown-content">
|
||||
<paper-item>Draft 1</paper-item>
|
||||
<paper-item>Draft 2</paper-item>
|
||||
<paper-item>Draft 3</paper-item>
|
||||
<paper-item>Draft 4</paper-item>
|
||||
</paper-listbox>
|
||||
</paper-dropdown-menu>
|
||||
<div class="buttons">
|
||||
<paper-button onclick="modalDetails.toggle()">More details</paper-button>
|
||||
<paper-button dialog-dismiss>Cancel</paper-button>
|
||||
<paper-button dialog-confirm autofocus>Discard</paper-button>
|
||||
</div>
|
||||
</simple-dialog>
|
||||
<simple-dialog id="modalDetails" modal>
|
||||
<h2>Details</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>
|
||||
<div class="buttons">
|
||||
<paper-button dialog-confirm autofocus>OK</paper-button>
|
||||
</div>
|
||||
</simple-dialog>
|
||||
</template>
|
||||
</demo-snippet>
|
||||
|
||||
<h3>Use <code>paper-dialog-scrollable</code> for scrolling content</h3>
|
||||
<demo-snippet class="centered-demo">
|
||||
<template>
|
||||
<paper-button raised onclick="scrolling.toggle()">scrolling</paper-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>
|
||||
</template>
|
||||
</demo-snippet>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,39 +0,0 @@
|
|||
<!--
|
||||
@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-dialog-behavior.html">
|
||||
<link rel="import" href="../paper-dialog-shared-styles.html">
|
||||
|
||||
<dom-module id="simple-dialog">
|
||||
<template>
|
||||
<style include="paper-dialog-shared-styles"></style>
|
||||
<content></content>
|
||||
</template>
|
||||
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
|
||||
(function() {
|
||||
|
||||
Polymer({
|
||||
|
||||
is: 'simple-dialog',
|
||||
|
||||
behaviors: [
|
||||
Polymer.PaperDialogBehavior
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
|
@ -1,51 +0,0 @@
|
|||
<?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>
|
Before Width: | Height: | Size: 2.4 KiB |
|
@ -1,30 +0,0 @@
|
|||
<!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>
|
|
@ -1,146 +0,0 @@
|
|||
<!--
|
||||
@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">
|
||||
|
||||
<script>
|
||||
|
||||
/**
|
||||
Use `Polymer.PaperDialogBehavior` and `paper-dialog-shared-styles.html` 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-shared-styles.html` 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`.
|
||||
|
||||
### Accessibility
|
||||
|
||||
This element has `role="dialog"` by default. Depending on the context, it may be more appropriate
|
||||
to override this attribute with `role="alertdialog"`.
|
||||
|
||||
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.
|
||||
|
||||
@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`, `no-cancel-on-esc-key` and `with-backdrop`.
|
||||
*/
|
||||
modal: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
observers: [
|
||||
'_modalChanged(modal, _readied)'
|
||||
],
|
||||
|
||||
listeners: {
|
||||
'tap': '_onDialogClick'
|
||||
},
|
||||
|
||||
ready: function () {
|
||||
// Only now these properties can be read.
|
||||
this.__prevNoCancelOnOutsideClick = this.noCancelOnOutsideClick;
|
||||
this.__prevNoCancelOnEscKey = this.noCancelOnEscKey;
|
||||
this.__prevWithBackdrop = this.withBackdrop;
|
||||
},
|
||||
|
||||
_modalChanged: function(modal, readied) {
|
||||
if (modal) {
|
||||
this.setAttribute('aria-modal', 'true');
|
||||
} else {
|
||||
this.setAttribute('aria-modal', 'false');
|
||||
}
|
||||
|
||||
// modal implies noCancelOnOutsideClick, noCancelOnEscKey and withBackdrop.
|
||||
// We need to wait for the element to be ready before we can read the
|
||||
// properties values.
|
||||
if (!readied) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (modal) {
|
||||
this.__prevNoCancelOnOutsideClick = this.noCancelOnOutsideClick;
|
||||
this.__prevNoCancelOnEscKey = this.noCancelOnEscKey;
|
||||
this.__prevWithBackdrop = this.withBackdrop;
|
||||
this.noCancelOnOutsideClick = true;
|
||||
this.noCancelOnEscKey = true;
|
||||
this.withBackdrop = true;
|
||||
} else {
|
||||
// If the value was changed to false, let it false.
|
||||
this.noCancelOnOutsideClick = this.noCancelOnOutsideClick &&
|
||||
this.__prevNoCancelOnOutsideClick;
|
||||
this.noCancelOnEscKey = this.noCancelOnEscKey &&
|
||||
this.__prevNoCancelOnEscKey;
|
||||
this.withBackdrop = this.withBackdrop && this.__prevWithBackdrop;
|
||||
}
|
||||
},
|
||||
|
||||
_updateClosingReasonConfirmed: function(confirmed) {
|
||||
this.closingReason = this.closingReason || {};
|
||||
this.closingReason.confirmed = confirmed;
|
||||
},
|
||||
|
||||
/**
|
||||
* Will dismiss the dialog if user clicked on an element with dialog-dismiss
|
||||
* or dialog-confirm attribute.
|
||||
*/
|
||||
_onDialogClick: function(event) {
|
||||
// Search for the element with dialog-confirm or dialog-dismiss,
|
||||
// from the root target until this (excluded).
|
||||
var path = Polymer.dom(event).path;
|
||||
for (var i = 0; i < path.indexOf(this); i++) {
|
||||
var target = path[i];
|
||||
if (target.hasAttribute && (target.hasAttribute('dialog-dismiss') || target.hasAttribute('dialog-confirm'))) {
|
||||
this._updateClosingReasonConfirmed(target.hasAttribute('dialog-confirm'));
|
||||
this.close();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/** @polymerBehavior */
|
||||
Polymer.PaperDialogBehavior = [Polymer.IronOverlayBehavior, Polymer.PaperDialogBehaviorImpl];
|
||||
|
||||
</script>
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
@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(--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, --primary-color);
|
||||
|
||||
@apply(--layout-horizontal);
|
||||
@apply(--layout-end-justified);
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
<!--
|
||||
@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-flex-layout/iron-flex-layout.html">
|
||||
<link rel="import" href="../paper-styles/default-theme.html">
|
||||
<link rel="import" href="../paper-styles/typography.html">
|
||||
<link rel="import" href="../paper-styles/shadow.html">
|
||||
|
||||
<!--
|
||||
### 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`
|
||||
-->
|
||||
|
||||
<dom-module id="paper-dialog-shared-styles">
|
||||
<template>
|
||||
<style>
|
||||
:host {
|
||||
display: block;
|
||||
margin: 24px 40px;
|
||||
|
||||
background: var(--paper-dialog-background-color, --primary-background-color);
|
||||
color: var(--paper-dialog-color, --primary-text-color);
|
||||
|
||||
@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, --primary-color);
|
||||
|
||||
@apply(--layout-horizontal);
|
||||
@apply(--layout-end-justified);
|
||||
}
|
||||
</style>
|
||||
</template>
|
||||
</dom-module>
|
|
@ -1,31 +0,0 @@
|
|||
<!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',
|
||||
'paper-dialog-behavior.html?dom=shadow'
|
||||
]);
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body></html>
|
|
@ -1,418 +0,0 @@
|
|||
<!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>
|
||||
|
||||
<link rel="import" href="../../paper-icon-button/paper-icon-button.html">
|
||||
<link rel="import" href="../../iron-icons/iron-icons.html">
|
||||
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
|
||||
<link rel="import" href="test-dialog.html">
|
||||
<link rel="import" href="test-buttons.html">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<test-fixture id="basic">
|
||||
<template>
|
||||
<test-dialog>
|
||||
<p>Dialog</p>
|
||||
<div class="buttons">
|
||||
<button extra>extra</button>
|
||||
<button dialog-dismiss>dismiss</button>
|
||||
<button dialog-confirm>confirm</button>
|
||||
</div>
|
||||
</test-dialog>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="buttons">
|
||||
<template>
|
||||
<test-dialog>
|
||||
<p>Dialog with test-buttons</p>
|
||||
<test-buttons class="buttons"></test-buttons>
|
||||
</test-dialog>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="custom-element-button">
|
||||
<template>
|
||||
<test-dialog>
|
||||
<p>Dialog</p>
|
||||
<div class="buttons">
|
||||
<paper-icon-button icon="cancel" dialog-dismiss></paper-icon-button>
|
||||
<paper-icon-button icon="add-circle" dialog-confirm></paper-icon-button>
|
||||
<paper-icon-button icon="favorite"></paper-icon-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="like-modal">
|
||||
<template>
|
||||
<test-dialog no-cancel-on-esc-key no-cancel-on-outside-click with-backdrop>
|
||||
<p>Dialog</p>
|
||||
</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>
|
||||
|
||||
<test-fixture id="multiple">
|
||||
<template>
|
||||
<test-dialog modal id="dialog1">
|
||||
<p>Dialog 1</p>
|
||||
</test-dialog>
|
||||
<test-dialog modal id="dialog2">
|
||||
<p>Dialog 2</p>
|
||||
</test-dialog>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="nestedmodals">
|
||||
<template>
|
||||
<test-dialog modal opened>
|
||||
<p>Dialog 1</p>
|
||||
<div class="buttons">
|
||||
<button dialog-dismiss>dismiss</button>
|
||||
<button dialog-confirm autofocus>confirm</button>
|
||||
</div>
|
||||
|
||||
<test-dialog modal opened>
|
||||
<p>Dialog 2</p>
|
||||
<div class="buttons">
|
||||
<button dialog-dismiss>dismiss</button>
|
||||
<button dialog-confirm autofocus>confirm</button>
|
||||
</div>
|
||||
</test-dialog>
|
||||
</test-dialog>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
|
||||
function runAfterOpen(dialog, callback) {
|
||||
dialog.addEventListener('iron-overlay-opened', callback);
|
||||
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');
|
||||
});
|
||||
MockInteractions.tap(dialog);
|
||||
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();
|
||||
});
|
||||
MockInteractions.tap(Polymer.dom(dialog).querySelector('[dialog-dismiss]'));
|
||||
});
|
||||
});
|
||||
|
||||
test('dialog-dismiss on a custom element is handled', function(done) {
|
||||
var dialog = fixture('custom-element-button');
|
||||
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();
|
||||
});
|
||||
MockInteractions.tap(Polymer.dom(dialog).querySelector('[dialog-dismiss]'));
|
||||
});
|
||||
});
|
||||
|
||||
test('dialog-dismiss button inside a custom element is handled', function(done) {
|
||||
var dialog = fixture('buttons');
|
||||
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();
|
||||
});
|
||||
MockInteractions.tap(Polymer.dom(dialog).querySelector('test-buttons').$.dismiss);
|
||||
});
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
MockInteractions.tap(Polymer.dom(dialog).querySelector('[dialog-confirm]'));
|
||||
});
|
||||
});
|
||||
|
||||
test('dialog-confirm on a custom element handled', function(done) {
|
||||
var dialog = fixture('custom-element-button');
|
||||
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();
|
||||
});
|
||||
MockInteractions.tap(Polymer.dom(dialog).querySelector('[dialog-confirm]'));
|
||||
});
|
||||
});
|
||||
|
||||
test('dialog-confirm button inside a custom element is handled', function(done) {
|
||||
var dialog = fixture('buttons');
|
||||
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();
|
||||
});
|
||||
MockInteractions.tap(Polymer.dom(dialog).querySelector('test-buttons').$.confirm);
|
||||
});
|
||||
});
|
||||
|
||||
test('clicking dialog-dismiss button closes only the dialog where is contained', function(done) {
|
||||
var dialog = fixture('nestedmodals');
|
||||
var innerDialog = Polymer.dom(dialog).querySelector('test-dialog');
|
||||
MockInteractions.tap(Polymer.dom(innerDialog).querySelector('[dialog-dismiss]'));
|
||||
setTimeout(function() {
|
||||
assert.isFalse(innerDialog.opened, 'inner dialog is closed');
|
||||
assert.isTrue(dialog.opened, 'dialog is still open');
|
||||
done();
|
||||
}, 10);
|
||||
});
|
||||
|
||||
test('clicking dialog-confirm button closes only the dialog where is contained', function(done) {
|
||||
var dialog = fixture('nestedmodals');
|
||||
var innerDialog = Polymer.dom(dialog).querySelector('test-dialog');
|
||||
MockInteractions.tap(Polymer.dom(innerDialog).querySelector('[dialog-confirm]'));
|
||||
setTimeout(function() {
|
||||
assert.isFalse(innerDialog.opened, 'inner dialog is closed');
|
||||
assert.isTrue(dialog.opened, 'dialog is still open');
|
||||
done();
|
||||
}, 10);
|
||||
});
|
||||
|
||||
var properties = ['noCancelOnEscKey', 'noCancelOnOutsideClick', 'withBackdrop'];
|
||||
properties.forEach(function(property) {
|
||||
|
||||
test('modal sets ' + property + ' to true', function() {
|
||||
var dialog = fixture('modal');
|
||||
assert.isTrue(dialog[property], property);
|
||||
});
|
||||
|
||||
test('modal toggling keeps current value of ' + property, function() {
|
||||
var dialog = fixture('modal');
|
||||
// Changed to false while modal is true.
|
||||
dialog[property] = false;
|
||||
dialog.modal = false;
|
||||
assert.isFalse(dialog[property], property + ' is false');
|
||||
});
|
||||
|
||||
test('modal toggling keeps previous value of ' + property, function() {
|
||||
var dialog = fixture('basic');
|
||||
// Changed before modal is true.
|
||||
dialog[property] = true;
|
||||
// Toggle twice to trigger observer.
|
||||
dialog.modal = true;
|
||||
dialog.modal = false;
|
||||
assert.isTrue(dialog[property], property + ' is still true');
|
||||
});
|
||||
|
||||
test('default modal does not override ' + property +' (attribute)', function() {
|
||||
// Property is set on ready from attribute.
|
||||
var dialog = fixture('like-modal');
|
||||
assert.isTrue(dialog[property], property + ' is true');
|
||||
});
|
||||
|
||||
test('modal toggling keeps previous value of ' + property + ' (attribute)', function() {
|
||||
// Property is set on ready from attribute.
|
||||
var dialog = fixture('like-modal');
|
||||
// Toggle twice to trigger observer.
|
||||
dialog.modal = true;
|
||||
dialog.modal = false;
|
||||
assert.isTrue(dialog[property], property + ' is still true');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test('clicking outside a modal dialog does not move focus from dialog', function(done) {
|
||||
var dialog = fixture('modal');
|
||||
runAfterOpen(dialog, function() {
|
||||
MockInteractions.tap(document.body);
|
||||
setTimeout(function() {
|
||||
assert.equal(document.activeElement, Polymer.dom(dialog).querySelector('[autofocus]'), 'document.activeElement is the autofocused button');
|
||||
done();
|
||||
}, 10);
|
||||
});
|
||||
});
|
||||
|
||||
test('removing a child element on click does not cause an exception', function(done) {
|
||||
var dialog = fixture('basic');
|
||||
runAfterOpen(dialog, function() {
|
||||
var button = Polymer.dom(dialog).querySelector('[extra]');
|
||||
button.addEventListener('click', function(event) {
|
||||
Polymer.dom(event.target.parentNode).removeChild(event.target);
|
||||
// should not throw exception here
|
||||
done();
|
||||
});
|
||||
MockInteractions.tap(button);
|
||||
});
|
||||
});
|
||||
|
||||
test('multiple modal dialogs opened, handle focus change', function(done) {
|
||||
var dialogs = fixture('multiple');
|
||||
|
||||
runAfterOpen(dialogs[0], function() {
|
||||
runAfterOpen(dialogs[1], function() {
|
||||
// Each modal dialog will trap the focus within its children.
|
||||
// Multiple modal dialogs doing it might result in an infinite loop
|
||||
// dialog1 focus -> dialog2 focus -> dialog1 focus -> dialog2 focus...
|
||||
// causing a "Maximum call stack size exceeded" error.
|
||||
// Wait 50ms and verify this does not happen.
|
||||
Polymer.Base.async(function() {
|
||||
// Should not enter in an infinite loop.
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('multiple modal dialogs opened, handle outside click', function(done) {
|
||||
var dialogs = fixture('multiple');
|
||||
|
||||
runAfterOpen(dialogs[0], function() {
|
||||
runAfterOpen(dialogs[1], function() {
|
||||
// Click should be handled only by dialogs[1].
|
||||
MockInteractions.tap(document.body);
|
||||
// Each modal dialog will trap the focus within its children.
|
||||
// Multiple modal dialogs doing it might result in an infinite loop
|
||||
// dialog1 focus -> dialog2 focus -> dialog1 focus -> dialog2 focus...
|
||||
// causing a "Maximum call stack size exceeded" error.
|
||||
// Wait 50ms and verify this does not happen.
|
||||
Polymer.Base.async(function() {
|
||||
// Should not enter in an infinite loop.
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('focus is given to the autofocus element when clicking on backdrop', function(done) {
|
||||
var dialog = fixture('modal');
|
||||
dialog.addEventListener('iron-overlay-opened', onFirstOpen);
|
||||
dialog.open();
|
||||
|
||||
function onFirstOpen() {
|
||||
dialog.removeEventListener('iron-overlay-opened', onFirstOpen);
|
||||
dialog.addEventListener('iron-overlay-closed', onFirstClose);
|
||||
// Set the focus on dismiss button
|
||||
MockInteractions.focus(Polymer.dom(dialog).querySelector('[dialog-dismiss]'));
|
||||
// Close the dialog
|
||||
dialog.close();
|
||||
}
|
||||
|
||||
function onFirstClose() {
|
||||
dialog.removeEventListener('iron-overlay-closed', onFirstClose);
|
||||
dialog.addEventListener('iron-overlay-opened', onSecondOpen);
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
function onSecondOpen() {
|
||||
MockInteractions.tap(document.body);
|
||||
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"');
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1,30 +0,0 @@
|
|||
<!--
|
||||
@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">
|
||||
|
||||
<dom-module id="test-buttons">
|
||||
<template>
|
||||
<button dialog-dismiss id="dismiss">dismiss</button>
|
||||
<button dialog-confirm id="confirm">confirm</button>
|
||||
</template>
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
|
||||
(function() {
|
||||
|
||||
Polymer({
|
||||
is: 'test-buttons'
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
|
@ -1,39 +0,0 @@
|
|||
<!--
|
||||
@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-dialog-behavior.html">
|
||||
<link rel="import" href="../paper-dialog-shared-styles.html">
|
||||
|
||||
<dom-module id="test-dialog">
|
||||
<template>
|
||||
<style include="paper-dialog-shared-styles"></style>
|
||||
<content></content>
|
||||
</template>
|
||||
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
|
||||
(function() {
|
||||
|
||||
Polymer({
|
||||
|
||||
is: 'test-dialog',
|
||||
|
||||
behaviors: [
|
||||
Polymer.PaperDialogBehavior
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
|
@ -1,46 +0,0 @@
|
|||
{
|
||||
"name": "paper-dialog-scrollable",
|
||||
"version": "1.0.1",
|
||||
"description": "A scrollable area used inside the material design dialog",
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
],
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"polymer",
|
||||
"dialog",
|
||||
"overlay"
|
||||
],
|
||||
"main": [
|
||||
"paper-dialog-scrollable.html"
|
||||
],
|
||||
"private": true,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/PolymerElements/paper-dialog-scrollable"
|
||||
},
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"homepage": "https://github.com/PolymerElements/paper-dialog-scrollable",
|
||||
"ignore": [],
|
||||
"dependencies": {
|
||||
"polymer": "Polymer/polymer#^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
|
||||
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0",
|
||||
"paper-styles": "PolymerElements/paper-styles#^1.0.0",
|
||||
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
|
||||
"web-component-tester": "*",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
},
|
||||
"_release": "1.0.1",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.0.1",
|
||||
"commit": "94e65968791d9166d2d3bf186e449d042b10168f"
|
||||
},
|
||||
"_source": "git://github.com/PolymerElements/paper-dialog-scrollable.git",
|
||||
"_target": "~1.0.1",
|
||||
"_originalSource": "PolymerElements/paper-dialog-scrollable",
|
||||
"_direct": true
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
bower_components
|
|
@ -1,36 +0,0 @@
|
|||
{
|
||||
"name": "paper-dialog-scrollable",
|
||||
"version": "1.0.1",
|
||||
"description": "A scrollable area used inside the material design dialog",
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
],
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"polymer",
|
||||
"dialog",
|
||||
"overlay"
|
||||
],
|
||||
"main": [
|
||||
"paper-dialog-scrollable.html"
|
||||
],
|
||||
"private": true,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/PolymerElements/paper-dialog-scrollable"
|
||||
},
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"homepage": "https://github.com/PolymerElements/paper-dialog-scrollable",
|
||||
"ignore": [],
|
||||
"dependencies": {
|
||||
"polymer": "Polymer/polymer#^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
|
||||
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0",
|
||||
"paper-styles": "PolymerElements/paper-styles#^1.0.0",
|
||||
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
|
||||
"web-component-tester": "*",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
}
|
||||
}
|
|
@ -1,290 +0,0 @@
|
|||
<!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-scrollable demo</title>
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
|
||||
<link rel="import" href="../paper-dialog-scrollable.html">
|
||||
|
||||
<link rel="import" href="../../paper-styles/classes/typography.html">
|
||||
<link rel="import" href="../../iron-flex-layout/classes/iron-flex-layout.html">
|
||||
|
||||
<style>
|
||||
|
||||
section {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.header, .footer {
|
||||
padding: 8px 24px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body class="fullbleed">
|
||||
|
||||
<section class="layout vertical">
|
||||
|
||||
<div class="header paper-font-title">
|
||||
Alice in Wonderland
|
||||
</div>
|
||||
|
||||
<paper-dialog-scrollable class="flex paper-font-body1">
|
||||
|
||||
<p>Alice was beginning to get very tired of sitting by her sister
|
||||
on the bank, and of having nothing to do: once or twice she had
|
||||
peeped into the book her sister was reading, but it had no
|
||||
pictures or conversations in it, 'and what is the use of a book,'
|
||||
thought Alice 'without pictures or conversation?'</p>
|
||||
|
||||
<p>So she was considering in her own mind (as well as she could,
|
||||
for the hot day made her feel very sleepy and stupid), whether
|
||||
the pleasure of making a daisy-chain would be worth the trouble
|
||||
of getting up and picking the daisies, when suddenly a White
|
||||
Rabbit with pink eyes ran close by her.</p>
|
||||
|
||||
<p>There was nothing so <i>very</i> remarkable in that; nor did
|
||||
Alice think it so <i>very</i> much out of the way to hear the
|
||||
Rabbit say to itself, 'Oh dear! Oh dear! I shall be late!' (when
|
||||
she thought it over afterwards, it occurred to her that she ought
|
||||
to have wondered at this, but at the time it all seemed quite
|
||||
natural); but when the Rabbit actually <i>took a watch out of its
|
||||
waistcoat-pocket,</i> and looked at it, and then hurried on,
|
||||
Alice started to her feet, for it flashed across her mind that
|
||||
she had never before seen a rabbit with either a
|
||||
waistcoat-pocket, or a watch to take out of it, and burning with
|
||||
curiosity, she ran across the field after it, and fortunately was
|
||||
just in time to see it pop down a large rabbit-hole under the
|
||||
hedge.</p>
|
||||
|
||||
<p>In another moment down went Alice after it, never once
|
||||
considering how in the world she was to get out again.</p>
|
||||
|
||||
<p>The rabbit-hole went straight on like a tunnel for some way,
|
||||
and then dipped suddenly down, so suddenly that Alice had not a
|
||||
moment to think about stopping herself before she found herself
|
||||
falling down a very deep well.</p>
|
||||
|
||||
<p>Either the well was very deep, or she fell very slowly, for
|
||||
she had plenty of time as she went down to look about her and to
|
||||
wonder what was going to happen next. First, she tried to look
|
||||
down and make out what she was coming to, but it was too dark to
|
||||
see anything; then she looked at the sides of the well, and
|
||||
noticed that they were filled with cupboards and book-shelves;
|
||||
here and there she saw maps and pictures hung upon pegs. She took
|
||||
down a jar from one of the shelves as she passed; it was labelled
|
||||
'ORANGE MARMALADE', but to her great disappointment it was empty:
|
||||
she did not like to drop the jar for fear of killing somebody, so
|
||||
managed to put it into one of the cupboards as she fell past
|
||||
it.</p>
|
||||
|
||||
<p>'Well!' thought Alice to herself, 'after such a fall as this,
|
||||
I shall think nothing of tumbling down stairs! How brave they'll
|
||||
all think me at home! Why, I wouldn't say anything about it, even
|
||||
if I fell off the top of the house!' (Which was very likely
|
||||
true.)</p>
|
||||
|
||||
<p>Down, down, down. Would the fall <i>never</i> come to an end!
|
||||
'I wonder how many miles I've fallen by this time?' she said
|
||||
aloud. 'I must be getting somewhere near the centre of the earth.
|
||||
Let me see: that would be four thousand miles down, I think--'
|
||||
(for, you see, Alice had learnt several things of this sort in
|
||||
her lessons in the schoolroom, and though this was not a <i>very</i>
|
||||
good opportunity for showing off her knowledge, as there was no
|
||||
one to listen to her, still it was good practice to say it over)
|
||||
'--yes, that's about the right distance--but then I wonder what
|
||||
Latitude or Longitude I've got to?' (Alice had no idea what
|
||||
Latitude was, or Longitude either, but thought they were nice
|
||||
grand words to say.)</p>
|
||||
|
||||
<p>Presently she began again. 'I wonder if I shall fall right
|
||||
<i>through</i> the earth! How funny it'll seem to come out among
|
||||
the people that walk with their heads downward! The Antipathies,
|
||||
I think--' (she was rather glad there <i>was</i> no one listening, this
|
||||
time, as it didn't sound at all the right word) '--but I shall
|
||||
have to ask them what the name of the country is, you know.
|
||||
Please, Ma'am, is this New Zealand or Australia?' (and she tried
|
||||
to curtsey as she spoke--fancy <i>curtseying</i> as you're
|
||||
falling through the air! Do you think you could manage it?) 'And
|
||||
what an ignorant little girl she'll think me for asking! No,
|
||||
it'll never do to ask: perhaps I shall see it written up
|
||||
somewhere.'</p>
|
||||
|
||||
<p>Down, down, down. There was nothing else to do, so Alice soon
|
||||
began talking again. 'Dinah'll miss me very much to-night, I
|
||||
should think!' (Dinah was the cat.) 'I hope they'll remember her
|
||||
saucer of milk at tea-time. Dinah my dear! I wish you were down
|
||||
here with me! There are no mice in the air, I'm afraid, but you
|
||||
might catch a bat, and that's very like a mouse, you know. But do
|
||||
cats eat bats, I wonder?' And here Alice began to get rather
|
||||
sleepy, and went on saying to herself, in a dreamy sort of way,
|
||||
'Do cats eat bats? Do cats eat bats?' and sometimes, 'Do bats eat
|
||||
cats?' for, you see, as she couldn't answer either question, it
|
||||
didn't much matter which way she put it. She felt that she was
|
||||
dozing off, and had just begun to dream that she was walking hand
|
||||
in hand with Dinah, and saying to her very earnestly, 'Now,
|
||||
Dinah, tell me the truth: did you ever eat a bat?' when suddenly,
|
||||
thump! thump! down she came upon a heap of sticks and dry leaves,
|
||||
and the fall was over.</p>
|
||||
|
||||
<p>Alice was not a bit hurt, and she jumped up on to her feet in
|
||||
a moment: she looked up, but it was all dark overhead; before her
|
||||
was another long passage, and the White Rabbit was still in
|
||||
sight, hurrying down it. There was not a moment to be lost: away
|
||||
went Alice like the wind, and was just in time to hear it say, as
|
||||
it turned a corner, 'Oh my ears and whiskers, how late it's
|
||||
getting!' She was close behind it when she turned the corner, but
|
||||
the Rabbit was no longer to be seen: she found herself in a long,
|
||||
low hall, which was lit up by a row of lamps hanging from the
|
||||
roof.</p>
|
||||
|
||||
<p>There were doors all round the hall, but they were all locked;
|
||||
and when Alice had been all the way down one side and up the
|
||||
other, trying every door, she walked sadly down the middle,
|
||||
wondering how she was ever to get out again.</p>
|
||||
|
||||
<p>Suddenly she came upon a little three-legged table, all made
|
||||
of solid glass; there was nothing on it except a tiny golden key,
|
||||
and Alice's first thought was that it might belong to one of the
|
||||
doors of the hall; but, alas! either the locks were too large, or
|
||||
the key was too small, but at any rate it would not open any of
|
||||
them. However, on the second time round, she came upon a low
|
||||
curtain she had not noticed before, and behind it was a little
|
||||
door about fifteen inches high: she tried the little golden key
|
||||
in the lock, and to her great delight it fitted!</p>
|
||||
|
||||
<p>Alice opened the door and found that it led into a small
|
||||
passage, not much larger than a rat-hole: she knelt down and
|
||||
looked along the passage into the loveliest garden you ever saw.
|
||||
How she longed to get out of that dark hall, and wander about
|
||||
among those beds of bright flowers and those cool fountains, but
|
||||
she could not even get her head though the doorway; 'and even if
|
||||
my head <i>would</i> go through,' thought poor Alice, 'it would
|
||||
be of very little use without my shoulders. Oh, how I wish I
|
||||
could shut up like a telescope! I think I could, if I only know
|
||||
how to begin.' For, you see, so many out-of-the-way things had
|
||||
happened lately, that Alice had begun to think that very few
|
||||
things indeed were really impossible.</p>
|
||||
|
||||
<p>There seemed to be no use in waiting by the little door, so
|
||||
she went back to the table, half hoping she might find another
|
||||
key on it, or at any rate a book of rules for shutting people up
|
||||
like telescopes: this time she found a little bottle on it,
|
||||
('which certainly was not here before,' said Alice,) and round
|
||||
the neck of the bottle was a paper label, with the words 'DRINK
|
||||
ME' beautifully printed on it in large letters.</p>
|
||||
|
||||
<p>It was all very well to say 'Drink me,' but the wise little
|
||||
Alice was not going to do <i>that</i> in a hurry. 'No, I'll look
|
||||
first,' she said, 'and see whether it's marked "<i>poison</i>" or
|
||||
not'; for she had read several nice little histories about
|
||||
children who had got burnt, and eaten up by wild beasts and other
|
||||
unpleasant things, all because they <i>would</i> not remember the
|
||||
simple rules their friends had taught them: such as, that a
|
||||
red-hot poker will burn you if you hold it too long; and that if
|
||||
you cut your finger <i>very</i> deeply with a knife, it usually
|
||||
bleeds; and she had never forgotten that, if you drink much from
|
||||
a bottle marked '<i>poison</i>,' it is almost certain to disagree
|
||||
with you, sooner or later.</p>
|
||||
|
||||
<p>However, this bottle was <i>not</i> marked 'poison,' so Alice
|
||||
ventured to taste it, and finding it very nice, (it had, in fact,
|
||||
a sort of mixed flavour of cherry-tart, custard, pine-apple,
|
||||
roast turkey, toffee, and hot buttered toast,) she very soon
|
||||
finished it off.</p>
|
||||
|
||||
<p class="asterisks">
|
||||
<br>
|
||||
* * * * *
|
||||
<br>
|
||||
* * * *
|
||||
<br>
|
||||
* * * * *
|
||||
<br>
|
||||
</p>
|
||||
|
||||
<p>'What a curious feeling!' said Alice; 'I must be shutting up
|
||||
like a telescope.'</p>
|
||||
|
||||
<p>And so it was indeed: she was now only ten inches high, and
|
||||
her face brightened up at the thought that she was now the right
|
||||
size for going through the little door into that lovely garden.
|
||||
First, however, she waited for a few minutes to see if she was
|
||||
going to shrink any further: she felt a little nervous about
|
||||
this; 'for it might end, you know,' said Alice to herself, 'in my
|
||||
going out altogether, like a candle. I wonder what I should be
|
||||
like then?' And she tried to fancy what the flame of a candle is
|
||||
like after the candle is blown out, for she could not remember
|
||||
ever having seen such a thing.</p>
|
||||
|
||||
<p>After a while, finding that nothing more happened, she decided
|
||||
on going into the garden at once; but, alas for poor Alice! when
|
||||
she got to the door, she found she had forgotten the little
|
||||
golden key, and when she went back to the table for it, she found
|
||||
she could not possibly reach it: she could see it quite plainly
|
||||
through the glass, and she tried her best to climb up one of the
|
||||
legs of the table, but it was too slippery; and when she had
|
||||
tired herself out with trying, the poor little thing sat down and
|
||||
cried.</p>
|
||||
|
||||
<p>'Come, there's no use in crying like that!' said Alice to
|
||||
herself, rather sharply; 'I advise you to leave off this minute!'
|
||||
She generally gave herself very good advice, (though she very
|
||||
seldom followed it), and sometimes she scolded herself so
|
||||
severely as to bring tears into her eyes; and once she remembered
|
||||
trying to box her own ears for having cheated herself in a game
|
||||
of croquet she was playing against herself, for this curious
|
||||
child was very fond of pretending to be two people. 'But it's no
|
||||
use now,' thought poor Alice, 'to pretend to be two people! Why,
|
||||
there's hardly enough of me left to make <i>one</i> respectable
|
||||
person!'</p>
|
||||
|
||||
<p>Soon her eye fell on a little glass box that was lying under
|
||||
the table: she opened it, and found in it a very small cake, on
|
||||
which the words 'EAT ME' were beautifully marked in currants.
|
||||
'Well, I'll eat it,' said Alice, 'and if it makes me grow larger,
|
||||
I can reach the key; and if it makes me grow smaller, I can creep
|
||||
under the door; so either way I'll get into the garden, and I
|
||||
don't care which happens!'</p>
|
||||
|
||||
<p>She ate a little bit, and said anxiously to herself, 'Which
|
||||
way? Which way?', holding her hand on the top of her head to feel
|
||||
which way it was growing, and she was quite surprised to find
|
||||
that she remained the same size: to be sure, this generally
|
||||
happens when one eats cake, but Alice had got so much into the
|
||||
way of expecting nothing but out-of-the-way things to happen,
|
||||
that it seemed quite dull and stupid for life to go on in the
|
||||
common way.</p>
|
||||
|
||||
<p>So she set to work, and very soon finished off the cake.</p>
|
||||
|
||||
</paper-dialog-scrollable>
|
||||
|
||||
<div class="footer paper-font-subhead">
|
||||
Lewis Carroll
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,69 +0,0 @@
|
|||
<?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="0,124 0,126 2,126 "/>
|
||||
<polygon points="0,111.6 0,114.4 11.6,126 14.4,126 "/>
|
||||
<polygon points="0,99.1 0,101.9 24.1,126 26.9,126 "/>
|
||||
<polygon points="0,86.6 0,89.5 36.5,126 39.4,126 "/>
|
||||
<polygon points="0,74.2 0,77 49,126 51.8,126 "/>
|
||||
<polygon points="0,61.7 0,64.5 61.5,126 64.3,126 "/>
|
||||
<polygon points="0,49.2 0,52.1 73.9,126 76.8,126 "/>
|
||||
<polygon points="0,36.8 0,39.6 86.4,126 89.2,126 "/>
|
||||
<polygon points="76.7,101 74,101 74,98.3 0,24.3 0,27.1 98.9,126 101.7,126 "/>
|
||||
<polygon points="74,88.7 74,85.8 0,11.8 0,14.7 "/>
|
||||
<polygon points="89.2,101 86.3,101 111.3,126 114.2,126 "/>
|
||||
<polygon points="101.6,101 98.8,101 123.8,126 126.6,126 "/>
|
||||
<polygon points="74,76.2 74,73.4 0.6,0 0,0 0,2.2 "/>
|
||||
<polygon points="114.1,101 111.3,101 136.3,126 139.1,126 "/>
|
||||
<polygon points="74,63.7 74,60.9 13.1,0 10.3,0 "/>
|
||||
<polygon points="74,51.3 74,48.4 25.6,0 22.7,0 "/>
|
||||
<polygon points="126.6,101 123.7,101 148.7,126 151.6,126 "/>
|
||||
<polygon points="74,38.8 74,36 38,0 35.2,0 "/>
|
||||
<polygon points="139,101 136.2,101 161.2,126 164,126 "/>
|
||||
<polygon points="74,26.3 74,25 75.5,25 50.5,0 47.7,0 "/>
|
||||
<polygon points="150,99.5 150,101 148.7,101 173.7,126 176.5,126 "/>
|
||||
<polygon points="150,87 150,89.9 186.1,126 189,126 "/>
|
||||
<polygon points="85.1,25 88,25 63,0 60.1,0 "/>
|
||||
<polygon points="150,74.6 150,77.4 198.6,126 201.4,126 "/>
|
||||
<polygon points="97.6,25 100.4,25 75.4,0 72.6,0 "/>
|
||||
<polygon points="150,62.1 150,64.9 211.1,126 213.9,126 "/>
|
||||
<polygon points="110.1,25 112.9,25 87.9,0 85.1,0 "/>
|
||||
<polygon points="150,49.7 150,52.5 223.5,126 225,126 225,124.7 "/>
|
||||
<polygon points="122.5,25 125.3,25 100.3,0 97.5,0 "/>
|
||||
<polygon points="112.8,0 110,0 135,25 137.8,25 "/>
|
||||
<polygon points="150,37.2 150,40 225,115 225,112.2 "/>
|
||||
<polygon points="125.3,0 122.5,0 147.5,25 150,25 150,27.5 225,102.5 225,99.7 "/>
|
||||
<polygon points="137.7,0 134.9,0 225,90.1 225,87.3 "/>
|
||||
<polygon points="150.2,0 147.4,0 225,77.6 225,74.8 "/>
|
||||
<polygon points="162.7,0 159.8,0 225,65.2 225,62.3 "/>
|
||||
<polygon points="175.1,0 172.3,0 225,52.7 225,49.9 "/>
|
||||
<polygon points="187.6,0 184.8,0 225,40.2 225,37.4 "/>
|
||||
<polygon points="200.1,0 197.2,0 225,27.8 225,24.9 "/>
|
||||
<polygon points="212.5,0 209.7,0 225,15.3 225,12.5 "/>
|
||||
<polygon points="225,0 222.2,0 225,2.8 225,0 "/>
|
||||
</g>
|
||||
<path d="M151,102H73V24h78V102z M75,100h74V26H75V100z"/>
|
||||
<rect x="82" y="53" width="26" height="2"/>
|
||||
<rect x="116" y="53" width="26" height="2"/>
|
||||
<rect x="82" y="62" width="26" height="2"/>
|
||||
<rect x="82" y="72" width="26" height="2"/>
|
||||
<rect x="116" y="72" width="26" height="2"/>
|
||||
<rect x="82" y="42" width="26" height="2"/>
|
||||
<circle cx="120" cy="63" r="4"/>
|
||||
<circle cx="134" cy="63" r="4"/>
|
||||
<rect x="116" y="85" width="22" height="5.5"/>
|
||||
<g id="ic_x5F_add_x0D_">
|
||||
</g>
|
||||
</g>
|
||||
<g id="Guides">
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 3.4 KiB |
|
@ -1,30 +0,0 @@
|
|||
<!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-scrollable</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>
|
|
@ -1,151 +0,0 @@
|
|||
<!--
|
||||
@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-flex-layout/classes/iron-flex-layout.html">
|
||||
<link rel="import" href="../paper-styles/paper-styles.html">
|
||||
|
||||
<!--
|
||||
`paper-dialog-scrollable` implements a scrolling area used in a Material Design dialog. It shows
|
||||
a divider at the top and/or bottom indicating more content, depending on scroll position. Use this
|
||||
together with elements implementing `Polymer.PaperDialogBehavior`.
|
||||
|
||||
<paper-dialog-impl>
|
||||
<h2>Header</h2>
|
||||
<paper-dialog-scrollable>
|
||||
Lorem ipsum...
|
||||
</paper-dialog-scrollable>
|
||||
<div class="buttons">
|
||||
<paper-button>OK</paper-button>
|
||||
</div>
|
||||
</paper-dialog-impl>
|
||||
|
||||
It shows a top divider after scrolling if it is not the first child in its parent container,
|
||||
indicating there is more content above. It shows a bottom divider if it is scrollable and it is not
|
||||
the last child in its parent container, indicating there is more content below. The bottom divider
|
||||
is hidden if it is scrolled to the bottom.
|
||||
|
||||
@group Paper Elements
|
||||
@element paper-dialog-scrollable
|
||||
@demo demo/index.html
|
||||
@hero hero.svg
|
||||
-->
|
||||
|
||||
<dom-module id="paper-dialog-scrollable">
|
||||
|
||||
<style>
|
||||
|
||||
:host {
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
:host(.is-scrolled:not(:first-child))::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 1px;
|
||||
background: var(--divider-color);
|
||||
}
|
||||
|
||||
:host(.can-scroll:not(.scrolled-to-bottom):not(:last-child))::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 1px;
|
||||
background: var(--divider-color);
|
||||
}
|
||||
|
||||
.scrollable {
|
||||
padding: 0 24px;
|
||||
|
||||
@apply(--layout-scroll);
|
||||
|
||||
@apply(--paper-dialog-scrollable);
|
||||
}
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<div id="scrollable" class="scrollable">
|
||||
<content></content>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
|
||||
(function() {
|
||||
|
||||
Polymer({
|
||||
|
||||
is: 'paper-dialog-scrollable',
|
||||
|
||||
properties: {
|
||||
|
||||
/**
|
||||
* The dialog element that implements `Polymer.PaperDialogBehavior` containing this element.
|
||||
* @type {?Node}
|
||||
*/
|
||||
dialogElement: {
|
||||
type: Object,
|
||||
value: function() {
|
||||
return this.parentNode;
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
listeners: {
|
||||
'scrollable.scroll': '_onScroll',
|
||||
'iron-resize': '_onIronResize'
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the scrolling element.
|
||||
*/
|
||||
get scrollTarget() {
|
||||
return this.$.scrollable;
|
||||
},
|
||||
|
||||
attached: function() {
|
||||
this.classList.add('no-padding');
|
||||
// Set itself to the overlay sizing target
|
||||
this.dialogElement.sizingTarget = this.scrollTarget;
|
||||
// If the host is sized, fit the scrollable area to the container. Otherwise let it be
|
||||
// its natural size.
|
||||
requestAnimationFrame(function() {
|
||||
if (this.offsetHeight > 0) {
|
||||
this.$.scrollable.classList.add('fit');
|
||||
}
|
||||
this._scroll();
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_scroll: function() {
|
||||
this.toggleClass('is-scrolled', this.scrollTarget.scrollTop > 0);
|
||||
this.toggleClass('can-scroll', this.scrollTarget.offsetHeight < this.scrollTarget.scrollHeight);
|
||||
this.toggleClass('scrolled-to-bottom',
|
||||
this.scrollTarget.scrollTop + this.scrollTarget.offsetHeight >= this.scrollTarget.scrollHeight);
|
||||
},
|
||||
|
||||
_onScroll: function() {
|
||||
this._scroll();
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
|
@ -1,34 +0,0 @@
|
|||
<!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-scrollable.html'
|
||||
]);
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,171 +0,0 @@
|
|||
<!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-scrollable 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="../paper-dialog-scrollable.html">
|
||||
|
||||
<link rel="import" href="../../iron-flex-layout/classes/iron-flex-layout.html">
|
||||
|
||||
<style>
|
||||
.fixed-height {
|
||||
height: 400px;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<test-fixture id="basic">
|
||||
<template>
|
||||
<section class="fixed-height layout vertical">
|
||||
<div class="header">Header</div>
|
||||
<paper-dialog-scrollable class="flex">
|
||||
<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="footer">Footer</div>
|
||||
</section>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="only-child">
|
||||
<template>
|
||||
<section class="fixed-height layout vertical">
|
||||
<paper-dialog-scrollable class="flex">
|
||||
<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>
|
||||
</section>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="short">
|
||||
<template>
|
||||
<section class="fixed-height layout vertical">
|
||||
<div class="header">Header</div>
|
||||
<paper-dialog-scrollable class="flex">
|
||||
<p>Hello world!</p>
|
||||
</paper-dialog-scrollable>
|
||||
<div class="footer">Footer</div>
|
||||
</section>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
|
||||
function runAfterScroll(node, scrollTop, callback) {
|
||||
var timeout = function() {
|
||||
node.scrollTop = scrollTop;
|
||||
if (node.scrollTop === scrollTop) {
|
||||
// there seems to be no good way to wait for pseudoelement styling to apply and
|
||||
// chrome takes a while before getComputedStyle returns the correct values
|
||||
setTimeout(function() {
|
||||
callback();
|
||||
}, 250);
|
||||
} else {
|
||||
setTimeout(timeout, 10);
|
||||
}
|
||||
};
|
||||
node.scrollTop = scrollTop;
|
||||
setTimeout(timeout);
|
||||
}
|
||||
|
||||
suite('basic', function() {
|
||||
|
||||
test('shows top divider if scrolled', function(done) {
|
||||
var container = fixture('basic');
|
||||
var scrollable = Polymer.dom(container).querySelector('paper-dialog-scrollable');
|
||||
setTimeout(function() {
|
||||
runAfterScroll(scrollable.scrollTarget, 10, function() {
|
||||
assert.ok(getComputedStyle(scrollable, '::before').content, '::before has content');
|
||||
done();
|
||||
});
|
||||
}, 10);
|
||||
});
|
||||
|
||||
test('shows bottom divider if scrollable', function(done) {
|
||||
var container = fixture('basic');
|
||||
setTimeout(function() {
|
||||
var scrollable = Polymer.dom(container).querySelector('paper-dialog-scrollable');
|
||||
requestAnimationFrame(function() {
|
||||
assert.ok(getComputedStyle(scrollable, '::after').content, '::after has content');
|
||||
done();
|
||||
});
|
||||
}, 10);
|
||||
});
|
||||
|
||||
test('hides bottom divider if scrolled to bottom', function(done) {
|
||||
var container = fixture('basic');
|
||||
var scrollable = Polymer.dom(container).querySelector('paper-dialog-scrollable');
|
||||
setTimeout(function() {
|
||||
runAfterScroll(scrollable.scrollTarget, scrollable.scrollTarget.scrollHeight - scrollable.scrollTarget.offsetHeight, function() {
|
||||
var content = getComputedStyle(scrollable, '::after').content;
|
||||
assert.ok(!content || content === 'none', '::after does not have content');
|
||||
done();
|
||||
});
|
||||
}, 10);
|
||||
});
|
||||
|
||||
test('does not show dividers if scrolled and only child', function(done) {
|
||||
var container = fixture('only-child');
|
||||
var scrollable = Polymer.dom(container).querySelector('paper-dialog-scrollable');
|
||||
setTimeout(function() {
|
||||
runAfterScroll(scrollable.scrollTarget, 10, function() {
|
||||
var contentBefore = getComputedStyle(scrollable, '::before').content;
|
||||
assert.ok(!contentBefore || contentBefore === 'none', '::before does not have content');
|
||||
var contentAfter = getComputedStyle(scrollable, '::after').content;
|
||||
assert.ok(!contentAfter || contentAfter === 'none', '::after does not have content');
|
||||
done();
|
||||
});
|
||||
}, 10);
|
||||
});
|
||||
|
||||
test('does not show bottom divider if not scrollable', function(done) {
|
||||
var container = fixture('short');
|
||||
setTimeout(function() {
|
||||
var scrollable = Polymer.dom(container).querySelector('paper-dialog-scrollable');
|
||||
var contentAfter = getComputedStyle(scrollable, '::after').content;
|
||||
assert.ok(!contentAfter || contentAfter === 'none', '::after does not have content');
|
||||
done();
|
||||
}, 10);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,47 +0,0 @@
|
|||
{
|
||||
"name": "paper-dialog",
|
||||
"description": "A Material Design dialog",
|
||||
"version": "1.0.4",
|
||||
"authors": "The Polymer Authors",
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"polymer",
|
||||
"dialog",
|
||||
"overlay"
|
||||
],
|
||||
"main": "paper-dialog.html",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/PolymerElements/paper-dialog"
|
||||
},
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"homepage": "https://github.com/PolymerElements/paper-dialog",
|
||||
"ignore": [],
|
||||
"dependencies": {
|
||||
"neon-animation": "PolymerElements/neon-animation#^1.0.0",
|
||||
"paper-dialog-behavior": "PolymerElements/paper-dialog-behavior#^1.0.0",
|
||||
"paper-styles": "PolymerElements/paper-styles#^1.0.0",
|
||||
"polymer": "Polymer/polymer#^1.1.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",
|
||||
"paper-dropdown-menu": "PolymerElements/paper-dropdown-menu#^1.0.0",
|
||||
"paper-item": "PolymerElements/paper-item#^1.0.0",
|
||||
"paper-menu": "PolymerElements/paper-menu#^1.0.0",
|
||||
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
|
||||
"web-component-tester": "^4.0.0",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
},
|
||||
"_release": "1.0.4",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.0.4",
|
||||
"commit": "53b099bed06bbbab7cb0f82c8209328c1a82aee6"
|
||||
},
|
||||
"_source": "git://github.com/PolymerElements/paper-dialog.git",
|
||||
"_target": "~1.0.0",
|
||||
"_originalSource": "PolymerElements/paper-dialog"
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
bower_components
|
|
@ -1,25 +0,0 @@
|
|||
language: node_js
|
||||
sudo: false
|
||||
before_script:
|
||||
- npm install -g bower polylint web-component-tester
|
||||
- bower install
|
||||
- polylint
|
||||
env:
|
||||
global:
|
||||
- secure: CiislAd2L7WGhu3ZFWeP/tq7aToNIKX//D4gUbafyI1vmFykDOTeZ22UzoFZ/SJ2pHUdoMGyjiYBr+MGS0G81+CEAgUC/8RI5HzWRg10KdEWB7qWQgWlxABdl0MV2T6RY2rv1gMss2b8sFL8FoBsR2ydqeKyGHhiuNG3/th7HBUdyLur4VnGlVHcQAHk8CgszBgL78RFU61+FbJR1RyJpjytAkJJP4X2DFdNx5XYh6nwDWKnRciZEHFzgj9c52eaQKBNOKwJjm/Gc2Mcyhq7inUM9di5qfRhP3EVn3aENC3WJoIyGu3wgzjD+r3Mp+PsEq6OLvm09g6ljbeMKfV9haQ0MPRQTmZiEjsiEXmxzL3qfYZhA/YoySyl/PyrXoAXFE19sbCBV9tCbbmR9vStIZOiFQLtUGAHUosWQOhR2Nym23q7B1sSlYAhaAaQlzkflhkb+h4QFCUW5IBjQEDl4CwG0n0dm7YO+Z+jZFoEz1kiper3D5T8mJxso69WQskG/kENqnrP1U9RMJbFQOQFYXauNBpc5ufbODTRivwHnNA+Gu2D5AbljGM8xcUNlzLJx+BWUU5QIt/ddfjynCdFyUazHNU/P2gH6R8e2ROVzupvBsdr2PyU5kQqdD8yTGPHkOimtlRY2Hsnp50NkNzDzuxIz+1SYjve7OOZXFWpRi4=
|
||||
- secure: iEyYkfoa4Sp68fk1ttK0AEdoJ2i+3Ggx1cFcEuNtTjyrmSDVVb10E6LeTBWgWgxnK1EmV5MRY+5m3BzONDaPJMoChNa1ddqitPSqfK8SARjIUZ9DrliLwgsnfl/k/5EkKxzayH+xASYSqqMknpJC+irIs48oMZPB1zEVRK4FdhaCTPcWlDbdHtqwhDeRjXWmpY4uggRTyuql9PLwSU+P+e2S6UqBvXs5ldwHbC+361l8nDX4eB2AC/RmcSoawHoptd2+40+vJ2hs9+bcmQcD5rwGN3Y793q+F5L5ZTJu3v9KKU+9ABNT7yaIEk497dSA3lWa0I4MNT+pe5UcvJ6A1f5/pKLPZ8gYVdOx61Y9yHYW8c86k+QasGBTgwrzwIhk71iu+t9c6Jtt39mmZpewsfGpmUKoVTCBpO7YYlQwe1BCxQOLwdiudXE1wZKy2yLFSBHGa6wM1C9tLw6IW9Wb0ncUCSP/SIsXFlzBQKpOHBtJe0yGqw6yPf5/mxoVcsm5+F49Vh8nu7CTNVpZ9rcQcObLMAsy9qs7etiCHlzA5bAXtX0mmTob8+R5Cbjiir9LwR8ZltASivJg87taMldtXJDEDxNuHiSytxMTF56OxnWx82ek8aOaDY0WiIzUNEVufVh+sLTp47OHKOJXMRsLXu16TkaOkCVPsBkF2KVNwT4=
|
||||
- CXX=g++-4.8
|
||||
node_js: stable
|
||||
addons:
|
||||
firefox: latest
|
||||
apt:
|
||||
sources:
|
||||
- google-chrome
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- google-chrome-stable
|
||||
- g++-4.8
|
||||
sauce_connect: true
|
||||
script:
|
||||
- xvfb-run wct
|
||||
- "if [ \"${TRAVIS_PULL_REQUEST}\" = \"false\" ]; then wct -s 'default'; fi"
|
|
@ -1,77 +0,0 @@
|
|||
|
||||
<!--
|
||||
This file is autogenerated based on
|
||||
https://github.com/PolymerElements/ContributionGuide/blob/master/CONTRIBUTING.md
|
||||
|
||||
If you edit that file, it will get updated everywhere else.
|
||||
If you edit this file, your changes will get overridden :)
|
||||
|
||||
You can however override the jsbin link with one that's customized to this
|
||||
specific element:
|
||||
|
||||
jsbin=https://jsbin.com/cagaye/edit?html,output
|
||||
-->
|
||||
# Polymer Elements
|
||||
## Guide for Contributors
|
||||
|
||||
Polymer Elements are built in the open, and the Polymer authors eagerly encourage any and all forms of community contribution. When contributing, please follow these guidelines:
|
||||
|
||||
### Filing Issues
|
||||
|
||||
**If you are filing an issue to request a feature**, please provide a clear description of the feature. It can be helpful to describe answers to the following questions:
|
||||
|
||||
1. **Who will use the feature?** _“As someone filling out a form…”_
|
||||
2. **When will they use the feature?** _“When I enter an invalid value…”_
|
||||
3. **What is the user’s goal?** _“I want to be visually notified that the value needs to be corrected…”_
|
||||
|
||||
**If you are filing an issue to report a bug**, please provide:
|
||||
|
||||
1. **A clear description of the bug and related expectations.** Consider using the following example template for reporting a bug:
|
||||
|
||||
```markdown
|
||||
The `paper-foo` element causes the page to turn pink when clicked.
|
||||
|
||||
## Expected outcome
|
||||
|
||||
The page stays the same color.
|
||||
|
||||
## Actual outcome
|
||||
|
||||
The page turns pink.
|
||||
|
||||
## Steps to reproduce
|
||||
|
||||
1. Put a `paper-foo` element in the page.
|
||||
2. Open the page in a web browser.
|
||||
3. Click the `paper-foo` element.
|
||||
```
|
||||
|
||||
2. **A reduced test case that demonstrates the problem.** If possible, please include the test case as a JSBin. Start with this template to easily import and use relevant Polymer Elements: [https://jsbin.com/cagaye/edit?html,output](https://jsbin.com/cagaye/edit?html,output).
|
||||
|
||||
3. **A list of browsers where the problem occurs.** This can be skipped if the problem is the same across all browsers.
|
||||
|
||||
### Submitting Pull Requests
|
||||
|
||||
**Before creating a pull request**, please ensure that an issue exists for the corresponding change in the pull request that you intend to make. **If an issue does not exist, please create one per the guidelines above**. The goal is to discuss the design and necessity of the proposed change with Polymer authors and community before diving into a pull request.
|
||||
|
||||
When submitting pull requests, please provide:
|
||||
|
||||
1. **A reference to the corresponding issue** or issues that will be closed by the pull request. Please refer to these issues in the pull request description using the following syntax:
|
||||
|
||||
```markdown
|
||||
(For a single issue)
|
||||
Fixes #20
|
||||
|
||||
(For multiple issues)
|
||||
Fixes #32, fixes #40
|
||||
```
|
||||
|
||||
2. **A succinct description of the design** used to fix any related issues. For example:
|
||||
|
||||
```markdown
|
||||
This fixes #20 by removing styles that leaked which would cause the page to turn pink whenever `paper-foo` is clicked.
|
||||
```
|
||||
|
||||
3. **At least one test for each bug fixed or feature added** as part of the pull request. Pull requests that fix bugs or add features without accompanying tests will not be considered.
|
||||
|
||||
If a proposed change contains multiple commits, please [squash commits](https://www.google.com/url?q=http://blog.steveklabnik.com/posts/2012-11-08-how-to-squash-commits-in-a-github-pull-request) to as few as is necessary to succinctly express the change. A Polymer author can help you squash commits, so don’t be afraid to ask us if you need help with that!
|
|
@ -1,38 +0,0 @@
|
|||
{
|
||||
"name": "paper-dialog",
|
||||
"description": "A Material Design dialog",
|
||||
"version": "1.0.4",
|
||||
"authors": "The Polymer Authors",
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"polymer",
|
||||
"dialog",
|
||||
"overlay"
|
||||
],
|
||||
"main": "paper-dialog.html",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/PolymerElements/paper-dialog"
|
||||
},
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"homepage": "https://github.com/PolymerElements/paper-dialog",
|
||||
"ignore": [],
|
||||
"dependencies": {
|
||||
"neon-animation": "PolymerElements/neon-animation#^1.0.0",
|
||||
"paper-dialog-behavior": "PolymerElements/paper-dialog-behavior#^1.0.0",
|
||||
"paper-styles": "PolymerElements/paper-styles#^1.0.0",
|
||||
"polymer": "Polymer/polymer#^1.1.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",
|
||||
"paper-dropdown-menu": "PolymerElements/paper-dropdown-menu#^1.0.0",
|
||||
"paper-item": "PolymerElements/paper-item#^1.0.0",
|
||||
"paper-menu": "PolymerElements/paper-menu#^1.0.0",
|
||||
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
|
||||
"web-component-tester": "^4.0.0",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
}
|
||||
}
|
|
@ -1,199 +0,0 @@
|
|||
<!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 demo</title>
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
|
||||
<link rel="import" href="../paper-dialog.html">
|
||||
<link rel="import" href="../../paper-button/paper-button.html">
|
||||
<link rel="import" href="../../paper-dialog-scrollable/paper-dialog-scrollable.html">
|
||||
<link rel="import" href="../../paper-styles/color.html">
|
||||
<link rel="import" href="../../paper-styles/demo-pages.html">
|
||||
<link rel="import" href="../../neon-animation/neon-animations.html">
|
||||
<link rel="import" href="../../paper-dropdown-menu/paper-dropdown-menu.html">
|
||||
<link rel="import" href="../../paper-menu/paper-menu.html">
|
||||
<link rel="import" href="../../paper-item/paper-item.html">
|
||||
|
||||
<link rel="stylesheet" href="../../paper-styles/demo.css">
|
||||
|
||||
<style is="custom-style">
|
||||
|
||||
section {
|
||||
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
||||
}
|
||||
|
||||
section > paper-button {
|
||||
background-color: var(--google-grey-300);
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
section > paper-button:hover {
|
||||
background-color: var(--paper-light-blue-200);
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
paper-dialog.colored {
|
||||
border: 2px solid;
|
||||
border-color: var(--paper-green-500);
|
||||
background-color: var(--paper-light-green-50);
|
||||
color: var(--paper-green-500);
|
||||
}
|
||||
|
||||
paper-dialog.size-position {
|
||||
position: fixed;
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body unresolved>
|
||||
|
||||
<section onclick="clickHandler(event)">
|
||||
<h4>Dialog layouts</h4>
|
||||
|
||||
<paper-button data-dialog="dialog">plain dialog</paper-button>
|
||||
<paper-button data-dialog="scrolling">scrolling dialog</paper-button>
|
||||
<paper-button data-dialog="actions">dialog with actions</paper-button>
|
||||
<paper-button data-dialog="modal">modal dialog</paper-button>
|
||||
<paper-button data-dialog="dropdown">dialog with dropdown</paper-button>
|
||||
<paper-button data-dialog="nested">dialog with nested dialog</paper-button>
|
||||
|
||||
<paper-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>
|
||||
</paper-dialog>
|
||||
|
||||
<paper-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 autofocus>OK</paper-button>
|
||||
</div>
|
||||
</paper-dialog>
|
||||
|
||||
<paper-dialog id="actions">
|
||||
<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>
|
||||
<div class="buttons">
|
||||
<paper-button >More Info...</paper-button>
|
||||
<paper-button dialog-dismiss>Decline</paper-button>
|
||||
<paper-button dialog-confirm autofocus>Accept</paper-button>
|
||||
</div>
|
||||
</paper-dialog>
|
||||
|
||||
<paper-dialog id="modal" modal>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing 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.</p>
|
||||
<div class="buttons">
|
||||
<paper-button dialog-confirm autofocus>Tap me to close</paper-button>
|
||||
</div>
|
||||
</paper-dialog>
|
||||
|
||||
<paper-dialog id="dropdown">
|
||||
<h2>Dialog Title</h2>
|
||||
<paper-dropdown-menu label="Value">
|
||||
<paper-menu class="dropdown-content">
|
||||
<paper-item>1</paper-item>
|
||||
<paper-item>2</paper-item>
|
||||
<paper-item>3</paper-item>
|
||||
<paper-item>4</paper-item>
|
||||
<paper-item>5</paper-item>
|
||||
<paper-item>6</paper-item>
|
||||
<paper-item>7</paper-item>
|
||||
<paper-item>8</paper-item>
|
||||
<paper-item>9</paper-item>
|
||||
<paper-item>10</paper-item>
|
||||
</paper-menu>
|
||||
</paper-dropdown-menu>
|
||||
</paper-dialog>
|
||||
|
||||
<paper-dialog id="nested">
|
||||
<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>
|
||||
<div class="buttons">
|
||||
<paper-button data-dialog="innerDialog">Open nested dialog</paper-button>
|
||||
</div>
|
||||
</paper-dialog>
|
||||
|
||||
<paper-dialog id="innerDialog">
|
||||
<h2>Dialog Title</h2>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
|
||||
</paper-dialog>
|
||||
|
||||
</section>
|
||||
|
||||
<section onclick="clickHandler(event)">
|
||||
<h4>Custom styling</h4>
|
||||
<paper-button data-dialog="colors">colors</paper-button>
|
||||
<paper-button data-dialog="position">size & position</paper-button>
|
||||
|
||||
<paper-dialog id="colors" class="colored">
|
||||
<h2>Custom Colors</h2>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing 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>
|
||||
|
||||
<paper-dialog id="position" class="size-position">
|
||||
<h2>Custom Size & Position</h2>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing 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>
|
||||
</section>
|
||||
|
||||
<section onclick="clickHandler(event)">
|
||||
<h4>Transitions</h4>
|
||||
<paper-button data-dialog="animated">transitions</paper-button>
|
||||
<paper-dialog id="animated" entry-animation="scale-up-animation" exit-animation="fade-out-animation" with-backdrop>
|
||||
<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>
|
||||
</paper-dialog>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
function clickHandler(e) {
|
||||
var button = e.target;
|
||||
while (!button.hasAttribute('data-dialog') && button !== document.body) {
|
||||
button = button.parentElement;
|
||||
}
|
||||
|
||||
if (!button.hasAttribute('data-dialog')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var id = button.getAttribute('data-dialog');
|
||||
var dialog = document.getElementById(id);
|
||||
if (dialog) {
|
||||
dialog.open();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,58 +0,0 @@
|
|||
<?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="0,124 0,126 2,126 "/>
|
||||
<polygon points="0,111.6 0,114.4 11.6,126 14.4,126 "/>
|
||||
<polygon points="0,99.1 0,101.9 24.1,126 26.9,126 "/>
|
||||
<polygon points="0,86.6 0,89.5 36.5,126 39.4,126 "/>
|
||||
<polygon points="0,74.2 0,77 49,126 51.8,126 "/>
|
||||
<polygon points="0,61.7 0,64.5 61.5,126 64.3,126 "/>
|
||||
<polygon points="0,49.2 0,52.1 73.9,126 76.8,126 "/>
|
||||
<polygon points="0,36.8 0,39.6 86.4,126 89.2,126 "/>
|
||||
<polygon points="0,24.3 0,27.1 98.9,126 101.7,126 "/>
|
||||
<polygon points="75.2,87 74,87 74,85.8 0,11.8 0,14.7 111.3,126 114.2,126 "/>
|
||||
<polygon points="87.6,87 84.8,87 123.8,126 126.6,126 "/>
|
||||
<polygon points="74,76.2 74,73.4 0.6,0 0,0 0,2.2 "/>
|
||||
<polygon points="74,63.7 74,60.9 13.1,0 10.3,0 "/>
|
||||
<polygon points="100.1,87 97.3,87 136.3,126 139.1,126 "/>
|
||||
<polygon points="112.6,87 109.7,87 148.7,126 151.6,126 "/>
|
||||
<polygon points="74,51.3 74,48.4 25.6,0 22.7,0 "/>
|
||||
<polygon points="125,87 122.2,87 161.2,126 164,126 "/>
|
||||
<polygon points="74.2,39 77,39 38,0 35.2,0 "/>
|
||||
<polygon points="86.7,39 89.5,39 50.5,0 47.7,0 "/>
|
||||
<polygon points="137.5,87 134.7,87 173.7,126 176.5,126 "/>
|
||||
<polygon points="150,87 147.1,87 186.1,126 189,126 "/>
|
||||
<polygon points="99.1,39 102,39 63,0 60.1,0 "/>
|
||||
<polygon points="150,74.6 150,77.4 198.6,126 201.4,126 "/>
|
||||
<polygon points="111.6,39 114.4,39 75.4,0 72.6,0 "/>
|
||||
<polygon points="150,62.1 150,64.9 211.1,126 213.9,126 "/>
|
||||
<polygon points="124.1,39 126.9,39 87.9,0 85.1,0 "/>
|
||||
<polygon points="100.3,0 97.5,0 136.5,39 139.3,39 "/>
|
||||
<polygon points="150,49.7 150,52.5 223.5,126 225,126 225,124.7 "/>
|
||||
<polygon points="112.8,0 110,0 149,39 150,39 150,40 225,115 225,112.2 "/>
|
||||
<polygon points="125.3,0 122.5,0 225,102.5 225,99.7 "/>
|
||||
<polygon points="137.7,0 134.9,0 225,90.1 225,87.3 "/>
|
||||
<polygon points="150.2,0 147.4,0 225,77.6 225,74.8 "/>
|
||||
<polygon points="162.7,0 159.8,0 225,65.2 225,62.3 "/>
|
||||
<polygon points="175.1,0 172.3,0 225,52.7 225,49.9 "/>
|
||||
<polygon points="187.6,0 184.8,0 225,40.2 225,37.4 "/>
|
||||
<polygon points="200.1,0 197.2,0 225,27.8 225,24.9 "/>
|
||||
<polygon points="212.5,0 209.7,0 225,15.3 225,12.5 "/>
|
||||
<polygon points="225,0 222.2,0 225,2.8 225,0 "/>
|
||||
</g>
|
||||
<g id="ic_x5F_add_x0D_">
|
||||
</g>
|
||||
<path d="M151,88H73V38h78V88z M75,86h74V40H75V86z"/>
|
||||
</g>
|
||||
<g id="Guides">
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 2.9 KiB |
|
@ -1,30 +0,0 @@
|
|||
<!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</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>
|
|
@ -1,122 +0,0 @@
|
|||
<!--
|
||||
@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="../neon-animation/neon-animation-runner-behavior.html">
|
||||
<link rel="import" href="../paper-dialog-behavior/paper-dialog-behavior.html">
|
||||
<link rel="import" href="../paper-dialog-behavior/paper-dialog-shared-styles.html">
|
||||
<!--
|
||||
Material design: [Dialogs](https://www.google.com/design/spec/components/dialogs.html)
|
||||
|
||||
`<paper-dialog>` is a dialog with Material Design styling and optional animations when it is
|
||||
opened or closed. It provides styles for a header, content area, and an action area for buttons.
|
||||
You can use the `<paper-dialog-scrollable>` element (in its own repository) if you need a scrolling
|
||||
content area. See `Polymer.PaperDialogBehavior` for specifics.
|
||||
|
||||
For example, the following code implements a dialog with a header, scrolling content area and
|
||||
buttons.
|
||||
|
||||
<paper-dialog>
|
||||
<h2>Header</h2>
|
||||
<paper-dialog-scrollable>
|
||||
Lorem ipsum...
|
||||
</paper-dialog-scrollable>
|
||||
<div class="buttons">
|
||||
<paper-button dialog-dismiss>Cancel</paper-button>
|
||||
<paper-button dialog-confirm>Accept</paper-button>
|
||||
</div>
|
||||
</paper-dialog>
|
||||
|
||||
### Styling
|
||||
|
||||
See the docs for `Polymer.PaperDialogBehavior` for the custom properties available for styling
|
||||
this element.
|
||||
|
||||
### Animations
|
||||
|
||||
Set the `entry-animation` and/or `exit-animation` attributes to add an animation when the dialog
|
||||
is opened or closed. See the documentation in
|
||||
[PolymerElements/neon-animation](https://github.com/PolymerElements/neon-animation) for more info.
|
||||
|
||||
For example:
|
||||
|
||||
<link rel="import" href="components/neon-animation/animations/scale-up-animation.html">
|
||||
<link rel="import" href="components/neon-animation/animations/fade-out-animation.html">
|
||||
|
||||
<paper-dialog entry-animation="scale-up-animation"
|
||||
exit-animation="fade-out-animation">
|
||||
<h2>Header</h2>
|
||||
<div>Dialog body</div>
|
||||
</paper-dialog>
|
||||
|
||||
### Accessibility
|
||||
|
||||
See the docs for `Polymer.PaperDialogBehavior` for accessibility features implemented by this
|
||||
element.
|
||||
|
||||
@group Paper Elements
|
||||
@element paper-dialog
|
||||
@hero hero.svg
|
||||
@demo demo/index.html
|
||||
-->
|
||||
|
||||
<dom-module id="paper-dialog">
|
||||
<template>
|
||||
<style include="paper-dialog-shared-styles"></style>
|
||||
<content></content>
|
||||
</template>
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
|
||||
(function() {
|
||||
|
||||
Polymer({
|
||||
|
||||
is: 'paper-dialog',
|
||||
|
||||
behaviors: [
|
||||
Polymer.PaperDialogBehavior,
|
||||
Polymer.NeonAnimationRunnerBehavior
|
||||
],
|
||||
|
||||
listeners: {
|
||||
'neon-animation-finish': '_onNeonAnimationFinish'
|
||||
},
|
||||
|
||||
_renderOpened: function() {
|
||||
this.cancelAnimation();
|
||||
if (this.withBackdrop) {
|
||||
this.backdropElement.open();
|
||||
}
|
||||
this.playAnimation('entry');
|
||||
},
|
||||
|
||||
_renderClosed: function() {
|
||||
this.cancelAnimation();
|
||||
if (this.withBackdrop) {
|
||||
this.backdropElement.close();
|
||||
}
|
||||
this.playAnimation('exit');
|
||||
},
|
||||
|
||||
_onNeonAnimationFinish: function() {
|
||||
if (this.opened) {
|
||||
this._finishRenderOpened();
|
||||
} else {
|
||||
this._finishRenderClosed();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
|
@ -1,31 +0,0 @@
|
|||
<!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.html',
|
||||
'paper-dialog.html?dom=shadow'
|
||||
]);
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body></html>
|
|
@ -1,49 +0,0 @@
|
|||
<!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="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
<link rel="import" href="../paper-dialog.html">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<test-fixture id="basic">
|
||||
<template>
|
||||
<paper-dialog>
|
||||
<p>Dialog</p>
|
||||
</paper-dialog>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
|
||||
suite('a11y', function() {
|
||||
|
||||
test('dialog has role="dialog"', function() {
|
||||
var dialog = fixture('basic');
|
||||
assert.equal(dialog.getAttribute('role'), 'dialog', 'has role="dialog"');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,54 +0,0 @@
|
|||
{
|
||||
"name": "paper-dropdown-menu",
|
||||
"version": "1.0.5",
|
||||
"description": "An element that works similarly to a native browser select",
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
],
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"web-component",
|
||||
"polymer",
|
||||
"dropdown",
|
||||
"select"
|
||||
],
|
||||
"main": "paper-dropdown-menu.html",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/PolymerElements/paper-dropdown-menu"
|
||||
},
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"homepage": "https://github.com/PolymerElements/paper-dropdown-menu",
|
||||
"dependencies": {
|
||||
"polymer": "polymer/polymer#^1.0.0",
|
||||
"iron-a11y-keys-behavior": "polymerelements/iron-a11y-keys-behavior#^1.0.0",
|
||||
"iron-icon": "polymerelements/iron-icon#^1.0.0",
|
||||
"iron-icons": "polymerelements/iron-icons#^1.0.0",
|
||||
"paper-input": "polymerelements/paper-input#^1.0.9",
|
||||
"paper-menu-button": "polymerelements/paper-menu-button#^1.0.0",
|
||||
"paper-ripple": "polymerelements/paper-ripple#^1.0.0",
|
||||
"paper-styles": "polymerelements/paper-styles#^1.0.0",
|
||||
"iron-form-element-behavior": "PolymerElements/iron-form-element-behavior#^1.0.0",
|
||||
"iron-validatable-behavior": "PolymerElements/iron-validatable-behavior#^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"iron-component-page": "polymerelements/iron-component-page#^1.0.0",
|
||||
"test-fixture": "polymerelements/test-fixture#^1.0.0",
|
||||
"iron-test-helpers": "polymerelements/iron-test-helpers#^1.0.0",
|
||||
"paper-item": "polymerelements/paper-item#^1.0.0",
|
||||
"paper-menu": "polymerelements/paper-menu#^1.0.0",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0",
|
||||
"web-component-tester": "*",
|
||||
"paper-tabs": "polymerelements/paper-tabs#^1.0.0"
|
||||
},
|
||||
"_release": "1.0.5",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.0.5",
|
||||
"commit": "63b8200dc68ce297dcf2000a60587f3f68464f31"
|
||||
},
|
||||
"_source": "git://github.com/PolymerElements/paper-dropdown-menu.git",
|
||||
"_target": "~1.0.1",
|
||||
"_originalSource": "PolymerElements/paper-dropdown-menu"
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
bower_components
|
|
@ -1,45 +0,0 @@
|
|||
{
|
||||
"name": "paper-dropdown-menu",
|
||||
"version": "1.0.5",
|
||||
"description": "An element that works similarly to a native browser select",
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
],
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"web-component",
|
||||
"polymer",
|
||||
"dropdown",
|
||||
"select"
|
||||
],
|
||||
"main": "paper-dropdown-menu.html",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/PolymerElements/paper-dropdown-menu"
|
||||
},
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"homepage": "https://github.com/PolymerElements/paper-dropdown-menu",
|
||||
"dependencies": {
|
||||
"polymer": "polymer/polymer#^1.0.0",
|
||||
"iron-a11y-keys-behavior": "polymerelements/iron-a11y-keys-behavior#^1.0.0",
|
||||
"iron-icon": "polymerelements/iron-icon#^1.0.0",
|
||||
"iron-icons": "polymerelements/iron-icons#^1.0.0",
|
||||
"paper-input": "polymerelements/paper-input#^1.0.9",
|
||||
"paper-menu-button": "polymerelements/paper-menu-button#^1.0.0",
|
||||
"paper-ripple": "polymerelements/paper-ripple#^1.0.0",
|
||||
"paper-styles": "polymerelements/paper-styles#^1.0.0",
|
||||
"iron-form-element-behavior": "PolymerElements/iron-form-element-behavior#^1.0.0",
|
||||
"iron-validatable-behavior": "PolymerElements/iron-validatable-behavior#^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"iron-component-page": "polymerelements/iron-component-page#^1.0.0",
|
||||
"test-fixture": "polymerelements/test-fixture#^1.0.0",
|
||||
"iron-test-helpers": "polymerelements/iron-test-helpers#^1.0.0",
|
||||
"paper-item": "polymerelements/paper-item#^1.0.0",
|
||||
"paper-menu": "polymerelements/paper-menu#^1.0.0",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0",
|
||||
"web-component-tester": "*",
|
||||
"paper-tabs": "polymerelements/paper-tabs#^1.0.0"
|
||||
}
|
||||
}
|
|
@ -1,191 +0,0 @@
|
|||
<!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.0, user-scalable=yes">
|
||||
|
||||
<title>paper-dropdown-menu demo</title>
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
|
||||
<link rel="import" href="../../iron-icons/iron-icons.html">
|
||||
<link rel="import" href="../../iron-icon/iron-icon.html">
|
||||
<link rel="import" href="../../paper-menu/paper-menu.html">
|
||||
<link rel="import" href="../../paper-item/paper-item.html">
|
||||
<link rel="import" href="../../paper-button/paper-button.html">
|
||||
<link rel="import" href="../../paper-styles/demo-pages.html">
|
||||
<link rel="import" href="../../paper-tabs/paper-tabs.html">
|
||||
|
||||
<link rel="import" href="../paper-dropdown-menu.html">
|
||||
|
||||
<style>
|
||||
paper-menu {
|
||||
display: block;
|
||||
}
|
||||
|
||||
paper-dropdown-menu {
|
||||
text-align: left;
|
||||
margin: auto;
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
paper-dropdown-menu.letters {
|
||||
width: 90px;
|
||||
}
|
||||
|
||||
paper-tabs {
|
||||
width: 400px;
|
||||
}
|
||||
|
||||
.horizontal-section {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<template id="Demo" is="dom-bind">
|
||||
|
||||
<div class="horizontal-section-container">
|
||||
<div>
|
||||
<h4>Basic Menu</h4>
|
||||
<div class="horizontal-section">
|
||||
<paper-dropdown-menu label="Dinosaurs">
|
||||
<paper-menu class="dropdown-content">
|
||||
<template is="dom-repeat" items="[[dinosaurs]]" as="dinosaur">
|
||||
<paper-item>[[dinosaur]]</paper-item>
|
||||
</template>
|
||||
</paper-menu>
|
||||
</paper-dropdown-menu>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="horizontal-section-container">
|
||||
<div>
|
||||
<h4>Pre-selected Value</h4>
|
||||
<div class="horizontal-section">
|
||||
<paper-dropdown-menu label="Dinosaurs">
|
||||
<paper-menu class="dropdown-content" selected="1">
|
||||
<template is="dom-repeat" items="[[dinosaurs]]" as="dinosaur">
|
||||
<paper-item>[[dinosaur]]</paper-item>
|
||||
</template>
|
||||
</paper-menu>
|
||||
</paper-dropdown-menu>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="horizontal-section-container">
|
||||
<div>
|
||||
<h4>Disabled</h4>
|
||||
<div class="horizontal-section">
|
||||
<paper-dropdown-menu disabled label="Disabled">
|
||||
<paper-menu class="dropdown-content">
|
||||
<template is="dom-repeat" items="[[letters]]" as="letter">
|
||||
<paper-item>[[letter]]</paper-item>
|
||||
</template>
|
||||
</paper-menu>
|
||||
</paper-dropdown-menu>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="horizontal-section-container">
|
||||
<div>
|
||||
<h4>Alternative Content</h4>
|
||||
<div class="horizontal-section">
|
||||
<paper-dropdown-menu label="Menu tabs!?">
|
||||
<paper-tabs class="dropdown-content">
|
||||
<template is="dom-repeat" items="[[letters]]" as="letter">
|
||||
<paper-tab>[[letter]]</paper-tab>
|
||||
</template>
|
||||
</paper-tabs>
|
||||
</paper-dropdown-menu>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="horizontal-section-container">
|
||||
<div>
|
||||
<h4>No Label Float</h4>
|
||||
<div class="horizontal-section">
|
||||
<paper-dropdown-menu class="letters" label="Letters" no-label-float>
|
||||
<paper-menu class="dropdown-content">
|
||||
<template is="dom-repeat" items="[[letters]]" as="letter">
|
||||
<paper-item>[[letter]]</paper-item>
|
||||
</template>
|
||||
</paper-menu>
|
||||
</paper-dropdown-menu>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="horizontal-section-container">
|
||||
<div>
|
||||
<h4>No Ripple, No Animations</h4>
|
||||
<div class="horizontal-section">
|
||||
<paper-dropdown-menu label="Dinosaurs" noink no-animations>
|
||||
<paper-menu class="dropdown-content">
|
||||
<template is="dom-repeat" items="[[dinosaurs]]" as="dinosaur">
|
||||
<paper-item>[[dinosaur]]</paper-item>
|
||||
</template>
|
||||
</paper-menu>
|
||||
</paper-dropdown-menu>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
Demo.letters = [
|
||||
'alpha',
|
||||
'beta',
|
||||
'gamma',
|
||||
'delta',
|
||||
'epsilon'
|
||||
];
|
||||
Demo.dinosaurs = [
|
||||
'allosaurus',
|
||||
'brontosaurus',
|
||||
'carcharodontosaurus',
|
||||
'diplodocus',
|
||||
'ekrixinatosaurus',
|
||||
'fukuiraptor',
|
||||
'gallimimus',
|
||||
'hadrosaurus',
|
||||
'iguanodon',
|
||||
'jainosaurus',
|
||||
'kritosaurus',
|
||||
'liaoceratops',
|
||||
'megalosaurus',
|
||||
'nemegtosaurus',
|
||||
'ornithomimus',
|
||||
'protoceratops',
|
||||
'quetecsaurus',
|
||||
'rajasaurus',
|
||||
'stegosaurus',
|
||||
'triceratops',
|
||||
'utahraptor',
|
||||
'vulcanodon',
|
||||
'wannanosaurus',
|
||||
'xenoceratops',
|
||||
'yandusaurus',
|
||||
'zephyrosaurus'
|
||||
];
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue