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

Unified Diff: third_party/polymer/components-chromium/paper-focusable/paper-focusable-extracted.js

Issue 592593002: Inline scripts were extracted from Polymer elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/echo ""/echo/ Created 6 years, 3 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/components-chromium/paper-focusable/paper-focusable-extracted.js
diff --git a/third_party/polymer/components-chromium/paper-focusable/paper-focusable-extracted.js b/third_party/polymer/components-chromium/paper-focusable/paper-focusable-extracted.js
new file mode 100644
index 0000000000000000000000000000000000000000..6b4173c596214d0f76bf650fa524b0d798649bc3
--- /dev/null
+++ b/third_party/polymer/components-chromium/paper-focusable/paper-focusable-extracted.js
@@ -0,0 +1,111 @@
+
+ Polymer('paper-focusable', {
+
+ publish: {
+
+ /**
+ * If true, the button is currently active either because the
+ * user is holding down the button, or the button is a toggle
+ * and is currently in the active state.
+ *
+ * @attribute active
+ * @type boolean
+ * @default false
+ */
+ active: {value: false, reflect: true},
+
+ /**
+ * If true, the element currently has focus due to keyboard
+ * navigation.
+ *
+ * @attribute focused
+ * @type boolean
+ * @default false
+ */
+ focused: {value: false, reflect: true},
+
+ /**
+ * If true, the user is currently holding down the button.
+ *
+ * @attribute pressed
+ * @type boolean
+ * @default false
+ */
+ pressed: {value: false, reflect: true},
+
+ /**
+ * If true, the user cannot interact with this element.
+ *
+ * @attribute disabled
+ * @type boolean
+ * @default false
+ */
+ disabled: {value: false, reflect: true},
+
+ /**
+ * If true, the button toggles the active state with each tap.
+ * Otherwise, the button becomes active when the user is holding
+ * it down.
+ *
+ * @attribute isToggle
+ * @type boolean
+ * @default false
+ */
+ isToggle: {value: false, reflect: false}
+
+ },
+
+ disabledChanged: function() {
+ if (this.disabled) {
+ this.removeAttribute('tabindex');
+ } else {
+ this.setAttribute('tabindex', 0);
+ }
+ },
+
+ downAction: function() {
+ this.pressed = true;
+ this.focused = false;
+
+ if (this.isToggle) {
+ this.active = !this.active;
+ } else {
+ this.active = true;
+ }
+ },
+
+ // Pulling up the context menu for an item should focus it; but we need to
+ // be careful about how we deal with down/up events surrounding context
+ // menus. The up event typically does not fire until the context menu
+ // closes: so we focus immediately.
+ //
+ // This fires _after_ downAction.
+ contextMenuAction: function(e) {
+ // Note that upAction may fire _again_ on the actual up event.
+ this.upAction(e);
+ this.focusAction();
+ },
+
+ upAction: function() {
+ this.pressed = false;
+
+ if (!this.isToggle) {
+ this.active = false;
+ }
+ },
+
+ focusAction: function() {
+ if (!this.pressed) {
+ // Only render the "focused" state if the element gains focus due to
+ // keyboard navigation.
+ this.focused = true;
+ }
+ },
+
+ blurAction: function() {
+ this.focused = false;
+ }
+
+ });
+
+

Powered by Google App Engine
This is Rietveld 408576698