polymer-paper-elements-rails 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +51 -0
  3. data/Rakefile +1 -0
  4. data/app/assets/components/iron-a11y-announcer/iron-a11y-announcer.html +125 -0
  5. data/app/assets/components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html +418 -0
  6. data/app/assets/components/iron-autogrow-textarea/hero.svg +33 -0
  7. data/app/assets/components/iron-autogrow-textarea/iron-autogrow-textarea.html +263 -0
  8. data/app/assets/components/iron-behaviors/iron-button-state.html +195 -0
  9. data/app/assets/components/iron-behaviors/iron-control-state.html +102 -0
  10. data/app/assets/components/iron-fit-behavior/iron-fit-behavior.html +230 -0
  11. data/app/assets/components/iron-flex-layout/classes/iron-flex-layout.html +307 -0
  12. data/app/assets/components/iron-flex-layout/classes/iron-shadow-flex-layout.html +302 -0
  13. data/app/assets/components/iron-flex-layout/iron-flex-layout.html +313 -0
  14. data/app/assets/components/iron-form-element-behavior/iron-form-element-behavior.html +50 -0
  15. data/app/assets/components/iron-icon/hero.svg +19 -0
  16. data/app/assets/components/iron-icon/iron-icon.html +187 -0
  17. data/app/assets/components/iron-icons/av-icons.html +73 -0
  18. data/app/assets/components/iron-icons/communication-icons.html +59 -0
  19. data/app/assets/components/iron-icons/device-icons.html +94 -0
  20. data/app/assets/components/iron-icons/editor-icons.html +70 -0
  21. data/app/assets/components/iron-icons/hardware-icons.html +61 -0
  22. data/app/assets/components/iron-icons/hero.svg +35 -0
  23. data/app/assets/components/iron-icons/image-icons.html +164 -0
  24. data/app/assets/components/iron-icons/iron-icons.html +303 -0
  25. data/app/assets/components/iron-icons/maps-icons.html +71 -0
  26. data/app/assets/components/iron-icons/notification-icons.html +62 -0
  27. data/app/assets/components/iron-icons/social-icons.html +40 -0
  28. data/app/assets/components/iron-iconset-svg/iron-iconset-svg.html +191 -0
  29. data/app/assets/components/iron-input/hero.svg +19 -0
  30. data/app/assets/components/iron-input/iron-input.html +235 -0
  31. data/app/assets/components/iron-media-query/hero.svg +29 -0
  32. data/app/assets/components/iron-media-query/iron-media-query.html +84 -0
  33. data/app/assets/components/iron-menu-behavior/iron-menu-behavior.html +214 -0
  34. data/app/assets/components/iron-menu-behavior/iron-menubar-behavior.html +65 -0
  35. data/app/assets/components/iron-meta/hero.svg +33 -0
  36. data/app/assets/components/iron-meta/iron-meta.html +352 -0
  37. data/app/assets/components/iron-overlay-behavior/iron-overlay-backdrop.html +132 -0
  38. data/app/assets/components/iron-overlay-behavior/iron-overlay-behavior.html +432 -0
  39. data/app/assets/components/iron-overlay-behavior/iron-overlay-manager.html +107 -0
  40. data/app/assets/components/iron-range-behavior/iron-range-behavior.html +101 -0
  41. data/app/assets/components/iron-resizable-behavior/iron-resizable-behavior.html +139 -0
  42. data/app/assets/components/iron-selector/iron-multi-selectable.html +120 -0
  43. data/app/assets/components/iron-selector/iron-selectable.html +307 -0
  44. data/app/assets/components/iron-selector/iron-selection.html +115 -0
  45. data/app/assets/components/iron-selector/iron-selector.html +71 -0
  46. data/app/assets/components/iron-validatable-behavior/iron-validatable-behavior.html +100 -0
  47. data/app/assets/components/neon-animation/animations/cascaded-animation.html +84 -0
  48. data/app/assets/components/neon-animation/animations/fade-in-animation.html +49 -0
  49. data/app/assets/components/neon-animation/animations/fade-out-animation.html +49 -0
  50. data/app/assets/components/neon-animation/animations/hero-animation.html +83 -0
  51. data/app/assets/components/neon-animation/animations/opaque-animation.html +46 -0
  52. data/app/assets/components/neon-animation/animations/ripple-animation.html +92 -0
  53. data/app/assets/components/neon-animation/animations/scale-down-animation.html +65 -0
  54. data/app/assets/components/neon-animation/animations/scale-up-animation.html +58 -0
  55. data/app/assets/components/neon-animation/animations/slide-down-animation.html +59 -0
  56. data/app/assets/components/neon-animation/animations/slide-from-left-animation.html +60 -0
  57. data/app/assets/components/neon-animation/animations/slide-from-right-animation.html +60 -0
  58. data/app/assets/components/neon-animation/animations/slide-left-animation.html +59 -0
  59. data/app/assets/components/neon-animation/animations/slide-right-animation.html +59 -0
  60. data/app/assets/components/neon-animation/animations/slide-up-animation.html +59 -0
  61. data/app/assets/components/neon-animation/animations/transform-animation.html +61 -0
  62. data/app/assets/components/neon-animation/guides/neon-animation.md +313 -0
  63. data/app/assets/components/neon-animation/neon-animatable-behavior.html +156 -0
  64. data/app/assets/components/neon-animation/neon-animatable.html +54 -0
  65. data/app/assets/components/neon-animation/neon-animated-pages.html +208 -0
  66. data/app/assets/components/neon-animation/neon-animation-behavior.html +88 -0
  67. data/app/assets/components/neon-animation/neon-animation-runner-behavior.html +110 -0
  68. data/app/assets/components/neon-animation/neon-animation.html +17 -0
  69. data/app/assets/components/neon-animation/neon-animations.html +25 -0
  70. data/app/assets/components/neon-animation/neon-shared-element-animatable-behavior.html +37 -0
  71. data/app/assets/components/neon-animation/neon-shared-element-animation-behavior.html +66 -0
  72. data/app/assets/components/neon-animation/web-animations.html +11 -0
  73. data/app/assets/components/paper-behaviors/paper-button-behavior.html +55 -0
  74. data/app/assets/components/paper-behaviors/paper-inky-focus-behavior.html +44 -0
  75. data/app/assets/components/paper-button/paper-button.html +177 -0
  76. data/app/assets/components/paper-checkbox/metadata.html +17 -0
  77. data/app/assets/components/paper-checkbox/paper-checkbox.css +149 -0
  78. data/app/assets/components/paper-checkbox/paper-checkbox.html +163 -0
  79. data/app/assets/components/paper-dialog-behavior/hero.svg +51 -0
  80. data/app/assets/components/paper-dialog-behavior/paper-dialog-behavior.html +236 -0
  81. data/app/assets/components/paper-dialog-behavior/paper-dialog-common.css +58 -0
  82. data/app/assets/components/paper-dialog-scrollable/hero.svg +69 -0
  83. data/app/assets/components/paper-dialog-scrollable/paper-dialog-scrollable.html +150 -0
  84. data/app/assets/components/paper-dialog/hero.svg +58 -0
  85. data/app/assets/components/paper-dialog/paper-dialog.html +122 -0
  86. data/app/assets/components/paper-drawer-panel/hero.svg +21 -0
  87. data/app/assets/components/paper-drawer-panel/paper-drawer-panel.css +142 -0
  88. data/app/assets/components/paper-drawer-panel/paper-drawer-panel.html +585 -0
  89. data/app/assets/components/paper-fab/paper-fab.html +159 -0
  90. data/app/assets/components/paper-header-panel/hero.svg +38 -0
  91. data/app/assets/components/paper-header-panel/paper-header-panel.html +496 -0
  92. data/app/assets/components/paper-icon-button/paper-icon-button.html +141 -0
  93. data/app/assets/components/paper-input/all-imports.html +12 -0
  94. data/app/assets/components/paper-input/hero.svg +19 -0
  95. data/app/assets/components/paper-input/paper-input-addon-behavior.html +43 -0
  96. data/app/assets/components/paper-input/paper-input-behavior.html +293 -0
  97. data/app/assets/components/paper-input/paper-input-char-counter.html +95 -0
  98. data/app/assets/components/paper-input/paper-input-container.html +495 -0
  99. data/app/assets/components/paper-input/paper-input-error.html +99 -0
  100. data/app/assets/components/paper-input/paper-input.html +126 -0
  101. data/app/assets/components/paper-input/paper-textarea.html +100 -0
  102. data/app/assets/components/paper-item/all-imports.html +13 -0
  103. data/app/assets/components/paper-item/paper-icon-item.html +86 -0
  104. data/app/assets/components/paper-item/paper-item-body.html +93 -0
  105. data/app/assets/components/paper-item/paper-item-shared.css +19 -0
  106. data/app/assets/components/paper-item/paper-item.html +95 -0
  107. data/app/assets/components/paper-material/paper-material.html +98 -0
  108. data/app/assets/components/paper-menu/hero.svg +35 -0
  109. data/app/assets/components/paper-menu/paper-menu.html +133 -0
  110. data/app/assets/components/paper-progress/hero.svg +21 -0
  111. data/app/assets/components/paper-progress/paper-progress.html +199 -0
  112. data/app/assets/components/paper-radio-button/hero.svg +22 -0
  113. data/app/assets/components/paper-radio-button/paper-radio-button.css +109 -0
  114. data/app/assets/components/paper-radio-button/paper-radio-button.html +148 -0
  115. data/app/assets/components/paper-radio-group/hero.svg +25 -0
  116. data/app/assets/components/paper-radio-group/paper-radio-group.html +186 -0
  117. data/app/assets/components/paper-ripple/hero.svg +30 -0
  118. data/app/assets/components/paper-ripple/paper-ripple.html +714 -0
  119. data/app/assets/components/paper-scroll-header-panel/hero.svg +41 -0
  120. data/app/assets/components/paper-scroll-header-panel/paper-scroll-header-panel.html +455 -0
  121. data/app/assets/components/paper-slider/hero.svg +20 -0
  122. data/app/assets/components/paper-slider/paper-slider.css +252 -0
  123. data/app/assets/components/paper-slider/paper-slider.html +449 -0
  124. data/app/assets/components/paper-spinner/hero.svg +27 -0
  125. data/app/assets/components/paper-spinner/paper-spinner.css +325 -0
  126. data/app/assets/components/paper-spinner/paper-spinner.html +222 -0
  127. data/app/assets/components/paper-styles/classes/global.html +96 -0
  128. data/app/assets/components/paper-styles/classes/shadow-layout.html +302 -0
  129. data/app/assets/components/paper-styles/classes/shadow.html +39 -0
  130. data/app/assets/components/paper-styles/classes/typography.html +171 -0
  131. data/app/assets/components/paper-styles/color.html +333 -0
  132. data/app/assets/components/paper-styles/default-theme.html +39 -0
  133. data/app/assets/components/paper-styles/paper-styles-classes.html +14 -0
  134. data/app/assets/components/paper-styles/paper-styles.html +17 -0
  135. data/app/assets/components/paper-styles/shadow.html +61 -0
  136. data/app/assets/components/paper-styles/typography.html +240 -0
  137. data/app/assets/components/paper-tabs/hero.svg +23 -0
  138. data/app/assets/components/paper-tabs/paper-tab.html +158 -0
  139. data/app/assets/components/paper-tabs/paper-tabs-icons.html +18 -0
  140. data/app/assets/components/paper-tabs/paper-tabs.html +483 -0
  141. data/app/assets/components/paper-toast/hero.svg +20 -0
  142. data/app/assets/components/paper-toast/paper-toast.html +164 -0
  143. data/app/assets/components/paper-toggle-button/hero.svg +22 -0
  144. data/app/assets/components/paper-toggle-button/paper-toggle-button.css +108 -0
  145. data/app/assets/components/paper-toggle-button/paper-toggle-button.html +183 -0
  146. data/app/assets/components/paper-toolbar/paper-toolbar.html +375 -0
  147. data/app/assets/components/polymer-gestures/Gruntfile.js +60 -0
  148. data/app/assets/components/polymer-gestures/banner.txt +9 -0
  149. data/app/assets/components/polymer-gestures/build.json +17 -0
  150. data/app/assets/components/polymer-gestures/conf/karma.conf.js +39 -0
  151. data/app/assets/components/polymer-gestures/package.json +20 -0
  152. data/app/assets/components/polymer-gestures/polymer-gestures.html +21 -0
  153. data/app/assets/components/polymer-gestures/polymer-gestures.js +46 -0
  154. data/app/assets/components/polymer-gestures/src/dispatcher.js +474 -0
  155. data/app/assets/components/polymer-gestures/src/eventFactory.js +127 -0
  156. data/app/assets/components/polymer-gestures/src/hold.js +129 -0
  157. data/app/assets/components/polymer-gestures/src/mouse.js +135 -0
  158. data/app/assets/components/polymer-gestures/src/ms.js +80 -0
  159. data/app/assets/components/polymer-gestures/src/pinch.js +186 -0
  160. data/app/assets/components/polymer-gestures/src/platform-events.js +39 -0
  161. data/app/assets/components/polymer-gestures/src/pointer.js +68 -0
  162. data/app/assets/components/polymer-gestures/src/pointermap.js +67 -0
  163. data/app/assets/components/polymer-gestures/src/scope.js +10 -0
  164. data/app/assets/components/polymer-gestures/src/tap.js +103 -0
  165. data/app/assets/components/polymer-gestures/src/targetfind.js +244 -0
  166. data/app/assets/components/polymer-gestures/src/touch-action.js +60 -0
  167. data/app/assets/components/polymer-gestures/src/touch.js +341 -0
  168. data/app/assets/components/polymer-gestures/src/track.js +230 -0
  169. data/app/assets/components/web-animations-js/web-animations-next-lite.min.js +17 -0
  170. data/app/assets/components/web-animations-js/web-animations-next.min.js +17 -0
  171. data/app/assets/components/web-animations-js/web-animations.min.js +17 -0
  172. data/app/assets/components/webcomponentsjs/CustomElements.js +956 -0
  173. data/app/assets/components/webcomponentsjs/CustomElements.min.js +11 -0
  174. data/app/assets/components/webcomponentsjs/HTMLImports.js +1078 -0
  175. data/app/assets/components/webcomponentsjs/HTMLImports.min.js +11 -0
  176. data/app/assets/components/webcomponentsjs/MutationObserver.js +344 -0
  177. data/app/assets/components/webcomponentsjs/MutationObserver.min.js +11 -0
  178. data/app/assets/components/webcomponentsjs/ShadowDOM.js +4414 -0
  179. data/app/assets/components/webcomponentsjs/ShadowDOM.min.js +15 -0
  180. data/app/assets/components/webcomponentsjs/package.json +31 -0
  181. data/app/assets/components/webcomponentsjs/webcomponents-lite.js +2300 -0
  182. data/app/assets/components/webcomponentsjs/webcomponents-lite.min.js +13 -0
  183. data/app/assets/components/webcomponentsjs/webcomponents.js +7112 -0
  184. data/app/assets/components/webcomponentsjs/webcomponents.min.js +15 -0
  185. data/lib/polymer-paper-elements-rails.rb +2 -0
  186. data/lib/polymer-paper-elements-rails/engine.rb +4 -0
  187. data/lib/polymer-paper-elements-rails/version.rb +3 -0
  188. metadata +272 -0
@@ -0,0 +1,127 @@
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
+ /**
11
+ * This is the constructor for new PointerEvents.
12
+ *
13
+ * New Pointer Events must be given a type, and an optional dictionary of
14
+ * initialization properties.
15
+ *
16
+ * Due to certain platform requirements, events returned from the constructor
17
+ * identify as MouseEvents.
18
+ *
19
+ * @constructor
20
+ * @param {String} inType The type of the event to create.
21
+ * @param {Object} [inDict] An optional dictionary of initial event properties.
22
+ * @return {Event} A new PointerEvent of type `inType` and initialized with properties from `inDict`.
23
+ */
24
+ (function(scope) {
25
+
26
+ var MOUSE_PROPS = [
27
+ 'bubbles',
28
+ 'cancelable',
29
+ 'view',
30
+ 'detail',
31
+ 'screenX',
32
+ 'screenY',
33
+ 'clientX',
34
+ 'clientY',
35
+ 'ctrlKey',
36
+ 'altKey',
37
+ 'shiftKey',
38
+ 'metaKey',
39
+ 'button',
40
+ 'relatedTarget',
41
+ 'pageX',
42
+ 'pageY'
43
+ ];
44
+
45
+ var MOUSE_DEFAULTS = [
46
+ false,
47
+ false,
48
+ null,
49
+ null,
50
+ 0,
51
+ 0,
52
+ 0,
53
+ 0,
54
+ false,
55
+ false,
56
+ false,
57
+ false,
58
+ 0,
59
+ null,
60
+ 0,
61
+ 0
62
+ ];
63
+
64
+ var NOP_FACTORY = function(){ return function(){}; };
65
+
66
+ var eventFactory = {
67
+ // TODO(dfreedm): this is overridden by tap recognizer, needs review
68
+ preventTap: NOP_FACTORY,
69
+ makeBaseEvent: function(inType, inDict) {
70
+ var e = document.createEvent('Event');
71
+ e.initEvent(inType, inDict.bubbles || false, inDict.cancelable || false);
72
+ e.preventTap = eventFactory.preventTap(e);
73
+ return e;
74
+ },
75
+ makeGestureEvent: function(inType, inDict) {
76
+ inDict = inDict || Object.create(null);
77
+
78
+ var e = this.makeBaseEvent(inType, inDict);
79
+ for (var i = 0, keys = Object.keys(inDict), k; i < keys.length; i++) {
80
+ k = keys[i];
81
+ if( k !== 'bubbles' && k !== 'cancelable' ) {
82
+ e[k] = inDict[k];
83
+ }
84
+ }
85
+ return e;
86
+ },
87
+ makePointerEvent: function(inType, inDict) {
88
+ inDict = inDict || Object.create(null);
89
+
90
+ var e = this.makeBaseEvent(inType, inDict);
91
+ // define inherited MouseEvent properties
92
+ for(var i = 2, p; i < MOUSE_PROPS.length; i++) {
93
+ p = MOUSE_PROPS[i];
94
+ e[p] = inDict[p] || MOUSE_DEFAULTS[i];
95
+ }
96
+ e.buttons = inDict.buttons || 0;
97
+
98
+ // Spec requires that pointers without pressure specified use 0.5 for down
99
+ // state and 0 for up state.
100
+ var pressure = 0;
101
+ if (inDict.pressure) {
102
+ pressure = inDict.pressure;
103
+ } else {
104
+ pressure = e.buttons ? 0.5 : 0;
105
+ }
106
+
107
+ // add x/y properties aliased to clientX/Y
108
+ e.x = e.clientX;
109
+ e.y = e.clientY;
110
+
111
+ // define the properties of the PointerEvent interface
112
+ e.pointerId = inDict.pointerId || 0;
113
+ e.width = inDict.width || 0;
114
+ e.height = inDict.height || 0;
115
+ e.pressure = pressure;
116
+ e.tiltX = inDict.tiltX || 0;
117
+ e.tiltY = inDict.tiltY || 0;
118
+ e.pointerType = inDict.pointerType || '';
119
+ e.hwTimestamp = inDict.hwTimestamp || 0;
120
+ e.isPrimary = inDict.isPrimary || false;
121
+ e._source = inDict._source || '';
122
+ return e;
123
+ }
124
+ };
125
+
126
+ scope.eventFactory = eventFactory;
127
+ })(window.PolymerGestures);
@@ -0,0 +1,129 @@
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
+ /**
11
+ * This event is fired when a pointer is held down for 200ms.
12
+ *
13
+ * @module PointerGestures
14
+ * @submodule Events
15
+ * @class hold
16
+ */
17
+ /**
18
+ * Type of pointer that made the holding event.
19
+ * @type String
20
+ * @property pointerType
21
+ */
22
+ /**
23
+ * Screen X axis position of the held pointer
24
+ * @type Number
25
+ * @property clientX
26
+ */
27
+ /**
28
+ * Screen Y axis position of the held pointer
29
+ * @type Number
30
+ * @property clientY
31
+ */
32
+ /**
33
+ * Type of pointer that made the holding event.
34
+ * @type String
35
+ * @property pointerType
36
+ */
37
+ /**
38
+ * This event is fired every 200ms while a pointer is held down.
39
+ *
40
+ * @class holdpulse
41
+ * @extends hold
42
+ */
43
+ /**
44
+ * Milliseconds pointer has been held down.
45
+ * @type Number
46
+ * @property holdTime
47
+ */
48
+ /**
49
+ * This event is fired when a held pointer is released or moved.
50
+ *
51
+ * @class release
52
+ */
53
+
54
+ (function(scope) {
55
+ var dispatcher = scope.dispatcher;
56
+ var eventFactory = scope.eventFactory;
57
+ var hold = {
58
+ // wait at least HOLD_DELAY ms between hold and pulse events
59
+ HOLD_DELAY: 200,
60
+ // pointer can move WIGGLE_THRESHOLD pixels before not counting as a hold
61
+ WIGGLE_THRESHOLD: 16,
62
+ events: [
63
+ 'down',
64
+ 'move',
65
+ 'up',
66
+ ],
67
+ exposes: [
68
+ 'hold',
69
+ 'holdpulse',
70
+ 'release'
71
+ ],
72
+ heldPointer: null,
73
+ holdJob: null,
74
+ pulse: function() {
75
+ var hold = Date.now() - this.heldPointer.timeStamp;
76
+ var type = this.held ? 'holdpulse' : 'hold';
77
+ this.fireHold(type, hold);
78
+ this.held = true;
79
+ },
80
+ cancel: function() {
81
+ clearInterval(this.holdJob);
82
+ if (this.held) {
83
+ this.fireHold('release');
84
+ }
85
+ this.held = false;
86
+ this.heldPointer = null;
87
+ this.target = null;
88
+ this.holdJob = null;
89
+ },
90
+ down: function(inEvent) {
91
+ if (inEvent.isPrimary && !this.heldPointer) {
92
+ this.heldPointer = inEvent;
93
+ this.target = inEvent.target;
94
+ this.holdJob = setInterval(this.pulse.bind(this), this.HOLD_DELAY);
95
+ }
96
+ },
97
+ up: function(inEvent) {
98
+ if (this.heldPointer && this.heldPointer.pointerId === inEvent.pointerId) {
99
+ this.cancel();
100
+ }
101
+ },
102
+ move: function(inEvent) {
103
+ if (this.heldPointer && this.heldPointer.pointerId === inEvent.pointerId) {
104
+ var x = inEvent.clientX - this.heldPointer.clientX;
105
+ var y = inEvent.clientY - this.heldPointer.clientY;
106
+ if ((x * x + y * y) > this.WIGGLE_THRESHOLD) {
107
+ this.cancel();
108
+ }
109
+ }
110
+ },
111
+ fireHold: function(inType, inHoldTime) {
112
+ var p = {
113
+ bubbles: true,
114
+ cancelable: true,
115
+ pointerType: this.heldPointer.pointerType,
116
+ pointerId: this.heldPointer.pointerId,
117
+ x: this.heldPointer.clientX,
118
+ y: this.heldPointer.clientY,
119
+ _source: 'hold'
120
+ };
121
+ if (inHoldTime) {
122
+ p.holdTime = inHoldTime;
123
+ }
124
+ var e = eventFactory.makeGestureEvent(inType, p);
125
+ this.target.dispatchEvent(e);
126
+ }
127
+ };
128
+ dispatcher.registerGesture('hold', hold);
129
+ })(window.PolymerGestures);
@@ -0,0 +1,135 @@
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 dispatcher = scope.dispatcher;
12
+ var pointermap = dispatcher.pointermap;
13
+ // radius around touchend that swallows mouse events
14
+ var DEDUP_DIST = 25;
15
+
16
+ var WHICH_TO_BUTTONS = [0, 1, 4, 2];
17
+
18
+ var currentButtons = 0;
19
+
20
+ var FIREFOX_LINUX = /Linux.*Firefox\//i;
21
+
22
+ var HAS_BUTTONS = (function() {
23
+ // firefox on linux returns spec-incorrect values for mouseup.buttons
24
+ // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.buttons#See_also
25
+ // https://codereview.chromium.org/727593003/#msg16
26
+ if (FIREFOX_LINUX.test(navigator.userAgent)) {
27
+ return false;
28
+ }
29
+ try {
30
+ return new MouseEvent('test', {buttons: 1}).buttons === 1;
31
+ } catch (e) {
32
+ return false;
33
+ }
34
+ })();
35
+
36
+ // handler block for native mouse events
37
+ var mouseEvents = {
38
+ POINTER_ID: 1,
39
+ POINTER_TYPE: 'mouse',
40
+ events: [
41
+ 'mousedown',
42
+ 'mousemove',
43
+ 'mouseup'
44
+ ],
45
+ exposes: [
46
+ 'down',
47
+ 'up',
48
+ 'move'
49
+ ],
50
+ register: function(target) {
51
+ dispatcher.listen(target, this.events);
52
+ },
53
+ unregister: function(target) {
54
+ if (target.nodeType === Node.DOCUMENT_NODE) {
55
+ return;
56
+ }
57
+ dispatcher.unlisten(target, this.events);
58
+ },
59
+ lastTouches: [],
60
+ // collide with the global mouse listener
61
+ isEventSimulatedFromTouch: function(inEvent) {
62
+ var lts = this.lastTouches;
63
+ var x = inEvent.clientX, y = inEvent.clientY;
64
+ for (var i = 0, l = lts.length, t; i < l && (t = lts[i]); i++) {
65
+ // simulated mouse events will be swallowed near a primary touchend
66
+ var dx = Math.abs(x - t.x), dy = Math.abs(y - t.y);
67
+ if (dx <= DEDUP_DIST && dy <= DEDUP_DIST) {
68
+ return true;
69
+ }
70
+ }
71
+ },
72
+ prepareEvent: function(inEvent) {
73
+ var e = dispatcher.cloneEvent(inEvent);
74
+ e.pointerId = this.POINTER_ID;
75
+ e.isPrimary = true;
76
+ e.pointerType = this.POINTER_TYPE;
77
+ e._source = 'mouse';
78
+ if (!HAS_BUTTONS) {
79
+ var type = inEvent.type;
80
+ var bit = WHICH_TO_BUTTONS[inEvent.which] || 0;
81
+ if (type === 'mousedown') {
82
+ currentButtons |= bit;
83
+ } else if (type === 'mouseup') {
84
+ currentButtons &= ~bit;
85
+ }
86
+ e.buttons = currentButtons;
87
+ }
88
+ return e;
89
+ },
90
+ mousedown: function(inEvent) {
91
+ if (!this.isEventSimulatedFromTouch(inEvent)) {
92
+ var p = pointermap.has(this.POINTER_ID);
93
+ var e = this.prepareEvent(inEvent);
94
+ e.target = scope.findTarget(inEvent);
95
+ pointermap.set(this.POINTER_ID, e.target);
96
+ dispatcher.down(e);
97
+ }
98
+ },
99
+ mousemove: function(inEvent) {
100
+ if (!this.isEventSimulatedFromTouch(inEvent)) {
101
+ var target = pointermap.get(this.POINTER_ID);
102
+ if (target) {
103
+ var e = this.prepareEvent(inEvent);
104
+ e.target = target;
105
+ // handle case where we missed a mouseup
106
+ if ((HAS_BUTTONS ? e.buttons : e.which) === 0) {
107
+ if (!HAS_BUTTONS) {
108
+ currentButtons = e.buttons = 0;
109
+ }
110
+ dispatcher.cancel(e);
111
+ this.cleanupMouse(e.buttons);
112
+ } else {
113
+ dispatcher.move(e);
114
+ }
115
+ }
116
+ }
117
+ },
118
+ mouseup: function(inEvent) {
119
+ if (!this.isEventSimulatedFromTouch(inEvent)) {
120
+ var e = this.prepareEvent(inEvent);
121
+ e.relatedTarget = scope.findTarget(inEvent);
122
+ e.target = pointermap.get(this.POINTER_ID);
123
+ dispatcher.up(e);
124
+ this.cleanupMouse(e.buttons);
125
+ }
126
+ },
127
+ cleanupMouse: function(buttons) {
128
+ if (buttons === 0) {
129
+ pointermap.delete(this.POINTER_ID);
130
+ }
131
+ }
132
+ };
133
+
134
+ scope.mouseEvents = mouseEvents;
135
+ })(window.PolymerGestures);
@@ -0,0 +1,80 @@
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 dispatcher = scope.dispatcher;
12
+ var pointermap = dispatcher.pointermap;
13
+ var HAS_BITMAP_TYPE = window.MSPointerEvent && typeof window.MSPointerEvent.MSPOINTER_TYPE_MOUSE === 'number';
14
+ var msEvents = {
15
+ events: [
16
+ 'MSPointerDown',
17
+ 'MSPointerMove',
18
+ 'MSPointerUp',
19
+ 'MSPointerCancel',
20
+ ],
21
+ register: function(target) {
22
+ dispatcher.listen(target, this.events);
23
+ },
24
+ unregister: function(target) {
25
+ if (target.nodeType === Node.DOCUMENT_NODE) {
26
+ return;
27
+ }
28
+ dispatcher.unlisten(target, this.events);
29
+ },
30
+ POINTER_TYPES: [
31
+ '',
32
+ 'unavailable',
33
+ 'touch',
34
+ 'pen',
35
+ 'mouse'
36
+ ],
37
+ prepareEvent: function(inEvent) {
38
+ var e = inEvent;
39
+ e = dispatcher.cloneEvent(inEvent);
40
+ if (HAS_BITMAP_TYPE) {
41
+ e.pointerType = this.POINTER_TYPES[inEvent.pointerType];
42
+ }
43
+ e._source = 'ms';
44
+ return e;
45
+ },
46
+ cleanup: function(id) {
47
+ pointermap['delete'](id);
48
+ },
49
+ MSPointerDown: function(inEvent) {
50
+ var e = this.prepareEvent(inEvent);
51
+ e.target = scope.findTarget(inEvent);
52
+ pointermap.set(inEvent.pointerId, e.target);
53
+ dispatcher.down(e);
54
+ },
55
+ MSPointerMove: function(inEvent) {
56
+ var target = pointermap.get(inEvent.pointerId);
57
+ if (target) {
58
+ var e = this.prepareEvent(inEvent);
59
+ e.target = target;
60
+ dispatcher.move(e);
61
+ }
62
+ },
63
+ MSPointerUp: function(inEvent) {
64
+ var e = this.prepareEvent(inEvent);
65
+ e.relatedTarget = scope.findTarget(inEvent);
66
+ e.target = pointermap.get(e.pointerId);
67
+ dispatcher.up(e);
68
+ this.cleanup(inEvent.pointerId);
69
+ },
70
+ MSPointerCancel: function(inEvent) {
71
+ var e = this.prepareEvent(inEvent);
72
+ e.relatedTarget = scope.findTarget(inEvent);
73
+ e.target = pointermap.get(e.pointerId);
74
+ dispatcher.cancel(e);
75
+ this.cleanup(inEvent.pointerId);
76
+ }
77
+ };
78
+
79
+ scope.msEvents = msEvents;
80
+ })(window.PolymerGestures);