add name setting
This commit is contained in:
parent
dd4f02c4a9
commit
03d4fcde8b
35
css/bootstrap.css
vendored
Normal file
35
css/bootstrap.css
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
.modal-dialog {
|
||||
margin-top: 100px;
|
||||
}
|
||||
.modal-header {
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px;
|
||||
background: #327EC0;
|
||||
color: #FFF;
|
||||
}
|
||||
.modal-header .close {
|
||||
margin-top: 3px;
|
||||
}
|
||||
.modal-header .modal-title {
|
||||
font-size: 14px;
|
||||
line-height: 25px;
|
||||
}
|
||||
.modal-footer {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.modal-body {
|
||||
min-height: 100px;
|
||||
}
|
||||
.modal-content {
|
||||
border-color: rgba(0, 0, 0, 0.5);
|
||||
-webkit-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
overflow: hidden;
|
||||
}
|
||||
.dropdown-menu a {
|
||||
cursor: pointer;
|
||||
}
|
||||
.input-group {
|
||||
margin-bottom: 10px;
|
||||
}
|
4
css/bootstrap.less
vendored
4
css/bootstrap.less
vendored
@ -42,3 +42,7 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.input-group {
|
||||
margin-bottom: 10px;
|
||||
}
|
@ -30,6 +30,9 @@
|
||||
.dropdown-menu a {
|
||||
cursor: pointer;
|
||||
}
|
||||
.input-group {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
body,
|
||||
html {
|
||||
margin: 0;
|
||||
|
@ -30,6 +30,9 @@
|
||||
.dropdown-menu a {
|
||||
cursor: pointer;
|
||||
}
|
||||
.input-group {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
body,
|
||||
html {
|
||||
margin: 0;
|
||||
@ -161,6 +164,8 @@ html {
|
||||
display: none;
|
||||
}
|
||||
.glyf-list {
|
||||
padding-bottom: 1000000px;
|
||||
margin-bottom: -1000000px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.glyf-list > .glyf-item {
|
||||
|
@ -35,7 +35,8 @@
|
||||
|
||||
|
||||
.glyf-list {
|
||||
|
||||
padding-bottom: 1000000px;
|
||||
margin-bottom: -1000000px;
|
||||
overflow: hidden;
|
||||
|
||||
>.glyf-item {
|
||||
|
64
src/fonteditor/dialog/setting-name.js
Normal file
64
src/fonteditor/dialog/setting-name.js
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @file setting-unicode.js
|
||||
* @author mengke01
|
||||
* @date
|
||||
* @description
|
||||
* 设置字体命名信息
|
||||
*/
|
||||
|
||||
define(
|
||||
function(require) {
|
||||
|
||||
var tpl = ''
|
||||
+ '<div class="input-group input-group-sm">'
|
||||
+ '<span class="input-group-addon">字体家族</span>'
|
||||
+ '<input data-field="fontFamily" type="text" class="form-control">'
|
||||
+ '</div>'
|
||||
+ '<div class="input-group input-group-sm">'
|
||||
+ '<span class="input-group-addon">字体子家族</span>'
|
||||
+ '<input data-field="fontSubFamily" type="text" class="form-control">'
|
||||
+ '</div>'
|
||||
+ '<div class="input-group input-group-sm">'
|
||||
+ '<span class="input-group-addon">完整字体名</span>'
|
||||
+ '<input data-field="fullName" type="text" class="form-control">'
|
||||
+ '</div>'
|
||||
+ '<div class="input-group input-group-sm">'
|
||||
+ '<span class="input-group-addon">版本</span>'
|
||||
+ '<input data-field="version" type="text" class="form-control">'
|
||||
+ '</div>'
|
||||
+ '<div class="input-group input-group-sm">'
|
||||
+ '<span class="input-group-addon">PostScript名称</span>'
|
||||
+ '<input data-field="postScriptName" type="text" class="form-control">'
|
||||
+ '</div>';
|
||||
|
||||
|
||||
return require('./setting').derive({
|
||||
|
||||
title: '命名信息',
|
||||
|
||||
getTpl: function() {
|
||||
return tpl;
|
||||
},
|
||||
|
||||
set: function(setting) {
|
||||
this.getDialog().find('[data-field]').each(function(i, item) {
|
||||
item = $(item);
|
||||
item.val(setting[item.attr('data-field')] || '');
|
||||
});
|
||||
},
|
||||
|
||||
validate: function() {
|
||||
var name = {};
|
||||
this.getDialog().find('[data-field]').each(function(i, item) {
|
||||
item = $(item);
|
||||
var val = item.val().trim();
|
||||
if (val) {
|
||||
name[item.attr('data-field')] = val;
|
||||
}
|
||||
});
|
||||
return name;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
);
|
@ -25,15 +25,16 @@ define(
|
||||
|
||||
return require('./setting').derive({
|
||||
|
||||
title: '设置代码点',
|
||||
|
||||
getTpl: function() {
|
||||
return tpl;
|
||||
},
|
||||
onConfirm: function() {
|
||||
|
||||
validate: function() {
|
||||
var unicode = $('#setting-text-unicode').val();
|
||||
if (unicode.match(/^\$[A-E0-9]+$/i)) {
|
||||
this.fire('change', {
|
||||
unicode: unicode
|
||||
});
|
||||
return this.setting = unicode;
|
||||
}
|
||||
else {
|
||||
alert('代码点设置不正确');
|
||||
|
@ -17,20 +17,17 @@ define(
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function Setting() {
|
||||
}
|
||||
function Setting(options) {
|
||||
|
||||
this.options = options || {};
|
||||
|
||||
/**
|
||||
* 初始化绑定事件
|
||||
*/
|
||||
Setting.prototype.preInit = function() {
|
||||
var dlg = $('#model-dialog');
|
||||
dlg.find('.modal-title').html(this.title);
|
||||
dlg.find('.modal-title').html(this.title || '设置');
|
||||
dlg.find('.modal-body').html(this.getTpl());
|
||||
|
||||
dlg.on('hidden.bs.modal', lang.bind(function (e) {
|
||||
if (dlg) {
|
||||
this.un();
|
||||
delete this.options;
|
||||
dlg.off('hidden.bs.modal');
|
||||
dlg.find('.btn-confirm').off('click');
|
||||
dlg = null;
|
||||
@ -38,11 +35,14 @@ define(
|
||||
}, this));
|
||||
|
||||
dlg.find('.btn-confirm').on('click', lang.bind(function() {
|
||||
if (false !== this.onConfirm()) {
|
||||
var setting = this.validate();
|
||||
if (false !== setting) {
|
||||
this.options.onChange && this.options.onChange.call(this, setting);
|
||||
dlg.modal('hide');
|
||||
}
|
||||
}, this));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取模板
|
||||
@ -54,21 +54,53 @@ define(
|
||||
};
|
||||
|
||||
/**
|
||||
* 确定事件
|
||||
* 获取dialog对象
|
||||
*
|
||||
* @return {boolean=} 是否关闭对话框
|
||||
* @return {Object} dialog对象
|
||||
*/
|
||||
Setting.prototype.onConfirm = function() {
|
||||
Setting.prototype.getDialog = function() {
|
||||
return $('#model-dialog');
|
||||
};
|
||||
|
||||
/**
|
||||
* 验证设置
|
||||
*
|
||||
* @return {boolean}
|
||||
*/
|
||||
Setting.prototype.validate = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 显示
|
||||
* @param {Object} setting 设置选项
|
||||
*/
|
||||
Setting.prototype.show = function() {
|
||||
Setting.prototype.show = function(setting) {
|
||||
$('#model-dialog').modal('show');
|
||||
this.set(setting);
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 设置设置选项
|
||||
*
|
||||
* @return {this}
|
||||
*/
|
||||
Setting.prototype.set = function(setting) {
|
||||
this.setting = setting;
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取设置选项
|
||||
*
|
||||
* @return {Object} 设置选项
|
||||
*/
|
||||
Setting.prototype.get = function() {
|
||||
return this.setting;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 注销
|
||||
*/
|
||||
@ -76,7 +108,6 @@ define(
|
||||
$('#model-dialog').modal('hide');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 派生一个setting
|
||||
*
|
||||
@ -87,14 +118,11 @@ define(
|
||||
|
||||
function Class() {
|
||||
Setting.apply(this, arguments);
|
||||
this.preInit();
|
||||
this.initialize && this.initialize();
|
||||
}
|
||||
|
||||
Class.prototype = new Setting();
|
||||
lang.extend(Class.prototype, Setting.prototype, proto);
|
||||
Class.prototype.constructor = Setting;
|
||||
lang.extend(Class.prototype, proto);
|
||||
observable.mixin(Class.prototype);
|
||||
|
||||
return Class;
|
||||
};
|
||||
|
@ -21,7 +21,8 @@ define(
|
||||
|
||||
|
||||
var setting = {
|
||||
'unicode': require('../dialog/setting-unicode')
|
||||
'unicode': require('../dialog/setting-unicode'),
|
||||
'name': require('../dialog/setting-name')
|
||||
}
|
||||
|
||||
var actions = {
|
||||
@ -53,17 +54,29 @@ define(
|
||||
});
|
||||
},
|
||||
|
||||
'setting-unicode': function(e) {
|
||||
var dlg = new setting.unicode();
|
||||
|
||||
dlg.on('change', function(e) {
|
||||
'setting-unicode': function() {
|
||||
var dlg = new setting.unicode({
|
||||
onChange: function(unicode) {
|
||||
// 此处延迟处理
|
||||
setTimeout(function(){
|
||||
setUnicode(e.unicode);
|
||||
setUnicode(unicode);
|
||||
}, 20);
|
||||
}
|
||||
});
|
||||
|
||||
dlg.show();
|
||||
},
|
||||
|
||||
'setting-name': function() {
|
||||
var ttf = program.ttfmanager.get();
|
||||
if (ttf) {
|
||||
var dlg = new setting.name({
|
||||
onChange: function(setting) {
|
||||
program.ttfmanager.setName(setting);
|
||||
}
|
||||
});
|
||||
dlg.show(ttf.name);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -161,7 +161,7 @@ define(
|
||||
}
|
||||
|
||||
|
||||
me.capture = new MouseCapture(me.main.parent().get(0), {
|
||||
me.capture = new MouseCapture(me.main.get(0), {
|
||||
events: {
|
||||
dblclick: false,
|
||||
mousewheel: false,
|
||||
|
@ -184,7 +184,7 @@ define(
|
||||
}
|
||||
|
||||
list = list.filter(function(g) {
|
||||
return g.name != '.notdef';
|
||||
return g.name != '.notdef' && g.name != '.null' && g.name != 'nonmarkingreturn';
|
||||
});
|
||||
|
||||
if (list.length) {
|
||||
@ -239,6 +239,19 @@ define(
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 撤销
|
||||
* @return {this}
|
||||
*/
|
||||
Manager.prototype.setName = function(name) {
|
||||
if (name) {
|
||||
name.fontFamily = name.fontFamily || 'fonteditor';
|
||||
name.fontSubFamily = name.fontSubFamily || 'Medium';
|
||||
name.fullName = name.fontFamily;
|
||||
this.ttf.name = name;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 撤销
|
||||
* @return {this}
|
||||
|
8
ttf.html
8
ttf.html
@ -21,7 +21,7 @@
|
||||
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li data-action="add-new"><a>新字形</a></li>
|
||||
<li data-action="add-exist"><a>已有字形</a></li>
|
||||
<!--<li data-action="add-exist"><a>已有字形</a></li>-->
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@ -40,8 +40,8 @@
|
||||
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a data-action="setting-unicode">代码点</a></li>
|
||||
<li><a>字体信息</a></li>
|
||||
<li><a>字形转换</a></li>
|
||||
<li><a data-action="setting-name">字体信息</a></li>
|
||||
<!--<li><a>字形转换</a></li>-->
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@ -68,7 +68,7 @@
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
|
||||
<h4 class="modal-title" id="model-label">设置代码点</h4>
|
||||
<h4 class="modal-title" id="model-label">设置</h4>
|
||||
</div>
|
||||
<div class="modal-body"></div>
|
||||
<div class="modal-footer">
|
||||
|
Loading…
x
Reference in New Issue
Block a user