!function(i){"use strict";i(document).ready((function(){var e,o=i("#fusion-custom-icons-upload"),n=JSON.parse(JSON.stringify(fusionUploaderOptions)),s=i(".fusion-icons-uploader");o.on("click",(function(e){var o,n=i(this),s={title:n.data("title"),multiple:!1,frame:"post",className:"media-frame mode-select fusion-builder-media-dialog wp-admin "+n.data("id"),displayUserSettings:!1,displaySettings:!0,allowLocalEdits:!0,library:{type:"application/zip"}};return e&&e.preventDefault(),o=wp.media(s),wp.media.frames.file_frame=wp.media(s),o.on("select insert",(function(){o.state().get("selection").map((function(e){return i("#fusion-custom-icons-attachment-id").val(e.id),0<i("#fusion-custom-icons-update").length&&(i("#fusion-custom-icons-update").val("true"),i(".fusion-custom-icon-preview-wrapper").remove()),e}))})),o.open(),!1})),0<i("#fusion-icons-uploader-wrapper").length&&(n.multipart_params._ajax_nonce=i("#fusion-custom-icons-nonce").val(),s.hasClass("multiple")&&(n.multi_selection=!0),(e=new plupload.Uploader(n)).init(),e.bind("FilesAdded",(function(e,o){e.refresh(),e.start(),i("#fusion-icons-uploader-drop-zone .spinner").css("visibility","visible")})),e.bind("Error",(function(i,e){var o=e.file&&e.file.type&&0===e.file.type.indexOf("image/"),n=e&&e.status;"function"==typeof tryAgain&&o&&500<=n&&600>n?tryAgain(i,e):("function"==typeof uploadError&&uploadError(e.file,e.code,e.message,i),i.refresh())})),e.bind("FileUploaded",(function(e,o,n){"success"==(n=JSON.parse(n.response)).status?(i("#fusion-custom-icons-attachment-id").val(n.attachment.id),""===i("#title").val()&&i("#title").val("Custom Icon Set"),i("#publish").trigger("click")):i("#fusion-icons-error").html(n.error),i("#fusion-icons-uploader-drop-zone .spinner").css("visibility","hidden")}))),i("#fusion-icons-uploader-drop-zone").on("dragover",(function(){i(this).addClass("fusion-drag-over")})),i("#fusion-icons-uploader-drop-zone").on("dragleave drop",(function(){i(this).removeClass("fusion-drag-over")}))}))}(jQuery);