/* global redux_change, wp */// Add a file via the wp.media function function redux_add_file(e,t){e.preventDefault();var n,r=jQuery(this);if(n){n.open();return}n=wp.media({multiple:!1,library:{type:"image"},title:r.data("choose"),button:{text:r.data("update")}});n.on("select",function(){var e=n.state().get("selection").first();n.close();if(e.attributes.type!=="image")return;t.find(".upload").val(e.attributes.url).trigger("check_dependencies",t.find(".upload"));t.find(".upload-id").val(e.attributes.id);t.find(".upload-height").val(e.attributes.height);t.find(".upload-width").val(e.attributes.width);var r=e.attributes.url;if(typeof e.attributes.sizes.thumbnail.url!="undefined")r=e.attributes.sizes.thumbnail.url;else{var i=e.attributes.height;for(var s in e.attributes.sizes){var o=e.attributes.sizes[s];if(o.height').slideDown("fast");t.find(".remove-image").removeClass("hide");t.find(".redux-background-properties").slideDown()});n.open()}function redux_remove_file(e){if(!e.find(".remove-image").addClass("hide"))return;redux_change(jQuery("#"+e.attr("rel")));e.find(".remove-image").addClass("hide");e.find(".upload").val("").trigger("check_dependencies",e.find(".upload"));e.find(".upload-id").val("");e.find(".upload-height").val("");e.find(".upload-width").val("");e.find(".redux-background-properties").hide();var t=e.find(".screenshot");t.slideUp();e.find(".remove-file").unbind();jQuery(".section-upload .upload-notice").length>0&&jQuery(".media_upload_button").remove()}(function(e){"use strict";e.redux=e.redux||{};e(document).ready(function(){e.redux.media()});e.redux.media=function(){e(".remove-image, .remove-file").unbind("click").on("click",function(){redux_remove_file(e(this).closest("fieldset"));redux_change(e(this).closest("fieldset:first").find(".upload"))});e(".media_upload_button").unbind().on("click",function(t){redux_add_file(t,e(this).closest("fieldset"));redux_change(e(this).closest("fieldset:first").find(".upload"))})}})(jQuery);