AdminLTE/dist/js/pages/dashboard.js

198 lines
5.7 KiB
JavaScript
Raw Normal View History

2015-02-01 21:25:09 +00:00
/*
* Author: Abdullah A Almsaeed
* Date: 4 Jan 2014
* Description:
* This is a demo file used only for the main dashboard (index.html)
**/
$(function () {
2018-03-17 17:07:55 +00:00
'use strict'
2015-07-25 19:06:16 +00:00
2018-02-03 23:45:19 +00:00
// Make the dashboard widgets sortable Using jquery UI
2018-03-17 17:07:55 +00:00
$('.connectedSortable').sortable({
placeholder : 'sort-highlight',
connectWith : '.connectedSortable',
handle : '.card-header, .nav-tabs',
2015-02-01 21:25:09 +00:00
forcePlaceholderSize: true,
2018-03-17 17:07:55 +00:00
zIndex : 999999
})
$('.connectedSortable .card-header, .connectedSortable .nav-tabs-custom').css('cursor', 'move')
2015-07-12 13:42:55 +00:00
2018-02-03 23:45:19 +00:00
// jQuery UI sortable for the todo list
2018-03-17 17:07:55 +00:00
$('.todo-list').sortable({
placeholder : 'sort-highlight',
handle : '.handle',
2015-02-01 21:25:09 +00:00
forcePlaceholderSize: true,
2018-03-17 17:07:55 +00:00
zIndex : 999999
})
2015-02-01 21:25:09 +00:00
2018-02-03 23:45:19 +00:00
// bootstrap WYSIHTML5 - text editor
2018-03-17 17:07:55 +00:00
$('.textarea').wysihtml5()
2015-02-01 21:25:09 +00:00
2015-07-25 19:06:16 +00:00
$('.daterange').daterangepicker({
2018-03-17 17:07:55 +00:00
ranges : {
'Today' : [moment(), moment()],
'Yesterday' : [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days' : [moment().subtract(6, 'days'), moment()],
2015-07-25 19:06:16 +00:00
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
2018-03-17 17:07:55 +00:00
'This Month' : [moment().startOf('month'), moment().endOf('month')],
'Last Month' : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
2015-07-25 19:06:16 +00:00
},
startDate: moment().subtract(29, 'days'),
2018-03-17 17:07:55 +00:00
endDate : moment()
2015-07-25 19:06:16 +00:00
}, function (start, end) {
2018-03-17 17:07:55 +00:00
window.alert('You chose: ' + start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'))
})
2015-02-01 21:25:09 +00:00
/* jQueryKnob */
2018-03-17 17:07:55 +00:00
$('.knob').knob()
2015-02-01 21:25:09 +00:00
2018-02-03 23:45:19 +00:00
// jvectormap data
2015-02-01 21:25:09 +00:00
var visitorsData = {
2018-03-17 17:07:55 +00:00
'US': 398, //USA
'SA': 400, //Saudi Arabia
'CA': 1000, //Canada
'DE': 500, //Germany
'FR': 760, //France
'CN': 300, //China
'AU': 700, //Australia
'BR': 600, //Brazil
'IN': 800, //India
'GB': 320, //Great Britain
'RU': 3000 //Russia
}
2018-02-03 23:45:19 +00:00
// World map by jvectormap
2015-02-01 21:25:09 +00:00
$('#world-map').vectorMap({
2018-03-17 17:07:55 +00:00
map : 'world_mill_en',
backgroundColor : 'transparent',
regionStyle : {
2015-02-01 21:25:09 +00:00
initial: {
2018-03-17 17:07:55 +00:00
fill : 'rgba(255, 255, 255, 0.7)',
'fill-opacity' : 1,
stroke : 'rgba(0,0,0,.2)',
'stroke-width' : 1,
'stroke-opacity': 1
2015-02-01 21:25:09 +00:00
}
},
2018-03-17 17:07:55 +00:00
series : {
2015-02-01 21:25:09 +00:00
regions: [{
2018-03-17 17:07:55 +00:00
values : visitorsData,
scale : ['#ffffff', '#0154ad'],
2015-09-19 18:05:54 +00:00
normalizeFunction: 'polynomial'
}]
2015-02-01 21:25:09 +00:00
},
onRegionLabelShow: function (e, el, code) {
2018-03-17 17:07:55 +00:00
if (typeof visitorsData[code] != 'undefined')
el.html(el.html() + ': ' + visitorsData[code] + ' new visitors')
2015-02-01 21:25:09 +00:00
}
2018-03-17 17:07:55 +00:00
})
2015-02-01 21:25:09 +00:00
2018-02-03 23:45:19 +00:00
// Sparkline charts
2018-03-17 17:07:55 +00:00
var myvalues = [1000, 1200, 920, 927, 931, 1027, 819, 930, 1021]
2015-02-01 21:25:09 +00:00
$('#sparkline-1').sparkline(myvalues, {
2018-03-17 17:07:55 +00:00
type : 'line',
2015-02-01 21:25:09 +00:00
lineColor: '#92c1dc',
2018-03-17 17:07:55 +00:00
fillColor: '#ebf4f9',
height : '50',
width : '80'
})
myvalues = [515, 519, 520, 522, 652, 810, 370, 627, 319, 630, 921]
2015-02-01 21:25:09 +00:00
$('#sparkline-2').sparkline(myvalues, {
2018-03-17 17:07:55 +00:00
type : 'line',
2015-02-01 21:25:09 +00:00
lineColor: '#92c1dc',
2018-03-17 17:07:55 +00:00
fillColor: '#ebf4f9',
height : '50',
width : '80'
})
myvalues = [15, 19, 20, 22, 33, 27, 31, 27, 19, 30, 21]
2015-02-01 21:25:09 +00:00
$('#sparkline-3').sparkline(myvalues, {
2018-03-17 17:07:55 +00:00
type : 'line',
2015-02-01 21:25:09 +00:00
lineColor: '#92c1dc',
2018-03-17 17:07:55 +00:00
fillColor: '#ebf4f9',
height : '50',
width : '80'
})
2015-02-01 21:25:09 +00:00
2018-02-03 23:45:19 +00:00
// The Calender
2018-03-17 17:07:55 +00:00
$('#calendar').datepicker()
2015-02-01 21:25:09 +00:00
2018-02-03 23:45:19 +00:00
// SLIMSCROLL FOR CHAT WIDGET
$('#chat-box').overlayScrollbars({
2015-02-01 21:25:09 +00:00
height: '250px'
2018-03-17 17:07:55 +00:00
})
2015-02-01 21:25:09 +00:00
/* Morris.js Charts */
// Sales chart
var area = new Morris.Area({
2018-03-17 17:07:55 +00:00
element : 'revenue-chart',
resize : true,
data : [
{ y: '2011 Q1', item1: 2666, item2: 2666 },
{ y: '2011 Q2', item1: 2778, item2: 2294 },
{ y: '2011 Q3', item1: 4912, item2: 1969 },
{ y: '2011 Q4', item1: 3767, item2: 3597 },
{ y: '2012 Q1', item1: 6810, item2: 1914 },
{ y: '2012 Q2', item1: 5670, item2: 4293 },
{ y: '2012 Q3', item1: 4820, item2: 3795 },
{ y: '2012 Q4', item1: 15073, item2: 5967 },
{ y: '2013 Q1', item1: 10687, item2: 4460 },
{ y: '2013 Q2', item1: 8432, item2: 5713 }
2015-02-01 21:25:09 +00:00
],
2018-03-17 17:07:55 +00:00
xkey : 'y',
ykeys : ['item1', 'item2'],
labels : ['Item 1', 'Item 2'],
lineColors: ['#495057', '#007cff'],
hideHover : 'auto'
})
2015-02-01 21:25:09 +00:00
var line = new Morris.Line({
2018-03-17 17:07:55 +00:00
element : 'line-chart',
resize : true,
data : [
{ y: '2011 Q1', item1: 2666 },
{ y: '2011 Q2', item1: 2778 },
{ y: '2011 Q3', item1: 4912 },
{ y: '2011 Q4', item1: 3767 },
{ y: '2012 Q1', item1: 6810 },
{ y: '2012 Q2', item1: 5670 },
{ y: '2012 Q3', item1: 4820 },
{ y: '2012 Q4', item1: 15073 },
{ y: '2013 Q1', item1: 10687 },
{ y: '2013 Q2', item1: 8432 }
2015-02-01 21:25:09 +00:00
],
2018-03-17 17:07:55 +00:00
xkey : 'y',
ykeys : ['item1'],
labels : ['Item 1'],
lineColors : ['#efefef'],
lineWidth : 2,
hideHover : 'auto',
gridTextColor : '#fff',
gridStrokeWidth : 0.4,
pointSize : 4,
pointStrokeColors: ['#efefef'],
gridLineColor : '#efefef',
gridTextFamily : 'Open Sans',
gridTextSize : 10
})
2015-02-01 21:25:09 +00:00
2018-02-03 23:45:19 +00:00
// Donut Chart
2015-02-01 21:25:09 +00:00
var donut = new Morris.Donut({
2018-03-17 17:07:55 +00:00
element : 'sales-chart',
resize : true,
colors : ['#007bff', '#dc3545', '#28a745'],
data : [
{ label: 'Download Sales', value: 12 },
{ label: 'In-Store Sales', value: 30 },
{ label: 'Mail-Order Sales', value: 20 }
2015-02-01 21:25:09 +00:00
],
hideHover: 'auto'
2018-03-17 17:07:55 +00:00
})
2015-02-01 21:25:09 +00:00
2018-02-03 23:45:19 +00:00
// Fix for charts under tabs
2015-07-25 19:06:16 +00:00
$('.box ul.nav a').on('shown.bs.tab', function () {
2018-03-17 17:07:55 +00:00
area.redraw()
donut.redraw()
line.redraw()
})
})