File: /home/madepabj/www/wp-content/plugins/rehub-framework/vendor/vafpress/public/js/metabox.min.js
(function(h){var f=[];var b=[];var a=[];var j=[];h(document).on("click",".vp-wpa-group-title",function(o){o.preventDefault();var n=h(this).parents(".wpa_group:first");var m=n.find(".vp-controls:first");var p=n.siblings(".wpa_group:not(.tocopy)");var l=h("html, body");if(m.hasClass("vp-hide")){if(p.exists()){p.each(function(q,r){h(this).find(".vp-controls").first().slideUp("fast",function(){h(this).addClass("vp-hide").slideDown(0,function(){if(q==p.length-1){l.animate({scrollTop:n.offset().top-h("#wpadminbar").height()}).promise().done(function(){m.slideUp(0,function(){h(this).removeClass("vp-hide").slideDown("fast")})})}})})})}else{l.animate({scrollTop:n.offset().top-h("#wpadminbar").height()}).promise().done(function(){m.slideUp(0,function(){h(this).removeClass("vp-hide").slideDown("fast")})})}}else{m.slideUp("fast",function(){h(this).addClass("vp-hide").slideDown(0)})}return false});function e(l){l.each(function(){if(h(this).parents(".tocopy").length<=0){vp.init_controls(h(this));var s=h(this).attr("id"),m=h(this).attr("id"),q=h(this).attr("data-vp-validation"),r=h(this).attr("data-vp-bind"),o=h(this).attr("data-vp-items-bind"),p=h(this).attr("data-vp-dependency"),n=h(this).getDatas().type;q&&f.push({name:s,rules:q,type:n});if(typeof r!=="undefined"&&r!==false){r&&b.push({bind:r,type:n,source:s})}if(typeof o!=="undefined"&&o!==false){o&&a.push({bind:o,type:n,source:s})}if(typeof p!=="undefined"&&p!==false){p&&j.push({dep:p,type:"field",source:s})}}})}function k(l){l.each(function(){if(h(this).parents(".tocopy").length<=0&&!h(this).hasClass(".tocopy")){var n=h(this).attr("data-vp-dependency"),m=h(this).getDatas().type,o=h(this).attr("id");if(typeof n!=="undefined"&&n!==false){n&&j.push({dep:n,type:"section",source:o})}}})}function c(){var l=[];h(".wpa_loop.vp-sortable").sortable({items:">.wpa_group",handle:".vp-wpa-group-heading",axis:"y",opacity:0.5,tolerance:"pointer",start:function(m,n){if(typeof window.KIA_metabox!=="undefined"){l=[];vp.tinyMCE_save();h(n.item).find(".customEditor textarea").each(function(){if(h(this).parents(".tocopy").length<=0){try{tinyMCE.execCommand("mceRemoveControl",false,this.id)}catch(o){}l.push(vp.jqid(this.id))}})}},stop:function(n,o){if(typeof window.KIA_metabox!=="undefined"){for(var m=l.length-1;m>=0;m--){var q=h(l[m]);q.val(switchEditors.wpautop(q.val()))}l=l.join(", ");try{KIA_metabox.runTinyMCE(h(l));vp.tinyMCE_save();for(var m=l.length-1;m>=0;m--){var q=h(l[m]);q.val(switchEditors.pre_wpautop(q.val()))}}catch(p){}}}})}h(document).ready(function(){e(jQuery(".vp-metabox .vp-field"));k(jQuery(".vp-metabox .vp-meta-group"));d(b);g(a);i(j);c()});vp.is_multianswer=function(l){var m=["vp-checkbox","vp-checkimage","vp-multiselect"];if(jQuery.inArray(l,m)!==-1){return true}return false};vp.custom_check_radio_event(".vp-metabox",".vp-field.vp-checkimage .field .input label");vp.custom_check_radio_event(".vp-metabox",".vp-field.vp-radioimage .field .input label");h("#post").on("submit",function(o){var n=h("input[type=submit][clicked=true]"),m=n.val(),p=0;vp.tinyMCE_save();h(".vp-field").removeClass("vp-error");h(".validation-msg.vp-error").remove();h(".vp-metabox-error").remove();p=vp.fields_validation_loop(f);if(p>0){$notif=h('<span class="vp-metabox-error vp-js-tipsy" original-title="'+p+' error(s) found in metabox"></span>');if(m==="Save Draft"){h("#minor-publishing-actions .spinner, #minor-publishing-actions .ajax-loading").hide();$notif.tipsy();$notif.insertAfter("#minor-publishing-actions .spinner, #minor-publishing-actions .ajax-loading");h("#save-post").prop("disabled",false).removeClass("button-disabled")}else{if(m==="Publish"||m==="Update"){h("#publishing-action .spinner, #publishing-action .ajax-loading").hide();$notif.tipsy();$notif.insertAfter("#publishing-action .spinner, #publishing-action .ajax-loading");h("#publish").prop("disabled",false).removeClass("button-primary-disabled")}}var l=Math.ceil((n.outerHeight()-$notif.height())/2);if(l>0){$notif.css("margin-top",l)}o.preventDefault();return}h(this).find(".vp-toggle .vp-input").each(function(){var q=h("<input>",{type:"hidden",name:this.name,value:0});h(this).before(q)})});h("#post input[type=submit]").on("click", function(){h("input[type=submit]",h(this).parents("form")).removeAttr("clicked");h(this).attr("clicked","true")});function d(m){for(var p=0;p<m.length;p++){var r=m[p];var t=r.bind.split("|");var n=t[0];var s=t[1];var l=[];var q="";q=r.source.replace("[]","");q=q.substring(0,q.lastIndexOf("["));s=s.split(/[\s,]+/);for(var o=0;o<s.length;o++){s[o]=q+"["+s[o]+"]";l.push(s[o])}for(o=0;o<l.length;o++){vp.binding_event(l,o,r,n,".vp-metabox","metabox")}}}function g(l){for(var p=0;p<l.length;p++){var r=l[p];var t=r.bind.split("|");var n=t[0];var s=t[1];var m=[];var q="";q=r.source.replace("[]","");q=q.substring(0,q.lastIndexOf("["));s=s.split(/[\s,]+/);for(var o=0;o<s.length;o++){s[o]=q+"["+s[o]+"]";m.push(s[o])}for(o=0;o<m.length;o++){vp.items_binding_event(m,o,r,n,".vp-metabox","metabox")}}}function i(r){for(var o=0;o<r.length;o++){var s=r[o];var u=s.dep.split("|");var m=u[0];var t=u[1];var l=[];var p="";if(s.type==="field"){p=s.source.replace("[]","");p=p.substring(0,p.lastIndexOf("["))}else{if(s.type==="section"){var q=jQuery(vp.jqid(s.source));if(q.parents(".wpa_group").length>0){p=jQuery(vp.jqid(s.source)).parents(".wpa_group").first().attr("id")}else{p=jQuery(vp.jqid(s.source)).parents(".postbox").attr("id");p=p.substring(0,p.lastIndexOf("_"))}}}t=t.split(",");for(var n=0;n<t.length;n++){t[n]=p+"["+t[n]+"]";l.push(t[n])}for(n=0;n<l.length;n++){vp.dependency_event(l,n,s,m,".vp-metabox")}}}h.wpalchemy.on("wpa_copy",function(l,m){b=[];j=[];a=[];m.find('input[class="tocopy-hidden"]').first().remove();e(m.find(".vp-field"));k(m.find(".vp-meta-group"));m.find(".vp-wpa-group-title:first").trigger("click");d(b);g(a);i(j)})}(jQuery));
jQuery( function( $ ) {
if ($('#rh_post_images_container').length > 0) {
// Product gallery file uploads.
var post_gallery_frame;
var $image_gallery_ids = $( '#rh_post_image_gallery' );
var $post_images = $( '#rh_post_images_container' ).find( 'ul.rh_post_images' );
$( '.rh_add_post_images' ).on( 'click', 'a', function( event ) {
var $el = $( this );
event.preventDefault();
// If the media frame already exists, reopen it.
if ( post_gallery_frame ) {
post_gallery_frame.open();
return;
}
// Create the media frame.
post_gallery_frame = wp.media.frames.post_gallery = wp.media({
// Set the title of the modal.
title: $el.data( 'choose' ),
button: {
text: $el.data( 'update' )
},
states: [
new wp.media.controller.Library({
title: $el.data( 'choose' ),
filterable: 'all',
multiple: true
})
]
});
// When an image is selected, run a callback.
post_gallery_frame.on( 'select', function() {
var selection = post_gallery_frame.state().get( 'selection' );
var attachment_ids = $image_gallery_ids.val();
selection.map( function( attachment ) {
attachment = attachment.toJSON();
if ( attachment.id ) {
attachment_ids = attachment_ids ? attachment_ids + ',' + attachment.id : attachment.id;
var attachment_image = attachment.sizes && attachment.sizes.thumbnail ? attachment.sizes.thumbnail.url : attachment.url;
$post_images.append( '<li class="image" data-attachment_id="' + attachment.id + '"><img src="' + attachment_image + '" /><ul class="actions"><li><a href="#" class="delete" title="' + $el.data('delete') + '">' + $el.data('text') + '</a></li></ul></li>' );
}
});
$image_gallery_ids.val( attachment_ids );
});
// Finally, open the modal.
post_gallery_frame.open();
});
// Image ordering.
$post_images.sortable({
items: 'li.image',
cursor: 'move',
scrollSensitivity: 40,
forcePlaceholderSize: true,
forceHelperSize: false,
helper: 'clone',
opacity: 0.65,
placeholder: 'rh-metabox-sortable-placeholder',
start: function( event, ui ) {
ui.item.css( 'background-color', '#f6f6f6' );
},
stop: function( event, ui ) {
ui.item.removeAttr( 'style' );
},
update: function() {
var attachment_ids = '';
$( '#rh_post_images_container' ).find( 'ul li.image' ).css( 'cursor', 'default' ).each( function() {
var attachment_id = $( this ).attr( 'data-attachment_id' );
attachment_ids = attachment_ids + attachment_id + ',';
});
$image_gallery_ids.val( attachment_ids );
}
});
// Remove images.
$( '#rh_post_images_container' ).on( 'click', 'a.delete', function() {
$( this ).closest( 'li.image' ).remove();
var attachment_ids = '';
$( '#rh_post_images_container' ).find( 'ul li.image' ).css( 'cursor', 'default' ).each( function() {
var attachment_id = $( this ).attr( 'data-attachment_id' );
attachment_ids = attachment_ids + attachment_id + ',';
});
$image_gallery_ids.val( attachment_ids );
// Remove any lingering tooltips.
$( '#tiptip_holder' ).removeAttr( 'style' );
$( '#tiptip_arrow' ).removeAttr( 'style' );
return false;
});
}
});