切换,关闭,打开 tab,底部行列修改 & rename 时全选

This commit is contained in:
Van 2014-11-17 18:08:03 +08:00
parent 31ef718244
commit 8375ae1130
3 changed files with 23 additions and 10 deletions

View File

@ -12,7 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
*/
var editors = {
data: [],
@ -110,6 +110,7 @@ var editors = {
id: ".edit-panel",
clickAfter: function (id) {
if (id === 'startPage') {
$(".footer .cursor").text('');
return false;
}
@ -124,9 +125,12 @@ var editors = {
break;
}
}
wide.curEditor.setCursor(wide.curEditor.getCursor());
var cursor = wide.curEditor.getCursor();
wide.curEditor.setCursor(cursor);
wide.curEditor.focus();
$(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
},
removeBefore: function (id) {
if (id === 'startPage') { // 当前关闭的 tab 是起始页
@ -134,7 +138,6 @@ var editors = {
return true;
}
// 移除编辑器
for (var i = 0, ii = editors.data.length; i < ii; i++) {
if (editors.data[i].id === id) {
if (editors.data[i].editor.doc.isClean()) {
@ -180,6 +183,7 @@ var editors = {
tree.fileTree.cancelSelectedNode();
wide.curNode = undefined;
wide.curEditor = undefined;
$(".footer .cursor").text('');
return false;
}
@ -199,6 +203,9 @@ var editors = {
break;
}
}
var cursor = wide.curEditor.getCursor();
$(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
}
});
@ -570,6 +577,8 @@ var editors = {
cursor = CodeMirror.Pos(data.cursorLine - 1, data.cursorCh - 1);
}
$(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
for (var i = 0, ii = editors.data.length; i < ii; i++) {
if (editors.data[i].id === id) {
editors.tabs.setCurrent(id);
@ -583,7 +592,6 @@ var editors = {
editor.scrollTo(0, cursorCoords.top);
editor.focus();
return false;
}
}
@ -770,7 +778,6 @@ var editors = {
var cursor = cm.getCursor();
$(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
// TODO: 关闭 tab 的时候要重置
});
editor.on('focus', function (cm) {

View File

@ -250,6 +250,9 @@ var tree = {
wide.curNode = treeNode;
wide.curEditor = editors.data[i].editor;
wide.curEditor.focus();
var cursor = wide.curEditor.getCursor();
$(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
return false;
}
}

View File

@ -106,10 +106,13 @@ var wide = {
"okText": config.label.rename,
"cancelText": config.label.cancel,
"afterOpen": function () {
var index = wide.curNode.name.lastIndexOf(".");
$("#dialogRenamePrompt > input").val(wide.curNode.name.substring(0, index)).focus();
// TODO: 全选
var index = wide.curNode.name.lastIndexOf("."),
name = wide.curNode.name.substring(0, index);
if (index === -1) {
name = wide.curNode.name;
}
$("#dialogRenamePrompt").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled", true);
$("#dialogRenamePrompt > input").val(name).select().focus();
},
"ok": function () {
var name = $("#dialogRenamePrompt > input").val(),
@ -517,7 +520,7 @@ var wide = {
$workspace.data("value", $workspace.val());
$password.data("value", $password.val());
$locale.data("value", $locale.val());
var $okBtn = $("#dialogPreference").closest(".dialog-main").find(".dialog-footer > button:eq(0)");
$okBtn.prop("disabled", true);
}