// JavaScript Document var day_state = {"Su":0,"M":0,"Tu":0,"W":0,"Th":0,"F":0,"Sa":0}; if(jQuery.fn.qtip) { $.fn.qtip.styles.mystyle = { // Last part is the name of the style width: 400, background: '#fff', color: '#133636', textSize: '14px', textAlign: 'left', fontFamily: 'Arial, Helvetica, sans-serif', border: { width: 7, radius: 10, color: '#999' }, tip: 'bottomLeft', name: 'dark' // Inherit the rest of the attributes from the preset dark style } $.fn.qtip.styles.errstyle = { // Last part is the name of the style width: 200, background: '#fff', color: '#FF0000', textSize: '14px', textAlign: 'left', fontFamily: 'Arial, Helvetica, sans-serif', cursor: 'pointer', border: { width: 7, radius: 10, color: '#F00' }, tip: 'bottomRight', name: 'dark' // Inherit the rest of the attributes from the preset dark style } } /* Object.prototype.convertToArray = function(n) { if (! this.length) {return [];} // length must be set on the object, or it is not iterable var a = []; try { a = Array.prototype.slice.call(this, n); } // IE 6 and posssibly other browsers will throw an exception, so catch it and use brute force catch(e) { Core.batch(this, function(o, i) { if (n <= i) { a[i - n] = o; } }); } return a; };*/ function checkdays(d) { c=0; for (var k in day_state) { if (day_state[k] > 0 || k==d) { if (k!=d) { c++; } else if (day_state[d]==0) { c++; } } else { c=0; } if (c>2) { return false; } } return true; } function show_response(responseText, statusText) { jQuery.each(responseText, function(k,v) { if (k=='feedback'){ $('#feedback').removeClass("hide").html(v); } else { /*$('#'+k).qtip({ content: {text: v}, show: {ready: true}, style: {name: 'red'} });*/ $('#'+k).css('background-color', '#F79992'); } }); } function clear_errors(formData, jqForm, options) { jQuery.each(formData, function(i, o) { $('#'+o.name+'').css('background-color', '#FFFFFF'); //$('#'+o.name+'').qtip("destroy"); }); return true; } // Create the tooltips only on document load $(document).ready(function() { if(jQuery.fn.qtip) { // By suppling no content attribute, the library uses each elements title attribute by default $('.footerAnchor a[href][title]').qtip({ content: { text: false // Use each elements title attribute }, position: { corner: { target: 'topMiddle', tooltip: 'bottomLeft' } }, style: 'mystyle' // Give it some style }); $('#errorBox a[title]').qtip({ content: { text: false // Use each elements title attribute }, position: { corner: { target: 'topMiddle', tooltip: 'bottomRight' } }, style: 'errstyle' // Give it some style }); } if(jQuery.fn.ajaxSubmit) { // handle forms on account page. var options = { beforeSubmit: clear_errors, // pre-submit callback success: show_response, // post-submit callback dataType: 'json', url: '/user/account/ajax' }; $('#feedback').addClass("hide"); $('#frm_personal_info').ajaxForm(options); $('#frm_password').ajaxForm(options); $('#frm_creditcard').ajaxForm(options); } // NOTE: You can even omit all options and simply replace the regular title tooltips like so: // $('#content a[href]').qtip(); $('#headerLogin #password').hide(); $('#headerLogin #email').focus(function () { $(this).val(""); $('#headerLogin #email').focus(); }); $('#headerLogin #passwordMoc').focus(function () { //$(this).val(""); $(this).hide(); $('#headerLogin #password').show(); $('#headerLogin #password').focus(); }); $('#oneRepMaxTip').click(function (){ $('#footerNotes').slideToggle("slow"); }); $('#workoutDaysContainer span').each(function(i){ day_state[$(this).text()] = ($(this).hasClass('selected'))?1:0; }); $('#AltWorkoutDaysContainer span').each(function(i){ if ( $(this).hasClass('selected') ) { day_state[$(this).text()] = 2; } }); $('#workoutDaysContainer span').click(function (){ var d=$(this).text(); if ( !checkdays(d) ) { return false; } $(this).toggleClass('selected') .toggleClass('notSelected'); day_state[d] = ($(this).hasClass('selected'))?1:0; $("#AltWorkoutDaysContainer span:contains('"+d+"')") .removeClass('selected') .addClass('notSelected'); console.log(day_state); }); $('#AltWorkoutDaysContainer span').click(function (){ var d=$(this).text(); if ( !checkdays(d) ) { return false; } $(this).toggleClass('selected') .toggleClass('notSelected'); day_state[d] = ($(this).hasClass('selected'))?2:0; $("#workoutDaysContainer span:contains('"+d+"')") .removeClass('selected') .addClass('notSelected'); console.log(day_state); }); $('.h1iconPreferences').click(function (){ $(this).parents('.secondBox').find('.innerBox').toggle('fast'); }); $("#formPrefs").submit(function() { $(this).append(""); }); $("#sendmail").click(function() { if (confirm('Are you sure you want to send your excercises to your email account?')) { $("#feedback").removeClass("hide").load("/user/sendmail"); } return false; }); $("#sendtext").click(function() { if (confirm('Are you sure you want to text your excercises to your phone?')) { $("#feedback").removeClass("hide").load("/user/sendtext"); } return false; }); });