dashboard.js 6.4 KB

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