lightyear.js 2.4 KB

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