app/views/sketchily/_embed.js.erb~ in sketchily-0.0.2 vs app/views/sketchily/_embed.js.erb~ in sketchily-0.1.0
- old
+ new
@@ -6,17 +6,25 @@
# show_menu
# hide_image_tool %>
var svgCanvas_<%= id %> = null;
+function attachSubmitHandler_<%= id %>() {
+ $("input#<%= id %>").closest("form").one("submit", function(event) {
+ svgCanvas_<%= id %>.getSvgString()(handleSvgData_<%= id %>);
+ event.preventDefault();
+ });
+}
+
function handleSvgData_<%= id %>(data, error) {
if (error) {
alert('Error: ' + error);
}
else {
$("input#<%= id %>").attr("value", svgedit.utilities.encode64("<?xml version=\"1.0\"?>\n" + data));
$("input#<%= id %>").closest("form").submit();
+ attachSubmitHandler_<%= id %>();
}
}
function initEmbed_<%= id %>() {
var frame = document.getElementById('svgedit_<%= id %>');
@@ -34,17 +42,14 @@
var toolsTop = doc.getElementById('tools_top');
toolsTop.style.left = '120px';
toolsTop.style.right = '2px';
<% end %>
- <% if hide_image %>
+ <% if hide_image_tool %>
var imageTool = doc.getElementById('tool_image');
imageTool.style.display = 'none';
<% end %>
- $("input#<%= id %>").closest("form").one("submit", function(event) {
- svgCanvas_<%= id %>.getSvgString()(handleSvgData_<%= id %>);
- event.preventDefault();
- });
+ attachSubmitHandler_<%= id %>();
svgCanvas_<%= id %>.setSvgString(svgedit.utilities.decode64("<%= value.try(:squish) %>"));
}