From: yasushiito Date: Fri, 9 Aug 2013 09:18:46 +0000 (+0900) Subject: t#31144:add writing_format X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=commitdiff_plain;h=0d0ae53d10129add2a45125ddaf07432209f038f t#31144:add writing_format --- diff --git a/app/assets/javascripts/panels.js.coffee b/app/assets/javascripts/panels.js.coffee index 49ebed0b..1a8a61de 100644 --- a/app/assets/javascripts/panels.js.coffee +++ b/app/assets/javascripts/panels.js.coffee @@ -4,9 +4,6 @@ $ -> new_element_index = {} new_element_index[pettanr_current_panel_id] = 0 - escapeHTML = (t) -> - $("
").text(t).html() - set_tree_value = (keys, last_attr, value) -> key = keys.shift() if keys.length <= 0 @@ -309,25 +306,21 @@ $ -> $(@).focusout -> switch $(@).attr('column') when 'content' - trace = element_tag_id($(@)) - speech_trace = '#panel' + $(@).attr('panel_id') + 'speech_balloon' + $(@).attr('element_id') + 'speech' + $(@).attr('element_part_id') - v = escapeHTML($(@).val()) - $(speech_trace).html(v) + trace = '#panel' + $(@).attr('panel_id') + 'speech_balloon' + $(@).attr('element_id') + 'speech' + $(@).attr('element_part_id') + wf_sel = $(trace + 'writing_format_id') + wf_id = parseInt(wf_sel.val()) + v = writing_format_functions[writing_formats[wf_id]]($(@).val()) + $(trace).html(v) $('textarea').map -> if $(@).attr('element_type') and $(@).attr('element_type') == 'speech_balloon' switch $(@).attr('column') when 'content' $(@).bind('textchange', (event, previousText) -> - trace = element_tag_id($(@)) + trace = '#panel' + $(@).attr('panel_id') + 'speech_balloon' + $(@).attr('element_id') + 'speech' + $(@).attr('element_part_id') wf_sel = $(trace + 'writing_format_id') wf_id = parseInt(wf_sel.val()) - speech_trace = '#panel' + $(@).attr('panel_id') + 'speech_balloon' + $(@).attr('element_id') + 'speech' + $(@).attr('element_part_id') - fn = writing_formats[wf_id].toString() + '_render()' - confirm(fn ) -# f = new Function("return " + fn) -# f() - v = escapeHTML($(@).val()) - $(speech_trace).html(v) + v = writing_format_functions[writing_formats[wf_id]]($(@).val()) + $(trace).html(v) ) diff --git a/app/views/panels/_form.html.erb b/app/views/panels/_form.html.erb index c18a7fb9..bee3579a 100644 --- a/app/views/panels/_form.html.erb +++ b/app/views/panels/_form.html.erb @@ -199,6 +199,7 @@