初步框架搭建

This commit is contained in:
2024-09-03 20:57:22 +08:00
parent 808b211882
commit d32e0000ba
947 changed files with 159376 additions and 0 deletions
@@ -0,0 +1,171 @@
/*
* Rounded Rectangle Extension for Bar Charts and Horizontal Bar Charts
* Tested with Charts.js 2.7.0
*/
Chart.elements.Rectangle.prototype.draw = function() {
var ctx = this._chart.ctx;
var vm = this._view;
var left, right, top, bottom, signX, signY, borderSkipped, radius;
var borderWidth = vm.borderWidth;
// If radius is less than 0 or is large enough to cause drawing errors a max
// radius is imposed. If cornerRadius is not defined set it to 0.
var cornerRadius = this._chart.config.options.cornerRadius;
if(cornerRadius < 0){ cornerRadius = 0; }
if(typeof cornerRadius == 'undefined'){ cornerRadius = 0; }
if (!vm.horizontal) {
// bar
left = vm.x - vm.width / 2;
right = vm.x + vm.width / 2;
top = vm.y;
bottom = vm.base;
signX = 1;
signY = bottom > top? 1: -1;
borderSkipped = vm.borderSkipped || 'bottom';
} else {
// horizontal bar
left = vm.base;
right = vm.x;
top = vm.y - vm.height / 2;
bottom = vm.y + vm.height / 2;
signX = right > left? 1: -1;
signY = 1;
borderSkipped = vm.borderSkipped || 'left';
}
// Canvas doesn't allow us to stroke inside the width so we can
// adjust the sizes to fit if we're setting a stroke on the line
if (borderWidth) {
// borderWidth shold be less than bar width and bar height.
var barSize = Math.min(Math.abs(left - right), Math.abs(top - bottom));
borderWidth = borderWidth > barSize? barSize: borderWidth;
var halfStroke = borderWidth / 2;
// Adjust borderWidth when bar top position is near vm.base(zero).
var borderLeft = left + (borderSkipped !== 'left'? halfStroke * signX: 0);
var borderRight = right + (borderSkipped !== 'right'? -halfStroke * signX: 0);
var borderTop = top + (borderSkipped !== 'top'? halfStroke * signY: 0);
var borderBottom = bottom + (borderSkipped !== 'bottom'? -halfStroke * signY: 0);
// not become a vertical line?
if (borderLeft !== borderRight) {
top = borderTop;
bottom = borderBottom;
}
// not become a horizontal line?
if (borderTop !== borderBottom) {
left = borderLeft;
right = borderRight;
}
}
ctx.beginPath();
ctx.fillStyle = vm.backgroundColor;
ctx.strokeStyle = vm.borderColor;
ctx.lineWidth = borderWidth;
// Corner points, from bottom-left to bottom-right clockwise
// | 1 2 |
// | 0 3 |
var corners = [
[left, bottom],
[left, top],
[right, top],
[right, bottom]
];
// Find first (starting) corner with fallback to 'bottom'
var borders = ['bottom', 'left', 'top', 'right'];
var startCorner = borders.indexOf(borderSkipped, 0);
if (startCorner === -1) {
startCorner = 0;
}
function cornerAt(index) {
return corners[(startCorner + index) % 4];
}
// Draw rectangle from 'startCorner'
var corner = cornerAt(0);
ctx.moveTo(corner[0], corner[1]);
for (var i = 1; i < 4; i++) {
corner = cornerAt(i);
nextCornerId = i+1;
if(nextCornerId == 4){
nextCornerId = 0
}
nextCorner = cornerAt(nextCornerId);
width = corners[2][0] - corners[1][0];
height = corners[0][1] - corners[1][1];
x = corners[1][0];
y = corners[1][1];
var radius = cornerRadius;
// Fix radius being too large
if(radius > Math.abs(height)/2){
radius = Math.floor(Math.abs(height)/2);
}
if(radius > Math.abs(width)/2){
radius = Math.floor(Math.abs(width)/2);
}
if(height < 0){
// Negative values in a standard bar chart
x_tl = x; x_tr = x+width;
y_tl = y+height; y_tr = y+height;
x_bl = x; x_br = x+width;
y_bl = y; y_br = y;
// Draw
ctx.moveTo(x_bl+radius, y_bl);
ctx.lineTo(x_br-radius, y_br);
ctx.quadraticCurveTo(x_br, y_br, x_br, y_br-radius);
ctx.lineTo(x_tr, y_tr+radius);
ctx.quadraticCurveTo(x_tr, y_tr, x_tr-radius, y_tr);
ctx.lineTo(x_tl+radius, y_tl);
ctx.quadraticCurveTo(x_tl, y_tl, x_tl, y_tl+radius);
ctx.lineTo(x_bl, y_bl-radius);
ctx.quadraticCurveTo(x_bl, y_bl, x_bl+radius, y_bl);
}else if(width < 0){
// Negative values in a horizontal bar chart
x_tl = x+width; x_tr = x;
y_tl= y; y_tr = y;
x_bl = x+width; x_br = x;
y_bl = y+height; y_br = y+height;
// Draw
ctx.moveTo(x_bl+radius, y_bl);
ctx.lineTo(x_br-radius, y_br);
ctx.quadraticCurveTo(x_br, y_br, x_br, y_br-radius);
ctx.lineTo(x_tr, y_tr+radius);
ctx.quadraticCurveTo(x_tr, y_tr, x_tr-radius, y_tr);
ctx.lineTo(x_tl+radius, y_tl);
ctx.quadraticCurveTo(x_tl, y_tl, x_tl, y_tl+radius);
ctx.lineTo(x_bl, y_bl-radius);
ctx.quadraticCurveTo(x_bl, y_bl, x_bl+radius, y_bl);
}else{
//Positive Value
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width - radius, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
ctx.lineTo(x + width, y + height - radius);
ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
ctx.lineTo(x + radius, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
ctx.lineTo(x, y + radius);
ctx.quadraticCurveTo(x, y, x + radius, y);
}
}
ctx.fill();
if (borderWidth) {
ctx.stroke();
}
};
@@ -0,0 +1,363 @@
$(function() {
/* ChartJS
* -------
* Data and config for chartjs
*/
'use strict';
var data = {
labels: ["2013", "2014", "2014", "2015", "2016", "2017"],
datasets: [{
label: '# of Votes',
data: [10, 19, 3, 5, 2, 3],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255,99,132,1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1,
fill: false
}]
};
var multiLineData = {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: 'Dataset 1',
data: [12, 19, 3, 5, 2, 3],
borderColor: [
'#587ce4'
],
borderWidth: 2,
fill: false
},
{
label: 'Dataset 2',
data: [5, 23, 7, 12, 42, 23],
borderColor: [
'#ede190'
],
borderWidth: 2,
fill: false
},
{
label: 'Dataset 3',
data: [15, 10, 21, 32, 12, 33],
borderColor: [
'#f44252'
],
borderWidth: 2,
fill: false
}
]
};
var options = {
scales: {
y: {
ticks: {
beginAtZero: true
}
}
},
legend: {
display: false
},
elements: {
line:{
tension: 0.5
},
point: {
radius: 0
}
}
};
var doughnutPieData = {
datasets: [{
data: [30, 40, 30],
backgroundColor: [
'rgba(255, 99, 132, 0.5)',
'rgba(54, 162, 235, 0.5)',
'rgba(255, 206, 86, 0.5)',
'rgba(75, 192, 192, 0.5)',
'rgba(153, 102, 255, 0.5)',
'rgba(255, 159, 64, 0.5)'
],
borderColor: [
'rgba(255,99,132,1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
}],
// These labels appear in the legend and in the tooltips when hovering different arcs
labels: [
'Pink',
'Blue',
'Yellow',
]
};
var doughnutPieOptions = {
responsive: true,
animation: {
animateScale: true,
animateRotate: true
}
};
var areaData = {
labels: ["2013", "2014", "2015", "2016", "2017"],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255,99,132,1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1,
fill: true, // 3: no fill
}]
};
var areaOptions = {
elements: {
line: {
tension: 0.5
}
},
plugins: {
filler: {
propagate: true
}
}
}
var multiAreaData = {
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
datasets: [{
label: 'Facebook',
data: [8, 11, 13, 15, 12, 13, 16, 15, 13, 19, 11, 14],
borderColor: ['rgba(255, 99, 132, 0.5)'],
backgroundColor: ['rgba(255, 99, 132, 0.5)'],
borderWidth: 1,
fill: true
},
{
label: 'Twitter',
data: [7, 17, 12, 16, 14, 18, 16, 12, 15, 11, 13, 9],
borderColor: ['rgba(54, 162, 235, 0.5)'],
backgroundColor: ['rgba(54, 162, 235, 0.5)'],
borderWidth: 1,
fill: true
},
{
label: 'Linkedin',
data: [6, 14, 16, 20, 12, 18, 15, 12, 17, 19, 15, 11],
borderColor: ['rgba(255, 206, 86, 0.5)'],
backgroundColor: ['rgba(255, 206, 86, 0.5)'],
borderWidth: 1,
fill: true
}
]
};
var multiAreaOptions = {
plugins: {
filler: {
propagate: true
}
},
elements: {
line:{
tension:0.5
},
point: {
radius: 0
}
},
scales: {
x: {
gridLines: {
display: false
}
},
y: {
gridLines: {
display: false
}
}
}
}
var scatterChartData = {
datasets: [{
label: 'First Dataset',
data: [{
x: -10,
y: 0
},
{
x: 0,
y: 3
},
{
x: -25,
y: 5
},
{
x: 40,
y: 5
}
],
backgroundColor: [
'rgba(255, 99, 132, 0.2)'
],
borderColor: [
'rgba(255,99,132,1)'
],
borderWidth: 1
},
{
label: 'Second Dataset',
data: [{
x: 10,
y: 5
},
{
x: 20,
y: -30
},
{
x: -25,
y: 15
},
{
x: -10,
y: 5
}
],
backgroundColor: [
'rgba(54, 162, 235, 0.2)',
],
borderColor: [
'rgba(54, 162, 235, 1)',
],
borderWidth: 1
}
]
}
var scatterChartOptions = {
scales: {
x: {
type: 'linear',
position: 'bottom'
}
}
}
// Get context with jQuery - using jQuery's .get() method.
if ($("#barChart").length) {
var barChartCanvas = $("#barChart").get(0).getContext("2d");
// This will get the first returned node in the jQuery collection.
var barChart = new Chart(barChartCanvas, {
type: 'bar',
data: data,
options: options
});
}
if ($("#lineChart").length) {
var lineChartCanvas = $("#lineChart").get(0).getContext("2d");
var lineChart = new Chart(lineChartCanvas, {
type: 'line',
data: data,
options: options
});
}
if ($("#linechart-multi").length) {
var multiLineCanvas = $("#linechart-multi").get(0).getContext("2d");
var lineChart = new Chart(multiLineCanvas, {
type: 'line',
data: multiLineData,
options: options
});
}
if ($("#areachart-multi").length) {
var multiAreaCanvas = $("#areachart-multi").get(0).getContext("2d");
var multiAreaChart = new Chart(multiAreaCanvas, {
type: 'line',
data: multiAreaData,
options: multiAreaOptions
});
}
if ($("#doughnutChart").length) {
var doughnutChartCanvas = $("#doughnutChart").get(0).getContext("2d");
var doughnutChart = new Chart(doughnutChartCanvas, {
type: 'doughnut',
data: doughnutPieData,
options: doughnutPieOptions
});
}
if ($("#pieChart").length) {
var pieChartCanvas = $("#pieChart").get(0).getContext("2d");
var pieChart = new Chart(pieChartCanvas, {
type: 'pie',
data: doughnutPieData,
options: doughnutPieOptions
});
}
if ($("#areaChart").length) {
var areaChartCanvas = $("#areaChart").get(0).getContext("2d");
var areaChart = new Chart(areaChartCanvas, {
type: 'line',
data: areaData,
options: areaOptions
});
}
if ($("#scatterChart").length) {
var scatterChartCanvas = $("#scatterChart").get(0).getContext("2d");
var scatterChart = new Chart(scatterChartCanvas, {
type: 'scatter',
data: scatterChartData,
options: scatterChartOptions
});
}
if ($("#browserTrafficChart").length) {
var doughnutChartCanvas = $("#browserTrafficChart").get(0).getContext("2d");
var doughnutChart = new Chart(doughnutChartCanvas, {
type: 'doughnut',
data: browserTrafficData,
options: doughnutPieOptions
});
}
});
@@ -0,0 +1,51 @@
(function($) {
'use strict';
if ($('textarea[name=code-editable]').length) {
var editableCodeMirror = CodeMirror.fromTextArea(document.getElementById('code-editable'), {
mode: "javascript",
theme: "ambiance",
lineNumbers: true
});
}
if ($('#code-readonly').length) {
var readOnlyCodeMirror = CodeMirror.fromTextArea(document.getElementById('code-readonly'), {
mode: "javascript",
theme: "ambiance",
lineNumbers: true,
readOnly: "nocursor"
});
}
//Use this method of there are multiple codes with same properties
if ($('.multiple-codes').length) {
var code_type = '';
var editorTextarea = $('.multiple-codes');
for (var i = 0; i < editorTextarea.length; i++) {
$(editorTextarea[i]).attr('id', 'code-' + i);
CodeMirror.fromTextArea(document.getElementById('code-' + i), {
mode: "javascript",
theme: "ambiance",
lineNumbers: true,
readOnly: "nocursor",
maxHighlightLength: 0,
workDelay: 0
});
}
}
//Use this method of there are multiple codes with same properties in shell mode
if ($('.shell-mode').length) {
var code_type = '';
var shellEditor = $('.shell-mode');
for (var i = 0; i < shellEditor.length; i++) {
$(shellEditor[i]).attr('id', 'code-' + i);
CodeMirror.fromTextArea(document.getElementById('code-' + i), {
mode: "shell",
theme: "ambiance",
readOnly: "nocursor",
maxHighlightLength: 0,
workDelay: 0
});
}
}
})(jQuery);
@@ -0,0 +1,536 @@
(function($) {
'use strict';
$(function() {
if ($("#performanceLine").length) {
const ctx = document.getElementById('performanceLine');
var graphGradient = document.getElementById("performanceLine").getContext('2d');
var graphGradient2 = document.getElementById("performanceLine").getContext('2d');
var saleGradientBg = graphGradient.createLinearGradient(5, 0, 5, 100);
saleGradientBg.addColorStop(0, 'rgba(26, 115, 232, 0.18)');
saleGradientBg.addColorStop(1, 'rgba(26, 115, 232, 0.02)');
var saleGradientBg2 = graphGradient2.createLinearGradient(100, 0, 50, 150);
saleGradientBg2.addColorStop(0, 'rgba(0, 208, 255, 0.19)');
saleGradientBg2.addColorStop(1, 'rgba(0, 208, 255, 0.03)');
new Chart(ctx, {
type: 'line',
data: {
labels: ["SUN","sun", "MON", "mon", "TUE","tue", "WED", "wed", "THU", "thu", "FRI", "fri", "SAT"],
datasets: [{
label: 'This week',
data: [50, 110, 60, 290, 200, 115, 130, 170, 90, 210, 240, 280, 200],
backgroundColor: saleGradientBg,
borderColor: [
'#1F3BB3',
],
borderWidth: 1.5,
fill: true, // 3: no fill
pointBorderWidth: 1,
pointRadius: [4, 4, 4, 4, 4,4, 4, 4, 4, 4,4, 4, 4],
pointHoverRadius: [2, 2, 2, 2, 2,2, 2, 2, 2, 2,2, 2, 2],
pointBackgroundColor: ['#1F3BB3)', '#1F3BB3', '#1F3BB3', '#1F3BB3','#1F3BB3)', '#1F3BB3', '#1F3BB3', '#1F3BB3','#1F3BB3)', '#1F3BB3', '#1F3BB3', '#1F3BB3','#1F3BB3)'],
pointBorderColor: ['#fff','#fff','#fff','#fff','#fff','#fff','#fff','#fff','#fff','#fff','#fff','#fff','#fff',],
},{
label: 'Last week',
data: [30, 150, 190, 250, 120, 150, 130, 20, 30, 15, 40, 95, 180],
backgroundColor: saleGradientBg2,
borderColor: [
'#52CDFF',
],
borderWidth: 1.5,
fill: true, // 3: no fill
pointBorderWidth: 1,
pointRadius: [0, 0, 0, 4, 0],
pointHoverRadius: [0, 0, 0, 2, 0],
pointBackgroundColor: ['#52CDFF)', '#52CDFF', '#52CDFF', '#52CDFF','#52CDFF)', '#52CDFF', '#52CDFF', '#52CDFF','#52CDFF)', '#52CDFF', '#52CDFF', '#52CDFF','#52CDFF)'],
pointBorderColor: ['#fff','#fff','#fff','#fff','#fff','#fff','#fff','#fff','#fff','#fff','#fff','#fff','#fff',],
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
elements: {
line: {
tension: 0.4,
}
},
scales: {
y: {
border: {
display: false
},
grid: {
display: true,
color:"#F0F0F0",
drawBorder: false,
},
ticks: {
beginAtZero: false,
autoSkip: true,
maxTicksLimit: 4,
color:"#6B778C",
font: {
size: 10,
}
}
},
x: {
border: {
display: false
},
grid: {
display: false,
drawBorder: false,
},
ticks: {
beginAtZero: false,
autoSkip: true,
maxTicksLimit: 7,
color:"#6B778C",
font: {
size: 10,
}
}
}
},
plugins: {
legend: {
display: false,
}
}
},
plugins: [{
afterDatasetUpdate: function (chart, args, options) {
const chartId = chart.canvas.id;
var i;
const legendId = `${chartId}-legend`;
const ul = document.createElement('ul');
for(i=0;i<chart.data.datasets.length; i++) {
ul.innerHTML += `
<li>
<span style="background-color: ${chart.data.datasets[i].borderColor}"></span>
${chart.data.datasets[i].label}
</li>
`;
}
return document.getElementById(legendId).appendChild(ul);
}
}]
});
}
if ($("#status-summary").length) {
const statusSummaryChartCanvas = document.getElementById('status-summary');
new Chart(statusSummaryChartCanvas, {
type: 'line',
data: {
labels: ["SUN", "MON", "TUE", "WED", "THU", "FRI"],
datasets: [{
label: '# of Votes',
data: [50, 68, 70, 10, 12, 80],
backgroundColor: "#ffcc00",
borderColor: [
'#01B6A0',
],
borderWidth: 2,
fill: false, // 3: no fill
pointBorderWidth: 0,
pointRadius: [0, 0, 0, 0, 0, 0],
pointHoverRadius: [0, 0, 0, 0, 0, 0],
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
elements: {
line: {
tension: 0.4,
}
},
scales: {
y: {
border: {
display: false
},
display: false,
grid: {
display: false,
},
},
x: {
border: {
display: false
},
display: false,
grid: {
display: false,
}
}
},
plugins: {
legend: {
display: false,
}
}
}
});
}
if ($("#marketingOverview").length) {
const marketingOverviewCanvas = document.getElementById('marketingOverview');
new Chart(marketingOverviewCanvas, {
type: 'bar',
data: {
labels: ["JAN","FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"],
datasets: [{
label: 'Last week',
data: [110, 220, 200, 190, 220, 110, 210, 110, 205, 202, 201, 150],
backgroundColor: "#52CDFF",
borderColor: [
'#52CDFF',
],
borderWidth: 0,
barPercentage: 0.35,
fill: true, // 3: no fill
},{
label: 'This week',
data: [215, 290, 210, 250, 290, 230, 290, 210, 280, 220, 190, 300],
backgroundColor: "#1F3BB3",
borderColor: [
'#1F3BB3',
],
borderWidth: 0,
barPercentage: 0.35,
fill: true, // 3: no fill
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
elements: {
line: {
tension: 0.4,
}
},
scales: {
y: {
border: {
display: false
},
grid: {
display: true,
drawTicks: false,
color:"#F0F0F0",
zeroLineColor: '#F0F0F0',
},
ticks: {
beginAtZero: false,
autoSkip: true,
maxTicksLimit: 4,
color:"#6B778C",
font: {
size: 10,
}
}
},
x: {
border: {
display: false
},
stacked: true,
grid: {
display: false,
drawTicks: false,
},
ticks: {
beginAtZero: false,
autoSkip: true,
maxTicksLimit: 7,
color:"#6B778C",
font: {
size: 10,
}
}
}
},
plugins: {
legend: {
display: false,
}
}
},
plugins: [{
afterDatasetUpdate: function (chart, args, options) {
const chartId = chart.canvas.id;
var i;
const legendId = `${chartId}-legend`;
const ul = document.createElement('ul');
for(i=0;i<chart.data.datasets.length; i++) {
ul.innerHTML += `
<li>
<span style="background-color: ${chart.data.datasets[i].borderColor}"></span>
${chart.data.datasets[i].label}
</li>
`;
}
return document.getElementById(legendId).appendChild(ul);
}
}]
});
}
if ($('#totalVisitors').length) {
var bar = new ProgressBar.Circle(totalVisitors, {
color: '#fff',
// This has to be the same size as the maximum width to
// prevent clipping
strokeWidth: 15,
trailWidth: 15,
easing: 'easeInOut',
duration: 1400,
text: {
autoStyleContainer: false
},
from: {
color: '#52CDFF',
width: 15
},
to: {
color: '#677ae4',
width: 15
},
// Set default step function for all animate calls
step: function(state, circle) {
circle.path.setAttribute('stroke', state.color);
circle.path.setAttribute('stroke-width', state.width);
var value = Math.round(circle.value() * 100);
if (value === 0) {
circle.setText('');
} else {
circle.setText(value);
}
}
});
bar.text.style.fontSize = '0rem';
bar.animate(.64); // Number from 0.0 to 1.0
}
if ($('#visitperday').length) {
var bar = new ProgressBar.Circle(visitperday, {
color: '#fff',
// This has to be the same size as the maximum width to
// prevent clipping
strokeWidth: 15,
trailWidth: 15,
easing: 'easeInOut',
duration: 1400,
text: {
autoStyleContainer: false
},
from: {
color: '#34B1AA',
width: 15
},
to: {
color: '#677ae4',
width: 15
},
// Set default step function for all animate calls
step: function(state, circle) {
circle.path.setAttribute('stroke', state.color);
circle.path.setAttribute('stroke-width', state.width);
var value = Math.round(circle.value() * 100);
if (value === 0) {
circle.setText('');
} else {
circle.setText(value);
}
}
});
bar.text.style.fontSize = '0rem';
bar.animate(.34); // Number from 0.0 to 1.0
}
if ($("#doughnutChart").length) {
const doughnutChartCanvas = document.getElementById('doughnutChart');
new Chart(doughnutChartCanvas, {
type: 'doughnut',
data: {
labels: ['Total','Net','Gross','AVG'],
datasets: [{
data: [40, 20, 30, 10],
backgroundColor: [
"#1F3BB3",
"#FDD0C7",
"#52CDFF",
"#81DADA"
],
borderColor: [
"#1F3BB3",
"#FDD0C7",
"#52CDFF",
"#81DADA"
],
}]
},
options: {
cutout: 90,
animationEasing: "easeOutBounce",
animateRotate: true,
animateScale: false,
responsive: true,
maintainAspectRatio: true,
showScale: true,
legend: false,
plugins: {
legend: {
display: false,
}
}
},
plugins: [{
afterDatasetUpdate: function (chart, args, options) {
const chartId = chart.canvas.id;
var i;
const legendId = `${chartId}-legend`;
const ul = document.createElement('ul');
for(i=0;i<chart.data.datasets[0].data.length; i++) {
ul.innerHTML += `
<li>
<span style="background-color: ${chart.data.datasets[0].backgroundColor[i]}"></span>
${chart.data.labels[i]}
</li>
`;
}
return document.getElementById(legendId).appendChild(ul);
}
}]
});
}
if ($("#leaveReport").length) {
const leaveReportCanvas = document.getElementById('leaveReport');
new Chart(leaveReportCanvas, {
type: 'bar',
data: {
labels: ["Jan","Feb", "Mar", "Apr", "May"],
datasets: [{
label: 'Last week',
data: [18, 25, 39, 11, 24],
backgroundColor: "#52CDFF",
borderColor: [
'#52CDFF',
],
borderWidth: 0,
fill: true, // 3: no fill
barPercentage: 0.5,
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
elements: {
line: {
tension: 0.4,
}
},
scales: {
y: {
border: {
display: false
},
display: true,
grid: {
display: false,
drawBorder: false,
color:"rgba(255,255,255,.05)",
zeroLineColor: "rgba(255,255,255,.05)",
},
ticks: {
beginAtZero: true,
autoSkip: true,
maxTicksLimit: 5,
fontSize: 10,
color:"#6B778C",
font: {
size: 10,
}
}
},
x: {
border: {
display: false
},
display: true,
grid: {
display: false,
},
ticks: {
beginAtZero: false,
autoSkip: true,
maxTicksLimit: 7,
fontSize: 10,
color:"#6B778C",
font: {
size: 10,
}
}
}
},
plugins: {
legend: {
display: false,
}
}
}
});
}
if ($.cookie('staradmin2-pro-banner')!="true") {
document.querySelector('#proBanner').classList.add('d-flex');
document.querySelector('.navbar').classList.remove('fixed-top');
}
else {
document.querySelector('#proBanner').classList.add('d-none');
document.querySelector('.navbar').classList.add('fixed-top');
}
if ($( ".navbar" ).hasClass( "fixed-top" )) {
document.querySelector('.page-body-wrapper').classList.remove('pt-0');
document.querySelector('.navbar').classList.remove('pt-5');
}
else {
document.querySelector('.page-body-wrapper').classList.add('pt-0');
document.querySelector('.navbar').classList.add('pt-5');
document.querySelector('.navbar').classList.add('mt-3');
}
document.querySelector('#bannerClose').addEventListener('click',function() {
document.querySelector('#proBanner').classList.add('d-none');
document.querySelector('#proBanner').classList.remove('d-flex');
document.querySelector('.navbar').classList.remove('pt-5');
document.querySelector('.navbar').classList.add('fixed-top');
document.querySelector('.page-body-wrapper').classList.add('proBanner-padding-top');
document.querySelector('.navbar').classList.remove('mt-3');
var date = new Date();
date.setTime(date.getTime() + 24 * 60 * 60 * 1000);
$.cookie('staradmin2-pro-banner', "true", { expires: date });
});
});
// iconify.load('icons.svg').then(function() {
// iconify(document.querySelector('.my-cool.icon'));
// });
})(jQuery);
@@ -0,0 +1,12 @@
(function($) {
'use strict';
$(function() {
$('.file-upload-browse').on('click', function() {
var file = $(this).parent().parent().parent().find('.file-upload-default');
file.trigger('click');
});
$('.file-upload-default').on('change', function() {
$(this).parent().find('.form-control').val($(this).val().replace(/C:\\fakepath\\/i, ''));
});
});
})(jQuery);
@@ -0,0 +1,25 @@
(function($) {
'use strict';
//Open submenu on hover in compact sidebar mode and horizontal menu mode
$(document).on('mouseenter mouseleave', '.sidebar .nav-item', function(ev) {
var body = $('body');
var sidebarIconOnly = body.hasClass("sidebar-icon-only");
var sidebarFixed = body.hasClass("sidebar-fixed");
if (!('ontouchstart' in document.documentElement)) {
if (sidebarIconOnly) {
if (sidebarFixed) {
if (ev.type === 'mouseenter') {
body.removeClass('sidebar-icon-only');
}
} else {
var $menuItem = $(this);
if (ev.type === 'mouseenter') {
$menuItem.addClass('hover-open')
} else {
$menuItem.removeClass('hover-open')
}
}
}
}
});
})(jQuery);
@@ -0,0 +1,9 @@
(function($) {
'use strict';
if ($("#fileuploader").length) {
$("#fileuploader").uploadFile({
url: "YOUR_FILE_UPLOAD_URL",
fileName: "myfile"
});
}
})(jQuery);
@@ -0,0 +1,117 @@
/*!
* jQuery Cookie Plugin v1.4.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// CommonJS
factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
var pluses = /\+/g;
function encode(s) {
return config.raw ? s : encodeURIComponent(s);
}
function decode(s) {
return config.raw ? s : decodeURIComponent(s);
}
function stringifyCookieValue(value) {
return encode(config.json ? JSON.stringify(value) : String(value));
}
function parseCookieValue(s) {
if (s.indexOf('"') === 0) {
// This is a quoted cookie as according to RFC2068, unescape...
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
}
try {
// Replace server-side written pluses with spaces.
// If we can't decode the cookie, ignore it, it's unusable.
// If we can't parse the cookie, ignore it, it's unusable.
s = decodeURIComponent(s.replace(pluses, ' '));
return config.json ? JSON.parse(s) : s;
} catch(e) {}
}
function read(s, converter) {
var value = config.raw ? s : parseCookieValue(s);
return $.isFunction(converter) ? converter(value) : value;
}
var config = $.cookie = function (key, value, options) {
// Write
if (value !== undefined && !$.isFunction(value)) {
options = $.extend({}, config.defaults, options);
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setTime(+t + days * 864e+5);
}
return (document.cookie = [
encode(key), '=', stringifyCookieValue(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// Read
var result = key ? undefined : {};
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling $.cookie().
var cookies = document.cookie ? document.cookie.split('; ') : [];
for (var i = 0, l = cookies.length; i < l; i++) {
var parts = cookies[i].split('=');
var name = decode(parts.shift());
var cookie = parts.join('=');
if (key && key === name) {
// If second argument (value) is a function it's a converter...
result = read(cookie, value);
break;
}
// Prevent storing a cookie that we couldn't decode.
if (!key && (cookie = read(cookie)) !== undefined) {
result[name] = cookie;
}
}
return result;
};
config.defaults = {};
$.removeCookie = function (key, options) {
if ($.cookie(key) === undefined) {
return false;
}
// Must not alter options, thus extending a fresh object...
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
return !$.cookie(key);
};
}));
@@ -0,0 +1,8 @@
(function($) {
'use strict';
$(function() {
$('[data-bs-toggle="offcanvas"]').on("click", function() {
$('.sidebar-offcanvas').toggleClass('active')
});
});
})(jQuery);
@@ -0,0 +1 @@
table.dataTable tbody>tr.selected,table.dataTable tbody>tr>.selected{background-color:#B0BED9}table.dataTable.stripe tbody>tr.odd.selected,table.dataTable.stripe tbody>tr.odd>.selected,table.dataTable.display tbody>tr.odd.selected,table.dataTable.display tbody>tr.odd>.selected{background-color:#acbad4}table.dataTable.hover tbody>tr.selected:hover,table.dataTable.hover tbody>tr>.selected:hover,table.dataTable.display tbody>tr.selected:hover,table.dataTable.display tbody>tr>.selected:hover{background-color:#aab7d1}table.dataTable.order-column tbody>tr.selected>.sorting_1,table.dataTable.order-column tbody>tr.selected>.sorting_2,table.dataTable.order-column tbody>tr.selected>.sorting_3,table.dataTable.order-column tbody>tr>.selected,table.dataTable.display tbody>tr.selected>.sorting_1,table.dataTable.display tbody>tr.selected>.sorting_2,table.dataTable.display tbody>tr.selected>.sorting_3,table.dataTable.display tbody>tr>.selected{background-color:#acbad5}table.dataTable.display tbody>tr.odd.selected>.sorting_1,table.dataTable.order-column.stripe tbody>tr.odd.selected>.sorting_1{background-color:#a6b4cd}table.dataTable.display tbody>tr.odd.selected>.sorting_2,table.dataTable.order-column.stripe tbody>tr.odd.selected>.sorting_2{background-color:#a8b5cf}table.dataTable.display tbody>tr.odd.selected>.sorting_3,table.dataTable.order-column.stripe tbody>tr.odd.selected>.sorting_3{background-color:#a9b7d1}table.dataTable.display tbody>tr.even.selected>.sorting_1,table.dataTable.order-column.stripe tbody>tr.even.selected>.sorting_1{background-color:#acbad5}table.dataTable.display tbody>tr.even.selected>.sorting_2,table.dataTable.order-column.stripe tbody>tr.even.selected>.sorting_2{background-color:#aebcd6}table.dataTable.display tbody>tr.even.selected>.sorting_3,table.dataTable.order-column.stripe tbody>tr.even.selected>.sorting_3{background-color:#afbdd8}table.dataTable.display tbody>tr.odd>.selected,table.dataTable.order-column.stripe tbody>tr.odd>.selected{background-color:#a6b4cd}table.dataTable.display tbody>tr.even>.selected,table.dataTable.order-column.stripe tbody>tr.even>.selected{background-color:#acbad5}table.dataTable.display tbody>tr.selected:hover>.sorting_1,table.dataTable.order-column.hover tbody>tr.selected:hover>.sorting_1{background-color:#a2aec7}table.dataTable.display tbody>tr.selected:hover>.sorting_2,table.dataTable.order-column.hover tbody>tr.selected:hover>.sorting_2{background-color:#a3b0c9}table.dataTable.display tbody>tr.selected:hover>.sorting_3,table.dataTable.order-column.hover tbody>tr.selected:hover>.sorting_3{background-color:#a5b2cb}table.dataTable.display tbody>tr:hover>.selected,table.dataTable.display tbody>tr>.selected:hover,table.dataTable.order-column.hover tbody>tr:hover>.selected,table.dataTable.order-column.hover tbody>tr>.selected:hover{background-color:#a2aec7}table.dataTable tbody td.select-checkbox,table.dataTable tbody th.select-checkbox{position:relative}table.dataTable tbody td.select-checkbox:before,table.dataTable tbody td.select-checkbox:after,table.dataTable tbody th.select-checkbox:before,table.dataTable tbody th.select-checkbox:after{display:block;position:absolute;top:1.2em;left:50%;width:12px;height:12px;box-sizing:border-box}table.dataTable tbody td.select-checkbox:before,table.dataTable tbody th.select-checkbox:before{content:' ';margin-top:-6px;margin-left:-6px;border:1px solid black;border-radius:3px}table.dataTable tr.selected td.select-checkbox:after,table.dataTable tr.selected th.select-checkbox:after{content:'\2714';margin-top:-11px;margin-left:-4px;text-align:center;text-shadow:1px 1px #B0BED9, -1px -1px #B0BED9, 1px -1px #B0BED9, -1px 1px #B0BED9}div.dataTables_wrapper span.select-info,div.dataTables_wrapper span.select-item{margin-left:0.5em}@media screen and (max-width: 640px){div.dataTables_wrapper span.select-info,div.dataTables_wrapper span.select-item{margin-left:0;display:block}}
@@ -0,0 +1,10 @@
(function($) {
'use strict';
if ($(".js-example-basic-single").length) {
$(".js-example-basic-single").select2();
}
if ($(".js-example-basic-multiple").length) {
$(".js-example-basic-multiple").select2();
}
})(jQuery);
@@ -0,0 +1,109 @@
(function($) {
'use strict';
$(function() {
$(".nav-settings").on("click", function() {
$("#right-sidebar").toggleClass("open");
});
$(".settings-close").on("click", function() {
$("#right-sidebar,#theme-settings").removeClass("open");
});
$("#settings-trigger").on("click" , function(){
$("#theme-settings").toggleClass("open");
});
//background constants
var navbar_classes = "navbar-danger navbar-success navbar-warning navbar-dark navbar-light navbar-primary navbar-info navbar-pink";
var sidebar_classes = "sidebar-light sidebar-dark";
var $body = $("body");
//sidebar backgrounds
$("#sidebar-light-theme").on("click" , function(){
$body.removeClass(sidebar_classes);
$body.addClass("sidebar-light");
$(".sidebar-bg-options").removeClass("selected");
$(this).addClass("selected");
});
$("#sidebar-dark-theme").on("click" , function(){
$body.removeClass(sidebar_classes);
$body.addClass("sidebar-dark");
$(".sidebar-bg-options").removeClass("selected");
$(this).addClass("selected");
});
//Navbar Backgrounds
$(".tiles.primary").on("click" , function(){
$(".navbar").removeClass(navbar_classes);
$(".navbar").addClass("navbar-primary");
$(".tiles").removeClass("selected");
$(this).addClass("selected");
});
$(".tiles.success").on("click" , function(){
$(".navbar").removeClass(navbar_classes);
$(".navbar").addClass("navbar-success");
$(".tiles").removeClass("selected");
$(this).addClass("selected");
});
$(".tiles.warning").on("click" , function(){
$(".navbar").removeClass(navbar_classes);
$(".navbar").addClass("navbar-warning");
$(".tiles").removeClass("selected");
$(this).addClass("selected");
});
$(".tiles.danger").on("click" , function(){
$(".navbar").removeClass(navbar_classes);
$(".navbar").addClass("navbar-danger");
$(".tiles").removeClass("selected");
$(this).addClass("selected");
});
$(".tiles.light").on("click" , function(){
$(".navbar").removeClass(navbar_classes);
$(".navbar").addClass("navbar-light");
$(".tiles").removeClass("selected");
$(this).addClass("selected");
});
$(".tiles.info").on("click" , function(){
$(".navbar").removeClass(navbar_classes);
$(".navbar").addClass("navbar-info");
$(".tiles").removeClass("selected");
$(this).addClass("selected");
});
$(".tiles.dark").on("click" , function(){
$(".navbar").removeClass(navbar_classes);
$(".navbar").addClass("navbar-dark");
$(".tiles").removeClass("selected");
$(this).addClass("selected");
});
$(".tiles.default").on("click" , function(){
$(".navbar").removeClass(navbar_classes);
$(".tiles").removeClass("selected");
$(this).addClass("selected");
});
$(".tiles.default").on("click" , function(){
$(".navbar").removeClass(navbar_classes);
$(".tiles").removeClass("selected");
$(this).addClass("selected");
});
$(".color-theme.default").click(function(){
$(".color-theme.default").attr({
"href" : "https://www.bootstrapdash.com/demo/star-admin2-pro/template/demo/vertical-default-light/index.html",
"title" : "Light"
});
});
$(".color-theme.dark").click(function(){
$(".color-theme.dark").attr({
"href" : "https://www.bootstrapdash.com/demo/star-admin2-pro/template/demo/vertical-default-dark/index.html",
"title" : "Dark"
});
});
$(".color-theme.brown").click(function(){
$(".color-theme.brown").attr({
"href" : "https://www.bootstrapdash.com/demo/star-admin2-pro/template/demo/vertical-default-brown/index.html",
"title" : "Brown"
});
});
});
})(jQuery);
@@ -0,0 +1,145 @@
(function ($) {
'use strict';
$(function () {
var body = $('body');
var contentWrapper = $('.content-wrapper');
var scroller = $('.container-scroller');
var footer = $('.footer');
var sidebar = $('.sidebar');
//Add active class to nav-link based on url dynamically
//Active class can be hard coded directly in html file also as required
function addActiveClass(element) {
if (current === "") {
//for root url
if (element.attr('href').indexOf("index.html") !== -1) {
element.parents('.nav-item').last().addClass('active');
if (element.parents('.sub-menu').length) {
element.closest('.collapse').addClass('show');
element.addClass('active');
}
}
} else {
//for other url
if (element.attr('href').indexOf(current) !== -1) {
element.parents('.nav-item').last().addClass('active');
if (element.parents('.sub-menu').length) {
element.closest('.collapse').addClass('show');
element.addClass('active');
}
if (element.parents('.submenu-item').length) {
element.addClass('active');
}
}
}
}
var current = location.pathname.split("/").slice(-1)[0].replace(/^\/|\/$/g, '');
$('.nav li a', sidebar).each(function () {
var $this = $(this);
addActiveClass($this);
})
$('.horizontal-menu .nav li a').each(function () {
var $this = $(this);
addActiveClass($this);
})
//Close other submenu in sidebar on opening any
sidebar.on('show.bs.collapse', '.collapse', function () {
sidebar.find('.collapse.show').collapse('hide');
});
//Change sidebar and content-wrapper height
applyStyles();
function applyStyles() {
//Applying perfect scrollbar
if (!body.hasClass("rtl")) {
if ($('.settings-panel .tab-content .tab-pane.scroll-wrapper').length) {
const settingsPanelScroll = new PerfectScrollbar('.settings-panel .tab-content .tab-pane.scroll-wrapper');
}
if ($('.chats').length) {
const chatsScroll = new PerfectScrollbar('.chats');
}
if (body.hasClass("sidebar-fixed")) {
if ($('#sidebar').length) {
var fixedSidebarScroll = new PerfectScrollbar('#sidebar .nav');
}
}
}
}
$('[data-bs-toggle="minimize"]').on("click", function () {
if ((body.hasClass('sidebar-toggle-display')) || (body.hasClass('sidebar-absolute'))) {
body.toggleClass('sidebar-hidden');
} else {
body.toggleClass('sidebar-icon-only');
}
});
//checkbox and radios
$(".form-check label,.form-radio label").append('<i class="input-helper"></i>');
//Horizontal menu in mobile
$('[data-toggle="horizontal-menu-toggle"]').on("click", function () {
$(".horizontal-menu .bottom-navbar").toggleClass("header-toggled");
});
// Horizontal menu navigation in mobile menu on click
var navItemClicked = $('.horizontal-menu .page-navigation >.nav-item');
navItemClicked.on("click", function (event) {
if (window.matchMedia('(max-width: 991px)').matches) {
if (!($(this).hasClass('show-submenu'))) {
navItemClicked.removeClass('show-submenu');
}
$(this).toggleClass('show-submenu');
}
})
$(window).scroll(function () {
if (window.matchMedia('(min-width: 992px)').matches) {
var header = $('.horizontal-menu');
if ($(window).scrollTop() >= 70) {
$(header).addClass('fixed-on-scroll');
} else {
$(header).removeClass('fixed-on-scroll');
}
}
});
if ($("#datepicker-popup").length) {
$('#datepicker-popup').datepicker({
enableOnReadonly: true,
todayHighlight: true,
});
$("#datepicker-popup").datepicker("setDate", "0");
}
});
//check all boxes in order status
$("#check-all").click(function () {
$(".form-check-input").prop('checked', $(this).prop('checked'));
});
// focus input when clicking on search icon
$('#navbar-search-icon').click(function () {
$("#navbar-search-input").focus();
});
$(window).scroll(function () {
var scroll = $(window).scrollTop();
//>=, not <=
if (scroll >= 97) {
//clearHeader, not clearheader - caps H
$(".fixed-top").addClass("headerLight");
}
else {
$(".fixed-top").removeClass("headerLight");
}
}); //missing );
})(jQuery);
@@ -0,0 +1,34 @@
(function($) {
'use strict';
$(function() {
var todoListItem = $('.todo-list');
var todoListInput = $('.todo-list-input');
$('.todo-list-add-btn').on("click", function(event) {
event.preventDefault();
var item = $(this).prevAll('.todo-list-input').val();
if (item) {
todoListItem.append("<li><div class='form-check'><label class='form-check-label'><input class='checkbox' type='checkbox'/>" + item + "<i class='input-helper'></i></label></div><i class='remove ti-close'></i></li>");
todoListInput.val("");
}
});
todoListItem.on('change', '.checkbox', function() {
if ($(this).attr('checked')) {
$(this).removeAttr('checked');
} else {
$(this).attr('checked', 'checked');
}
$(this).closest("li").toggleClass('completed');
});
todoListItem.on('click', '.remove', function() {
$(this).parent().remove();
});
});
})(jQuery);
@@ -0,0 +1,60 @@
(function($) {
'use strict';
var substringMatcher = function(strs) {
return function findMatches(q, cb) {
var matches, substringRegex;
// an array that will be populated with substring matches
matches = [];
// regex used to determine if a string contains the substring `q`
var substrRegex = new RegExp(q, 'i');
// iterate through the pool of strings and for any string that
// contains the substring `q`, add it to the `matches` array
for (var i = 0; i < strs.length; i++) {
if (substrRegex.test(strs[i])) {
matches.push(strs[i]);
}
}
cb(matches);
};
};
var states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California',
'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii',
'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana',
'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota',
'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire',
'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota',
'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island',
'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont',
'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'
];
$('#the-basics .typeahead').typeahead({
hint: true,
highlight: true,
minLength: 1
}, {
name: 'states',
source: substringMatcher(states)
});
// constructs the suggestion engine
var states = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
// `states` is an array of state names defined in "The Basics"
local: states
});
$('#bloodhound .typeahead').typeahead({
hint: true,
highlight: true,
minLength: 1
}, {
name: 'states',
source: states
});
})(jQuery);