browse.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. $(document).ready(function()
  2. {
  3. /* expand active tree. */
  4. $('#' + window.category).parent().addClass('active');
  5. $('.tree').tree('expandSelect', '.active');
  6. if(typeof window.label !== undefined && window.label)
  7. {
  8. $('#subNavbar .nav li').removeClass('active');
  9. if(config.requestType == 'GET')
  10. {
  11. $("#subNavbar .nav li a[href*=browse][href*='label\=" + window.label + "']").parent('li').addClass('active');
  12. }
  13. else
  14. {
  15. $("#subNavbar .nav li a[href*=browse][href*='browse-" + window.label + ".html']").parent('li').addClass('active');
  16. }
  17. }
  18. if(window.mode == 'search') $('#subNavbar .nav #bysearchTab').click();
  19. if($('#searchTab').length == 1) $('#subNavbar .nav').append($('#searchTab'));
  20. $('.toggleTreeMenu').click(function()
  21. {
  22. var text = $(this).text();
  23. var type = $(this).data('type');
  24. $('.currentMenu').html(text + "<span class='caret'></span>");
  25. $('.treeMenuBox').hide();
  26. $('.treeMenuBox#' + type + 'Box').show();
  27. });
  28. $(document).on('click', 'td.child .addItem', function()
  29. {
  30. var child = $(this).parents('table').data('child');
  31. $(this).closest('tr').after(window.itemRows[child].replace(/KEY/g, window.childKey));
  32. initSelect($(this).closest('tr').next().find('.picker-select'));
  33. $(this).closest('tr').next().find('.form-date, .form-datetime').datetimepicker(
  34. {
  35. language: config.clientLang,
  36. weekStart: 1,
  37. todayBtn: 1,
  38. autoclose: 1,
  39. todayHighlight: 1,
  40. startView: 2,
  41. minView: 2,
  42. forceParse: 0,
  43. format: 'yyyy-mm-dd'
  44. });
  45. });
  46. $(document).on('click', 'td.child .delItem', function()
  47. {
  48. if($(this).parents('.table-child').find('tr').size() > 1)
  49. {
  50. $(this).closest('tr').remove();
  51. }
  52. else
  53. {
  54. $(this).closest('tr').find('input,select,textarea').val('');
  55. }
  56. })
  57. $('.reloadPage').click(function()
  58. {
  59. url = $(this).attr('href');
  60. $.getJSON(url, function(response)
  61. {
  62. if(response.message)
  63. {
  64. bootbox.alert(response.message, function()
  65. {
  66. if(response.locate)
  67. {
  68. location.href = response.locate;
  69. return false;
  70. }
  71. location.reload();
  72. });
  73. }
  74. else
  75. {
  76. if(response.locate)
  77. {
  78. location.href = response.locate;
  79. return false;
  80. }
  81. location.reload();
  82. }
  83. });
  84. return false;
  85. });
  86. })