Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

notify.js 37KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166
  1. /* ------------------------------------------------------------------------------
  2. *
  3. * # PNotify notifications
  4. *
  5. * Specific JS code additions for components_notifications_pnotify.html page
  6. *
  7. * Version: 1.1
  8. * Latest update: Feb 1, 2016
  9. *
  10. * ---------------------------------------------------------------------------- */
  11. $(function() {
  12. // Popup notifications
  13. // ------------------------------
  14. //
  15. // Notification styles
  16. //
  17. // Default style
  18. $('#pnotify-default').on('click', function () {
  19. new PNotify({
  20. title: 'Primary notice',
  21. text: 'Check me out! I\'m a notice.',
  22. icon: 'icofont icofont-info-circle',
  23. type: 'default'
  24. });
  25. });
  26. // primary style
  27. $('#pnotify-primary').on('click', function () {
  28. new PNotify({
  29. title: 'Primary notice',
  30. text: 'Check me out! I\'m a notice.',
  31. icon: 'icofont icofont-info-circle',
  32. type: 'primary'
  33. });
  34. });
  35. // Success notification
  36. $('#pnotify-success').on('click', function () {
  37. new PNotify({
  38. title: 'Success notice',
  39. text: 'Check me out! I\'m a notice.',
  40. icon: 'icofont icofont-info-circle',
  41. type: 'success'
  42. });
  43. });
  44. // Info notification
  45. $('#pnotify-info').on('click', function () {
  46. new PNotify({
  47. title: 'Info notice',
  48. text: 'Check me out! I\'m a notice.',
  49. icon: 'icofont icofont-info-square',
  50. type: 'info'
  51. });
  52. });
  53. // Danger notification
  54. $('#pnotify-danger').on('click', function () {
  55. new PNotify({
  56. title: 'Danger notice',
  57. text: 'Check me out! I\'m a notice.',
  58. icon: 'icofont icofont-info-circle',
  59. type: 'error'
  60. });
  61. });
  62. // Styled left
  63. $('#pnotify-styled-left').on('click', function () {
  64. new PNotify({
  65. title: 'Left icon',
  66. text: 'Check me out! I\'m a notice.',
  67. addclass: 'alert alert-styled-left',
  68. type: 'info'
  69. });
  70. });
  71. // Styled right
  72. $('#pnotify-styled-right').on('click', function () {
  73. new PNotify({
  74. title: 'Right icon',
  75. text: 'Check me out! I\'m a notice.',
  76. addclass: 'alert alert-warning alert-styled-right',
  77. type: 'error'
  78. });
  79. });
  80. // Styled with arrow
  81. $('#pnotify-styled-arrow').on('click', function () {
  82. new PNotify({
  83. title: 'Notice with arrow',
  84. text: 'Check me out! I\'m a notice.',
  85. addclass: 'alert alert-styled-left alert-arrow-left',
  86. type: 'info'
  87. });
  88. });
  89. // Custom style
  90. $('#pnotify-custom-styled').on('click', function () {
  91. new PNotify({
  92. title: 'Custom color notice',
  93. text: 'Check me out! I\'m a notice.',
  94. addclass: 'alert alert-styled-left alert-styled-custom alert-arrow-left alpha-teal text-teal-800'
  95. });
  96. });
  97. //
  98. // Solid color style
  99. //
  100. // Solid default
  101. $('#pnotify-solid-default').on('click', function () {
  102. new PNotify({
  103. title: 'default notice',
  104. text: 'Check me out! I\'m a notice.',
  105. addclass: 'bg-basic-default'
  106. });
  107. });
  108. // Solid primary
  109. $('#pnotify-solid-primary').on('click', function () {
  110. new PNotify({
  111. title: 'Primary notice',
  112. text: 'Check me out! I\'m a notice.',
  113. addclass: 'bg-primary'
  114. });
  115. });
  116. // Solid danger
  117. $('#pnotify-solid-danger').on('click', function () {
  118. new PNotify({
  119. title: 'Danger notice',
  120. text: 'Check me out! I\'m a notice.',
  121. addclass: 'bg-danger'
  122. });
  123. });
  124. // Solid success
  125. $('#pnotify-solid-success').on('click', function () {
  126. new PNotify({
  127. title: 'Success notice',
  128. text: 'Check me out! I\'m a notice.',
  129. addclass: 'bg-success'
  130. });
  131. });
  132. // Solid warning
  133. $('#pnotify-solid-warning').on('click', function () {
  134. new PNotify({
  135. title: 'Warning notice',
  136. text: 'Check me out! I\'m a notice.',
  137. addclass: 'bg-warning'
  138. });
  139. });
  140. // Solid info
  141. $('#pnotify-solid-info').on('click', function () {
  142. new PNotify({
  143. title: 'Info notice',
  144. text: 'Check me out! I\'m a notice.',
  145. addclass: 'bg-info'
  146. });
  147. });
  148. // Solid inverse
  149. $('#pnotify-solid-inverse').on('click', function () {
  150. new PNotify({
  151. title: 'Info notice',
  152. text: 'Check me out! I\'m a notice.',
  153. addclass: 'bg-inverse'
  154. });
  155. });
  156. // Custom solid color
  157. $('#pnotify-solid-custom').on('click', function () {
  158. new PNotify({
  159. title: 'Custom color notice',
  160. text: 'Check me out! I\'m a notice.',
  161. addclass: 'bg-teal'
  162. });
  163. });
  164. // Solid styled left
  165. $('#pnotify-solid-styled-left').on('click', function () {
  166. new PNotify({
  167. title: 'Left icon',
  168. text: 'Check me out! I\'m a notice.',
  169. addclass: 'alert bg-primary alert-styled-left'
  170. });
  171. });
  172. // Solid styled right
  173. $('#pnotify-solid-styled-right').on('click', function () {
  174. new PNotify({
  175. title: 'Right icon',
  176. text: 'Check me out! I\'m a notice.',
  177. addclass: 'alert bg-danger alert-styled-right',
  178. type: 'error'
  179. });
  180. });
  181. // Desktop notifications
  182. // ------------------------------
  183. // Danger
  184. $('#pnotify-desktop-danger').on('click', function () {
  185. PNotify.desktop.permission();
  186. (new PNotify({
  187. title: 'Danger Desktop Notice',
  188. type: 'danger',
  189. text: 'I\'m a danger desktop notification, if you have given me a permission.',
  190. desktop: {
  191. desktop: true,
  192. icon: 'assets/images/pnotify/danger.png'
  193. }
  194. })
  195. ).get().click(function(e) {
  196. if ($('.ui-pnotify-closer, .ui-pnotify-sticker, .ui-pnotify-closer *, .ui-pnotify-sticker *').is(e.target)) return;
  197. alert('Hey! You clicked the desktop notification!');
  198. });
  199. });
  200. // Success
  201. $('#pnotify-desktop-success').on('click', function () {
  202. PNotify.desktop.permission();
  203. (new PNotify({
  204. title: 'Success Desktop Notice',
  205. type: 'success',
  206. text: 'I\'m a success desktop notification, if you have given me a permission.',
  207. desktop: {
  208. desktop: true,
  209. icon: 'assets/images/pnotify/success.png'
  210. }
  211. })
  212. ).get().click(function(e) {
  213. if ($('.ui-pnotify-closer, .ui-pnotify-sticker, .ui-pnotify-closer *, .ui-pnotify-sticker *').is(e.target)) return;
  214. alert('Hey! You clicked the desktop notification!');
  215. });
  216. });
  217. // Warning
  218. $('#pnotify-desktop-warning').on('click', function () {
  219. PNotify.desktop.permission();
  220. (new PNotify({
  221. title: 'Warning Desktop Notice',
  222. type: 'warning',
  223. text: 'I\'m a warning desktop notification, if you have given me a permission.',
  224. desktop: {
  225. desktop: true,
  226. icon: 'assets/images/pnotify/warning.png'
  227. }
  228. })
  229. ).get().click(function(e) {
  230. if ($('.ui-pnotify-closer, .ui-pnotify-sticker, .ui-pnotify-closer *, .ui-pnotify-sticker *').is(e.target)) return;
  231. alert('Hey! You clicked the desktop notification!');
  232. });
  233. });
  234. // Info
  235. $('#pnotify-desktop-info').on('click', function () {
  236. PNotify.desktop.permission();
  237. (new PNotify({
  238. title: 'Info Desktop Notice',
  239. type: 'info',
  240. text: 'I\'m an info desktop notification, if you have given me a permission.',
  241. desktop: {
  242. desktop: true,
  243. icon: 'assets/images/pnotify/notice.png'
  244. }
  245. })
  246. ).get().click(function(e) {
  247. if ($('.ui-pnotify-closer, .ui-pnotify-sticker, .ui-pnotify-closer *, .ui-pnotify-sticker *').is(e.target)) return;
  248. alert('Hey! You clicked the desktop notification!');
  249. });
  250. });
  251. // Options
  252. // ------------------------------
  253. // No title
  254. $('#pnotify-no-title').on('click', function () {
  255. new PNotify({
  256. text: 'Check me out! I\'m a notice without title.',
  257. addclass: 'bg-primary',
  258. icon: 'none'
  259. });
  260. });
  261. // Rich content
  262. $('#pnotify-rich').on('click', function () {
  263. new PNotify({
  264. title: 'Rich content notice',
  265. text: 'Look at my beautiful <strong>strong</strong>, <a href="#" class="alert-link">linked</a>, <em>emphasized</em>, and <u>underlined</u> text with <i class="icon-make-group"></i> icon.',
  266. icon: 'icon-comment-discussion'
  267. });
  268. });
  269. // Close on click
  270. $('#pnotify-click').on('click', function () {
  271. var notice = new PNotify({
  272. title: 'Close on click',
  273. text: 'Click me anywhere to dismiss me.',
  274. addclass: 'bg-warning',
  275. hide: false,
  276. icon:'none',
  277. buttons: {
  278. closer: false,
  279. sticker: false
  280. }
  281. });
  282. notice.get().click(function() {
  283. notice.remove();
  284. });
  285. });
  286. // Form
  287. $('#pnotify-form').on('click', function () {
  288. var notice = new PNotify({
  289. text: $('#form_notice').html(),
  290. width: '300px',
  291. hide: false,
  292. addclass: 'bg-slate',
  293. buttons: {
  294. closer: false,
  295. sticker: false
  296. },
  297. insert_brs: false
  298. });
  299. // Remove if cancelled
  300. notice.get().find('button[name=cancel]').on('click', function() {
  301. notice.remove();
  302. })
  303. // Submit form
  304. notice.get().submit(function() {
  305. var username = $(this).find('input[name=username]').val();
  306. if (!username) {
  307. alert('Please provide a username.');
  308. return false;
  309. }
  310. notice.update({
  311. title: 'Welcome',
  312. text: 'Successfully logged in as ' + username,
  313. addclass: 'bg-teal',
  314. icon: true,
  315. width: PNotify.prototype.options.width,
  316. hide: true,
  317. buttons: {
  318. closer: true,
  319. sticker: true
  320. }
  321. });
  322. return false;
  323. });
  324. });
  325. // Sticky notice
  326. $('#pnotify-sticky').on('click', function () {
  327. new PNotify({
  328. title: 'Sticky notice',
  329. text: 'Check me out! I\'m a sticky notice. You\'ll have to close me yourself.',
  330. addclass: 'bg-primary',
  331. hide: false
  332. });
  333. });
  334. // Sticky buttons
  335. $('#pnotify-sticky-buttons').on('click', function () {
  336. new PNotify({
  337. title: 'No sticky button notice',
  338. text: 'I\'m a sticky notice with no unsticky button. You\'ll have to close me yourself.',
  339. addclass: 'bg-primary',
  340. hide: false,
  341. buttons: {
  342. sticker: false
  343. }
  344. });
  345. });
  346. // Permanent buttons
  347. $('#pnotify-permanent-buttons').on('click', function () {
  348. new PNotify({
  349. title: 'Permanent buttons notice',
  350. text: 'My buttons are really lonely, so they\'re gonna hang out with us.',
  351. addclass: 'bg-slate',
  352. buttons: {
  353. closer_hover: false,
  354. sticker_hover: false
  355. }
  356. });
  357. });
  358. // Modules
  359. // ------------------------------
  360. // Confirm
  361. $('#pnotify-confirm').on('click', function () {
  362. // Setup
  363. var notice = new PNotify({
  364. title: 'Confirmation',
  365. text: '<p>Are you sure you want to discard changes?</p>',
  366. hide: false,
  367. type: 'warning',
  368. confirm: {
  369. confirm: true,
  370. buttons: [
  371. {
  372. text: 'Yes',
  373. addClass: 'btn btn-sm btn-primary'
  374. },
  375. {
  376. addClass: 'btn btn-sm btn-link'
  377. }
  378. ]
  379. },
  380. buttons: {
  381. closer: false,
  382. sticker: false
  383. },
  384. history: {
  385. history: false
  386. }
  387. })
  388. // On confirm
  389. notice.get().on('pnotify.confirm', function() {
  390. alert('Ok, cool.');
  391. })
  392. // On cancel
  393. notice.get().on('pnotify.cancel', function() {
  394. alert('Oh ok. Chicken, I see.');
  395. });
  396. });
  397. // Prompt
  398. $('#pnotify-prompt').on('click', function () {
  399. // Setup
  400. var notice = new PNotify({
  401. title: 'Input needed',
  402. text: 'What side would you like?',
  403. hide: false,
  404. confirm: {
  405. prompt: true,
  406. buttons: [
  407. {
  408. text: 'Yes',
  409. addClass: 'btn btn-sm btn-primary'
  410. },
  411. {
  412. addClass: 'btn btn-sm btn-link'
  413. }
  414. ]
  415. },
  416. buttons: {
  417. closer: false,
  418. sticker: false
  419. },
  420. history: {
  421. history: false
  422. }
  423. });
  424. // On confirm
  425. notice.get().on('pnotify.confirm', function(e, notice, val) {
  426. notice.cancelRemove().update({
  427. title: 'You\'ve chosen a side',
  428. text: 'You want ' + $('<div/>').text(val).html() + '.',
  429. icon: 'icon-checkmark3',
  430. type: 'success',
  431. delay: 2000,
  432. hide: true,
  433. confirm: {
  434. prompt: false
  435. },
  436. buttons: {
  437. closer: true,
  438. sticker: true
  439. }
  440. });
  441. })
  442. // On cancel
  443. notice.get().on('pnotify.cancel', function(e, notice) {
  444. notice.cancelRemove().update({
  445. title: 'You don\'t want a side',
  446. text: 'No soup for you!',
  447. icon: 'icon-blocked',
  448. type: 'error',
  449. delay: 2000,
  450. hide: true,
  451. confirm: {
  452. prompt: false
  453. },
  454. buttons: {
  455. closer: true,
  456. sticker: true
  457. }
  458. });
  459. });
  460. });
  461. // Multiline prompt
  462. $('#pnotify-multiline').on('click', function () {
  463. // Setup
  464. var notice = new PNotify({
  465. title: 'Input needed',
  466. text: 'Write me a poem, please.',
  467. hide: false,
  468. confirm: {
  469. prompt: true,
  470. prompt_multi_line: true,
  471. prompt_default: 'Roses are red,\nViolets are blue,\n',
  472. buttons: [
  473. {
  474. text: 'Yes',
  475. addClass: 'btn btn-sm btn-primary'
  476. },
  477. {
  478. addClass: 'btn btn-sm btn-link'
  479. }
  480. ]
  481. },
  482. buttons: {
  483. closer: false,
  484. sticker: false
  485. },
  486. history: {
  487. history: false
  488. }
  489. });
  490. // Confirm
  491. notice.get().on('pnotify.confirm', function(e, notice, val) {
  492. notice.cancelRemove().update({
  493. title: 'Your poem',
  494. text: $('<div/>').text(val).html(),
  495. icon: 'icon-checkmark3',
  496. type: 'success',
  497. hide: true,
  498. confirm: {
  499. prompt: false
  500. },
  501. buttons: {
  502. closer: true,
  503. sticker: true
  504. }
  505. });
  506. });
  507. // On cancel
  508. notice.get().on('pnotify.cancel', function(e, notice) {
  509. notice.cancelRemove().update({
  510. title: 'You don\'t like poetry',
  511. text: 'Roses are dead,\nViolets are dead,\nI at gardening.',
  512. icon: 'icon-blocked',
  513. type: 'error',
  514. hide: true,
  515. confirm: {
  516. prompt: false
  517. },
  518. buttons: {
  519. closer: true,
  520. sticker: true
  521. }
  522. });
  523. });
  524. });
  525. // Custom buttons
  526. $('#pnotify-buttons').on('click', function () {
  527. new PNotify({
  528. title: 'Choose a side',
  529. text: 'You have three options to choose from.',
  530. hide: false,
  531. width: 420,
  532. confirm: {
  533. confirm: true,
  534. buttons: [
  535. {
  536. text: 'Fries',
  537. addClass: 'btn btn-sm bg-blue',
  538. click: function(notice) {
  539. notice.update({
  540. title: 'You\'ve chosen a side',
  541. text: 'You want fries.',
  542. icon: 'icon-checkmark3',
  543. type: 'success',
  544. hide: true,
  545. confirm: {
  546. confirm: false
  547. },
  548. buttons: {
  549. closer: true,
  550. sticker: true
  551. }
  552. });
  553. }
  554. },
  555. {
  556. text: 'Mashed Potatoes',
  557. addClass: 'btn btn-sm bg-pink-400',
  558. click: function(notice) {
  559. notice.update({
  560. title: 'You\'ve chosen a side',
  561. text: 'You want mashed potatoes.',
  562. icon: 'icon-checkmark3',
  563. type: 'info',
  564. hide: true,
  565. confirm: {
  566. confirm: false
  567. },
  568. buttons: {
  569. closer: true,
  570. sticker: true
  571. }
  572. });
  573. }
  574. },
  575. {
  576. text: 'Fruit',
  577. addClass: 'btn btn-sm bg-indigo-400',
  578. click: function(notice) {
  579. notice.update({
  580. title: 'You\'ve chosen a side',
  581. text: 'You want fruit.',
  582. icon: 'icon-checkmark3',
  583. type: 'info',
  584. hide: true,
  585. confirm: {
  586. confirm: false
  587. },
  588. buttons: {
  589. closer: true,
  590. sticker: true
  591. }
  592. });
  593. }
  594. }
  595. ]
  596. },
  597. buttons: {
  598. closer: false,
  599. sticker: false
  600. },
  601. history: {
  602. closer:'icofont icofont-close-circled',
  603. history: false
  604. }
  605. });
  606. });
  607. // Permanotice
  608. $('#pnotify-permanotice').on('click', function () {
  609. var permanotice;
  610. if (permanotice) {
  611. permanotice.open();
  612. }
  613. else {
  614. permanotice = new PNotify({
  615. title: 'Now look here',
  616. text: 'There\'s something you need to know, and I won\'t go away until you come to grips with it.',
  617. addclass: 'bg-danger',
  618. hide: false,
  619. buttons: {
  620. closer: false,
  621. sticker: false
  622. }
  623. });
  624. }
  625. });
  626. // Callbacks
  627. $('#pnotify-callbacks').on('click', function () {
  628. var dont_alert = function() {};
  629. new PNotify({
  630. title: 'I\'m here',
  631. text: 'I have a callback for each of my events. I\'ll call all my callbacks while I change states.',
  632. addclass: 'bg-teal',
  633. before_init: function(opts) {
  634. dont_alert('I\'m called before the notice initializes. I\'m passed the options used to make the notice. I can modify them. Watch me replace the word callback with tire iron!');
  635. opts.text = opts.text.replace(/callback/g, 'tire iron');
  636. },
  637. after_init: function(PNotify) {
  638. dont_alert('I\'m called after the notice initializes. I\'m passed the PNotify object for the current notice: ' + PNotify + '\n\nThere are more callbacks you can assign, but this is the last notice you\'ll see. Check the code to see them all.');
  639. },
  640. before_open: function(PNotify) {
  641. var source_note = 'Return false to cancel opening.';
  642. dont_alert('I\'m called before the notice opens. I\'m passed the PNotify object for the current notice: ' + PNotify);
  643. },
  644. after_open: function(PNotify) {
  645. alert('I\'m called after the notice opens. I\'m passed the PNotify object for the current notice: ' + PNotify);
  646. },
  647. before_close: function(PNotify, timer_hide) {
  648. var source_note = 'Return false to cancel close. Use PNotify.queueRemove() to set the removal timer again.';
  649. dont_alert('I\'m called before the notice closes. I\'m passed the PNotify object for the current notice: ' + PNotify);
  650. dont_alert('I also have an argument called timer_hide, which is true if the notice was closed because the timer ran down. Value: ' + timer_hide);
  651. },
  652. after_close: function(PNotify, timer_hide) {
  653. alert('I\'m called after the notice closes. I\'m passed the PNotify object for the current notice: ' + PNotify);
  654. dont_alert('I also have an argument called timer_hide, which is true if the notice was closed because the timer ran down. Value: ' + timer_hide);
  655. }
  656. });
  657. });
  658. // Switching notices
  659. $('#pnotify-switching').on('click', function () {
  660. new PNotify({
  661. title: 'Notice',
  662. text: 'Right now I\'m a notice.',
  663. addclass: 'alert bg-primary alert-styled-right',
  664. before_close: function(PNotify) {
  665. PNotify.update({
  666. title: 'Error',
  667. text: 'Uh oh. Now I\'ve become an error.',
  668. addclass: 'alert bg-danger alert-styled-right',
  669. type: 'error',
  670. before_close: function(PNotify) {
  671. PNotify.update({
  672. title: 'Success',
  673. text: 'I fixed the error!',
  674. addclass: 'alert bg-success alert-styled-right',
  675. type: 'success',
  676. before_close: function(PNotify) {
  677. PNotify.update({
  678. title: 'Info',
  679. text: 'Everything\'s cool now.',
  680. addclass: 'alert bg-info alert-styled-right',
  681. type: 'info',
  682. before_close: null
  683. });
  684. PNotify.queueRemove();
  685. return false;
  686. }
  687. });
  688. PNotify.queueRemove();
  689. return false;
  690. }
  691. });
  692. PNotify.queueRemove();
  693. return false;
  694. }
  695. });
  696. });
  697. // Progress loader
  698. $('#pnotify-progress').on('click', function () {
  699. var cur_value = 1,
  700. progress;
  701. // Make a loader.
  702. var loader = new PNotify({
  703. title: "Creating series of tubes",
  704. text: '<div class="progress progress-striped active" style="margin:0">\
  705. <div class="progress-bar bg-danger" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0">\
  706. <span class="sr-only">0%</span>\
  707. </div>\
  708. </div>',
  709. addclass: 'bg-primary',
  710. icon: 'icon-spinner4 spinner',
  711. hide: false,
  712. buttons: {
  713. closer: false,
  714. sticker: false
  715. },
  716. history: {
  717. history: false
  718. },
  719. before_open: function(PNotify) {
  720. progress = PNotify.get().find("div.progress-bar");
  721. progress.width(cur_value + "%").attr("aria-valuenow", cur_value).find("span").html(cur_value + "%");
  722. // Pretend to do something.
  723. var timer = setInterval(function() {
  724. if (cur_value >= 100) {
  725. // Remove the interval.
  726. window.clearInterval(timer);
  727. loader.remove();
  728. return;
  729. }
  730. cur_value += 1;
  731. progress.width(cur_value + "%").attr("aria-valuenow", cur_value).find("span").html(cur_value + "%");
  732. }, 65);
  733. }
  734. });
  735. });
  736. // Dynamic loader
  737. $('#pnotify-dynamic').on('click', function () {
  738. var percent = 0;
  739. var notice = new PNotify({
  740. text: "Please wait",
  741. addclass: 'bg-primary',
  742. type: 'info',
  743. icon: 'icon-spinner4 spinner',
  744. hide: false,
  745. buttons: {
  746. closer: false,
  747. sticker: false
  748. },
  749. opacity: .9,
  750. width: "170px"
  751. });
  752. setTimeout(function() {
  753. notice.update({
  754. title: false
  755. });
  756. var interval = setInterval(function() {
  757. percent += 2;
  758. var options = {
  759. text: percent + "% complete."
  760. };
  761. if (percent == 80) options.title = "Almost There";
  762. if (percent >= 100) {
  763. window.clearInterval(interval);
  764. options.title = "Done!";
  765. options.addclass = "bg-success";
  766. options.type = "success";
  767. options.hide = true;
  768. options.buttons = {
  769. closer: true,
  770. sticker: true
  771. };
  772. options.icon = 'icon-checkmark3';
  773. options.opacity = 1;
  774. options.width = PNotify.prototype.options.width;
  775. }
  776. notice.update(options);
  777. }, 120);
  778. }, 2000);
  779. });
  780. // Stacks
  781. // ------------------------------
  782. // Define directions
  783. var stack_top_left = {"dir1": "down", "dir2": "right", "push": "top"};
  784. var stack_bottom_left = {"dir1": "right", "dir2": "up", "push": "top"};
  785. var stack_bottom_right = {"dir1": "up", "dir2": "left", "firstpos1": 25, "firstpos2": 25};
  786. var stack_custom_left = {"dir1": "right", "dir2": "down"};
  787. var stack_custom_right = {"dir1": "left", "dir2": "up", "push": "top"};
  788. var stack_custom_top = {"dir1": "down", "dir2": "right", "push": "top", "spacing1": 1};
  789. var stack_custom_bottom = {"dir1": "up", "dir2": "right", "spacing1": 1};
  790. //
  791. // Setup options for positions
  792. //
  793. // Top left
  794. function show_stack_top_left(type) {
  795. var opts = {
  796. title: "Over here",
  797. text: "Check me out. I'm in a different stack.",
  798. addclass: "stack-top-left bg-primary",
  799. stack: stack_top_left
  800. };
  801. switch (type) {
  802. case 'error':
  803. opts.title = "Oh No";
  804. opts.text = "Watch out for that water tower!";
  805. opts.addclass = "stack-top-left bg-danger";
  806. opts.type = "error";
  807. break;
  808. case 'info':
  809. opts.title = "Breaking News";
  810. opts.text = "Have you met Ted?";
  811. opts.addclass = "stack-top-left bg-info";
  812. opts.type = "info";
  813. break;
  814. case 'success':
  815. opts.title = "Good News Everyone";
  816. opts.text = "I've invented a device that bites shiny metal asses.";
  817. opts.addclass = "stack-top-left bg-success";
  818. opts.type = "success";
  819. break;
  820. }
  821. new PNotify(opts);
  822. }
  823. // Bottom left
  824. function show_stack_bottom_left(type) {
  825. var opts = {
  826. title: "Over here",
  827. text: "Check me out. I'm in a different stack.",
  828. addclass: "stack-bottom-left bg-primary",
  829. stack: stack_bottom_left
  830. };
  831. switch (type) {
  832. case 'error':
  833. opts.title = "Oh No";
  834. opts.text = "Watch out for that water tower!";
  835. opts.addclass = "stack-bottom-left bg-danger";
  836. opts.type = "error";
  837. break;
  838. case 'info':
  839. opts.title = "Breaking News";
  840. opts.text = "Have you met Ted?";
  841. opts.addclass = "stack-bottom-left bg-info";
  842. opts.type = "info";
  843. break;
  844. case 'success':
  845. opts.title = "Good News Everyone";
  846. opts.text = "I've invented a device that bites shiny metal asses.";
  847. opts.addclass = "stack-bottom-left bg-success";
  848. opts.type = "success";
  849. break;
  850. }
  851. new PNotify(opts);
  852. }
  853. // Bottom right
  854. function show_stack_bottom_right(type) {
  855. var opts = {
  856. title: "Over here",
  857. text: "Check me out. I'm in a different stack.",
  858. addclass: "stack-bottom-right bg-primary",
  859. stack: stack_bottom_right
  860. };
  861. switch (type) {
  862. case 'error':
  863. opts.title = "Oh No";
  864. opts.text = "Watch out for that water tower!";
  865. opts.addclass = "stack-bottom-right bg-danger";
  866. opts.type = "error";
  867. break;
  868. case 'info':
  869. opts.title = "Breaking News";
  870. opts.text = "Have you met Ted?";
  871. opts.addclass = "stack-bottom-right bg-info";
  872. opts.type = "info";
  873. break;
  874. case 'success':
  875. opts.title = "Good News Everyone";
  876. opts.text = "I've invented a device that bites shiny metal asses.";
  877. opts.addclass = "stack-bottom-right bg-success";
  878. opts.type = "success";
  879. break;
  880. }
  881. new PNotify(opts);
  882. }
  883. // Custom left position
  884. function show_stack_custom_left(type) {
  885. var opts = {
  886. title: "Over here",
  887. text: "Check me out. I'm in a different stack.",
  888. addclass: "stack-custom-left bg-primary alert-styled-right",
  889. stack: stack_custom_left
  890. };
  891. switch (type) {
  892. case 'error':
  893. opts.title = "Oh No";
  894. opts.text = "Watch out for that water tower!";
  895. opts.addclass = "stack-custom-left bg-danger";
  896. opts.type = "error";
  897. break;
  898. case 'info':
  899. opts.title = "Breaking News";
  900. opts.text = "Have you met Ted?";
  901. opts.addclass = "stack-custom-left bg-info";
  902. opts.type = "info";
  903. break;
  904. case 'success':
  905. opts.title = "Good News Everyone";
  906. opts.text = "I've invented a device that bites shiny metal asses.";
  907. opts.addclass = "stack-custom-left bg-success";
  908. opts.type = "success";
  909. break;
  910. }
  911. new PNotify(opts);
  912. }
  913. // Custom right position
  914. function show_stack_custom_right(type) {
  915. var opts = {
  916. title: "Over here",
  917. text: "Check me out. I'm in a different stack.",
  918. addclass: "stack-custom-right bg-primary",
  919. stack: stack_custom_right
  920. };
  921. switch (type) {
  922. case 'error':
  923. opts.title = "Oh No";
  924. opts.text = "Watch out for that water tower!";
  925. opts.addclass = "stack-custom-right bg-danger";
  926. opts.type = "error";
  927. break;
  928. case 'info':
  929. opts.title = "Breaking News";
  930. opts.text = "Have you met Ted?";
  931. opts.addclass = "stack-custom-right bg-info";
  932. opts.type = "info";
  933. break;
  934. case 'success':
  935. opts.title = "Good News Everyone";
  936. opts.text = "I've invented a device that bites shiny metal asses.";
  937. opts.addclass = "stack-custom-right bg-success";
  938. opts.type = "success";
  939. break;
  940. }
  941. new PNotify(opts);
  942. }
  943. // Custom top position
  944. function show_stack_custom_top(type) {
  945. var opts = {
  946. title: "Over here",
  947. text: "Check me out. I'm in a different stack.",
  948. width: "100%",
  949. cornerclass: "no-border-radius",
  950. addclass: "stack-custom-top bg-primary",
  951. stack: stack_custom_top
  952. };
  953. switch (type) {
  954. case 'error':
  955. opts.title = "Oh No";
  956. opts.text = "Watch out for that water tower!";
  957. opts.addclass = "stack-custom-top bg-danger";
  958. opts.type = "error";
  959. break;
  960. case 'info':
  961. opts.title = "Breaking News";
  962. opts.text = "Have you met Ted?";
  963. opts.addclass = "stack-custom-top bg-info";
  964. opts.type = "info";
  965. break;
  966. case 'success':
  967. opts.title = "Good News Everyone";
  968. opts.text = "I've invented a device that bites shiny metal asses.";
  969. opts.addclass = "stack-custom-top bg-success";
  970. opts.type = "success";
  971. break;
  972. }
  973. new PNotify(opts);
  974. }
  975. // Custom bottom position
  976. function show_stack_custom_bottom(type) {
  977. var opts = {
  978. title: "Over here",
  979. text: "Check me out. I'm in a different stack.",
  980. width: "100%",
  981. cornerclass: "no-border-radius",
  982. addclass: "stack-custom-bottom bg-primary",
  983. stack: stack_custom_bottom
  984. };
  985. switch (type) {
  986. case 'error':
  987. opts.title = "Oh No";
  988. opts.text = "Watch out for that water tower!";
  989. opts.addclass = "stack-custom-bottom bg-danger";
  990. opts.type = "error";
  991. break;
  992. case 'info':
  993. opts.title = "Breaking News";
  994. opts.text = "Have you met Ted?";
  995. opts.addclass = "stack-custom-bottom bg-info";
  996. opts.type = "info";
  997. break;
  998. case 'success':
  999. opts.title = "Good News Everyone";
  1000. opts.text = "I've invented a device that bites shiny metal asses.";
  1001. opts.addclass = "stack-custom-bottom bg-success";
  1002. opts.type = "success";
  1003. break;
  1004. }
  1005. new PNotify(opts);
  1006. }
  1007. //
  1008. // Initialize
  1009. //
  1010. // Top left
  1011. $('#pnotify-stack-top-left').on('click', function () {
  1012. show_stack_top_left('primary');
  1013. });
  1014. // Bottom left
  1015. $('#pnotify-stack-bottom-left').on('click', function () {
  1016. show_stack_bottom_left('primary');
  1017. });
  1018. // Bottom right
  1019. $('#pnotify-stack-bottom-right').on('click', function () {
  1020. show_stack_bottom_right('danger');
  1021. });
  1022. // Custom left
  1023. $('#pnotify-stack-custom-left').on('click', function () {
  1024. show_stack_custom_left('success');
  1025. });
  1026. // Custom right
  1027. $('#pnotify-stack-custom-right').on('click', function () {
  1028. show_stack_custom_right('success');
  1029. });
  1030. // Custom top
  1031. $('#pnotify-stack-custom-top').on('click', function () {
  1032. show_stack_custom_top('info');
  1033. });
  1034. // Custom bottom
  1035. $('#pnotify-stack-custom-bottom').on('click', function () {
  1036. show_stack_custom_bottom('info');
  1037. });
  1038. });