(function(b){redux.field_objects=redux.field_objects||{};redux.field_objects.media=redux.field_objects.media||{};var a;b(document).ready(function(){});redux.field_objects.media.init=function(c){if(!c){c=b(document).find(".redux-container-media")}b(c).each(function(){var e=b(this);var d=e;if(!e.hasClass("redux-field-container")){d=e.parents(".redux-field-container:first")}if(d.hasClass("redux-field-init")){d.removeClass("redux-field-init")}else{return}a=false;e.find(".remove-image, .remove-file").unbind("click").on("click",function(){redux.field_objects.media.removeFile(b(this).parents("fieldset.redux-field:first"))});e.find(".media_upload_button").unbind().on("click",function(f){redux.field_objects.media.addFile(f,b(this).parents("fieldset.redux-field:first"))})})};redux.field_objects.media.addFile=function(g,c){g.preventDefault();var h;var e=b(this);var d;if(h){h.open();return}var f=b(c).find(".library-filter").data("lib-filter");if(f!==undefined){if(f!==""){d=[];a=true;f=decodeURIComponent(f);f=JSON.parse(f);b.each(f,function(i,j){d.push(j)})}}h=wp.media({multiple:false,library:{type:d},title:e.data("choose"),button:{text:e.data("update")}});h.on("select",function(){var n=h.state().get("selection").first();h.close();var m=b(c).find(".data").data();if(typeof redux.field_objects.media==="undefined"||typeof redux.field_objects.media===undefined){redux.field_objects.media={}}if(m===undefined||m.mode==="undefined"){m={};m.mode="image"}if(a===true){m.mode=0}if(m.mode===0){}else{if(m.mode!==false){if(n.attributes.type!==m.mode){if(n.attributes.subtype!==m.mode){return}}}}c.find(".upload").val(n.attributes.url);c.find(".upload-id").val(n.attributes.id);c.find(".upload-height").val(n.attributes.height);c.find(".upload-width").val(n.attributes.width);redux_change(b(c).find(".upload-id"));var l=n.attributes.url;if(typeof n.attributes.sizes!=="undefined"&&typeof n.attributes.sizes.thumbnail!=="undefined"){l=n.attributes.sizes.thumbnail.url}else{if(typeof n.attributes.sizes!=="undefined"){var i=n.attributes.height;for(var k in n.attributes.sizes){var j=n.attributes.sizes[k];if(j.height').slideDown("fast")}c.find(".remove-image").removeClass("hide");c.find(".redux-background-properties").slideDown()});h.open()};redux.field_objects.media.removeFile=function(c){if(!c.find(".remove-image").addClass("hide")){return}c.find(".remove-image").addClass("hide");c.find(".upload").val("");c.find(".upload-id").val("");c.find(".upload-height").val("");c.find(".upload-width").val("");c.find(".upload-thumbnail").val("");redux_change(b(c).find(".upload-id"));c.find(".redux-background-properties").hide();var d=c.find(".screenshot");d.slideUp();c.find(".remove-file").unbind();if(c.find(".section-upload .upload-notice").length>0){c.find(".media_upload_button").remove()}}})(jQuery);