Last active
July 10, 2018 14:04
-
-
Save MikeiLL/9b94ba5af7a69e74ac2a5a7dc00ab03a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
$(document).ready(function ($) { | |
var mz_mbo_state = { | |
logged: mz_mindbody_schedule.loggedMBO, // from php | |
html: undefined, | |
target: undefined, | |
siteID: undefined, | |
nonce: undefined, | |
location: undefined, | |
classID: undefined, | |
className: undefined, | |
staffName: undefined, | |
classTime: undefined, | |
login_form: $('#mzLogInContainer'), | |
initialize: function(target){ | |
this.target = $(target).attr("href"); | |
this.siteID = $(target).attr('data-siteID'); | |
this.nonce = $(target).attr("data-nonce"); | |
this.location = $(target).attr("data-location"); | |
this.classID = $(target).attr("data-classID"); | |
this.className = $(target).attr("data-className"); | |
this.staffName = $(target).attr("data-staffName"); | |
this.classTime = $(target).attr("data-time"); | |
console.log(this); | |
}, | |
states: { | |
logged_in: { | |
render: function(){ | |
mz_mbo_state.html = "rendering logged in"; | |
} | |
}, | |
logged_out: { | |
render: function(){ | |
mz_mbo_state.html = "rendering logged out"; | |
} | |
}, | |
signed_up: { | |
render: function(){ | |
mz_mbo_state.html = "rendering signed up"; | |
} | |
} | |
} | |
}; | |
/** | |
* Initial Modal Window to Register for a Class | |
* | |
* Also leads to options to login and sign-up with MBO | |
* | |
*/ | |
$(document).on('click', "a[data-target=mzSignUpModal]", function (ev) { | |
ev.preventDefault(); | |
console.log(mz_mbo_state.logged); | |
mz_mbo_state.initialize(this); | |
if ( mz_mbo_state.logged == 0 ) { // Not signed in | |
mz_mbo_state.states.logged_out.render(); | |
} else { // We are signed in | |
mz_mbo_state.states.logged_in.render(); | |
} | |
$("#mzSignUpModal").load(mz_mbo_state.target, function () { | |
$.colorbox({html: mz_mbo_state.html, href: mz_mbo_state.target}); | |
$("#mzSignUpModal").colorbox(); | |
}); | |
}); | |
}); // End document ready | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment