Advertisement
Guest User

main.min.js

a guest
Sep 23rd, 2014
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function(e){"use strict";redux.field_objects=redux.field_objects||{};redux.field_objects.media=redux.field_objects.media||{};e(document).ready(function(){});redux.field_objects.media.init=function(t){if(!t){t=e(document).find(".redux-container-media")}e(t).each(function(){var t=e(this);var n=t;if(!t.hasClass("redux-field-container")){n=t.parents(".redux-field-container:first")}if(n.hasClass("redux-field-init")){n.removeClass("redux-field-init")}else{return}t.find(".remove-image, .remove-file").unbind("click").on("click",function(){redux.field_objects.media.removeFile(e(this).parents("fieldset.redux-field:first"))});t.find(".media_upload_button").unbind().on("click",function(t){redux.field_objects.media.addFile(t,e(this).parents("fieldset.redux-field:first"))})})};redux.field_objects.media.addFile=function(t,n){t.preventDefault();var r;var i=e(this);if(r){r.open();return}r=wp.media({multiple:false,library:{},title:i.data("choose"),button:{text:i.data("update")}});r.on("select",function(){var t=r.state().get("selection").first();r.close();console.log(n);var i=e(n).find(".data").data();if(typeof redux.field_objects.media==="undefined"||typeof redux.field_objects.media===undefined){redux.field_objects.media={}}n.find(".upload").val(t.attributes.url);n.find(".upload-id").val(t.attributes.id);n.find(".upload-height").val(t.attributes.height);n.find(".upload-width").val(t.attributes.width);redux_change(e(n).find(".upload-id"));var s=t.attributes.url;if(typeof t.attributes.sizes!=="undefined"&&typeof t.attributes.sizes.thumbnail!=="undefined"){s=t.attributes.sizes.thumbnail.url}else if(typeof t.attributes.sizes!=="undefined"){var o=t.attributes.height;for(var u in t.attributes.sizes){var a=t.attributes.sizes[u];if(a.height<o){o=a.height;s=a.url}}}else{s=t.attributes.icon}n.find(".upload-thumbnail").val(s);if(!n.find(".upload").hasClass("noPreview")){n.find(".screenshot").empty().hide().append('<img class="redux-option-image" src="'+s+'">').slideDown("fast")}n.find(".remove-image").removeClass("hide");n.find(".redux-background-properties").slideDown()});r.open()};redux.field_objects.media.removeFile=function(t){if(!t.find(".remove-image").addClass("hide")){return}t.find(".remove-image").addClass("hide");t.find(".upload").val("");t.find(".upload-id").val("");t.find(".upload-height").val("");t.find(".upload-width").val("");t.find(".upload-thumbnail").val("");redux_change(e(t).find(".upload-id"));t.find(".redux-background-properties").hide();var n=t.find(".screenshot");n.slideUp();t.find(".remove-file").unbind();if(t.find(".section-upload .upload-notice").length>0){t.find(".media_upload_button").remove()}}})(jQuery)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement