Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: third_party/polymer/v0_8/components-chromium/polymer/src/standard/events-extracted.js

Issue 1082403004: Import Polymer 0.8 and several key elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also remove polymer/explainer Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v0_8/components-chromium/polymer/src/standard/events-extracted.js
diff --git a/third_party/polymer/v0_8/components-chromium/polymer/src/standard/events-extracted.js b/third_party/polymer/v0_8/components-chromium/polymer/src/standard/events-extracted.js
new file mode 100644
index 0000000000000000000000000000000000000000..4f6a3e795cb77fe3d21fd945569c5e16d3f48f10
--- /dev/null
+++ b/third_party/polymer/v0_8/components-chromium/polymer/src/standard/events-extracted.js
@@ -0,0 +1,84 @@
+
+
+ /**
+ * Supports `listeners` and `keyPresses` objects.
+ *
+ * Example:
+ *
+ * using('Base', function(Base) {
+ *
+ * Polymer({
+ *
+ * listeners: {
+ * // `click` events on the host are delegated to `clickHandler`
+ * 'click': 'clickHandler'
+ * },
+ *
+ * keyPresses: {
+ * // 'ESC' key presses are delegated to `escHandler`
+ * Base.ESC_KEY: 'escHandler'
+ * },
+ *
+ * ...
+ *
+ * });
+ *
+ * });
+ *
+ * @class standard feature: events
+ *
+ */
+
+ Polymer.Base._addFeature({
+
+ listeners: {},
+
+ _listenListeners: function(listeners) {
+ var node, name, key;
+ for (key in listeners) {
+ if (key.indexOf('.') < 0) {
+ node = this;
+ name = key;
+ } else {
+ name = key.split('.');
+ node = this.$[name[0]];
+ name = name[1];
+ }
+ this.listen(node, name, listeners[key]);
+ }
+ },
+
+ listen: function(node, eventName, methodName) {
+ var host = this;
+ var handler = function(e) {
+ if (host[methodName]) {
+ host[methodName](e, e.detail);
+ } else {
+ console.warn('[%s].[%s]: event handler [%s] is null in scope (%o)',
+ node.localName, eventName, methodName, host);
+ }
+ };
+ switch (eventName) {
+ case 'tap':
+ case 'track':
+ Polymer.Gestures.add(eventName, node, handler);
+ break;
+
+ default:
+ node.addEventListener(eventName, handler);
+ break;
+ }
+ },
+
+ keyCodes: {
+ ESC_KEY: 27,
+ ENTER_KEY: 13,
+ LEFT: 37,
+ UP: 38,
+ RIGHT: 39,
+ DOWN: 40,
+ SPACE: 32
+ }
+
+ });
+

Powered by Google App Engine
This is Rietveld 408576698