Fixed eslint issues

This commit is contained in:
Tomas Korcak 2015-08-14 19:54:03 +02:00
parent 3a4355416c
commit 82ba3fab49
3 changed files with 63 additions and 65 deletions

View File

@ -11,8 +11,8 @@
* http://www.apache.org/licenses/LICENSE-2.0
*/
var ARR_EACH = Array.prototype.forEach;
var ARR_SLICE = Array.prototype.slice;
const ARR_EACH = Array.prototype.forEach;
const ARR_SLICE = Array.prototype.slice;
/**
* Band-aid methods for things that should be a lot easier in JavaScript.
@ -20,71 +20,65 @@ var ARR_SLICE = Array.prototype.slice;
* http://documentcloud.github.com/underscore/
*/
var Common = {
const Common = {
BREAK: {},
extend: function(target) {
this.each(ARR_SLICE.call(arguments, 1), function(obj) {
for (var key in obj)
if (!this.isUndefined(obj[key]))
for (const key in obj) {
if (!this.isUndefined(obj[key])) {
target[key] = obj[key];
}
}
}, this);
return target;
},
defaults: function(target) {
this.each(ARR_SLICE.call(arguments, 1), function(obj) {
for (var key in obj)
if (this.isUndefined(target[key]))
for (const key in obj) {
if (this.isUndefined(target[key])) {
target[key] = obj[key];
}
}
}, this);
return target;
},
compose: function() {
var toCall = ARR_SLICE.call(arguments);
const toCall = ARR_SLICE.call(arguments);
return function() {
var args = ARR_SLICE.call(arguments);
for (var i = toCall.length - 1; i >= 0; i--) {
let args = ARR_SLICE.call(arguments);
for (let i = toCall.length - 1; i >= 0; i--) {
args = [toCall[i].apply(this, args)];
}
return args[0];
}
};
},
each: function(obj, itr, scope) {
if (!obj) return;
if (ARR_EACH && obj.forEach && obj.forEach === ARR_EACH) {
obj.forEach(itr, scope);
} else if (obj.length === obj.length + 0) { // Is number but not NaN
for (var key = 0, l = obj.length; key < l; key++)
if (key in obj && itr.call(scope, obj[key], key) === this.BREAK)
if (!obj) {
return;
} else {
for (var key in obj)
if (itr.call(scope, obj[key], key) === this.BREAK)
return;
}
if (ARR_EACH && obj.forEach && obj.forEach === ARR_EACH) {
obj.forEach(itr, scope);
} else if (obj.length === obj.length + 0) { // Is number but not NaN
let key;
for (key = 0, l = obj.length; key < l; key++) {
if (key in obj && itr.call(scope, obj[key], key) === this.BREAK) {
return;
}
}
} else {
for (const key in obj) {
if (itr.call(scope, obj[key], key) === this.BREAK) {
return;
}
}
}
},
defer: function(fnc) {
@ -105,7 +99,7 @@ var Common = {
},
isNaN: function(obj) {
return obj !== obj;
return isNaN(obj);
},
isArray: Array.isArray || function(obj) {
@ -134,4 +128,4 @@ var Common = {
};
module.exports = Common;
export default Common;

View File

@ -12,17 +12,18 @@
*/
module.exports = {
load: function (url, doc) {
doc = doc || document;
var link = doc.createElement('link');
load: function(url, indoc) {
const doc = indoc || document;
const link = doc.createElement('link');
link.type = 'text/css';
link.rel = 'stylesheet';
link.href = url;
doc.getElementsByTagName('head')[0].appendChild(link);
},
inject: function (css, doc) {
doc = doc || document;
var injected = document.createElement('style');
inject: function(css, indoc) {
const doc = indoc || document;
const injected = document.createElement('style');
injected.type = 'text/css';
injected.innerHTML = css;
doc.getElementsByTagName('head')[0].appendChild(injected);

View File

@ -11,13 +11,16 @@
* http://www.apache.org/licenses/LICENSE-2.0
*/
module.exports = function () {
export default function() {
function requestAnimationFrame(callback) {
// TODO: Get rid of window
window.setTimeout(callback, 1000 / 60);
}
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function (callback, element) {
window.setTimeout(callback, 1000 / 60);
};
};
requestAnimationFrame;
}