Skip to content

Instantly share code, notes, and snippets.

@davidray
Created May 18, 2009 03:35
Show Gist options
  • Save davidray/113301 to your computer and use it in GitHub Desktop.
Save davidray/113301 to your computer and use it in GitHub Desktop.
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
var rowGuid = 0;
var $j = jQuery.noConflict();
jQuery(document).ready(function($){
$("#markItUp").markItUp(nameOfSettings);
});
jQuery.ajaxSetup({
'beforeSend': function(xhr) {xhr.setRequestHeader("Accept",
"text/javascript")}
});
jQuery(document).ajaxSend(function(event, request, settings) {
if (typeof(AUTH_TOKEN) == "undefined") return;
// settings.data is a serialized string like "foo=bar&baz=boink" (or null)
settings.data = settings.data || "";
settings.data += (settings.data ? "&" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN);
});
function add_participant(selectItem) {
var option = selectItem.options[ selectItem.selectedIndex ];
if(option.disabled) {
selectItem.selectedIndex = 0;
return false;
}
if(option.value=="") {
selectItem.selectedIndex = 0;
return false;
}
option.disabled = true;
option.style.color = "graytext";
//alert("value="+option.value+" text="+option.text);
var rowId = ""+(++rowGuid);
// var rowHtml = "<tr id=\""+rowId+"\"><td><input type=\"checkbox\" name=\"user["+option.value+"].is_organizer\" /></td><td>"+option.text+"</td><td><input type=\"text\" name=\"user["+option.value+"].hours\" size=\"3\" /></td><td><a href=\"#\" onclick=\"return deleteParticipantRow(this);\">X</a></td></tr>";
// var rowHtml = "<tr id=\""+rowId+"\"><td><input type=\"checkbox\" name=\"user["+option.value+"].is_organizer\" /></td><td>"+option.text+"</td><td><input type=\"text\" name=\"hours2\" size=\"3\" /></td><td><a href=\"#\" onclick=\"return deleteParticipantRow(this);\">X</a></td></tr>";
// $("#participants_table tbody:first").append(rowHtml);
trElement = document.createElement("tr");
trElement.id = rowId;
tdElement = document.createElement("td");
//tdElement.innerHTML = "<input type=\"checkbox\" name=\"user["+option.value+"][is_organizer]\" />";
txElement.appendChild( createCheckbox(user["+option.value+"][is_organizer]) );
trElement.appendChild(tdElement);
tdElement = document.createElement("td");
//TODO1tdElement.innerHTML = option.text;
trElement.appendChild(tdElement);
tdElement = document.createElement("td");
//TODO1tdElement.innerHTML = "<input type=\"text\" name=\"user["+option.value+"][hours]\" size=\"3\" />"
trElement.appendChild(tdElement);
tdElement = document.createElement("td");
//TODO1tdElement.innerHTML = "<a href=\"#\" onclick=\"return deleteParticipantRow(this);\">X</a>";
trElement.appendChild(tdElement);
$("#participants_table tbody:first").each(function() {
this.appendChild(trElement);
});
// var row = document.getElementById(rowId);
//row.option = option;
// row.optionIndex = selectItem.selectedIndex;
// participant_user_ids[participant_user_ids.length] = option.value;
selectItem.selectedIndex = 0;
updateParticipantUserIds();
return false;
}
function deleteParticipantRow(link) {
var row = link.parentNode.parentNode;
//alert(row);
var table = row.parentNode.parentNode;
//alert(table);
var option = document.getElementById("add_participant_id").options[ row.optionIndex ];
option.disabled = false;
option.style.color = "menutext";
// var index = jQuery.inArray(option.value, participant_user_ids);
// participant_user_ids[index] = 0;
// participant_user_ids = jQuery.unique(participant_user_ids);
// alert(index);
// alert(participant_user_ids);
table.deleteRow( row.rowIndex );
updateParticipantUserIds();
return false;
}
function updateParticipantUserIds() {
var participant_user_ids = new Array();
$("#add_participant_id option[disabled]").each( function() {
participant_user_ids[participant_user_ids.length] = this.value;
//alert(this.value+"\t"+this.text);
} );
var user_ids = participant_user_ids.join(",");
$("#participant_user_ids").each( function() {
this.value = user_ids;
} );
}
function delete_family_contact(user_id) {
document.contact_form.action += "&delete_family_contact_user_ids[]="+user_id;
document.getElementById("family_contact_user_id_"+user_id).style.display="none";
//alert(document.contact_form.action);
return false;
}
function updateRankAction(selectItem) {
var option = selectItem.options[ selectItem.selectedIndex ];
$(".goal").hide();
$(".full").hide();
$(".partial").hide();
document.getElementById("update_bulk_edit_ranks_form").update_rank_action.value = option.value;
if(option.disabled) {
selectItem.selectedIndex = 0;
return false;
}
if(option.value=="") {
selectItem.selectedIndex = 0;
return false;
}
$("."+option.value).show();
if(option.value=="partial") {
//document.getElementById("update_bulk_edit_ranks_form").
srcRankIdSelect = document.getElementById("rank_ids[]")
rankIdSelect = document.getElementById("rank_ids[]").cloneNode(true);
rankIdSelect.id = "rank_ids2[]";
document.getElementById("load_rank_partials_form_div").appendChild(rankIdSelect);
for(var i=0; i<rankIdSelect.options.length; i++) {
if(srcRankIdSelect.options[i].selected) {
rankIdSelect.options[i].selected = true;
}
}
// document.getElementById("load_rank_partials_form_div").parentNode.submit();
document.getElementById("submit_load_partials_form").click();
}
return true;
}
function updateMeritBadgeAction(selectItem) {
var option = selectItem.options[ selectItem.selectedIndex ];
$(".goal").hide();
$(".full").hide();
$(".partial").hide();
document.getElementById("update_bulk_edit_merit_badges_form").update_merit_badge_action.value = option.value;
if(option.disabled) {
selectItem.selectedIndex = 0;
return false;
}
if(option.value=="") {
selectItem.selectedIndex = 0;
return false;
}
$("."+option.value).show();
return true;
}
function genericPickerToggleEntity(liItem, scoutId) {
var mainDiv = liItem.parentNode.parentNode;
var selectList = mainDiv.backingSelectNode;
var isSelected;
if("selected" == liItem.className) {
liItem.className = "";
isSelected = false;
}
else {
liItem.className = "selected";
isSelected = true;
}
for(var i=0; i<selectList.options.length;i++) {
var option = selectList.options[i];
if(option.value == scoutId) {
option.selected = isSelected;
}
}
return false;
}
function genericPickerInitPickerItems(mainDiv) {
var selectList = mainDiv.backingSelectNode;
var pickLiItems = mainDiv.pickLiItems;
var counter=0;
$(pickLiItems).each( function() {
//var option = selectList.options[counter];
//if(counter==0) { alert(this); }
//if(counter==0) { alert(this.id); }
var targetOptionValue = this.id.substring(this.id.lastIndexOf("_")+1);
//if(counter==0) { alert(targetOptionValue); }
var option = null;
for(var i=0; i<selectList.options.length;i++) {
option2 = selectList.options[i];
if(option2.value == targetOptionValue) {
option = option2;
break;
}
}
//if(counter==0) { alert(option.value+option.selected); }
if(option.selected == true) {
this.className = "selected";
}
else {
this.className = "";
}
counter++;
});
}
function genericPickerClear(clearLink) {
var mainDiv = clearLink.parentNode.parentNode.parentNode;
var selectList = mainDiv.backingSelectNode;
for(var i=0; i<selectList.options.length;i++) {
var option = selectList.options[i];
option.selected = false;
}
genericPickerInitPickerItems(mainDiv);
return false;
}
function genericPickerClose(closeLink) {
var mainDiv = closeLink.parentNode.parentNode.parentNode;
var selectList = mainDiv.backingSelectNode;
$(mainDiv).hide("slide", {}, "normal");
//setParticipants(selectList);
mainDiv.closeCallback(selectList);
return false;
}
function showScoutPicker(linkItemNode, selectNode, closeCallback) {
var linkItem = $(linkItemNode);
var coordinates = linkItem.offset();
var scoutPickerDiv = $('#scout_picker_div');
var pickLiItems = $(".scout_picker_scout_list li");
scoutPickerDiv.css("position", "absolute");
scoutPickerDiv.css("top", coordinates.top + linkItem.height());
scoutPickerDiv.css("left", coordinates.left + linkItem.width());
$(scoutPickerDiv).each( function() {
this.backingSelectNode = selectNode;
this.closeCallback = closeCallback;
this.pickLiItems = pickLiItems;
genericPickerInitPickerItems(this);
});
scoutPickerDiv.show("slide", { }, "normal");
return false;
}
function scoutPicker(linkId, selectId, closeCallback) {
var linkNode = document.getElementById(linkId);
var selectNode = document.getElementById(selectId);
$(selectNode).css("display", "none");
$(linkNode).click(function() {
showScoutPicker(linkNode, selectNode, closeCallback);
return false;
})
}
function showMeritBadgePicker(linkItemNode, selectNode, closeCallback) {
var linkItem = $(linkItemNode);
var coordinates = linkItem.offset();
var scoutPickerDiv = $('#merit_badge_picker_div');
var pickLiItems = $(".merit_badge_picker_list_item");
scoutPickerDiv.css("position", "absolute");
scoutPickerDiv.css("top", coordinates.top + linkItem.height());
scoutPickerDiv.css("left", coordinates.left + linkItem.width());
$(scoutPickerDiv).each( function() {
this.backingSelectNode = selectNode;
this.closeCallback = closeCallback;
this.pickLiItems = pickLiItems;
genericPickerInitPickerItems(this);
});
//document.getElementById("merit_badge_picker_page_select").
scoutPickerDiv.show("slide", { }, "normal");
return false;
}
function meritBadgePicker(linkId, selectId, closeCallback) {
var linkNode = document.getElementById(linkId);
var selectNode = document.getElementById(selectId);
// $(selectNode).css("display", "none");
$(linkNode).click(function() {
showMeritBadgePicker(linkNode, selectNode, closeCallback);
return false;
})
}
function setParticipants2(backingSelectNode) {
$("#select_participants_button").each(function() {
this.click();
});
}
function setParticipants(backingSelectNode) {
/* $("#participants_table tbody:first").each(function() {
for(var i=this.rows.length-1;i>=0;i--) {
this.deleteRow(i);
}
});*/
var participantTable = document.getElementById("participants_table");
var selectList = backingSelectNode;
for(var i=0; i<selectList.options.length;i++) {
var option = selectList.options[i];
var scoutRow = document.getElementById("tr_scout_"+option.value);
if(option.selected == true) {
if(!scoutRow) {
addParticipant2(option);
}
}
else {
if(scoutRow) {
participantTable.deleteRow( scoutRow.rowIndex );
}
}
}
updateParticipantTablesorter(participantTable);
}
function setParticipants3(backingSelectNode) {
$("#service_project_form").each(function() {
this.submit();
});
/* $("#participants_table tbody:first").each(function() {
for(var i=this.rows.length-1;i>=0;i--) {
this.deleteRow(i);
}
});*/
/* var participantTable = document.getElementById("participants_table");
var selectList = backingSelectNode;
for(var i=0; i<selectList.options.length;i++) {
var option = selectList.options[i];
var scoutRow = document.getElementById("tr_scout_"+option.value);
if(option.selected == true) {
if(!scoutRow) {
addParticipant2(option);
}
}
else {
if(scoutRow) {
participantTable.deleteRow( scoutRow.rowIndex );
}
}
}
updateParticipantTablesorter(participantTable);*/
}
function addParticipant2(option) {
var hoursInput = document.getElementById("service_project_hours");
var hoursValue = hoursInput.value;
var troopId = document.getElementById("troop_id").value;
var rowId = ""+(++rowGuid);
trElement = document.createElement("tr");
var scoutRowId = "tr_scout_"+option.value;
trElement.id = scoutRowId;
tdElement = document.createElement("td");
tdElement.align = "center";
tdElement.appendChild( createCheckbox("user["+option.value+"][is_organizer]") );
trElement.appendChild(tdElement);
tdElement = document.createElement("td");
tdElement.appendChild( createLink("/troop/show_scout_profile?troop_id="+troopId+"&user_id="+option.value, option.text) );
trElement.appendChild(tdElement);
tdElement = document.createElement("td");
//tdElement.innerHTML = "<input type=\"text\" name=\"user["+option.value+"][hours]\" size=\"3\" value=\""+hoursValue+"\" />"
tdElement.appendChild( createTextInput("user["+option.value+"][hours]",hoursValue,"3") );
trElement.appendChild(tdElement);
tdElement = document.createElement("td");
//tdElement.innerHTML = "<a href=\"#\" onclick=\"return deleteParticipantRow2('"+option.value+"');\">X</a>";
tdElement.appendChild( createLink("#","X","return deleteParticipantRow2('"+option.value+"');") );
trElement.appendChild(tdElement);
$("#participants_table tbody:first").each(function() {
this.appendChild(trElement);
});
}
function createCheckbox(name) {
var inputElement = document.createElement("input");
inputElement.type = "checkbox";
inputElement.name = name;
return inputElement;
}
function createTextInput(name, value, size) {
var inputElement = document.createElement("input");
inputElement.type = "text";
inputElement.name = name;
inputElement.size = size;
return inputElement;
}
function createLink(href, label) {
var linkElement = document.createElement("a");
linkElement.href = href;
linkElement.appendChild( document.createTextNode(label) );
return linkElement;
}
function createLink(href, label, onclick) {
var linkElement = document.createElement("a");
linkElement.href = href;
//linkElement.click = onclick;
linkElement.setAttribute("onclick",onclick);
linkElement.appendChild( document.createTextNode(label) );
return linkElement;
}
function deleteParticipantRow2(scoutId) {
var participantTable = document.getElementById("participants_table");
var scoutRowId = "tr_scout_"+scoutId;
var scoutRow = document.getElementById(scoutRowId);
participantTable.deleteRow( scoutRow.rowIndex );
var selectList = document.getElementById("participant_user_ids[]");
for(var i=0; i<selectList.options.length;i++) {
var option = selectList.options[i];
if(option.value == scoutId) {
option.selected = false;
}
}
updateParticipantTablesorter(participantTable);
return false;
}
function updateParticipantTablesorter(participantTable) {
$(participantTable).trigger("update");
var sorting = [[0,0]];
$(participantTable).trigger("sorton",[sorting]);
}
function meritBadgePickerJumpPage(targetPageId) {
$("#merit_badge_picker_div ul").each( function() {
this.style.display = "none";
});
$("#"+targetPageId).show();
}
function add_patrol() {
return submitPatrolUpdates();
}
function delete_patrol(patrol_id) {
document.patrol_form.action += "&delete_patrol_ids[]="+patrol_id;
document.getElementById("div_patrol_"+patrol_id).style.display="none";
//alert(document.patrol_form.action);
return false;
}
function expandRankTree(link, rankId) {
expandRankTreeDiv = link.parentNode;
collapseRankTreeDiv = expandRankTreeDiv.nextSibling;
$(expandRankTreeDiv).hide();
$(collapseRankTreeDiv).show();
$("ul.rankRequirements").hide();
$("#rankRequirements_"+rankId).show();
}
function collapseRankTree(link, rankId) {
collapseRankTreeDiv = link.parentNode;
expandRankTreeDiv = collapseRankTreeDiv.previousSibling;
$(expandRankTreeDiv).show();
$(collapseRankTreeDiv).hide();
$("ul.rankRequirements").hide();
//$("#rankRequirements_"+rankId).();
}
function addMemberRoleSelectChanged(selectItem) {
var option = selectItem.options[ selectItem.selectedIndex ];
//$(".contactInput").hide("slide", {}, "slow");
//$(".parentAccessInput").hide("slide", {}, "slow");
//$(".scoutInput").hide("slide", {}, "slow");
//$(".mbcInput").hide("slide", {}, "slow");
$(".contactInput").css("display", "none");
$(".parentAccessInput").css("display", "none");
$(".scoutInput").css("display", "none");
$(".mbcInput").css("display", "none");
if(option.value=="") {
}
else if(option.value=="Scout") {
$(".scoutInput").show("slide", {}, "slow");
}
else if(option.value=="MeritBadgeCounselor") {
$(".mbcInput").show("slide", {}, "slow");
}
else if(option.value=="ContactOrParent") {
$(".contactInput").show("slide", {}, "slow");
$(".parentAccessInput").show("slide", {}, "slow");
}
return true;
}
function validateAddMemberForm() {
var selectItem;
$("#primary_role").each( function() {
selectItem = this;
});
var roleOption = selectItem.options[ selectItem.selectedIndex ];
if(roleOption.value=="") {
alert("You must select a role type");
return false;
}
else if(roleOption.value=="Scout") {
//nothing required, default role to none
}
else if(roleOption.value=="MeritBadgeCounselor") {
var isAnySelected = false;
$("#merit_badge_ids option:selected").each( function() {
isAnySelected = true;
});
if(!isAnySelected) {
if(!confirm("Counselor has no assigned Merit Badges!\n"+
"Hit Cancel to add Merit Badges.\n"+
"Hit Ok to add as regular Adult.\n(You can always enter details later.)")) {
return false;
}
}
}
else if(roleOption.value=="ContactOrParent") {
var isAnySelected = false;
$("#parent_contact_for_user_ids option:selected").each( function() {
isAnySelected = true;
});
$("#other_contact_for_user_ids option:selected").each( function() {
isAnySelected = true;
});
$("#parent_access_for_user_ids option:selected").each( function() {
isAnySelected = true;
});
if(!isAnySelected) {
if(!confirm("Not a contact or parent accesser to any scout.\n"+
"Hit Cancel to assign.\n"+
"Hit Ok to add as regular Adult.\n(You can always enter details later.)")) {
return false;
}
}
}
if(document.getElementById("is_invite_user").checked) {
if(document.getElementById("user_email").value.length==0) {
alert("Please either provide an email address or uncheck Invite To Login.");
return false;
}
}
if(document.getElementById("user_last_name").value.length==0) {
alert("Last name is required");
return false;
}
return true;
}
/*function hideIfShowing(jqObject) {
jqObject.each( function() {
if(this.style.display == "none") {
$(this).hide("slide", {}, "slow");
}
});
}*/
$(document).ready(function(){
//$(".input_date").datepicker();
$(".input_date").datepicker({ yearRange: '1900:2100' });
/*$(".clockpick").clockpick({
starthour: 0,
endhour: 23,
});*/
var hours = "12 1 2 3 4 5 6 7 8 9 10 11".split(" ");
var minutes = ":00 :30".split(" ");
var timeOptions = new Array();
// var meridians = "am pm".split(" ");
for(var h = 0; h < hours.length; h++) {
for(var m = 0; m < minutes.length; m++) {
timeOptions[timeOptions.length] = hours[h]+minutes[m];
}
}
//var data = "7:00PM 7:30PM 8:30PM 9:30PM".split(" ");
$(".input_time").autocomplete(timeOptions, {
minChars: 0,
autoFill: true,
max: 24,
width: 90
});
/*$(".input_time_meridian").autocomplete(meridians, {
minChars: 0,
autoFill: true,
max: 2,
width: 45
});*/
$(".input_birth_date").datepicker({ yearRange: '1900:2009' });
//$("input:visible:first").focus();
//$(".initialFocus").focus();
document.isFocusSet = false;
//$("input:visible:first").each( function() {
$("input[@type=text]:visible").each( function() {
//alert(this.id+"\t"+this.type+"\t"+this);
if(!document.isFocusSet) {
if(!this.className ||
(this.className.indexOf("input_date")<0
&& this.className.indexOf("site_search")<0)) {
$(this).focus();
document.isFocusSet = true;
//alert(this.id+"\t"+this);
}
}
});
$("select[multiple].asmSelect").asmSelect({
addItemTarget: 'bottom',
hideWhenAdded: true,
animate: true,
sortable: true
});
//$("fieldset").corner();
});
function submitPatrolUpdates() {
$(".recordedPatrolList").each( function() {
//var parentList = this.parentNode;
// alert(parentList.id);
var selectItem = nextObject(this);
//alert(this+"\t"+selectItem);
for(var i=0; i<selectItem.options.length; i++) {
selectItem.options[i].selected = false;
}
var userIds = "";
$("#"+this.id+" li").each( function() {
var idIndex = this.id.lastIndexOf("_");
if(idIndex>0) {
var userId = this.id.substring(idIndex+1);
userIds+=userId+", ";
//alert(userId);
for(var i=0; i<selectItem.options.length; i++) {
if(selectItem.options[i].value == userId) {
selectItem.options[i].selected = true;
//alert(userId);
break;
}
}
}
});
//alert(this.id+"\t"+userIds);
});
return true;
}
function nextObject(baseItem) {
var n = baseItem.nextSibling;
while(n && n.nodeType != 1) {
n = n.nextSibling;
}
return n;
}
function loadMeritBadgeDetails() {
var formNode = document.getElementById("bulk_edit_merit_badges_form");
//$.ajax({data:$.param($(this).serializeArray()) + '&authenticity_token=' + encodeURIComponent('82f4b06c69f0a622c1b645be3c986ca45ae0a281'), dataType:'script', type:'post', url:'/troop/bulk_edit_get_something'}); return false;
$.ajax(
{data:$.param($(formNode).serializeArray()) + '&loadDetails=true',
dataType:'script',
type:'get',
url:'/troop/bulk_edit_merit_badges'
}
);
return false;
}
function loadRankDetails() {
var formNode = document.getElementById("bulk_edit_ranks_form");
//$.ajax({data:$.param($(this).serializeArray()) + '&authenticity_token=' + encodeURIComponent('82f4b06c69f0a622c1b645be3c986ca45ae0a281'), dataType:'script', type:'post', url:'/troop/bulk_edit_get_something'}); return false;
$.ajax(
{data:$.param($(formNode).serializeArray()) + '&loadDetails=true',
dataType:'script',
type:'get',
url:'/troop/bulk_edit_ranks'
}
);
return false;
}
function submitFormOnChange(selectItem, submitButtonId) {
var option = selectItem.options[ selectItem.selectedIndex ];
if(option.disabled || option.value==null || option.value=="") {
return;
}
//document.getElementById(formId).submit();
document.getElementById(submitButtonId).click();
}
function disable_form(form_id) {
$("#"+form_id+" input").each( function() {
this.disabled = "true";
});
$("#"+form_id+" select").each( function() {
this.disabled = "true";
});
$("#"+form_id+" textarea").each( function() {
this.disabled = "true";
});
}
function toggleCheckRow(checkBoxItem, rowId) {
if(checkBoxItem.checked) {
$("#"+rowId+" td").each(function() {
$(this).css("backgroundColor","#ffffcc");
});
}
else {
$("#"+rowId+" td").each(function() {
$(this).css("backgroundColor","");
});
}
}
function selectAllCheckBoxRows(tableId) {
//$("#"+tableId+" tbody tr td:first input:checkbox").each(function() {
$("#"+tableId+" input:checkbox").each(function() {
if(!this.checked) {
this.click();
}
});
}
function selectNoneCheckBoxRows(tableId) {
//$("#"+tableId+" tbody tr td:first input:checkbox").each(function() {
$("#"+tableId+" input:checkbox").each(function() {
if(this.checked) {
this.click();
}
});
}
function initCheckBoxRows(tableId) {
//$("#"+tableId+" tbody tr td:first input:checkbox").each(function() {
$("#"+tableId+" input:checkbox").each(function() {
if(this.checked) {
this.click();
this.click();
//this.checked = false;
}
});
}
function showModal(divID)
{
//window.onscroll = function () { document.getElementById(divID).style.top = document.body.scrollTop; };
document.getElementById(divID).style.display = "block";
document.getElementById(divID).style.top = document.body.scrollTop;
//document.getElementById(divID).style.top = 0;
}
function hideModal(divID)
{
//alert("divID='"+divID+"'");
document.getElementById(divID).style.display = "none";
}
function selectAllOptions(selectId) {
selectObject = document.getElementById(selectId);
for(var i=0; i<selectObject.options.length; i++) {
selectObject.options[i].selected = true;
}
}
function selectNoneOptions(selectId) {
selectObject = document.getElementById(selectId);
for(var i=0; i<selectObject.options.length; i++) {
selectObject.options[i].selected = false;
}
}
function selectOptions(selectId, optionIds) {
optionIdsArray = optionIds.split(",");
selectObject = document.getElementById(selectId);
for(var i=0; i<selectObject.options.length; i++) {
for(var j=0; j<optionIdsArray.length; j++) {
if(selectObject.options[i].value == optionIdsArray[j]) {
selectObject.options[i].selected = true;
break;
}
}
}
}
function areAnyCheckBoxRowsSelected(tableId) {
var flag = false;
$("#"+tableId+" input:checkbox").each(function() {
if(this.checked) {
flag = true;
}
});
return flag;
}
function event_guests_email(event_form_id) {
var form_object = document.getElementById(event_form_id);
showModal('modelEmailPage');
return false;
}
function event_guests_email_actual(event_form_id) {
var form_object = document.getElementById(event_form_id);
var select_to_object = document.getElementById("event_email_to_type");
if(select_to_object.selectedIndex == 1) {
if( !areAnyCheckBoxRowsSelected('guestsTable') ) {
alert('No Guests Selected');
hideModal('modelEmailPage');
return false;
}
}
return true;
}
function event_guests_add(event_form_id) {
var form_object = document.getElementById(event_form_id);
//alert('Feature Not Ready For Use Yet');
showModal('modalAddGuestsPage');
return false;
}
function event_guests_remove(event_form_id) {
var form_object = document.getElementById(event_form_id);
if( !areAnyCheckBoxRowsSelected('guestsTable') ) {
alert('No Guests Selected');
return false;
}
return true;
}
function event_guests_add_actual(event_form_id) {
var form_object = document.getElementById(event_form_id);
var select_who_object = document.getElementById("event_new_attendee_user_ids");
if(select_who_object.selectedIndex < 0) {
alert('Must select someone to add');
return false;
}
return true;
}
function event_delete_request(event_form_id) {
var form_object = document.getElementById(event_form_id);
if(!confirm("Event will be deleted\nAre you sure?")) {
return false;
}
return true;
}
function add_adult_training() {
var select_who_object = document.getElementById("user_new_training_ids");
if(select_who_object.selectedIndex < 0) {
alert('None selected');
return false;
}
return true;
}
function changeToEditMode() {
$(".reportViewMode").each( function() {
this.style.display = "none";
});
$(".reportEditMode").each( function() {
this.style.display = "inline";
});
return true;
}
function changeToViewMode() {
$(".reportViewMode").each( function() {
this.style.display = "inline";
});
$(".reportEditMode").each( function() {
this.style.display = "none";
});
return true;
}
function goSiteSearch() {
//document.getElementById("siteSearchTextInput").
return true;
}
function isShouldInviteUsersChanged(selectItem) {
var option = selectItem.options[ selectItem.selectedIndex ];
//$(".contactInput").css("display", "none");
if(option.value=="yes") {
$(".shouldInviteUsers").show("slide", {}, "slow");
}
else {
$(".shouldInviteUsers").hide("slide", {}, "slow");
}
}
function initShouldInviteUsers() {
var selectItem = document.getElementById("is_should_invite_users");
if(selectItem.selectedIndex > 0) {
$(".shouldInviteUsers").css("display", "none");
//isShouldInviteUsersChanged(selectItem);
}
}
function troopMembersMakeLeaderClicked() {
if(!isAnyTableCheckboxesSelected('memberTable')) {
alert("Must select at least one adult");
return false;
}
return true;
}
function troopMembersRevokeLeaderClicked() {
}
function isAnyTableCheckboxesSelected(tableId) {
var isAnySelected = false;
//$("#"+tableId+" tbody tr td:first input:checkbox").each(function() {
$("#"+tableId+" input:checkbox").each(function() {
if(this.checked) {
isAnySelected = true;
}
});
return isAnySelected;
}
function submitNewCredit(formId) {
return submitNewMoneyTransaction(formId, "new_credit_money_transaction_value", "new_credit_money_transaction_date_string_activity_on");
}
function submitNewDebit(formId) {
return submitNewMoneyTransaction(formId, "new_debit_money_transaction_value", "new_debit_money_transaction_date_string_activity_on");
}
function submitNewMoneyTransaction(formId, valueId, dateId) {
dateItem = document.getElementById(dateId);
valueItem = document.getElementById(valueId);
if(valueItem.value.length==0) {
alert("Must give an amount");
return false;
}
if(dateItem.value.length==0) {
alert("Must give a date");
return false;
}
return true;
}
function onChangeEventType(selectItem) {
var optionItem = selectItem.options[ selectItem.selectedIndex ];
/*var prevItem = selectItem.prevItem;
if(prevItem) {
$("."+prevItem.value).hide("slide", { }, "normal");
}*/
//$("."+optionItem.value+"Not").hide("slide", { }, "normal");
$(".EventType:visible").hide("slide", { }, "normal");
$("."+optionItem.value).show("slide", { }, "normal");
//selectItem.prevItem = prevItem;
}
function addFundraiserProducts(formId) {
var form_object = document.getElementById(formId);
//alert('Feature Not Ready For Use Yet');
showModal('addFundraiserProductsPage');
return false;
}
function addFundraiserProductsSubmit(formId) {
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment