bottomGroup refactor
This commit is contained in:
		
							parent
							
								
									d0061b38b8
								
							
						
					
					
						commit
						a44de44ded
					
				| 
						 | 
					@ -0,0 +1,25 @@
 | 
				
			||||||
 | 
					var bottomGroup = {
 | 
				
			||||||
 | 
					    tabs: undefined,
 | 
				
			||||||
 | 
					    searchTab: undefined,
 | 
				
			||||||
 | 
					    init: function () {
 | 
				
			||||||
 | 
					        this._initTabs();
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    clearOutput: function () {
 | 
				
			||||||
 | 
					        $('.bottom-window-group .output > div').text('');
 | 
				
			||||||
 | 
					        bottomGroup.tabs.setCurrent("output");
 | 
				
			||||||
 | 
					        windows.flowBottom();
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    _initTabs: function () {
 | 
				
			||||||
 | 
					        this.tabs = new Tabs({
 | 
				
			||||||
 | 
					            id: ".bottom-window-group",
 | 
				
			||||||
 | 
					            clickAfter: function (id) {
 | 
				
			||||||
 | 
					                this._$tabsPanel.find("." + id).focus();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    fillOutput: function (data) {
 | 
				
			||||||
 | 
					        var $output = $('.bottom-window-group .output');
 | 
				
			||||||
 | 
					        $output.find("div").html(data.replace(/\n/g, '<br/>'));
 | 
				
			||||||
 | 
					        $output.parent().scrollTop($output[0].scrollHeight);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -489,7 +489,7 @@ var editors = {
 | 
				
			||||||
            title = config.label.search_text;
 | 
					            title = config.label.search_text;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if ($search.find("ul").length === 0) {
 | 
					        if ($search.find("ul").length === 0) {
 | 
				
			||||||
            wide.searchTab = new Tabs({
 | 
					            bottomGroup.searchTab = new Tabs({
 | 
				
			||||||
                id: ".bottom-window-group .search",
 | 
					                id: ".bottom-window-group .search",
 | 
				
			||||||
                removeAfter: function (id, prevId) {
 | 
					                removeAfter: function (id, prevId) {
 | 
				
			||||||
                    if ($search.find("ul").length === 1) {
 | 
					                    if ($search.find("ul").length === 1) {
 | 
				
			||||||
| 
						 | 
					@ -533,7 +533,7 @@ var editors = {
 | 
				
			||||||
            $search.find(".tabs .first").text(title);
 | 
					            $search.find(".tabs .first").text(title);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $search.find(".tabs").show();
 | 
					            $search.find(".tabs").show();
 | 
				
			||||||
            wide.searchTab.add({
 | 
					            bottomGroup.searchTab.add({
 | 
				
			||||||
                "id": "search" + (new Date()).getTime(),
 | 
					                "id": "search" + (new Date()).getTime(),
 | 
				
			||||||
                "title": title,
 | 
					                "title": title,
 | 
				
			||||||
                "content": searcHTML
 | 
					                "content": searcHTML
 | 
				
			||||||
| 
						 | 
					@ -541,7 +541,7 @@ var editors = {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // focus
 | 
					        // focus
 | 
				
			||||||
        wide.bottomWindowTab.setCurrent("search");
 | 
					        bottomGroup.tabs.setCurrent("search");
 | 
				
			||||||
        windows.flowBottom();
 | 
					        windows.flowBottom();
 | 
				
			||||||
        $(".bottom-window-group .search").focus();
 | 
					        $(".bottom-window-group .search").focus();
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -226,7 +226,7 @@ var hotkeys = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (event.ctrlKey === hotKeys.goOutPut.ctrlKey
 | 
					            if (event.ctrlKey === hotKeys.goOutPut.ctrlKey
 | 
				
			||||||
                    && event.which === hotKeys.goOutPut.which) { // Ctrl+4 焦点切换到输出窗口   
 | 
					                    && event.which === hotKeys.goOutPut.which) { // Ctrl+4 焦点切换到输出窗口   
 | 
				
			||||||
                wide.bottomWindowTab.setCurrent("output");
 | 
					                bottomGroup.tabs.setCurrent("output");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                windows.flowBottom();
 | 
					                windows.flowBottom();
 | 
				
			||||||
                $(".bottom-window-group .output").focus();
 | 
					                $(".bottom-window-group .output").focus();
 | 
				
			||||||
| 
						 | 
					@ -236,7 +236,7 @@ var hotkeys = {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (event.ctrlKey === hotKeys.goSearch.ctrlKey
 | 
					            if (event.ctrlKey === hotKeys.goSearch.ctrlKey
 | 
				
			||||||
                    && event.which === hotKeys.goSearch.which) { // Ctrl+5 焦点切换到搜索窗口  
 | 
					                    && event.which === hotKeys.goSearch.which) { // Ctrl+5 焦点切换到搜索窗口  
 | 
				
			||||||
                wide.bottomWindowTab.setCurrent("search");
 | 
					                bottomGroup.tabs.setCurrent("search");
 | 
				
			||||||
                windows.flowBottom();
 | 
					                windows.flowBottom();
 | 
				
			||||||
                $(".bottom-window-group .search").focus();
 | 
					                $(".bottom-window-group .search").focus();
 | 
				
			||||||
                event.preventDefault();
 | 
					                event.preventDefault();
 | 
				
			||||||
| 
						 | 
					@ -246,7 +246,7 @@ var hotkeys = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (event.ctrlKey === hotKeys.goNotification.ctrlKey
 | 
					            if (event.ctrlKey === hotKeys.goNotification.ctrlKey
 | 
				
			||||||
                    && event.which === hotKeys.goNotification.which) { // Ctrl+6 焦点切换到通知窗口          
 | 
					                    && event.which === hotKeys.goNotification.which) { // Ctrl+6 焦点切换到通知窗口          
 | 
				
			||||||
                wide.bottomWindowTab.setCurrent("notification");
 | 
					                bottomGroup.tabs.setCurrent("notification");
 | 
				
			||||||
                windows.flowBottom();
 | 
					                windows.flowBottom();
 | 
				
			||||||
                $(".bottom-window-group .notification").focus();
 | 
					                $(".bottom-window-group .notification").focus();
 | 
				
			||||||
                event.preventDefault();
 | 
					                event.preventDefault();
 | 
				
			||||||
| 
						 | 
					@ -283,7 +283,7 @@ var hotkeys = {
 | 
				
			||||||
                            break;
 | 
					                            break;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    wide.bottomWindowTab.setCurrent(nextId);
 | 
					                    bottomGroup.tabs.setCurrent(nextId);
 | 
				
			||||||
                    $(".bottom-window-group ." + nextId).focus();
 | 
					                    $(".bottom-window-group ." + nextId).focus();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    event.preventDefault();
 | 
					                    event.preventDefault();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
var notification = {
 | 
					var notification = {
 | 
				
			||||||
    init: function () {
 | 
					    init: function () {
 | 
				
			||||||
        $(".notification-count").click(function () {
 | 
					        $(".notification-count").click(function () {
 | 
				
			||||||
            wide.bottomWindowTab.setCurrent("notification");
 | 
					            bottomGroup.tabs.setCurrent("notification");
 | 
				
			||||||
            $(".bottom-window-group .notification").focus();
 | 
					            $(".bottom-window-group .notification").focus();
 | 
				
			||||||
            $(this).hide();
 | 
					            $(this).hide();
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,8 +2,6 @@ var wide = {
 | 
				
			||||||
    curNode: undefined,
 | 
					    curNode: undefined,
 | 
				
			||||||
    curEditor: undefined,
 | 
					    curEditor: undefined,
 | 
				
			||||||
    curProcessId: undefined, // 当前正在运行的进程 id(pid)
 | 
					    curProcessId: undefined, // 当前正在运行的进程 id(pid)
 | 
				
			||||||
    bottomWindowTab: undefined,
 | 
					 | 
				
			||||||
    searchTab: undefined,
 | 
					 | 
				
			||||||
    _initDialog: function () {
 | 
					    _initDialog: function () {
 | 
				
			||||||
        $(".dialog-prompt > input").keyup(function (event) {
 | 
					        $(".dialog-prompt > input").keyup(function (event) {
 | 
				
			||||||
            var $okBtn = $(this).closest(".dialog-main").find(".dialog-footer > button:eq(0)");
 | 
					            var $okBtn = $(this).closest(".dialog-main").find(".dialog-footer > button:eq(0)");
 | 
				
			||||||
| 
						 | 
					@ -323,14 +321,6 @@ var wide = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $(".bottom-window-group > .tabs-panel > div > div").height(bottomH - 20);
 | 
					        $(".bottom-window-group > .tabs-panel > div > div").height(bottomH - 20);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    _initBottomWindowGroup: function () {
 | 
					 | 
				
			||||||
        this.bottomWindowTab = new Tabs({
 | 
					 | 
				
			||||||
            id: ".bottom-window-group",
 | 
					 | 
				
			||||||
            clickAfter: function (id) {
 | 
					 | 
				
			||||||
                this._$tabsPanel.find("." + id).focus();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    _initWS: function () {
 | 
					    _initWS: function () {
 | 
				
			||||||
        var outputWS = new ReconnectingWebSocket(config.channel.output + '/output/ws?sid=' + config.wideSessionId);
 | 
					        var outputWS = new ReconnectingWebSocket(config.channel.output + '/output/ws?sid=' + config.wideSessionId);
 | 
				
			||||||
        outputWS.onopen = function () {
 | 
					        outputWS.onopen = function () {
 | 
				
			||||||
| 
						 | 
					@ -359,7 +349,7 @@ var wide = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            switch (data.cmd) {
 | 
					            switch (data.cmd) {
 | 
				
			||||||
                case 'run': // 正在运行
 | 
					                case 'run': // 正在运行
 | 
				
			||||||
                    wide.fillOutput($('.bottom-window-group .output > div').html() + data.output);
 | 
					                    bottomGroup.fillOutput($('.bottom-window-group .output > div').html() + data.output);
 | 
				
			||||||
                    wide.curProcessId = data.pid;
 | 
					                    wide.curProcessId = data.pid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
| 
						 | 
					@ -374,17 +364,17 @@ var wide = {
 | 
				
			||||||
                case 'start-test':
 | 
					                case 'start-test':
 | 
				
			||||||
                case 'start-install':
 | 
					                case 'start-install':
 | 
				
			||||||
                case 'start-get':
 | 
					                case 'start-get':
 | 
				
			||||||
                    wide.fillOutput(data.output);
 | 
					                    bottomGroup.fillOutput(data.output);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case 'go test':
 | 
					                case 'go test':
 | 
				
			||||||
                case 'go install':
 | 
					                case 'go install':
 | 
				
			||||||
                case 'go get':
 | 
					                case 'go get':
 | 
				
			||||||
                    wide.fillOutput($('.bottom-window-group .output > div').html() + data.output);
 | 
					                    bottomGroup.fillOutput($('.bottom-window-group .output > div').html() + data.output);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case 'build':
 | 
					                case 'build':
 | 
				
			||||||
                    wide.fillOutput($('.bottom-window-group .output > div').html() + data.output);
 | 
					                    bottomGroup.fillOutput($('.bottom-window-group .output > div').html() + data.output);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (data.lints) { // 说明编译有错误输出            
 | 
					                    if (data.lints) { // 说明编译有错误输出            
 | 
				
			||||||
                        for (var i = 0; i < data.lints.length; i++) {
 | 
					                        for (var i = 0; i < data.lints.length; i++) {
 | 
				
			||||||
| 
						 | 
					@ -422,8 +412,6 @@ var wide = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this._initWS();
 | 
					        this._initWS();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this._initBottomWindowGroup();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 点击隐藏弹出层
 | 
					        // 点击隐藏弹出层
 | 
				
			||||||
        $("body").bind("mousedown", function (event) {
 | 
					        $("body").bind("mousedown", function (event) {
 | 
				
			||||||
            if (!(event.target.id === "dirRMenu" || $(event.target).closest("#dirRMenu").length > 0)) {
 | 
					            if (!(event.target.id === "dirRMenu" || $(event.target).closest("#dirRMenu").length > 0)) {
 | 
				
			||||||
| 
						 | 
					@ -573,11 +561,6 @@ var wide = {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    fillOutput: function (data) {
 | 
					 | 
				
			||||||
        var $output = $('.bottom-window-group .output');
 | 
					 | 
				
			||||||
        $output.find("div").html(data.replace(/\n/g, '<br/>'));
 | 
					 | 
				
			||||||
        $output.parent().scrollTop($output[0].scrollHeight);
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    // 构建.
 | 
					    // 构建.
 | 
				
			||||||
    build: function () {
 | 
					    build: function () {
 | 
				
			||||||
        wide.saveAllFiles();
 | 
					        wide.saveAllFiles();
 | 
				
			||||||
| 
						 | 
					@ -602,9 +585,7 @@ var wide = {
 | 
				
			||||||
            data: JSON.stringify(request),
 | 
					            data: JSON.stringify(request),
 | 
				
			||||||
            dataType: "json",
 | 
					            dataType: "json",
 | 
				
			||||||
            beforeSend: function (data) {
 | 
					            beforeSend: function (data) {
 | 
				
			||||||
                $('.bottom-window-group .output > div').text('');
 | 
					                bottomGroup.clearOutput();
 | 
				
			||||||
                wide.bottomWindowTab.setCurrent("output");
 | 
					 | 
				
			||||||
                windows.flowBottom();
 | 
					 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            success: function (data) {
 | 
					            success: function (data) {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -639,9 +620,7 @@ var wide = {
 | 
				
			||||||
            data: JSON.stringify(request),
 | 
					            data: JSON.stringify(request),
 | 
				
			||||||
            dataType: "json",
 | 
					            dataType: "json",
 | 
				
			||||||
            beforeSend: function (data) {
 | 
					            beforeSend: function (data) {
 | 
				
			||||||
                $('.bottom-window-group .output > div').text('');
 | 
					                bottomGroup.clearOutput();
 | 
				
			||||||
                wide.bottomWindowTab.setCurrent("output");
 | 
					 | 
				
			||||||
                windows.flowBottom();
 | 
					 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            success: function (data) {
 | 
					            success: function (data) {
 | 
				
			||||||
                $(".toolbars .ico-buildrun").addClass("ico-stop")
 | 
					                $(".toolbars .ico-buildrun").addClass("ico-stop")
 | 
				
			||||||
| 
						 | 
					@ -671,9 +650,7 @@ var wide = {
 | 
				
			||||||
            data: JSON.stringify(request),
 | 
					            data: JSON.stringify(request),
 | 
				
			||||||
            dataType: "json",
 | 
					            dataType: "json",
 | 
				
			||||||
            beforeSend: function (data) {
 | 
					            beforeSend: function (data) {
 | 
				
			||||||
                $('.bottom-window-group .output > div').text('');
 | 
					                bottomGroup.clearOutput();
 | 
				
			||||||
                wide.bottomWindowTab.setCurrent("output");
 | 
					 | 
				
			||||||
                windows.flowBottom();
 | 
					 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            success: function (data) {
 | 
					            success: function (data) {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -700,9 +677,7 @@ var wide = {
 | 
				
			||||||
            data: JSON.stringify(request),
 | 
					            data: JSON.stringify(request),
 | 
				
			||||||
            dataType: "json",
 | 
					            dataType: "json",
 | 
				
			||||||
            beforeSend: function (data) {
 | 
					            beforeSend: function (data) {
 | 
				
			||||||
                $('.bottom-window-group .output > div').text('');
 | 
					                bottomGroup.clearOutput();
 | 
				
			||||||
                wide.bottomWindowTab.setCurrent("output");
 | 
					 | 
				
			||||||
                windows.flowBottom();
 | 
					 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            success: function (data) {
 | 
					            success: function (data) {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -729,9 +704,7 @@ var wide = {
 | 
				
			||||||
            data: JSON.stringify(request),
 | 
					            data: JSON.stringify(request),
 | 
				
			||||||
            dataType: "json",
 | 
					            dataType: "json",
 | 
				
			||||||
            beforeSend: function (data) {
 | 
					            beforeSend: function (data) {
 | 
				
			||||||
                $('.bottom-window-group .output > div').text('');
 | 
					                bottomGroup.clearOutput();
 | 
				
			||||||
                wide.bottomWindowTab.setCurrent("output");
 | 
					 | 
				
			||||||
                windows.flowBottom();
 | 
					 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            success: function (data) {
 | 
					            success: function (data) {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -830,4 +803,5 @@ $(document).ready(function () {
 | 
				
			||||||
    session.init();
 | 
					    session.init();
 | 
				
			||||||
    editors.init();
 | 
					    editors.init();
 | 
				
			||||||
    windows.init();
 | 
					    windows.init();
 | 
				
			||||||
 | 
					    bottomGroup.init();
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
| 
						 | 
					@ -173,6 +173,13 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <div class="bottom-window-group">
 | 
					            <div class="bottom-window-group">
 | 
				
			||||||
                <span title="{{.i18n.min}}" class="font-ico ico-min"></span>
 | 
					                <span title="{{.i18n.min}}" class="font-ico ico-min"></span>
 | 
				
			||||||
 | 
					                <div class="frame">
 | 
				
			||||||
 | 
					                    <ul>
 | 
				
			||||||
 | 
					                        <li onclick="editors.close()" title="{{.i18n.close}}">
 | 
				
			||||||
 | 
					                            <span>{{.i18n.close}}</span>
 | 
				
			||||||
 | 
					                        </li>   
 | 
				
			||||||
 | 
					                    </ul>
 | 
				
			||||||
 | 
					                </div>
 | 
				
			||||||
                <div class="tabs">
 | 
					                <div class="tabs">
 | 
				
			||||||
                    <div class="current" data-index="output">
 | 
					                    <div class="current" data-index="output">
 | 
				
			||||||
                        <span title="{{.i18n.output}}">{{.i18n.output}}</span>
 | 
					                        <span title="{{.i18n.output}}">{{.i18n.output}}</span>
 | 
				
			||||||
| 
						 | 
					@ -340,5 +347,6 @@
 | 
				
			||||||
        <script type="text/javascript" src="{{.conf.StaticServer}}/static/js/menu.js?{{.conf.StaticResourceVersion}}"></script>
 | 
					        <script type="text/javascript" src="{{.conf.StaticServer}}/static/js/menu.js?{{.conf.StaticResourceVersion}}"></script>
 | 
				
			||||||
        <script type="text/javascript" src="{{.conf.StaticServer}}/static/js/windows.js?{{.conf.StaticResourceVersion}}"></script>
 | 
					        <script type="text/javascript" src="{{.conf.StaticServer}}/static/js/windows.js?{{.conf.StaticResourceVersion}}"></script>
 | 
				
			||||||
        <script type="text/javascript" src="{{.conf.StaticServer}}/static/js/hotkeys.js?{{.conf.StaticResourceVersion}}"></script>
 | 
					        <script type="text/javascript" src="{{.conf.StaticServer}}/static/js/hotkeys.js?{{.conf.StaticResourceVersion}}"></script>
 | 
				
			||||||
 | 
					        <script type="text/javascript" src="{{.conf.StaticServer}}/static/js/bottomGroup.js?{{.conf.StaticResourceVersion}}"></script>
 | 
				
			||||||
    </body>
 | 
					    </body>
 | 
				
			||||||
</html>
 | 
					</html>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue