balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

redux-background.min.js (5241B)


      1 !function(o){"use strict";redux.field_objects=redux.field_objects||{},redux.field_objects.background=redux.field_objects.background||{},redux.field_objects.background.init=function(e){e=o.redux.getSelector(e,"background"),o(e).each(function(){var t=o(this),e=t;t.hasClass("redux-field-container")||(e=t.parents(".redux-field-container:first")),e.is(":hidden")||e.hasClass("redux-field-init")&&(e.removeClass("redux-field-init"),t.find(".redux-remove-background").off("click").on("click",function(e){return e.preventDefault(),redux.field_objects.background.removeImage(o(this).parents(".redux-container-background:first")),redux.field_objects.background.preview(o(this)),!1}),t.find(".redux-background-upload").off().on("click",function(e){redux.field_objects.background.addImage(e,o(this).parents(".redux-container-background:first"))}),t.find(".redux-background-input").on("change",function(){redux.field_objects.background.preview(o(this))}),t.find(".redux-color").wpColorPicker({change:function(e,r){o(this).val(r.color.toString()),redux_change(o(this)),o("#"+e.target.id+"-transparency").removeAttr("checked"),redux.field_objects.background.preview(o(this))},clear:function(e){redux_change(o(this).parent().find(".redux-color-init")),redux.field_objects.background.preview(o(this))}}),t.find(".redux-color").on("blur",function(){var e=o(this).val(),r="#"+o(this).attr("id");"transparent"===e?(o(this).parent().parent().find(".wp-color-result").css("background-color","transparent"),t.find(r+"-transparency").attr("checked","checked")):(colorValidate(this)===e&&0!==e.indexOf("#")&&o(this).val(o(this).data("oldcolor")),t.find(r+"-transparency").removeAttr("checked"))}),t.find(".redux-color").on("focus",function(){o(this).data("oldcolor",o(this).val())}),t.find(".redux-color").on("keyup",function(){var e=o(this).val(),r=colorValidate(this),i="#"+o(this).attr("id");"transparent"===e?(o(this).parent().parent().find(".wp-color-result").css("background-color","transparent"),t.find(i+"-transparency").attr("checked","checked")):(t.find(i+"-transparency").removeAttr("checked"),r&&r!==o(this).val()&&o(this).val(r))}),t.find(".color-transparency").on("click",function(){var e;o(this).is(":checked")?(t.find(".redux-saved-color").val(o("#"+o(this).data("id")).val()),t.find("#"+o(this).data("id")).val("transparent"),t.find("#"+o(this).data("id")).parents(".redux-field-container").find(".wp-color-result").css("background-color","transparent")):(""===(e=o(this).parents(".redux-field-container").find(".redux-saved-color").val())&&(e=o("#"+o(this).data("id")).data("default-color")),t.find("#"+o(this).data("id")).parents(".redux-field-container").find(".wp-color-result").css("background-color",e),t.find("#"+o(this).data("id")).val(e)),redux_change(o(this))}),t.find(" .redux-background-repeat, .redux-background-clip, .redux-background-origin, .redux-background-size, .redux-background-attachment, .redux-background-position").select2())})},redux.field_objects.background.preview=function(e){var r,i=!0,t=o(e).parents(".redux-container-background:first"),d=o(t).find(".background-preview");d&&(r="height:"+d.height()+"px;",o(t).find(".redux-background-input").each(function(){var e=o(this).serializeArray();(e=e[0])&&-1!==e.name.indexOf("[background-")&&""!==e.value&&(i=!1,e.name=e.name.split("[background-"),e.name="background-"+e.name[1].replace("]",""),"background-image"===e.name?r+=e.name+':url("'+e.value+'");':r+=e.name+":"+e.value+";")}),i?d.slideUp():d.attr("style",r).fadeIn())},redux.field_objects.background.addImage=function(e,a){var n,r=o(this);e.preventDefault(),n||(n=wp.media({multiple:!1,library:{},title:r.data("choose"),button:{text:r.data("update")}})).on("select",function(){var e,r,i,t,d=n.state().get("selection").first();if(n.close(),"image"===d.attributes.type){if(a.find(".upload").val(d.attributes.url),a.find(".upload-id").val(d.attributes.id),a.find(".upload-height").val(d.attributes.height),a.find(".upload-width").val(d.attributes.width),redux_change(o(a).find(".upload-id")),e=d.attributes.url,void 0!==d.attributes.sizes&&void 0!==d.attributes.sizes.thumbnail)e=d.attributes.sizes.thumbnail.url;else if(void 0!==d.attributes.sizes)for(i in r=d.attributes.height,d.attributes.sizes)d.attributes.sizes.hasOwnProperty(i)&&(t=d.attributes.sizes[i]).height<r&&(r=t.height,e=t.url);else e=d.attributes.icon;a.find(".upload-thumbnail").val(e),a.find(".upload").hasClass("noPreview")||a.find(".screenshot").empty().hide().append('<img class="redux-option-image" src="'+e+'">').slideDown("fast"),a.find(".redux-remove-background").removeClass("hide"),a.find(".redux-background-input-properties").slideDown(),redux.field_objects.background.preview(a.find(".upload"))}}),n.open()},redux.field_objects.background.removeImage=function(e){e.find(".redux-remove-background").addClass("hide")&&(e.find(".redux-remove-background").addClass("hide"),e.find(".upload").val(""),e.find(".upload-id").val(""),e.find(".upload-height").val(""),e.find(".upload-width").val(""),redux_change(o(e).find(".upload-id")),e.find(".redux-background-input-properties").hide(),e.find(".screenshot").slideUp(),e.find(".remove-file").off(),0<o(".section-upload .upload-notice").length&&o(".redux-background-upload").remove())}}(jQuery);