jQuery(document).ready((function($){var time_tally;$.ajaxSetup({headers:{"X-WP-Nonce":wpt_rest.nonce}});var agenda_add_minutes=function(dt,minutes){return new Date(dt.getTime()+6e4*minutes)};function agenda_time_format(time_tally){var hour=time_tally.getHours(),minute=time_tally.getMinutes(),ampm=hour>=12?"pm":"am";return minute<10&&(minute="0"+minute),(hour=hour>=12?hour-12:hour)+":"+minute+" "+ampm}var agenda_time_tally=function(){$("#rsvpsection").html(""),time_tally=new Date($("#tweak_time_start").val()),$(".time_allowed").each((function(index){var block_count=$(this).attr("block_count"),formatted=agenda_time_format(time_tally);$("#cacltime"+index).fadeTo("fast",.1),$("#calctime"+index).text(formatted),$("#calctime"+index).delay(50*index).fadeTo("fast",1);var tallyadd=0,addthis=Number($(this).val());isNaN(addthis)||(tallyadd+=addthis);var padding=$(this).attr("id").replace("time_allowed","padding_time");addthis=Number($("#"+padding).val()),isNaN(addthis)||(tallyadd+=addthis),time_tally=agenda_add_minutes(time_tally,tallyadd)})),$("#tweak_time_end").text(agenda_time_format(time_tally))};void 0!==tm_vars.tweak_times&&agenda_time_tally(),$(".time_allowed").on("change",(function(){agenda_time_tally()})),$(".padding_time").on("change",(function(){agenda_time_tally()})),$(".count").on("change",(function(){var role=$(this).attr("role"),block_count=$(this).attr("block_count"),count=$(this).val(),time=0;"Speaker"==role?(time=7*parseInt(count),$("#time_allowed_"+block_count).val(time),agenda_time_tally()):"Evaluator"==role&&(time=3*parseInt(count),$("#time_allowed_"+block_count).val(time),agenda_time_tally())})),$("#tweak_times_form").submit((function(event){event.preventDefault(),$("#tweak_times_result").html("Updating ..."),data=$("#tweak_times_form").serialize(),jQuery.post(wpt_rest.url+"rsvptm/v1/tweak_times",data,(function(response){$("#tweak_times_result").html(response.next)}))})),$(".planner_edits_wrapper").hide(),$(".planner_edits_checkbox").click((function(){var index=$(this).val();index=index.replace(".","\\."),console.log("index "+index),console.log($("#check-wrapper-"+index).html()),$("#check-wrapper-"+index).hide(),$("#wrapper-"+index).show()})),$(".role_remove").click((function(){var block_count=$(this).val();$("#time_allowed_"+block_count).val(0),$("#padding_time_"+block_count).val(0),$("#count_"+block_count).val(0),$("#timeline_"+block_count).fadeOut(),agenda_time_tally()})),$(".remove_names").click((function(){$(".remove_absences").show(),$(".remove_in_person").show(),$(".remove_names_line").hide()})),$(".tmsortable").sortable({containment:"parent",cursor:"move",update:function(event,ui){for(var datastr="action=wpt_reorder&post_id="+this.closest(".post_id"),order=$(this).sortable("toArray"),assigned=0,basefield=order[0].replace(/_[0-9]+/,""),field=basefield+"[]",post_id=$("#"+basefield+"post_id").val(),datastr="action=wpt_reorder&reorder_nonce="+$("#reorder_nonce").val()+"&post_id="+post_id,arrayLength=order.length,i=0;i<arrayLength;i++)void 0!==(assigned=$("#"+order[i]+"_assigned").val())&&(datastr=datastr+"&"+field+"="+assigned);var id=$(this).prop("id");$("#"+id+"_sortresult").text("Working ...");var ajaxurl=wpt_rest.url+"rsvptm/v1/reorder";console.log(ajaxurl),console.log(datastr),jQuery.post(ajaxurl,datastr,(function(response){console.log(response),$("#"+id+"_sortresult").html(response),$("#"+id+"_sortresult").fadeIn(200)}))}}),$(".tmsortable").disableSelection(),$("div.role-block").mouseenter((function(){$(this).css("background-color","#EFEFEF")})),$("div.role-block").mouseleave((function(){$(this).css("background-color","white")}));var menu=$("#cssmenu"),menuList=menu.find("ul:first"),listItems=menu.find("li").not("#responsive-tab");menuList.prepend('<li id="responsive-tab"><a href="#">Menu</a></li>'),menu.on("click","#responsive-tab",(function(){listItems.slideToggle("fast"),listItems.addClass("collapsed")}));var sum=0;$(".maxtime").each((function(){sum+=Number($(this).val())}));var time_limit=0;$(".time_limit").each((function(){time_limit+=Number($(this).val())})),0!=time_limit&&sum>time_limit?$(".time_message").html("Time reserved, all speakers: "+sum+' minutes <span style="color:red;">(limit:'+time_limit+")</span>"):0!=time_limit&&sum>0?$(".time_message").html("Time reserved, all speakers: "+sum+" minutes (limit:"+time_limit+")."):sum>0&&$(".time_message").html("Time reserved, all speakers: "+sum+" minutes."),$(".recommend_instead").on("click",(function(){var target=this.value,role=target.replace("_rm","");$("#"+target).html('<p>Add a personal note (optional):<br /><textarea rows="3" cols="40" name="editor_suggest_note['+role+']"></textarea><br /><input type="checkbox" name="ccme" value="1" /> Send me a copy</p>')}));var suggest_mode=!1;$(".editor_assign").on("change",(function(){if(!suggest_mode){var user_id=this.value,id,parts,role=this.id.split("editor_assign")[1];if($('input[name="recommend_instead'+role+'"]').is(":checked"))return!1;$("#_manual_"+role).html(project_list.manuals),$("#_project_"+role).html('<option value="">Pick Manual for Project List</option>'),$("#title_text"+role).val(""),$("#_intro_"+role).val("");var post_id=$(this).attr("post_id"),editor_id=$("#editor_id").val();if($("#status"+role).html("Saving ... "+role),post_id>0){var data={action:"editor_assign",role:role,user_id:user_id,editor_id:editor_id,post_id:post_id,timelord:rsvpmaker_rest.timelord};$.post(wpt_rest.url+"rsvptm/v1/editor_assign",data,(function(response){var test;(response.status&&$("#status"+role).html(response.status),response.list)&&(void 0!==$("#_manual_"+role).val()?($("#_manual_"+role).html(response.list),$("#_project_"+role).html(response.projects),$("#_manualtype_"+role).val(response.type)):($("#editone_manual_"+role).html(response.list),$("#editone_project_"+role).html(response.projects),$("#editone_manualtype_"+role).val(response.type),$("#editone_title_text"+role).val(""),$("#editone_intro_"+role).val("")))}))}}})),$(".manual").on("change",(function(){var manual=this.value,target=this.id.replace("manual","project"),list=project_list.projects[manual];$("#"+target).html('<option value="">Pick a Project</option>'+list)})),$(".manualtype").on("change",(function(){var manualtype=this.value,target=this.id.replace("manualtype","manual"),projects_target=this.id.replace("manualtype","project"),current=$("#"+target).val();$.get(wpt_rest.url+"rsvptm/v1/type_to_manual/"+manualtype,(function(data){data.list&&($("#"+target).html(data.list),$("#"+projects_target).html(data.projects))}))})),$(".project").on("change",(function(){var project=this.value,time_id=this.id.replace("project","maxtime"),display_time_id=this.id.replace("project","display_time"),time_msg_id=this.id.replace("project","tmsg"),time=project_times[project],display_time=display_times[project];if($("#"+time_id).val(time),$("#"+display_time_id).val(display_time),!(this.id.indexOf("Backup")>-1)){var sum=0;$(".maxtime").each((function(){sum+=Number($(this).val())})),0!=time_limit&&sum>time_limit?($("#"+time_msg_id).html('<span style="color:red">This choice would push the total time required for speeches over the limit set for the agenda ('+time_limit+" minutes). You may need to speak to club and meeting organizers about adjusting the agenda. You can also manually adjust the Time Required field if you do not need the maximum time specified by the manual.</span>"),$(".time_message").html("Time reserved, all speakers: "+sum+' minutes <span style="color: red;">(limit:'+time_limit+")</span>.")):0!=time_limit&&sum>0?($(".time_message").html("Time reserved, all speakers: "+sum+" minutes (limit:"+time_limit+")."),$("#"+time_msg_id).html("")):sum>0&&($(".time_message").html("Time reserved, all speakers: "+sum+" minutes."),$("#"+time_msg_id).html(""))}})),$(".moremeetings").hide(),$("#showmore").click((function(){$(".moremeetings").slideDown(),$("#showmore").hide()})),$(".tm_edit_detail").submit((function(event){event.preventDefault();var $form=$(this),status=$(this).attr("status");data=$form.serialize(),jQuery.post(ajaxurl,data,(function(response){$("#form"+status).html(response),$("#delete"+status).html("")}))})),$(".delete_tm_detail").click((function(event){event.preventDefault();var key=$(this).attr("key"),status=$(this).attr("status"),user_id=$("#user_id_"+status).val();data={action:"delete_tm_detail",timelord:rsvpmaker_rest.timelord,user_id:user_id,key:key},jQuery.post(ajaxurl,data,(function(response){$("#form"+status).html(response),$("#delete"+status).html("")}))})),$(document).on("submit","form.toastrole",(function(event){event.preventDefault();var conjunction=wpt_rest.url.indexOf("?")>0?"&":"?",action=wpt_rest.url+"rsvptm/v1/tm_role"+conjunction+"tm_ajax=role",formid=$(this).attr("id"),data=$(this).serialize();$("#"+formid).html('<div style="line-height: 3">Saving ...</div>'),setTimeout((function(){$("#"+formid).addClass("bounce")}),1e3),jQuery.post(action,data,(function(response){$("#"+formid).html(response.content),$("#"+formid).removeClass("bounce"),$("#"+formid).css("opacity","1"),$("#"+formid).css("display","block"),$("#"+formid).addClass("grow")}))})),$(document).on("submit","form.remove_me_form",(function(event){event.preventDefault();var action=wpt_rest.url+"rsvptm/v1/tm_role?tm_ajax=remove_role",formid=$(this).attr("id");$("#"+formid).hide();var signup_id=formid.replace("remove",""),data=$(this).serialize();setTimeout((function(){$("#"+signup_id).addClass("bounce")}),1e3),jQuery.post(action,data,(function(response){$("#"+signup_id).html('<div style="min-height: 3em;">'+response.content+"</div>"),$("#"+signup_id).removeClass("bounce"),$("#"+signup_id).css("opacity","1"),$("#"+signup_id).css("display","block"),$("#"+signup_id).addClass("grow")}))})),$(".absences").on("change",(function(){var user_id=this.value;if(!(user_id<1)){var id=this.id,post_id=$("#"+id).attr("post_id"),statusid="status_absences"+post_id;$("#"+statusid).html("Saving ...");var editor_id=$("#editor_id").val();if(security&&post_id>0){var data={action:"editor_absences",user_id:user_id,editor_id:editor_id,post_id:post_id,timelord:rsvpmaker_rest.timelord};jQuery.post(ajaxurl,data,(function(response){$("#"+statusid).html(response),$("#"+statusid).fadeIn(200)}))}}})),$(".absences_remove").on("click",(function(){var user_id=this.value;if(!(user_id<1)){var id=this.id,post_id=$("#"+id).attr("post_id"),statusid="current_absences"+post_id+user_id;$("#"+statusid).html("Saving ...");var editor_id=$("#editor_id").val();if(security&&post_id>0){var data={action:"absences_remove",user_id:user_id,editor_id:editor_id,timelord:rsvpmaker_rest.timelord,post_id:post_id};jQuery.post(ajaxurl,data,(function(response){$("#"+statusid).html(response),$("#"+statusid).fadeIn(200)}))}}})),$("#edit_roles_new").length?($(".toastrole").hide(),$(".editone_wrapper").hide(),$(".remove_me_form").hide(),$(".agenda_note_editable_editone").show(),$(".agenda_note_editable_editone_wrapper").hide(),$(".editable_content").hide()):$(".edit_one_form").hide(),$(".editonelink").on("click",(function(e){suggest_mode=!1,e.preventDefault();var field=$(this).attr("editone");$("#editone"+field).show(),$("#edito newrapper"+field).hide(),$("#"+field+"_form").hide(),$("#remove"+field+"_form").hide()})),$(".suggestonelink").on("click",(function(e){suggest_mode=!0,e.preventDefault();var field=$(this).attr("editone");$("#editone"+field).show(),$("#edito newrapper"+field).hide(),$("#"+field+"_form").hide(),$("#remove"+field+"_form").hide(),$(".speaker_details_form").hide(),$("#suggest"+field).html('<p>Nominate the member for a role. Send them an email with your note and a one-click signup link.</p><p><textarea name="suggest_note" rows="3" cols="80"></textarea><br />Send to <input type="radio" name="ccme" value="0" checked="checked" /> member <input type="radio" name="ccme" value="1" /> member + copy to me <input type="radio" name="ccme" value="2" /> only to me </p>')})),$(".agenda_note_editable_editone").hide(),$(".agenda_note_editable_editone_on").on("click",(function(e){e.preventDefault(),$(".agenda_note_editable_editone").show(),$(".agenda_note_editable_editone_wrapper").hide(),$(".editable_content").hide()})),$(".agenda_note_editable_editone").submit((function(e){e.preventDefault();var data=$(this).serializeArray();$(this).html(data[0].value);var form=this;console.log(data);var postdata_agenda_note=data[0].value,postdata_agenda_note_label=data[1].value,postdata_post_id=data[2].value,postdata_timelord=data[3].value;$.post(wpt_rest.url+"rsvptm/v1/editable_note_update",data,(function(response){console.log("posting"),console.log(data),$(form).html(data[0].value+response),console.log(response)}))})),$(document).on("submit","form.edit_one_form",(function(event){event.preventDefault();var conjunction="?",action=wpt_rest.url+"rsvptm/v1/tm_role?tm_ajax=role",formid=$(this).attr("id"),data=$(this).serialize(),user_id=$("#"+formid+" .editor_assign").val();data=data.concat("&user_id="+user_id),$("#"+formid).html('<div style="line-height: 3">Saving ...</div>'),setTimeout((function(){$("#"+formid).addClass("bounce")}),1e3),jQuery.post(action,data,(function(response){$("#"+formid).html(response.content),$("#"+formid).removeClass("bounce"),$("#"+formid).css("opacity","1"),$("#"+formid).css("display","block"),$("#"+formid).addClass("grow")}))})),$(".editor_assign").select2()}));