';
if ($('#entryform').length > 0)
{
$('#entryform').append(string);
}
else if ($('#publishForm').length > 0)
{
$('#publishForm').append(string);
}
else if ($('#submit_button').length > 0)
{
$('#submit_button').before(string);
}
// TODO: We could check for errors at some point...
success = true;
return success;
};
//END save_calendar_data
// -------------------------------------
// get rule id
// -------------------------------------
var _get_rule_id = function($context)
{
if ($context.closest('.rule').find('select[name=interval]').val() == 'none')
{
return '';
}
var val = $context.val();
return (val == undefined) ? '' : val;
};
// -------------------------------------
// _get_rule_type
// -------------------------------------
var _get_rule_type = function($context)
{
var val = $context.find('select[name=type]').val();
return (val == undefined || val == '') ? '+' : val;
};
// -------------------------------------
// _get_rule_date
// -------------------------------------
var _get_rule_date = function($field)
{
var val = $field.val();
if (val == undefined)
{
return '';
}
val = $.datepicker.formatDate(
'yymmdd',
_get_date(val),
SSCalendar.dateFormatSettings
);
return val;
};
// -------------------------------------
// _get_rule_all_day
// -------------------------------------
var _get_rule_all_day = function($context)
{
return ($('.all_day input:checkbox', $context).
is(':checked')) ? 'y' : '';
};
// -------------------------------------
// _get_rule_time
// -------------------------------------
var _get_rule_time = function($field)
{
var val = String($field.val());
if (val == undefined || val == '')
{
return '';
}
var minute = '';
var hour = '';
var ampm = ($field.siblings('select[name=ampm]').length == 1) ?
$field.siblings('select[name=ampm]').val() : '';
// Just an hour
if (val.length == 1 || val.length == 2)
{
minute = '00';
hour = val;
}
else if (val.indexOf(':') != -1)
{
var temp = val.split(':');
hour = temp[0];
minute = temp[1];
}
else if (val.length == 3 || val.length == 4)
{
minute = val.substring(val.length - 2);
hour = val.substring(0, val.length - 2);
}
else
{
minute = '00';
hour = '00';
}
// Remove leading zero, or else we won't like what parseInt() gives us
if (hour.substring(0, 1) == 0)
{
hour = hour.substring(1);
}
//adjust hours to military if pm
if (ampm == 'pm' && parseInt(hour, 10) 23)
{
hour = '00';
}
//no negatives of over 60m
if (parseInt(minute, 10) 59)
{
minute = '00';
}
//add leading 0
if (hour.length == 1)
{
hour = "0" + hour;
}
return hour + minute;
};
//END _get_rule_time
// -------------------------------------
// _get_rule_years
// -------------------------------------
var _get_rule_years = function($context)
{
var val = '';
if ($('select[name=interval]', $context).val() == 'yearly')
{
val = $('input[name=every]', $context).val();
}
return val;
};
// -------------------------------------
// _get_rule_months
// -------------------------------------
var _get_rule_months = function($context)
{
var val = '';
if ($('select[name=interval]', $context).val() == 'monthly')
{
val = $('input[name=every]', $context).val();
}
return val;
};
// -------------------------------------
// _get_rule_weeks
// -------------------------------------
var _get_rule_weeks = function($context)
{
var val = '';
if ($('select[name=interval]', $context).val() == 'weekly')
{
val = $('input[name=every]', $context).val();
}
return val;
};
// -------------------------------------
// _get_rule_days
// -------------------------------------
var _get_rule_days = function($context)
{
var val = '';
if ($('select[name=interval]', $context).val() == 'daily')
{
val = $('input[name=every]', $context).val();
}
return val;
};
// -------------------------------------
// _get_rule_dow
// -------------------------------------
var _get_rule_dow = function($context)
{
var val = [];
$('.dows .selector .item', $context).each(function()
{
if ($(this).data('selector') == true)
{
val.push($(this).data('value'));
}
});
return val.join('|');
};
// -------------------------------------
// _get_rule_relative
// -------------------------------------
var _get_rule_relative = function($context)
{
var val = [];
if ($('select[name=by]', $context).val() == 'by_relative')
{
$('.by_relative .selector .item', $context).each(function(){
if ($(this).data('selector') == true)
{
val.push($(this).data('value'));
}
});
}
return val.join('|');
};
// -------------------------------------
// _get_rule_dom
// -------------------------------------
var _get_rule_dom = function($context)
{
var val = new Array;
if ($('select[name=by]', $context).val() == 'by_date')
{
$('.by_date .selector .item', $context).each(function()
{
if ($(this).data('selector') == true)
{
val.push($(this).data('value'));
}
});
}
return val.join('|');
};
// -------------------------------------
// _get_rule_end_after
// -------------------------------------
var _get_rule_end_after = function($context)
{
var val = '';
if ($('select[name=end]', $context).val() == 'after')
{
val = $('input[name=end_after]', $context).val();
}
return val;
}
// -------------------------------------
// _create_hidden_input
// -------------------------------------
var _create_hidden_input = function(name, value)
{
return '';
};
// -------------------------------------
// show_hide_x
// -------------------------------------
var show_hide_x = function()
{
var $rules = $('.rule', $cal_fields);
// Hide X if there is only one rule
if ($rules.length == 1)
{
$('.rule_close, .type', $rules).addClass('inactive');
}
// Hide X on the first rule if there is only one include rule
else if ($('.type select[value="+"]', $rules).length == 1)
{
$('.type select[value="+"]', $rules).closest('.rule').
find('.rule_close, .type').addClass('inactive');
}
// Show X on first rule
else
{
$('.rule:first .rule_close', $cal_fields).removeClass('inactive');
}
}
//------------------------------------------------------------------
// start everything
//------------------------------------------------------------------
// Systems are go!
initialize();
// 12 hour or 24 hour?
var time_format = (
$('.rule.first select[name=ampm]', $cal_fields).length > 0
) ? '12' : '24';
// When the user clicks submit, the work is just getting started...
$('input[name=submit], input[name=save], .calendar_submit').click(function()
{
return save_calendar_data();
});
// Toggle open/close the Dates & Options fields
$('.label a', $cal_fields).click(function()
{
// Hide 'em, Danno
$('#calendar_wrapper', $cal_fields).toggle();
// Swap the +/- image
$(this).find('img').toggle();
return false;
});
// Toggle the time fields when switching between Include and Exclude
$('select[name=type]').live('change', function()
{
var val = $(this).val();
//if we are at val== '-', lets make select dates default if none is selected
if (val == '-')
{
if ($(this).closest('.rule').find('select[name=interval]').val() == 'none')
{
$(this).closest('.rule').find('select[name=interval]').val('select_dates').trigger('change');
}
}
if (val == '+')
{
$(this).closest('.inner').
find('.date_range, .date_range *').removeClass('inactive').
find('.time').show().end().
find('.all_day').show();
}
else if ($(this).closest('.rule').find('select[name=interval]').val() == 'select_dates')
{
$(this).closest('.inner').find('.date_range').addClass('inactive');
}
else
{
$(this).closest('.inner').
find('.date_range').
find('.time, .all_day').addClass('inactive');
}
show_hide_x();
});
// Toggle display of time fields
$('div.all_day input:checkbox').live('change', function()
{
toggle_time_fields($(this));
});
// Toggle display of event details
$('#calendar_calendars select[name=calendar_calendar_id]', $cal_fields).change(function()
{
//fills the hidden field so 'required' field works
if ($hidden_field)
{
$hidden_field.val($.trim($(this).val()));
}
toggle_event_details();
});
//fills the hidden field so 'required' field works (in case this is an edit)
if ($hidden_field)
{
$hidden_field.val(
$.trim(
$('#calendar_calendars select[name=calendar_calendar_id]', $cal_fields).val()
)
);
}
// Toggle display of interval details
$('.repeat_select select', $cal_fields).change(function()
{
toggle_interval_details($(this));
});
// Selector widget actions
$('.selector .item a', $cal_fields).live('click', function()
{
var $item = $(this).closest('.item');
toggle_selector_item($item);
return false;
});
// Add a new rule
$('#calendar_new_date button').click(function() {
var $rule = $(_html_new_rule());
// Get rid of am/pm dropdowns if we're in 24 hour time
if (time_format == '24')
{
$rule.find('select[name=ampm]').remove();
}
// Add rule number
$rule.find('div.rule_number span').text($('.rule', $cal_fields).length+1);
// Add date picker to From field
$('input[name=start_date]', $rule).datepicker({
dateFormat : SSCalendar.dateFormat,
firstDay : SSCalendar.firstDay,
changeMonth : true,
changeYear : true,
onSelect : function()
{
update_to_field_mindate($rule, true);
update_picker_three_mindate($rule);
update_end_by_mindate($rule);
update_picker_three_mindate($rule);
}
});
// Add date picker to To field
$('input[name=end_date]', $rule).datepicker({
dateFormat : SSCalendar.dateFormat,
firstDay : SSCalendar.firstDay,
changeMonth : true,
changeYear : true
});
update_from_field_mindate($rule);
update_to_field_mindate($rule, true);
// Toggle display of interval details
$('.repeat_select select', $rule).change(function() {
toggle_interval_details($(this));
});
$('#calendar_wrapper div.rule:last').after($rule);
show_hide_x();
return false;
});
// Close the rule
$('.rule_close', $cal_fields).live('click', function(){
$firstrule = $(this).closest('.rule.first');
if ($firstrule.length == 1)
{
var $includes = $('.type select[value="+"]', $cal_fields).
not($firstrule.find('.type select'));
if ($includes.length > 0)
{
$includes.eq(0).
closest('.rule').addClass('first').
replaceAll($firstrule).
find('.group').addClass('first');
}
}
else
{
$(this).closest('.rule').remove();
}
renumber_rules();
show_hide_x();
// Remove rule_type from first rule
$('.rule.first .type').addClass('inactive');
return false;
});
});
jQuery.expr[':'].regex = function(elem, index, match)
{
var matchParams = match[3].split(','),
validLabels = /^(data|css):/,
attr = {
method: matchParams[0].match(validLabels) ?
matchParams[0].split(':')[0] : 'attr',
property: matchParams.shift().replace(validLabels,'')
},
regexFlags = 'ig',
regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
return regex.test(jQuery(elem)[attr.method](attr.property));
}
Due to our upcoming changes, WE ARE NO LONGER ACCEPTING SUBMISSIONS FOR EVENTS WITH DATES AFTER MARCH 30. Follow our social media platforms or sign up for our newsletter to stay in the loop!