Sha256: 5b493c6a4bb4a7082e20920ab1e634fa7c3b73d14f0e61e6cee5e4e7be156ffa

Contents?: true

Size: 1.18 KB

Versions: 46

Compression:

Stored size: 1.18 KB

Contents

/*
 * canvas2png.js
 *
 * Copyright (c) 2010-2013 Shinya Muramatsu
 * Released under the MIT License
 * http://flashcanvas.net/
 */

(function(doc) {

var scripts = doc.getElementsByTagName("script");
var script  = scripts[scripts.length - 1];
var url     = script.getAttribute("src").replace(/[^\/]+$/, "save.php");

window.canvas2png = function(canvas, filename) {
    var tagName = canvas.tagName.toLowerCase();
    if (tagName !== "canvas") {
        return;
    }

    if (typeof FlashCanvas !== "undefined") {
        FlashCanvas.saveImage(canvas, filename);
    } else {
        var action = url;
        if (filename) {
            action += "?filename=" + filename;
        }

        var form  = doc.createElement("form");
        var input = doc.createElement("input");

        form.setAttribute("action", action);
        form.setAttribute("method", "post");

        input.setAttribute("type",  "hidden");
        input.setAttribute("name",  "dataurl");
        input.setAttribute("value", canvas.toDataURL());

        doc.body.appendChild(form);
        form.appendChild(input);
        form.submit();
        form.removeChild(input);
        doc.body.removeChild(form);
    }
}

})(document);

Version data entries

46 entries across 23 versions & 1 rubygems

Version Path
webshims-rails-1.16.0 vendor/assets/javascripts/webshims/shims/FlashCanvas/canvas2png.js
webshims-rails-1.16.0 vendor/assets/javascripts/webshims/shims/FlashCanvasPro/canvas2png.js
webshims-rails-1.15.10 vendor/assets/javascripts/webshims/shims/FlashCanvasPro/canvas2png.js
webshims-rails-1.15.10 vendor/assets/javascripts/webshims/shims/FlashCanvas/canvas2png.js
webshims-rails-1.15.9 vendor/assets/javascripts/webshims/shims/FlashCanvas/canvas2png.js
webshims-rails-1.15.9 vendor/assets/javascripts/webshims/shims/FlashCanvasPro/canvas2png.js
webshims-rails-1.15.8 vendor/assets/javascripts/webshims/shims/FlashCanvas/canvas2png.js
webshims-rails-1.15.8 vendor/assets/javascripts/webshims/shims/FlashCanvasPro/canvas2png.js
webshims-rails-1.15.6.4 vendor/assets/javascripts/webshims/shims/FlashCanvasPro/canvas2png.js
webshims-rails-1.15.6.4 vendor/assets/javascripts/webshims/shims/FlashCanvas/canvas2png.js
webshims-rails-1.15.6.3 vendor/assets/javascripts/webshims/shims/FlashCanvasPro/canvas2png.js
webshims-rails-1.15.6.3 vendor/assets/javascripts/webshims/shims/FlashCanvas/canvas2png.js
webshims-rails-1.15.6.2 vendor/assets/javascripts/webshims/shims/FlashCanvas/canvas2png.js
webshims-rails-1.15.6.2 vendor/assets/javascripts/webshims/shims/FlashCanvasPro/canvas2png.js
webshims-rails-1.15.6 vendor/assets/javascripts/webshims/shims/FlashCanvas/canvas2png.js
webshims-rails-1.15.6 vendor/assets/javascripts/webshims/shims/FlashCanvasPro/canvas2png.js
webshims-rails-1.15.5 vendor/assets/javascripts/webshims/shims/FlashCanvasPro/canvas2png.js
webshims-rails-1.15.5 vendor/assets/javascripts/webshims/shims/FlashCanvas/canvas2png.js
webshims-rails-1.15.4 vendor/assets/javascripts/webshims/shims/FlashCanvas/canvas2png.js
webshims-rails-1.15.4 vendor/assets/javascripts/webshims/shims/FlashCanvasPro/canvas2png.js