Tab 上面加上右键菜单(关闭、关闭其他、关闭所有)

This commit is contained in:
Van 2014-11-05 16:41:53 +08:00
parent d6caae9252
commit 7652d9d459
7 changed files with 70 additions and 8 deletions

View File

@ -115,5 +115,7 @@
"sing_up_error": "Sign Up Error",
"user_name_ruler": "Username only by az, AZ, 0-9, _ consisting of a length of 16",
"password_no_match": "Password doesn't match the confirmation",
"discard": "Discard"
"discard": "Discard",
"close": "Close",
"close_other": "Close Other"
}

View File

@ -115,5 +115,7 @@
"sing_up_error": "登録に失敗しました",
"user_name_ruler": "16の長さからなる_ AZ、AZ、0-9、によってユーザ名のみ",
"password_no_match": "一貫性のないパスワード入力",
"discard": "あきらめる"
"discard": "あきらめる",
"close": "クローズ",
"close_other": "閉じるその他"
}

View File

@ -115,5 +115,7 @@
"sing_up_error": "注册失败",
"user_name_ruler": "用户名只能由 a-z, A-Z, 0-9, _ 组成长度为16",
"password_no_match": "密码输入不一致",
"discard": "放弃"
"discard": "放弃",
"close": "关闭",
"close_other": "关闭其它"
}

View File

@ -115,5 +115,7 @@
"sing_up_error": "註冊失敗",
"user_name_ruler": "用戶名只能由az, AZ, 0-9, _ 組成長度為16",
"password_no_match": "密碼輸入不一致",
"discard": "放棄"
"discard": "放棄",
"close": "關閉",
"close_other": "關閉其它"
}

View File

@ -1,6 +1,24 @@
var editors = {
data: [],
tabs: {},
close: function () {
$(".edit-panel .tabs > div[data-index=" + $(".edit-panel .frame").data("index") + "]").find(".ico-close").click();
},
closeOther: function () {
var currentIndex = $(".edit-panel .frame").data("index");
// 设置全部关闭标识
var removeData = [];
$(".edit-panel .tabs > div").each(function (i) {
if (currentIndex !== $(this).data("index")) {
removeData.push($(this).data("index"));
}
});
var firstIndex = removeData.splice(0, 1);
$("#dialogCloseEditor").data("removeData", removeData);
// 开始关闭
$(".edit-panel .tabs > div[data-index=" + firstIndex + "]").find(".ico-close").click();
},
_removeAllMarker: function () {
var removeData = $("#dialogCloseEditor").data("removeData");
if (removeData && removeData.length > 0) {
@ -9,6 +27,28 @@ var editors = {
$(".edit-panel .tabs > div[data-index=" + removeIndex + "] .ico-close").click();
}
},
_initClose: function () {
// 关闭、关闭其他、关闭所有
$(".edit-panel").on("mousedown", '.tabs > div', function (event) {
event.stopPropagation();
if (event.button === 0) { // 左键
$(".edit-panel .frame").hide();
return false;
}
// event.button === 2 右键
var left = event.screenX;
if ($(".side").css("left") === "auto" || $(".side").css("left") === "0px") {
left = event.screenX - $(".side").width();
}
$(".edit-panel .frame").show().css({
"left": left + "px",
"top": "21px"
}).data('index', $(this).data("index"));
return false;
});
},
init: function () {
$("#dialogCloseEditor").dialog({
"modal": true,
@ -152,6 +192,7 @@ var editors = {
this._initCodeMirrorHotKeys();
this.openStartPage();
this._initClose();
},
openStartPage: function () {
var dateFormat = function (time, fmt) {

View File

@ -154,6 +154,19 @@
<span onclick="wide.fmt(editors.getCurrentPath(), wide.curEditor)" class="ico-format font-ico" title="{{.i18n.format}}"></span>
<span class="font-ico ico-max" onclick="windows.maxEditor()" title="{{.i18n.max_editor}}"></span>
</div>
<div class="frame">
<ul>
<li onclick="editors.close()" title="{{.i18n.close}}">
<span>{{.i18n.close}}</span>
</li>
<li onclick="wide.closeAllFiles()" title="{{.i18n.close_all_files}}">
<span>{{.i18n.close_all_files}}</span>
</li>
<li onclick="editors.closeOther()" title="{{.i18n.close_other}}">
<span>{{.i18n.close_other}}</span>
</li>
</ul>
</div>
<div class="tabs"></div>
<div class="tabs-panel"></div>
</div>