summaryrefslogtreecommitdiff
path: root/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior')
-rw-r--r--chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/.bower.json41
-rw-r--r--chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/CONTRIBUTING.md77
-rw-r--r--chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/README.md36
-rw-r--r--chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/bower.json31
-rw-r--r--chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/demo/index.html29
-rw-r--r--chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/demo/src/x-app.html114
-rw-r--r--chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/index.html25
-rw-r--r--chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/iron-resizable-behavior.html195
8 files changed, 548 insertions, 0 deletions
diff --git a/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/.bower.json b/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/.bower.json
new file mode 100644
index 00000000000..2e765b93245
--- /dev/null
+++ b/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/.bower.json
@@ -0,0 +1,41 @@
+{
+ "name": "iron-resizable-behavior",
+ "version": "1.0.3",
+ "license": "http://polymer.github.io/LICENSE.txt",
+ "description": "Coordinates the flow of resizeable elements",
+ "private": true,
+ "main": "iron-resizable-behavior.html",
+ "authors": [
+ "The Polymer Authors"
+ ],
+ "keywords": [
+ "web-components",
+ "polymer",
+ "iron",
+ "behavior"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/PolymerElements/iron-resizable-behavior.git"
+ },
+ "dependencies": {
+ "polymer": "Polymer/polymer#^1.0.0"
+ },
+ "devDependencies": {
+ "iron-component-page": "polymerelements/iron-component-page#^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-resizable-behavior",
+ "_release": "1.0.3",
+ "_resolution": {
+ "type": "version",
+ "tag": "v1.0.3",
+ "commit": "dda1df6aaf452aedf3e52ff0cf69e72439452216"
+ },
+ "_source": "git://github.com/PolymerElements/iron-resizable-behavior.git",
+ "_target": "^1.0.0",
+ "_originalSource": "PolymerElements/iron-resizable-behavior"
+} \ No newline at end of file
diff --git a/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/CONTRIBUTING.md b/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/CONTRIBUTING.md
new file mode 100644
index 00000000000..f147978a3e1
--- /dev/null
+++ b/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/CONTRIBUTING.md
@@ -0,0 +1,77 @@
+
+<!--
+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!
diff --git a/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/README.md b/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/README.md
new file mode 100644
index 00000000000..2f37628c126
--- /dev/null
+++ b/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/README.md
@@ -0,0 +1,36 @@
+
+<!---
+
+This README is automatically generated from the comments in these files:
+iron-resizable-behavior.html
+
+Edit those files, and our readme bot will duplicate them over here!
+Edit this file, and the bot will squash your changes :)
+
+The bot does some handling of markdown. Please file a bug if it does the wrong
+thing! https://github.com/PolymerLabs/tedium/issues
+
+-->
+
+[![Build status](https://travis-ci.org/PolymerElements/iron-resizable-behavior.svg?branch=master)](https://travis-ci.org/PolymerElements/iron-resizable-behavior)
+
+_[Demo and API docs](https://elements.polymer-project.org/elements/iron-resizable-behavior)_
+
+
+##Polymer.IronResizableBehavior
+
+`IronResizableBehavior` is a behavior that can be used in Polymer elements to
+coordinate the flow of resize events between "resizers" (elements that control the
+size or hidden state of their children) and "resizables" (elements that need to be
+notified when they are resized or un-hidden by their parents in order to take
+action on their new measurements).
+
+Elements that perform measurement should add the `IronResizableBehavior` behavior to
+their element definition and listen for the `iron-resize` event on themselves.
+This event will be fired when they become showing after having been hidden,
+when they are resized explicitly by another resizable, or when the window has been
+resized.
+
+Note, the `iron-resize` event is non-bubbling.
+
+
diff --git a/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/bower.json b/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/bower.json
new file mode 100644
index 00000000000..053bfd0c88a
--- /dev/null
+++ b/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/bower.json
@@ -0,0 +1,31 @@
+{
+ "name": "iron-resizable-behavior",
+ "version": "1.0.3",
+ "license": "http://polymer.github.io/LICENSE.txt",
+ "description": "Coordinates the flow of resizeable elements",
+ "private": true,
+ "main": "iron-resizable-behavior.html",
+ "authors": [
+ "The Polymer Authors"
+ ],
+ "keywords": [
+ "web-components",
+ "polymer",
+ "iron",
+ "behavior"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/PolymerElements/iron-resizable-behavior.git"
+ },
+ "dependencies": {
+ "polymer": "Polymer/polymer#^1.0.0"
+ },
+ "devDependencies": {
+ "iron-component-page": "polymerelements/iron-component-page#^1.0.0",
+ "test-fixture": "polymerelements/test-fixture#^1.0.0",
+ "web-component-tester": "^4.0.0",
+ "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
+ },
+ "ignore": []
+}
diff --git a/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/demo/index.html b/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/demo/index.html
new file mode 100644
index 00000000000..2896c50d256
--- /dev/null
+++ b/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/demo/index.html
@@ -0,0 +1,29 @@
+<!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-resizable-behavior demo</title>
+
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+
+ <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
+ <link rel="import" href="src/x-app.html">
+
+</head>
+<body>
+
+ <x-app></x-app>
+
+</body>
+</html>
diff --git a/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/demo/src/x-app.html b/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/demo/src/x-app.html
new file mode 100644
index 00000000000..c334ad3d2fa
--- /dev/null
+++ b/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/demo/src/x-app.html
@@ -0,0 +1,114 @@
+<!--
+@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-resizable-behavior.html">
+
+<dom-module id="x-puck">
+
+ <style>
+
+ :host {
+ display: inline-block;
+ border: 3px solid lightblue;
+ }
+
+ </style>
+
+ <template>
+
+ <b>I'm a resize-aware, thirdifying puck at (<span>{{x}}</span> x <span>{{y}}</span>).</b>
+
+ </template>
+
+</dom-module>
+
+<script>
+
+ Polymer({
+
+ is: 'x-puck',
+
+ behaviors: [
+ Polymer.IronResizableBehavior
+ ],
+
+ properties: {
+ x: {
+ type: Number,
+ value: 0
+ },
+
+ y: {
+ type: Number,
+ value: 0
+ }
+ },
+
+ listeners: {
+ 'iron-resize': '_onIronResize'
+ },
+
+ attached: function() {
+ this.async(this.notifyResize, 1);
+ },
+
+ get parent() {
+ if (this.parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
+ return this.parentNode.host;
+ }
+
+ return this.parentNode;
+ },
+
+ _onIronResize: function() {
+ var x = this.x = Math.floor(this.parent.offsetWidth / 3);
+ var y = this.y = Math.floor(this.parent.offsetHeight / 3);
+
+ this.translate3d(x + 'px', y + 'px', 0);
+ }
+ });
+
+</script>
+
+<dom-module id="x-app">
+
+ <style>
+
+ :host {
+ display: block;
+ position: absolute;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ }
+
+ </style>
+
+ <template>
+
+ <x-puck></x-puck>
+
+ </template>
+
+</dom-module>
+
+<script>
+
+ Polymer({
+
+ is: 'x-app',
+
+ behaviors: [
+ Polymer.IronResizableBehavior
+ ]
+ });
+
+</script>
diff --git a/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/index.html b/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/index.html
new file mode 100644
index 00000000000..b9b8809560f
--- /dev/null
+++ b/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/index.html
@@ -0,0 +1,25 @@
+<!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-resizable-behavior</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>
diff --git a/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/iron-resizable-behavior.html b/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/iron-resizable-behavior.html
new file mode 100644
index 00000000000..9ac0d3967e8
--- /dev/null
+++ b/chromium/third_party/catapult/third_party/polymer/components/iron-resizable-behavior/iron-resizable-behavior.html
@@ -0,0 +1,195 @@
+<!--
+@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>
+ /**
+ * `IronResizableBehavior` is a behavior that can be used in Polymer elements to
+ * coordinate the flow of resize events between "resizers" (elements that control the
+ * size or hidden state of their children) and "resizables" (elements that need to be
+ * notified when they are resized or un-hidden by their parents in order to take
+ * action on their new measurements).
+ *
+ * Elements that perform measurement should add the `IronResizableBehavior` behavior to
+ * their element definition and listen for the `iron-resize` event on themselves.
+ * This event will be fired when they become showing after having been hidden,
+ * when they are resized explicitly by another resizable, or when the window has been
+ * resized.
+ *
+ * Note, the `iron-resize` event is non-bubbling.
+ *
+ * @polymerBehavior Polymer.IronResizableBehavior
+ * @demo demo/index.html
+ **/
+ Polymer.IronResizableBehavior = {
+ properties: {
+ /**
+ * The closest ancestor element that implements `IronResizableBehavior`.
+ */
+ _parentResizable: {
+ type: Object,
+ observer: '_parentResizableChanged'
+ },
+
+ /**
+ * True if this element is currently notifying its descedant elements of
+ * resize.
+ */
+ _notifyingDescendant: {
+ type: Boolean,
+ value: false
+ }
+ },
+
+ listeners: {
+ 'iron-request-resize-notifications': '_onIronRequestResizeNotifications'
+ },
+
+ created: function() {
+ // We don't really need property effects on these, and also we want them
+ // to be created before the `_parentResizable` observer fires:
+ this._interestedResizables = [];
+ this._boundNotifyResize = this.notifyResize.bind(this);
+ },
+
+ attached: function() {
+ this.fire('iron-request-resize-notifications', null, {
+ node: this,
+ bubbles: true,
+ cancelable: true
+ });
+
+ if (!this._parentResizable) {
+ window.addEventListener('resize', this._boundNotifyResize);
+ this.notifyResize();
+ }
+ },
+
+ detached: function() {
+ if (this._parentResizable) {
+ this._parentResizable.stopResizeNotificationsFor(this);
+ } else {
+ window.removeEventListener('resize', this._boundNotifyResize);
+ }
+
+ this._parentResizable = null;
+ },
+
+ /**
+ * Can be called to manually notify a resizable and its descendant
+ * resizables of a resize change.
+ */
+ notifyResize: function() {
+ if (!this.isAttached) {
+ return;
+ }
+
+ this._interestedResizables.forEach(function(resizable) {
+ if (this.resizerShouldNotify(resizable)) {
+ this._notifyDescendant(resizable);
+ }
+ }, this);
+
+ this._fireResize();
+ },
+
+ /**
+ * Used to assign the closest resizable ancestor to this resizable
+ * if the ancestor detects a request for notifications.
+ */
+ assignParentResizable: function(parentResizable) {
+ this._parentResizable = parentResizable;
+ },
+
+ /**
+ * Used to remove a resizable descendant from the list of descendants
+ * that should be notified of a resize change.
+ */
+ stopResizeNotificationsFor: function(target) {
+ var index = this._interestedResizables.indexOf(target);
+
+ if (index > -1) {
+ this._interestedResizables.splice(index, 1);
+ this.unlisten(target, 'iron-resize', '_onDescendantIronResize');
+ }
+ },
+
+ /**
+ * This method can be overridden to filter nested elements that should or
+ * should not be notified by the current element. Return true if an element
+ * should be notified, or false if it should not be notified.
+ *
+ * @param {HTMLElement} element A candidate descendant element that
+ * implements `IronResizableBehavior`.
+ * @return {boolean} True if the `element` should be notified of resize.
+ */
+ resizerShouldNotify: function(element) { return true; },
+
+ _onDescendantIronResize: function(event) {
+ if (this._notifyingDescendant) {
+ event.stopPropagation();
+ return;
+ }
+
+ // NOTE(cdata): In ShadowDOM, event retargetting makes echoing of the
+ // otherwise non-bubbling event "just work." We do it manually here for
+ // the case where Polymer is not using shadow roots for whatever reason:
+ if (!Polymer.Settings.useShadow) {
+ this._fireResize();
+ }
+ },
+
+ _fireResize: function() {
+ this.fire('iron-resize', null, {
+ node: this,
+ bubbles: false
+ });
+ },
+
+ _onIronRequestResizeNotifications: function(event) {
+ var target = event.path ? event.path[0] : event.target;
+
+ if (target === this) {
+ return;
+ }
+
+ if (this._interestedResizables.indexOf(target) === -1) {
+ this._interestedResizables.push(target);
+ this.listen(target, 'iron-resize', '_onDescendantIronResize');
+ }
+
+ target.assignParentResizable(this);
+ this._notifyDescendant(target);
+
+ event.stopPropagation();
+ },
+
+ _parentResizableChanged: function(parentResizable) {
+ if (parentResizable) {
+ window.removeEventListener('resize', this._boundNotifyResize);
+ }
+ },
+
+ _notifyDescendant: function(descendant) {
+ // NOTE(cdata): In IE10, attached is fired on children first, so it's
+ // important not to notify them if the parent is not attached yet (or
+ // else they will get redundantly notified when the parent attaches).
+ if (!this.isAttached) {
+ return;
+ }
+
+ this._notifyingDescendant = true;
+ descendant.notifyResize();
+ this._notifyingDescendant = false;
+ }
+ };
+</script>
+