lightyear.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. var lightyear = function(){
  2. /**
  3. * 页面loading
  4. */
  5. var pageLoader = function($mode) {
  6. var $loadingEl = jQuery('#lyear-loading');
  7. $mode = $mode || 'show';
  8. if ($mode === 'show') {
  9. if ($loadingEl.length) {
  10. $loadingEl.fadeIn(250);
  11. } else {
  12. jQuery('body').prepend('<div id="lyear-loading"><div class="spinner-border text-primary" role="status"><span class="sr-only">Loading...</span></div></div>');
  13. }
  14. } else if ($mode === 'hide') {
  15. if ($loadingEl.length) {
  16. $loadingEl.fadeOut(250);
  17. }
  18. }
  19. return false;
  20. };
  21. /**
  22. * 页面小提示
  23. * @param $msg 提示信息
  24. * @param $type 提示类型:'info', 'success', 'warning', 'danger'
  25. * @param $icon 图标,例如:'fa fa-user' 或 'glyphicon glyphicon-warning-sign'
  26. * @param $from 'top' 或 'bottom'
  27. * @param $align 'left', 'right', 'center'
  28. * @author CaiWeiMing <314013107@qq.com>
  29. */
  30. var tips = function ($msg, $type, $icon, $from, $align) {
  31. $type = $type || 'info';
  32. $from = $from || 'top';
  33. $align = $align || 'center';
  34. $enter = $type == 'danger' ? 'animated shake' : 'animated fadeInUp';
  35. jQuery.notify({
  36. icon: $icon,
  37. message: $msg
  38. },
  39. {
  40. element: 'body',
  41. type: $type,
  42. allow_dismiss: true,
  43. newest_on_top: true,
  44. showProgressbar: false,
  45. placement: {
  46. from: $from,
  47. align: $align
  48. },
  49. offset: 20,
  50. spacing: 10,
  51. z_index: 10800,
  52. delay: 3000,
  53. timer: 1000,
  54. animate: {
  55. enter: $enter,
  56. exit: 'animated fadeOutDown'
  57. }
  58. });
  59. };
  60. return {
  61. // 页面小提示
  62. notify : function ($msg, $type, $icon, $from, $align) {
  63. tips($msg, $type, $icon, $from, $align);
  64. },
  65. // 页面加载动画
  66. loading : function ($mode) {
  67. pageLoader($mode);
  68. }
  69. };
  70. }();