dashboard.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * Author: Abdullah A Almsaeed
  3. * Date: 4 Jan 2014
  4. * Description:
  5. * This is a demo file used only for the main dashboard (index.html)
  6. **/
  7. $(function () {
  8. 'use strict';
  9. // Make the dashboard widgets sortable Using jquery UI
  10. $('.connectedSortable').sortable({
  11. placeholder : 'sort-highlight',
  12. connectWith : '.connectedSortable',
  13. handle : '.box-header, .nav-tabs',
  14. forcePlaceholderSize: true,
  15. zIndex : 999999
  16. });
  17. $('.connectedSortable .box-header, .connectedSortable .nav-tabs-custom').css('cursor', 'move');
  18. // jQuery UI sortable for the todo list
  19. $('.todo-list').sortable({
  20. placeholder : 'sort-highlight',
  21. handle : '.handle',
  22. forcePlaceholderSize: true,
  23. zIndex : 999999
  24. });
  25. // bootstrap WYSIHTML5 - text editor
  26. $('.textarea').wysihtml5();
  27. $('.daterange').daterangepicker({
  28. ranges : {
  29. 'Today' : [moment(), moment()],
  30. 'Yesterday' : [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
  31. 'Last 7 Days' : [moment().subtract(6, 'days'), moment()],
  32. 'Last 30 Days': [moment().subtract(29, 'days'), moment()],
  33. 'This Month' : [moment().startOf('month'), moment().endOf('month')],
  34. 'Last Month' : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
  35. },
  36. startDate: moment().subtract(29, 'days'),
  37. endDate : moment()
  38. }, function (start, end) {
  39. window.alert('You chose: ' + start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
  40. });
  41. /* jQueryKnob */
  42. $('.knob').knob();
  43. // jvectormap data
  44. var visitorsData = {
  45. US: 398, // USA
  46. SA: 400, // Saudi Arabia
  47. CA: 1000, // Canada
  48. DE: 500, // Germany
  49. FR: 760, // France
  50. CN: 300, // China
  51. AU: 700, // Australia
  52. BR: 600, // Brazil
  53. IN: 800, // India
  54. GB: 320, // Great Britain
  55. RU: 3000 // Russia
  56. };
  57. // World map by jvectormap
  58. $('#world-map').vectorMap({
  59. map : 'world_mill_en',
  60. backgroundColor : 'transparent',
  61. regionStyle : {
  62. initial: {
  63. fill : '#e4e4e4',
  64. 'fill-opacity' : 1,
  65. stroke : 'none',
  66. 'stroke-width' : 0,
  67. 'stroke-opacity': 1
  68. }
  69. },
  70. series : {
  71. regions: [
  72. {
  73. values : visitorsData,
  74. scale : ['#92c1dc', '#ebf4f9'],
  75. normalizeFunction: 'polynomial'
  76. }
  77. ]
  78. },
  79. onRegionLabelShow: function (e, el, code) {
  80. if (typeof visitorsData[code] != 'undefined')
  81. el.html(el.html() + ': ' + visitorsData[code] + ' new visitors');
  82. }
  83. });
  84. // Sparkline charts
  85. var myvalues = [1000, 1200, 920, 927, 931, 1027, 819, 930, 1021];
  86. $('#sparkline-1').sparkline(myvalues, {
  87. type : 'line',
  88. lineColor: '#92c1dc',
  89. fillColor: '#ebf4f9',
  90. height : '50',
  91. width : '80'
  92. });
  93. myvalues = [515, 519, 520, 522, 652, 810, 370, 627, 319, 630, 921];
  94. $('#sparkline-2').sparkline(myvalues, {
  95. type : 'line',
  96. lineColor: '#92c1dc',
  97. fillColor: '#ebf4f9',
  98. height : '50',
  99. width : '80'
  100. });
  101. myvalues = [15, 19, 20, 22, 33, 27, 31, 27, 19, 30, 21];
  102. $('#sparkline-3').sparkline(myvalues, {
  103. type : 'line',
  104. lineColor: '#92c1dc',
  105. fillColor: '#ebf4f9',
  106. height : '50',
  107. width : '80'
  108. });
  109. // The Calender
  110. $('#calendar').datepicker();
  111. // SLIMSCROLL FOR CHAT WIDGET
  112. $('#chat-box').slimScroll({
  113. height: '250px'
  114. });
  115. /* Morris.js Charts */
  116. // Sales chart
  117. var area = new Morris.Area({
  118. element : 'revenue-chart',
  119. resize : true,
  120. data : [
  121. { y: '2011 Q1', item1: 2666, item2: 2666 },
  122. { y: '2011 Q2', item1: 2778, item2: 2294 },
  123. { y: '2011 Q3', item1: 4912, item2: 1969 },
  124. { y: '2011 Q4', item1: 3767, item2: 3597 },
  125. { y: '2012 Q1', item1: 6810, item2: 1914 },
  126. { y: '2012 Q2', item1: 5670, item2: 4293 },
  127. { y: '2012 Q3', item1: 4820, item2: 3795 },
  128. { y: '2012 Q4', item1: 15073, item2: 5967 },
  129. { y: '2013 Q1', item1: 10687, item2: 4460 },
  130. { y: '2013 Q2', item1: 8432, item2: 5713 }
  131. ],
  132. xkey : 'y',
  133. ykeys : ['item1', 'item2'],
  134. labels : ['Item 1', 'Item 2'],
  135. lineColors: ['#a0d0e0', '#3c8dbc'],
  136. hideHover : 'auto'
  137. });
  138. var line = new Morris.Line({
  139. element : 'line-chart',
  140. resize : true,
  141. data : [
  142. { y: '2011 Q1', item1: 2666 },
  143. { y: '2011 Q2', item1: 2778 },
  144. { y: '2011 Q3', item1: 4912 },
  145. { y: '2011 Q4', item1: 3767 },
  146. { y: '2012 Q1', item1: 6810 },
  147. { y: '2012 Q2', item1: 5670 },
  148. { y: '2012 Q3', item1: 4820 },
  149. { y: '2012 Q4', item1: 15073 },
  150. { y: '2013 Q1', item1: 10687 },
  151. { y: '2013 Q2', item1: 8432 }
  152. ],
  153. xkey : 'y',
  154. ykeys : ['item1'],
  155. labels : ['Item 1'],
  156. lineColors : ['#efefef'],
  157. lineWidth : 2,
  158. hideHover : 'auto',
  159. gridTextColor : '#fff',
  160. gridStrokeWidth : 0.4,
  161. pointSize : 4,
  162. pointStrokeColors: ['#efefef'],
  163. gridLineColor : '#efefef',
  164. gridTextFamily : 'Open Sans',
  165. gridTextSize : 10
  166. });
  167. // Donut Chart
  168. var donut = new Morris.Donut({
  169. element : 'sales-chart',
  170. resize : true,
  171. colors : ['#3c8dbc', '#f56954', '#00a65a'],
  172. data : [
  173. { label: 'Download Sales', value: 12 },
  174. { label: 'In-Store Sales', value: 30 },
  175. { label: 'Mail-Order Sales', value: 20 }
  176. ],
  177. hideHover: 'auto'
  178. });
  179. // Fix for charts under tabs
  180. $('.box ul.nav a').on('shown.bs.tab', function () {
  181. area.redraw();
  182. donut.redraw();
  183. line.redraw();
  184. });
  185. /* The todo list plugin */
  186. $('.todo-list').todoList({
  187. onCheck : function () {
  188. window.console.log($(this), 'The element has been checked');
  189. },
  190. onUnCheck: function () {
  191. window.console.log($(this), 'The element has been unchecked');
  192. }
  193. });
  194. });