;(function ($, settings) { "use strict"; if (window.Opalestate === undefined) { window.Opalestate = {}; } /** * GooglemapSearch */ var AgencyUpdateProfile = Opalestate.AgencyUpdateProfile = function ( form ) { /** * Create Google Map In Single Property Only */ function getFormData () { var formData = new FormData(); formData.append('section', 'general'); $(".cmb2-uploader-files").each( function(){ var file_btn = $( 'input.select-file', this ); var files = $(".uploader-item-preview", this ); var name = $(this).data( 'name' ); var issingle = $( this ).data('single'); $(files).each( function( i , element ){ var file = $(this).prop( 'file'); if( file ) { if( issingle ){ formData.append( name, file ); } else { formData.append( name+"["+i+"]", file ); } } } ); }); return formData; } function toggleSubmit ( _this ){ if( $( _this ).attr('disabled') == "disabled" ){ $( _this ).removeAttr( 'disabled' ); $(_this).find('i').remove( ); } else { $( _this ).attr('disabled','disabled'); $(_this).append( ' ' ); } }; function makeAjax( formData, $submit_btn ) { $.ajax({ url : opalesateJS.ajaxurl, data : formData, type : 'POST', processData: false, contentType: false, dataType: "json", success : function( response ){ if( response.status == true ){ if( response.redirect ){ window.location.href = response.redirect; } var myToast = $.toast({ heading: response.heading, text: response.message, icon: 'success', position: 'bottom-right', hideAfter: 5000, showHideTransition: 'fade', }); } else { toggleSubmit( $submit_btn ); var myToast = $.toast({ heading: response.heading, text: response.message, icon: 'error', position: 'bottom-right', hideAfter: 5000, showHideTransition: 'fade' }); } } }); } var init = function ( form ){ $( form ).on( "submit", function(){ if( typeof(tinyMCE) != "undefined" ) { tinyMCE.triggerSave(); } toggleSubmit( $("button:submit" , form ) ) ; var formData = getFormData(); var dataSubmit = $( form ).serializeArray(); $.each( dataSubmit, function ( key, input ) { formData.append( input.name, input.value ); }); makeAjax( formData, $("button:submit" , form ) ) return false; } ); } init( form ); } ///// $(document).ready(function () { /// update agency profile if( $("#opalestate_ofe_front").length > 0 ){ new AgencyUpdateProfile( $("#opalestate_ofe_front") ); } // update agent profile if( $("#opalestate_agt_front").length > 0 ){ new AgencyUpdateProfile( $("#opalestate_agt_front") ); } if( $("#opalestate_user_front").length > 0 ){ new AgencyUpdateProfile( $("#opalestate_user_front") ); } if( $("#opalestate-add-team-form").length > 0 ){ function formatRepo (repo) { if ( repo.loading ) { return repo.text; } var markup = "