add project savable
This commit is contained in:
parent
170ac9ad02
commit
0d75fcd62f
@ -38,6 +38,7 @@ define(
|
||||
}
|
||||
$.getJSON('./src/fonteditor/data/empty.json', function(imported) {
|
||||
program.ttfmanager.set(imported);
|
||||
program.data.projectName = null;
|
||||
});
|
||||
},
|
||||
|
||||
@ -108,6 +109,7 @@ define(
|
||||
}
|
||||
else {
|
||||
program.ttfmanager.set(imported);
|
||||
program.data.projectName = null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -191,6 +193,7 @@ define(
|
||||
type: file.name.slice(file.name.lastIndexOf('.') + 1).toLowerCase(),
|
||||
success: function(imported) {
|
||||
program.ttfmanager.set(imported);
|
||||
program.data.projectName = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ define(
|
||||
|
||||
var clipboard = require('../clipboard');
|
||||
var lang = require('common/lang');
|
||||
var string = require('common/string');
|
||||
|
||||
return {
|
||||
|
||||
@ -41,6 +42,24 @@ define(
|
||||
program.ttfmanager.undo();
|
||||
}).on('redo', function(e) {
|
||||
program.ttfmanager.redo();
|
||||
}).on('save', function(e) {
|
||||
// 保存项目
|
||||
if (program.ttfmanager.get()) {
|
||||
if (program.data.projectName) {
|
||||
program.project.add(program.data.projectName, program.ttfmanager.get());
|
||||
program.ttfmanager.setState('new');
|
||||
}
|
||||
else {
|
||||
var name = '';
|
||||
if(name = window.prompt('请输入项目名称:')) {
|
||||
name = string.encodeHTML(name);
|
||||
var list = program.project.add(name, program.ttfmanager.get());
|
||||
program.projectViewer.show(list);
|
||||
program.data.projectName = name;
|
||||
program.ttfmanager.setState('new');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
program.projectViewer.on('open', function(e) {
|
||||
|
@ -112,6 +112,12 @@ define(
|
||||
e.stopPropagation();
|
||||
me.fire('redo');
|
||||
}
|
||||
// 保存
|
||||
else if (83 === e.keyCode && e.ctrlKey) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
me.fire('save');
|
||||
}
|
||||
// 取消选中
|
||||
else if (27 === e.keyCode) {
|
||||
e.stopPropagation();
|
||||
|
6
ttf.html
6
ttf.html
@ -9,9 +9,9 @@
|
||||
<body>
|
||||
|
||||
<section class="navbar navbar-inverse" role="navigation">
|
||||
<button data-action="new" type="button" class="btn btn-primary btn-sm">新建</button>
|
||||
<button data-action="open" type="button" class="btn btn-primary btn-sm">打开</button>
|
||||
<button data-action="import" type="button" class="btn btn-primary btn-sm">导入</button>
|
||||
<button data-action="new" type="button" class="btn btn-primary btn-sm" title="新建ttf字体文件">新建</button>
|
||||
<button data-action="open" type="button" class="btn btn-primary btn-sm" title="打开ttf,woff格式字体文件">打开</button>
|
||||
<button data-action="import" type="button" class="btn btn-primary btn-sm" title="导入ttf,woff,svg格式字体文件">导入</button>
|
||||
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">
|
||||
|
Loading…
x
Reference in New Issue
Block a user