1// Centralized helpers and validators â must be declared before any usage 2 3// Helper: reliably find the server-side upload fields inside a container. 4function risUpload_findFields($container) { 5 if (!$container || $container.length === 0) return $(); 6 7 return $container.find('input').filter(function () { 8 var $t = $(this); 9 var type = ($t.attr('type') || '').toLowerCase(); 10 var nm = ($t.attr('name') || '').toLowerCase(); 11 var id = ($t.attr('id') || '').toLowerCase(); 12 return $t.hasClass('ris-upload-hidden') 13 || type === 'hidden' 14 || /_guid$/.test(nm) || /_guid$/.test(id) 15 || /_filename$/.test(nm) || /_filename$/.test(id) 16 || /_delfile$/.test(nm) || /_delfile$/.test(id) 17 || ($t.hasClass('none') && $t.attr('aria-hidden') === 'true'); 18 }); 19} 20 21// Ensure a safe global reset function exists before any init code calls it 22if (typeof window.risUpload_resetFields !== 'function') { 23 window.risUpload_resetFields = function (uploadContainer) { 24 var $c = $(uploadContainer); 25 if (!$c || $c.length === 0) return; 26 27 // Clear visible UI 28 $c.find(".form-input--fakeInputValue").text("").removeAttr("title"); 29 30 // Widen scope to .form-field so sibling inputs (outside .form-group--file) are found 31 var $scope = $c.closest('.form-field'); 32 if (!$scope.length) $scope = $c; 33 34 var $fields = $scope.find('input.ris-upload-hidden, input[type="hidden"], input[type="text"]').filter(function () { 35 var $t = $(this); 36 var nm = ($t.attr('name') || '').toLowerCase(); 37 var id = ($t.attr('id') || '').toLowerCase(); 38 return $t.hasClass('ris-upload-hidden') 39 || $t.attr('type') === 'hidden' 40 || /_guid$/.test(nm) || /_guid$/.test(id) 41 || /_filename$/.test(nm) || /_filename$/.test(id) 42 || /_delfile$/.test(nm) || /_delfile$/.test(id); 43 }); 44 45 // Clear values and attached jQuery data 46 $fields.each(function () { 47 try { 48 $(this).val('').removeData('files').removeData('tempid'); 49 } catch (e) { /* ignore readonly etc */ } 50 }); 51 52 // Remove file-list UI 53 $c.find(".form-group--addonFileList").empty(); 54 55 // Remove state classes 56 $c.removeClass("form-group--fileExists form-group--fileLoading"); 57 }; 58} 59 60// Upload error helper (used by risUpload_uploadFile) 61function risUpload_throwError(uploadContainer, errorTxt) { 62 try { alert(errorTxt); } catch (e) { /* ignore */ } 63 if (typeof window.risUpload_resetFields === 'function') { 64 try { window.risUpload_resetFields(uploadContainer); } catch (ex) { console.warn('reset failed', ex); } 65 } else { 66 $(uploadContainer).find(".form-input--fakeInputValue").text("").removeAttr("title"); 67 } 68} 69 70// Utility 71function isNullOrWhitespace(input) { 72 if (typeof input === 'undefined' || input == null) 73 return true; 74 return input.replace(/\s/g, '').length < 1; 75} 76function stripTags(input) { 77 var div = document.createElement("div"); 78 div.innerHTML = input; 79 return div.textContent || div.innerText || ""; 80} 81function replaceSpecialChars(str) { 82 var replaceRegex = /(_{1,})|([^A-Za-z0-9ÃÃÃäöü._\-\[\]])/g; 83 return (str || "").replace(replaceRegex, "_").replace(replaceRegex, "_"); 84} 85 86var validator; 87var initDone = false; 88 89// Safe validator caller 90function safeValidateElement(el) { 91 if (!window.validator || typeof window.validator.element !== 'function') return; 92 try { 93 window.validator.element(el); 94 } catch (ex) { 95 if (window.console && console.warn) console.warn('safeValidateElement failed', ex, el); 96 } 97} 98 99// Register validation methods up-front so rules('add', ...) is safe 100$.validator.addMethod('customemail', function (value, element) { 101 return this.optional(element) || (typeof validCustomRegex !== 'undefined' && validCustomRegex.test(value)); 102}, (typeof customErrors !== "undefined" && customErrors.email) ? customErrors.email : "Invalid email"); 103 104jQuery.validator.addMethod("notEqual", 105 function (value, element, params) { 106 var val = new Date('1/1/1991' + ' ' + value); 107 var par = new Date('1/1/1991' + ' ' + $(params).val());
108 if (!/Invalid|NaN/.test(new Date(val))) { 109 return val.getTime() != par.getTime() 110 } 111 return isNaN(val) && isNaN(par) 112 || (Number(val) > Number(par)); 113 }, $.validator.format((typeof customErrors !== "undefined" && customErrors.greaterThan) ? customErrors.greaterThan : "Invalid")); 114 115$.validator.addMethod("countrestrict", function (value, element, options) { 116 var $fields = $(element).closest("fieldset").find("input:checked"); 117 return $fields.length <= options; 118}, $.validator.format('Choose no more than {0}.')); 119 120$.validator.addMethod("validateNullOrWhiteSpace", function (value, element) { 121 return !isNullOrWhitespace(stripTags(value)); 122}, $.validator.format((typeof customErrors !== "undefined" && customErrors.notEmpty) ? customErrors.notEmpty : "This field is required.")); 123 124$.validator.addMethod("validateNotNullForDD", function (value, element) { 125 return (isNaN(value) && value.length > 0) || value > 0 126}, $.validator.format((typeof customErrors !== "undefined" && customErrors.notValidValue) ? customErrors.notValidValue : "Invalid selection")); 127 128jQuery.validator.addMethod("validation", function (value, element) { 129 if (this.optional(element)) return true; 130 var pat = $(element).attr("pattern") || ""; 131 if (!pat) return true; 132 var pattern; 133 try { pattern = new RegExp(pat, 'gm'); } catch (ex) { console.warn('invalid pattern', pat); return true; } 134 if ($(element).is('textarea')) { 135 return pattern.test(value.trim()); 136 } 137 if ($(element).is('input:text') && value.trim() != value) { 138 return false; 139 } 140 return pattern.test(value); 141}, function (params, element) { 142 var $element = $(element); 143 var errMsg = $element.attr("data-errormsg") || "Invalid value"; 144 if ($element.is('input:text') && $element.val() != $element.val().trim()) { 145 if (window.customErrors && customErrors.extraSpaces) errMsg = customErrors.extraSpaces; 146 } 147 return $.validator.format(errMsg); 148}); 149 150$.validator.addMethod("require_from_group", function (value, element, options) { 151 var maxLen = Number.MAX_SAFE_INTEGER || 9007199254740991; 152 if (options[2] != undefined) maxLen = options[2]; 153 var $fields = $(element).closest("fieldset").find("input" + options[1]), 154 $fieldsFirst = $fields.eq(0), 155 validatorClone = $fieldsFirst.data("valid_req_grp") ? $fieldsFirst.data("valid_req_grp") : $.extend({}, this), 156 isValid = function () { 157 var len = $fields.filter(function () { return validatorClone.elementValue(this); }).length; 158 return len >= options[0] && len <= maxLen; 159 }; 160 161 $fieldsFirst.data("valid_req_grp", validatorClone); 162 163 if (!$(element).data("being_validated")) { 164 $fields.data("being_validated", true); 165 $fields.each(function () { 166 validatorClone.element(this); 167 }); 168 $fields.data("being_validated", false); 169 } 170 return isValid(); 171}, function (options, element) { 172 var errMsg = (typeof customErrors !== "undefined" && customErrors.selectOne) ? customErrors.selectOne : "Select at least one"; 173 if ($(element).closest("fieldset").find("input" + options[1]).filter(function () { return validator.elementValue(this); }).length != 0) { 174 if (options[2] != undefined) { 175 if (typeof customErrors !== "undefined" && customErrors.lessThan) errMsg = customErrors.lessThan.format(options[2]); 176 } 177 } 178 return $.validator.format(errMsg); 179}); 180 181// Improved upload function â validation call guarded (no direct .valid()) 182function risUpload_uploadFile(uploadContainer, file, repeated) { 183 var multi = $(uploadContainer).hasClass("form-group--multiple"); 184 if (!multi) { 185 risUpload_resetFields(uploadContainer); 186 } 187 $(uploadContainer).addClass("form-group--fileLoading"); 188 repeated = repeated === undefined ? 0 : repeated; 189 190 var xhr = new XMLHttpRequest(); 191 var uploadErrorTexts = { 192 tooLarge: "Diese Datei ist zu groÃ.Die maximal zulässige GröÃe beträgt 10Mb.", 193 invalidType: "Dieser Datentyp wird nicht unterstützt" 194 }; 195 196 xhr.addEventListener("load", function () { 197 if (typeof uploadErrorTextsDB !== 'undefined') { 198 $.extend(uploadErrorTexts, uploadErrorTextsDB); 199 } 200 201 var status = xhr.status; 202 var respText = xhr.response || xhr.responseText || ""; 203 var uploadData; 204 try { uploadData = respText ? JSON.parse(respText) : {}; } catch (e) { uploadData = {}; } 205 206 var $uploadContainer = $(uploadContainer); 207 var multi = $uploadContainer.hasClass("form-group--multiple"); 208 209 if (status == 200 && !uploadData.ErrorText) { 210 $uploadContainer.removeClass("form-group--fileLoading"); 211 212 var $scope = $uploadContainer.closest('.form-field'); 213 if (!$scope.length) $scope = $uploadContainer; 214 var $files = risUpload_findFields($scope); 215 216 if (multi) { 217 if (!$files.data("files")) $files.data("files", []); 218 $files.data("files").push(uploadData); 219 if ($files.length) $files.val(JSON.stringify($files.data("files"))); 220 addFileCtrl($uploadContainer.find(".form-group--addon
220FileList"), uploadData); 221 } else { 222 $uploadContainer.find(".form-input--fakeInputValue").text(uploadData.FileName || ""); 223 $uploadContainer.find(".form-input--fakeInputValue").attr("title", uploadData.FileName || ""); 224 225 var $filesFirst = $files.first(); 226 227 if ($filesFirst && $filesFirst.length) { 228 try { $filesFirst.val(uploadData.TempId || ""); } catch (e) { /* ignore */ } 229 try { $filesFirst.data('tempid', uploadData.TempId || ""); } catch (e) { /* ignore */ } 230 try { $uploadContainer.data('tempid', uploadData.TempId || ""); } catch (e) { /* ignore */ } 231 232 // update filename sibling (if present) and validate it safely using validator.element 233 var $nameSibling = $filesFirst.next('input[type=text], input[type=hidden], textarea, select'); 234 if ($nameSibling && $nameSibling.length && validator && typeof validator.element === 'function') { 235 try { $nameSibling.val(uploadData.FileName || ""); } catch (e) { /* ignore */ } 236 try { validator.element($nameSibling[0]); } catch (e) { /* ignore */ } 237 } 238 239 // clear delfile sibling if it exists 240 var $delfield = $filesFirst.next().next(); 241 if ($delfield && $delfield.length) { 242 try { $delfield.val(null); } catch (e) { /* ignore */ } 243 } 244 } 245 246 $uploadContainer.addClass("form-group--fileExists"); 247 } 248 return; 249 } 250 251 if ((status === 500 || status === 502 || status === 503 || status === 504) && repeated < 3) { 252 $uploadContainer.removeClass("form-group--fileLoading"); 253 setTimeout(function () { 254 risUpload_uploadFile(uploadContainer, file, repeated + 1); 255 }, 300 * (repeated + 1)); 256 return; 257 } 258 259 var errorText = xhr.statusText || "Upload failed"; 260 try { 261 if (uploadData && uploadData.ErrorText) errorText = uploadData.ErrorText; 262 } catch (e) { /* ignore */ } 263 264 if (status == 413) errorText = uploadErrorTexts.tooLarge; 265 if (status == 501) errorText = uploadErrorTexts.invalidType; 266 267 risUpload_throwError(uploadContainer, errorText); 268 }, false); 269 270 xhr.addEventListener("error", function () { 271 $(uploadContainer).removeClass("form-group--fileLoading"); 272 risUpload_throwError(uploadContainer, "Network error during upload."); 273 }, false); 274 275 try { 276 xhr.open("post", envurl + "system/web/services/upload/uploadHandler.ashx", true); 277 try { xhr.setRequestHeader("Content-Type", "multipart/form-data"); } catch (e) { /* ignore */ } 278 try { xhr.setRequestHeader("X-File-Type", file.type); } catch (e) { /* ignore */ } 279 try { xhr.setRequestHeader("X-File-Size", file.size); } catch (e) { /* ignore */ } 280 try { xhr.setRequestHeader("X-File-Name", replaceSpecialChars(file.name)); } catch (e) { /* ignore */ } 281 282 try { xhr.send(file); } catch (e) { risUpload_throwError(uploadContainer, "Failed to send file."); } 283 } catch (e) { 284 risUpload_throwError(uploadContainer, "Upload initialization failed."); 285 } 286} 287// Add / remove UI helpers for addon file list 288function addonFileList_handleDelete(e) { 289 if (e.type == "keydown" && e.key != "Enter") { 290 return; 291 } 292 removeFileItem(this, $(this).parent().parent().attr("id")); 293} 294 295function addFileCtrl(container, uploadData) { 296 var $container = $(container); 297 if (!$container || $container.length === 0 || !uploadData || !uploadData.TempId) return; 298 299 var safeId = (uploadData.TempId || "").toString().replace(/([ #;&,.+*~':"!^$[\]()=>|\/\\])/g, "\\$1"); 300 301 var $list = $container.children('ul').first(); 302 if ($list.length === 0) { 303 $list = $('<ul></ul>'); 304 $container.append($list); 305 } 306 307 if ($list.find('li#' + safeId).length) return; 308 309 var fileli = $('<li/>') 310 .attr("id", uploadData.TempId) 311 .html("<span> <span class=\"far fa-file\"></span><span>" + uploadData.FileName + "</span> </span> "); 312 var fileDel = $('<span/>') 313 .attr('tabindex', '0') 314 .addClass('addonFileList__delete') 315 .html(" <span class=\"fas fa-xmark\" aria-hidden=\"true\"></span> <span class=\"sr-only\">Datei entfernen</span> "); 316 fileDel[0].addEventListener("click", addonFileList_handleDelete); 317 fileDel[0].addEventListener("keydown", addonFileList_handleDelete); 318 fileli.append(fileDel); 319 $list.append(fileli); 320} 321 322function removeFileItem(container, TempId) { 323 var $files = $(container).parent().parent().parent().parent().parent().find("input[type=hidden]"); 324 var data = jQuery.grep($files.data("files") || [], function (value) { 325 return value.TempId != TempId; 326 });
327 $files.data("files", data); 328 $files.val(JSON.stringify($files.data("files") || [])); 329 $(container).parent().remove(); 330} 331 332/* --------------------------- 333 Main initialization and original logic follows 334 --------------------------- */ 335 336$(document).ready(function () { 337 $('#aspnetForm :radio, #aspnetForm :checkbox').on('change', function () { 338 if ($(this).is(':radio')) { 339 $(this).closest('.form-field').find('.form-label.is-checked').removeClass('is-checked') 340 } 341 if ($(this).is(':checked')) { 342 $(this).closest('.form-label').addClass('is-checked') 343 } else { 344 $(this).closest('.form-label').removeClass('is-checked') 345 } 346 }); 347 348 $("span[id$=_ffinput]").each(function () { 349 if ($(this).find("[type=checkbox][required]").length > 0 && $(this).find("[type=checkbox]").length > 1) { 350 $(this).attr("data-groupWithOneRequired", true) 351 $(this).find("label input").removeAttr("required") 352 $(this).find("label input").addClass("jsValidate-requireOne"); 353 } 354 }); 355 356 $('.risFormEdit').each(function () { 357 new FroalaEditor(this, { 358 enter: FroalaEditor.ENTER_P, 359 paragraphFormat: { 360 N: 'Normal', 361 H2: 'Heading 2', 362 H3: 'Heading 3', 363 H4: 'Heading 4' 364 }, 365 language: langSetting, 366 key: editorConfig.key, 367 attribution: false, 368 toolbarButtons: { 369 'moreText': { 370 'buttons': ['bold', 'italic', 'subscript', 'superscript'], 371 'buttonsVisible': 2 372 }, 373 'moreParagraph': { 374 'buttons': ['alignLeft', 'alignCenter', 'alignRight', 'alignJustify', 'formatOLSimple', 'formatUL', 'paragraphFormat'], 375 'buttonsVisible': 3 376 }, 377 'moreRich': { 378 'buttons': ['insertHR', 'clearFormatting'] 379 }, 380 'moreMisc': { 381 'buttons': ['undo', 'redo'], 382 'align': 'right', 383 'buttonsVisible': 0 384 } 385 }, 386 placeholderText: null 387 }) 388 }); 389 390 // Validator initialization uses methods already registered above 391 validator = $('#aspnetForm').validate({ 392 onfocusout: function (element) { 393 if ($(element).hasClass("fr-element")) 394 element = $(element).closest(".fr-box").next("textarea"); 395 396 try { $(element).valid(); } catch (e) { /* defensive */ } 397 }, 398 ignore: function (index, el) { 399 if ($(el).hasClass("fr-element")) 400 element = $(el).closest(".fr-box").next("textarea"); 401 402 var $el = $(el); 403 if ($el.hasClass('always-validate')) { 404 return false; 405 } 406 // Default behavior 407 return $el.is(':hidden:not([data-timeseries="text"][required="required"])'); 408 }, 409 highlight: function (element, errorClass, validClass) { 410 unhighlightWarning($(element)); 411 if ($(element).parents().eq(2).is("fieldset")) { 412 $(element).parents().eq(2).addClass("form-alert form-alert--error form-alert--withBg fieldset-error"); 413 } else { 414 $(element).parent().addClass("form-alert form-alert--error form-alert--withBg"); 415 } 416 if ($(element).parents().eq(2).is("fieldset")) { 417 $(element).parents().eq(3).addClass("form-error-inside"); 418 } else { 419 $(element).parents().eq(2).addClass("form-error-inside"); 420 } 421 422 var $errorBox = $('#ctl00_ctl00_ctl00_cph_col_a_cph_content_cph_content_detail_pnlNeuErrors'); 423 var $errorList = $errorBox.find('ul'); 424 if ($errorList.length === 0) { 425 $errorList = $('<ul></ul>'); 426 $errorBox.append('<div class="defaultfontsize"><div class="form-alert form-alert--error form-alert--withBg formErrorList"><p class="formErrorListTitle">Folgende Fehler sind beim Absenden aufgetreten!</p></div></div>'); 427 $errorBox.find('.formErrorList').append($errorList); 428 } 429 var labelText = $(element).closest('.form-field').find('.form-legend').text() || 430 $(element).closest('.form-field').find('.form-label').first().text() || 431 $(element).closest('.form-field').find('label[for="' + $(element).attr('id') + '"]').text(); 432 var errorMsg = $(element).data('errormsg') || jQuery.validator.messages.required; 433 434 var errorText; 435 if (typeof errorMsg === 'string' && errorMsg.indexOf('{0}') >= 0) { 436 errorText = errorMsg.replace('{0}', $.trim(labelText).replace(/[.!?]+$/, '')); 437 } else { 438 errorText = $.trim(labelText) + ': ' + errorMsg; 439 } 440 441 if ($errorList.find('li:contains("' + errorText + '")').length === 0) { 442 var errorFrom = $(element).attr('name'); 443 var $errorItem = $( 444 '<li>' + 445 '<a href="javascript:void(0)" onclick="focusError(this);" ' + 446 'data-errorelement="' + $(element).attr('id') + '" ' + 447 'data-errorfrom="' + errorFrom + '" ' + 448 'class="errorElement" ' +
449 'title="Springen Sie zu dem jeweiligen Feld!">' + 450 errorText + 451 '</a>' + 452 '</li>' 453 ); 454 $errorList.append($errorItem); 455 } 456 $errorBox.show(); 457 }, 458 unhighlight: function (element, errorClass, validClass) { 459 var $errorBox = $('#ctl00_ctl00_ctl00_cph_col_a_cph_content_cph_content_detail_pnlNeuErrors'); 460 var $errorList = $errorBox.find('ul'); 461 var labelText = $(element).closest('.form-field').find('.form-legend').text() || 462 $(element).closest('.form-field').find('.form-label').first().text() || 463 $(element).closest('.form-field').find('label[for="' + $(element).attr('id') + '"]').text(); 464 var errorMsg = $(element).data('errormsg') || jQuery.validator.messages.required; 465 var errorFrom = $(element).attr('name'); 466 $errorList.find('a[data-errorfrom="' + errorFrom + '"]').closest('li').remove(); 467 if ($errorList.children().length === 0) { 468 $errorBox.hide(); 469 } 470 if ($(element).parents().eq(2).is("fieldset")) { 471 $(element).parents().eq(2).removeClass("form-alert form-alert--error form-alert--withBg fieldset-error"); 472 } else { 473 $(element).parent().removeClass("form-alert form-alert--error form-alert--withBg"); 474 } 475 if ($(element).parents().eq(2).find(".form-alert").length > 0) { 476 return (false); 477 } else if ($(element).parents().eq(2).is("fieldset") && $(element).parents().eq(5).find(".form-alert").length > 0) { 478 return (false); 479 } else if ($(element).parents().eq(2).is("fieldset")) { 480 $(element).parents().eq(4).removeClass("form-error-inside"); 481 } else { 482 $(element).parents().eq(2).removeClass("form-error-inside"); 483 } 484 }, 485 errorPlacement: function (error, element) { 486 var placement = $(element).data('error'); 487 if (placement) { 488 if (!$(placement).html()) { 489 $(placement).append(error) 490 } 491 } else { 492 element.parent().append(error); 493 } 494 } 495 }); 496 // Refresh messages on postback: rebuild inline error labels using current rules/messages.
497 // Fixes cases where the server rendered invalid state but the jquery-validate message is still the default EN text. 498 // Global override: for "required", prefer data-errormsg (localized), otherwise fall back. 499 $.extend($.validator.messages, { 500 required: function (param, element) { 501 var $el = $(element); 502 var msg = $el.data('errormsg'); 503 504 if (typeof msg === 'string' && msg.length) { 505 if (msg.indexOf('{0}') >= 0) { 506 var labelText = 507 $el.closest('.form-field').find('.form-legend').text() || 508 $el.closest('.form-field').find('.form-label').first().text() || 509 $el.closest('.form-field').find('label[for="' + $el.attr('id') + '"]').text() || 510 ''; 511 msg = msg.replace('{0}', $.trim(labelText).replace(/[.!?]+$/, '')); 512 } 513 return msg; 514 } 515 516 return "Dieses Feld ist erforderlich."; 517 } 518 }); 519 // wire file controls 520 $("#aspnetForm").find(".form-group--file").each(function () { 521 var uploadContainer = $(this); 522 var input = $(this).find("input[type='file']"); 523 var delInputEl = $(this).find("span.form-input--fileDelete"); 524 var fakeInput = $(this).find(".form-input.form-input--fakeInput"); 525 526 // Widen scope to .form-field so sibling inputs are found 527 var $fieldScope = uploadContainer.closest('.form-field'); 528 if (!$fieldScope.length) $fieldScope = uploadContainer; 529 var $existing = risUpload_findFields($fieldScope); 530 var hasServerValue = false; 531 if ($existing && $existing.length) { 532 $existing.each(function () { 533 if ($(this).val().trim().length > 0) { hasServerValue = true; return false; } 534 }); 535 } 536 if (!uploadContainer.hasClass("form-group--fileExists") && !hasServerValue) { 537 window.risUpload_resetFields(uploadContainer); 538 } 539 540 $(fakeInput).on("click", function () { 541 $(input).trigger("click"); 542 }); 543 544 $(input).on("change", function () { 545 var files = $(this)[0] && $(this)[0].files ? $(this)[0].files : []; 546 for (var i = 0, l = files.length; i < l; i++) { 547 risUpload_uploadFile(uploadContainer, files[i]); 548 } 549 }); 550 551 $(delInputEl).on("click keyup", function (evt) { 552 if (evt.type == "keyup" && evt.key !== "Enter") { 553 return; 554 } 555 window.risUpload_resetFields(uploadContainer); 556 var $scope = uploadContainer.closest('.form-field'); 557 if (!$scope.length) $scope = uploadContainer.parent(); 558 $scope.find('input').filter(function () { 559 var id = ($(this).attr('id') || '').toLowerCase(); 560 var nm = ($(this).attr('name') || '').toLowerCase(); 561 return /_delfile$/.test(id) || /_delfile$/.test(nm); 562 }).val('true'); 563 }); 564 }); 565 566 $('#aspnetForm div[id$=_NeuFormular] [id*=_ffinput], #aspnetForm div[id$=_NeuFormular] [id*=_fflogin]').not('[id^=info-ff]').not('span').each(function () { 567 if ($(this).attr('required')) { 568 $(this).rules('add', { required: true }); 569 if ($(this).is(':text') || $(this).is('textarea')) { 570 $(this).rules('add', { validateNullOrWhiteSpace: true }); 571 } else if ($(this).is('select')) { 572 $(this).rules('add', { validateNotNullForDD: true }); 573 } 574 } 575 if ($(this).hasClass('jsValidate-requireOne')) { 576 $(this).rules('add', { require_from_group: [1, '.jsValidate-requireOne', $(this).data('form-cbo-maxlength')] }); 577 } 578 $(this).rules('add', { validation: true }); 579 }); 580 581 $("[data-formmaxlen]").each(function () { 582 $(this).rules('add', { maxlength: $(this).data('formmaxlen') }); 583 }); 584 585 $("[data-endtime]").each(function () { 586 $(this).rules('add', { notEqual: $('[data-starttime="' + $(this).data('endtime') + '"]') }); 587 });
588 589 $("[data-formminlen]").each(function () { 590 $(this).rules('add', { minlength: $(this).data('formminlen') }); 591 }); 592 593 $('#aspnetForm input[type="time"]').blur(function () { $(this).val($(this).val()) }); 594 595 $('#aspnetForm input[type="date"]').blur(function () { $(this).val($(this).val()) }); 596 597 $('[data-ddchange=true]').each(function () { 598 $(this).change(function () { 599 updateRelatedDDElements(this, true); 600 }); 601 updateRelatedDDElements(this, false); 602 }); 603 604 $('[data-errorelement]').each(function () { 605 var $element = $('#' + $(this).data('errorelement')); 606 if ($element.parents().eq(2).is("fieldset")) { 607 $element.parents().eq(2).addClass("form-alert form-alert--error form-alert--withBg fieldset-error"); 608 } else { 609 $element.parent().addClass("form-alert form-alert--error form-alert--withBg"); 610 } 611 if ($element.parents().eq(2).is("fieldset")) { 612 $element.parents().eq(3).addClass("form-error-inside"); 613 } else { 614 $element.parents().eq(2).addClass("form-error-inside"); 615 } 616 }); 617 618 $('[data-timeseries=button]').click(function (event) { 619 event.preventDefault(); 620 var gnr = 4; 621 var stylesheet = 1; 622 risform_openTerminserieWithTime($(this), gnr, ris_form_sprache, stylesheet); 623 }); 624 625 function updateRelatedDDElements(element, validate) { 626 $element = $(element); 627 if ($element.is(':visible') && $element.data('truevalues') != undefined) { 628 var vals = $element.data('truevalues').toString(); 629 var toShow = $.inArray($(element).val(), vals.split(',')) > -1 630 $('[' + $element.data('itemstochange') + ']').each(function () { 631 if (toShow) { 632 if ($(this).is("fieldset")) { 633 $(this).show(); 634 } else { 635 $(this).closest('.form-grid').show(); 636 updateRelatedDDElements(this); 637 } 638 } else { 639 if ($(this).is("fieldset")) { 640 $(this).hide(); 641 } else { 642 $(this).closest('.form-grid').hide(); 643 $(this).rules('remove', 'required'); 644 $(this).removeAttr('required'); 645 $(this).closest('.form-grid').find('.form-optional').show(); 646 } 647 } 648 }); 649 } 650 if ($element.data('showonvalue') != undefined) { 651 var itmstochange = $element.data('showonvalue').replace("data-", ""); 652 $('[' + $element.data('showonvalue') + ']').each(function () { 653 if ($element.val() == $(this).data(itmstochange)) { 654 $(this).closest('.form-grid').show(); 655 } else { 656 $(this).closest('.form-grid').hide(); 657 } 658 }); 659 } 660 if ($element.is(':visible') && $element.data('updatereq')) { 661 var ddval = $element.val(); 662 $('[' + $element.data('itemstochange') + ']').each(function () { 663 if ($(this).data('reqonvalue') == ddval) { 664 $(this).rules('add', 'required'); 665 $(this).attr('required', 'required'); 666 $(this).closest('.form-grid').find('.form-optional').hide(); 667 668 } else { 669 $(this).rules('remove', 'required'); 670 $(this).removeAttr('required'); 671 $(this).removeAttr('aria-invalid'); 672 $(this).closest('.form-grid').find('.form-optional').show(); 673 } 674 if (validate) 675 validator.element(this); 676 }); 677 } 678 } 679 // Restore upload UI from server-provided fields (run on page load) 680 function risUpload_initFromServer() { 681 $("#aspnetForm").find(".form-group--file").each(function () { 682 var $container = $(this); 683
684 // Widen scope to .form-field so sibling inputs (outside .form-group--file) are found 685 var $scope = $container.closest('.form-field'); 686 if (!$scope.length) $scope = $container; 687 688 var $serverFields = $scope.find('input.ris-upload-hidden, input[type="hidden"], input[type="text"]').filter(function () { 689 var $t = $(this); 690 var nm = ($t.attr('name') || '').toLowerCase(); 691 var id = ($t.attr('id') || '').toLowerCase(); 692 return $t.hasClass('ris-upload-hidden') 693 || $t.attr('type') === 'hidden' 694 || /_guid$/.test(nm) || /_guid$/.test(id) 695 || /_filename$/.test(nm) || /_filename$/.test(id) 696 || /_delfile$/.test(nm) || /_delfile$/.test(id); 697 }); 698 699 if (!$serverFields || $serverFields.length === 0) return; 700 701 // 1) Multi-file JSON field 702 var jsonFiles = null; 703 try { 704 jsonFiles = $serverFields.data("files") || null; 705 if (!jsonFiles && $serverFields.length && typeof $serverFields.val === "function") { 706 var raw = $serverFields.val(); 707 if (raw && (raw.charAt(0) === "[" || raw.charAt(0) === "{")) { 708 jsonFiles = JSON.parse(raw); 709 } 710 } 711 } catch (e) { jsonFiles = null; } 712 713 // inside risUpload_initFromServer, where jsonFiles is processed: 714 if (Array.isArray(jsonFiles) && jsonFiles.length > 0) { 715 $serverFields.data("files", jsonFiles); 716 try { $serverFields.val(JSON.stringify(jsonFiles)); } catch (e) { /* ignore */ } 717 var $list = $container.find(".form-group--addonFileList"); 718 // do NOT blindly empty if the server already rendered items; instead dedupe 719 for (var i = 0; i < jsonFiles.length; i++) { 720 try { 721 // skip if li with same TempId already present 722 var tempId = (jsonFiles[i].TempId || "").toString().replace(/([ #;&,.+*~':"!^$[\]()=>|\/\\])/g, "\\$1"); 723 if ($list.find("li#" + tempId).length) continue; 724 addFileCtrl($list, jsonFiles[i]); 725 } catch (e) { /* ignore */ } 726 } 727 $container.addClass("form-group--fileExists"); 728 return; 729 } 730 731 // 2) Single-file GUID/filename/delfile triplet 732 var guid = "", filename = "", delflag = ""; 733 $serverFields.each(function () { 734 var nm = (this.name || "").toLowerCase(); 735 var id = (this.id || "").toLowerCase(); 736 var val = $(this).val(); 737 if (/_guid$/.test(nm) || /_guid$/.test(id)) guid = val || guid; 738 if (/_filename$/.test(nm) || /_filename$/.test(id)) filename = val || filename; 739 if (/_delfile$/.test(nm) || /_delfile$/.test(id)) delflag = val || delflag; 740 }); 741 742 // If server marked file deleted, ensure UI cleared 743 if (delflag && (delflag === "1" || (typeof delflag === "string" && delflag.toLowerCase() === "true"))) { 744 try { window.risUpload_resetFields($container); } catch (e) { /* ignore */ } 745 return; 746 } 747 748 if (guid || filename) { 749 // Update visible UI 750 var displayName = filename || ""; 751 $container.find(".form-input--fakeInputValue").text(displayName).attr("title", displayName); 752 753 try { 754 // Prefer explicit filename/guid fields by suffix 755 var $guidField = $serverFields.filter(function () { 756 var n = (this.name || "").toLowerCase(), i = (this.id || "").toLowerCase(); 757 return /_guid$/.test(n) || /_guid$/.test(i); 758 }).first(); 759 var $fileNameField = $serverFields.filter(function () { 760 var n = (this.name || "").toLowerCase(), i = (this.id || "").toLowerCase(); 761 return /_filename$/.test(n) || /_filename$/.test(i); 762 }).first(); 763 764 if ($guidField && $guidField.length) { 765 $guidField.val(guid || "").data('tempid', guid || "").trigger('change'); 766 } 767 768 if ($fileNameField && $fileNameField.length) { 769 $fileNameField.val(filename || "").trigger('change'); 770 // validate filename field safely 771 if (validator && typeof validator.element === 'function') { 772 try { validator.element($fileNameField[0]); } catch (e) { /* ignore */ } 773 } else { 774 safeValidateElement($fileNameField[0]); 775 } 776 } 777 778 // fallback: keep data.files JSON updated in a generic field 779 if ((!$guidField.length && !$fileNameField.length) && $serverFields.length) { 780 try { 781 if (!$serverFields.data("files")) $serverFields.data("files", []); 782 $serverFields.data("files").push({ TempId: guid || "", FileName: filename || "" }); 783 $serverFields.val(JSON.stringify($serverFields.data("files"))).trigger('change'); 784 } catch (e) { /* ignore */ } 785 } 786 } catch (e) { /* ignore */ } 787 788 $container.data('tempid', guid || ""); 789 $container.addClass("form-group--fileExists"); 790 } 791 }); 792 } 793 794 // Call initializer so server-provided values restore the UI before user interacts 795 risUpload_initFromServer(); 796 $("[data-form-max-length-no-muss]").each(function () { 797 $(this).closest("fieldset").find("input").rules('add', { countrestrict: $(this).data('maxcount') }); 798 $(this).closest("fieldset").find("input").rules('add', { validation: true });
799 }); 800 801 $('[data-rdochange=true]').each(function () { 802 $(this).change(function () { 803 var changedElements = []; 804 var changeval = $(this).find('input:checked').val(); 805 var itmstochange = $(this).data('itemstochange').replace("data-", ""); 806 $('[' + $(this).data('itemstochange') + ']').each(function () { 807 if ($(this).data(itmstochange) == changeval) { 808 $(this).closest('.form-grid').show(); 809 changedElements.push($(this)); 810 } else { 811 $(this).closest('.form-grid').hide(); 812 } 813 if ($(this).data('reqonvalue')) { 814 if ($(this).data('reqonvalue') == changeval) { 815 $(this).rules('add', 'required'); 816 $(this).attr('required', 'required'); 817 $(this).closest('.form-grid').find('.form-optional').hide(); 818 819 } else { 820 $(this).rules('remove', 'required'); 821 $(this).removeAttr('required'); 822 $(this).removeAttr('aria-invalid'); 823 $(this).closest('.form-grid').find('.form-optional').show(); 824 } 825 if (initDone) 826 validator.element(this); 827 } 828 }); 829 830 for (var element in changedElements) { 831 if (changedElements[element].data('ddchange')) 832 updateRelatedDDElements(changedElements[element], false); 833 }; 834 }); 835 $(this).change(); 836 }); 837 838 $('[data-cbochange=true]').each(function () { 839 $(this).change(function () { 840 var toHide = $(this).find("input").is(":checked"); 841 var itmstochange = $(this).data('itemstochange').replace("data-", ""); 842 $('[' + $(this).data('itemstochange') + ']').each(function () { 843 if (toHide == $(this).data(itmstochange)) { 844 $(this).closest('.form-grid').show(); 845 } else { 846 $(this).closest('.form-grid').hide(); 847 } 848 if ($(this).data('reqonvalue')) { 849 if ($(this).data('reqonvalue') == toHide) { 850 $(this).rules('add', 'required'); 851 $(this).attr('required', 'required'); 852 $(this).closest('.form-grid').find('.form-optional').hide(); 853 } else { 854 $(this).rules('remove', 'required'); 855 $(this).removeAttr('required'); 856 $(this).removeAttr('aria-invalid'); 857 $(this).closest('.form-grid').find('.form-optional').show(); 858 } 859 if (initDone) 860 validator.element(this); 861 } 862 }); 863 }); 864 $(this).change(); 865 }); 866 867 $('[data-cbochange=false]').each(function () { 868 $(this).change(function () { 869 var toHide = !($(this).find("input").is(":checked")); 870 var itmstochange = $(this).data('itemstochange').replace("data-", ""); 871 var els = []; 872 $('[' + $(this).data('itemstochange') + ']').each(function () { 873 if (toHide == $(this).data(itmstochange)) { 874 $(this).closest('.form-grid').show(); 875 } else { 876 $(this).closest('.form-grid').hide(); 877 } 878 els.push($(this)); 879 }); 880 if (toHide) 881 for (var i = 0; i < els.length; i++) { 882 els[i].change(); 883 } 884 }); 885 $(this).change(); 886 }); 887 888 $('[id$="dd_ffms"]').each(function () { 889 risform_showms($(this).parent()); 890 }); 891 892 $('[data-timeseries=text]').each(function () { 893 rists_formatTimes(this); 894 }); 895 896 initDone = true; 897 898 $("button[type='reset']").closest('form').on('reset', function (event) { 899 $('.is-checked [type=checkbox]:not(:checked)').closest('label').removeClass('is-checked'); 900 $('[id$=NeuFormular] :input:visible:enabled:first').focus(); 901 if ($("[id$=ff_oz_hidden]").length > 0) { 902 $("[id$=ff_oz_hidden]").val($("[id$=ff_oz_hiddeninit]").val()); 903 risoz_formatTimes(); 904 } 905 removeMarker(); 906 setTimeout(function () { 907 $('[data-ddchange=true]').each(function () { 908 updateRelatedDDElements(this, false); 909 }); 910 $('[data-rdochange=true]').each(function () { 911 $(this).change(); 912 }); 913 validator.resetForm(); 914 }, 1); 915 });
916 917 $.fn.ris_frm_collapsible = function (options) { 918 var settings = $.extend({ 919 collapsed: false, 920 animation: true, 921 speed: "medium" 922 }, options); 923 924 this.each(function () { 925 var $fieldset = $(this); 926 var $legend = $fieldset.children("legend"); 927 var isCollapsed = $fieldset.hasClass("collapsed"); 928 929 $legend.click(function () { 930 collapse($fieldset, settings, !isCollapsed); 931 isCollapsed = !isCollapsed; 932 }); 933 934 // Perform initial collapse. 935 // Don't use animation to close for initial collapse. 936 if (isCollapsed) { 937 collapse($fieldset, { animation: false }, isCollapsed); 938 } else { 939 collapse($fieldset, settings, isCollapsed); 940 } 941 942 }); 943 }; 944 945 /** 946 * Collapse/uncollapse the specified fieldset. 947 * @param {object} $fieldset 948 * @param {object} options 949 * @param {boolean} collapse 950 */ 951 function collapse($fieldset, options, doCollapse) { 952 $container = $fieldset.find("div:not(.none):not(.collapsible-icon)"); 953 if (doCollapse) { 954 if (options.animation) { 955 $container.slideUp(options.speed); 956 957 } else { 958 $container.hide(); 959 } 960 $fieldset.find('.collapsible-icon').ris_rotate(0, 350); 961 $fieldset.removeClass("expanded").addClass("collapsed"); 962 } else { 963 if (options.animation) { 964 $container.slideDown(options.speed); 965 } else { 966 $container.show(); 967 } 968 $fieldset.find('.collapsible-icon').ris_rotate(180, 350); 969 $fieldset.removeClass("collapsed").addClass("expanded"); 970 } 971 }; 972 $('.form-fieldset.collapsed').ris_frm_collapsible() 973 $('.form-fieldset.collapsed a').focus(function () { 974 $(this).closest('.form-fieldset').addClass('selected_collapser'); 975 }).blur(function () { 976 $(this).closest('.form-fieldset').removeClass('selected_collapser'); 977 }); 978 $('.form-fieldset.collapsed').each(function () { 979 if ($(this).find(":input").filter(function () { 980 if ($(this).is('select') && ($(this).val() == 0 || $(this).val() == 523)) { 981 return false; 982 } 983 return $.trim($(this).val()).length > 0 984 }).length > 0) { 985 $(this).find('legend').click(); 986 987 } 988 }); 989 990 $('[data-vmnews=fw]').click(function (event) { 991 event.preventDefault(); 992 if ($('#aspnetForm').valid()) { 993 $("." + $(this).data('csstohide')).addClass("none"); 994 $("." + $(this).data('csstoshow')).removeClass("none"); 995 if ($(this).data('vmds') !== undefined) { 996 if ($(this).data('vmds')) 997 $(".vmds").show(); 998 else 999 $(".vmds").hide(); 1000 } 1001 if ($("." + $(this).data('csstoshow')).find('[data-vmfoto=1]').length > 0) 1002 { 1003 if ($("." + $(this).data('csstoshow')).find('[data-vmfoto=1]').find("input").is(":checked")) 1004 $("." + $(this).data('csstoshow') + "sub").removeClass("none"); 1005 else 1006 $("." + $(this).data('csstoshow') + "sub").addClass("none"); 1007 } 1008 } 1009 return false; 1010 }); 1011 1012 $('[data-warning]').blur(function () { 1013 var warning = $(this).data().warning; 1014 if ($(this).attr("aria-invalid") != "true") { 1015 unhighlightWarning($(this)); 1016 var curval = parseFloat($(this).val().replace(',', '.')) 1017 if (warning.max) { 1018 if (curval > warning.max) { 1019 highlightWarning($(this), warning.warningmsg) 1020 } 1021 } 1022 if (warning.min) { 1023 if (curval < warning.min) { 1024 highlightWarning($(this), warning.warningmsg) 1025 } 1026 } 1027 } else { 1028 unhighlightWarning($(this)); 1029 validator.element(this); 1030 } 1031 });
1032 1033 1034 $('[data-vmnews=bw]').click(function (event) { 1035 event.preventDefault(); 1036 $("." + $(this).data('csstohide')).addClass("none"); 1037 $("." + $(this).data('csstoshow')).removeClass("none"); 1038 if ($(this).data('vmds') !== undefined) { 1039 if ($(this).data('vmds')) 1040 $(".vmds").show(); 1041 else 1042 $(".vmds").hide(); 1043 } 1044 if ($("." + $(this).data('csstoshow')).find('[data-vmfoto=1]').length > 0) { 1045 if ($("." + $(this).data('csstoshow')).find('[data-vmfoto=1]').find("input").is(":checked")) 1046 $("." + $(this).data('csstoshow') + "sub").removeClass("none"); 1047 else 1048 $("." + $(this).data('csstoshow') + "sub").addClass("none"); 1049 } 1050 return false; 1051 }); 1052 1053 $('[data-vmnews=cancel]').click(function (event) { 1054 event.preventDefault(); 1055 history.back(); 1056 return false; 1057 }); 1058 /* Set up download on Error*/ 1059 if ($('.form-group--file > input:hidden')) { 1060 var $files = $('.form-group--file > input:hidden'); 1061 var filesinfo = $files.data("files"); 1062 if (filesinfo) { 1063 for (var file in filesinfo) { 1064 addFileCtrl($(".form-group--addonFileList"), filesinfo[file]) 1065 } 1066 $files.val(JSON.stringify($files.data("files"))); 1067 } 1068 } 1069}); 1070 1071function openfieldset(fs) { } 1072 1073function fileUploaded(sender, args) { 1074 $(sender._element).closest('.form-field').find('[type=text]').val('1'); 1075 validator.element($(sender._element).closest('.form-field').find('[type=text]')[0]); 1076} 1077 1078function OnClientFileUploading(sender, args) { 1079 $telerik.$('.ruCancel').bind('click', function (e) { 1080 sender._cancelUpload(args.get_row()); 1081 sender.deleteFileInputAt(args.get_row()); 1082 }); 1083} 1084 1085function toggleAll(ctrl) { 1086 if ($(ctrl).closest('label').hasClass('is-checked')) { 1087 $(ctrl).closest('fieldset').find('.form-label.is-checked').click(); 1088 } else { 1089 $(ctrl).closest('fieldset').find('.form-label:not(.is-checked)').click(); 1090 } 1091} 1092 1093function isNullOrWhitespace(input) { 1094 if (typeof input === 'undefined' || input == null) 1095 return true; 1096} 1097 1098function stripTags(input) { 1099 var div = document.createElement("div"); 1100 div.innerHTML = input; 1101 return div.textContent || div.innerText || ""; 1102} 1103 1104$.validator.addMethod("countrestrict", function (value, element, options) { 1105 var $fields = $(element).closest("fieldset").find("input:checked"); 1106 return $fields.length <= options; 1107}, 1108 $.validator.format('Choose no more than 3.')); 1109 1110$.validator.addMethod("validateNullOrWhiteSpace", function (value, element) { 1111 return !isNullOrWhitespace(stripTags(value)); 1112}, $.validator.format((typeof customErrors !== "undefined" && customErrors.notEmpty) ? customErrors.notEmpty : "This field is required.")); 1113 1114$.validator.addMethod("validateNotNullForDD", function (value, element) { 1115 return (isNaN(value) && value.length > 0) || value > 0 1116}, $.validator.format((typeof customErrors !== "undefined" && customErrors.notValidValue) ? customErrors.notValidValue : "Invalid selection")); 1117 1118//Custom error messages for validation 1119//The message is defined through the "data-errormsg" attribute and the pattern through the "pattern" attribute in each input tag 1120jQuery.validator.addMethod("validation", function (value, element) { 1121 if (this.optional(element)) { 1122 return true; 1123 } 1124 var pattern = new RegExp($(element).attr("pattern"), 'gm'); 1125 if ($(element).is('textarea')) { 1126 return pattern.test(value.trim()); 1127 } 1128 // test for leading/trailing spaces 1129 if ($(element).is('input:text') && value.trim() != value) { 1130 return false; 1131 } 1132 return pattern.test(value); 1133}, function (params, element) { 1134 var $element = $(element); 1135 var errMsg = $element.attr("data-errormsg"); 1136 if ($element.is('input:text') && $element.val() != $element.val().trim()) { 1137 if (typeof customErrors !== "undefined" && customErrors.extraSpaces) errMsg = customErrors.extraSpaces; 1138 } 1139 return $.validator.format(errMsg); 1140}); 1141 1142 1143 //Redirect to the input with focus and autoscroll 1144function focusError(element) { 1145 var errorElement = $(element).attr("data-errorElement"); 1146 $("#" + errorElement).focus(); 1147 window.scrollBy(0, window.innerHeight / 3); 1148} 1149 1150$.validator.addMethod("require_from_group", function (value, element, options) { 1151 var maxLen = Number.MAX_SAFE_INTEGER || 9007199254740991; 1152 if (options[2] != undefined) { 1153 maxLen = options[2]; 1154 } 1155 var $fields = $(element).closest("fieldset").find("input" + options[1]), 1156 $fieldsFirst = $fields.eq(0), 1157 validator = $fieldsFirst.data("valid_req_grp") ? $fieldsFirst.data("valid_req_grp") : $.extend({}, this), 1158 isValid = function () { 1159 var len = $fields.filter(function () { 1160 return validator.elementValue(this); 1161 }).length; 1162 return len >= options[0] && len <= maxLen; 1163 } 1164 1165 // Store the cloned validator for future validation 1166 $fieldsFirst.data("valid_req_grp", validator); 1167 1168 // If element isn't being validated, run each require_from_group field's validation rules 1169 if (!$(element).data("being_validated")) { 1170 $fields.data("being_validated", true); 1171 $fields.each(function () { 1172 validator.element(this); 1173 }); 1174 $fields.data("being_validated", false); 1175 } 1176 return isValid(); 1177}, function (options, element) { 1178 var errMsg = (typeof customErrors !== "undefined" && customErrors.selectOne) ? customErrors.selectOne : "Select at least one"; 1179 if ($(element).closest("fieldset").find("input" + options[1]).filter(function () { return validator.elementValue(this); }).length != 0) { 1180 if (options[2] != undefined) { 1181 if (typeof customErrors !== "undefined" && customErrors.lessThan) errMsg = customErrors.lessThan.format(
1181options[2]); 1182 } 1183 } 1184 return $.validator.format(errMsg); 1185}) 1186 1187function unhighlightWarning(ctrl) { 1188 if (ctrl.parents().eq(2).is("fieldset")) { 1189 ctrl.parents().eq(2).removeClass("form-alert form-alert--error form-alert--withBg fieldset-error"); 1190 } else { 1191 ctrl.parent().removeClass("form-alert form-alert--error form-alert--withBg"); 1192 } 1193 if (ctrl.parents().eq(2).find(".form-alert").length > 0) { 1194 return (false); 1195 } else if (ctrl.parents().eq(2).is("fieldset") && ctrl.parents().eq(5).find(".form-alert").length > 0) { 1196 return (false); 1197 } else if (ctrl.parents().eq(2).is("fieldset")) { 1198 ctrl.parents().eq(4).removeClass("form-warning-inside"); 1199 } else { 1200 ctrl.parents().eq(2).removeClass("form-warning-inside"); 1201 } 1202 ctrl.closest('.form-field').find('label.formError').remove(); 1203 ctrl.closest('.form-field').find('label.formError').hide(); 1204} 1205 1206function highlightWarning(ctrl, warningmsg) { 1207 if (ctrl.parents().eq(2).is("fieldset")) { 1208 ctrl.parents().eq(2).addClass("form-alert form-alert--warning form-alert--withBg fieldset-warning"); 1209 } else { 1210 ctrl.parent().addClass("form-alert form-alert--warning form-alert--withBg"); 1211 } 1212 if (ctrl.parents().eq(2).is("fieldset")) { 1213 ctrl.parents().eq(3).addClass("form-warning-inside"); 1214 } else { 1215 ctrl.parents().eq(2).addClass("form-warning-inside"); 1216 } 1217 if (ctrl.closest('.form-field').find('label.formError').length == 0) { 1218 ctrl.after('<label class="formError">' + warningmsg + '</label></div>'); 1219 } 1220} 1221//Validating whole form with the id "form" 1222 1223jQuery.validator.setDefaults({ 1224 highlight: function (element, errorClass, validClass) { 1225 unhighlightWarning($(element)); 1226 if ($(element).parents().eq(2).is("fieldset")) { 1227 $(element).parents().eq(2).addClass("form-alert form-alert--error form-alert--withBg fieldset-error"); 1228 } else { 1229 $(element).parent().addClass("form-alert form-alert--error form-alert--withBg"); 1230 } 1231 if ($(element).parents().eq(2).is("fieldset")) { 1232 $(element).parents().eq(3).addClass("form-error-inside"); 1233 } else { 1234 $(element).parents().eq(2).addClass("form-error-inside"); 1235 } 1236 }, 1237 unhighlight: function (element, errorClass, validClass) { 1238 if ($(element).parents().eq(2).is("fieldset")) { 1239 $(element).parents().eq(2).removeClass("form-alert form-alert--error form-alert--withBg fieldset-error"); 1240 } else { 1241 $(element).parent().removeClass("form-alert form-alert--error form-alert--withBg"); 1242 } 1243 if ($(element).parents().eq(2).find(".form-alert").length > 0) { 1244 return (false); 1245 } else if ($(element).parents().eq(2).is("fieldset") && $(element).parents().eq(5).find(".form-alert").length > 0) { 1246 return (false); 1247 } else if ($(element).parents().eq(2).is("fieldset")) { 1248 $(element).parents().eq(4).removeClass("form-error-inside"); 1249 } else { 1250 $(element).parents().eq(2).removeClass("form-error-inside"); 1251 } 1252 }, 1253 errorPlacement: function (error, element) { 1254 var placement = $(element).data('error'); 1255 if (placement) { 1256 if (!$(placement).html()) { 1257 $(placement).append(error) 1258 } 1259 } else { 1260 element.parent().append(error); 1261 } 1262 } 1263}); 1264 1265//Ãffnungszeiten JS 1266 1267$(document).ready(ris_oz_init); 1268var id = -1; 1269var textsArray; 1270 1271function ris_oz_init() { 1272 if ($('[id$="vonzeit_ffoz"]')[0]) 1273 risoz_formatTimes(); 1274} 1275 1276function addDates(tgBtns) { 1277 var sZVon = $('[id$="vonzeit_ffoz"]').val(); 1278 var sZBis = $('[id$="biszeit_ffoz"]').val(); 1279 if (sZBis == "" || sZVon == "") { 1280 alert(textsArray.errNoTimes); 1281 return false; 1282 } 1283 var Mo = $("[id$=ffoz_0]")[0]; 1284 var Di = $("[id$=ffoz_1]")[0]; 1285 var Mi = $("[id$=ffoz_2]")[0]; 1286 var Do = $("[id$=ffoz_3]")[0]; 1287 var Fr = $("[id$=ffoz_4]")[0]; 1288 var Sa = $("[id$=ffoz_5]")[0]; 1289 var So = $("[id$=ffoz_6]")[0]; 1290 if (!(Mo.checked || Di.checked || Mi.checked || Do.checked || Fr.checked || Sa.checked || So.checked)) { 1291 alert(textsArray.errNoDay); 1292 return false; 1293 } 1294 deleteIds(Mo.value); 1295 deleteIds(Di.value); 1296 deleteIds(Mi.value); 1297 deleteIds(Do.value); 1298 deleteIds(Fr.value); 1299 deleteIds(Sa.value); 1300 deleteIds(So.value); 1301 var newTimes = ""; 1302 var ozHidden = $("[id$=ff_oz_hidden]")[0] 1303 var oldTimes = ozHidden.value; 1304 var sTimes = sZVon + ";" + sZBis + ";" 1305 newTimes += gethValueFromChk(Mo, "1", oldTimes, sTimes); 1306 newTimes += gethValueFromChk(Di, "2", oldTimes, sTimes); 1307 newTimes += gethValueFromChk(Mi, "3", oldTimes, sTimes); 1308 newTimes += gethValueFromChk(Do, "4", oldTimes, sTimes); 1309 newTimes += gethValueFromChk(Fr, "5", oldTimes, sTimes); 1310 newTimes += gethValueFromChk(Sa, "6", oldTimes, sTimes); 1311 newTimes += gethValueFromChk(So, "0", oldTimes, sTimes); 1312 ozHidden.value += newTimes; 1313 Mo.value = ""; 1314 Mo.checked = false; 1315 Di.value = ""; 1316 Di.checked = false; 1317 Mi.value = ""; 1318 Mi.checked = false; 1319 Do.value = ""; 1320 Do.checked = false; 1321 Fr.value = ""; 1322 Fr.checked = false; 1323 Sa.value = ""; 1324 Sa.checked = false; 1325 So.value = ""; 1326 So.checked = false; 1327 $('[id$="vonzeit_ffoz"]').val(''); 1328 $('[id$="biszeit_ffoz"]').val(''); 1329 risoz_formatTimes(); 1330 if (tgBtns) toggleSaveBtns(); 1331} 1332 1333function gethValueFromChk(chk, wd, oldTimes, sTimes) { 1334 if (chk.checked && oldTimes.indexOf(";" + sTimes + wd) == -1) { 1335 var newTime = "|"; 1336 if (chk.value != "on" && chk.value != "") { 1337 newTime += chk.value; 1338 } 1339 else { 1340 newTime += id; 1341 id--; 1342 } 1343 newTime += ";" + sTimes + wd; 1344 return newTime; 1345 } 1346 return ""; 1347} 1348 1349function risoz_formatTimes() { 1350 var arrValues = getTimeArray() 1351 if (arrValues.length > 0) { 1352 var displayHtml = "<table class=\"ris_table\"><caption>" + textsArray.zeitenSummary + "'</caption><tbody>"; 1353 displayHtml += "<tr class=\"tableheaderrow even\"><th scope=\"col\" data-label=\"ï³\">" + textsArray.hdWeekday + "</th><th scope=\"col\" data-label=\"ï\">" + textsArray.hdVon + "</th><th scope=\"col\" data-label=\"ï\">" + textsArray.hdBis + "</th><th scope=\"col\" data-label=\"ï \">" + textsArray.hdAktionen + "</th></tr>" 1354 for (var vals in arrValues) { 1355 var bOverlap = false; 1356 if (hasOverlap(arrValues, vals)) { 1357 bOverlap = true; 1358 } 1359 displayHtml += "<tr><td data-label=\"ï³\">" + (bOverlap ? "<span title='" + textsArray.overlapMsg + "'> ! </span>" : "") + formatWeekdayList(arrValues[vals].weekday) + "</td><td data-label=\"ï\">" + arrValues[vals].timeFrom + "</td><td data-label=\"ï\">" + arrValues[vals].timeTo + "</td><td data-label=\"ï \"><a href='javascript:editIds(\"" + arrValues[vals].id.join(',') + "\")'><span class='fa fa-edit'> </span></a><a href='javascript:deleteIds(\"" + arrValues[vals].id.join(',') + "\")'><span class='fa fa-times'> </span></a></td></tr>" 1360 } 1361 displayHtml += "</tbody></table>"
1362 $("[id$=DisplayTimes]")[0].innerHTML = displayHtml; 1363 } else { 1364 $("[id$=DisplayTimes]")[0].innerHTML = ""; 1365 } 1366} 1367 1368function formatWeekdayList(weekdaylist) { 1369 var wdString = ""; 1370 for (var i in weekdaylist.sort(sortWd)) { 1371 wdString += getDayName(weekdaylist[i]) + " "; 1372 } 1373 return wdString; 1374} 1375 1376function hasOverlap(arrValues, curval) { 1377 if (arrValues.length > 1) { 1378 for (var vals in arrValues) { 1379 if (vals != curval) { 1380 for (var wds in arrValues[curval].weekday) { 1381 for (var vwds in arrValues[vals].weekday) { 1382 if (arrValues[vals].weekday[vwds] == arrValues[curval].weekday[wds]) { 1383 if (arrValues[vals].timeFrom < arrValues[curval].timeFrom && arrValues[vals].timeTo > arrValues[curval].timeFrom 1384 || arrValues[vals].timeFrom < arrValues[curval].timeTo && arrValues[vals].timeTo > arrValues[curval].timeTo) { 1385 return true; 1386 } 1387 continue; 1388 } 1389 } 1390 } 1391 } 1392 } 1393 } 1394 return false; 1395} 1396 1397function editIds(ids) { 1398 var arrIds = ids.split(","); 1399 $("[id=saveBtns]").show(); 1400 $("[id=addBtn]").hide(); 1401 var arrTimes = getBasicArray(); 1402 for (var i = 0; i < 7; i++) { 1403 checkWeekday(i, 0, "") 1404 } 1405 for (var i in arrTimes) { 1406 var foundId = false; 1407 for (var j in arrIds) { 1408 if (arrTimes[i].id == arrIds[j]) { 1409 foundId = true; 1410 continue; 1411 } 1412 } 1413 if (foundId) { 1414 $('[id$="vonzeit_ffoz"]').val(arrTimes[i].timeFrom); 1415 $('[id$="biszeit_ffoz"]').val(arrTimes[i].timeTo); 1416 checkWeekday(arrTimes[i].weekdayNo, 1, arrTimes[i].id) 1417 } 1418 } 1419} 1420 1421function checkWeekday(weekday, chk, val) { 1422 1423 switch (weekday.toString()) { 1424 case "0": 1425 $("[id$=ffoz_6]")[0].checked = chk; 1426 $("[id$=ffoz_6]")[0].value = val; 1427 break; 1428 case "1": 1429 $("[id$=ffoz_0]")[0].checked = chk; 1430 $("[id$=ffoz_0]")[0].value = val; 1431 break; 1432 case "2": 1433 $("[id$=ffoz_1]")[0].checked = chk; 1434 $("[id$=ffoz_1]")[0].value = val; 1435 break; 1436 case "3": 1437 $("[id$=ffoz_2]")[0].checked = chk 1438 $("[id$=ffoz_2]")[0].value = val; 1439 break; 1440 case "4": 1441 $("[id$=ffoz_3]")[0].checked = chk 1442 $("[id$=ffoz_3]")[0].value = val; 1443 break; 1444 case "5": 1445 $("[id$=ffoz_4]")[0].checked = chk 1446 $("[id$=ffoz_4]")[0].value = val; 1447 break; 1448 case "6": 1449 $("[id$=ffoz_5]")[0].checked = chk; 1450 $("[id$=ffoz_5]")[0].value = val; 1451 break; 1452 } 1453} 1454 1455function getBasicArray() { 1456 var arrBasic = []; 1457 var arrValues = $("[id$=ff_oz_hidden]")[0].value.split("|"); 1458 for (var vals in arrValues) { 1459 if (arrValues[vals] != "") { 1460 var tmp = arrValues[vals].split(";"); 1461 arrBasic.push({ 1462 id: tmp[0], 1463 timeFrom: tmp[1], 1464 timeTo: tmp[2], 1465 weekdayNo: tmp[3] 1466 }) 1467 } 1468 } 1469 return arrBasic; 1470} 1471 1472function deleteIds(ids) { 1473 if (ids == "0" || id == "") { 1474 return; 1475 } 1476 var arrIds = ids.toString().split(","); 1477 var arrValues = $("[id$=ff_oz_hidden]")[0].value.split("|"); 1478 for (var todelid in arrIds) { 1479 for (var vals in arrValues) { 1480 if (arrValues[vals]) { 1481 var tmp = arrValues[vals].split(";"); 1482 if (tmp[0] == arrIds[todelid]) { 1483 arrValues.splice(vals, 1); 1484 continue; 1485 } 1486 } 1487 } 1488 } 1489 $("[id$=ff_oz_hidden]")[0].value = arrValues.join("|"); 1490 risoz_formatTimes(); 1491} 1492 1493function toggleSaveBtns() { 1494 for (var i = 0; i < 7; i++) { 1495 checkWeekday(i, 0, "0") 1496 } 1497 $("[id=saveBtns]").toggle(); 1498 $("[id=addBtn]").toggle(); 1499} 1500 1501function getDayName(weekday) { 1502 switch (weekday) { 1503 case "0": 1504 return textsArray.So; 1505 case "1": 1506 return textsArray.Mo; 1507 case "2": 1508 return textsArray.Di; 1509 case "3": 1510 return textsArray.Mi; 1511 case "4": 1512 return textsArray.Do; 1513 case "5": 1514 return textsArray.Fr; 1515 case "6": 1516 return textsArray.Sa; 1517 } 1518} 1519 1520function risform_addms(ctrl) { 1521 var $ctrl = $(ctrl);
1522 var selval = parseInt($ctrl.siblings('select').val()); 1523 var msArr; 1524 if ($ctrl.siblings('input').val() == '') { 1525 msArr = new Array(); 1526 } else { 1527 msArr = JSON.parse($ctrl.siblings('input').val()); 1528 } 1529 if (selval > 0 && $.inArray(selval, msArr) === -1) { 1530 msArr.push(selval); 1531 $ctrl.siblings('input').val(JSON.stringify(msArr)); 1532 } 1533 risform_showms($ctrl.parent()); 1534} 1535 1536function risform_removems(ctrl, onr) { 1537 var $ctrl = $(ctrl).closest('div'); 1538 var msArr; 1539 var $input = $ctrl.children('input:hidden'); 1540 if ($input.val() == '') { 1541 msArr = new Array(); 1542 } else { 1543 msArr = JSON.parse($input.val()); 1544 } 1545 msArr.splice($.inArray(onr, msArr), 1); 1546 $input.val(JSON.stringify(msArr)); 1547 risform_showms($ctrl); 1548} 1549 1550function risform_showms(ctrl) { 1551 var $ctrl = $(ctrl) 1552 $ctrl.children('ul').remove(); 1553 var msArr; 1554 if ($ctrl.children('input').val() == '') { 1555 msArr = new Array(); 1556 } else { 1557 msArr = JSON.parse($ctrl.children('input').val()); 1558 } 1559 var ddopts = $ctrl.children('select')[0].options; 1560 var list = $('<ul class="form-ms-list"/>').appendTo($ctrl); 1561 1562 for (i = 0; i < msArr.length; i++) { 1563 for (j = 0; j < ddopts.length; j++) { 1564 if (ddopts[j].value == msArr[i]) { 1565 list.append('<li>' + ddopts[j].text + ' <span class="fa fa-times risms-remove" onclick="risform_removems(this, ' + msArr[i] + ')"></span></li>'); 1566 break; 1567 } 1568 } 1569 } 1570} 1571 1572function sortEx(ex1, ex2) { 1573 1574 if (ex1.date > ex2.date) { 1575 return 1; 1576 } else if (ex1.date < ex2.date) { 1577 return -1; 1578 } 1579 if (ex1.timeFrom > ex2.timeFrom) { 1580 return 1; 1581 } else if (ex1.timeFrom < ex2.timeFrom) { 1582 return -1; 1583 } 1584 if ( ex1.timeTo < ex2.timeTo) { 1585 return -1; 1586 } else if (ex1.timeTo > ex2.timeTo) { 1587 return 1 1588 } else { 1589 return 0; 1590 } 1591} 1592 1593function getTimeArray() { 1594 var arrValues = $("[id$=ff_oz_hidden]")[0].value.split("|"); 1595 var arrObjValues = []; 1596 if (arrValues) 1597 for (var vals in arrValues) { 1598 if (arrValues[vals] != "") { 1599 var tmp = arrValues[vals].split(";"); 1600 var toAdd = true; 1601 for (var i in arrObjValues) { 1602 if (arrObjValues[i].timeFrom == tmp[1] 1603 && arrObjValues[i].timeTo == tmp[2]) { 1604 var toaddwd = true 1605 for (var days in arrObjValues[i].weekday) { 1606 if (arrObjValues[i].weekday[days] == tmp[3]) { 1607 toaddwd = false; 1608 } 1609 } 1610 if (toaddwd) { 1611 arrObjValues[i].weekday.push(tmp[3]); 1612 arrObjValues[i].id.push(tmp[0]); 1613 if (arrObjValues[i].weekdayNo > tmp[3]) 1614 arrObjValues[i].weekdayNo = tmp[3] 1615 } 1616 toAdd = false 1617 } 1618 } 1619 if (toAdd) { 1620 var wd = [] 1621 wd.push(tmp[3]); 1622 var id = [] 1623 id.push(tmp[0]); 1624 arrObjValues.push({ 1625 id: id, 1626 timeFrom: tmp[1], 1627 timeTo: tmp[2], 1628 weekday: wd, 1629 weekdayNo: tmp[3] 1630 }) 1631 } 1632 } 1633 } 1634 return arrObjValues.sort(sortF); 1635} 1636 1637function sortWd(wd1, wd2) { 1638 return ((parseInt(wd1) + 6) % 7) - ((parseInt(wd2) + 6) % 7) 1639} 1640 1641function RemoveSelectButton(sender, args) { 1642 $(sender._element).closest('.form-field').removeClass('form-alert form-alert--error form-alert--withBg fieldset-error') 1643 $(sender._element).closest('.form-field').find('.upload-error').remove(); 1644 $(sender._element).closest('.form-field').find('.formError').remove() 1645 var e = $(sender._element).find('.rcuFileSelect'); 1646 if (e) { 1647 e.hide(); 1648 } 1649} 1650 1651function GetSelectButton(sender, args) { 1652 $(sender._element).closest('.form-field').removeClass('form-alert form-alert--error form-alert--withBg') 1653 $(sender._element).closest('.form-grid').removeClass("form-error-inside"); 1654 $(sender._element).closest('.form-field').find('.upload-error').remove(); 1655 $(sender._element).closest('.form-field').find('.formError').remove() 1656 var e = $(sender._element).find('.rcuFileSelect'); 1657 if (e) { 1658 e.show(); 1659 } 1660} 1661 1662function OnClientValidationFailed(sender, args) { 1663 var e = $(sender._element).find('.rcuFileSelect'); 1664 if (e) { 1665 e.hide(); 1666 } 1667 var errorMessage = args.get_message(); 1668 $(sender._element).closest('.form-field').addClass('form-alert form-alert--error form-alert--withBg') 1669 $(sender._element).closest('.form-grid').addClass("form-error-inside"); 1670 $(sender._element).append('<div class="upload-error clear_both">') 1671 $(sender._element).append('<label class="formError">' + errorMessage + '</label></div>'); 1672 $(sender._element).closest('.form-field').find('[type=text]').val(''); 1673} 1674 1675function sortF(ob1, ob2) { 1676 if (((parseInt(ob1.weekdayNo) + 6) % 7) > ((parseInt(ob2.weekdayNo) + 6) % 7)) { 1677 return 1; 1678 } else if (((parseInt(ob1.weekdayNo) + 6) % 7) < ((parseInt(ob2.weekdayNo) + 6) % 7)) { 1679 return -1; 1680 } 1681 if (ob1.timeFrom > ob2.timeFrom) { 1682 return 1; 1683 } else if (ob1.timeFrom < ob2.timeFrom) { 1684 return -1; 1685 } 1686 if ( ob1.timeTo < ob2.timeTo) { 1687 return -1; 1688 } else if (ob1.timeTo > ob2.timeTo) { 1689 return 1 1690 } else { 1691 return 0; 1692 } 1693} 1694 1695function RaiseDateRecurrence() { 1696 $('[data-timeseries=text]').each(function () { 1697 rists_formatTimes(this); 1698 });
1699 $('[data-timeseries=text]').each(function () { 1700 validator.element(this); 1701 }); 1702} 1703 1704function rists_formatTimes(ctrl) { 1705 1706 var times = ""; 1707 $ctrl = $(ctrl); 1708 if ($ctrl.val() == "[]") $ctrl.val(""); 1709 var allday = $(ctrl).data().allday; 1710 var uhr = $ctrl.data().uhr; 1711 var jsTime = $.parseJSON($ctrl.val()); 1712 if (jsTime != null && jsTime.length > 0) { 1713 times = "<ul>"; 1714 $.each(jsTime.slice(0, 9), function () { 1715 dtStart = new Date(this.Start); 1716 dtEnd = new Date(this.End); 1717 times += "<li class=\"termindate\">" + dtStart.toLocaleDateString(); 1718 if (dtStart.getHours() == 0 && dtStart.getMinutes() == 0 && ((dtEnd.getHours() == 23 && dtEnd.getMinutes() == 59) || (dtEnd.getHours() == 0 && dtEnd.getMinutes() == 0))) { 1719 times += "<span class=\"terminallday\">, " + allday + "</span>"; 1720 } 1721 else if (dtEnd.getHours() == 23 && dtEnd.getMinutes() == 59) 1722 times += '<span class=\'terminstartzeit\'>, ' + dtStart.toTimeString().substring(0, 5) + ' ' + uhr + '</span>'; 1723 else 1724 times += '<span class=\'terminzeit\'>, ' + dtStart.toTimeString().substring(0, 5) + ' ' + uhr + ' - ' + dtEnd.toTimeString().substring(0, 5) + ' ' + uhr + '</span>'; 1725 times += "</li>" 1726 }); 1727 if (jsTime.length > 9) { 1728 times += "<li class=\"terminmore\">...</li>" 1729 } 1730 times += "</ul>" 1731 } 1732 $ctrl.siblings('.form-timeserie-list').html(times); 1733} 1734 1735function risform_openTerminserieWithTime(ctrl, gnr, sprache, stylesheet) { 1736 var edittermin = "" 1737 if (ctrl.siblings('[data-timeseries]').val() != "") { 1738 edittermin = "readopener"; 1739 } 1740 opener = ctrl.siblings('[data-timeseries]')[0].id; 1741 var urlstr = new String(envurl + 'system/web/terminserie.aspx?cmd=open&style=' + stylesheet + '&edittermin=' + edittermin + '&gnr=' + gnr + '&sprache=' + sprache + '&opener=' + opener + '&useJquery=true'); 1742 urlstr = urlstr + '&typ=time'; 1743 urlstr = urlstr + '&callback=RaiseDateRecurrence'; 1744 urlstr = urlstr + '&timefrom=00:00:00&timeto=23:59:59&usejson=true' 1745 var pickerWin = window.open(urlstr, "TerminserieWin", "height=480,width=850,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=yes"); 1746 if (pickerWin) { 1747 pickerWin.focus(); 1748 } 1749 else { 1750 alert("Please turn off your PopUp blocking software"); 1751 return; 1752 } 1753}; 1754 1755function ShowControls(sender, start, end, affectedCtrlClass) { 1756 var ctrls = $('.' + affectedCtrlClass).parent(); 1757 if (ctrls) { 1758 for (var i = start; i <= end; i++) { 1759 if (ctrls.length - 1 >= i) { 1760 var obj = $(ctrls[i]); 1761 if (obj != null && $(obj).hasClass('none')) { 1762 $(obj).removeClass('none'); 1763 if (i >= end) { 1764 $(sender).closest('.form-grid-cell').addClass('none') 1765 } 1766 return; 1767 } 1768 } 1769 } 1770 } 1771} 1772 1773function UpdateThemeDD(sender, json, ddCssToFill, zerovalue) { 1774 var cbo = $(sender) ? $(sender)[0] : null; 1775 var optionDD = $("." + ddCssToFill).children('select') ? $("." + ddCssToFill).children('select')[0] : null; 1776 var selected = -1; 1777 if (cbo != null && optionDD != null && json != null) { 1778 optionDD.options.length = 0; 1779 optionDD.options.add(new Option(zerovalue, 0)); 1780 for (i = 0; i < cbo.length; i++) { if (cbo.options[i].selected) selected = i }; 1781 if ((selected != -1) && (cbo.options[selected].value != -1) && (cbo.options[selected].value != 0)) { 1782 $.each(json, function (i, el) { 1783 if (el.art == cbo.options[selected].value) { 1784 //var add = true; 1785 //var oval = el.bez.split('-'); 1786 //if (oval.length > 1) { 1787 // for (var j = 0; j < oval.length; j++) { 1788 // if (oval[j].indexOf(" ") != 0) { 1789 // add = false; 1790 // } 1791 // } 1792 //} 1793 optionDD.options.add(new Option(el.bez, el.thema)) 1794 } 1795 }); 1796 } 1797 if (optionDD.options.length > 1) { 1798 optionDD.disabled = false; 1799 } 1800 else { 1801 optionDD.disabled = true; 1802 } 1803 $("." + ddCssToFill + "rel").parent().addClass('none'); 1804 } 1805} 1806 1807function FillSubDD(sender, json, ddCssToFill) { 1808 var selectedValue = $(sender).val(); 1809 var subsel = $(sender).closest(".form-grid-cell").find("~ .form-grid-cell ." + ddCssToFill).first().children('select'); 1810 if (subsel.length == 0) 1811 subsel = $(sender).closest(".form-grid").find("~ .form-grid").find("." + ddCssToFill).first().children('select'); 1812 if (subsel.length > 0) { 1813 var selDD = $(subsel)[0]; 1814 if (selDD) { 1815 selDD.options.length = 0; 1816 if (selectedValue != "" && selectedValue != "0") { 1817 $.each(json, function (i, el) { 1818 if (el.parentOnr == "0" || el.parentOnr == selectedValue) { 1819 selDD.options.add(new Option(el.bez, el.onr)) 1820 } 1821 }); 1822 } 1823 if (selDD.options.length > 1) 1824 $(subsel).closest(".form-grid-cell").removeClass('none'); 1825 else 1826 $(subsel).closest(".form-grid-cell").addClass('none'); 1827 } 1828 $(subsel).trigger('change'); 1829 } 1830} 1831 1832/* MAPS FUNCTIONS */ 1833var geoSuccess = function (position) { 1834 var pos = { 1835 lat: position.coords.latitude, 1836 lng: position.coords.longitude 1837 }; 1838 risForm_verortung_setPos(pos); 1839}; 1840 1841var geoError = function (position) { 1842 1843}; 1844 1845var marker; 1846 1847function risForm_verortung_showMap() { 1848 navigator.geolocation.getCurrentPosition(geoSuccess, geoError); 1849} 1850 1851function risForm_verortung_setPos(pos) { 1852 $("[id$='lat_ffverortung']").val(pos.lat); 1853 $("[id$='long_ffverortung']").val(pos.lng); 1854 if (typeof google !== 'undefined') { 1855 marker = new google.maps.Marker({ 1856 position: pos, 1857 map: mf.map, 1858 draggable: true, 1859 }); 1860 mf.map.panTo(pos); 1861 google.maps.event.addListener(marker, 'dragend', function (marker) { 1862 var latLng = marker.latLng; 1863 currentLatitude = latLng.lat(); 1864 currentLongitude = latLng.lng(); 1865 $("[id$='lat_ffverortung']").val(currentLatitude); 1866 $("[id$='long_ffverortung']").val(currentLongitude); 1867 }); 1868 } else { 1869 mf.updateLatLng(pos); 1870 } 1871} 1872 1873window.risForm_verortung_Init = function () { 1874 $("#risform_loadmap").closest('.form-grid-cell').hide(); 1875 $("#risform_resetmap").closest('.form-grid-cell').show(); 1876 $("[data-verortung-hinweis]").closest('.form-grid-cell').show(); 1877 window.fillOptions(); 1878 $("[id$='map_ffverortung']").each(function () { 1879 $(this).closest('.form-grid-cell').show(); 1880 mf = new mapfinder(); 1881 mf.initMap(this.id, mf_options); 1882 risForm_verortung_showMap(); 1883 if (typeof google !== 'undefined') { 1884 google.maps.event.addListener(mf.map, "click", function (e) { 1885 latLng = e.latLng; 1886 window.removeMarker(); 1887 risForm_verortung_setPos(latLng); 1888 }); 1889 } 1890 });
1891} 1892 1893window.removeMarker = function () { 1894 if (typeof google !== 'undefined') { 1895 if (marker && marker.setMap) { 1896 marker.setMap(null); 1897 } 1898 } else { 1899 mf.removeMarker(); 1900 } 1901 $("[id$='lat_ffverortung']").val(""); 1902 $("[id$='long_ffverortung']").val(""); 1903} 1904 1905window.loadGoogleMaps = function (ApiUrl, loaderUrl) { 1906 if (gMapsLoaded) return window.gMapsCallback(); 1907 loadScript(ApiUrl + '&callback=gMapsCallback'); 1908 loadScript(loaderUrl); 1909} 1910 1911function loadScript(scriptUrl) { 1912 var script_tag = document.createElement('script'); 1913 script_tag.setAttribute("type", "text/javascript"); 1914 script_tag.setAttribute("src", scriptUrl); 1915 (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag); 1916} 1917 1918var gMapsLoaded = false; 1919 1920window.gMapsCallback = function () { 1921 gMapsLoaded = true; 1922 $(window).trigger('gMapsLoaded'); 1923} 1924 1925String.prototype.format = function () { 1926 var s = this, 1927 i = arguments.length; 1928 1929 while (i--) { 1930 s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]); 1931 } 1932 return s; 1933}; 1934/* MAPS FUNCTIONS END */ 1935
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.