polymer-paper-elements-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +51 -0
- data/Rakefile +1 -0
- data/app/assets/components/iron-a11y-announcer/iron-a11y-announcer.html +125 -0
- data/app/assets/components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html +418 -0
- data/app/assets/components/iron-autogrow-textarea/hero.svg +33 -0
- data/app/assets/components/iron-autogrow-textarea/iron-autogrow-textarea.html +263 -0
- data/app/assets/components/iron-behaviors/iron-button-state.html +195 -0
- data/app/assets/components/iron-behaviors/iron-control-state.html +102 -0
- data/app/assets/components/iron-fit-behavior/iron-fit-behavior.html +230 -0
- data/app/assets/components/iron-flex-layout/classes/iron-flex-layout.html +307 -0
- data/app/assets/components/iron-flex-layout/classes/iron-shadow-flex-layout.html +302 -0
- data/app/assets/components/iron-flex-layout/iron-flex-layout.html +313 -0
- data/app/assets/components/iron-form-element-behavior/iron-form-element-behavior.html +50 -0
- data/app/assets/components/iron-icon/hero.svg +19 -0
- data/app/assets/components/iron-icon/iron-icon.html +187 -0
- data/app/assets/components/iron-icons/av-icons.html +73 -0
- data/app/assets/components/iron-icons/communication-icons.html +59 -0
- data/app/assets/components/iron-icons/device-icons.html +94 -0
- data/app/assets/components/iron-icons/editor-icons.html +70 -0
- data/app/assets/components/iron-icons/hardware-icons.html +61 -0
- data/app/assets/components/iron-icons/hero.svg +35 -0
- data/app/assets/components/iron-icons/image-icons.html +164 -0
- data/app/assets/components/iron-icons/iron-icons.html +303 -0
- data/app/assets/components/iron-icons/maps-icons.html +71 -0
- data/app/assets/components/iron-icons/notification-icons.html +62 -0
- data/app/assets/components/iron-icons/social-icons.html +40 -0
- data/app/assets/components/iron-iconset-svg/iron-iconset-svg.html +191 -0
- data/app/assets/components/iron-input/hero.svg +19 -0
- data/app/assets/components/iron-input/iron-input.html +235 -0
- data/app/assets/components/iron-media-query/hero.svg +29 -0
- data/app/assets/components/iron-media-query/iron-media-query.html +84 -0
- data/app/assets/components/iron-menu-behavior/iron-menu-behavior.html +214 -0
- data/app/assets/components/iron-menu-behavior/iron-menubar-behavior.html +65 -0
- data/app/assets/components/iron-meta/hero.svg +33 -0
- data/app/assets/components/iron-meta/iron-meta.html +352 -0
- data/app/assets/components/iron-overlay-behavior/iron-overlay-backdrop.html +132 -0
- data/app/assets/components/iron-overlay-behavior/iron-overlay-behavior.html +432 -0
- data/app/assets/components/iron-overlay-behavior/iron-overlay-manager.html +107 -0
- data/app/assets/components/iron-range-behavior/iron-range-behavior.html +101 -0
- data/app/assets/components/iron-resizable-behavior/iron-resizable-behavior.html +139 -0
- data/app/assets/components/iron-selector/iron-multi-selectable.html +120 -0
- data/app/assets/components/iron-selector/iron-selectable.html +307 -0
- data/app/assets/components/iron-selector/iron-selection.html +115 -0
- data/app/assets/components/iron-selector/iron-selector.html +71 -0
- data/app/assets/components/iron-validatable-behavior/iron-validatable-behavior.html +100 -0
- data/app/assets/components/neon-animation/animations/cascaded-animation.html +84 -0
- data/app/assets/components/neon-animation/animations/fade-in-animation.html +49 -0
- data/app/assets/components/neon-animation/animations/fade-out-animation.html +49 -0
- data/app/assets/components/neon-animation/animations/hero-animation.html +83 -0
- data/app/assets/components/neon-animation/animations/opaque-animation.html +46 -0
- data/app/assets/components/neon-animation/animations/ripple-animation.html +92 -0
- data/app/assets/components/neon-animation/animations/scale-down-animation.html +65 -0
- data/app/assets/components/neon-animation/animations/scale-up-animation.html +58 -0
- data/app/assets/components/neon-animation/animations/slide-down-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/slide-from-left-animation.html +60 -0
- data/app/assets/components/neon-animation/animations/slide-from-right-animation.html +60 -0
- data/app/assets/components/neon-animation/animations/slide-left-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/slide-right-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/slide-up-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/transform-animation.html +61 -0
- data/app/assets/components/neon-animation/guides/neon-animation.md +313 -0
- data/app/assets/components/neon-animation/neon-animatable-behavior.html +156 -0
- data/app/assets/components/neon-animation/neon-animatable.html +54 -0
- data/app/assets/components/neon-animation/neon-animated-pages.html +208 -0
- data/app/assets/components/neon-animation/neon-animation-behavior.html +88 -0
- data/app/assets/components/neon-animation/neon-animation-runner-behavior.html +110 -0
- data/app/assets/components/neon-animation/neon-animation.html +17 -0
- data/app/assets/components/neon-animation/neon-animations.html +25 -0
- data/app/assets/components/neon-animation/neon-shared-element-animatable-behavior.html +37 -0
- data/app/assets/components/neon-animation/neon-shared-element-animation-behavior.html +66 -0
- data/app/assets/components/neon-animation/web-animations.html +11 -0
- data/app/assets/components/paper-behaviors/paper-button-behavior.html +55 -0
- data/app/assets/components/paper-behaviors/paper-inky-focus-behavior.html +44 -0
- data/app/assets/components/paper-button/paper-button.html +177 -0
- data/app/assets/components/paper-checkbox/metadata.html +17 -0
- data/app/assets/components/paper-checkbox/paper-checkbox.css +149 -0
- data/app/assets/components/paper-checkbox/paper-checkbox.html +163 -0
- data/app/assets/components/paper-dialog-behavior/hero.svg +51 -0
- data/app/assets/components/paper-dialog-behavior/paper-dialog-behavior.html +236 -0
- data/app/assets/components/paper-dialog-behavior/paper-dialog-common.css +58 -0
- data/app/assets/components/paper-dialog-scrollable/hero.svg +69 -0
- data/app/assets/components/paper-dialog-scrollable/paper-dialog-scrollable.html +150 -0
- data/app/assets/components/paper-dialog/hero.svg +58 -0
- data/app/assets/components/paper-dialog/paper-dialog.html +122 -0
- data/app/assets/components/paper-drawer-panel/hero.svg +21 -0
- data/app/assets/components/paper-drawer-panel/paper-drawer-panel.css +142 -0
- data/app/assets/components/paper-drawer-panel/paper-drawer-panel.html +585 -0
- data/app/assets/components/paper-fab/paper-fab.html +159 -0
- data/app/assets/components/paper-header-panel/hero.svg +38 -0
- data/app/assets/components/paper-header-panel/paper-header-panel.html +496 -0
- data/app/assets/components/paper-icon-button/paper-icon-button.html +141 -0
- data/app/assets/components/paper-input/all-imports.html +12 -0
- data/app/assets/components/paper-input/hero.svg +19 -0
- data/app/assets/components/paper-input/paper-input-addon-behavior.html +43 -0
- data/app/assets/components/paper-input/paper-input-behavior.html +293 -0
- data/app/assets/components/paper-input/paper-input-char-counter.html +95 -0
- data/app/assets/components/paper-input/paper-input-container.html +495 -0
- data/app/assets/components/paper-input/paper-input-error.html +99 -0
- data/app/assets/components/paper-input/paper-input.html +126 -0
- data/app/assets/components/paper-input/paper-textarea.html +100 -0
- data/app/assets/components/paper-item/all-imports.html +13 -0
- data/app/assets/components/paper-item/paper-icon-item.html +86 -0
- data/app/assets/components/paper-item/paper-item-body.html +93 -0
- data/app/assets/components/paper-item/paper-item-shared.css +19 -0
- data/app/assets/components/paper-item/paper-item.html +95 -0
- data/app/assets/components/paper-material/paper-material.html +98 -0
- data/app/assets/components/paper-menu/hero.svg +35 -0
- data/app/assets/components/paper-menu/paper-menu.html +133 -0
- data/app/assets/components/paper-progress/hero.svg +21 -0
- data/app/assets/components/paper-progress/paper-progress.html +199 -0
- data/app/assets/components/paper-radio-button/hero.svg +22 -0
- data/app/assets/components/paper-radio-button/paper-radio-button.css +109 -0
- data/app/assets/components/paper-radio-button/paper-radio-button.html +148 -0
- data/app/assets/components/paper-radio-group/hero.svg +25 -0
- data/app/assets/components/paper-radio-group/paper-radio-group.html +186 -0
- data/app/assets/components/paper-ripple/hero.svg +30 -0
- data/app/assets/components/paper-ripple/paper-ripple.html +714 -0
- data/app/assets/components/paper-scroll-header-panel/hero.svg +41 -0
- data/app/assets/components/paper-scroll-header-panel/paper-scroll-header-panel.html +455 -0
- data/app/assets/components/paper-slider/hero.svg +20 -0
- data/app/assets/components/paper-slider/paper-slider.css +252 -0
- data/app/assets/components/paper-slider/paper-slider.html +449 -0
- data/app/assets/components/paper-spinner/hero.svg +27 -0
- data/app/assets/components/paper-spinner/paper-spinner.css +325 -0
- data/app/assets/components/paper-spinner/paper-spinner.html +222 -0
- data/app/assets/components/paper-styles/classes/global.html +96 -0
- data/app/assets/components/paper-styles/classes/shadow-layout.html +302 -0
- data/app/assets/components/paper-styles/classes/shadow.html +39 -0
- data/app/assets/components/paper-styles/classes/typography.html +171 -0
- data/app/assets/components/paper-styles/color.html +333 -0
- data/app/assets/components/paper-styles/default-theme.html +39 -0
- data/app/assets/components/paper-styles/paper-styles-classes.html +14 -0
- data/app/assets/components/paper-styles/paper-styles.html +17 -0
- data/app/assets/components/paper-styles/shadow.html +61 -0
- data/app/assets/components/paper-styles/typography.html +240 -0
- data/app/assets/components/paper-tabs/hero.svg +23 -0
- data/app/assets/components/paper-tabs/paper-tab.html +158 -0
- data/app/assets/components/paper-tabs/paper-tabs-icons.html +18 -0
- data/app/assets/components/paper-tabs/paper-tabs.html +483 -0
- data/app/assets/components/paper-toast/hero.svg +20 -0
- data/app/assets/components/paper-toast/paper-toast.html +164 -0
- data/app/assets/components/paper-toggle-button/hero.svg +22 -0
- data/app/assets/components/paper-toggle-button/paper-toggle-button.css +108 -0
- data/app/assets/components/paper-toggle-button/paper-toggle-button.html +183 -0
- data/app/assets/components/paper-toolbar/paper-toolbar.html +375 -0
- data/app/assets/components/polymer-gestures/Gruntfile.js +60 -0
- data/app/assets/components/polymer-gestures/banner.txt +9 -0
- data/app/assets/components/polymer-gestures/build.json +17 -0
- data/app/assets/components/polymer-gestures/conf/karma.conf.js +39 -0
- data/app/assets/components/polymer-gestures/package.json +20 -0
- data/app/assets/components/polymer-gestures/polymer-gestures.html +21 -0
- data/app/assets/components/polymer-gestures/polymer-gestures.js +46 -0
- data/app/assets/components/polymer-gestures/src/dispatcher.js +474 -0
- data/app/assets/components/polymer-gestures/src/eventFactory.js +127 -0
- data/app/assets/components/polymer-gestures/src/hold.js +129 -0
- data/app/assets/components/polymer-gestures/src/mouse.js +135 -0
- data/app/assets/components/polymer-gestures/src/ms.js +80 -0
- data/app/assets/components/polymer-gestures/src/pinch.js +186 -0
- data/app/assets/components/polymer-gestures/src/platform-events.js +39 -0
- data/app/assets/components/polymer-gestures/src/pointer.js +68 -0
- data/app/assets/components/polymer-gestures/src/pointermap.js +67 -0
- data/app/assets/components/polymer-gestures/src/scope.js +10 -0
- data/app/assets/components/polymer-gestures/src/tap.js +103 -0
- data/app/assets/components/polymer-gestures/src/targetfind.js +244 -0
- data/app/assets/components/polymer-gestures/src/touch-action.js +60 -0
- data/app/assets/components/polymer-gestures/src/touch.js +341 -0
- data/app/assets/components/polymer-gestures/src/track.js +230 -0
- data/app/assets/components/web-animations-js/web-animations-next-lite.min.js +17 -0
- data/app/assets/components/web-animations-js/web-animations-next.min.js +17 -0
- data/app/assets/components/web-animations-js/web-animations.min.js +17 -0
- data/app/assets/components/webcomponentsjs/CustomElements.js +956 -0
- data/app/assets/components/webcomponentsjs/CustomElements.min.js +11 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.js +1078 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.min.js +11 -0
- data/app/assets/components/webcomponentsjs/MutationObserver.js +344 -0
- data/app/assets/components/webcomponentsjs/MutationObserver.min.js +11 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.js +4414 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.min.js +15 -0
- data/app/assets/components/webcomponentsjs/package.json +31 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.js +2300 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.min.js +13 -0
- data/app/assets/components/webcomponentsjs/webcomponents.js +7112 -0
- data/app/assets/components/webcomponentsjs/webcomponents.min.js +15 -0
- data/lib/polymer-paper-elements-rails.rb +2 -0
- data/lib/polymer-paper-elements-rails/engine.rb +4 -0
- data/lib/polymer-paper-elements-rails/version.rb +3 -0
- metadata +272 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
/*
|
2
|
+
* @license
|
3
|
+
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
4
|
+
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
+
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
+
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
+
* Code distributed by Google as part of the polymer project is also
|
8
|
+
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
+
*/
|
10
|
+
|
11
|
+
module.exports = function(karma) {
|
12
|
+
var common = require('../../tools/test/karma-common.conf.js');
|
13
|
+
karma.set(common.mixin_common_opts(karma, {
|
14
|
+
// base path, that will be used to resolve files and exclude
|
15
|
+
basePath: '../../',
|
16
|
+
|
17
|
+
// list of files / patterns to load in the browser
|
18
|
+
files: [
|
19
|
+
'polymer-gestures/node_modules/chai/chai.js',
|
20
|
+
'polymer-gestures/src/scope.js',
|
21
|
+
'polymer-gestures/src/targetfind.js',
|
22
|
+
'polymer-gestures/src/touch-action.js',
|
23
|
+
'polymer-gestures/src/eventFactory.js',
|
24
|
+
'polymer-gestures/src/pointermap.js',
|
25
|
+
'polymer-gestures/src/dispatcher.js',
|
26
|
+
'polymer-gestures/src/mouse.js',
|
27
|
+
'polymer-gestures/src/touch.js',
|
28
|
+
'polymer-gestures/src/ms.js',
|
29
|
+
'polymer-gestures/src/pointer.js',
|
30
|
+
'polymer-gestures/src/platform-events.js',
|
31
|
+
'polymer-gestures/src/track.js',
|
32
|
+
'polymer-gestures/src/hold.js',
|
33
|
+
'polymer-gestures/src/tap.js',
|
34
|
+
'polymer-gestures/test/js/setup.js',
|
35
|
+
'polymer-gestures/test/js/fake.js',
|
36
|
+
'polymer-gestures/test/js/*.js'
|
37
|
+
]
|
38
|
+
}));
|
39
|
+
};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"name": "polymergestures",
|
3
|
+
"main": "Gruntfile.js",
|
4
|
+
"devDependencies": {
|
5
|
+
"mocha": "*",
|
6
|
+
"chai": "^1.9.1",
|
7
|
+
"grunt": "^0.4.4",
|
8
|
+
"grunt-contrib-concat": "^0.4.0",
|
9
|
+
"grunt-contrib-uglify": "^0.4.0",
|
10
|
+
"karma": "~0.12.0",
|
11
|
+
"karma-mocha": "*",
|
12
|
+
"karma-firefox-launcher": "*",
|
13
|
+
"karma-ie-launcher": "*",
|
14
|
+
"karma-script-launcher": "*",
|
15
|
+
"karma-crbot-reporter": "*",
|
16
|
+
"grunt-karma": "*",
|
17
|
+
"karma-safari-launcher": "~0.1.1",
|
18
|
+
"karma-firefox-launcher": "^0.1.3"
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<!-- Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
2
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
3
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
4
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
5
|
+
Code distributed by Google as part of the polymer project is also
|
6
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt -->
|
7
|
+
|
8
|
+
<script src="src/scope.js"></script>
|
9
|
+
<script src="src/targetfind.js"></script>
|
10
|
+
<script src="src/touch-action.js"></script>
|
11
|
+
<script src="src/eventFactory.js"></script>
|
12
|
+
<script src="src/pointermap.js"></script>
|
13
|
+
<script src="src/dispatcher.js"></script>
|
14
|
+
<script src="src/mouse.js"></script>
|
15
|
+
<script src="src/touch.js"></script>
|
16
|
+
<script src="src/ms.js"></script>
|
17
|
+
<script src="src/pointer.js"></script>
|
18
|
+
<script src="src/platform-events.js"></script>
|
19
|
+
<script src="src/track.js"></script>
|
20
|
+
<script src="src/hold.js"></script>
|
21
|
+
<script src="src/tap.js"></script>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
3
|
+
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
4
|
+
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
5
|
+
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
6
|
+
* Code distributed by Google as part of the polymer project is also
|
7
|
+
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
8
|
+
*/
|
9
|
+
(function() {
|
10
|
+
var thisFile = 'polymer-gestures.js';
|
11
|
+
var scopeName = 'PolymerGestures';
|
12
|
+
var modules = [
|
13
|
+
'src/scope.js',
|
14
|
+
'src/targetfind.js',
|
15
|
+
'src/touch-action.js',
|
16
|
+
'src/eventFactory.js',
|
17
|
+
'src/pointermap.js',
|
18
|
+
'src/dispatcher.js',
|
19
|
+
'src/mouse.js',
|
20
|
+
'src/touch.js',
|
21
|
+
'src/ms.js',
|
22
|
+
'src/pointer.js',
|
23
|
+
'src/platform-events.js',
|
24
|
+
'src/track.js',
|
25
|
+
'src/hold.js',
|
26
|
+
'src/tap.js',
|
27
|
+
'src/pinch.js'
|
28
|
+
];
|
29
|
+
|
30
|
+
window[scopeName] = {
|
31
|
+
entryPointName: thisFile,
|
32
|
+
modules: modules
|
33
|
+
};
|
34
|
+
|
35
|
+
var script = document.currentScript || document.querySelector('script[src $= "' + thisFile + '"]');
|
36
|
+
var src = script.attributes.src.value;
|
37
|
+
var basePath = src.slice(0, src.indexOf(thisFile));
|
38
|
+
|
39
|
+
if (!window.PolymerLoader) {
|
40
|
+
var path = basePath + '../tools/loader/loader.js';
|
41
|
+
document.write('<script src="' + path + '"></script>');
|
42
|
+
}
|
43
|
+
|
44
|
+
document.write('<script>PolymerLoader.load("' + scopeName + '")</script>');
|
45
|
+
|
46
|
+
})();
|
@@ -0,0 +1,474 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
3
|
+
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
4
|
+
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
5
|
+
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
6
|
+
* Code distributed by Google as part of the polymer project is also
|
7
|
+
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
8
|
+
*/
|
9
|
+
|
10
|
+
(function(scope) {
|
11
|
+
var CLONE_PROPS = [
|
12
|
+
// MouseEvent
|
13
|
+
'bubbles',
|
14
|
+
'cancelable',
|
15
|
+
'view',
|
16
|
+
'detail',
|
17
|
+
'screenX',
|
18
|
+
'screenY',
|
19
|
+
'clientX',
|
20
|
+
'clientY',
|
21
|
+
'ctrlKey',
|
22
|
+
'altKey',
|
23
|
+
'shiftKey',
|
24
|
+
'metaKey',
|
25
|
+
'button',
|
26
|
+
'relatedTarget',
|
27
|
+
// DOM Level 3
|
28
|
+
'buttons',
|
29
|
+
// PointerEvent
|
30
|
+
'pointerId',
|
31
|
+
'width',
|
32
|
+
'height',
|
33
|
+
'pressure',
|
34
|
+
'tiltX',
|
35
|
+
'tiltY',
|
36
|
+
'pointerType',
|
37
|
+
'hwTimestamp',
|
38
|
+
'isPrimary',
|
39
|
+
// event instance
|
40
|
+
'type',
|
41
|
+
'target',
|
42
|
+
'currentTarget',
|
43
|
+
'which',
|
44
|
+
'pageX',
|
45
|
+
'pageY',
|
46
|
+
'timeStamp',
|
47
|
+
// gesture addons
|
48
|
+
'preventTap',
|
49
|
+
'tapPrevented',
|
50
|
+
'_source'
|
51
|
+
];
|
52
|
+
|
53
|
+
var CLONE_DEFAULTS = [
|
54
|
+
// MouseEvent
|
55
|
+
false,
|
56
|
+
false,
|
57
|
+
null,
|
58
|
+
null,
|
59
|
+
0,
|
60
|
+
0,
|
61
|
+
0,
|
62
|
+
0,
|
63
|
+
false,
|
64
|
+
false,
|
65
|
+
false,
|
66
|
+
false,
|
67
|
+
0,
|
68
|
+
null,
|
69
|
+
// DOM Level 3
|
70
|
+
0,
|
71
|
+
// PointerEvent
|
72
|
+
0,
|
73
|
+
0,
|
74
|
+
0,
|
75
|
+
0,
|
76
|
+
0,
|
77
|
+
0,
|
78
|
+
'',
|
79
|
+
0,
|
80
|
+
false,
|
81
|
+
// event instance
|
82
|
+
'',
|
83
|
+
null,
|
84
|
+
null,
|
85
|
+
0,
|
86
|
+
0,
|
87
|
+
0,
|
88
|
+
0,
|
89
|
+
function(){},
|
90
|
+
false
|
91
|
+
];
|
92
|
+
|
93
|
+
var HAS_SVG_INSTANCE = (typeof SVGElementInstance !== 'undefined');
|
94
|
+
|
95
|
+
var eventFactory = scope.eventFactory;
|
96
|
+
|
97
|
+
// set of recognizers to run for the currently handled event
|
98
|
+
var currentGestures;
|
99
|
+
|
100
|
+
/**
|
101
|
+
* This module is for normalizing events. Mouse and Touch events will be
|
102
|
+
* collected here, and fire PointerEvents that have the same semantics, no
|
103
|
+
* matter the source.
|
104
|
+
* Events fired:
|
105
|
+
* - pointerdown: a pointing is added
|
106
|
+
* - pointerup: a pointer is removed
|
107
|
+
* - pointermove: a pointer is moved
|
108
|
+
* - pointerover: a pointer crosses into an element
|
109
|
+
* - pointerout: a pointer leaves an element
|
110
|
+
* - pointercancel: a pointer will no longer generate events
|
111
|
+
*/
|
112
|
+
var dispatcher = {
|
113
|
+
IS_IOS: false,
|
114
|
+
pointermap: new scope.PointerMap(),
|
115
|
+
requiredGestures: new scope.PointerMap(),
|
116
|
+
eventMap: Object.create(null),
|
117
|
+
// Scope objects for native events.
|
118
|
+
// This exists for ease of testing.
|
119
|
+
eventSources: Object.create(null),
|
120
|
+
eventSourceList: [],
|
121
|
+
gestures: [],
|
122
|
+
// map gesture event -> {listeners: int, index: gestures[int]}
|
123
|
+
dependencyMap: {
|
124
|
+
// make sure down and up are in the map to trigger "register"
|
125
|
+
down: {listeners: 0, index: -1},
|
126
|
+
up: {listeners: 0, index: -1}
|
127
|
+
},
|
128
|
+
gestureQueue: [],
|
129
|
+
/**
|
130
|
+
* Add a new event source that will generate pointer events.
|
131
|
+
*
|
132
|
+
* `inSource` must contain an array of event names named `events`, and
|
133
|
+
* functions with the names specified in the `events` array.
|
134
|
+
* @param {string} name A name for the event source
|
135
|
+
* @param {Object} source A new source of platform events.
|
136
|
+
*/
|
137
|
+
registerSource: function(name, source) {
|
138
|
+
var s = source;
|
139
|
+
var newEvents = s.events;
|
140
|
+
if (newEvents) {
|
141
|
+
newEvents.forEach(function(e) {
|
142
|
+
if (s[e]) {
|
143
|
+
this.eventMap[e] = s[e].bind(s);
|
144
|
+
}
|
145
|
+
}, this);
|
146
|
+
this.eventSources[name] = s;
|
147
|
+
this.eventSourceList.push(s);
|
148
|
+
}
|
149
|
+
},
|
150
|
+
registerGesture: function(name, source) {
|
151
|
+
var obj = Object.create(null);
|
152
|
+
obj.listeners = 0;
|
153
|
+
obj.index = this.gestures.length;
|
154
|
+
for (var i = 0, g; i < source.exposes.length; i++) {
|
155
|
+
g = source.exposes[i].toLowerCase();
|
156
|
+
this.dependencyMap[g] = obj;
|
157
|
+
}
|
158
|
+
this.gestures.push(source);
|
159
|
+
},
|
160
|
+
register: function(element, initial) {
|
161
|
+
var l = this.eventSourceList.length;
|
162
|
+
for (var i = 0, es; (i < l) && (es = this.eventSourceList[i]); i++) {
|
163
|
+
// call eventsource register
|
164
|
+
es.register.call(es, element, initial);
|
165
|
+
}
|
166
|
+
},
|
167
|
+
unregister: function(element) {
|
168
|
+
var l = this.eventSourceList.length;
|
169
|
+
for (var i = 0, es; (i < l) && (es = this.eventSourceList[i]); i++) {
|
170
|
+
// call eventsource register
|
171
|
+
es.unregister.call(es, element);
|
172
|
+
}
|
173
|
+
},
|
174
|
+
// EVENTS
|
175
|
+
down: function(inEvent) {
|
176
|
+
this.requiredGestures.set(inEvent.pointerId, currentGestures);
|
177
|
+
this.fireEvent('down', inEvent);
|
178
|
+
},
|
179
|
+
move: function(inEvent) {
|
180
|
+
// pipe move events into gesture queue directly
|
181
|
+
inEvent.type = 'move';
|
182
|
+
this.fillGestureQueue(inEvent);
|
183
|
+
},
|
184
|
+
up: function(inEvent) {
|
185
|
+
this.fireEvent('up', inEvent);
|
186
|
+
this.requiredGestures.delete(inEvent.pointerId);
|
187
|
+
},
|
188
|
+
cancel: function(inEvent) {
|
189
|
+
inEvent.tapPrevented = true;
|
190
|
+
this.fireEvent('up', inEvent);
|
191
|
+
this.requiredGestures.delete(inEvent.pointerId);
|
192
|
+
},
|
193
|
+
addGestureDependency: function(node, currentGestures) {
|
194
|
+
var gesturesWanted = node._pgEvents;
|
195
|
+
if (gesturesWanted && currentGestures) {
|
196
|
+
var gk = Object.keys(gesturesWanted);
|
197
|
+
for (var i = 0, r, ri, g; i < gk.length; i++) {
|
198
|
+
// gesture
|
199
|
+
g = gk[i];
|
200
|
+
if (gesturesWanted[g] > 0) {
|
201
|
+
// lookup gesture recognizer
|
202
|
+
r = this.dependencyMap[g];
|
203
|
+
// recognizer index
|
204
|
+
ri = r ? r.index : -1;
|
205
|
+
currentGestures[ri] = true;
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
},
|
210
|
+
// LISTENER LOGIC
|
211
|
+
eventHandler: function(inEvent) {
|
212
|
+
// This is used to prevent multiple dispatch of events from
|
213
|
+
// platform events. This can happen when two elements in different scopes
|
214
|
+
// are set up to create pointer events, which is relevant to Shadow DOM.
|
215
|
+
|
216
|
+
var type = inEvent.type;
|
217
|
+
|
218
|
+
// only generate the list of desired events on "down"
|
219
|
+
if (type === 'touchstart' || type === 'mousedown' || type === 'pointerdown' || type === 'MSPointerDown') {
|
220
|
+
if (!inEvent._handledByPG) {
|
221
|
+
currentGestures = {};
|
222
|
+
}
|
223
|
+
|
224
|
+
// in IOS mode, there is only a listener on the document, so this is not re-entrant
|
225
|
+
if (this.IS_IOS) {
|
226
|
+
var ev = inEvent;
|
227
|
+
if (type === 'touchstart') {
|
228
|
+
var ct = inEvent.changedTouches[0];
|
229
|
+
// set up a fake event to give to the path builder
|
230
|
+
ev = {target: inEvent.target, clientX: ct.clientX, clientY: ct.clientY, path: inEvent.path};
|
231
|
+
}
|
232
|
+
// use event path if available, otherwise build a path from target finding
|
233
|
+
var nodes = inEvent.path || scope.targetFinding.path(ev);
|
234
|
+
for (var i = 0, n; i < nodes.length; i++) {
|
235
|
+
n = nodes[i];
|
236
|
+
this.addGestureDependency(n, currentGestures);
|
237
|
+
}
|
238
|
+
} else {
|
239
|
+
this.addGestureDependency(inEvent.currentTarget, currentGestures);
|
240
|
+
}
|
241
|
+
}
|
242
|
+
|
243
|
+
if (inEvent._handledByPG) {
|
244
|
+
return;
|
245
|
+
}
|
246
|
+
var fn = this.eventMap && this.eventMap[type];
|
247
|
+
if (fn) {
|
248
|
+
fn(inEvent);
|
249
|
+
}
|
250
|
+
inEvent._handledByPG = true;
|
251
|
+
},
|
252
|
+
// set up event listeners
|
253
|
+
listen: function(target, events) {
|
254
|
+
for (var i = 0, l = events.length, e; (i < l) && (e = events[i]); i++) {
|
255
|
+
this.addEvent(target, e);
|
256
|
+
}
|
257
|
+
},
|
258
|
+
// remove event listeners
|
259
|
+
unlisten: function(target, events) {
|
260
|
+
for (var i = 0, l = events.length, e; (i < l) && (e = events[i]); i++) {
|
261
|
+
this.removeEvent(target, e);
|
262
|
+
}
|
263
|
+
},
|
264
|
+
addEvent: function(target, eventName) {
|
265
|
+
target.addEventListener(eventName, this.boundHandler);
|
266
|
+
},
|
267
|
+
removeEvent: function(target, eventName) {
|
268
|
+
target.removeEventListener(eventName, this.boundHandler);
|
269
|
+
},
|
270
|
+
// EVENT CREATION AND TRACKING
|
271
|
+
/**
|
272
|
+
* Creates a new Event of type `inType`, based on the information in
|
273
|
+
* `inEvent`.
|
274
|
+
*
|
275
|
+
* @param {string} inType A string representing the type of event to create
|
276
|
+
* @param {Event} inEvent A platform event with a target
|
277
|
+
* @return {Event} A PointerEvent of type `inType`
|
278
|
+
*/
|
279
|
+
makeEvent: function(inType, inEvent) {
|
280
|
+
var e = eventFactory.makePointerEvent(inType, inEvent);
|
281
|
+
e.preventDefault = inEvent.preventDefault;
|
282
|
+
e.tapPrevented = inEvent.tapPrevented;
|
283
|
+
e._target = e._target || inEvent.target;
|
284
|
+
return e;
|
285
|
+
},
|
286
|
+
// make and dispatch an event in one call
|
287
|
+
fireEvent: function(inType, inEvent) {
|
288
|
+
var e = this.makeEvent(inType, inEvent);
|
289
|
+
return this.dispatchEvent(e);
|
290
|
+
},
|
291
|
+
/**
|
292
|
+
* Returns a snapshot of inEvent, with writable properties.
|
293
|
+
*
|
294
|
+
* @param {Event} inEvent An event that contains properties to copy.
|
295
|
+
* @return {Object} An object containing shallow copies of `inEvent`'s
|
296
|
+
* properties.
|
297
|
+
*/
|
298
|
+
cloneEvent: function(inEvent) {
|
299
|
+
var eventCopy = Object.create(null), p;
|
300
|
+
for (var i = 0; i < CLONE_PROPS.length; i++) {
|
301
|
+
p = CLONE_PROPS[i];
|
302
|
+
eventCopy[p] = inEvent[p] || CLONE_DEFAULTS[i];
|
303
|
+
// Work around SVGInstanceElement shadow tree
|
304
|
+
// Return the <use> element that is represented by the instance for Safari, Chrome, IE.
|
305
|
+
// This is the behavior implemented by Firefox.
|
306
|
+
if (p === 'target' || p === 'relatedTarget') {
|
307
|
+
if (HAS_SVG_INSTANCE && eventCopy[p] instanceof SVGElementInstance) {
|
308
|
+
eventCopy[p] = eventCopy[p].correspondingUseElement;
|
309
|
+
}
|
310
|
+
}
|
311
|
+
}
|
312
|
+
// keep the semantics of preventDefault
|
313
|
+
eventCopy.preventDefault = function() {
|
314
|
+
inEvent.preventDefault();
|
315
|
+
};
|
316
|
+
return eventCopy;
|
317
|
+
},
|
318
|
+
/**
|
319
|
+
* Dispatches the event to its target.
|
320
|
+
*
|
321
|
+
* @param {Event} inEvent The event to be dispatched.
|
322
|
+
* @return {Boolean} True if an event handler returns true, false otherwise.
|
323
|
+
*/
|
324
|
+
dispatchEvent: function(inEvent) {
|
325
|
+
var t = inEvent._target;
|
326
|
+
if (t) {
|
327
|
+
t.dispatchEvent(inEvent);
|
328
|
+
// clone the event for the gesture system to process
|
329
|
+
// clone after dispatch to pick up gesture prevention code
|
330
|
+
var clone = this.cloneEvent(inEvent);
|
331
|
+
clone.target = t;
|
332
|
+
this.fillGestureQueue(clone);
|
333
|
+
}
|
334
|
+
},
|
335
|
+
gestureTrigger: function() {
|
336
|
+
// process the gesture queue
|
337
|
+
for (var i = 0, e, rg; i < this.gestureQueue.length; i++) {
|
338
|
+
e = this.gestureQueue[i];
|
339
|
+
rg = e._requiredGestures;
|
340
|
+
if (rg) {
|
341
|
+
for (var j = 0, g, fn; j < this.gestures.length; j++) {
|
342
|
+
// only run recognizer if an element in the source event's path is listening for those gestures
|
343
|
+
if (rg[j]) {
|
344
|
+
g = this.gestures[j];
|
345
|
+
fn = g[e.type];
|
346
|
+
if (fn) {
|
347
|
+
fn.call(g, e);
|
348
|
+
}
|
349
|
+
}
|
350
|
+
}
|
351
|
+
}
|
352
|
+
}
|
353
|
+
this.gestureQueue.length = 0;
|
354
|
+
},
|
355
|
+
fillGestureQueue: function(ev) {
|
356
|
+
// only trigger the gesture queue once
|
357
|
+
if (!this.gestureQueue.length) {
|
358
|
+
requestAnimationFrame(this.boundGestureTrigger);
|
359
|
+
}
|
360
|
+
ev._requiredGestures = this.requiredGestures.get(ev.pointerId);
|
361
|
+
this.gestureQueue.push(ev);
|
362
|
+
}
|
363
|
+
};
|
364
|
+
dispatcher.boundHandler = dispatcher.eventHandler.bind(dispatcher);
|
365
|
+
dispatcher.boundGestureTrigger = dispatcher.gestureTrigger.bind(dispatcher);
|
366
|
+
scope.dispatcher = dispatcher;
|
367
|
+
|
368
|
+
/**
|
369
|
+
* Listen for `gesture` on `node` with the `handler` function
|
370
|
+
*
|
371
|
+
* If `handler` is the first listener for `gesture`, the underlying gesture recognizer is then enabled.
|
372
|
+
*
|
373
|
+
* @param {Element} node
|
374
|
+
* @param {string} gesture
|
375
|
+
* @return Boolean `gesture` is a valid gesture
|
376
|
+
*/
|
377
|
+
scope.activateGesture = function(node, gesture) {
|
378
|
+
var g = gesture.toLowerCase();
|
379
|
+
var dep = dispatcher.dependencyMap[g];
|
380
|
+
if (dep) {
|
381
|
+
var recognizer = dispatcher.gestures[dep.index];
|
382
|
+
if (!node._pgListeners) {
|
383
|
+
dispatcher.register(node);
|
384
|
+
node._pgListeners = 0;
|
385
|
+
}
|
386
|
+
// TODO(dfreedm): re-evaluate bookkeeping to avoid using attributes
|
387
|
+
if (recognizer) {
|
388
|
+
var touchAction = recognizer.defaultActions && recognizer.defaultActions[g];
|
389
|
+
var actionNode;
|
390
|
+
switch(node.nodeType) {
|
391
|
+
case Node.ELEMENT_NODE:
|
392
|
+
actionNode = node;
|
393
|
+
break;
|
394
|
+
case Node.DOCUMENT_FRAGMENT_NODE:
|
395
|
+
actionNode = node.host;
|
396
|
+
break;
|
397
|
+
default:
|
398
|
+
actionNode = null;
|
399
|
+
break;
|
400
|
+
}
|
401
|
+
if (touchAction && actionNode && !actionNode.hasAttribute('touch-action')) {
|
402
|
+
actionNode.setAttribute('touch-action', touchAction);
|
403
|
+
}
|
404
|
+
}
|
405
|
+
if (!node._pgEvents) {
|
406
|
+
node._pgEvents = {};
|
407
|
+
}
|
408
|
+
node._pgEvents[g] = (node._pgEvents[g] || 0) + 1;
|
409
|
+
node._pgListeners++;
|
410
|
+
}
|
411
|
+
return Boolean(dep);
|
412
|
+
};
|
413
|
+
|
414
|
+
/**
|
415
|
+
*
|
416
|
+
* Listen for `gesture` from `node` with `handler` function.
|
417
|
+
*
|
418
|
+
* @param {Element} node
|
419
|
+
* @param {string} gesture
|
420
|
+
* @param {Function} handler
|
421
|
+
* @param {Boolean} capture
|
422
|
+
*/
|
423
|
+
scope.addEventListener = function(node, gesture, handler, capture) {
|
424
|
+
if (handler) {
|
425
|
+
scope.activateGesture(node, gesture);
|
426
|
+
node.addEventListener(gesture, handler, capture);
|
427
|
+
}
|
428
|
+
};
|
429
|
+
|
430
|
+
/**
|
431
|
+
* Tears down the gesture configuration for `node`
|
432
|
+
*
|
433
|
+
* If `handler` is the last listener for `gesture`, the underlying gesture recognizer is disabled.
|
434
|
+
*
|
435
|
+
* @param {Element} node
|
436
|
+
* @param {string} gesture
|
437
|
+
* @return Boolean `gesture` is a valid gesture
|
438
|
+
*/
|
439
|
+
scope.deactivateGesture = function(node, gesture) {
|
440
|
+
var g = gesture.toLowerCase();
|
441
|
+
var dep = dispatcher.dependencyMap[g];
|
442
|
+
if (dep) {
|
443
|
+
if (node._pgListeners > 0) {
|
444
|
+
node._pgListeners--;
|
445
|
+
}
|
446
|
+
if (node._pgListeners === 0) {
|
447
|
+
dispatcher.unregister(node);
|
448
|
+
}
|
449
|
+
if (node._pgEvents) {
|
450
|
+
if (node._pgEvents[g] > 0) {
|
451
|
+
node._pgEvents[g]--;
|
452
|
+
} else {
|
453
|
+
node._pgEvents[g] = 0;
|
454
|
+
}
|
455
|
+
}
|
456
|
+
}
|
457
|
+
return Boolean(dep);
|
458
|
+
};
|
459
|
+
|
460
|
+
/**
|
461
|
+
* Stop listening for `gesture` from `node` with `handler` function.
|
462
|
+
*
|
463
|
+
* @param {Element} node
|
464
|
+
* @param {string} gesture
|
465
|
+
* @param {Function} handler
|
466
|
+
* @param {Boolean} capture
|
467
|
+
*/
|
468
|
+
scope.removeEventListener = function(node, gesture, handler, capture) {
|
469
|
+
if (handler) {
|
470
|
+
scope.deactivateGesture(node, gesture);
|
471
|
+
node.removeEventListener(gesture, handler, capture);
|
472
|
+
}
|
473
|
+
};
|
474
|
+
})(window.PolymerGestures);
|