This commit is contained in:
Van 2014-11-01 12:05:52 +08:00
parent 7cb70347bf
commit 9c1d5b09a0
5 changed files with 114 additions and 52 deletions

View File

@ -1,6 +1,6 @@
/* start icon */
@font-face {
1 @font-face {
font-family: 'icomoon';
src: url('fonts/icomoon.eot?35cb2z');
src: url('fonts/icomoon.eot?#iefix35cb2z') format('embedded-opentype'), url('fonts/icomoon.woff?35cb2z') format('woff'), url('fonts/icomoon.ttf?35cb2z') format('truetype'), url('fonts/icomoon.svg?35cb2z#icomoon') format('svg');

View File

@ -37,7 +37,7 @@
"closeIconHover": "dialog-close-icon-hover",
"title": "dialog-title"
}
}
};
};
$.extend(Dialog.prototype, {
@ -174,6 +174,10 @@
$.dialog._close(id, settings);
}
});
if (typeof settings.afterInit === "function") {
settings.afterInit();
}
},
_bindMove: function (id, className) {
$("#" + id + "Dialog ." + className).mousedown(function (event) {

View File

@ -2,6 +2,32 @@ var editors = {
data: [],
tabs: {},
init: function () {
$("#dialogCloseEditor").dialog({
"modal": true,
"height": 26,
"width": 260,
"title": config.label.tip,
"hideFooter": true,
"afterInit": function () {
$("#dialogCloseEditor button.save").click(function () {
var i = $("#dialogCloseEditor").data("index");
wide.fmt(tree.fileTree.getNodeByTId(editors.data[i].id).path, editors.data[i].editor);
editors.tabs.del(editors.data[i].id);
$("#dialogCloseEditor").dialog("close");
});
$("#dialogCloseEditor button.discard").click(function () {
$("#dialogCloseEditor").dialog("close");
});
$("#dialogCloseEditor button.cancel").click(function () {
var i = $("#dialogCloseEditor").data("index");
editors.tabs.del(editors.data[i].id);
$("#dialogCloseEditor").dialog("close");
});
}
});
editors.tabs = new Tabs({
id: ".edit-panel",
clickAfter: function (id) {
@ -23,6 +49,26 @@ var editors = {
wide.curEditor.focus();
},
removeBefore: function (id) {
if (id === 'startPage') { // 当前关闭的 tab 是起始页
return false;
}
// 移除编辑器
for (var i = 0, ii = editors.data.length; i < ii; i++) {
if (editors.data[i].id === id) {
if (editors.data[i].editor.doc.isClean()) {
return true;
} else {
$("#dialogCloseEditor").dialog("open");
$("#dialogCloseEditor").data("index", i);
return false;
}
break;
}
}
},
removeAfter: function (id, nextId) {
if (id === 'startPage') { // 当前关闭的 tab 是起始页
return false;
@ -31,8 +77,6 @@ var editors = {
// 移除编辑器
for (var i = 0, ii = editors.data.length; i < ii; i++) {
if (editors.data[i].id === id) {
wide.fmt(tree.fileTree.getNodeByTId(editors.data[i].id).path, editors.data[i].editor);
editors.data.splice(i, 1);
break;
}
@ -81,7 +125,7 @@ var editors = {
});
this._initCodeMirrorHotKeys();
this.openStartPage()
this.openStartPage();
},
openStartPage: function () {
var dateFormat = function (time, fmt) {
@ -136,7 +180,7 @@ var editors = {
+ article.articlePermalink + "'>"
+ article.articleTitle + "</a>&nbsp; <span class='date'>"
+ dateFormat(article.articleCreateTime, 'yyyy-MM-dd hh:mm');
+"</span></li>"
+"</span></li>";
}
$("#startPage .news").html(listHTML + "</ul>");

View File

@ -22,8 +22,16 @@ $.extend(Tabs.prototype, {
});
obj._$tabs.on("click", ".ico-close", function (event) {
var id = $(this).parent().data("index");
var id = $(this).parent().data("index"),
isRemove = true;
if (typeof obj.removeBefore === 'function') {
isRemove = obj.removeBefore(id);
}
if (isRemove) {
_that.del(id);
}
event.stopPropagation();
});
},
@ -65,6 +73,7 @@ $.extend(Tabs.prototype, {
$tabs = this.obj._$tabs,
stack = this.obj._stack,
prevId = null;
$tabs.children("div[data-index='" + id + "']").remove();
$tabsPanel.children("div[data-index='" + id + "']").remove();

View File

@ -222,10 +222,15 @@
<input placeholder="{{.i18n.keyword}}" />
<input placeholder="{{.i18n.file_format}}" />
</div>
<div id="dialogCloseEditor" class="dialog-form fn-none">
<button class="save">save</button>
<button class="discard">discard</button>
<button class="cancel">cancel</button>
</div>
<script>
var config = {
"pathSeparator": {{.pathSeparator}},
"latestSessionContent": {{.latestSessionContent}},
"pathSeparator": '{{.pathSeparator}}',
"latestSessionContent": '{{.latestSessionContent}}',
"label": {
"restore_editor": "{{.i18n.restore_editor}}",
"max_editor": "{{.i18n.max_editor}}",
@ -263,7 +268,7 @@
function newWideRequest() {
var ret = {
sid: config.wideSessionId
}
};
return ret;
}