bottomGroup refactor

This commit is contained in:
Van 2014-11-06 11:58:55 +08:00
parent d0061b38b8
commit a44de44ded
6 changed files with 51 additions and 44 deletions

25
static/js/bottomGroup.js Normal file
View File

@ -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);
}
};

View File

@ -489,7 +489,7 @@ var editors = {
title = config.label.search_text;
}
if ($search.find("ul").length === 0) {
wide.searchTab = new Tabs({
bottomGroup.searchTab = new Tabs({
id: ".bottom-window-group .search",
removeAfter: function (id, prevId) {
if ($search.find("ul").length === 1) {
@ -533,7 +533,7 @@ var editors = {
$search.find(".tabs .first").text(title);
} else {
$search.find(".tabs").show();
wide.searchTab.add({
bottomGroup.searchTab.add({
"id": "search" + (new Date()).getTime(),
"title": title,
"content": searcHTML
@ -541,7 +541,7 @@ var editors = {
}
// focus
wide.bottomWindowTab.setCurrent("search");
bottomGroup.tabs.setCurrent("search");
windows.flowBottom();
$(".bottom-window-group .search").focus();
},

View File

@ -226,7 +226,7 @@ var hotkeys = {
if (event.ctrlKey === hotKeys.goOutPut.ctrlKey
&& event.which === hotKeys.goOutPut.which) { // Ctrl+4 焦点切换到输出窗口
wide.bottomWindowTab.setCurrent("output");
bottomGroup.tabs.setCurrent("output");
windows.flowBottom();
$(".bottom-window-group .output").focus();
@ -236,7 +236,7 @@ var hotkeys = {
}
if (event.ctrlKey === hotKeys.goSearch.ctrlKey
&& event.which === hotKeys.goSearch.which) { // Ctrl+5 焦点切换到搜索窗口
wide.bottomWindowTab.setCurrent("search");
bottomGroup.tabs.setCurrent("search");
windows.flowBottom();
$(".bottom-window-group .search").focus();
event.preventDefault();
@ -246,7 +246,7 @@ var hotkeys = {
if (event.ctrlKey === hotKeys.goNotification.ctrlKey
&& event.which === hotKeys.goNotification.which) { // Ctrl+6 焦点切换到通知窗口
wide.bottomWindowTab.setCurrent("notification");
bottomGroup.tabs.setCurrent("notification");
windows.flowBottom();
$(".bottom-window-group .notification").focus();
event.preventDefault();
@ -283,7 +283,7 @@ var hotkeys = {
break;
}
}
wide.bottomWindowTab.setCurrent(nextId);
bottomGroup.tabs.setCurrent(nextId);
$(".bottom-window-group ." + nextId).focus();
event.preventDefault();

View File

@ -1,7 +1,7 @@
var notification = {
init: function () {
$(".notification-count").click(function () {
wide.bottomWindowTab.setCurrent("notification");
bottomGroup.tabs.setCurrent("notification");
$(".bottom-window-group .notification").focus();
$(this).hide();
});

View File

@ -2,8 +2,6 @@ var wide = {
curNode: undefined,
curEditor: undefined,
curProcessId: undefined, // 当前正在运行的进程 idpid
bottomWindowTab: undefined,
searchTab: undefined,
_initDialog: function () {
$(".dialog-prompt > input").keyup(function (event) {
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);
},
_initBottomWindowGroup: function () {
this.bottomWindowTab = new Tabs({
id: ".bottom-window-group",
clickAfter: function (id) {
this._$tabsPanel.find("." + id).focus();
}
});
},
_initWS: function () {
var outputWS = new ReconnectingWebSocket(config.channel.output + '/output/ws?sid=' + config.wideSessionId);
outputWS.onopen = function () {
@ -359,7 +349,7 @@ var wide = {
switch (data.cmd) {
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;
break;
@ -374,17 +364,17 @@ var wide = {
case 'start-test':
case 'start-install':
case 'start-get':
wide.fillOutput(data.output);
bottomGroup.fillOutput(data.output);
break;
case 'go test':
case 'go install':
case 'go get':
wide.fillOutput($('.bottom-window-group .output > div').html() + data.output);
bottomGroup.fillOutput($('.bottom-window-group .output > div').html() + data.output);
break;
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) { // 说明编译有错误输出
for (var i = 0; i < data.lints.length; i++) {
@ -422,8 +412,6 @@ var wide = {
this._initWS();
this._initBottomWindowGroup();
// 点击隐藏弹出层
$("body").bind("mousedown", function (event) {
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 () {
wide.saveAllFiles();
@ -602,9 +585,7 @@ var wide = {
data: JSON.stringify(request),
dataType: "json",
beforeSend: function (data) {
$('.bottom-window-group .output > div').text('');
wide.bottomWindowTab.setCurrent("output");
windows.flowBottom();
bottomGroup.clearOutput();
},
success: function (data) {
}
@ -639,9 +620,7 @@ var wide = {
data: JSON.stringify(request),
dataType: "json",
beforeSend: function (data) {
$('.bottom-window-group .output > div').text('');
wide.bottomWindowTab.setCurrent("output");
windows.flowBottom();
bottomGroup.clearOutput();
},
success: function (data) {
$(".toolbars .ico-buildrun").addClass("ico-stop")
@ -671,9 +650,7 @@ var wide = {
data: JSON.stringify(request),
dataType: "json",
beforeSend: function (data) {
$('.bottom-window-group .output > div').text('');
wide.bottomWindowTab.setCurrent("output");
windows.flowBottom();
bottomGroup.clearOutput();
},
success: function (data) {
}
@ -700,9 +677,7 @@ var wide = {
data: JSON.stringify(request),
dataType: "json",
beforeSend: function (data) {
$('.bottom-window-group .output > div').text('');
wide.bottomWindowTab.setCurrent("output");
windows.flowBottom();
bottomGroup.clearOutput();
},
success: function (data) {
}
@ -729,9 +704,7 @@ var wide = {
data: JSON.stringify(request),
dataType: "json",
beforeSend: function (data) {
$('.bottom-window-group .output > div').text('');
wide.bottomWindowTab.setCurrent("output");
windows.flowBottom();
bottomGroup.clearOutput();
},
success: function (data) {
}
@ -830,4 +803,5 @@ $(document).ready(function () {
session.init();
editors.init();
windows.init();
bottomGroup.init();
});

View File

@ -173,6 +173,13 @@
<div class="bottom-window-group">
<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="current" data-index="output">
<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/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/bottomGroup.js?{{.conf.StaticResourceVersion}}"></script>
</body>
</html>