$(document).ready(function(e) { $('.rw_sc_target').each(function(index){ var rw_sc_options = "no_options"; //dynamically assign ids $(this).attr("id","rw_sc_"+index); var rw_sc_types = $(this).attr("type"); var rw_sc_data = $(this).html(); var rw_sc_options_check = $(this).attr("options"); if(rw_sc_options_check){ rw_sc_options = rw_sc_options_check; };//close if /**************************************** IF A GALLERY ADD THE LOADER ****************************************/ /************************************************* if(rw_sc_types == "gallery"){ //get each gallery's full specs var rw_gal = $("#rw_sc_"+index); var rw_gal_pos = rw_gal.position(); var rw_gal_top = rw_gal_pos.top; var rw_gal_left = rw_gal_pos.left; var rw_gal_width = rw_gal.width(); var rw_gal_height = rw_gal.height(); //alert(rw_gal_width); //dynamic deploy a white overlay with loader $( "#rw_sub_contents" ).prepend( "
" ); $("#rw_loader_"+index).css({'top':rw_gal_top+'px'}); };//close if ***************************************************/ if(rw_sc_data.substr(0,rw_sc_data.indexOf("-")) == ""){rw_sc_data=rw_sc_data;}else{ rw_sc_data = rw_sc_data.substr(0,rw_sc_data.indexOf("-")); } var rw_sc_token = $("#csrf_token").val(); $.ajax({ type: "get", url: "/rw_shortcodes/rw_sc_ajax_response", data: { rw_sc_types_passed: rw_sc_types, rw_sc_data_passed: rw_sc_data, rw_sc_options_passed: rw_sc_options, csrf_token:rw_sc_token, rw_sc_index:index} }) .done(function(rw_response) { console.log('shortcode callback initiated'); $('#rw_sc_'+index).html(rw_response); if(rw_sc_types == 'gallery'){ //get each gallery's full specs var rw_gal = $("#rw_sc_"+index); var rw_gal_pos = rw_gal.position(); var rw_gal_top = rw_gal_pos.top; var rw_gal_left = rw_gal_pos.left; var rw_gal_width = rw_gal.width(); var rw_gal_height = rw_gal.height(); //alert("rw_sc_"+index); //dynamic pos a white overlay with loader $("#rw_loader_"+index).css({ //'top':rw_gal_top+'px', 'height':rw_gal_height+'px' }); $('#rw_sc_'+index).css('display','block'); /*** RW AUTO CROPPER (WORKS WITH GALLERY) ***************************/ setTimeout(function(){ $(".rw_crop_a").each(function(e){ var t=$(this).children("img"); var n=t.height(); var r=t.width(); //console.log(r); if(r>200){t.css({width:200+"px"}); if(t.height()<200){t.css({width:"auto"}); t.css({height:200+"px"}) } } var i=t.height(); var s=t.width(); var o=-((i-150)/2); var u=-((s-150)/2); t.css({"margin-top":o+"px"}); t.css({"margin-left":u+"px"}); //$("#rw_loader_"+index).fadeOut(); $("a[rel^='prettyPhoto']").prettyPhoto({social_tools:false,deeplinking:false}); }) },3000); }else if(rw_sc_types == 'inline_contact'){$('#rw_sc_'+index).css('display','inline-block');}else if(rw_sc_types == 'library_inline'){$('#rw_sc_'+index).css('display','inline-block');}else{$('#rw_sc_'+index).css('display','block');}//close if block }).fail(function(error){ alert('failed ' + error.statusText); });//close full ajax block });//close the each loop }); //close ready event $(window).load(function(){ /**** $( "#rw_sub_left" ).delegate( ".rw_photo_gallery_loader", "click", function() {$(this).fadeOut();}); *****/ });