This commit is contained in:
Liang Ding 2014-09-19 19:21:27 +08:00
commit aceddad8ad
9 changed files with 132 additions and 29 deletions

View File

@ -0,0 +1 @@
111111111111111111111111111

View File

@ -0,0 +1 @@
222222222222222222222

View File

@ -252,3 +252,11 @@ ul {
width: 100%;
}
/* end output */
/* start footer */
.notification-count {
float: right;
display: none;
cursor: pointer;
}
/* end footer */

View File

@ -35,6 +35,20 @@ var hotkeys = {
shiftKey: false,
which: 54
},
// Ctrl+Q 关闭当前编辑器
closeCurEditor: {
ctrlKey: true,
altKey: false,
shiftKey: false,
which: 81
},
// Ctrl+D 窗口组切换
changeEditor: {
ctrlKey: true,
altKey: false,
shiftKey: false,
which: 68
},
// F6 构建并运行
buildRun: {
ctrlKey: false,
@ -196,7 +210,7 @@ var hotkeys = {
return;
}
if (event.ctrlKey === hotKeys.goNotification.ctrlKey
&& event.which === hotKeys.goNotification.which) { // Ctrl+6 焦点切换到通知窗口
wide.bottomWindowTab.setCurrent("notification");
@ -206,6 +220,69 @@ var hotkeys = {
return;
}
if (event.ctrlKey === hotKeys.closeCurEditor.ctrlKey
&& event.which === hotKeys.closeCurEditor.which) { // Ctrl+Q 关闭当前编辑器
if (editors.tabs.getCurrentId()) {
editors.tabs.del(editors.tabs.getCurrentId());
}
event.preventDefault();
return;
}
if (event.ctrlKey === hotKeys.changeEditor.ctrlKey
&& event.which === hotKeys.changeEditor.which) { // Ctrl+D 窗口组切换
if (document.activeElement.className === "notification"
|| document.activeElement.className === "output"
|| document.activeElement.className === "search") {
// 焦点在底部窗口组时,对底部进行切换
var tabs = ["output", "search", "notification"],
nextId = "";
for (var i = 0, ii = tabs.length; i < ii; i++) {
if (document.activeElement.className === tabs[i]) {
if (i < ii - 1) {
nextId = tabs[i + 1];
} else {
nextId = tabs[0];
}
break;
}
}
wide.bottomWindowTab.setCurrent(nextId);
$(".bottom-window-group ." + nextId).focus();
event.preventDefault();
return false;
}
if (editors.data.length > 1) {
var nextId = "";
for (var i = 0, ii = editors.data.length; i < ii; i++) {
if (editors.tabs.getCurrentId() === editors.data[i].id) {
if (i < ii - 1) {
nextId = editors.data[i + 1].id;
wide.curEditor = editors.data[i + 1].editor;
} else {
nextId = editors.data[0].id;
wide.curEditor = editors.data[0].editor;
}
break;
}
}
editors.tabs.setCurrent(nextId);
wide.curNode = tree.fileTree.getNodeByTId(nextId);
tree.fileTree.selectNode(wide.curNode);
wide.curEditor.focus();
}
event.preventDefault();
return false;
}
if (event.which === hotKeys.buildRun.which) { // F6 构建并运行
wide.run();
event.preventDefault();

View File

@ -1,28 +1,36 @@
var notificationWS = new WebSocket(config.channel.shell + '/notification/ws?sid=' + config.wideSessionId);
notificationWS.onopen = function() {
console.log('[notification onopen] connected');
};
notificationWS.onmessage = function(e) {
console.log('[notification onmessage]' + e.data);
var data = JSON.parse(e.data);
if ('init-notification' !== data.cmd) {
$('.bottom-window-group .notification').val(data.output);
}
};
notificationWS.onclose = function(e) {
console.log('[notification onclose] disconnected (' + e.code + ')');
delete notificationWS;
};
notificationWS.onerror = function(e) {
console.log('[notification onerror] ' + e);
};
var notification = {
init: function() {
}
};
$(".notification-count").click(function() {
wide.bottomWindowTab.setCurrent("notification");
$(".bottom-window-group .notification").focus();
$(this).hide();
});
$(document).ready(function() {
notification.init();
});
this._initWS();
},
_initWS: function() {
var notificationWS = new WebSocket(config.channel.shell + '/notification/ws?sid=' + config.wideSessionId);
notificationWS.onopen = function() {
console.log('[notification onopen] connected');
};
notificationWS.onmessage = function(e) {
var data = JSON.parse(e.data);
if ('init-notification' !== data.cmd) {
$(".notification-count").show();
$('.bottom-window-group .notification').text(
$('.bottom-window-group .notification').text() + data.output);
}
};
notificationWS.onclose = function(e) {
console.log('[notification onclose] disconnected (' + e.code + ')');
delete notificationWS;
};
notificationWS.onerror = function(e) {
console.log('[notification onerror] ' + e);
};
}
};

View File

@ -14,7 +14,9 @@ $.extend(Tabs.prototype, {
obj._$tabs.on("click", "div", function(event) {
var id = $(this).data("index");
_that.setCurrent(id);
obj.clickAfter(id);
if (typeof (obj.clickAfter) === "function") {
obj.clickAfter(id);
}
});
obj._$tabs.on("click", ".ico-close", function(event) {
@ -54,7 +56,7 @@ $.extend(Tabs.prototype, {
} else {
prevId = this.obj._prevId;
}
this.obj.removeAfter(id, prevId);
this.setCurrent(prevId);
},

View File

@ -252,6 +252,7 @@ var tree = {
editors.tabs.setCurrent(treeNode.tId);
wide.curNode = treeNode;
wide.curEditor = editors.data[i].editor;
wide.curEditor.focus();
return false;
}
}

View File

@ -74,7 +74,10 @@ var wide = {
},
_initBottomWindowGroup: function() {
this.bottomWindowTab = new Tabs({
id: ".bottom-window-group"
id: ".bottom-window-group",
clickAfter: function(id) {
this._$tabsPanel.find("." + id).focus();
}
});
},
init: function() {
@ -241,4 +244,5 @@ $(document).ready(function() {
tree.init();
menu.init();
hotkeys.init();
notification.init();
});

View File

@ -163,6 +163,7 @@
<div class="footer">
<span>|</span>
<span id="footer-cursor" style="float: right;"></span>
<span class="notification-count" title="you have unread notification">N</span>
</div>
<script type="text/javascript">