mirror of
https://github.com/tabler/tabler.git
synced 2025-12-21 17:34:25 +04:00
JS code change with Google guide recommendations
change var by let, block indentation +2 spaces and more
This commit is contained in:
162
dist/assets/js/core.js
vendored
162
dist/assets/js/core.js
vendored
@@ -1,97 +1,107 @@
|
|||||||
var hexToRgba = function(hex, opacity) {
|
/**
|
||||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
*
|
||||||
var rgb = result ? {
|
*/
|
||||||
r: parseInt(result[1], 16),
|
let hexToRgba = function(hex, opacity) {
|
||||||
g: parseInt(result[2], 16),
|
let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||||
b: parseInt(result[3], 16)
|
let rgb = result ? {
|
||||||
} : null;
|
r: parseInt(result[1], 16),
|
||||||
|
g: parseInt(result[2], 16),
|
||||||
|
b: parseInt(result[3], 16)
|
||||||
|
} : null;
|
||||||
|
|
||||||
return 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', '+ opacity + ')';
|
return 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', ' + opacity + ')';
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).ready(function () {
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$(document).ready(function() {
|
||||||
|
/** Constant div card */
|
||||||
|
const DIV_CARD = 'div.card';
|
||||||
|
|
||||||
// Initialize tooltips
|
/** Initialize tooltips */
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
|
|
||||||
// Initialize popovers
|
/** Initialize popovers */
|
||||||
$('[data-toggle="popover"]').popover({
|
$('[data-toggle="popover"]').popover({
|
||||||
html: true
|
html: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// Function for remove card
|
/** Function for remove card */
|
||||||
$('[data-toggle="card-remove"]').on('click', function (e) {
|
$('[data-toggle="card-remove"]').on('click', function(e) {
|
||||||
var $card = $(this).closest('div.card');
|
let $card = $(this).closest(DIV_CARD);
|
||||||
$card.remove();
|
|
||||||
|
|
||||||
e.preventDefault();
|
$card.remove();
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Function for collapse card
|
e.preventDefault();
|
||||||
$('[data-toggle="card-collapse"]').on('click', function (e) {
|
return false;
|
||||||
var $this = $(this),
|
});
|
||||||
$card = $this.closest('div.card');
|
|
||||||
|
|
||||||
$card.toggleClass('card-collapsed');
|
/** Function for collapse card */
|
||||||
|
$('[data-toggle="card-collapse"]').on('click', function(e) {
|
||||||
|
let $card = $(this).closest(DIV_CARD);
|
||||||
|
|
||||||
e.preventDefault();
|
$card.toggleClass('card-collapsed');
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Function for fullscreen card
|
e.preventDefault();
|
||||||
$('[data-toggle="card-fullscreen"]').on('click', function(e) {
|
return false;
|
||||||
var $card = $(this).closest('div.card');
|
});
|
||||||
|
|
||||||
$card.toggleClass('card-fullscreen').removeClass('card-collapsed');
|
/** Function for fullscreen card */
|
||||||
|
$('[data-toggle="card-fullscreen"]').on('click', function(e) {
|
||||||
|
let $card = $(this).closest(DIV_CARD);
|
||||||
|
|
||||||
e.preventDefault();
|
$card.toggleClass('card-fullscreen').removeClass('card-collapsed');
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
if($('[data-sparkline]').length) {
|
e.preventDefault();
|
||||||
var generateSparkline = function($elem, data, params) {
|
return false;
|
||||||
$elem.sparkline(data, {
|
});
|
||||||
type: $elem.attr('data-sparkline-type'),
|
|
||||||
height: '100%',
|
|
||||||
barColor: params.color,
|
|
||||||
lineColor: params.color,
|
|
||||||
fillColor: 'transparent',
|
|
||||||
spotColor: params.color,
|
|
||||||
spotRadius: 0,
|
|
||||||
lineWidth: 2,
|
|
||||||
highlightColor: hexToRgba(params.color, .6),
|
|
||||||
highlightLineColor: '#666',
|
|
||||||
defaultPixelsPerValue: 5
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
require(['sparkline'], function(){
|
/** */
|
||||||
$('[data-sparkline]').each(function(){
|
if ($('[data-sparkline]').length) {
|
||||||
var $chart = $(this);
|
let generateSparkline = function($elem, data, params) {
|
||||||
|
$elem.sparkline(data, {
|
||||||
|
type: $elem.attr('data-sparkline-type'),
|
||||||
|
height: '100%',
|
||||||
|
barColor: params.color,
|
||||||
|
lineColor: params.color,
|
||||||
|
fillColor: 'transparent',
|
||||||
|
spotColor: params.color,
|
||||||
|
spotRadius: 0,
|
||||||
|
lineWidth: 2,
|
||||||
|
highlightColor: hexToRgba(params.color, .6),
|
||||||
|
highlightLineColor: '#666',
|
||||||
|
defaultPixelsPerValue: 5
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
generateSparkline($chart, JSON.parse($chart.attr('data-sparkline')), {
|
require(['sparkline'], function() {
|
||||||
color: $chart.attr('data-sparkline-color')
|
$('[data-sparkline]').each(function() {
|
||||||
});
|
let $chart = $(this);
|
||||||
});
|
|
||||||
|
generateSparkline($chart, JSON.parse($chart.attr('data-sparkline')), {
|
||||||
|
color: $chart.attr('data-sparkline-color')
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
|
if ($('.chart-circle').length) {
|
||||||
|
require(['circle-progress'], function() {
|
||||||
|
$('.chart-circle').each(function() {
|
||||||
|
let $this = $(this);
|
||||||
|
|
||||||
if($('.chart-circle').length) {
|
$this.circleProgress({
|
||||||
require(['circle-progress'], function () {
|
fill: {
|
||||||
$('.chart-circle').each(function () {
|
color: tabler.colors[$this.attr('data-color')] || tabler.colors.blue
|
||||||
var $this = $(this);
|
},
|
||||||
$this.circleProgress({
|
size: $this.height(),
|
||||||
fill: {
|
startAngle: -Math.PI / 4 * 2,
|
||||||
color: tabler.colors[$this.attr('data-color')] || tabler.colors.blue
|
emptyFill: '#F4F4F4',
|
||||||
},
|
lineCap: 'round'
|
||||||
size: $this.height(),
|
|
||||||
startAngle: -Math.PI / 4 * 2,
|
|
||||||
emptyFill: '#F4F4F4',
|
|
||||||
lineCap: 'round'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
@@ -1,97 +1,107 @@
|
|||||||
var hexToRgba = function(hex, opacity) {
|
/**
|
||||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
*
|
||||||
var rgb = result ? {
|
*/
|
||||||
r: parseInt(result[1], 16),
|
let hexToRgba = function(hex, opacity) {
|
||||||
g: parseInt(result[2], 16),
|
let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||||
b: parseInt(result[3], 16)
|
let rgb = result ? {
|
||||||
} : null;
|
r: parseInt(result[1], 16),
|
||||||
|
g: parseInt(result[2], 16),
|
||||||
|
b: parseInt(result[3], 16)
|
||||||
|
} : null;
|
||||||
|
|
||||||
return 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', '+ opacity + ')';
|
return 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', ' + opacity + ')';
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).ready(function () {
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$(document).ready(function() {
|
||||||
|
/** Constant div card */
|
||||||
|
const DIV_CARD = 'div.card';
|
||||||
|
|
||||||
// Initialize tooltips
|
/** Initialize tooltips */
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
|
|
||||||
// Initialize popovers
|
/** Initialize popovers */
|
||||||
$('[data-toggle="popover"]').popover({
|
$('[data-toggle="popover"]').popover({
|
||||||
html: true
|
html: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// Function for remove card
|
/** Function for remove card */
|
||||||
$('[data-toggle="card-remove"]').on('click', function (e) {
|
$('[data-toggle="card-remove"]').on('click', function(e) {
|
||||||
var $card = $(this).closest('div.card');
|
let $card = $(this).closest(DIV_CARD);
|
||||||
$card.remove();
|
|
||||||
|
|
||||||
e.preventDefault();
|
$card.remove();
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Function for collapse card
|
e.preventDefault();
|
||||||
$('[data-toggle="card-collapse"]').on('click', function (e) {
|
return false;
|
||||||
var $this = $(this),
|
});
|
||||||
$card = $this.closest('div.card');
|
|
||||||
|
|
||||||
$card.toggleClass('card-collapsed');
|
/** Function for collapse card */
|
||||||
|
$('[data-toggle="card-collapse"]').on('click', function(e) {
|
||||||
|
let $card = $(this).closest(DIV_CARD);
|
||||||
|
|
||||||
e.preventDefault();
|
$card.toggleClass('card-collapsed');
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Function for fullscreen card
|
e.preventDefault();
|
||||||
$('[data-toggle="card-fullscreen"]').on('click', function(e) {
|
return false;
|
||||||
var $card = $(this).closest('div.card');
|
});
|
||||||
|
|
||||||
$card.toggleClass('card-fullscreen').removeClass('card-collapsed');
|
/** Function for fullscreen card */
|
||||||
|
$('[data-toggle="card-fullscreen"]').on('click', function(e) {
|
||||||
|
let $card = $(this).closest(DIV_CARD);
|
||||||
|
|
||||||
e.preventDefault();
|
$card.toggleClass('card-fullscreen').removeClass('card-collapsed');
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
if($('[data-sparkline]').length) {
|
e.preventDefault();
|
||||||
var generateSparkline = function($elem, data, params) {
|
return false;
|
||||||
$elem.sparkline(data, {
|
});
|
||||||
type: $elem.attr('data-sparkline-type'),
|
|
||||||
height: '100%',
|
|
||||||
barColor: params.color,
|
|
||||||
lineColor: params.color,
|
|
||||||
fillColor: 'transparent',
|
|
||||||
spotColor: params.color,
|
|
||||||
spotRadius: 0,
|
|
||||||
lineWidth: 2,
|
|
||||||
highlightColor: hexToRgba(params.color, .6),
|
|
||||||
highlightLineColor: '#666',
|
|
||||||
defaultPixelsPerValue: 5
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
require(['sparkline'], function(){
|
/** */
|
||||||
$('[data-sparkline]').each(function(){
|
if ($('[data-sparkline]').length) {
|
||||||
var $chart = $(this);
|
let generateSparkline = function($elem, data, params) {
|
||||||
|
$elem.sparkline(data, {
|
||||||
|
type: $elem.attr('data-sparkline-type'),
|
||||||
|
height: '100%',
|
||||||
|
barColor: params.color,
|
||||||
|
lineColor: params.color,
|
||||||
|
fillColor: 'transparent',
|
||||||
|
spotColor: params.color,
|
||||||
|
spotRadius: 0,
|
||||||
|
lineWidth: 2,
|
||||||
|
highlightColor: hexToRgba(params.color, .6),
|
||||||
|
highlightLineColor: '#666',
|
||||||
|
defaultPixelsPerValue: 5
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
generateSparkline($chart, JSON.parse($chart.attr('data-sparkline')), {
|
require(['sparkline'], function() {
|
||||||
color: $chart.attr('data-sparkline-color')
|
$('[data-sparkline]').each(function() {
|
||||||
});
|
let $chart = $(this);
|
||||||
});
|
|
||||||
|
generateSparkline($chart, JSON.parse($chart.attr('data-sparkline')), {
|
||||||
|
color: $chart.attr('data-sparkline-color')
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
|
if ($('.chart-circle').length) {
|
||||||
|
require(['circle-progress'], function() {
|
||||||
|
$('.chart-circle').each(function() {
|
||||||
|
let $this = $(this);
|
||||||
|
|
||||||
if($('.chart-circle').length) {
|
$this.circleProgress({
|
||||||
require(['circle-progress'], function () {
|
fill: {
|
||||||
$('.chart-circle').each(function () {
|
color: tabler.colors[$this.attr('data-color')] || tabler.colors.blue
|
||||||
var $this = $(this);
|
},
|
||||||
$this.circleProgress({
|
size: $this.height(),
|
||||||
fill: {
|
startAngle: -Math.PI / 4 * 2,
|
||||||
color: tabler.colors[$this.attr('data-color')] || tabler.colors.blue
|
emptyFill: '#F4F4F4',
|
||||||
},
|
lineCap: 'round'
|
||||||
size: $this.height(),
|
|
||||||
startAngle: -Math.PI / 4 * 2,
|
|
||||||
emptyFill: '#F4F4F4',
|
|
||||||
lineCap: 'round'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user