"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "mrbs-1.9.4/web/js/edit_entry.js.php" between
mrbs-1.9.4.tar.gz and mrbs-1.10.0.tar.gz

About: MRBS is a web application for booking meeting rooms or other resources (using PHP and MySQL/pgsql).

edit_entry.js.php  (mrbs-1.9.4):edit_entry.js.php  (mrbs-1.10.0)
skipping to change at line 74 skipping to change at line 74
case <?php echo REP_MONTHLY ?>: case <?php echo REP_MONTHLY ?>:
$('#rep_monthly').show(); $('#rep_monthly').show();
break; break;
default: default:
break; break;
} }
}; };
<?php <?php
// Function to change the units for the repeat interval to match the repeat type . // Function to change the units for the repeat interval to match the repeat type .
// Additionally, the lines for repetition and skipping are shown/hidden.
?> ?>
var changeRepIntervalUnits = function changeRepIntervalUnits() { var changeRepIntervalUnits = function changeRepIntervalUnits() {
var repType = parseInt($('input[name="rep_type"]:checked').val(), 10); var repType = parseInt($('input[name="rep_type"]:checked').val(), 10);
var repInterval = parseInt($('input[name="rep_interval"]').val(), 10); var repInterval = parseInt($('input[name="rep_interval"]').val(), 10);
var units = $('#interval_units'); var units = $('#interval_units');
var text; var text;
switch (repType) switch (repType)
{ {
case <?php echo REP_DAILY ?>: case <?php echo REP_DAILY ?>:
text = (repInterval === 1) ? '<?php echo get_vocab('day') ?>' : '<?php e cho get_vocab('days') ?>'; text = (repInterval === 1) ? '<?php echo get_vocab('day') ?>' : '<?php e cho get_vocab('days') ?>';
skipping to change at line 101 skipping to change at line 102
case <?php echo REP_YEARLY ?>: case <?php echo REP_YEARLY ?>:
text = (repInterval === 1) ? '<?php echo get_vocab('year_lc') ?>' : '<?p hp echo get_vocab('years') ?>'; text = (repInterval === 1) ? '<?php echo get_vocab('year_lc') ?>' : '<?p hp echo get_vocab('years') ?>';
break; break;
default: default:
text = units.text(); text = units.text();
break; break;
} }
units.text(text); units.text(text);
units.parent().toggle(repType !== <?php echo REP_NONE ?>); units.parent().toggle(repType !== <?php echo REP_NONE ?>);
$('#rep_end_date').parent().toggle(repType !== <?php echo REP_NONE ?>);
$('#skip').parent().toggle(repType !== <?php echo REP_NONE ?>);
}; };
// areaConfig returns the properties ('enable_periods', etc.) for an area, // areaConfig returns the properties ('enable_periods', etc.) for an area,
// by default the current area // by default the current area
var areaConfig = function areaConfig(property, areaId) { var areaConfig = function areaConfig(property, areaId) {
var properties = ['enable_periods', 'n_periods', 'default_duration', 'max_du ration_enabled', var properties = ['enable_periods', 'n_periods', 'default_duration', 'max_du ration_enabled',
'max_duration_secs', 'max_duration_periods', 'max_duration _qty', 'max_duration_secs', 'max_duration_periods', 'max_duration _qty',
'max_duration_units', 'timezone']; 'max_duration_units', 'timezone'];
var i, p, room; var i, p, room;
skipping to change at line 1170 skipping to change at line 1174
var editEntryVisChanged = function editEntryVisChanged() { var editEntryVisChanged = function editEntryVisChanged() {
<?php <?php
// Clear the conflict timer and then restart it. We want // Clear the conflict timer and then restart it. We want
// a check to be performed immediately the page becomes // a check to be performed immediately the page becomes
// visible again. // visible again.
?> ?>
conflictTimer(false); conflictTimer(false);
conflictTimer(true); conflictTimer(true);
}; };
function populateFromSessionStorage(form)
{
var storedData = sessionStorage.getItem('form_data');
if (storedData)
{
var form_data = JSON.parse(storedData);
<?php
// Before we populate the form we have to set the area select to the correct
// area and then change selects that depend on it, eg the room selects.
?>
$.each(form_data, function (index, field)
{
if (field.name === 'area')
{
$('#area').val(field.value).trigger('change');
return false; // We've found the area field so we can stop.
}
});
<?php // Now iterate through the data again and populate the form ?>
var selects = {};
$.each(form_data, function (index, field)
{
<?php // Don't change the CSRF token - the form will have its own one. ?>
if (field.name === 'csrf_token')
{
return;
}
var el = $('[name="' + field.name + '"]'),
tagName = el.prop('tagName'),
type;
<?php
// If it's a select element then these can be multi-valued. If we just do
// el.val() for each one it will change the value each time, rather than a
dding
// another one. So instead we need to assemble an array of values and do
a single
// el.val() at the end.
?>
if (tagName.toLowerCase() === 'select')
{
if (!selects[field.name])
{
selects[field.name] = []
}
selects[field.name].push(field.value);
}
<?php // Otherwise we can just process them as they come ?>
else
{
type = el.attr('type');
switch (type)
{
case 'checkbox':
<?php // If the name ends in '[]' it's an array and needs to be handle
d differently ?>
if (field.name.match(/\[]$/))
{
el.filter('[value="' + field.value + '"]').attr('checked', 'checke
d');
}
else
{
el.attr('checked', 'checked');
}
break;
case 'radio':
el.filter('[value="' + field.value + '"]').attr('checked', 'checked'
);
break;
default:
el.val(field.value);
break;
}
}
});
<?php // Now assign values to the selects ?>
for (const property in selects)
{
$('[name="' + property + '"]').val(selects[property]).change();
}
<?php // Fix up the datalists so that the correct value is displayed ?>
form.find('datalist').each(function() {
<?php
// Datalists in MRBS have the structure
// <input type="text" list="yyy">
// <input type="hidden" name="xxx">
// <datalist id="yyy">
// and we want to copy the value from the hidden input to the visible one
?>
var prev1 = $(this).prev();
var prev2 = prev1.prev();
if ($(this).attr('id') === prev2.attr('list'))
{
prev2.val(prev1.val());
}
else
{
console.warn("MRBS: something has gone wrong - maybe the MRBS datalist s
tructure has changed.")
}
});
}
}
$(document).on('page_ready', function() { $(document).on('page_ready', function() {
isBookAdmin = args.isBookAdmin; isBookAdmin = args.isBookAdmin;
var form = $('#main');
<?php <?php
// If there's only one enabled area in the database there won't be an area // If there's only one enabled area in the database there won't be an area
// select input, so we'll have to create a dummy input because the code // select input, so we'll have to create a dummy input because the code
// relies on it. // relies on it.
?> ?>
if ($('#area').length === 0) if ($('#area').length === 0)
{ {
$('#div_rooms').before('<input id="area" type="hidden" value="' + args.area + '">'); $('#div_rooms').before('<input id="area" type="hidden" value="' + args.area + '">');
} }
skipping to change at line 1233 skipping to change at line 1342
reloadSlotSelector($('#end_seconds'), newArea); reloadSlotSelector($('#end_seconds'), newArea);
adjustSlotSelectors(); adjustSlotSelectors();
}); });
$('input[name="all_day"]').on('click', function() { $('input[name="all_day"]').on('click', function() {
onAllDayClick(); onAllDayClick();
}); });
<?php <?php
// If we've got back here from edit_entry_handler.php then repopulate the form
// with the original data.
?>
if (form.data('back'))
{
populateFromSessionStorage(form);
}
<?php
// (1) Adjust the slot selectors // (1) Adjust the slot selectors
// (2) Add some Ajax capabilities to the form (if we can) so that when // (2) Add some Ajax capabilities to the form (if we can) so that when
// a booking parameter is changed MRBS checks to see whether there would // a booking parameter is changed MRBS checks to see whether there would
// be any conflicts // be any conflicts
?> ?>
var form = $('#main');
adjustSlotSelectors(); adjustSlotSelectors();
<?php <?php
// If this is an All Day booking then check the All Day box and disable the // If this is an All Day booking then check the All Day box and disable the
// start and end time boxes // start and end time boxes
?> ?>
startSelect = form.find('#start_seconds'); startSelect = form.find('#start_seconds');
endSelect = form.find('#end_seconds'); endSelect = form.find('#end_seconds');
allDay = form.find('#all_day'); allDay = form.find('#all_day');
skipping to change at line 1282 skipping to change at line 1399
<?php <?php
// If anything like a submit button is pressed then add a data flag to the for m so // If anything like a submit button is pressed then add a data flag to the for m so
// that the function that checks for a valid booking can see if the change was // that the function that checks for a valid booking can see if the change was
// triggered by a Submit button being pressed, and if so, not to send an Ajax request. // triggered by a Submit button being pressed, and if so, not to send an Ajax request.
?> ?>
form.find('[type="submit"], [type="button"], [type="image"]').on('click', func tion() { form.find('[type="submit"], [type="button"], [type="image"]').on('click', func tion() {
var trigger = $(this).attr('name'); var trigger = $(this).attr('name');
$(this).closest('form').data('submit', trigger); $(this).closest('form').data('submit', trigger);
}); });
form.on('submit', function() { form.on('submit', function()
var result = true; {
if ($(this).data('submit') === 'save_button') var result = true;
{ if ($(this).data('submit') === 'save_button')
<?php // Only validate the form if the Save button was pressed ?> {
result = validate($(this)); <?php // Only validate the form if the Save button was pressed ?>
if (!result) result = validate($(this));
{ if (!result)
<?php // Clear the data flag if the validation failed ?> {
$(this).removeData('submit'); <?php // Clear the data flag if the validation failed ?>
} $(this).removeData('submit');
} }
return result; }
}); <?php
// If we're OK to submit then store the form data in session storage so that
// we can repopulate the form if there's an error and we need to come back t
o
// the form from edit_entry_handler.php.
?>
if (result)
{
sessionStorage.setItem('form_data', JSON.stringify($(this).serializeArray(
)));
}
return result;
});
<?php <?php
// Add a change event handler to each of the form fields - except for those th at // Add a change event handler to each of the form fields - except for those th at
// are disabled and anything that might be a submit button - so that when they change // are disabled and anything that might be a submit button - so that when they change
// the validity of the booking is re-checked. (This probably causes more che cking // the validity of the booking is re-checked. (This probably causes more che cking
// than is really necessary, eg when the brief description is changed, but on the other // than is really necessary, eg when the brief description is changed, but on the other
// hand it (a) removes the need to know the names of the fields you want and ( b) keeps // hand it (a) removes the need to know the names of the fields you want and ( b) keeps
// the data available for policy checking as complete as possible just in case somebody // the data available for policy checking as complete as possible just in case somebody
// decides to set a policy based on for example the brief description, for som e reason). // decides to set a policy based on for example the brief description, for som e reason).
// //
 End of changes. 8 change blocks. 
14 lines changed or deleted 149 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)