Skip to content

Commit

Permalink
solve linting errors and enable eslint in travis
Browse files Browse the repository at this point in the history
  • Loading branch information
Chlodochar authored and invisiblek committed Aug 8, 2016
1 parent 314c1ac commit 513a6fc
Show file tree
Hide file tree
Showing 11 changed files with 2,033 additions and 1,424 deletions.
16 changes: 15 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,22 @@
},
"globals": {
"google": true,
"mapData": true,
"Store": true,
"centerLat": true,
"centerLng": true
"centerLng": true,
"pageLoaded": true,
"countMarkers": true,
"skel": true,
"setupPokemonMarker": true,

"noLabelsStyle": true,
"darkStyle": true,
"light2Style": true,
"pGoStyle": true,
"darkStyleNoLabels": true,
"light2StyleNoLabels": true,
"pGoStyleNoLabels": true
},
"rules": {
"semi": 0
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ install:
- npm install
script:
- npm run build
- npm run lint
- nosetests
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ module.exports = function(grunt) {
grunt.registerTask('css-build', ['sass', 'cssmin']);
grunt.registerTask('js-lint', ['eslint']);

grunt.registerTask('build', ['clean', 'js-build', 'css-build']);
grunt.registerTask('build', ['lint', 'clean', 'js-build', 'css-build']);
grunt.registerTask('lint', ['js-lint']);
grunt.registerTask('default', ['build', 'watch']);

Expand Down
205 changes: 108 additions & 97 deletions static/js/app.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,71 @@
(function() {

"use strict";
;(function () {
'use strict'

// Methods/polyfills.

// addEventsListener
var addEventsListener = function(o, t, e) {
var n, i = t.split(" ");
for (n in i) o.addEventListener(i[n], e)
var addEventsListener = function (o, t, e) {
var n
var i = t.split(' ')
for (n in i) {
o.addEventListener(i[n], e)
}
}

// classList | (c) @remy | github.com/remy/polyfills | rem.mit-license.org
! function() {
function t(t) {
this.el = t;
for (var n = t.className.replace(/^\s+|\s+$/g, "").split(/\s+/), i = 0; i < n.length; i++) e.call(this, n[i])
;(function () {
function t (t) {
this.el = t
for (var n = t.className.replace(/^\s+|\s+$/g, '').split(/\s+/), i = 0; i < n.length; i++) {
e.call(this, n[i])
}
}

function n(t, n, i) {
function n (t, n, i) {
Object.defineProperty ? Object.defineProperty(t, n, {
get: i
}) : t.__defineGetter__(n, i)
}
if (!("undefined" == typeof window.Element || "classList" in document.documentElement)) {
var i = Array.prototype,
e = i.push,
s = i.splice,
o = i.join;
if (!(typeof window.Element === 'undefined' || 'classList' in document.documentElement)) {
var i = Array.prototype
var e = i.push
var s = i.splice
var o = i.join
t.prototype = {
add: function(t) {
add: function (t) {
this.contains(t) || (e.call(this, t), this.el.className = this.toString())
},
contains: function(t) {
return -1 != this.el.className.indexOf(t)
contains: function (t) {
return this.el.className.indexOf(t) !== -1
},
item: function(t) {
item: function (t) {
return this[t] || null
},
remove: function(t) {
remove: function (t) {
if (this.contains(t)) {
for (var n = 0; n < this.length && this[n] != t; n++);
s.call(this, n, 1), this.el.className = this.toString()
for (var n = 0; n < this.length && this[n] !== t; n++) {
s.call(this, n, 1)
this.el.className = this.toString()
}
}
},
toString: function() {
return o.call(this, " ")
toString: function () {
return o.call(this, ' ')
},
toggle: function(t) {
return this.contains(t) ? this.remove(t) : this.add(t), this.contains(t)
toggle: function (t) {
this.contains(t) ? this.remove(t) : this.add(t)
return this.contains(t)
}
}, window.DOMTokenList = t, n(Element.prototype, "classList", function() {
return new t(this)
}
window.DOMTokenList = t
n(Element.prototype, 'classList', function () {
return new t(this) // eslint-disable-line new-cap
})
}
}();
})()

// Vars.
var $body = document.querySelector('body');
var $body = document.querySelector('body')

// Breakpoints.
skel.breakpoints({
Expand All @@ -65,110 +74,112 @@
medium: '(max-width: 980px)',
small: '(max-width: 736px)',
xsmall: '(max-width: 480px)'
});
})

// Disable animations/transitions until everything's loaded.
$body.classList.add('is-loading');
$body.classList.add('is-loading')

window.addEventListener('load', function() {
$body.classList.remove('is-loading');
});
window.addEventListener('load', function () {
$body.classList.remove('is-loading')
})

// Nav.
var $nav = document.querySelector('#nav'),
$navToggle = document.querySelector('a[href="#nav"]'),
$navClose;
var $nav = document.querySelector('#nav')
var $navToggle = document.querySelector('a[href="#nav"]')
var $navClose

// Stats.
var $stats = document.querySelector('#stats'),
$statsToggle = document.querySelector('a[href="#stats"]'),
$statsClose;
var $stats = document.querySelector('#stats')
var $statsToggle = document.querySelector('a[href="#stats"]')
var $statsClose

// Event: Prevent clicks/taps inside the nav from bubbling.
addEventsListener($nav, 'click touchend', function(event) {
event.stopPropagation();
});
addEventsListener($nav, 'click touchend', function (event) {
event.stopPropagation()
})

if($stats){
if ($stats) {
// Event: Prevent clicks/taps inside the stats from bubbling.
addEventsListener($stats, 'click touchend', function(event) {
event.stopPropagation();
});
addEventsListener($stats, 'click touchend', function (event) {
event.stopPropagation()
})
}

// Event: Hide nav on body click/tap.
addEventsListener($body, 'click touchend', function(event) {
addEventsListener($body, 'click touchend', function (event) {
// on ios safari, when navToggle is clicked,
// this function executes too, so if the target
// is the toggle button, exit this function
if (event.target.matches('a[href="#nav"]')) {
return;
return
}
if ($stats && event.target.matches('a[href="#stats]')) {
return;
return
}
$nav.classList.remove('visible')
if ($stats) {
$stats.classList.remove('visible')
}
$nav.classList.remove('visible');
if($stats)
$stats.classList.remove('visible');
});
})

// Toggle.

// Event: Toggle nav on click.
$navToggle.addEventListener('click', function(event) {
event.preventDefault();
event.stopPropagation();
$nav.classList.toggle('visible');
});
$navToggle.addEventListener('click', function (event) {
event.preventDefault()
event.stopPropagation()
$nav.classList.toggle('visible')
})

// Event: Toggle stats on click.
if($statsToggle){
$statsToggle.addEventListener('click', function(event) {
event.preventDefault();
event.stopPropagation();
$stats.classList.toggle('visible');
});
if ($statsToggle) {
$statsToggle.addEventListener('click', function (event) {
event.preventDefault()
event.stopPropagation()
$stats.classList.toggle('visible')
})
}

// Close.

// Create elements.
$navClose = document.createElement('a');
$navClose.href = '#';
$navClose.className = 'close';
$navClose.tabIndex = 0;
$nav.appendChild($navClose);

if($stats){
$statsClose = document.createElement('a');
$statsClose.href = '#';
$statsClose.className = 'close';
$statsClose.tabIndex = 0;
$stats.appendChild($statsClose);
$navClose = document.createElement('a')
$navClose.href = '#'
$navClose.className = 'close'
$navClose.tabIndex = 0
$nav.appendChild($navClose)

if ($stats) {
$statsClose = document.createElement('a')
$statsClose.href = '#'
$statsClose.className = 'close'
$statsClose.tabIndex = 0
$stats.appendChild($statsClose)
}

// Event: Hide on ESC.
window.addEventListener('keydown', function(event) {
if (event.keyCode == 27) {
$nav.classList.remove('visible');
if($stats)
$stats.classList.remove('visible');
window.addEventListener('keydown', function (event) {
if (event.keyCode === 27) {
$nav.classList.remove('visible')
if ($stats) {
$stats.classList.remove('visible')
}
}
});
})

// Event: Hide nav on click.
$navClose.addEventListener('click', function(event) {
event.preventDefault();
event.stopPropagation();
$nav.classList.remove('visible');
});
$navClose.addEventListener('click', function (event) {
event.preventDefault()
event.stopPropagation()
$nav.classList.remove('visible')
})

if($statsClose){
if ($statsClose) {
// Event: Hide stats on click.
$statsClose.addEventListener('click', function(event) {
event.preventDefault();
event.stopPropagation();
$stats.classList.remove('visible');
});
$statsClose.addEventListener('click', function (event) {
event.preventDefault()
event.stopPropagation()
$stats.classList.remove('visible')
})
}
})();
})()
Loading

0 comments on commit 513a6fc

Please sign in to comment.