MacRae Speakers & Entertainment : Sign Up to Stay in Touch
Sign up to stay in touch!
(function($){
$("#emailFormat").hide();
$("#colLeftContent").hide(); $(".colRight").removeClass("colRight").addClass("colLeft");
})(jQuery);
var ea = { toggleForm: function () { if ($jq('#updateEa:visible').length > 0) { this.hideForm(); } else { this.showForm(); } $jq('#updateEa').slideToggle(); }, showForm: function() {
$jq( '.visitorActions input[name=_save]' ).attr( 'disabled', 'disabled' ); $jq( '#updateEaSuccess' ).hide(); },
hideForm: function() { $jq( '.visitorActions input[name=_save]' ).removeAttr( 'disabled' ); $jq( '#eaUpdateErrors' ).hide(); $jq( '#updateEaForm :text' ).val( '' ); },
update: function() {
$jq( '#eaUpdateErrors' ).hide();
$jq.ajax( { type: 'POST', url: $jq( '#updateEaForm' ).attr( 'action' ), dataType: "json", data: $jq( '#updateEaForm' ).serialize(), success: function( data, textStatus ) { ea._handleUpdateSuccess( data ); }, error: function( request, textStatus, errorThrown ) { ea._handleUpdateError( errorThrown ); }, beforeSend: function( request ) { $jq( '#eaUpdateWait' ).toggle(); }, complete: function( request, textStatus ) { $jq( '#eaUpdateWait' ).toggle(); } } ); },
_handleUpdateSuccess: function( rsp ) {
if ( rsp.status == 'failure' ) {
this._displayError( rsp.fieldErrors.emailAddr ); return; }
$jq( '#emailAddr' ).text( rsp.ea.emailAddr ); $jq( '#updateEaForm input[name=oldEmailAddr]' ).val( rsp.ea.emailAddr ); $jq( '#updateEaSuccess' ).show(); this.hideForm(); },
_handleUpdateError: function( error ) {
this._displayError( 'We are unable to update your email address at this time' ); },
_displayError: function( error ) {
error = error.replace( /\.ea\.[\w]+$/, '' ); // Strip off .ea.emailAddr $jq( '#eaUpdateErrors' ).text( error ); $jq( '#eaUpdateErrors' ).fadeIn( 'slow' ); } };
jQuery( document ).ready( function() {
var buttonText = { update_profile: "Update Profile", yes_unsubscribe: "Yes, unsubscribe" }; var country = $jq('[data-name="Country"]'); var street = $jq('[data-name="Street Address"]') var address_label = $jq('
',{ 'class': 'prop-input clearfix' }).append($jq('',{ html: 'Address' })); country.insertBefore(street); $jq('input[data-input="Street Address"],input[data-input="City"],input[data-input="Zip Code"]') .each(function(){ $jq(this).val($jq(this).data('input')) }); $jq('div[data-name="Street Address"],div[data-name="State/Province"],div[data-name="City"],div[data-name="Zip Code"]') .each(function(){ $jq(this).find('label').hide(); }); address_label.insertBefore(country); $jq( '#optoutAllRadio' ).click( function() { $jq( '#intCatSelection' ).hide(); $jq( '.visitorActions .btn-primary').val(buttonText.yes_unsubscribe); $jq( '#emailFormat :input' ).attr( 'disabled', 'disabled' ); $jq( '#subProfile :input' ).attr( 'disabled', 'disabled' ); }); $jq( '#optoutSomeRadio' ).click( function() { $jq( '#intCatSelection' ).slideDown(); $jq( '.visitorActions .btn-primary').val(buttonText.update_profile); $jq( '#emailFormat :input' ).removeAttr( 'disabled' ); $jq( '#subProfile :input' ).removeAttr( 'disabled' ); });if ($jq( '#optoutAllRadio:checked').length > 0) { $jq( '#optoutAllRadio').trigger("click"); }
$jq( '#updateEmailAddrLink a' ).click( function() { ea.toggleForm(); });
$jq( '#updateEa .btn-primary' ).click( function() { ea.update(); return false; });
$jq( '#updateEa .btn-secondary' ).click( function() { ea.hideForm(); return false; }); var state_select = $jq('div[data-name="State/Province"] > select'); var state_id = state_select.prop('id'); var old_state_id = state_id + '_old'; // $jq('div[data-name="Country"] > select').change(function(){ // var country = $jq(this).val(); // var state_name_prop = state_select.prop('name'); // var state_text_input = $jq('',{ // 'id': state_id, // 'data-input': "State/Province", // 'name': state_name_prop, // 'type': 'text', // 'maxlength': '50', // 'value': 'State' // }); // // if( ( country == 'ca' ) || ( country == 'us' ) ){ // // change text to select // $jq('input[data-input="State/Province"]').prop('id',old_state_id).hide(); // state_select.prop('id',state_id).show(); // } else { // //change select to text // $jq('input[data-input="State/Province"]').remove(); // state_text_input.insertBefore(state_select).show(); // state_select.prop('id',old_state_id).hide(); // } // });
});