Sha256: eeb1dfec31bd68f50f949f561218abcc0664ea15cf93a910a26898edfcdfcae4

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

/*globals qq*/
qq.PasteSupport = function(o) {
    "use strict";

    var options, detachPasteHandler;

    options = {
        targetElement: null,
        callbacks: {
            log: function(message, level) {},
            pasteReceived: function(blob) {}
        }
    };

    function isImage(item) {
        return item.type &&
            item.type.indexOf("image/") === 0;
    }

    function registerPasteHandler() {
        qq(options.targetElement).attach("paste", function(event) {
            var clipboardData = event.clipboardData;

            if (clipboardData) {
                qq.each(clipboardData.items, function(idx, item) {
                    if (isImage(item)) {
                        var blob = item.getAsFile();
                        options.callbacks.pasteReceived(blob);
                    }
                });
            }
        });
    }

    function unregisterPasteHandler() {
        if (detachPasteHandler) {
            detachPasteHandler();
        }
    }

    qq.extend(options, o);
    registerPasteHandler();

    return {
        reset: function() {
            unregisterPasteHandler();
        }
    };
};

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fine_uploader-3.5.0 vendor/assets/javascripts/fine_uploader/paste.js
fine_uploader-3.4.1 vendor/assets/javascripts/fine_uploader/paste.js