/* Do not modify this file directly. It is compiled from other files. */ /* global pluploadL10n, plupload, _wpPluploadSettings, JSON */ window.wp=window.wp||{},function(e,t){var r,i;"undefined"!=typeof _wpPluploadSettings&&(r=function(o){var a,n,d=this,p=-1!==navigator.userAgent.indexOf("Trident/")||-1!==navigator.userAgent.indexOf("MSIE "),s={container:"container",browser:"browse_button",dropzone:"drop_element"};if(this.supports={upload:r.browser.supported},this.supported=this.supports.upload,this.supported){for(a in this.plupload=t.extend(!0,{multipart_params:{}},r.defaults),this.container=document.body,t.extend(!0,this,o),this)t.isFunction(this[a])&&(this[a]=t.proxy(this[a],this));for(a in s)this[a]&&(this[a]=t(this[a]).first(),this[a].length?(this[a].prop("id")||this[a].prop("id","__wp-uploader-id-"+r.uuid++),this.plupload[s[a]]=this[a].prop("id")):delete this[a]);(this.browser&&this.browser.length||this.dropzone&&this.dropzone.length)&&(p||"flash"!==plupload.predictRuntime(this.plupload)||this.plupload.required_features&&this.plupload.required_features.hasOwnProperty("send_binary_string")||(this.plupload.required_features=this.plupload.required_features||{},this.plupload.required_features.send_binary_string=!0),this.uploader=new plupload.Uploader(this.plupload),delete this.plupload,this.param(this.params||{}),delete this.params,void 0!==e.VideoPress?i=e.VideoPress:window.console&&window.console.error("The VideoPress object was not loaded. Errors may occur."),n=function(e,t,i){i.attachment&&i.attachment.destroy(),r.errors.unshift({message:e||pluploadL10n.default_error,data:t,file:i}),d.error(e,t,i)},this.uploader.bind("init",function(e){var i,o,a,n=d.dropzone;if(a=d.supports.dragdrop=e.features.dragdrop&&!r.browser.mobile,n){if(n.toggleClass("supports-drag-drop",!!a),!a)return n.unbind(".wp-uploader");n.bind("dragover.wp-uploader",function(){i&&clearTimeout(i),o||(n.trigger("dropzone:enter").addClass("drag-over"),o=!0)}),n.bind("dragleave.wp-uploader, drop.wp-uploader",function(){i=setTimeout(function(){o=!1,n.trigger("dropzone:leave").removeClass("drag-over")},0)}),d.ready=!0,t(d).trigger("uploader:ready")}}),this.uploader.bind("postinit",function(e){e.refresh(),d.init()}),this.uploader.init(),this.browser?this.browser.on("mouseenter",this.refresh):(this.uploader.disableBrowse(!0),t("#"+this.uploader.id+"_html5_container").hide()),this.uploader.bind("FilesAdded",function(e,t){_.each(t,function(e){var t,i;plupload.FAILED!==e.status&&(t=_.extend({file:e,uploading:!0,date:new Date,filename:e.name,menuOrder:0,uploadedTo:wp.media.model.settings.post.id},_.pick(e,"loaded","size","percent")),(i=/(?:jpe?g|png|gif)$/i.exec(e.name))&&(t.type="image",t.subtype="jpg"===i[0]?"jpeg":i[0]),e.attachment=wp.media.model.Attachment.create(t),r.queue.add(e.attachment),d.added(e.attachment))}),e.refresh(),e.start()}),this.uploader.bind("UploadProgress",function(e,t){t.attachment.set(_.pick(t,"loaded","percent")),d.progress(t.attachment)}),this.uploader.bind("FileUploaded",function(e,t,o){try{o=JSON.parse(o.response)}catch(e){return n(pluploadL10n.default_error,e,t)}o=void 0!==o.media?i.handleRestApiResponse(o,t):i.handleStandardResponse(o,t),_.each(["file","loaded","size","percent"],function(e){t.attachment.unset(e)}),t.attachment.set(_.extend(o.data,{uploading:!1})),wp.media.model.Attachment.get(o.data.id,t.attachment),r.queue.all(function(e){return!e.get("uploading")})&&(i&&i.resetToOriginalOptions(e),r.queue.reset()),d.success(t.attachment)}),this.uploader.bind("Error",function(e,t){var o,a=pluploadL10n.default_error;for(o in r.errorMap)if(t.code===plupload[o]){a=r.errorMap[o],_.isFunction(a)&&(a=a(t.file,t));break}n(a,t,t.file),i&&i.resetToOriginalOptions(e),e.refresh()}),this.uploader.bind("UploadComplete",function(e){i&&i.resetToOriginalOptions(e)}),this.uploader.bind("BeforeUpload",function(e,t){void 0!==t.videopress&&(i.originalOptions.url=e.getOption("url"),i.originalOptions.multipart_params=e.getOption("multipart_params"),i.originalOptions.file_data_name=e.getOption("file_data_name"),e.setOption("file_data_name","media[]"),e.setOption("url",t.videopress.upload_action_url),e.setOption("headers",{Authorization:'X_UPLOAD_TOKEN token="'+t.videopress.upload_token+'" blog_id="'+t.videopress.upload_blog_id+'"'}))}))}},t.extend(r,_wpPluploadSettings),r.uuid=0,r.errorMap={FAILED:pluploadL10n.upload_failed,FILE_EXTENSION_ERROR:pluploadL10n.invalid_filetype,IMAGE_FORMAT_ERROR:pluploadL10n.not_an_image,IMAGE_MEMORY_ERROR:pluploadL10n.image_memory_exceeded,IMAGE_DIMENSIONS_ERROR:pluploadL10n.image_dimensions_exceeded,GENERIC_ERROR:pluploadL10n.upload_failed,IO_ERROR:pluploadL10n.io_error,HTTP_ERROR:pluploadL10n.http_error,SECURITY_ERROR:pluploadL10n.security_error,FILE_SIZE_ERROR:function(e){return pluploadL10n.file_exceeds_size_limit.replace("%s",e.name)}},t.extend(r.prototype,{param:function(e,r){if(1===arguments.length&&"string"==typeof e)return this.uploader.settings.multipart_params[e];arguments.length>1?this.uploader.settings.multipart_params[e]=r:t.extend(this.uploader.settings.multipart_params,e)},init:function(){},error:function(){},success:function(){},added:function(){},progress:function(){},complete:function(){},refresh:function(){var e,r,i,o;if(this.browser){for(e=this.browser[0];e;){if(e===document.body){r=!0;break}e=e.parentNode}r||(o="wp-uploader-browser-"+this.uploader.id,(i=t("#"+o)).length||(i=t('
').css({position:"fixed",top:"-1000px",left:"-1000px",height:0,width:0}).attr("id","wp-uploader-browser-"+this.uploader.id).appendTo("body")),i.append(this.browser))}this.uploader.refresh()}}),r.queue=new wp.media.model.Attachments([],{query:!1}),r.errors=new Backbone.Collection,e.Uploader=r)}(wp,jQuery);