dashboard.js 6.0 KB

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