Skip to content

Instantly share code, notes, and snippets.

@garlicnation
Created December 7, 2015 21:53
Show Gist options
  • Save garlicnation/ddb7246980b0a28fbb33 to your computer and use it in GitHub Desktop.
Save garlicnation/ddb7246980b0a28fbb33 to your computer and use it in GitHub Desktop.
Polymer.Pd = {
properties: {
pressed: {
type: Boolean,
readOnly: !0,
value: !1,
reflectToAttribute: !0,
observer: "_pressedChanged"
},
toggles: {
type: Boolean,
value: !1,
reflectToAttribute: !0
},
active: {
type: Boolean,
value: !1,
notify: !0,
reflectToAttribute: !0
},
pointerDown: {
type: Boolean,
readOnly: !0,
value: !1
},
receivedFocusFromKeyboard: {
type: Boolean,
readOnly: !0
},
ariaActiveAttribute: {
type: String,
value: "aria-pressed",
observer: "_ariaActiveAttributeChanged"
}
},
listeners: {
down: "_downHandler",
up: "_upHandler",
tap: "_tapHandler"
},
observers: ["_detectKeyboardFocus(focused)",
"_activeChanged(active, ariaActiveAttribute)"
],
ta: {
"enter:keydown": "_asyncClick",
"space:keydown": "_spaceKeyDownHandler",
"space:keyup": "_spaceKeyUpHandler"
},
re: /^mouse/,
Ch: function() {
this.toggles ? this.Be(!this.active) : this.active = !1
},
lh: function(a) {
this._setReceivedFocusFromKeyboard(!this.pointerDown && a)
},
Be: function(a) {
this.active !== a && (this.active = a, this.fire("change"))
},
ke: function(a) {
a = a.detail.sourceEvent || a;
return this.re.test(a.type) ? "buttons" in a ? 1 === a.buttons : "number" === typeof a.which ? 2 > a.which :
1 > a.button : !0
},
nh: function(a) {
this.ke(a) && (this._setPointerDown(!0), this._setPressed(!0), this._setReceivedFocusFromKeyboard(!1))
},
Dh: function() {
this._setPointerDown(!1);
this._setPressed(!1)
},
Ah: function(a) {
a = a.detail.Gf;
a.preventDefault();
a.stopImmediatePropagation();
this._setPressed(!0)
},
Bh: function() {
this.pressed && this.fe();
this._setPressed(!1)
},
fe: function() {
this.async(function() {
this.click()
}, 1)
},
yh: function() {
this.ab()
},
$g: function(a, c) {
c && c != a && this.hasAttribute(c) && this.removeAttribute(c)
},
ee: function(a) {
this.toggles ? this.setAttribute(this.ariaActiveAttribute, a ? "true" : "false") : this.removeAttribute(this.ariaActiveAttribute);
this.ab()
},
pc: function() {
this.disabled ? this._setPressed(!1) : this.ab()
},
ab: function() {
this.he && this.he()
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment