managebook.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. $(document).ready(function()
  2. {
  3. $('select[name*="type"]').change(function()
  4. {
  5. if($(this).val() == 'article')
  6. {
  7. $(this).closest('tr').find("select[name*='chapterType']").attr('disabled', true);
  8. }
  9. else
  10. {
  11. $(this).closest('tr').find("select[name*='chapterType']").attr('disabled', false);
  12. }
  13. })
  14. $('select[name*="type"]').each(function()
  15. {
  16. if($(this).val() == 'article')
  17. {
  18. $(this).closest('tr').find("select[name*='chapterType']").attr('disabled', true);
  19. }
  20. else
  21. {
  22. $(this).closest('tr').find("select[name*='chapterType']").attr('disabled', false);
  23. }
  24. })
  25. /* Sort up. */
  26. $(document).on('click', '.icon-arrow-up', function()
  27. {
  28. $(this).parents('tr').prev().before($(this).parents('tr'));
  29. $('tr .order').each(function(index,obj){$(this).val(index + 1);});
  30. });
  31. /* Sort down. */
  32. $(document).on('click', '.icon-arrow-down', function()
  33. {
  34. var hasNext = $(this).parents('tr').next().find('.icon-arrow-down').size() > 0;
  35. if(hasNext)
  36. {
  37. $(this).parents('tr').next().after($(this).parents('tr'));
  38. $('tr .order').each(function(index,obj){$(this).val(index + 1);});
  39. }
  40. });
  41. $('tr .order').each(function(index,obj){$(this).val(index + 1);});
  42. var setCatalogKey = function()
  43. {
  44. maxID = maxID
  45. $('[value=new]').each(function()
  46. {
  47. maxID ++;
  48. $(this).parents('.node').find('[id*=type]').attr('name', 'type[' + maxID + ']');
  49. $(this).parents('.node').find('[id*=chapterType]').attr('name', 'chapterType[' + maxID + ']');
  50. $(this).parents('.node').find('[id*=title]').attr('name', 'title[' + maxID + ']');
  51. $(this).parents('.node').find('[id*=keywords]').attr('name', 'keywords[' + maxID + ']');
  52. $(this).parents('.node').find('[id*=order]').attr('name', 'order[' + maxID + ']');
  53. $(this).attr('name', 'mode[' + maxID + ']');
  54. })
  55. }
  56. setCatalogKey();
  57. });