1
0
mirror of https://github.com/tabler/tabler.git synced 2025-12-22 09:54:24 +04:00

Apply eslint 🍪

This commit is contained in:
Damian Sznajder
2019-06-17 21:43:15 +02:00
parent 9febb4be53
commit 497f238fd4
5 changed files with 96 additions and 103 deletions

View File

@@ -10,12 +10,11 @@ bs.init({
'/dist': 'dist', '/dist': 'dist',
'/libs': 'static/libs', '/libs': 'static/libs',
'/img': 'static/img', '/img': 'static/img',
} },
}, },
files: ['tmp/**/*', 'dist/css/*.css', 'dist/js/*.js'], files: ['tmp/**/*', 'dist/css/*.css', 'dist/js/*.js'],
watchOptions: { watchOptions: {
ignoreInitial: true ignoreInitial: true,
}, },
notify: false notify: false,
}); });

View File

@@ -4,18 +4,17 @@ const fs = require('fs'),
path = require('path'), path = require('path'),
yaml = require('yaml'); yaml = require('yaml');
const data = fs.readFileSync(path.resolve(__dirname, '../scss/fonts/_tabler-webfont.scss'), "utf8"), const data = fs.readFileSync(path.resolve(__dirname, '../scss/fonts/_tabler-webfont.scss'), 'utf8'),
re = /\$icon-([^\-\s]+)-([^:\s]+):\s'([^'\n]+)';/g; re = /\$icon-([^\-\s]+)-([^:\s]+):\s'([^'\n]+)';/g;
let items = {}; let items = {};
data.replace(re, function (match, g1, g2, g3) { data.replace(re, function(match, g1, g2, g3) {
if(!items[g1]) { if (!items[g1]) {
items[g1] = {}; items[g1] = {};
} }
items[g1][g2] = g3; items[g1][g2] = g3;
}); });
fs.writeFileSync('pages/_data/icons.yml', yaml.stringify(items)); fs.writeFileSync('pages/_data/icons.yml', yaml.stringify(items));

View File

@@ -20,13 +20,13 @@ const plugins = [
'createClass', 'createClass',
'inheritsLoose', 'inheritsLoose',
'defineProperty', 'defineProperty',
'objectSpread' 'objectSpread',
] ],
}) }),
]; ];
const globals = { const globals = {
'popper.js': 'Popper' 'popper.js': 'Popper',
}; };
if (BUNDLE) { if (BUNDLE) {
@@ -43,10 +43,10 @@ const rollupConfig = {
banner, banner,
file: path.resolve(__dirname, `../dist/js/${fileDest}.js`), file: path.resolve(__dirname, `../dist/js/${fileDest}.js`),
format: ESM ? 'esm' : 'umd', format: ESM ? 'esm' : 'umd',
globals globals,
}, },
external, external,
plugins plugins,
}; };
if (!ESM) { if (!ESM) {

View File

@@ -1,52 +1,47 @@
(function ($) { (function($) {
$(document).ready(function () { $(document).ready(function() {
$().peity &&
$('[data-spark]').each(function() {
const $this = $(this),
data = $this.attr('data-spark'),
color = $this.attr('data-spark-color') || 'blue',
type = $this.attr('data-spark-type') || 'line';
$().peity && $('[data-spark]').each(function () { const $div = $('<div />').html(data);
const $this = $(this), $this.append($div);
data = $this.attr('data-spark'),
color = $this.attr('data-spark-color') || 'blue',
type = $this.attr('data-spark-type') || 'line';
const $div = $('<div />').html(data); let strokeColor = tabler.colors[color],
$this.append($div); fillColor = tabler.colors[color];
let strokeColor = tabler.colors[color], if (type === 'donut' || type === 'pie') {
fillColor = tabler.colors[color]; fillColor = [fillColor, tabler.hexToRgbA(fillColor, 0.1)];
} else if (type === 'bar') {
fillColor = [fillColor];
} else if (type === 'line') {
fillColor = tabler.hexToRgbA(fillColor, 0.1);
}
if (type === 'donut' || type === 'pie') { $div.peity(type, {
fillColor = [fillColor, tabler.hexToRgbA(fillColor, .1)]; width: $this.width(),
} else if (type === 'bar') { height: $this.height(),
fillColor = [fillColor]; // max: 100,
} else if (type === 'line') { // min: 0,
fillColor = tabler.hexToRgbA(fillColor, .1); stroke: strokeColor,
} strokeWidth: 2,
fill: fillColor,
$div.peity(type, { padding: 0.2,
width: $this.width(), innerRadius: type === 'donut' ? 17 : 0,
height: $this.height(), });
// max: 100,
// min: 0,
stroke: strokeColor,
strokeWidth: 2,
fill: fillColor,
padding: .2,
innerRadius: (type === 'donut') ? 17 : 0
}); });
});
}); });
})(jQuery); })(jQuery);
/* /*
charts default configuration charts default configuration
*/ */
if (window.Apex) { if (window.Apex) {
const borderColor = 'rgba(0, 0, 0, 0.09)';
var borderColor = 'rgba(0, 0, 0, 0.09)'; const mutedColor = '#888e9a';
var mutedColor = '#888e9a';
window.Apex = { window.Apex = {
chart: { chart: {
@@ -56,11 +51,11 @@ if (window.Apex) {
show: false, show: false,
}, },
zoom: { zoom: {
enabled: false enabled: false,
}, },
animations: { animations: {
enabled: false, enabled: false,
} },
}, },
grid: { grid: {
@@ -71,8 +66,8 @@ if (window.Apex) {
right: 0, right: 0,
left: 0, left: 0,
bottom: 0, bottom: 0,
top: 0 top: 0,
} },
}, },
dataLabels: { dataLabels: {
@@ -100,7 +95,7 @@ if (window.Apex) {
fill: { fill: {
type: 'solid', type: 'solid',
opacity: 1 opacity: 1,
}, },
markers: { markers: {
@@ -109,7 +104,7 @@ if (window.Apex) {
radius: 2, radius: 2,
hover: { hover: {
size: 4, size: 4,
} },
}, },
legend: { legend: {
@@ -117,22 +112,22 @@ if (window.Apex) {
fontSize: '14px', fontSize: '14px',
markers: { markers: {
width: 8, width: 8,
height: 8 height: 8,
}, },
itemMargin: { itemMargin: {
horizontal: 0, horizontal: 0,
vertical: 8 vertical: 8,
}, },
}, },
title: { title: {
style: { style: {
fontSize: '14px', fontSize: '14px',
} },
}, },
tooltip: { tooltip: {
fillSeriesColor: false fillSeriesColor: false,
}, },
xaxis: { xaxis: {
@@ -140,27 +135,27 @@ if (window.Apex) {
style: { style: {
colors: mutedColor, colors: mutedColor,
fontSize: '12px', fontSize: '12px',
} },
}, },
tooltip: { tooltip: {
enabled: false enabled: false,
}, },
axisBorder: { axisBorder: {
color: borderColor, color: borderColor,
height: 0 height: 0,
}, },
axisTicks: { axisTicks: {
show: true, show: true,
height: 4, height: 4,
color: borderColor color: borderColor,
} },
}, },
yaxis: { yaxis: {
show: false, show: false,
labels: { labels: {
show: false show: false,
} },
} },
}; };
} }

View File

@@ -1,21 +1,21 @@
const tabler = { const tabler = {
colorVariation: function (color, variation) { colorVariation: function(color, variation) {
const colorValue = this.colors[color]; const colorValue = this.colors[color];
if (colorValue) { if (colorValue) {
switch (variation) { switch (variation) {
case 'light': case 'light':
return this.mixColors(colorValue, '#ffffff', 70); return this.mixColors(colorValue, '#ffffff', 70);
case 'lighten': case 'lighten':
return this.mixColors(colorValue, '#ffffff', 30); return this.mixColors(colorValue, '#ffffff', 30);
case 'lightest': case 'lightest':
return this.mixColors(colorValue, '#ffffff', 10); return this.mixColors(colorValue, '#ffffff', 10);
case 'dark': case 'dark':
return this.mixColors(colorValue, '#000000', 80); return this.mixColors(colorValue, '#000000', 80);
case 'darken': case 'darken':
return this.mixColors(colorValue, '#000000', 40); return this.mixColors(colorValue, '#000000', 40);
case 'darkest': case 'darkest':
return this.mixColors(colorValue, '#000000', 20); return this.mixColors(colorValue, '#000000', 20);
} }
return colorValue; return colorValue;
@@ -24,7 +24,7 @@ const tabler = {
throw new Error('Wrong color: ' + color); throw new Error('Wrong color: ' + color);
}, },
hexToRgbA: function (hex, opacity) { hexToRgbA: function(hex, opacity) {
let c; let c;
opacity = opacity || 1; opacity = opacity || 1;
@@ -40,7 +40,7 @@ const tabler = {
throw new Error('Bad Hex'); throw new Error('Bad Hex');
}, },
mixColors: function (color_1, color_2, weight) { mixColors: function(color_1, color_2, weight) {
color_1 = color_1.substr(1); color_1 = color_1.substr(1);
color_2 = color_2.substr(1); color_2 = color_2.substr(1);
@@ -52,7 +52,7 @@ const tabler = {
return parseInt(h, 16); return parseInt(h, 16);
} }
weight = (typeof(weight) !== 'undefined') ? weight : 50; weight = typeof weight !== 'undefined' ? weight : 50;
let color = '#'; let color = '#';
@@ -72,10 +72,14 @@ const tabler = {
return color; return color;
}, },
toggleFullscreen: function (elem) { toggleFullscreen: function(elem) {
elem = elem || document.documentElement; elem = elem || document.documentElement;
if (!document.fullscreenElement && !document.mozFullScreenElement && if (
!document.webkitFullscreenElement && !document.msFullscreenElement) { !document.fullscreenElement &&
!document.mozFullScreenElement &&
!document.webkitFullscreenElement &&
!document.msFullscreenElement
) {
if (elem.requestFullscreen) { if (elem.requestFullscreen) {
elem.requestFullscreen(); elem.requestFullscreen();
} else if (elem.msRequestFullscreen) { } else if (elem.msRequestFullscreen) {
@@ -96,14 +100,13 @@ const tabler = {
document.webkitExitFullscreen(); document.webkitExitFullscreen();
} }
} }
} },
}; };
$(document).ready(function() {
$(document).ready(function () {
const $body = $('body'); const $body = $('body');
$body.on('click', '[data-toggle="sidebar"]', function (e) { $body.on('click', '[data-toggle="sidebar"]', function(e) {
$body.toggleClass('sidebar-opened'); $body.toggleClass('sidebar-opened');
e.preventDefault(); e.preventDefault();
@@ -113,37 +116,34 @@ $(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip(); $('[data-toggle="tooltip"]').tooltip();
$('[data-toggle="popover"]').popover(); $('[data-toggle="popover"]').popover();
/* /*
Autosize plugin Autosize plugin
*/ */
if(window.autosize) { if (window.autosize) {
(function() { (function() {
const $elem = $('[data-toggle="autosize"]');
var $elem = $('[data-toggle="autosize"]');
if ($elem) { if ($elem) {
$elem.each(function() { $elem.each(function() {
autosize($(this)); autosize($(this));
}); });
} }
})(); })();
} }
/* /*
Imask plugin Imask plugin
*/ */
if(window.IMask) { if (window.IMask) {
(function() { (function() {
var $elem = $('[data-mask]'); const $elem = $('[data-mask]');
if ($elem) { if ($elem) {
$elem.each(function() { $elem.each(function() {
IMask($(this).get(0), { IMask($(this).get(0), {
mask: $(this).attr('data-mask'), mask: $(this).attr('data-mask'),
lazy: $(this).attr('data-mask-visible') === 'true' lazy: $(this).attr('data-mask-visible') === 'true',
}) });
}); });
} }
})(); })();
@@ -152,8 +152,8 @@ $(document).ready(function () {
/** /**
* Seelectize plugin * Seelectize plugin
*/ */
if(jQuery && jQuery().selectize) { if (jQuery && jQuery().selectize) {
var $elem = $('[data-selectize]'); const $elem = $('[data-selectize]');
if ($elem) { if ($elem) {
$elem.selectize(); $elem.selectize();