story.ui.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. $(document).off('click', '.batch-btn').on('click', '.batch-btn', function()
  2. {
  3. const dtable = zui.DTable.query($(this).target);
  4. const checkedList = dtable.$.getChecks();
  5. if(!checkedList.length) return;
  6. const url = $(this).data('url');
  7. const form = new FormData();
  8. checkedList.forEach((id) => form.append('storyIdList[]', id));
  9. if($(this).hasClass('ajax-btn'))
  10. {
  11. $.ajaxSubmit({url, data: form});
  12. }
  13. else
  14. {
  15. postAndLoadPage(url, form);
  16. }
  17. });
  18. /**
  19. * 对标题列进行重定义。
  20. * Redefine the title column.
  21. *
  22. * @param array result
  23. * @param array info
  24. * @access public
  25. * @return string|array
  26. */
  27. window.renderCell = function(result, info)
  28. {
  29. if(info.col.name == 'title' && result[0])
  30. {
  31. const story = info.row.data;
  32. if(story.shadow == 1) result[0].props.href += '#app=project';
  33. let html = '';
  34. let gradeLabel = '';
  35. if(showGrade || story.grade >= 2) gradeLabel = gradeGroup[story.type][story.grade]?.name;
  36. if(gradeLabel) html += "<span class='label gray-pale rounded-xl clip'>" + gradeLabel + "</span> ";
  37. if(story.color) result[0].props.style = 'color: ' + story.color;
  38. if(html) result.unshift({html});
  39. }
  40. return result;
  41. }
  42. $(document).off('click', '.switchButton').on('click', '.switchButton', function()
  43. {
  44. var storyViewType = $(this).attr('data-type');
  45. $.cookie.set('storyViewType', storyViewType, {expires:config.cookieLife, path:config.webRoot});
  46. loadCurrentPage();
  47. });