1/* DOKUWIKI:include jquery.paste_image_reader.js */ 2 3jQuery(function () { 4 if (!jQuery('#wiki__text').length) return; 5 6 jQuery('html').pasteImageReader({ 7 callback: function (x) { 8 console.log(x); 9 10 // create dialog 11 var offset = jQuery('.plugin_imagepaste').length * 20; 12 var $box = jQuery('<div><div class="content">' + LANG.plugins.imgpaste.inprogress + '</div></div>'); 13 $box.dialog({ 14 title: 'Upload', 15 dialogClass: 'plugin_imagepaste', 16 closeOnEscape: false, 17 resizable: false, 18 position: { 19 my: 'center+' + offset + ' center+' + offset 20 }, 21 appendTo: '.dokuwiki' 22 }); 23 24 // upload via AJAX 25 jQuery.ajax({ 26 url: DOKU_BASE + 'lib/exe/ajax.php', 27 type: 'POST', 28 data: { 29 call: 'plugin_imgpaste', 30 data: x.dataURL, 31 id: JSINFO.id 32 }, 33 34 // insert syntax and close dialog 35 success: function (data) { 36 $box.find('.content').addClass('success').text(data.message); 37 insertAtCarret('wiki__text', '{{:' + data.id + '}}'); 38 $box.delay(500).fadeOut(500, function () { 39 $box.dialog('destroy').remove() 40 }); 41 }, 42 43 // display error and close dialog 44 error: function (xhr, status, error) { 45 $box.find('.content').addClass('error').text(error); 46 $box.delay(1000).fadeOut(500, function () { 47 $box.dialog('destroy').remove() 48 }); 49 } 50 }); 51 } 52 }); 53});