| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388 |
- /**
- * Advanced Cards
- */
-
- 'use strict';
-
- document.addEventListener('DOMContentLoaded', function (e) {
- let cardColor, headingColor, legendColor, labelColor, fontFamily, currentTheme;
- cardColor = config.colors.cardColor;
- labelColor = config.colors.textMuted;
- legendColor = config.colors.bodyColor;
- headingColor = config.colors.headingColor;
- fontFamily = config.fontFamily;
-
- if (isDarkStyle) {
- currentTheme = 'dark';
- } else {
- currentTheme = 'light';
- }
-
- // Radial bar chart functions
- function radialBarChart(color, value, show) {
- const radialBarChartOpt = {
- chart: {
- height: show == 'true' ? 60 : 55,
- width: show == 'true' ? 58 : 45,
- type: 'radialBar'
- },
- plotOptions: {
- radialBar: {
- hollow: {
- size: show == 'true' ? '50%' : '25%'
- },
- dataLabels: {
- show: show == 'true' ? true : false,
- value: {
- offsetY: -10,
- fontSize: '15px',
- fontWeight: 500,
- fontFamily: fontFamily,
- color: headingColor
- }
- },
- track: {
- background: config.colors_label.secondary
- }
- }
- },
- stroke: {
- lineCap: 'round'
- },
- colors: [color],
- grid: {
- padding: {
- top: show == 'true' ? -12 : -15,
- bottom: show == 'true' ? -17 : -15,
- left: show == 'true' ? -17 : -5,
- right: -15
- }
- },
- series: [value],
- labels: show == 'true' ? [''] : ['Progress']
- };
- return radialBarChartOpt;
- }
-
- // Progress Chart
- // --------------------------------------------------------------------
- // All progress chart
- const chartProgressList = document.querySelectorAll('.chart-progress');
- if (chartProgressList) {
- chartProgressList.forEach(function (chartProgressEl) {
- const color = config.colors[chartProgressEl.dataset.color],
- series = chartProgressEl.dataset.series;
- const progress_variant = chartProgressEl.dataset.progress_variant
- ? chartProgressEl.dataset.progress_variant
- : 'false';
- const optionsBundle = radialBarChart(color, series, progress_variant);
- const chart = new ApexCharts(chartProgressEl, optionsBundle);
- chart.render();
- });
- }
-
- // Order Statistics Chart
- // --------------------------------------------------------------------
- const chartOrderStatistics = document.querySelector('#orderStatisticsChart'),
- orderChartConfig = {
- chart: {
- height: 165,
- width: 136,
- type: 'donut',
- offsetX: 15
- },
- labels: ['Electronic', 'Sports', 'Decor', 'Fashion'],
- series: [50, 85, 25, 40],
- colors: [config.colors.success, config.colors.primary, config.colors.secondary, config.colors.info],
- stroke: {
- width: 5,
- colors: [cardColor]
- },
- dataLabels: {
- enabled: false,
- formatter: function (val, opt) {
- return parseInt(val) + '%';
- }
- },
- legend: {
- show: false
- },
- grid: {
- padding: {
- top: 0,
- bottom: 0,
- right: 15
- }
- },
- tooltip: {
- theme: currentTheme
- },
- plotOptions: {
- pie: {
- donut: {
- size: '75%',
- labels: {
- show: true,
- value: {
- fontSize: '1.125rem',
- fontFamily: fontFamily,
- fontWeight: 500,
- color: headingColor,
- offsetY: -17,
- formatter: function (val) {
- return parseInt(val) + '%';
- }
- },
- name: {
- offsetY: 17,
- fontFamily: fontFamily
- },
- total: {
- show: true,
- fontSize: '13px',
- color: legendColor,
- label: 'Weekly',
- formatter: function (w) {
- return '38%';
- }
- }
- }
- }
- }
- },
- states: {
- active: {
- filter: {
- type: 'none'
- }
- }
- }
- };
- if (typeof chartOrderStatistics !== undefined && chartOrderStatistics !== null) {
- const statisticsChart = new ApexCharts(chartOrderStatistics, orderChartConfig);
- statisticsChart.render();
- }
-
- // Earning Reports Bar Chart
- // --------------------------------------------------------------------
- const reportBarChartEl = document.querySelector('#reportBarChart'),
- reportBarChartConfig = {
- chart: {
- height: 200,
- type: 'bar',
- toolbar: {
- show: false
- }
- },
- plotOptions: {
- bar: {
- barHeight: '60%',
- columnWidth: '60%',
- startingShape: 'rounded',
- endingShape: 'rounded',
- borderRadius: 4,
- distributed: true
- }
- },
- grid: {
- show: false,
- padding: {
- top: -20,
- bottom: 0,
- left: -10,
- right: -10
- }
- },
- colors: [
- config.colors_label.primary,
- config.colors_label.primary,
- config.colors_label.primary,
- config.colors_label.primary,
- config.colors.primary,
- config.colors_label.primary,
- config.colors_label.primary
- ],
- dataLabels: {
- enabled: false
- },
- series: [
- {
- data: [40, 95, 60, 45, 90, 50, 75]
- }
- ],
- legend: {
- show: false
- },
- xaxis: {
- categories: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
- axisBorder: {
- show: false
- },
- axisTicks: {
- show: false
- },
- labels: {
- style: {
- colors: labelColor,
- fontSize: '13px'
- }
- }
- },
- yaxis: {
- labels: {
- show: false
- }
- },
- states: {
- hover: {
- filter: {
- type: 'none'
- }
- },
- active: {
- filter: {
- type: 'none'
- }
- }
- }
- };
- if (typeof reportBarChartEl !== undefined && reportBarChartEl !== null) {
- const barChart = new ApexCharts(reportBarChartEl, reportBarChartConfig);
- barChart.render();
- }
-
- // Conversion rate Line Chart
- // --------------------------------------------------------------------
- const conversionLineChartEl = document.querySelector('#conversionRateChart'),
- conversionLineChartConfig = {
- chart: {
- height: 80,
- width: 140,
- type: 'line',
- toolbar: {
- show: false
- },
- dropShadow: {
- enabled: true,
- top: 10,
- left: 5,
- blur: 3,
- color: config.colors.primary,
- opacity: 0.15
- },
- sparkline: {
- enabled: true
- },
- offsetX: -5
- },
- markers: {
- size: 6,
- colors: 'transparent',
- strokeColors: 'transparent',
- strokeWidth: 4,
- discrete: [
- {
- fillColor: cardColor,
- seriesIndex: 0,
- dataPointIndex: 3,
- strokeColor: config.colors.primary,
- strokeWidth: 4,
- size: 5,
- radius: 2
- }
- ],
- hover: {
- size: 7
- }
- },
- grid: {
- show: false,
- padding: {
- right: 8
- }
- },
- colors: [config.colors.primary],
- dataLabels: {
- enabled: false
- },
- stroke: {
- width: 5,
- curve: 'smooth'
- },
- series: [
- {
- data: [137, 210, 160, 245]
- }
- ],
- xaxis: {
- show: false,
- lines: {
- show: false
- },
- labels: {
- show: false
- },
- axisBorder: {
- show: false
- }
- },
- yaxis: {
- show: false
- }
- };
- const conversionLineChart = new ApexCharts(conversionLineChartEl, conversionLineChartConfig);
- conversionLineChart.render();
-
- // Credit Card Validation
- // --------------------------------------------------------------------
-
- const creditCardPayment = document.querySelector('.credit-card-payment'),
- expiryDatePayment = document.querySelector('.expiry-date-payment'),
- cvvMaskList = document.querySelectorAll('.cvv-code-payment');
-
- // Credit Card Cleave Masking
- if (creditCardPayment) {
- creditCardPayment.addEventListener('input', event => {
- creditCardPayment.value = formatCreditCard(event.target.value);
- const cleanValue = event.target.value.replace(/\D/g, '');
- let type = getCreditCardType(cleanValue);
- if (type && type !== 'unknown' && type !== 'general') {
- document.querySelector('.card-payment-type').innerHTML =
- '<img src="' + assetsPath + 'img/icons/payments/' + type + '-cc.png" class="cc-icon-image" height="28"/>';
- } else {
- document.querySelector('.card-payment-type').innerHTML = '';
- }
- });
- registerCursorTracker({
- input: creditCardPayment,
- delimiter: ' '
- });
- }
-
- // Expiry Date Mask
- if (expiryDatePayment) {
- expiryDatePayment.addEventListener('input', event => {
- expiryDatePayment.value = formatDate(event.target.value, {
- delimiter: '/',
- datePattern: ['m', 'y']
- });
- });
- registerCursorTracker({
- input: expiryDatePayment,
- delimiter: '/'
- });
- }
-
- // All CVV field
- if (cvvMaskList) {
- cvvMaskList.forEach(function (cvvMaskEl) {
- cvvMaskEl.addEventListener('input', event => {
- const cleanValue = event.target.value.replace(/\D/g, '');
- cvvMaskEl.value = formatNumeral(cleanValue, {
- numeral: true,
- numeralPositiveOnly: true
- });
- });
- });
- }
- });
|