"...src/main/resources/static/js/libs/moment.min.js" did not exist on "29f71c00e847204d24f77d818bb5f570317668c0"
Newer
Older
$('#modalConfirmDelete').modal('open');
if($(".datepicker").length)
{

Robert Goldmann
committed
var pickerStartDate = $('#transaction-datepicker').pickadate({

Robert Goldmann
committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
selectMonths: true,
selectYears: 100,
firstDay: 1,
// Strings and translations
monthsFull: monthNames,
monthsShort: monthNamesShort,
weekdaysFull: weekDays,
weekdaysShort: weekDaysShort,
weekdaysLetter: weekDaysLetters,
// Buttons
today: buttonToday,
clear: buttonClear,
close: buttonClose,
// Accessibility labels
labelMonthNext: '',
labelMonthPrev: '',
labelMonthSelect: '',
labelYearSelect: '',
// Formats
format: 'dd.mm.yyyy',
formatSubmit: 'dd.mm.yyyy',
onSet: function()
{
var selectedDate = this.get('select').obj;
if(pickerEndDate.get('select').obj < selectedDate)
{
pickerEndDate.set('select', selectedDate);
}
pickerEndDate.set('min', selectedDate);
}
});
pickerStartDate = pickerStartDate.pickadate('picker');

Robert Goldmann
committed
var pickerEndDate = $('#transaction-repeating-end-date-input').pickadate({
selectMonths: true,
selectYears: 100,
firstDay: 1,
// Strings and translations
monthsFull: monthNames,
monthsShort: monthNamesShort,
weekdaysFull: weekDays,
weekdaysShort: weekDaysShort,
weekdaysLetter: weekDaysLetters,
// Buttons
today: buttonToday,
clear: buttonClear,
close: buttonClose,
// Accessibility labels
labelMonthNext: '',
labelMonthPrev: '',
labelMonthSelect: '',
labelYearSelect: '',
// Formats
format: 'dd.mm.yyyy',
formatSubmit: 'dd.mm.yyyy'
});

Robert Goldmann
committed
pickerEndDate = pickerEndDate.pickadate('picker');
// picker end date
var selectedDate = pickerStartDate.get('select').obj;
if(pickerEndDate.get('select').obj < selectedDate)
{
pickerEndDate.set('select', selectedDate);
}
pickerEndDate.set('min', selectedDate);
pickerEndDate.on({
set: function() {
// select corresponding radio button
var endDate = document.getElementById("repeating-end-date");
endDate.checked = true;
}
})
}

Robert Goldmann
committed
if($('#transaction-amount').length)
{

Robert Goldmann
committed
$('#transaction-amount').on('change keydown paste input', function() {
validateAmount($(this).val());
});
}

Robert Goldmann
committed
if($(transactionRepeatingModifierID).length)

Robert Goldmann
committed
$(transactionRepeatingModifierID).on('change keydown paste input', function() {
// substr(1) removes "#" at the beginning

Robert Goldmann
committed
validateNumber($(this).val(), transactionRepeatingModifierID.substr(1), "hidden-" + transactionRepeatingModifierID.substr(1), numberValidationMessage);
});
}

Robert Goldmann
committed
if($(transactionRepeatingEndAfterXTimesInputID).length)

Robert Goldmann
committed
$(transactionRepeatingEndAfterXTimesInputID).on('change keydown paste input', function() {
validateNumber($(this).val(), transactionRepeatingEndAfterXTimesInputID.substr(1), null, numberValidationMessage);
// select corresponding radio button
var endAfterXTimes = document.getElementById("repeating-end-after-x-times");
endAfterXTimes.checked = true;
if($(".chips-autocomplete").length)
{
$('.chips-autocomplete').material_chip({
autocompleteOptions: {
data: tagAutoComplete,
limit: Infinity,
minLength: 1
},

Robert Goldmann
committed
placeholder: tagsPlaceholder,
data: initialTags
$('#enableRepeating').change(function(){
if($(this).is(":checked"))
{

Robert Goldmann
committed
$('#transaction-repeating-modifier-row').show();
$('#transaction-repeating-end').show();

Robert Goldmann
committed
$('#transaction-repeating-modifier-row').hide();
$('#transaction-repeating-end').hide();
}
});
// fire change listener on page load
$('#enableRepeating').trigger("change");
// prevent form submit on enter (otherwise tag functionality will be hard to use)
$(document).on("keypress", 'form', function (e) {
var code = e.keyCode || e.which;
if (code === 13) {
e.preventDefault();
return false;
}
});
beautifyCategorySelect();
});

Robert Goldmann
committed
var transactionRepeatingModifierID = "#transaction-repeating-modifier";
var transactionRepeatingEndAfterXTimesInputID = "#transaction-repeating-end-after-x-times-input";
AMOUNT_REGEX = new RegExp("^-?\\d+(,\\d+)?(\\.\\d+)?$");
NUMBER_REGEX = new RegExp("^\\d+$");
ALLOWED_CHARACTERS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ",", "."];
function validateAmount(text)
{

Robert Goldmann
committed
var id = "transaction-amount";
if(text.match(AMOUNT_REGEX) == null)
{
addTooltip(id, amountValidationMessage);
document.getElementById("hidden-" + id).value = "";
}
else
{
var amount = parseInt(parseFloat(text.replace(",", ".")) * 100);
document.getElementById("hidden-" + id).value = amount;
}
function validateNumber(text, ID, hiddenID, message)
{
if(text.match(NUMBER_REGEX) == null)
{
addTooltip(ID, message);
if (hiddenID != null)
{
document.getElementById(hiddenID).value = "";
}
return false;
removeTooltip(ID);
if (hiddenID != null)
{
document.getElementById(hiddenID).value = parseInt(text);
}
return true;
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
}
}
function addTooltip(id, message)
{
var element = document.getElementById(id);
removeClass(element, "validate");
removeClass(element, "valid");
addClass(element, "tooltipped");
addClass(element, "invalid");
element.dataset.tooltip=message;
element.dataset.position="bottom";
element.dataset.delay="50";
$('#' + id).tooltip();
}
function removeTooltip(id)
{
var element = document.getElementById(id);
removeClass(element, "validate");
removeClass(element, "invalid");
removeClass(element, "tooltipped");
addClass(element, "valid");
$('#' + id).tooltip('remove');
}
function validateForm()
{
// amount

Robert Goldmann
committed
validateAmount($('#transaction-amount').val());
// handle tags
var tags = $('.chips-autocomplete').material_chip('data');

Robert Goldmann
committed
var parent = document.getElementById("hidden-transaction-tags");
for(var i = 0; i < tags.length; i++)
{
var input = document.createElement("input");
input.setAttribute("type", "hidden");
input.setAttribute("name", "tags[" + i + "].name");
input.setAttribute("value", tags[i].tag);
parent.appendChild(input);
}
if(document.getElementById("enableRepeating").checked)

Robert Goldmann
committed
if(!validateNumber($(transactionRepeatingModifierID).val(), transactionRepeatingModifierID.substr(1), "hidden-" + transactionRepeatingModifierID.substr(1), numberValidationMessage))
{
return false;
}
// handle repeating end
var endNever = document.getElementById("repeating-end-never");
var endAfterXTimes = document.getElementById("repeating-end-after-x-times");
var endDate = document.getElementById("repeating-end-date");

Robert Goldmann
committed
var endInput = document.getElementById("hidden-transaction-repeating-end-value");
if(endNever.checked)
return true;
}
if(endAfterXTimes.checked)
{

Robert Goldmann
committed
if(!validateNumber($(transactionRepeatingEndAfterXTimesInputID).val(), transactionRepeatingEndAfterXTimesInputID.substr(1), null, numberValidationMessage))
{
return false;
}

Robert Goldmann
committed
endInput.value = $(transactionRepeatingEndAfterXTimesInputID).val();
}
if(endDate.checked)
{

Robert Goldmann
committed
endInput.value = $("#transaction-repeating-end-date-input").val();
}

Robert Goldmann
committed
document.getElementById("hidden-" + transactionRepeatingModifierID.substr(1)).value = -1;
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
}
function beautifyCategorySelect() {
var counter = 0;
$("#categoryWrapper ul.dropdown-content.select-dropdown li span").each(function () {
var categoryInfos = $(this).text().split("@@@");
var categoryName = categoryInfos[0];
var firstLetter = capitalizeFirstLetter(categoryName);
var categoryColor = categoryInfos[1];
var appropriateTextColor = categoryInfos[2];
$(this).text(categoryName);
$(this).data("infos", categoryInfos);
$(this).addClass("category-select");
$(this).parent().prepend('<div class="category-circle-small category-select" id="category-' + counter + '" style="background-color: ' + categoryColor + '"><span style="color: ' + appropriateTextColor + '"></span></div>');
$('#categoryWrapper').parent().append('<style>#category-' + counter + ':after{content: "' + firstLetter + '";}</style>');
counter++;
});
// select current category from code again in order to avoid showing the full infos text (e.g. Test@@@#FFFFFF@#000000@@@1) in the input field by materialize
if(typeof selectedCategory !== 'undefined')
{
$("#categoryWrapper ul.dropdown-content.select-dropdown li span.category-select").each(function () {
var categoryID = $(this).data("infos")[3];
if(categoryID === selectedCategory)
{
$(this).parent().trigger("click");
}
});
}
}
function capitalizeFirstLetter(text)
{
return text.charAt(0).toUpperCase();