mirror of
https://github.com/tabler/tabler.git
synced 2025-12-22 01:44: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:
42
dist/assets/js/core.js
vendored
42
dist/assets/js/core.js
vendored
@@ -1,6 +1,9 @@
|
|||||||
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 ? {
|
*/
|
||||||
|
let hexToRgba = function(hex, opacity) {
|
||||||
|
let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||||
|
let rgb = result ? {
|
||||||
r: parseInt(result[1], 16),
|
r: parseInt(result[1], 16),
|
||||||
g: parseInt(result[2], 16),
|
g: parseInt(result[2], 16),
|
||||||
b: parseInt(result[3], 16)
|
b: parseInt(result[3], 16)
|
||||||
@@ -9,29 +12,34 @@ var hexToRgba = function(hex, opacity) {
|
|||||||
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();
|
$card.remove();
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Function for collapse card
|
/** Function for collapse card */
|
||||||
$('[data-toggle="card-collapse"]').on('click', function(e) {
|
$('[data-toggle="card-collapse"]').on('click', function(e) {
|
||||||
var $this = $(this),
|
let $card = $(this).closest(DIV_CARD);
|
||||||
$card = $this.closest('div.card');
|
|
||||||
|
|
||||||
$card.toggleClass('card-collapsed');
|
$card.toggleClass('card-collapsed');
|
||||||
|
|
||||||
@@ -39,9 +47,9 @@ $(document).ready(function () {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Function for fullscreen card
|
/** Function for fullscreen card */
|
||||||
$('[data-toggle="card-fullscreen"]').on('click', function(e) {
|
$('[data-toggle="card-fullscreen"]').on('click', function(e) {
|
||||||
var $card = $(this).closest('div.card');
|
let $card = $(this).closest(DIV_CARD);
|
||||||
|
|
||||||
$card.toggleClass('card-fullscreen').removeClass('card-collapsed');
|
$card.toggleClass('card-fullscreen').removeClass('card-collapsed');
|
||||||
|
|
||||||
@@ -49,8 +57,9 @@ $(document).ready(function () {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** */
|
||||||
if ($('[data-sparkline]').length) {
|
if ($('[data-sparkline]').length) {
|
||||||
var generateSparkline = function($elem, data, params) {
|
let generateSparkline = function($elem, data, params) {
|
||||||
$elem.sparkline(data, {
|
$elem.sparkline(data, {
|
||||||
type: $elem.attr('data-sparkline-type'),
|
type: $elem.attr('data-sparkline-type'),
|
||||||
height: '100%',
|
height: '100%',
|
||||||
@@ -68,7 +77,7 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
require(['sparkline'], function() {
|
require(['sparkline'], function() {
|
||||||
$('[data-sparkline]').each(function() {
|
$('[data-sparkline]').each(function() {
|
||||||
var $chart = $(this);
|
let $chart = $(this);
|
||||||
|
|
||||||
generateSparkline($chart, JSON.parse($chart.attr('data-sparkline')), {
|
generateSparkline($chart, JSON.parse($chart.attr('data-sparkline')), {
|
||||||
color: $chart.attr('data-sparkline-color')
|
color: $chart.attr('data-sparkline-color')
|
||||||
@@ -77,11 +86,12 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
if ($('.chart-circle').length) {
|
if ($('.chart-circle').length) {
|
||||||
require(['circle-progress'], function() {
|
require(['circle-progress'], function() {
|
||||||
$('.chart-circle').each(function() {
|
$('.chart-circle').each(function() {
|
||||||
var $this = $(this);
|
let $this = $(this);
|
||||||
|
|
||||||
$this.circleProgress({
|
$this.circleProgress({
|
||||||
fill: {
|
fill: {
|
||||||
color: tabler.colors[$this.attr('data-color')] || tabler.colors.blue
|
color: tabler.colors[$this.attr('data-color')] || tabler.colors.blue
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
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 ? {
|
*/
|
||||||
|
let hexToRgba = function(hex, opacity) {
|
||||||
|
let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||||
|
let rgb = result ? {
|
||||||
r: parseInt(result[1], 16),
|
r: parseInt(result[1], 16),
|
||||||
g: parseInt(result[2], 16),
|
g: parseInt(result[2], 16),
|
||||||
b: parseInt(result[3], 16)
|
b: parseInt(result[3], 16)
|
||||||
@@ -9,29 +12,34 @@ var hexToRgba = function(hex, opacity) {
|
|||||||
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();
|
$card.remove();
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Function for collapse card
|
/** Function for collapse card */
|
||||||
$('[data-toggle="card-collapse"]').on('click', function(e) {
|
$('[data-toggle="card-collapse"]').on('click', function(e) {
|
||||||
var $this = $(this),
|
let $card = $(this).closest(DIV_CARD);
|
||||||
$card = $this.closest('div.card');
|
|
||||||
|
|
||||||
$card.toggleClass('card-collapsed');
|
$card.toggleClass('card-collapsed');
|
||||||
|
|
||||||
@@ -39,9 +47,9 @@ $(document).ready(function () {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Function for fullscreen card
|
/** Function for fullscreen card */
|
||||||
$('[data-toggle="card-fullscreen"]').on('click', function(e) {
|
$('[data-toggle="card-fullscreen"]').on('click', function(e) {
|
||||||
var $card = $(this).closest('div.card');
|
let $card = $(this).closest(DIV_CARD);
|
||||||
|
|
||||||
$card.toggleClass('card-fullscreen').removeClass('card-collapsed');
|
$card.toggleClass('card-fullscreen').removeClass('card-collapsed');
|
||||||
|
|
||||||
@@ -49,8 +57,9 @@ $(document).ready(function () {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** */
|
||||||
if ($('[data-sparkline]').length) {
|
if ($('[data-sparkline]').length) {
|
||||||
var generateSparkline = function($elem, data, params) {
|
let generateSparkline = function($elem, data, params) {
|
||||||
$elem.sparkline(data, {
|
$elem.sparkline(data, {
|
||||||
type: $elem.attr('data-sparkline-type'),
|
type: $elem.attr('data-sparkline-type'),
|
||||||
height: '100%',
|
height: '100%',
|
||||||
@@ -68,7 +77,7 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
require(['sparkline'], function() {
|
require(['sparkline'], function() {
|
||||||
$('[data-sparkline]').each(function() {
|
$('[data-sparkline]').each(function() {
|
||||||
var $chart = $(this);
|
let $chart = $(this);
|
||||||
|
|
||||||
generateSparkline($chart, JSON.parse($chart.attr('data-sparkline')), {
|
generateSparkline($chart, JSON.parse($chart.attr('data-sparkline')), {
|
||||||
color: $chart.attr('data-sparkline-color')
|
color: $chart.attr('data-sparkline-color')
|
||||||
@@ -77,11 +86,12 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
if ($('.chart-circle').length) {
|
if ($('.chart-circle').length) {
|
||||||
require(['circle-progress'], function() {
|
require(['circle-progress'], function() {
|
||||||
$('.chart-circle').each(function() {
|
$('.chart-circle').each(function() {
|
||||||
var $this = $(this);
|
let $this = $(this);
|
||||||
|
|
||||||
$this.circleProgress({
|
$this.circleProgress({
|
||||||
fill: {
|
fill: {
|
||||||
color: tabler.colors[$this.attr('data-color')] || tabler.colors.blue
|
color: tabler.colors[$this.attr('data-color')] || tabler.colors.blue
|
||||||
|
|||||||
Reference in New Issue
Block a user