Skip to content

Instantly share code, notes, and snippets.

@MikeiLL
Last active July 10, 2018 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikeiLL/9b94ba5af7a69e74ac2a5a7dc00ab03a to your computer and use it in GitHub Desktop.
Save MikeiLL/9b94ba5af7a69e74ac2a5a7dc00ab03a to your computer and use it in GitHub Desktop.
(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