custom.js 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. /** ****** left menu *********************** **/
  7. $(function () {
  8. $('#sidebar-menu li ul').slideUp();
  9. $('#sidebar-menu li').removeClass('active');
  10. $('#sidebar-menu li').click(function () {
  11. if ($(this).is('.active')) {
  12. $(this).removeClass('active');
  13. $('ul', this).slideUp();
  14. $(this).removeClass('nv');
  15. $(this).addClass('vn');
  16. } else {
  17. $('#sidebar-menu li ul').slideUp();
  18. $(this).removeClass('vn');
  19. $(this).addClass('nv');
  20. $('ul', this).slideDown();
  21. $('#sidebar-menu li').removeClass('active');
  22. $(this).addClass('active');
  23. }
  24. });
  25. $('#menu_toggle').click(function () {
  26. if ($('body').hasClass('nav-md')) {
  27. $('body').removeClass('nav-md');
  28. $('body').addClass('nav-sm');
  29. $('.left_col').removeClass('scroll-view');
  30. $('.left_col').removeAttr('style');
  31. $('.sidebar-footer').hide();
  32. if ($('#sidebar-menu li').hasClass('active')) {
  33. $('#sidebar-menu li.active').addClass('active-sm');
  34. $('#sidebar-menu li.active').removeClass('active');
  35. }
  36. } else {
  37. $('body').removeClass('nav-sm');
  38. $('body').addClass('nav-md');
  39. $('.sidebar-footer').show();
  40. if ($('#sidebar-menu li').hasClass('active-sm')) {
  41. $('#sidebar-menu li.active-sm').addClass('active');
  42. $('#sidebar-menu li.active-sm').removeClass('active-sm');
  43. }
  44. }
  45. });
  46. });
  47. /* Sidebar Menu active class */
  48. $(function () {
  49. var url = window.location;
  50. $('#sidebar-menu a[href="' + url + '"]').parent('li').addClass('current-page');
  51. $('#sidebar-menu a').filter(function () {
  52. return this.href == url;
  53. }).parent('li').addClass('current-page').parent('ul').slideDown().parent().addClass('active');
  54. });
  55. /** ****** /left menu *********************** **/
  56. /** ****** tooltip *********************** **/
  57. $(function () {
  58. $('[data-toggle="tooltip"]').tooltip()
  59. })
  60. /** ****** /tooltip *********************** **/
  61. /** ****** progressbar *********************** **/
  62. if ($(".progress .progress-bar")[0]) {
  63. $('.progress .progress-bar').progressbar(); // bootstrap 3
  64. }
  65. /** ****** /progressbar *********************** **/
  66. /** ****** switchery *********************** **/
  67. if ($(".js-switch")[0]) {
  68. var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));
  69. elems.forEach(function (html) {
  70. var switchery = new Switchery(html, {
  71. color: '#26B99A'
  72. });
  73. });
  74. }
  75. /** ****** /switcher *********************** **/
  76. /** ****** collapse panel *********************** **/
  77. // Close ibox function
  78. $('.close-link').click(function () {
  79. var content = $(this).closest('div.x_panel');
  80. content.remove();
  81. });
  82. // Collapse ibox function
  83. $('.collapse-link').click(function () {
  84. var x_panel = $(this).closest('div.x_panel');
  85. var button = $(this).find('i');
  86. var content = x_panel.find('div.x_content');
  87. content.slideToggle(200);
  88. (x_panel.hasClass('fixed_height_390') ? x_panel.toggleClass('').toggleClass('fixed_height_390') : '');
  89. (x_panel.hasClass('fixed_height_320') ? x_panel.toggleClass('').toggleClass('fixed_height_320') : '');
  90. button.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down');
  91. setTimeout(function () {
  92. x_panel.resize();
  93. }, 50);
  94. });
  95. /** ****** /collapse panel *********************** **/
  96. /** ****** iswitch *********************** **/
  97. if ($("input.flat")[0]) {
  98. $(document).ready(function () {
  99. $('input.flat').iCheck({
  100. checkboxClass: 'icheckbox_flat-green',
  101. radioClass: 'iradio_flat-green'
  102. });
  103. });
  104. }
  105. /** ****** /iswitch *********************** **/
  106. /** ****** star rating *********************** **/
  107. // Starrr plugin (https://github.com/dobtco/starrr)
  108. var __slice = [].slice;
  109. (function ($, window) {
  110. var Starrr;
  111. Starrr = (function () {
  112. Starrr.prototype.defaults = {
  113. rating: void 0,
  114. numStars: 5,
  115. change: function (e, value) {}
  116. };
  117. function Starrr($el, options) {
  118. var i, _, _ref,
  119. _this = this;
  120. this.options = $.extend({}, this.defaults, options);
  121. this.$el = $el;
  122. _ref = this.defaults;
  123. for (i in _ref) {
  124. _ = _ref[i];
  125. if (this.$el.data(i) != null) {
  126. this.options[i] = this.$el.data(i);
  127. }
  128. }
  129. this.createStars();
  130. this.syncRating();
  131. this.$el.on('mouseover.starrr', 'span', function (e) {
  132. return _this.syncRating(_this.$el.find('span').index(e.currentTarget) + 1);
  133. });
  134. this.$el.on('mouseout.starrr', function () {
  135. return _this.syncRating();
  136. });
  137. this.$el.on('click.starrr', 'span', function (e) {
  138. return _this.setRating(_this.$el.find('span').index(e.currentTarget) + 1);
  139. });
  140. this.$el.on('starrr:change', this.options.change);
  141. }
  142. Starrr.prototype.createStars = function () {
  143. var _i, _ref, _results;
  144. _results = [];
  145. for (_i = 1, _ref = this.options.numStars; 1 <= _ref ? _i <= _ref : _i >= _ref; 1 <= _ref ? _i++ : _i--) {
  146. _results.push(this.$el.append("<span class='glyphicon .glyphicon-star-empty'></span>"));
  147. }
  148. return _results;
  149. };
  150. Starrr.prototype.setRating = function (rating) {
  151. if (this.options.rating === rating) {
  152. rating = void 0;
  153. }
  154. this.options.rating = rating;
  155. this.syncRating();
  156. return this.$el.trigger('starrr:change', rating);
  157. };
  158. Starrr.prototype.syncRating = function (rating) {
  159. var i, _i, _j, _ref;
  160. rating || (rating = this.options.rating);
  161. if (rating) {
  162. for (i = _i = 0, _ref = rating - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
  163. this.$el.find('span').eq(i).removeClass('glyphicon-star-empty').addClass('glyphicon-star');
  164. }
  165. }
  166. if (rating && rating < 5) {
  167. for (i = _j = rating; rating <= 4 ? _j <= 4 : _j >= 4; i = rating <= 4 ? ++_j : --_j) {
  168. this.$el.find('span').eq(i).removeClass('glyphicon-star').addClass('glyphicon-star-empty');
  169. }
  170. }
  171. if (!rating) {
  172. return this.$el.find('span').removeClass('glyphicon-star').addClass('glyphicon-star-empty');
  173. }
  174. };
  175. return Starrr;
  176. })();
  177. return $.fn.extend({
  178. starrr: function () {
  179. var args, option;
  180. option = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
  181. return this.each(function () {
  182. var data;
  183. data = $(this).data('star-rating');
  184. if (!data) {
  185. $(this).data('star-rating', (data = new Starrr($(this), option)));
  186. }
  187. if (typeof option === 'string') {
  188. return data[option].apply(data, args);
  189. }
  190. });
  191. }
  192. });
  193. })(window.jQuery, window);
  194. $(function () {
  195. return $(".starrr").starrr();
  196. });
  197. $(document).ready(function () {
  198. $('#stars').on('starrr:change', function (e, value) {
  199. $('#count').html(value);
  200. });
  201. $('#stars-existing').on('starrr:change', function (e, value) {
  202. $('#count-existing').html(value);
  203. });
  204. });
  205. /** ****** /star rating *********************** **/
  206. /** ****** table *********************** **/
  207. $('table input').on('ifChecked', function () {
  208. check_state = '';
  209. $(this).parent().parent().parent().addClass('selected');
  210. countChecked();
  211. });
  212. $('table input').on('ifUnchecked', function () {
  213. check_state = '';
  214. $(this).parent().parent().parent().removeClass('selected');
  215. countChecked();
  216. });
  217. var check_state = '';
  218. $('.bulk_action input').on('ifChecked', function () {
  219. check_state = '';
  220. $(this).parent().parent().parent().addClass('selected');
  221. countChecked();
  222. });
  223. $('.bulk_action input').on('ifUnchecked', function () {
  224. check_state = '';
  225. $(this).parent().parent().parent().removeClass('selected');
  226. countChecked();
  227. });
  228. $('.bulk_action input#check-all').on('ifChecked', function () {
  229. check_state = 'check_all';
  230. countChecked();
  231. });
  232. $('.bulk_action input#check-all').on('ifUnchecked', function () {
  233. check_state = 'uncheck_all';
  234. countChecked();
  235. });
  236. function countChecked() {
  237. if (check_state == 'check_all') {
  238. $(".bulk_action input[name='table_records']").iCheck('check');
  239. }
  240. if (check_state == 'uncheck_all') {
  241. $(".bulk_action input[name='table_records']").iCheck('uncheck');
  242. }
  243. var n = $(".bulk_action input[name='table_records']:checked").length;
  244. if (n > 0) {
  245. $('.column-title').hide();
  246. $('.bulk-actions').show();
  247. $('.action-cnt').html(n + ' Records Selected');
  248. } else {
  249. $('.column-title').show();
  250. $('.bulk-actions').hide();
  251. }
  252. }
  253. /** ****** /table *********************** **/
  254. /** ****** *********************** **/
  255. /** ****** *********************** **/
  256. /** ****** *********************** **/
  257. /** ****** *********************** **/
  258. /** ****** *********************** **/
  259. /** ****** *********************** **/
  260. /** ****** Accordion *********************** **/
  261. $(function () {
  262. $(".expand").on("click", function () {
  263. $(this).next().slideToggle(200);
  264. $expand = $(this).find(">:first-child");
  265. if ($expand.text() == "+") {
  266. $expand.text("-");
  267. } else {
  268. $expand.text("+");
  269. }
  270. });
  271. });
  272. /** ****** Accordion *********************** **/
  273. /** ****** scrollview *********************** **/
  274. $(document).ready(function () {
  275. $(".scroll-view").niceScroll({
  276. touchbehavior: true,
  277. cursorcolor: "rgba(42, 63, 84, 0.35)"
  278. });
  279. });
  280. /** ****** /scrollview *********************** **/