AdminLTE/dist/js/pages/dashboard.js

211 lines
5.9 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 () {
2017-02-13 00:15:52 +00:00
'use strict';
2015-07-25 19:06:16 +00:00
2017-02-13 00:15:52 +00:00
// Make the dashboard widgets sortable Using jquery UI
$('.connectedSortable').sortable({
placeholder : 'sort-highlight',
connectWith : '.connectedSortable',
handle : '.box-header, .nav-tabs',
2015-02-01 21:25:09 +00:00
forcePlaceholderSize: true,
2017-02-13 00:15:52 +00:00
zIndex : 999999
});
2017-02-13 00:15:52 +00:00
$('.connectedSortable .box-header, .connectedSortable .nav-tabs-custom').css('cursor', 'move');
2015-07-12 13:42:55 +00:00
2017-02-13 00:15:52 +00:00
// jQuery UI sortable for the todo list
$('.todo-list').sortable({
placeholder : 'sort-highlight',
handle : '.handle',
2015-02-01 21:25:09 +00:00
forcePlaceholderSize: true,
2017-02-13 00:15:52 +00:00
zIndex : 999999
});
2015-02-01 21:25:09 +00:00
2017-02-13 00:15:52 +00:00
// bootstrap WYSIHTML5 - text editor
$('.textarea').wysihtml5();
2015-07-25 19:06:16 +00:00
$('.daterange').daterangepicker({
2017-02-13 00:15:52 +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()],
2017-02-13 00:15:52 +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'),
2017-02-13 00:15:52 +00:00
endDate : moment()
2015-07-25 19:06:16 +00:00
}, function (start, end) {
2017-02-13 00:15:52 +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 */
2017-02-13 00:15:52 +00:00
$('.knob').knob();
2015-02-01 21:25:09 +00:00
2017-02-13 00:15:52 +00:00
// jvectormap data
2015-02-01 21:25:09 +00:00
var visitorsData = {
2017-02-13 00:15:52 +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
2015-02-01 21:25:09 +00:00
};
2017-02-13 00:15:52 +00:00
// World map by jvectormap
2015-02-01 21:25:09 +00:00
$('#world-map').vectorMap({
2017-02-13 00:15:52 +00:00
map : 'world_mill_en',
backgroundColor : 'transparent',
regionStyle : {
2015-02-01 21:25:09 +00:00
initial: {
2017-02-13 00:15:52 +00:00
fill : '#e4e4e4',
'fill-opacity' : 1,
stroke : 'none',
'stroke-width' : 0,
'stroke-opacity': 1
2015-02-01 21:25:09 +00:00
}
},
2017-02-13 00:15:52 +00:00
series : {
regions: [
{
values : visitorsData,
scale : ['#92c1dc', '#ebf4f9'],
normalizeFunction: 'polynomial'
}
]
2015-02-01 21:25:09 +00:00
},
onRegionLabelShow: function (e, el, code) {
2017-02-13 00:15:52 +00:00
if (typeof visitorsData[code] != 'undefined')
2015-02-01 21:25:09 +00:00
el.html(el.html() + ': ' + visitorsData[code] + ' new visitors');
}
});
2017-02-13 00:15:52 +00:00
// Sparkline charts
2015-02-01 21:25:09 +00:00
var myvalues = [1000, 1200, 920, 927, 931, 1027, 819, 930, 1021];
$('#sparkline-1').sparkline(myvalues, {
2017-02-13 00:15:52 +00:00
type : 'line',
2015-02-01 21:25:09 +00:00
lineColor: '#92c1dc',
2017-02-13 00:15:52 +00:00
fillColor: '#ebf4f9',
height : '50',
width : '80'
2015-02-01 21:25:09 +00:00
});
myvalues = [515, 519, 520, 522, 652, 810, 370, 627, 319, 630, 921];
$('#sparkline-2').sparkline(myvalues, {
2017-02-13 00:15:52 +00:00
type : 'line',
2015-02-01 21:25:09 +00:00
lineColor: '#92c1dc',
2017-02-13 00:15:52 +00:00
fillColor: '#ebf4f9',
height : '50',
width : '80'
2015-02-01 21:25:09 +00:00
});
myvalues = [15, 19, 20, 22, 33, 27, 31, 27, 19, 30, 21];
$('#sparkline-3').sparkline(myvalues, {
2017-02-13 00:15:52 +00:00
type : 'line',
2015-02-01 21:25:09 +00:00
lineColor: '#92c1dc',
2017-02-13 00:15:52 +00:00
fillColor: '#ebf4f9',
height : '50',
width : '80'
2015-02-01 21:25:09 +00:00
});
2017-02-13 00:15:52 +00:00
// The Calender
$('#calendar').datepicker();
2015-02-01 21:25:09 +00:00
2017-02-13 00:15:52 +00:00
// SLIMSCROLL FOR CHAT WIDGET
2015-02-01 21:25:09 +00:00
$('#chat-box').slimScroll({
height: '250px'
});
/* Morris.js Charts */
// Sales chart
var area = new Morris.Area({
2017-02-13 00:15:52 +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
],
2017-02-13 00:15:52 +00:00
xkey : 'y',
ykeys : ['item1', 'item2'],
labels : ['Item 1', 'Item 2'],
2015-02-01 21:25:09 +00:00
lineColors: ['#a0d0e0', '#3c8dbc'],
2017-02-13 00:15:52 +00:00
hideHover : 'auto'
2015-02-01 21:25:09 +00:00
});
var line = new Morris.Line({
2017-02-13 00:15:52 +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
],
2017-02-13 00:15:52 +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
});
2017-02-13 00:15:52 +00:00
// Donut Chart
2015-02-01 21:25:09 +00:00
var donut = new Morris.Donut({
2017-02-13 00:15:52 +00:00
element : 'sales-chart',
resize : true,
colors : ['#3c8dbc', '#f56954', '#00a65a'],
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'
});
2017-02-13 00:15:52 +00:00
// Fix for charts under tabs
2015-07-25 19:06:16 +00:00
$('.box ul.nav a').on('shown.bs.tab', function () {
2015-02-01 21:25:09 +00:00
area.redraw();
donut.redraw();
2015-07-25 19:06:16 +00:00
line.redraw();
2015-02-01 21:25:09 +00:00
});
/* The todo list plugin */
2017-02-25 19:54:11 +00:00
$('.todo-list').todoList({
onCheck : function () {
window.console.log($(this), 'The element has been checked');
2015-02-01 21:25:09 +00:00
},
2017-02-25 19:54:11 +00:00
onUnCheck: function () {
window.console.log($(this), 'The element has been unchecked');
2015-02-01 21:25:09 +00:00
}
});
2015-07-12 13:42:55 +00:00
});