gxb-ide.js 2.92 KB

;(function(window){

    GxbIde = function(){
        // this.init.apply(this, arguments);
    }

    // 储存一个树结构和编辑器的对应关系
    var treeLinkEditor  = [],   // 缓存整个目录树结构和代码编辑器的关系
        treeData        = {},   // 缓存目录树返回结果
        mainPath,               // 运行编译时候需要知道当前是哪个文件
        fileList,               // 有值的文件数据结构
        treeObj;                // 获取ztree对象

    var config = {
        edit: {
            enable: true
            // editNameSelectAll: true
        },
        view: { 
            addHoverDom: addHoverDom,
            removeHoverDom: removeHoverDom,
            selectedMulti: false,
            showLine: false
        },
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            beforeClick: beforeClick
        }
    };

    function beforeClick(treeId, treeNodes) {
        console.log('567890')
        console.log('点击了 ' + treeNodes.name);
        console.log('点击了 ' + treeNodes.isParent);

    }

    function addHoverDom(treeId, treeNodes) {
        // console.info('addHoverDom');
        // 修复第一个文件夹
        if(treeNode.isParent){
            $('a[title="'+ treeNode.name +'"]').find("#" + treeId + "_" + treeNode.id + "_edit").hide();
            return false;
        }

        // 不知道为什么 ztree 最后一项不显示编辑按钮 
        // 只能通过改变参数的值来让它显示编辑按钮
        if(treeNode.isLastNode){
            treeNode.isLastNode = false;
        }
    }

    function removeHoverDom(treeId, treeNodes){
        
    }

    // 初始化目录:增、删、改文件,文件夹目录结构
    var Dir = {
        treeData: {},   
        init: function(){
            console.log('Dir');
        },
        buildTree: function(select, treeData){
            $.fn.zTree.init(select, config, treeData);
        },
        getTreeData: function(){
            
        }
    }

    // 记录编写代码过程:输入代码、记录存放代码
    var Coding = {
        init: function(){
            console.log('Coding');
        }
    }  

    // 工具栏:负责编译,展示头部信息功能
    var ToolBox = {
        init: function(){
            console.log('Dir');
        }
    }    

    // 主题:IDE 主题
    var Theme = {
        init: function(){
            console.log('Theme');
        }
    }

    // 录制音频:录制、暂停、继续录制
    var Record = {
        init: function(){
            console.log('Record');
        }
    }


    GxbIde.ide = GxbIde.prototype = {
        constructor: GxbIde,
        init: function(){
            this.Coding.init()
        }
    }

    // 老师录制编辑
    GxbIde.ide.RecordIde = $.extend({ Coding, Dir, ToolBox, Theme, Record })


    window.GxbIde = GxbIde;

})(window)