diff --git a/client/editor.js b/client/editor.js index c6c0b9fc..30eb2667 100644 --- a/client/editor.js +++ b/client/editor.js @@ -42,24 +42,6 @@ Template.editor.helpers({ points: () => Session.get('stage.points'), }); -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[0].toUpperCase()}${x.substr(1)}:`, - value: glyph.metadata[x] || defaults[x] || '(unknown)', - })); - }, -}); - Template.status.helpers({ stage: () => Session.get('stage.type'), instructions: () => Session.get('stage.instructions'), diff --git a/client/index.html b/client/index.html index 4330c38c..5eb2a4d6 100644 --- a/client/index.html +++ b/client/index.html @@ -74,8 +74,8 @@ {{#each items}}
- - {{value}} + + {{value}}
{{/each}} diff --git a/client/metadata.js b/client/metadata.js new file mode 100644 index 00000000..4e3fbcf9 --- /dev/null +++ b/client/metadata.js @@ -0,0 +1,34 @@ +"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)', + })); + }, +});