Sha256: 3ed8fd07a1ef40de62c82a0224b2c8bec92dba333d3420add4c7b8dcf17a0b2a
Contents?: true
Size: 1.87 KB
Versions: 2
Compression:
Stored size: 1.87 KB
Contents
<% # This partial requires svgutils.js # # Clients of this partial must supply the following variables: # id # value # hide_menu # hide_image_tool # hide_hyperlink_tool %> var svgCanvas_<%= id %> = null; function submitHandler_<%= id %>(e) { svgCanvas_<%= id %>.getSvgString()(handleSvgData_<%= id %>); e.preventDefault(); e.stopImmediatePropagation(); } function attachSubmitHandler_<%= id %>() { $("input#<%= id %>").closest("form").on("submit", submitHandler_<%= id %>); } 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").off("submit", submitHandler_<%= id %>); $("input#<%= id %>").closest("form").one("submit", attachSubmitHandler_<%= id %>); $("input#<%= id %>").closest("form").submit(); } } function initEmbed_<%= id %>() { var frame = document.getElementById('svgedit_<%= id %>'); svgCanvas_<%= id %> = new embedded_svg_edit(frame); var doc; doc = frame.contentDocument; if (!doc) { doc = frame.contentWindow.document; } <% if hide_menu %> var mainButton = doc.getElementById('main_button'); mainButton.parentNode.removeChild(mainButton); var toolsTop = doc.getElementById('tools_top'); toolsTop.style.left = '5px'; <% end %> <% if hide_image_tool %> var imageTool = doc.getElementById('tool_image'); imageTool.parentNode.removeChild(imageTool); <% end %> <% if hide_hyperlink_tool %> var hyperlinkTool = doc.getElementById('tool_make_link'); hyperlinkTool.parentNode.removeChild(hyperlinkTool); <% end %> svgCanvas_<%= id %>.setSvgString(svgedit.utilities.decode64("<%= value.try(:squish) %>")); attachSubmitHandler_<%= id %>(); } $("#svgedit_<%= id %>").load(initEmbed_<%= id %>);
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sketchily-1.1.0 | app/views/sketchily/_embed.js.erb |
sketchily-1.0.3 | app/views/sketchily/_embed.js.erb |