12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- var $treeTable;
- var M = {
- getParam : function(funcName, pid) {
- var url = BDY.url + funcName + "?doc=func";
- $.get(url, function(objResult) {
- if (!objResult.result) {
- alert(objResult.msg);
- } else {
- objResult.data.pid = pid;
- var html = tpl.render("table_tr", objResult.data);
- $treeTable.addChilds(html);
- }
- }, 'json');
- },
- removeRet : function(funcName, index) {
- var url = BDY.url + "doc/removeRet?action=" + funcName + '&code=' + index;
- $.get(url, function(objResult) {
- if (!objResult.result) {
- alert(objResult.msg);
- } else {
- alert(objResult.msg);
- $('[pid="' + funcName + '"]').find('div[id=' + index + ']').remove();
- }
- }, 'json');
- }
- };
- var C = {
- init : function() {
- var options = {
- column : 0,
- expandLevel : 2
- };
-
- $treeTable = $('#class_list').treeTable(options);
- $treeTable.on(BDY.click, "[controller=true]", function(event) {
- var target = event.target;
- var $tr = $(target).parents("tr");
- var pid = $tr.attr("id");
- // 判断是否加载过
- if (!$("tr[pId='" + pid + "']").length) {
- var funcName = $(target).text().trim();
- M.getParam(funcName, pid);
- }
- });
-
- C.initNav();
- },
- initNav : function() {
- $(document).on(BDY.click, '[role=presentation]', function() {
- var $this = $(this);
- $this.siblings().removeClass('active');
- $this.addClass('active');
-
- var i = $this.text().trim();
- var $parentDiv = $this.parent().next();
- $parentDiv.find('div').hide();
- $parentDiv.find('div[id="' + i + '"]').show();
- });
-
- $(document).on(BDY.click, 'a[xIndex]', function() {
- var $this = $(this);
- var index = $this.attr('xIndex');
- var funcName = $this.parents('tr[pid]').attr('pid');
- // funcName = funcName.replace('_', '/');
-
- M.removeRet(funcName, index);
- });
- }
- };
- $(function() {
- C.init();
- })
|