managechapter.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. $(document).ready(function()
  2. {
  3. /* Sort up. */
  4. $(document).on('click', '.icon-arrow-up', function()
  5. {
  6. $(this).parents('tr').prev().before($(this).parents('tr'));
  7. $('tr .order').each(function(index,obj){$(this).val(index + 1);});
  8. });
  9. /* Sort down. */
  10. $(document).on('click', '.icon-arrow-down', function()
  11. {
  12. var hasNext = $(this).parents('tr').next().find('.icon-arrow-down').size() > 0;
  13. if(hasNext)
  14. {
  15. $(this).parents('tr').next().after($(this).parents('tr'));
  16. $('tr .order').each(function(index,obj){$(this).val(index + 1);});
  17. }
  18. });
  19. $('tr .order').each(function(index,obj){$(this).val(index + 1);});
  20. var setCatalogKey = function()
  21. {
  22. $('[value=new]').each(function()
  23. {
  24. maxID ++;
  25. $(this).parents('.node').find('[id*=type]').attr('name', 'type[' + maxID + ']');
  26. $(this).parents('.node').find('[id*=title]').attr('name', 'title[' + maxID + ']');
  27. $(this).parents('.node').find('[id*=keywords]').attr('name', 'keywords[' + maxID + ']');
  28. $(this).parents('.node').find('[id*=order]').attr('name', 'order[' + maxID + ']');
  29. $(this).attr('name', 'mode[' + maxID + ']');
  30. })
  31. }
  32. setCatalogKey();
  33. })