add name setting

This commit is contained in:
mkwiser 2014-10-07 17:04:55 +08:00
parent dd4f02c4a9
commit 03d4fcde8b
12 changed files with 206 additions and 39 deletions

35
css/bootstrap.css vendored Normal file
View 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
View File

@ -41,4 +41,8 @@
a { a {
cursor: pointer; cursor: pointer;
} }
}
.input-group {
margin-bottom: 10px;
} }

View File

@ -30,6 +30,9 @@
.dropdown-menu a { .dropdown-menu a {
cursor: pointer; cursor: pointer;
} }
.input-group {
margin-bottom: 10px;
}
body, body,
html { html {
margin: 0; margin: 0;

View File

@ -30,6 +30,9 @@
.dropdown-menu a { .dropdown-menu a {
cursor: pointer; cursor: pointer;
} }
.input-group {
margin-bottom: 10px;
}
body, body,
html { html {
margin: 0; margin: 0;
@ -161,6 +164,8 @@ html {
display: none; display: none;
} }
.glyf-list { .glyf-list {
padding-bottom: 1000000px;
margin-bottom: -1000000px;
overflow: hidden; overflow: hidden;
} }
.glyf-list > .glyf-item { .glyf-list > .glyf-item {

View File

@ -35,7 +35,8 @@
.glyf-list { .glyf-list {
padding-bottom: 1000000px;
margin-bottom: -1000000px;
overflow: hidden; overflow: hidden;
>.glyf-item { >.glyf-item {

View 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;
}
});
}
);

View File

@ -25,15 +25,16 @@ define(
return require('./setting').derive({ return require('./setting').derive({
title: '设置代码点',
getTpl: function() { getTpl: function() {
return tpl; return tpl;
}, },
onConfirm: function() {
validate: function() {
var unicode = $('#setting-text-unicode').val(); var unicode = $('#setting-text-unicode').val();
if (unicode.match(/^\$[A-E0-9]+$/i)) { if (unicode.match(/^\$[A-E0-9]+$/i)) {
this.fire('change', { return this.setting = unicode;
unicode: unicode
});
} }
else { else {
alert('代码点设置不正确'); alert('代码点设置不正确');

View File

@ -17,20 +17,17 @@ define(
* *
* @constructor * @constructor
*/ */
function Setting() { function Setting(options) {
}
this.options = options || {};
/**
* 初始化绑定事件
*/
Setting.prototype.preInit = function() {
var dlg = $('#model-dialog'); 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.find('.modal-body').html(this.getTpl());
dlg.on('hidden.bs.modal', lang.bind(function (e) { dlg.on('hidden.bs.modal', lang.bind(function (e) {
if (dlg) { if (dlg) {
this.un(); delete this.options;
dlg.off('hidden.bs.modal'); dlg.off('hidden.bs.modal');
dlg.find('.btn-confirm').off('click'); dlg.find('.btn-confirm').off('click');
dlg = null; dlg = null;
@ -38,11 +35,14 @@ define(
}, this)); }, this));
dlg.find('.btn-confirm').on('click', lang.bind(function() { 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'); dlg.modal('hide');
} }
}, this)); }, 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'); $('#model-dialog').modal('show');
this.set(setting);
return this; 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'); $('#model-dialog').modal('hide');
}; };
/** /**
* 派生一个setting * 派生一个setting
* *
@ -87,14 +118,11 @@ define(
function Class() { function Class() {
Setting.apply(this, arguments); Setting.apply(this, arguments);
this.preInit();
this.initialize && this.initialize(); this.initialize && this.initialize();
} }
Class.prototype = new Setting(); lang.extend(Class.prototype, Setting.prototype, proto);
Class.prototype.constructor = Setting; Class.prototype.constructor = Setting;
lang.extend(Class.prototype, proto);
observable.mixin(Class.prototype);
return Class; return Class;
}; };

View File

@ -21,7 +21,8 @@ define(
var setting = { var setting = {
'unicode': require('../dialog/setting-unicode') 'unicode': require('../dialog/setting-unicode'),
'name': require('../dialog/setting-name')
} }
var actions = { var actions = {
@ -53,17 +54,29 @@ define(
}); });
}, },
'setting-unicode': function(e) { 'setting-unicode': function() {
var dlg = new setting.unicode(); var dlg = new setting.unicode({
onChange: function(unicode) {
dlg.on('change', function(e) { // 此处延迟处理
// 此处延迟处理 setTimeout(function(){
setTimeout(function(){ setUnicode(unicode);
setUnicode(e.unicode); }, 20);
}, 20); }
}); });
dlg.show(); 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);
}
} }
}; };

View File

@ -161,7 +161,7 @@ define(
} }
me.capture = new MouseCapture(me.main.parent().get(0), { me.capture = new MouseCapture(me.main.get(0), {
events: { events: {
dblclick: false, dblclick: false,
mousewheel: false, mousewheel: false,

View File

@ -184,7 +184,7 @@ define(
} }
list = list.filter(function(g) { list = list.filter(function(g) {
return g.name != '.notdef'; return g.name != '.notdef' && g.name != '.null' && g.name != 'nonmarkingreturn';
}); });
if (list.length) { 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} * @return {this}

View File

@ -21,7 +21,7 @@
<ul class="dropdown-menu" role="menu"> <ul class="dropdown-menu" role="menu">
<li data-action="add-new"><a>新字形</a></li> <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> </ul>
</div> </div>
@ -40,8 +40,8 @@
<ul class="dropdown-menu" role="menu"> <ul class="dropdown-menu" role="menu">
<li><a data-action="setting-unicode">代码点</a></li> <li><a data-action="setting-unicode">代码点</a></li>
<li><a>字体信息</a></li> <li><a data-action="setting-name">字体信息</a></li>
<li><a>字形转换</a></li> <!--<li><a>字形转换</a></li>-->
</ul> </ul>
</div> </div>
@ -68,7 +68,7 @@
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span></button> <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</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>
<div class="modal-body"></div> <div class="modal-body"></div>
<div class="modal-footer"> <div class="modal-footer">