!function(a){"use strict";a.reduxBackground=a.reduxBackground||{},a(document).ready(function(){a.reduxBackground.init()}),a.reduxBackground.init=function(b){b||(b=a(document).find(".redux-container-background")),a(b).find(".redux-remove-background").unbind("click").on("click",function(b){return b.preventDefault(),a.reduxBackground.removeImage(a(this).parents(".redux-container-background:first")),a.reduxBackground.preview(a(this)),!1}),a(b).find(".redux-background-upload").unbind().on("click",function(b){a.reduxBackground.addImage(b,a(this).parents(".redux-container-background:first"))}),a(b).find(".redux-background-input").on("change",function(){a.reduxBackground.preview(a(this))}),a(b).find(".redux-color").wpColorPicker({change:function(b,c){redux_change(a(this)),a("#"+b.target.id+"-transparency").removeAttr("checked"),a(this).val(c.color.toString()),a.reduxBackground.preview(a(this))}})},a.reduxBackground.preview=function(b){var c=a(b).parents(".redux-container-background:first"),d=a(c).find(".background-preview");if(d){var e=!0,f=c.data("id")+"][",g="height:"+d.height()+"px;";a(c).find(".redux-background-input").each(function(){var b=a(this).serializeArray();b=b[0],b&&-1!=b.name.indexOf("[background-")&&""!==b.value&&(e=!1,b.name=b.name.split(f),b.name=b.name[1].replace("]",""),g+="background-image"==b.name?b.name+':url("'+b.value+'");':b.name+":"+b.value+";")}),e?d.slideUp():d.attr("style",g).fadeIn()}},a.reduxBackground.addImage=function(b,c){b.preventDefault();var d,e=a(this);return d?void d.open():(d=wp.media({multiple:!1,library:{},title:e.data("choose"),button:{text:e.data("update")}}),d.on("select",function(){var b=d.state().get("selection").first();if(d.close(),"image"===b.attributes.type){c.find(".upload").val(b.attributes.url),c.find(".upload-id").val(b.attributes.id),c.find(".upload-height").val(b.attributes.height),c.find(".upload-width").val(b.attributes.width),redux_change(a(c).find(".upload-id"));var e=b.attributes.url;if("undefined"!=typeof b.attributes.sizes&&"undefined"!=typeof b.attributes.sizes.thumbnail)e=b.attributes.sizes.thumbnail.url;else if("undefined"!=typeof b.attributes.sizes){var f=b.attributes.height;for(var g in b.attributes.sizes){var h=b.attributes.sizes[g];h.height').slideDown("fast"),c.find(".redux-remove-background").removeClass("hide"),c.find(".redux-background-input-properties").slideDown(),a.reduxBackground.preview(c.find(".upload"))}}),void d.open())},a.reduxBackground.removeImage=function(b){if(b.find(".redux-remove-background").addClass("hide")){b.find(".redux-remove-background").addClass("hide"),b.find(".upload").val(""),b.find(".upload-id").val(""),b.find(".upload-height").val(""),b.find(".upload-width").val(""),redux_change(a(b).find(".upload-id")),b.find(".redux-background-input-properties").hide();var c=b.find(".screenshot");c.slideUp(),b.find(".remove-file").unbind(),a(".section-upload .upload-notice").length>0&&a(".redux-background-upload").remove()}}}(jQuery);