jquery.core.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /**
  2. * Theme: Adminto Admin Template
  3. * Author: Coderthemes
  4. * Module/App: Core js
  5. */
  6. //portlets
  7. !function($) {
  8. "use strict";
  9. /**
  10. Portlet Widget
  11. */
  12. var Portlet = function() {
  13. this.$body = $("body"),
  14. this.$portletIdentifier = ".portlet",
  15. this.$portletCloser = '.portlet a[data-toggle="remove"]',
  16. this.$portletRefresher = '.portlet a[data-toggle="reload"]'
  17. };
  18. //on init
  19. Portlet.prototype.init = function() {
  20. // Panel closest
  21. var $this = this;
  22. $(document).on("click",this.$portletCloser, function (ev) {
  23. ev.preventDefault();
  24. var $portlet = $(this).closest($this.$portletIdentifier);
  25. var $portlet_parent = $portlet.parent();
  26. $portlet.slideUp("slow", function() {
  27. $(this).remove();
  28. });
  29. if ($portlet_parent.children().length == 0) {
  30. $portlet_parent.slideUp("slow", function() {
  31. $(this).remove();
  32. });
  33. }
  34. });
  35. // Panel Reload
  36. $(document).on("click",this.$portletRefresher, function (ev) {
  37. ev.preventDefault();
  38. var $portlet = $(this).closest($this.$portletIdentifier);
  39. // This is just a simulation, nothing is going to be reloaded
  40. $portlet.append('<div class="panel-disabled"><div class="loader-1"></div></div>');
  41. var $pd = $portlet.find('.panel-disabled');
  42. setTimeout(function () {
  43. $pd.fadeOut('fast', function () {
  44. $pd.remove();
  45. });
  46. }, 500 + 300 * (Math.random() * 5));
  47. });
  48. },
  49. //
  50. $.Portlet = new Portlet, $.Portlet.Constructor = Portlet
  51. }(window.jQuery),
  52. /**
  53. * Components
  54. */
  55. function($) {
  56. "use strict";
  57. var Components = function() {};
  58. //initializing tooltip
  59. Components.prototype.initTooltipPlugin = function() {
  60. $.fn.tooltip && $('[data-toggle="tooltip"]').tooltip()
  61. },
  62. //initializing popover
  63. Components.prototype.initPopoverPlugin = function() {
  64. $.fn.popover && $('[data-toggle="popover"]').popover()
  65. },
  66. //initializing custom modal
  67. Components.prototype.initCustomModalPlugin = function() {
  68. $('[data-plugin="custommodal"]').on('click', function(e) {
  69. Custombox.open({
  70. target: $(this).attr("href"),
  71. effect: $(this).attr("data-animation"),
  72. overlaySpeed: $(this).attr("data-overlaySpeed"),
  73. overlayColor: $(this).attr("data-overlayColor")
  74. });
  75. e.preventDefault();
  76. });
  77. },
  78. //initializing nicescroll
  79. Components.prototype.initNiceScrollPlugin = function() {
  80. //You can change the color of scroll bar here
  81. $.fn.niceScroll && $(".nicescroll").niceScroll({ cursorcolor: '#98a6ad',cursorwidth:'6px', cursorborderradius: '5px'});
  82. },
  83. //range slider
  84. Components.prototype.initRangeSlider = function() {
  85. $.fn.slider && $('[data-plugin="range-slider"]').slider({});
  86. },
  87. /* -------------
  88. * Form related controls
  89. */
  90. //switch
  91. Components.prototype.initSwitchery = function() {
  92. $('[data-plugin="switchery"]').each(function (idx, obj) {
  93. new Switchery($(this)[0], $(this).data());
  94. });
  95. },
  96. //multiselect
  97. Components.prototype.initMultiSelect = function() {
  98. if($('[data-plugin="multiselect"]').length > 0)
  99. $('[data-plugin="multiselect"]').multiSelect($(this).data());
  100. },
  101. /* -------------
  102. * small charts related widgets
  103. */
  104. //peity charts
  105. Components.prototype.initPeityCharts = function() {
  106. $('[data-plugin="peity-pie"]').each(function(idx, obj) {
  107. var colors = $(this).attr('data-colors')?$(this).attr('data-colors').split(","):[];
  108. var width = $(this).attr('data-width')?$(this).attr('data-width'):20; //default is 20
  109. var height = $(this).attr('data-height')?$(this).attr('data-height'):20; //default is 20
  110. $(this).peity("pie", {
  111. fill: colors,
  112. width: width,
  113. height: height
  114. });
  115. });
  116. //donut
  117. $('[data-plugin="peity-donut"]').each(function(idx, obj) {
  118. var colors = $(this).attr('data-colors')?$(this).attr('data-colors').split(","):[];
  119. var width = $(this).attr('data-width')?$(this).attr('data-width'):20; //default is 20
  120. var height = $(this).attr('data-height')?$(this).attr('data-height'):20; //default is 20
  121. $(this).peity("donut", {
  122. fill: colors,
  123. width: width,
  124. height: height
  125. });
  126. });
  127. $('[data-plugin="peity-donut-alt"]').each(function(idx, obj) {
  128. $(this).peity("donut");
  129. });
  130. // line
  131. $('[data-plugin="peity-line"]').each(function(idx, obj) {
  132. $(this).peity("line", $(this).data());
  133. });
  134. // bar
  135. $('[data-plugin="peity-bar"]').each(function(idx, obj) {
  136. var colors = $(this).attr('data-colors')?$(this).attr('data-colors').split(","):[];
  137. var width = $(this).attr('data-width')?$(this).attr('data-width'):20; //default is 20
  138. var height = $(this).attr('data-height')?$(this).attr('data-height'):20; //default is 20
  139. $(this).peity("bar", {
  140. fill: colors,
  141. width: width,
  142. height: height
  143. });
  144. });
  145. },
  146. Components.prototype.initKnob = function() {
  147. $('[data-plugin="knob"]').each(function(idx, obj) {
  148. $(this).knob();
  149. });
  150. },
  151. Components.prototype.initCircliful = function() {
  152. $('[data-plugin="circliful"]').each(function(idx, obj) {
  153. $(this).circliful();
  154. });
  155. },
  156. Components.prototype.initCounterUp = function() {
  157. var delay = $(this).attr('data-delay')?$(this).attr('data-delay'):100; //default is 100
  158. var time = $(this).attr('data-time')?$(this).attr('data-time'):1200; //default is 1200
  159. $('[data-plugin="counterup"]').each(function(idx, obj) {
  160. $(this).counterUp({
  161. delay: 100,
  162. time: 1200
  163. });
  164. });
  165. },
  166. //initilizing
  167. Components.prototype.init = function() {
  168. var $this = this;
  169. this.initTooltipPlugin(),
  170. this.initPopoverPlugin(),
  171. this.initNiceScrollPlugin(),
  172. this.initCustomModalPlugin(),
  173. this.initRangeSlider(),
  174. this.initSwitchery(),
  175. this.initMultiSelect(),
  176. this.initPeityCharts(),
  177. this.initKnob(),
  178. this.initCircliful(),
  179. this.initCounterUp(),
  180. //creating portles
  181. $.Portlet.init();
  182. },
  183. $.Components = new Components, $.Components.Constructor = Components
  184. }(window.jQuery),
  185. //initializing main application module
  186. function($) {
  187. "use strict";
  188. $.Components.init();
  189. }(window.jQuery);