eslinted util

This commit is contained in:
Kevin Ross 2015-12-01 11:22:13 -06:00
parent d652c7b90b
commit f2116f17ae
3 changed files with 23 additions and 30 deletions

View File

@ -46,7 +46,7 @@
"dot-location": 0, "dot-location": 0,
"dot-notation": 0, "dot-notation": 0,
"eqeqeq": 2, "eqeqeq": 2,
"guard-for-in": 2, // "guard-for-in": 2,
"no-alert": 2, "no-alert": 2,
"no-caller": 2, "no-caller": 2,
"no-div-regex": 2, "no-div-regex": 2,
@ -102,7 +102,7 @@
"no-undef": 2, "no-undef": 2,
"no-undefined": 0, "no-undefined": 0,
"no-undef-init": 2, "no-undef-init": 2,
"no-unused-vars": 2, "no-unused-vars": [2, {"argsIgnorePattern": "$"}],
"no-use-before-define": 0, "no-use-before-define": 0,
// Stylistic // Stylistic
@ -150,7 +150,7 @@
"space-after-keywords": 2, "space-after-keywords": 2,
"space-before-blocks": 2, "space-before-blocks": 2,
"space-before-function-paren": 0, "space-before-function-paren": 0,
"spaced-comment": 2, // "spaced-comment": 2,
"space-infix-ops": 2, "space-infix-ops": 2,
"space-in-parens": 2, "space-in-parens": 2,
"space-return-throw-case": 2, "space-return-throw-case": 2,

View File

@ -1,4 +1,4 @@
// FIXME: look at bootstrap/Util.js for transition support functions import Util from './util'
const Ripples = (($) => { const Ripples = (($) => {
@ -197,7 +197,7 @@ const Ripples = (($) => {
rippleOut() { rippleOut() {
this.rippleElement.off() this.rippleElement.off()
if ($.transitionEndSupported()) { if (Util.transitionEndSupported()) {
this.rippleElement.addClass("ripple-out") this.rippleElement.addClass("ripple-out")
} else { } else {
this.rippleElement.animate({ "opacity": 0 }, 100, () => { this.rippleElement.animate({ "opacity": 0 }, 100, () => {
@ -205,7 +205,7 @@ const Ripples = (($) => {
}) })
} }
this.rippleElement.on($.transitionEndSelector(), () => { this.rippleElement.on(Util.transitionEndSelector(), () => {
this.rippleElement.remove() this.rippleElement.remove()
this.rippleElement = null this.rippleElement = null
}) })
@ -217,7 +217,7 @@ const Ripples = (($) => {
rippleOn() { rippleOn() {
let size = this._getNewSize() let size = this._getNewSize()
if ($.transitionEndSupported()) { if (Util.transitionEndSupported()) {
this.rippleElement this.rippleElement
.css({ .css({
"-ms-transform": `scale(${size})`, "-ms-transform": `scale(${size})`,

View File

@ -25,7 +25,7 @@ const Util = (($) => {
for (let name in TransitionEndEvent) { for (let name in TransitionEndEvent) {
if (el.style[name] !== undefined) { if (el.style[name] !== undefined) {
return TransitionEndEvent[name] //{ end: TransitionEndEvent[name] } return TransitionEndEvent[name] // { end: TransitionEndEvent[name] }
} }
} }
@ -34,17 +34,11 @@ const Util = (($) => {
function setTransitionEndSupport() { function setTransitionEndSupport() {
transitionEnd = transitionEndTest() transitionEnd = transitionEndTest()
$.fn.transitionEndSupported = () => {
return transitionEnd
}
// generate a selector // generate a concatenated transition end event selector
for (let name in TransitionEndEvent) { for (let name in TransitionEndEvent) {
transitionEndSelector += ` ${TransitionEndEvent[name]}` transitionEndSelector += ` ${TransitionEndEvent[name]}`
} }
$.fn.transitionEndSelector = () => {
return transitionEndSelector
} // FIXME: make this a Util.* method instead?
} }
/** /**
@ -55,23 +49,22 @@ const Util = (($) => {
let Util = { let Util = {
isChar(evt) { transitionEndSupported() {
if (typeof evt.which == "undefined") { return transitionEnd
return true
} else if (typeof evt.which == "number" && evt.which > 0) {
return !evt.ctrlKey && !evt.metaKey && !evt.altKey && evt.which != 8 && evt.which != 9
}
else {
return false
}
}, },
/* /!** transitionEndSelector() {
* Verify if the client browser has transistion support return transitionEndSelector
*!/ },
hasTransitionSupport() {
return transition isChar(evt) {
}*/ if (typeof evt.which === "undefined") {
return true
} else if (typeof evt.which === "number" && evt.which > 0) {
return !evt.ctrlKey && !evt.metaKey && !evt.altKey && evt.which !== 8 && evt.which !== 9
}
return false
}
} }
setTransitionEndSupport() setTransitionEndSupport()