mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
Fixed eslint issues
This commit is contained in:
parent
3a4355416c
commit
82ba3fab49
@ -11,8 +11,8 @@
|
|||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var ARR_EACH = Array.prototype.forEach;
|
const ARR_EACH = Array.prototype.forEach;
|
||||||
var ARR_SLICE = Array.prototype.slice;
|
const ARR_SLICE = Array.prototype.slice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Band-aid methods for things that should be a lot easier in JavaScript.
|
* Band-aid methods for things that should be a lot easier in JavaScript.
|
||||||
@ -20,118 +20,112 @@ var ARR_SLICE = Array.prototype.slice;
|
|||||||
* http://documentcloud.github.com/underscore/
|
* http://documentcloud.github.com/underscore/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Common = {
|
const Common = {
|
||||||
|
|
||||||
BREAK: {},
|
BREAK: {},
|
||||||
|
|
||||||
extend: function (target) {
|
extend: function(target) {
|
||||||
|
this.each(ARR_SLICE.call(arguments, 1), function(obj) {
|
||||||
this.each(ARR_SLICE.call(arguments, 1), function (obj) {
|
for (const key in obj) {
|
||||||
|
if (!this.isUndefined(obj[key])) {
|
||||||
for (var key in obj)
|
|
||||||
if (!this.isUndefined(obj[key]))
|
|
||||||
target[key] = obj[key];
|
target[key] = obj[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
defaults: function (target) {
|
defaults: function(target) {
|
||||||
|
this.each(ARR_SLICE.call(arguments, 1), function(obj) {
|
||||||
this.each(ARR_SLICE.call(arguments, 1), function (obj) {
|
for (const key in obj) {
|
||||||
|
if (this.isUndefined(target[key])) {
|
||||||
for (var key in obj)
|
|
||||||
if (this.isUndefined(target[key]))
|
|
||||||
target[key] = obj[key];
|
target[key] = obj[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
compose: function () {
|
compose: function() {
|
||||||
var toCall = ARR_SLICE.call(arguments);
|
const toCall = ARR_SLICE.call(arguments);
|
||||||
return function () {
|
return function() {
|
||||||
var args = ARR_SLICE.call(arguments);
|
let args = ARR_SLICE.call(arguments);
|
||||||
for (var i = toCall.length - 1; i >= 0; i--) {
|
for (let i = toCall.length - 1; i >= 0; i--) {
|
||||||
args = [toCall[i].apply(this, args)];
|
args = [toCall[i].apply(this, args)];
|
||||||
}
|
}
|
||||||
return args[0];
|
return args[0];
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
each: function (obj, itr, scope) {
|
each: function(obj, itr, scope) {
|
||||||
|
if (!obj) {
|
||||||
if (!obj) return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ARR_EACH && obj.forEach && obj.forEach === ARR_EACH) {
|
if (ARR_EACH && obj.forEach && obj.forEach === ARR_EACH) {
|
||||||
|
|
||||||
obj.forEach(itr, scope);
|
obj.forEach(itr, scope);
|
||||||
|
|
||||||
} else if (obj.length === obj.length + 0) { // Is number but not NaN
|
} else if (obj.length === obj.length + 0) { // Is number but not NaN
|
||||||
|
let key;
|
||||||
for (var key = 0, l = obj.length; key < l; key++)
|
for (key = 0, l = obj.length; key < l; key++) {
|
||||||
if (key in obj && itr.call(scope, obj[key], key) === this.BREAK)
|
if (key in obj && itr.call(scope, obj[key], key) === this.BREAK) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
for (const key in obj) {
|
||||||
for (var key in obj)
|
if (itr.call(scope, obj[key], key) === this.BREAK) {
|
||||||
if (itr.call(scope, obj[key], key) === this.BREAK)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
defer: function (fnc) {
|
defer: function(fnc) {
|
||||||
setTimeout(fnc, 0);
|
setTimeout(fnc, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
toArray: function (obj) {
|
toArray: function(obj) {
|
||||||
if (obj.toArray) return obj.toArray();
|
if (obj.toArray) return obj.toArray();
|
||||||
return ARR_SLICE.call(obj);
|
return ARR_SLICE.call(obj);
|
||||||
},
|
},
|
||||||
|
|
||||||
isUndefined: function (obj) {
|
isUndefined: function(obj) {
|
||||||
return obj === undefined;
|
return obj === undefined;
|
||||||
},
|
},
|
||||||
|
|
||||||
isNull: function (obj) {
|
isNull: function(obj) {
|
||||||
return obj === null;
|
return obj === null;
|
||||||
},
|
},
|
||||||
|
|
||||||
isNaN: function (obj) {
|
isNaN: function(obj) {
|
||||||
return obj !== obj;
|
return isNaN(obj);
|
||||||
},
|
},
|
||||||
|
|
||||||
isArray: Array.isArray || function (obj) {
|
isArray: Array.isArray || function(obj) {
|
||||||
return obj.constructor === Array;
|
return obj.constructor === Array;
|
||||||
},
|
},
|
||||||
|
|
||||||
isObject: function (obj) {
|
isObject: function(obj) {
|
||||||
return obj === Object(obj);
|
return obj === Object(obj);
|
||||||
},
|
},
|
||||||
|
|
||||||
isNumber: function (obj) {
|
isNumber: function(obj) {
|
||||||
return obj === obj + 0;
|
return obj === obj + 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
isString: function (obj) {
|
isString: function(obj) {
|
||||||
return obj === obj + '';
|
return obj === obj + '';
|
||||||
},
|
},
|
||||||
|
|
||||||
isBoolean: function (obj) {
|
isBoolean: function(obj) {
|
||||||
return obj === false || obj === true;
|
return obj === false || obj === true;
|
||||||
},
|
},
|
||||||
|
|
||||||
isFunction: function (obj) {
|
isFunction: function(obj) {
|
||||||
return Object.prototype.toString.call(obj) === '[object Function]';
|
return Object.prototype.toString.call(obj) === '[object Function]';
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Common;
|
export default Common;
|
||||||
|
@ -12,17 +12,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
load: function (url, doc) {
|
load: function(url, indoc) {
|
||||||
doc = doc || document;
|
const doc = indoc || document;
|
||||||
var link = doc.createElement('link');
|
const link = doc.createElement('link');
|
||||||
link.type = 'text/css';
|
link.type = 'text/css';
|
||||||
link.rel = 'stylesheet';
|
link.rel = 'stylesheet';
|
||||||
link.href = url;
|
link.href = url;
|
||||||
doc.getElementsByTagName('head')[0].appendChild(link);
|
doc.getElementsByTagName('head')[0].appendChild(link);
|
||||||
},
|
},
|
||||||
inject: function (css, doc) {
|
|
||||||
doc = doc || document;
|
inject: function(css, indoc) {
|
||||||
var injected = document.createElement('style');
|
const doc = indoc || document;
|
||||||
|
const injected = document.createElement('style');
|
||||||
injected.type = 'text/css';
|
injected.type = 'text/css';
|
||||||
injected.innerHTML = css;
|
injected.innerHTML = css;
|
||||||
doc.getElementsByTagName('head')[0].appendChild(injected);
|
doc.getElementsByTagName('head')[0].appendChild(injected);
|
||||||
|
@ -11,13 +11,16 @@
|
|||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* 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 ||
|
return window.requestAnimationFrame ||
|
||||||
window.webkitRequestAnimationFrame ||
|
window.webkitRequestAnimationFrame ||
|
||||||
window.mozRequestAnimationFrame ||
|
window.mozRequestAnimationFrame ||
|
||||||
window.oRequestAnimationFrame ||
|
window.oRequestAnimationFrame ||
|
||||||
window.msRequestAnimationFrame ||
|
window.msRequestAnimationFrame ||
|
||||||
function (callback, element) {
|
requestAnimationFrame;
|
||||||
window.setTimeout(callback, 1000 / 60);
|
}
|
||||||
};
|
|
||||||
};
|
|
||||||
|
Loading…
Reference in New Issue
Block a user