Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML5 JavaScript Pasting Image Data in Chrome
    primarykey
    data
    text
    <p>How do I develop a working example using this plugin: <a href="http://strd6.com/2011/09/html5-javascript-pasting-image-data-in-chrome/" rel="nofollow">HTML5 JavaScript Pasting Image Data in Chrome</a></p> <p>The author has put together a great example that seems like it would suit our purposes. I'm not familiar with creating a jQuery plugin however. </p> <p>The goal will be to use this plugin to paste clipboard images into a rich text editor such as TinyMCE. </p> <pre><code>&lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;PASTE IMAGE&lt;/title&gt; &lt;script type="text/javascript" src="js/jquery-1.7.1.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/jquery-ui-1.8.18.custom.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; // Created by STRd6 // MIT License // jquery.paste_image_reader.js (function($) { var defaults; $.event.fix = (function(originalFix) { return function(event) { event = originalFix.apply(this, arguments); if (event.type.indexOf('copy') === 0 || event.type.indexOf('paste') === 0) { event.clipboardData = event.originalEvent.clipboardData; } return event; }; })($.event.fix); defaults = { callback: $.noop, matchType: /image.*/ }; $.fn.pasteImageReader = function(options) { if (typeof options === "function") { options = { callback: options }; } options = $.extend({}, defaults, options); return this.each(function() { var $this, element; element = this; $this = $(this); $this.bind('paste', function(event) { var clipboardData, found; found = false; clipboardData = event.clipboardData; Array.prototype.forEach.call(clipboardData.types, function(type, i) { var file, reader; if (found) { return; } if (!type.match(options.matchType)) { return; } file = clipboardData.items[i].getAsFile(); reader = new FileReader(); reader.onload = function(evt) { options.callback.call(element, { filename: file.name, dataURL: evt.target.result }); }; reader.readAsDataURL(file); found = true; }); }); }); }; })(jQuery); $("html").pasteImageReader (results) -&gt; {filename, dataURL} = results $("body").css backgroundImage: "url(#{dataURL})" &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I'm confused by the plugin call:</p> <pre><code>$("html").pasteImageReader (results) -&gt; {filename, dataURL} = results $("body").css backgroundImage: "url(#{dataURL})" </code></pre> <p>That doesn't look like jQuery that I've seen. Is it specific to the plugin itself? Any guidance would be greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload