app/views/sketchily/_embed.js.erb~ in sketchily-1.4.1 vs app/views/sketchily/_embed.js.erb~ in sketchily-1.5.0

- old
+ new

@@ -47,23 +47,38 @@ mainButton.parentNode.removeChild(mainButton); var toolsTop = doc.getElementById('tools_top'); toolsTop.style.left = '5px'; <% end %> - <% unless show_hyperlink_tool %> - var hyperlinkTool = doc.getElementById('tool_make_link'); - hyperlinkTool.parentNode.removeChild(hyperlinkTool); - <% end %> - <% if hide_image_tool %> var imageTool = doc.getElementById('tool_image'); imageTool.parentNode.removeChild(imageTool); <% end %> + <% unless show_hyperlink_tool %> + var hyperlinkTool = doc.getElementById('tool_make_link'); + hyperlinkTool.parentNode.removeChild(hyperlinkTool); + <% end %> + <% unless url %> svgCanvas_<%= id %>.setSvgString(sketchily_decode64("<%= value.try(:squish) %>")); <% end %> attachSubmitHandler_<%= id %>(); + + $("#svgedit_<%= id %>").css('visibility', ''); } -$("#svgedit_<%= id %>").load(initEmbed_<%= id %>); +function attachLoadHandler_<%= id %>() { + if ($("#svgedit_<%= id %>").attr('src')) { + $("#svgedit_<%= id %>").load(initEmbed_<%= id %>); + } + else { + $("#svgedit_<%= id %>").css('visibility', 'hidden'); + setTimeout(function () { + attachLoadHandler_<%= id %>(); + }, 0); + } +} + +attachLoadHandler_<%= id %>(); +