1
2
3
4
|
/* Do not modify this file directly. It is compiled from other files. */
/* jshint onevar: false, smarttabs: true, devel: true */
/* global Jetpack_Comics_Options */
jQuery(function(e){var o={init:function(){e(document).on("dragover.jetpack-comics","body, #jetpack-comic-drop-zone",this.onDragOver),e(document).on("dragleave.jetpack-comics","body, #jetpack-comic-drop-zone",this.onDragLeave),e(document).on("drop.jetpack-comics","body, #jetpack-comic-drop-zone",this.onDrop),e("body").append(e('<div id="jetpack-comic-drop-zone"><p class="dragging" /><p class="uploading" /></div>')),e("#jetpack-comic-drop-zone").find(".dragging").text(Jetpack_Comics_Options.labels.dragging).end().find(".uploading").text(Jetpack_Comics_Options.labels.uploading).prepend(e('<span class="spinner"/>')),"FileReader"in window&&"File"in window||(e("#jetpack-comic-drop-zone .dragging").text(Jetpack_Comics_Options.labels.unsupported),e(document).off("drop.jetpack-comics").on("drop.jetpack-comics","body, #jetpack-comic-drop-zone",this.onDragLeave))},filterImageFiles:function(e){for(var o=[],n=0,a=e.length;n<a;n++)e[n].type.match(/^image\//i)&&o.push(e[n]);return o},dragTimeout:null,onDragOver:function(n){n.preventDefault(),clearTimeout(o.dragTimeout),e("body").addClass("dragging")},onDragLeave:function(){clearTimeout(o.dragTimeout),o.dragTimeout=setTimeout(function(){e("body").removeClass("dragging")},100)},onDrop:function(n){n.preventDefault(),n.stopPropagation(),n.originalEvent.stopPropagation(),n.originalEvent.preventDefault();var a=o.filterImageFiles(n.originalEvent.dataTransfer.files);if(e("body").removeClass("dragging"),0!==a.length){e("body").addClass("uploading");for(var i=new FormData,t=0,r=a.length;t<r;t++)i.append("image_"+t,a[t]);e("#jetpack-comic-drop-zone .uploading .spinner").spin(),e.ajax({url:Jetpack_Comics_Options.writeURL+"&nonce="+Jetpack_Comics_Options.nonce,data:i,processData:!1,contentType:!1,type:"POST",dataType:"json",xhrFields:{withCredentials:!0}}).done(function(o){e("#jetpack-comic-drop-zone .uploading").text(Jetpack_Comics_Options.labels.processing),"url"in o?document.location.href=o.url:"error"in o&&(alert(o.error),e("body").removeClass("uploading"))}).fail(function(){alert(Jetpack_Comics_Options.labels.error)})}else alert(Jetpack_Comics_Options.labels.invalidUpload)}};o.init()});
|