dashboard.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. //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. {
  29. ranges: {
  30. 'Today': [moment(), moment()],
  31. 'Yesterday': [moment().subtract('days', 1), moment().subtract('days', 1)],
  32. 'Last 7 Days': [moment().subtract('days', 6), moment()],
  33. 'Last 30 Days': [moment().subtract('days', 29), moment()],
  34. 'This Month': [moment().startOf('month'), moment().endOf('month')],
  35. 'Last Month': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
  36. },
  37. startDate: moment().subtract('days', 29),
  38. endDate: moment()
  39. },
  40. function (start, end) {
  41. alert("You chose: " + start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
  42. });
  43. /* jQueryKnob */
  44. $(".knob").knob();
  45. //jvectormap data
  46. var visitorsData = {
  47. "US": 398, //USA
  48. "SA": 400, //Saudi Arabia
  49. "CA": 1000, //Canada
  50. "DE": 500, //Germany
  51. "FR": 760, //France
  52. "CN": 300, //China
  53. "AU": 700, //Australia
  54. "BR": 600, //Brazil
  55. "IN": 800, //India
  56. "GB": 320, //Great Britain
  57. "RU": 3000 //Russia
  58. };
  59. //World map by jvectormap
  60. $('#world-map').vectorMap({
  61. map: 'world_mill_en',
  62. backgroundColor: "transparent",
  63. regionStyle: {
  64. initial: {
  65. fill: '#e4e4e4',
  66. "fill-opacity": 1,
  67. stroke: 'none',
  68. "stroke-width": 0,
  69. "stroke-opacity": 1
  70. }
  71. },
  72. series: {
  73. regions: [{
  74. values: visitorsData,
  75. scale: ["#92c1dc", "#ebf4f9"],
  76. normalizeFunction: 'polynomial'
  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 (e) {
  181. area.redraw();
  182. donut.redraw();
  183. });
  184. /* BOX REFRESH PLUGIN EXAMPLE (usage with morris charts) */
  185. $("#loading-example").boxRefresh({
  186. source: "ajax/dashboard-boxrefresh-demo.php",
  187. onLoadDone: function (box) {
  188. bar = new Morris.Bar({
  189. element: 'bar-chart',
  190. resize: true,
  191. data: [
  192. {y: '2006', a: 100, b: 90},
  193. {y: '2007', a: 75, b: 65},
  194. {y: '2008', a: 50, b: 40},
  195. {y: '2009', a: 75, b: 65},
  196. {y: '2010', a: 50, b: 40},
  197. {y: '2011', a: 75, b: 65},
  198. {y: '2012', a: 100, b: 90}
  199. ],
  200. barColors: ['#00a65a', '#f56954'],
  201. xkey: 'y',
  202. ykeys: ['a', 'b'],
  203. labels: ['CPU', 'DISK'],
  204. hideHover: 'auto'
  205. });
  206. }
  207. });
  208. /* The todo list plugin */
  209. $(".todo-list").todolist({
  210. onCheck: function (ele) {
  211. console.log("The element has been checked")
  212. },
  213. onUncheck: function (ele) {
  214. console.log("The element has been unchecked")
  215. }
  216. });
  217. });