gzbg-helper.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. (function ( win, $) {
  2. var helper = {
  3. //拼接数组: ( dateArr, d, dt, da)
  4. contrastDate: function ( dateArr, d, s1, s2) {
  5. var da = dateArr,
  6. arr = [];
  7. for (var i = 0; i < da.length; i++) {
  8. var index = '';
  9. for (var j = 0; j < d[s1].length; j++) {
  10. var td = d[s1][j];
  11. if (td == da[i]) {
  12. index = j;
  13. break;
  14. }
  15. }
  16. if (index === 0 || !!index) {
  17. arr.push(d[s2][index]);
  18. } else {
  19. arr.push(0);
  20. }
  21. }
  22. return arr;
  23. },
  24. getWeeksData: function ( d, s1, s2) {
  25. var wn = $d.getWeeksNum(),
  26. arr = {da:[],dt:[]};
  27. for (var i = 1; i <= wn; i++) {
  28. var index = '';
  29. for (var j = 0; j < d[s1].length; j++) {
  30. var td = d[s1][j];
  31. if (td == i) {
  32. index = j;
  33. break;
  34. }
  35. }
  36. if (index === 0 || !!index) {
  37. arr.da.push(d[s2][index]);
  38. } else {
  39. arr.da.push(0);
  40. }
  41. arr.dt.push('第' + i + '周');
  42. }
  43. return arr;
  44. },
  45. setEvent : function (eArr) {//[[el, event, cb, nel],.....]
  46. $.each( eArr, function (ind) {
  47. eArr[ind][2] && eArr[ind][0].on( eArr[ind][1], eArr[ind][3] || '', eArr[ind][2]);
  48. });
  49. },
  50. initScroll: function (cb) {
  51. return new IScrollPullUpDown('wrapper', {
  52. probeType: 2,
  53. bounceTime: 250,
  54. bounceEasing: 'quadratic',
  55. mouseWheel: false,
  56. scrollbars: true,
  57. fadeScrollbars: true,
  58. click: true,
  59. interactiveScrollbars: false,
  60. click: true,
  61. }, cb, null);
  62. }
  63. };
  64. win.$h = helper;
  65. })( window, jQuery)