member.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. $(function(){
  2. /* 全选 */
  3. $('.checkall').click(function(){
  4. var _self = this;
  5. $('.checkitem').each(function(){
  6. if (!this.disabled)
  7. {
  8. $(this).attr('checked', _self.checked);
  9. }
  10. });
  11. $('.checkall').attr('checked', this.checked);
  12. });
  13. /* 批量操作按钮 */
  14. $('a[nc_type="batchbutton"]').click(function(){
  15. /* 是否有选择 */
  16. if($('.checkitem:checked').length == 0){ //没有选择
  17. return false;
  18. }
  19. /* 运行presubmit */
  20. if($(this).attr('presubmit')){
  21. if(!eval($(this).attr('presubmit'))){
  22. return false;
  23. }
  24. }
  25. /* 获取选中的项 */
  26. var items = '';
  27. $('.checkitem:checked').each(function(){
  28. items += this.value + ',';
  29. });
  30. items = items.substr(0, (items.length - 1));
  31. /* 将选中的项通过GET方式提交给指定的URI */
  32. var uri = $(this).attr('uri');
  33. window.location = uri + '&' + $(this).attr('name') + '=' + items;
  34. return false;
  35. });
  36. /* 缩小大图片 */
  37. $('.makesmall').each(function(){
  38. makesmall(this, $(this).attr('max_width'), $(this).attr('max_height'));
  39. });
  40. $('.su_btn').click(function(){
  41. if($(this).hasClass('close')){
  42. $(this).parent().next('.su_block').css('display', '');
  43. $(this).removeClass('close');
  44. }
  45. else{
  46. $(this).addClass('close');
  47. $(this).parent().next('.su_block').css('display', 'none');
  48. }
  49. });
  50. $('*[nc_type="dialog"]').click(function(){
  51. var id = $(this).attr('dialog_id');
  52. var title = $(this).attr('dialog_title') ? $(this).attr('dialog_title') : '';
  53. var url = $(this).attr('uri');
  54. var width = $(this).attr('dialog_width');
  55. ajax_form(id, title, url, width);
  56. return false;
  57. });
  58. var url = window.location.search;
  59. var params = url.substr(1).split('&');
  60. var act = '';
  61. //找出排序的列和排序的方式及app控制器
  62. var sort = '';
  63. var order = '';
  64. for(var j=0; j < params.length; j++)
  65. {
  66. var param = params[j];
  67. var arr = param.split('=');
  68. if(arr[0] == 'act')
  69. {
  70. act = arr[1];
  71. }
  72. if(arr[0] == 'sort')
  73. {
  74. sort = arr[1];
  75. }
  76. if(arr[0] == 'order')
  77. {
  78. order = arr[1];
  79. }
  80. }
  81. $('span[nc_type="order_by"]').each(function(){
  82. if($(this).parent().attr('column') == sort)
  83. {
  84. if(order == 'asc')
  85. {
  86. $(this).removeClass();
  87. $(this).addClass("sort_asc");
  88. }
  89. else if (order == 'desc')
  90. {
  91. $(this).removeClass();
  92. $(this).addClass("sort_desc");
  93. }
  94. }
  95. });
  96. $('span[nc_type="order_by"]').click(function(){
  97. var s_name = $(this).parent().attr('column');
  98. var found = false;
  99. for(var i = 0;i < params.length;i++)
  100. {
  101. var param = params[i];
  102. var arr = param.split('=');
  103. if('page' == arr[0])
  104. {
  105. params[i] = 'page=1';
  106. }
  107. else if('sort' == arr[0])
  108. {
  109. params[i] = 'sort'+'='+ s_name;
  110. found = true;
  111. }
  112. else if('order' == arr[0])
  113. {
  114. params[i] = 'order'+'='+(arr[1] =='asc' ? 'desc' : 'asc');
  115. }
  116. }
  117. if(!found)
  118. {
  119. params.push('sort'+'='+ s_name);
  120. params.push('order=asc');
  121. }
  122. if(location.pathname.indexOf('/admin/')>-1)
  123. {
  124. location.assign(SITE_URL + '/admin/index.php?' + params.join('&'));
  125. return;
  126. }
  127. location.assign(SITE_URL + '/index.php?' + params.join('&'));
  128. });
  129. });