/
font.module.js
123 lines (100 loc) · 3.63 KB
/
font.module.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
(function() {
if (!this.require) {
var modules = {}, cache = {};
var require = function(name, root) {
var path = expand(root, name), indexPath = expand(path, './index'), module, fn;
module = cache[path] || cache[indexPath];
if (module) {
return module;
} else if (fn = modules[path] || modules[path = indexPath]) {
module = {id: path, exports: {}};
cache[path] = module.exports;
fn(module.exports, function(name) {
return require(name, dirname(path));
}, module);
return cache[path] = module.exports;
} else {
throw 'module ' + name + ' not found';
}
};
var expand = function(root, name) {
var results = [], parts, part;
// If path is relative
if (/^\.\.?(\/|$)/.test(name)) {
parts = [root, name].join('/').split('/');
} else {
parts = name.split('/');
}
for (var i = 0, length = parts.length; i < length; i++) {
part = parts[i];
if (part == '..') {
results.pop();
} else if (part != '.' && part != '') {
results.push(part);
}
}
return results.join('/');
};
var dirname = function(path) {
return path.split('/').slice(0, -1).join('/');
};
this.require = function(name) {
return require(name, '');
};
this.require.define = function(bundle) {
for (var key in bundle) {
modules[key] = bundle[key];
}
};
this.require.modules = modules;
this.require.cache = cache;
}
return this.require;
}).call(this);
this.require.define({"app/controllers/inspector/font":function(exports, require, module){(function() {
var Color, ColorPicker, Font,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
Color = require('app/models/properties/color');
ColorPicker = require('lib/color_picker');
Font = (function(_super) {
__extends(Font, _super);
Font.name = 'Font';
Font.prototype.className = 'font';
Font.prototype.elements = {
'input': '$inputs',
'input[name=size]': '$size',
'select[name=family]': '$family'
};
Font.prototype.events = {
'change input, select': 'change'
};
function Font() {
this.render = __bind(this.render, this);
var _this = this;
Font.__super__.constructor.apply(this, arguments);
this.html(JST['app/views/inspector/font'](this));
this.$color = new ColorPicker.Preview;
this.$color.bind('change', function() {
return _this.change();
});
this.$('input[type=color]').replaceWith(this.$color.el);
}
Font.prototype.render = function() {
this.disabled = !this.stage.selection.isAny();
this.$color.val(this.stage.selection.get('color') || new Color.Black);
this.$size.val(this.stage.selection.get('fontSize'));
return this.$family.val(this.stage.selection.get('fontFamily'));
};
Font.prototype.change = function(e) {
this.stage.history.record('font');
this.stage.selection.set('color', this.$color.val());
this.stage.selection.set('fontSize', parseInt(this.$size.val(), 10));
return this.stage.selection.set('fontFamily', this.$family.val());
};
return Font;
})(Spine.Controller);
module.exports = Font;
}).call(this);
;}});