doc.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. var $treeTable;
  2. var M = {
  3. getParam : function(funcName, pid) {
  4. var url = BDY.url + funcName + "?doc=func";
  5. $.get(url, function(objResult) {
  6. if (!objResult.result) {
  7. alert(objResult.msg);
  8. } else {
  9. objResult.data.pid = pid;
  10. var html = tpl.render("table_tr", objResult.data);
  11. $treeTable.addChilds(html);
  12. }
  13. }, 'json');
  14. },
  15. removeRet : function(funcName, index) {
  16. var url = BDY.url + "doc/removeRet?action=" + funcName + '&code=' + index;
  17. $.get(url, function(objResult) {
  18. if (!objResult.result) {
  19. alert(objResult.msg);
  20. } else {
  21. alert(objResult.msg);
  22. $('[pid="' + funcName + '"]').find('div[id=' + index + ']').remove();
  23. }
  24. }, 'json');
  25. }
  26. };
  27. var C = {
  28. init : function() {
  29. var options = {
  30. column : 0,
  31. expandLevel : 2
  32. };
  33. $treeTable = $('#class_list').treeTable(options);
  34. $treeTable.on(BDY.click, "[controller=true]", function(event) {
  35. var target = event.target;
  36. var $tr = $(target).parents("tr");
  37. var pid = $tr.attr("id");
  38. // 判断是否加载过
  39. if (!$("tr[pId='" + pid + "']").length) {
  40. var funcName = $(target).text().trim();
  41. M.getParam(funcName, pid);
  42. }
  43. });
  44. C.initNav();
  45. },
  46. initNav : function() {
  47. $(document).on(BDY.click, '[role=presentation]', function() {
  48. var $this = $(this);
  49. $this.siblings().removeClass('active');
  50. $this.addClass('active');
  51. var i = $this.text().trim();
  52. var $parentDiv = $this.parent().next();
  53. $parentDiv.find('div').hide();
  54. $parentDiv.find('div[id="' + i + '"]').show();
  55. });
  56. $(document).on(BDY.click, 'a[xIndex]', function() {
  57. var $this = $(this);
  58. var index = $this.attr('xIndex');
  59. var funcName = $this.parents('tr[pid]').attr('pid');
  60. // funcName = funcName.replace('_', '/');
  61. M.removeRet(funcName, index);
  62. });
  63. }
  64. };
  65. $(function() {
  66. C.init();
  67. })