dashboard.js 5.5 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. values: visitorsData,
  73. scale: ["#92c1dc", "#ebf4f9"],
  74. normalizeFunction: 'polynomial'
  75. }]
  76. },
  77. onRegionLabelShow: function (e, el, code) {
  78. if (typeof visitorsData[code] != "undefined")
  79. el.html(el.html() + ': ' + visitorsData[code] + ' new visitors');
  80. }
  81. });
  82. //Sparkline charts
  83. var myvalues = [1000, 1200, 920, 927, 931, 1027, 819, 930, 1021];
  84. $('#sparkline-1').sparkline(myvalues, {
  85. type: 'line',
  86. lineColor: '#92c1dc',
  87. fillColor: "#ebf4f9",
  88. height: '50',
  89. width: '80'
  90. });
  91. myvalues = [515, 519, 520, 522, 652, 810, 370, 627, 319, 630, 921];
  92. $('#sparkline-2').sparkline(myvalues, {
  93. type: 'line',
  94. lineColor: '#92c1dc',
  95. fillColor: "#ebf4f9",
  96. height: '50',
  97. width: '80'
  98. });
  99. myvalues = [15, 19, 20, 22, 33, 27, 31, 27, 19, 30, 21];
  100. $('#sparkline-3').sparkline(myvalues, {
  101. type: 'line',
  102. lineColor: '#92c1dc',
  103. fillColor: "#ebf4f9",
  104. height: '50',
  105. width: '80'
  106. });
  107. //The Calender
  108. $("#calendar").datepicker();
  109. //SLIMSCROLL FOR CHAT WIDGET
  110. $('#chat-box').slimScroll({
  111. height: '250px'
  112. });
  113. /* Morris.js Charts */
  114. // Sales chart
  115. var area = new Morris.Area({
  116. element: 'revenue-chart',
  117. resize: true,
  118. data: [
  119. {y: '2011 Q1', item1: 2666, item2: 2666},
  120. {y: '2011 Q2', item1: 2778, item2: 2294},
  121. {y: '2011 Q3', item1: 4912, item2: 1969},
  122. {y: '2011 Q4', item1: 3767, item2: 3597},
  123. {y: '2012 Q1', item1: 6810, item2: 1914},
  124. {y: '2012 Q2', item1: 5670, item2: 4293},
  125. {y: '2012 Q3', item1: 4820, item2: 3795},
  126. {y: '2012 Q4', item1: 15073, item2: 5967},
  127. {y: '2013 Q1', item1: 10687, item2: 4460},
  128. {y: '2013 Q2', item1: 8432, item2: 5713}
  129. ],
  130. xkey: 'y',
  131. ykeys: ['item1', 'item2'],
  132. labels: ['Item 1', 'Item 2'],
  133. lineColors: ['#a0d0e0', '#3c8dbc'],
  134. hideHover: 'auto'
  135. });
  136. var line = new Morris.Line({
  137. element: 'line-chart',
  138. resize: true,
  139. data: [
  140. {y: '2011 Q1', item1: 2666},
  141. {y: '2011 Q2', item1: 2778},
  142. {y: '2011 Q3', item1: 4912},
  143. {y: '2011 Q4', item1: 3767},
  144. {y: '2012 Q1', item1: 6810},
  145. {y: '2012 Q2', item1: 5670},
  146. {y: '2012 Q3', item1: 4820},
  147. {y: '2012 Q4', item1: 15073},
  148. {y: '2013 Q1', item1: 10687},
  149. {y: '2013 Q2', item1: 8432}
  150. ],
  151. xkey: 'y',
  152. ykeys: ['item1'],
  153. labels: ['Item 1'],
  154. lineColors: ['#efefef'],
  155. lineWidth: 2,
  156. hideHover: 'auto',
  157. gridTextColor: "#fff",
  158. gridStrokeWidth: 0.4,
  159. pointSize: 4,
  160. pointStrokeColors: ["#efefef"],
  161. gridLineColor: "#efefef",
  162. gridTextFamily: "Open Sans",
  163. gridTextSize: 10
  164. });
  165. //Donut Chart
  166. var donut = new Morris.Donut({
  167. element: 'sales-chart',
  168. resize: true,
  169. colors: ["#3c8dbc", "#f56954", "#00a65a"],
  170. data: [
  171. {label: "Download Sales", value: 12},
  172. {label: "In-Store Sales", value: 30},
  173. {label: "Mail-Order Sales", value: 20}
  174. ],
  175. hideHover: 'auto'
  176. });
  177. //Fix for charts under tabs
  178. $('.box ul.nav a').on('shown.bs.tab', function () {
  179. area.redraw();
  180. donut.redraw();
  181. line.redraw();
  182. });
  183. /* The todo list plugin */
  184. $(".todo-list").todolist({
  185. onCheck: function (ele) {
  186. window.console.log("The element has been checked");
  187. return ele;
  188. },
  189. onUncheck: function (ele) {
  190. window.console.log("The element has been unchecked");
  191. return ele;
  192. }
  193. });
  194. });