mirror of
https://github.com/skishore/makemeahanzi.git
synced 2025-10-30 10:26:40 +08:00
35 lines
881 B
JavaScript
35 lines
881 B
JavaScript
"use strict";
|
|
|
|
Template.metadata.events({
|
|
'keypress .value': function(event) {
|
|
if (event.which === 13 /* \n */) {
|
|
$(event.target).trigger('blur');
|
|
event.preventDefault();
|
|
}
|
|
event.stopPropagation();
|
|
},
|
|
'blur .value': function(event) {
|
|
const text = $(event.target).text();
|
|
console.log(event, this, text);
|
|
},
|
|
});
|
|
|
|
Template.metadata.helpers({
|
|
character() {
|
|
const glyph = Session.get('editor.glyph');
|
|
if (!glyph) return;
|
|
return glyph.character;
|
|
},
|
|
items() {
|
|
const glyph = Session.get('editor.glyph');
|
|
if (!glyph) return;
|
|
const defaults = cjklib.getCharacterData(glyph.character);
|
|
const fields = ['definition', 'pinyin', 'strokes']
|
|
return fields.map((x) => ({
|
|
field: x,
|
|
label: `${x[0].toUpperCase()}${x.substr(1)}:`,
|
|
value: glyph.metadata[x] || defaults[x] || '(unknown)',
|
|
}));
|
|
},
|
|
});
|