block-ui.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. /*=========================================================================================
  2. File Name: block-ui.js
  3. Description: Block UI jQuery Plugin Intialization
  4. --------------------------------------------------------------------------------------
  5. Item Name: Robust - Responsive Admin Theme
  6. Version: 1.2
  7. Author: PIXINVENT
  8. Author URL: http://www.themeforest.net/user/pixinvent
  9. ==========================================================================================*/
  10. $(document).ready(function(){
  11. /************************************
  12. * Block Examples *
  13. ************************************/
  14. $('.block-element').on('click', function() {
  15. var block_ele = $(this).closest('.card');
  16. $(block_ele).block({
  17. message: '<div class="icon-spinner9 icon-spin icon-lg"></div>',
  18. timeout: 2000, //unblock after 2 seconds
  19. overlayCSS: {
  20. backgroundColor: '#fff',
  21. opacity: 0.8,
  22. cursor: 'wait'
  23. },
  24. css: {
  25. border: 0,
  26. padding: 0,
  27. backgroundColor: 'transparent'
  28. }
  29. });
  30. });
  31. // Block sidebar
  32. $('.block-sidebar').on('click', function() {
  33. var block_ele = $('.main-menu');
  34. $(block_ele).block({
  35. message: '<div class="icon-spinner9 icon-spin icon-lg"></div>',
  36. timeout: 2000, //unblock after 2 seconds
  37. overlayCSS: {
  38. backgroundColor: '#FFF',
  39. opacity: 0.8,
  40. cursor: 'wait'
  41. },
  42. css: {
  43. border: 0,
  44. padding: 0,
  45. backgroundColor: 'transparent'
  46. }
  47. });
  48. });
  49. // Block page
  50. $('.block-page').on('click', function() {
  51. $.blockUI({
  52. message: '<div class="icon-spinner9 icon-spin icon-lg"></div>',
  53. timeout: 2000, //unblock after 2 seconds
  54. overlayCSS: {
  55. backgroundColor: '#FFF',
  56. opacity: 0.8,
  57. cursor: 'wait'
  58. },
  59. css: {
  60. border: 0,
  61. padding: 0,
  62. backgroundColor: 'transparent'
  63. }
  64. });
  65. });
  66. /************************************
  67. * Message Options *
  68. ************************************/
  69. // Spinner only
  70. $('.block-spinner-only').on('click', function() {
  71. var block_ele = $(this).closest('.card');
  72. $(block_ele).block({
  73. message: '<div class="icon-spinner9 icon-spin icon-lg"></div>',
  74. timeout: 2000, //unblock after 2 seconds
  75. overlayCSS: {
  76. backgroundColor: '#fff',
  77. opacity: 0.8,
  78. cursor: 'wait'
  79. },
  80. css: {
  81. border: 0,
  82. padding: 0,
  83. backgroundColor: 'transparent'
  84. }
  85. });
  86. });
  87. // Defult Message
  88. $('.block-default-message').on('click', function() {
  89. var block_ele = $(this).closest('.card');
  90. $(block_ele).block({
  91. message: '<span class="semibold"> Loading...</span>',
  92. timeout: 2000, //unblock after 2 seconds
  93. overlayCSS: {
  94. backgroundColor: '#fff',
  95. opacity: 0.8,
  96. cursor: 'wait'
  97. },
  98. css: {
  99. border: 0,
  100. padding: 0,
  101. backgroundColor: 'transparent'
  102. }
  103. });
  104. });
  105. // Message Animation
  106. $('.block-msg-animation').on('click', function() {
  107. var block_ele = $(this).closest('.card');
  108. $(block_ele).block({
  109. message: '<div class="semibold"><span class="icon-spinner9 icon-spin text-left"></span>&nbsp; Loading ...</div>',
  110. fadeIn: 1000,
  111. fadeOut: 1000,
  112. timeout: 2000, //unblock after 2 seconds
  113. overlayCSS: {
  114. backgroundColor: '#fff',
  115. opacity: 0.8,
  116. cursor: 'wait'
  117. },
  118. css: {
  119. border: 0,
  120. padding: '10px 15px',
  121. color: '#fff',
  122. width: 'auto',
  123. backgroundColor: '#333'
  124. }
  125. });
  126. });
  127. // Multiple messages
  128. $('.block-multiple-msgs').on('click', function() {
  129. var message = $('.multiple-msgs');
  130. var block_ele = $(this).closest('.card');
  131. $(block_ele).block({
  132. message: message,
  133. overlayCSS: {
  134. backgroundColor: '#fff',
  135. opacity: 0.8,
  136. cursor: 'wait'
  137. },
  138. css: {
  139. // width: 200,
  140. border: 0,
  141. padding: 0,
  142. backgroundColor: 'transparent'
  143. },
  144. onBlock: function(){
  145. clearTimeout();
  146. }
  147. });
  148. window.setTimeout(function () {
  149. message.html('<div class="semibold"><span class="icon-spinner9 icon-spin text-left"></span>&nbsp; Loading ...</div>');
  150. }, 0);
  151. window.setTimeout(function () {
  152. message.html('<div class="semibold">Just a minute...</div>');
  153. }, 2000);
  154. window.setTimeout(function () {
  155. message.addClass('bg-success').html('<div class="semibold"><span class="icon-thumbs-o-up text-left"></span>&nbsp; Success</div>');
  156. }, 4000);
  157. window.setTimeout(function () {
  158. $(block_ele).unblock({
  159. onUnblock: function(){
  160. message.removeClass('bg-success');
  161. }
  162. });
  163. }, 6000);
  164. });
  165. // Non centered message
  166. $('.block-non-centered-msg').on('click', function() {
  167. var block_ele = $(this).closest('.card');
  168. $(block_ele).block({
  169. message: '<div class="semibold"><span class="icon-spinner9 icon-spin text-left"></span>&nbsp; Loading ...</div>',
  170. timeout: 2000, //unblock after 2 seconds
  171. centerX: 0,
  172. centerY: 0,
  173. overlayCSS: {
  174. backgroundColor: '#fff',
  175. opacity: 0.8,
  176. cursor: 'wait'
  177. },
  178. css: {
  179. top: '10px',
  180. left: '',
  181. right: '10px',
  182. border: 0,
  183. padding: '10px 15px',
  184. backgroundColor: 'transparent'
  185. }
  186. });
  187. });
  188. /****************************************
  189. * Overlay Examples *
  190. ****************************************/
  191. // Light overlay
  192. $('.block-light-overlay').on('click', function() {
  193. var block_ele = $(this).closest('.card');
  194. $(block_ele).block({
  195. message: '<div class="icon-spinner9 icon-spin icon-lg"></div>',
  196. timeout: 2000, //unblock after 2 seconds
  197. overlayCSS: {
  198. backgroundColor: '#fff',
  199. opacity: 0.8,
  200. cursor: 'wait'
  201. },
  202. css: {
  203. border: 0,
  204. padding: 0,
  205. backgroundColor: 'transparent'
  206. }
  207. });
  208. });
  209. // Custom overlay
  210. $('.block-opaque-overlay').on('click', function() {
  211. var block_ele = $(this).closest('.card');
  212. $(block_ele).block({
  213. message: '<div class="icon-spinner9 icon-spin icon-lg"></div>',
  214. timeout: 2000, //unblock after 2 seconds
  215. overlayCSS: {
  216. backgroundColor: '#2962FF',
  217. opacity: 1,
  218. cursor: 'wait'
  219. },
  220. css: {
  221. border: 0,
  222. padding: 0,
  223. color: '#fff',
  224. backgroundColor: 'transparent'
  225. }
  226. });
  227. });
  228. // Overlay with custom color
  229. $('.block-custom-overlay').on('click', function() {
  230. var block_ele = $(this).closest('.card');
  231. $(block_ele).block({
  232. message: '<div class="icon-spinner9 icon-spin icon-lg"></div>',
  233. timeout: 2000, //unblock after 2 seconds
  234. overlayCSS: {
  235. backgroundColor: '#E91E63',
  236. opacity: 0.8,
  237. cursor: 'wait'
  238. },
  239. css: {
  240. border: 0,
  241. padding: 0,
  242. color: '#fff',
  243. backgroundColor: 'transparent'
  244. }
  245. });
  246. });
  247. /****************************************
  248. * Callback Options *
  249. ****************************************/
  250. // onBlock callback
  251. $('.onblock-callback').on('click', function() {
  252. $.blockUI({
  253. message: '<div class="icon-spinner9 icon-spin icon-lg"></div>',
  254. fadeIn: 1000,
  255. timeout: 2000, //unblock after 2 seconds
  256. overlayCSS: {
  257. backgroundColor: '#FFF',
  258. opacity: 0.8,
  259. cursor: 'wait'
  260. },
  261. css: {
  262. border: 0,
  263. padding: 0,
  264. color: '#333',
  265. backgroundColor: 'transparent'
  266. },
  267. onBlock: function() {
  268. alert('Page is now blocked, FadeIn complete.');
  269. }
  270. });
  271. });
  272. // onUnblock callback
  273. $('.onunblock-callback').on('click', function() {
  274. $.blockUI({
  275. message: '<div class="icon-spinner9 icon-spin icon-lg"></div>',
  276. timeout: 2000, //unblock after 2 seconds
  277. overlayCSS: {
  278. backgroundColor: '#FFF',
  279. opacity: 0.8,
  280. cursor: 'wait'
  281. },
  282. css: {
  283. border: 0,
  284. padding: 0,
  285. color: '#333',
  286. backgroundColor: 'transparent'
  287. },
  288. onUnblock: function() {
  289. alert('Page is now unblocked. FadeOut complete.');
  290. }
  291. });
  292. });
  293. // Overlay callback
  294. $('.onoverlay-click-callback').on('click', function() {
  295. $.blockUI({
  296. message: '<div class="icon-spinner9 icon-spin icon-lg"></div>',
  297. overlayCSS: {
  298. backgroundColor: '#FFF',
  299. opacity: 0.8,
  300. cursor: 'wait'
  301. },
  302. css: {
  303. color: '#333',
  304. border: 0,
  305. padding: 0,
  306. backgroundColor: 'transparent'
  307. },
  308. onOverlayClick: $.unblockUI
  309. });
  310. });
  311. /************************************
  312. * Other Options *
  313. ************************************/
  314. // Block Without Message
  315. $('.block-without-msg').on('click', function() {
  316. var block_ele = $(this).closest('.card');
  317. $(block_ele).block({
  318. message: null,
  319. timeout: 2000, //unblock after 2 seconds
  320. overlayCSS: {
  321. backgroundColor: '#fff',
  322. opacity: 0.8,
  323. cursor: 'wait'
  324. },
  325. css: {
  326. border: 0,
  327. padding: 0,
  328. backgroundColor: 'transparent'
  329. }
  330. });
  331. });
  332. // Block without overlay
  333. $('.block-without-overlay').on('click', function() {
  334. var block_ele = $(this).closest('.card');
  335. $(block_ele).block({
  336. message: '<div class="icon-spinner9 icon-spin icon-lg"></div>',
  337. showOverlay: false,
  338. timeout: 2000, //unblock after 2 seconds
  339. css: {
  340. width: 50,
  341. height: 50,
  342. lineHeight: 1,
  343. color: '#FFF',
  344. border: 0,
  345. padding: 15,
  346. backgroundColor: '#333'
  347. }
  348. });
  349. });
  350. // Unblock on overlay click
  351. $('.overlay-unblock').on('click', function() {
  352. var block_ele = $(this).closest('.card');
  353. $(block_ele).block({
  354. message: '<div class="icon-spinner9 icon-spin icon-lg"></div>',
  355. overlayCSS: {
  356. backgroundColor: '#fff',
  357. opacity: 0.8,
  358. cursor: 'wait'
  359. },
  360. css: {
  361. border: 0,
  362. padding: 0,
  363. backgroundColor: 'transparent'
  364. }
  365. });
  366. $('.blockOverlay').on('click', function() {
  367. $(block_ele).unblock();
  368. });
  369. });
  370. // Growl notification
  371. $('.growl-notification').on('click', function() {
  372. $.blockUI({
  373. message: $('.growl-notification-example'),
  374. fadeIn: 700,
  375. fadeOut: 700,
  376. timeout: 50000,
  377. showOverlay: false,
  378. centerY: false,
  379. css: {
  380. width: '250px',
  381. top: '20px',
  382. left: '',
  383. right: '20px',
  384. border: 'none',
  385. padding: '15px 5px',
  386. backgroundColor: '#333',
  387. '-webkit-border-radius': '10px',
  388. '-moz-border-radius': '10px',
  389. opacity: 0.9,
  390. color: '#fff'
  391. }
  392. });
  393. });
  394. });