lightyear.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 $delay 毫秒数,例如:1000
  26. * @param $icon 图标,例如:'fa fa-user' 或 'glyphicon glyphicon-warning-sign'
  27. * @param $from 'top' 或 'bottom'
  28. * @param $align 'left', 'right', 'center'
  29. * @author CaiWeiMing <314013107@qq.com>
  30. */
  31. var tips = function ($msg, $type, $delay, $icon, $from, $align, $url) {
  32. $type = $type || 'info';
  33. $delay = $delay || 1000;
  34. $from = $from || 'top';
  35. $align = $align || 'center';
  36. $enter = $type == 'danger' ? 'animated shake' : 'animated fadeInUp';
  37. $url = $url || url;
  38. jQuery.notify({
  39. icon: $icon,
  40. message: $msg
  41. },
  42. {
  43. element: 'body',
  44. type: $type,
  45. allow_dismiss: true,
  46. newest_on_top: true,
  47. showProgressbar: false,
  48. placement: {
  49. from: $from,
  50. align: $align
  51. },
  52. offset: 20,
  53. spacing: 10,
  54. z_index: 10800,
  55. delay: $delay,
  56. //timer: 1000,
  57. animate: {
  58. enter: $enter,
  59. exit: 'animated fadeOutDown'
  60. }
  61. });
  62. if($url!=''){
  63. setTimeout(function(){
  64. window.location.href=$url;
  65. },$delay);
  66. }
  67. };
  68. var url = '';
  69. return {
  70. // 页面小提示
  71. notify : function ($msg, $type, $delay, $icon, $from, $align, $url) {
  72. tips($msg, $type, $delay, $icon, $from, $align, $url);
  73. },
  74. url : function ($url){
  75. url=$url;
  76. },
  77. // 页面加载动画
  78. loading : function ($mode) {
  79. pageLoader($mode);
  80. }
  81. };
  82. }();