| @@ 13-729 (lines=717) @@ | ||
| 10 | * |
|
| 11 | * The TYPO3 project - inspiring people to share! |
|
| 12 | */ |
|
| 13 | $(document).ready(function() { |
|
| 14 | jQuery('#new-document-form').trigger('reset'); |
|
| 15 | documentListConfirmDialog('#confirmDiscard'); |
|
| 16 | documentListConfirmDialog('#confirmPublish'); |
|
| 17 | documentListConfirmDialog('#confirmUpdate'); |
|
| 18 | documentListConfirmDialog('#confirmActivate'); |
|
| 19 | documentListConfirmDialog('#confirmInactivate'); |
|
| 20 | documentListConfirmDialog('#confirmRestore'); |
|
| 21 | documentListConfirmDialog('#confirmDelete'); |
|
| 22 | datepicker(); |
|
| 23 | jQuery('[data-toggle="tooltip"]').tooltip(); |
|
| 24 | var $disableForm = jQuery('form[data-disabled]').attr('data-disabled'); |
|
| 25 | if ($disableForm) { |
|
| 26 | jQuery('.input-field').each(function() { |
|
| 27 | jQuery(this).attr('disabled', 'disabled'); |
|
| 28 | }); |
|
| 29 | jQuery('.rem_file_group').each(function() { |
|
| 30 | jQuery(this).attr('disabled', 'disabled'); |
|
| 31 | }); |
|
| 32 | jQuery('.add_file_group').each(function() { |
|
| 33 | jQuery(this).attr('disabled', 'disabled'); |
|
| 34 | }); |
|
| 35 | jQuery('.input_file_upload').each(function() { |
|
| 36 | jQuery(this).attr('disabled', 'disabled'); |
|
| 37 | }); |
|
| 38 | jQuery('.add_field').each(function() { |
|
| 39 | jQuery(this).attr('disabled', 'disabled'); |
|
| 40 | }); |
|
| 41 | jQuery('.add_group').each(function() { |
|
| 42 | jQuery(this).attr('disabled', 'disabled'); |
|
| 43 | }); |
|
| 44 | jQuery('.rem_field').each(function() { |
|
| 45 | jQuery(this).attr('disabled', 'disabled'); |
|
| 46 | }); |
|
| 47 | jQuery('.rem_group').each(function() { |
|
| 48 | jQuery(this).attr('disabled', 'disabled'); |
|
| 49 | }); |
|
| 50 | jQuery('.fill_out_service_urn').each(function() { |
|
| 51 | jQuery(this).attr('disabled', 'disabled'); |
|
| 52 | }); |
|
| 53 | } |
|
| 54 | buttonFillOutServiceUrn(); |
|
| 55 | jQuery(".tx-dpf").on("click", ".rem_group", function() { |
|
| 56 | jQuery(this).parents('fieldset').fadeOut(300, function() { |
|
| 57 | jQuery(this).remove(); |
|
| 58 | }); |
|
| 59 | return false; |
|
| 60 | }); |
|
| 61 | jQuery(".tx-dpf").on("click", ".rem_file_group", deleteFile); |
|
| 62 | jQuery(".tx-dpf").on("click", ".rem_secondary_upload", function() { |
|
| 63 | var dataIndex = jQuery(this).data("index"); |
|
| 64 | jQuery(this).parents('.fs_file_group').fadeOut(300, function() { |
|
| 65 | jQuery(this).remove(); |
|
| 66 | }); |
|
| 67 | return false; |
|
| 68 | }); |
|
| 69 | jQuery(".tx-dpf").on("click", ".rem_field", function() { |
|
| 70 | var dataIndex = jQuery(this).data("index"); |
|
| 71 | var dataField = jQuery(this).data("field"); |
|
| 72 | jQuery(this).parents('.form-group').fadeOut(300, function() { |
|
| 73 | jQuery(this).remove(); |
|
| 74 | }); |
|
| 75 | return false; |
|
| 76 | }); |
|
| 77 | // Add metadata group |
|
| 78 | jQuery(".tx-dpf").on("click", ".add_group", addGroup); |
|
| 79 | jQuery(".tx-dpf").on("click", ".add_file_group", addGroup); |
|
| 80 | jQuery(".tx-dpf").on("click", ".add_field", addField); |
|
| 81 | jQuery(".tx-dpf").on("click", ".fill_out_service_urn", fillOutServiceUrn); |
|
| 82 | jQuery(".tx-dpf").on("keyup", "input.urn", buttonFillOutServiceUrn); |
|
| 83 | jQuery(".tx-dpf").on("click", "#next", continuousScroll); |
|
| 84 | jQuery(".form-submit").on("click", "#save", validateFormAndSave); |
|
| 85 | jQuery(".form-submit").on("click", "#validate", validateFormOnly); |
|
| 86 | ||
| 87 | // hide 'more results' link |
|
| 88 | var countResults = $('#search-results :not(thead) tr').length; |
|
| 89 | var resultCount = $('#next').data('resultCount'); |
|
| 90 | ||
| 91 | if (countResults < resultCount) { |
|
| 92 | jQuery("#next").hide(); |
|
| 93 | } |
|
| 94 | ||
| 95 | addRemoveFileButton(); |
|
| 96 | ||
| 97 | previousNextFormPage(); |
|
| 98 | ||
| 99 | var gnd = jQuery('.gnd'); |
|
| 100 | if(gnd.length > 0) { |
|
| 101 | gnd.each(function() { |
|
| 102 | setGndAutocomplete(jQuery(this).data("field"), jQuery(this).data("groupindex")); |
|
| 103 | }); |
|
| 104 | } |
|
| 105 | ||
| 106 | inputWithOptions(); |
|
| 107 | ||
| 108 | }); |
|
| 109 | ||
| 110 | var validateFormAndSave = function() { |
|
| 111 | jQuery("#validDocument").val("0"); |
|
| 112 | if (validateForm()) { |
|
| 113 | jQuery("#validDocument").val("1"); |
|
| 114 | ||
| 115 | jQuery("#new-document-form #save").prop("disabled", true); |
|
| 116 | ||
| 117 | jQuery('#new-document-form').submit(); |
|
| 118 | ||
| 119 | return true; |
|
| 120 | } |
|
| 121 | return false; |
|
| 122 | } |
|
| 123 | var validateFormOnly = function() { |
|
| 124 | if (validateForm()) { |
|
| 125 | showFormSuccess(); |
|
| 126 | } |
|
| 127 | return false; |
|
| 128 | } |
|
| 129 | var validateForm = function() { |
|
| 130 | var error = false; |
|
| 131 | jQuery('span.mandatory-error').remove(); |
|
| 132 | jQuery('div.alert').remove(); |
|
| 133 | jQuery('.tx-dpf-tabs li a').each(function() { |
|
| 134 | jQuery(this).removeClass('mandatory-error'); |
|
| 135 | }); |
|
| 136 | // check mandatory groups |
|
| 137 | jQuery('fieldset[data-mandatory=1]').each(function() { |
|
| 138 | var fieldset = jQuery(this); |
|
| 139 | if (hasMandatoryInputs(fieldset)) { |
|
| 140 | if (checkMandatoryInputs(fieldset)) { |
|
| 141 | jQuery('<div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-warning-sign pull-right"></span>' + form_error_msg_group_mandatory + '</div>').insertAfter(fieldset.find('legend').last()); |
|
| 142 | showFormError(); |
|
| 143 | error = true; |
|
| 144 | markPage(fieldset, true); |
|
| 145 | } |
|
| 146 | } else { |
|
| 147 | if (checkFilledInputs(fieldset)) { |
|
| 148 | jQuery('<div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-warning-sign pull-right"></span>' + form_error_msg_group_one_required + '</div>').insertAfter(fieldset.find('legend').last()); |
|
| 149 | showFormError(); |
|
| 150 | error = true; |
|
| 151 | markPage(fieldset, true); |
|
| 152 | error = true; |
|
| 153 | } |
|
| 154 | } |
|
| 155 | }); |
|
| 156 | jQuery('fieldset[id=primary_file]').each(function() { |
|
| 157 | var fieldset = jQuery(this); |
|
| 158 | if (checkPrimaryFile(fieldset)) { |
|
| 159 | jQuery('<div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-warning-sign pull-right"></span>' + form_error_msg_group_mandatory + '</div>').insertBefore(fieldset.find('legend').last()); |
|
| 160 | showFormError(); |
|
| 161 | error = true; |
|
| 162 | markPage(fieldset, true); |
|
| 163 | } |
|
| 164 | }); |
|
| 165 | // check non mandatory groups |
|
| 166 | jQuery('fieldset[data-mandatory=""]').each(function() { |
|
| 167 | var fieldset = jQuery(this); |
|
| 168 | var filledInputs = 0; |
|
| 169 | jQuery(this).find('.input-field').each(function() { |
|
| 170 | if (jQuery(this).val() && jQuery(this).attr('data-default') != '1') { |
|
| 171 | filledInputs++; |
|
| 172 | } |
|
| 173 | jQuery(this).removeClass('mandatory-error'); |
|
| 174 | }); |
|
| 175 | // if there are fields with a value then mandatory fields |
|
| 176 | // are relevant. |
|
| 177 | if (filledInputs) { |
|
| 178 | if (checkMandatoryInputs(fieldset)) { |
|
| 179 | jQuery('<div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-warning-sign pull-right"></span>' + form_error_msg_group_mandatory + '</div>').insertAfter(fieldset.find('legend').last()); |
|
| 180 | showFormError(); |
|
| 181 | markPage(fieldset, true); |
|
| 182 | error = true; |
|
| 183 | } |
|
| 184 | } |
|
| 185 | }); |
|
| 186 | jQuery('fieldset').each(function() { |
|
| 187 | var fieldset = jQuery(this); |
|
| 188 | fieldset.find('.input-field').each(function() { |
|
| 189 | jQuery(this).removeClass('invalid-error'); |
|
| 190 | var validation = jQuery(this).attr('data-regexp'); |
|
| 191 | if (jQuery(this).val() && jQuery(this).val().length > 0 && validation && validation.length > 0) { |
|
| 192 | try { |
|
| 193 | var regexp = new RegExp(validation); |
|
| 194 | var res = jQuery(this).val().match(regexp); |
|
| 195 | if (!(res && res.length == 1 && res[0] == jQuery(this).val())) { |
|
| 196 | jQuery('<div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-warning-sign pull-right"></span>' + form_error_msg_field_invalid + ': ' + jQuery(this).attr('data-label') + '</div>').insertAfter(fieldset.find('legend').last()); |
|
| 197 | jQuery(this).addClass('invalid-error'); |
|
| 198 | showFormError(); |
|
| 199 | markPage(fieldset, true); |
|
| 200 | error = true; |
|
| 201 | } |
|
| 202 | } catch (err) { |
|
| 203 | jQuery('<div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-warning-sign pull-right"></span>' + form_error_msg_field_invalid + ': ' + jQuery(this).attr('data-label') + '</div>').insertAfter(fieldset.find('legend').last()); |
|
| 204 | jQuery(this).addClass('invalid-error'); |
|
| 205 | showFormError(); |
|
| 206 | markPage(fieldset, true); |
|
| 207 | error = true; |
|
| 208 | } |
|
| 209 | } else { |
|
| 210 | var validateDate = jQuery(this).attr('data-datatype') == 'DATE'; |
|
| 211 | if (jQuery(this).val() && jQuery(this).val().length > 0 && validateDate && !isDate(jQuery(this).val())) { |
|
| 212 | jQuery('<div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-warning-sign pull-right"></span>' + form_error_msg_field_invalid + ': ' + jQuery(this).attr('data-label') + '</div>').insertAfter(fieldset.find('legend').last()); |
|
| 213 | jQuery(this).addClass('invalid-error'); |
|
| 214 | showFormError(); |
|
| 215 | markPage(fieldset, true); |
|
| 216 | error = true; |
|
| 217 | } |
|
| 218 | } |
|
| 219 | ||
| 220 | var maxLength = jQuery(this).attr('data-maxlength'); |
|
| 221 | if (maxLength && maxLength > 0) { |
|
| 222 | if (jQuery(this).val().length > maxLength) { |
|
| 223 | var max_lengrth_msg = form_error_msg_field_max_length.replace(/%s/gi, maxLength); |
|
| 224 | jQuery('<div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-warning-sign pull-right"></span>' + max_lengrth_msg + jQuery(this).attr('data-label') + '</div>').insertAfter(fieldset.find('legend').last()); |
|
| 225 | jQuery(this).addClass('invalid-error'); |
|
| 226 | showFormError(); |
|
| 227 | markPage(fieldset, true); |
|
| 228 | error = true; |
|
| 229 | } |
|
| 230 | } |
|
| 231 | }); |
|
| 232 | }); |
|
| 233 | ||
| 234 | return !error; |
|
| 235 | } |
|
| 236 | var showFormError = function() { |
|
| 237 | jQuery('.tx-dpf div.alert-danger').remove(); |
|
| 238 | jQuery('<div class="alert alert-danger" role="alert"><span class="glyphicon glyphicon glyphicon-fire pull-right"></span>' + form_error_msg + '</div>').insertBefore(jQuery('.tx-dpf form').first()); |
|
| 239 | jQuery("html, body").animate({ |
|
| 240 | scrollTop: 0 |
|
| 241 | }, 200); |
|
| 242 | } |
|
| 243 | var showFormSuccess = function() { |
|
| 244 | jQuery('.tx-dpf div.alert-danger').remove(); |
|
| 245 | jQuery('<div class="alert alert-success" role="alert"><span class="glyphicon glyphicon glyphicon-fire pull-right"></span>' + form_success_msg + '</div>').insertBefore(jQuery('.tx-dpf form').first()); |
|
| 246 | jQuery("html, body").animate({ |
|
| 247 | scrollTop: 0 |
|
| 248 | }, 200); |
|
| 249 | } |
|
| 250 | var hasMandatoryInputs = function(fieldset) { |
|
| 251 | var inputs = fieldset.find(".input-field[data-mandatory=1]"); |
|
| 252 | return inputs.length > 0 |
|
| 253 | } |
|
| 254 | var markPage = function(fieldset, error) { |
|
| 255 | var pageId = fieldset.parent().attr('id'); |
|
| 256 | var page = jQuery('.tx-dpf-tabs li a[href=#' + pageId + ']'); |
|
| 257 | if (error) { |
|
| 258 | page.addClass('mandatory-error'); |
|
| 259 | } else { |
|
| 260 | page.removeClass('mandatory-error'); |
|
| 261 | } |
|
| 262 | } |
|
| 263 | var checkMandatoryInputs = function(fieldset) { |
|
| 264 | var mandatoryError = false; |
|
| 265 | fieldset.find(".input-field[data-mandatory=1]").each(function() { |
|
| 266 | var id = jQuery(this).attr('id'); |
|
| 267 | if ((jQuery(this).attr('type') != 'checkbox' && !jQuery(this).val()) || (jQuery(this).attr('type') == 'checkbox' && (jQuery("#" + id + ":checked").length != 1 || !jQuery("#" + id + ":checked")))) { |
|
| 268 | mandatoryError = mandatoryError || true; |
|
| 269 | jQuery(this).addClass('mandatory-error'); |
|
| 270 | } else { |
|
| 271 | jQuery(this).removeClass('mandatory-error'); |
|
| 272 | } |
|
| 273 | }); |
|
| 274 | return mandatoryError; |
|
| 275 | } |
|
| 276 | var checkPrimaryFile = function(fieldset) { |
|
| 277 | var mandatoryError = false; |
|
| 278 | fieldset.find("input#inp_primaryFile[data-virtual!=1]").each(function() { |
|
| 279 | if (!jQuery(this).val()) { |
|
| 280 | mandatoryError = mandatoryError || true; |
|
| 281 | jQuery(this).addClass('mandatory-error'); |
|
| 282 | } else { |
|
| 283 | jQuery(this).removeClass('mandatory-error'); |
|
| 284 | } |
|
| 285 | }); |
|
| 286 | return mandatoryError; |
|
| 287 | } |
|
| 288 | var checkFilledInputs = function(fieldset) { |
|
| 289 | var filledInputs = 0; |
|
| 290 | fieldset.find('.input-field').each(function() { |
|
| 291 | if (jQuery(this).val()) { |
|
| 292 | filledInputs++; |
|
| 293 | } |
|
| 294 | jQuery(this).removeClass('mandatory-error'); |
|
| 295 | }); |
|
| 296 | return filledInputs < 1; |
|
| 297 | } |
|
| 298 | var addGroup = function() { |
|
| 299 | var element = jQuery(this); |
|
| 300 | // Get the group uid |
|
| 301 | var dataGroup = jQuery(this).attr('data-group'); |
|
| 302 | // Number of the next group item |
|
| 303 | var groupIndex = parseInt(jQuery(this).attr('data-index')) + 1; |
|
| 304 | jQuery(this).attr('data-index', groupIndex); |
|
| 305 | var ajaxURL = jQuery(this).attr('data-ajax'); |
|
| 306 | var params = buildAjaxParams(ajaxURL, "groupIndex", groupIndex); |
|
| 307 | //do the ajax-call |
|
| 308 | jQuery.post(ajaxURL, params, function(group) { |
|
| 309 | var group = jQuery(group).find("fieldset"); |
|
| 310 | // add the new group |
|
| 311 | jQuery(group).css({ |
|
| 312 | 'display': 'none' |
|
| 313 | }).insertAfter(jQuery('fieldset[data-group="' + dataGroup + '"]').last()); |
|
| 314 | var height = jQuery('fieldset[data-group="' + dataGroup + '"]').last().outerHeight(true) |
|
| 315 | jQuery('html, body').animate({ |
|
| 316 | scrollTop: element.offset().top - height |
|
| 317 | }, 400, function() { |
|
| 318 | jQuery(group).fadeIn(); |
|
| 319 | }); |
|
| 320 | buttonFillOutServiceUrn(); |
|
| 321 | datepicker(); |
|
| 322 | addRemoveFileButton(); |
|
| 323 | ||
| 324 | // gnd autocomplete for new groups |
|
| 325 | var gndField = jQuery(group).find('.gnd'); |
|
| 326 | if (gndField.length != 0) { |
|
| 327 | setGndAutocomplete(gndField.data('field'),gndField.data('groupindex')); |
|
| 328 | } |
|
| 329 | }); |
|
| 330 | return false; |
|
| 331 | } |
|
| 332 | var addField = function() { |
|
| 333 | var addButton = jQuery(this); |
|
| 334 | // Get the field uid |
|
| 335 | var dataField = jQuery(this).attr('data-field'); |
|
| 336 | // Number of the next field item |
|
| 337 | var fieldIndex = parseInt(jQuery(this).attr('data-index')) + 1; |
|
| 338 | jQuery(this).attr('data-index', fieldIndex); |
|
| 339 | var ajaxURL = jQuery(this).attr('data-ajax'); |
|
| 340 | var params = buildAjaxParams(ajaxURL, "fieldIndex", fieldIndex); |
|
| 341 | //do the ajax-call |
|
| 342 | jQuery.post(ajaxURL, params, function(element) { |
|
| 343 | var field = jQuery(element).find("#new-element").children(); |
|
| 344 | jQuery(field).css({ |
|
| 345 | 'display': 'none' |
|
| 346 | }).insertBefore(addButton).fadeIn(); |
|
| 347 | buttonFillOutServiceUrn(); |
|
| 348 | datepicker(); |
|
| 349 | ||
| 350 | // gnd autocomplete for new fields |
|
| 351 | var gndField = jQuery(element).find('.gnd'); |
|
| 352 | if (gndField.length != 0) { |
|
| 353 | setGndAutocomplete(gndField.data('field'),gndField.data('groupindex')); |
|
| 354 | } |
|
| 355 | }); |
|
| 356 | return false; |
|
| 357 | } |
|
| 358 | var deleteFile = function() { |
|
| 359 | var fileGroup = jQuery(this).parent().parent(); |
|
| 360 | var ajaxURL = jQuery(this).attr('data-ajax'); |
|
| 361 | var params = {} |
|
| 362 | //do the ajax-call |
|
| 363 | jQuery.post(ajaxURL, params, function(element) { |
|
| 364 | var field = jQuery(element).find("#new-element").children(); |
|
| 365 | jQuery(fileGroup).replaceWith(field); |
|
| 366 | }); |
|
| 367 | return false; |
|
| 368 | } |
|
| 369 | ||
| 370 | function buildAjaxParams(ajaxURL, indexName, index) { |
|
| 371 | var res = ajaxURL.match(/(tx\w+?)%/); // get param name |
|
| 372 | var params = {}; |
|
| 373 | var indexParam = {}; |
|
| 374 | if (res && res[1]) { |
|
| 375 | indexParam[indexName] = index; |
|
| 376 | params[res[1]] = indexParam; |
|
| 377 | } |
|
| 378 | return params; |
|
| 379 | } |
|
| 380 | var fillOutServiceUrn = function() { |
|
| 381 | // Get the field uid |
|
| 382 | var fieldUid = jQuery(this).attr('data-field'); |
|
| 383 | var fieldIndex = jQuery(this).attr('data-index'); |
|
| 384 | var groupUid = jQuery(this).attr('data-group'); |
|
| 385 | var groupIndex = jQuery(this).attr('data-groupindex'); |
|
| 386 | var ajaxURL = jQuery(this).attr('data-ajax'); |
|
| 387 | var qucosaId = jQuery('#qucosaid').val(); |
|
| 388 | var params = {}; |
|
| 389 | if (qucosaId) { |
|
| 390 | params = buildAjaxParams(ajaxURL, "qucosaId", qucosaId); |
|
| 391 | } else { |
|
| 392 | params = buildAjaxParams(ajaxURL, "qucosaId", ""); |
|
| 393 | } |
|
| 394 | ||
| 395 | var group = $(this).closest(".fs_group"); |
|
| 396 | ||
| 397 | //do the ajax-call |
|
| 398 | jQuery.getJSON(ajaxURL, params, function(element) { |
|
| 399 | ||
| 400 | group.find('.alert-filloutservice-urn').remove(); |
|
| 401 | ||
| 402 | if (element.error) { |
|
| 403 | var errorMsg = $('<div class="alert alert-danger alert-filloutservice-urn" role="alert"><span class="glyphicon glyphicon glyphicon-fire pull-right"></span>' + form_error_msg_filloutservice + '</div>'); |
|
| 404 | errorMsg.insertAfter(group.find('legend')); |
|
| 405 | $("html, body").animate({scrollTop: group.offset().top}, 200); |
|
| 406 | } else { |
|
| 407 | jQuery('#qucosaid').val(element.qucosaId); |
|
| 408 | jQuery('#qucosaUrn').val(element.value); |
|
| 409 | var inputField = jQuery('.input-field[data-field="' + fieldUid + '"][data-index="' + fieldIndex + '"][data-group="' + groupUid + '"][data-groupindex="' + groupIndex + '"]'); |
|
| 410 | inputField.val(element.value); |
|
| 411 | buttonFillOutServiceUrn(); |
|
| 412 | } |
|
| 413 | }); |
|
| 414 | return false; |
|
| 415 | } |
|
| 416 | var buttonFillOutServiceUrn = function() { |
|
| 417 | jQuery('input.urn').each(function() { |
|
| 418 | var fieldUid = jQuery(this).attr('data-field'); |
|
| 419 | var fieldIndex = jQuery(this).attr('data-index'); |
|
| 420 | var groupUid = jQuery(this).attr('data-group'); |
|
| 421 | var groupIndex = jQuery(this).attr('data-groupindex'); |
|
| 422 | var fillOutButton = jQuery('.fill_out_service_urn[data-field="' + fieldUid + '"][data-index="' + fieldIndex + '"]'); |
|
| 423 | if ((jQuery(this).val() && jQuery(this).val().length > 0) || hasQucosaUrn()) { |
|
| 424 | fillOutButton.hide(); |
|
| 425 | } else { |
|
| 426 | fillOutButton.show(); |
|
| 427 | } |
|
| 428 | }); |
|
| 429 | return false; |
|
| 430 | } |
|
| 431 | var hasQucosaUrn = function() { |
|
| 432 | var result = false; |
|
| 433 | var qucosaUrn = jQuery('#qucosaUrn').val(); |
|
| 434 | jQuery('input.urn').each(function() { |
|
| 435 | var currentUrn = jQuery(this).val(); |
|
| 436 | if (currentUrn && qucosaUrn && (currentUrn == qucosaUrn)) { |
|
| 437 | result = result || true; |
|
| 438 | } |
|
| 439 | }); |
|
| 440 | return result; |
|
| 441 | } |
|
| 442 | var continuousScroll = function() { |
|
| 443 | var ajaxURL = jQuery("#next").attr('href'); |
|
| 444 | jQuery.ajax({ |
|
| 445 | url: ajaxURL, |
|
| 446 | success: function(html) { |
|
| 447 | if (html) { |
|
| 448 | jQuery(html).find("table tbody tr").each(function() { |
|
| 449 | jQuery("#search-results tbody tr").last().parent().append(this); |
|
| 450 | }); |
|
| 451 | if (jQuery(html).find("table tbody tr").length <= 0) { |
|
| 452 | jQuery("#next").hide(); |
|
| 453 | } |
|
| 454 | } else { |
|
| 455 | jQuery("#next").hide(); |
|
| 456 | } |
|
| 457 | } |
|
| 458 | }); |
|
| 459 | return false; |
|
| 460 | } |
|
| 461 | $(window).scroll(function() { |
|
| 462 | if ($(this).scrollTop() > 330) { |
|
| 463 | $(".tx-dpf-tab-container").addClass("sticky"); |
|
| 464 | } else { |
|
| 465 | $(".tx-dpf-tab-container").removeClass("sticky"); |
|
| 466 | } |
|
| 467 | }); |
|
| 468 | var datepicker = function() { |
|
| 469 | var language = jQuery('div.tx-dpf[data-language]').first().attr('data-language'); |
|
| 470 | if (!language) language = "en"; |
|
| 471 | jQuery('.datetimepicker').datetimepicker({ |
|
| 472 | useCurrent: false, |
|
| 473 | format: 'DD.MM.YYYY', |
|
| 474 | locale: language, |
|
| 475 | keepInvalid: true |
|
| 476 | }).on("keydown", function(e){ |
|
| 477 | if (e.which == 13) { |
|
| 478 | $('.datetimepicker').closest('form').submit(); |
|
| 479 | } |
|
| 480 | }); |
|
| 481 | } |
|
| 482 | var isDate = function(value) { |
|
| 483 | if (value == '') return false; |
|
| 484 | var rxDatePattern = /^(\d{1,2})(\.)(\d{1,2})(\.)(\d{4})$/; //Declare Regex |
|
| 485 | var dtArray = value.match(rxDatePattern); // is format OK? |
|
| 486 | if (dtArray == null) return false; |
|
| 487 | //Checks for mm/dd/yyyy format. |
|
| 488 | var dtMonth = dtArray[3]; |
|
| 489 | var dtDay = dtArray[1]; |
|
| 490 | var dtYear = dtArray[5]; |
|
| 491 | if (dtMonth < 1 || dtMonth > 12) { |
|
| 492 | return false; |
|
| 493 | } else if (dtDay < 1 || dtDay > 31) { |
|
| 494 | return false; |
|
| 495 | } else if ((dtMonth == 4 || dtMonth == 6 || dtMonth == 9 || dtMonth == 11) && dtDay == 31) { |
|
| 496 | return false; |
|
| 497 | } else if (dtMonth == 2) { |
|
| 498 | var isleap = (dtYear % 4 == 0 && (dtYear % 100 != 0 || dtYear % 400 == 0)); |
|
| 499 | if (dtDay > 29 || (dtDay == 29 && !isleap)) return false; |
|
| 500 | } |
|
| 501 | return true; |
|
| 502 | } |
|
| 503 | var documentListConfirmDialog = function(dialogId) { |
|
| 504 | jQuery(dialogId).modal({ |
|
| 505 | show: false, |
|
| 506 | backdrop: 'static' |
|
| 507 | }); |
|
| 508 | jQuery(dialogId).on('show.bs.modal', function(e) { |
|
| 509 | jQuery(this).find('#discardDocument').attr('href', jQuery(e.relatedTarget).attr('href')); |
|
| 510 | var bodyText = jQuery(this).find('.modal-body p').html(); |
|
| 511 | var title = jQuery(e.relatedTarget).attr('data-documenttitle'); |
|
| 512 | jQuery(this).find('.modal-body p').html(bodyText.replace('%s', title)); |
|
| 513 | jQuery(e.relatedTarget).parent().parent().addClass('danger marked-for-removal'); |
|
| 514 | }); |
|
| 515 | jQuery(dialogId).on('hidden.bs.modal', function(e) { |
|
| 516 | jQuery('.marked-for-removal').removeClass('danger marked-for-removal'); |
|
| 517 | }); |
|
| 518 | } |
|
| 519 | ||
| 520 | function addRemoveFileButton() { |
|
| 521 | $('.rem_file').unbind('click'); |
|
| 522 | $('.rem_file').bind('click', function (evt) { |
|
| 523 | evt.preventDefault(); |
|
| 524 | $(this).siblings('.input_file_upload').val(''); |
|
| 525 | }) |
|
| 526 | } |
|
| 527 | ||
| 528 | ||
| 529 | function gndNothingFound(fieldId, groupIndex) { |
|
| 530 | var gndInputField = $('.gnd[data-field="' + fieldId + '"][data-groupindex="' + groupIndex + '"]'); |
|
| 531 | ||
| 532 | if (gndInputField.data('old_gnd_field_value')) { |
|
| 533 | gndInputField.val(gndInputField.data('old_gnd_field_value')); |
|
| 534 | } else { |
|
| 535 | gndInputField.val(); |
|
| 536 | } |
|
| 537 | ||
| 538 | var gndFieldId = gndInputField.data('gndfield'); |
|
| 539 | var linkedGroupIndex = gndInputField.data('groupindex'); |
|
| 540 | var gndLinkedInputField = $('input[data-field="' + gndFieldId + '"][data-groupindex="' + linkedGroupIndex + '"]'); |
|
| 541 | ||
| 542 | if (gndLinkedInputField.data('old_gnd_field_id')) { |
|
| 543 | gndLinkedInputField.val(gndLinkedInputField.data('old_gnd_field_id')); |
|
| 544 | } else { |
|
| 545 | gndLinkedInputField.val(); |
|
| 546 | } |
|
| 547 | ||
| 548 | /** global: form_error_msg_nothing_found */ |
|
| 549 | jQuery('<div id="gnd-nothing-found" class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-fire pull-right"></span>' + form_error_msg_nothing_found + '</div>').insertBefore(gndInputField.closest('.form-container')); |
|
| 550 | ||
| 551 | gndInputField.bind("keypress click", function () { |
|
| 552 | jQuery("#gnd-nothing-found").remove(); |
|
| 553 | }); |
|
| 554 | ||
| 555 | gndLinkedInputField.bind("keypress click", function () { |
|
| 556 | jQuery("#gnd-nothing-found").remove(); |
|
| 557 | }); |
|
| 558 | ||
| 559 | } |
|
| 560 | ||
| 561 | function setGndAutocomplete(fieldId, groupIndex) { |
|
| 562 | // GND autocomplete |
|
| 563 | var ajaxURL = $('.gnd[data-field="' + fieldId + '"][data-groupindex="' + groupIndex + '"]').attr('data-ajax'); |
|
| 564 | ||
| 565 | var gndInputField = $('.gnd[data-field="' + fieldId + '"][data-groupindex="' + groupIndex + '"]'); |
|
| 566 | var gndFieldId = gndInputField.data('gndfield'); |
|
| 567 | var linkedGroupIndex = gndInputField.data('groupindex'); |
|
| 568 | var gndLinkedInputField = $('input[data-field="' + gndFieldId + '"][data-groupindex="' + linkedGroupIndex + '"]'); |
|
| 569 | ||
| 570 | gndInputField.attr('data-old_gnd_field_value',gndInputField.val()); |
|
| 571 | gndLinkedInputField.attr('data-old_gnd_field_id',gndLinkedInputField.val()); |
|
| 572 | ||
| 573 | // Get the name of the parameter array (tx_dpf_...), |
|
| 574 | // the name depends on whether the call is from the frontend or the backend |
|
| 575 | var res = ajaxURL.match(/(tx_dpf\w+?)%/); |
|
| 576 | var paramName = "tx_dpf_qucosaform[search]"; |
|
| 577 | if (res && res[1]) { |
|
| 578 | paramName = res[1]+"[search]"; |
|
| 579 | } |
|
| 580 | ||
| 581 | $('.gnd[data-field="' + fieldId + '"][data-groupindex="' + groupIndex + '"]').autocomplete({ |
|
| 582 | source: function (request, response) { |
|
| 583 | ||
| 584 | $('input[data-field="' + gndFieldId + '"][data-groupindex="' + linkedGroupIndex + '"]').val(''); |
|
| 585 | ||
| 586 | var requestData = {}; |
|
| 587 | requestData[paramName] = request.term.replace(" ", "+"); |
|
| 588 | $.ajax({ |
|
| 589 | type: 'POST', |
|
| 590 | url: ajaxURL, |
|
| 591 | data: requestData, |
|
| 592 | dataType: 'json', |
|
| 593 | timeout: 10000, |
|
| 594 | success: function (data) { |
|
| 595 | if (data) { |
|
| 596 | response(data); |
|
| 597 | } else { |
|
| 598 | gndNothingFound(fieldId, groupIndex); |
|
| 599 | response([]); |
|
| 600 | } |
|
| 601 | }, |
|
| 602 | error: function () { |
|
| 603 | gndNothingFound(fieldId, groupIndex); |
|
| 604 | response([]); |
|
| 605 | } |
|
| 606 | }); |
|
| 607 | }, |
|
| 608 | minLength: 3, |
|
| 609 | select: function (event, ui) { |
|
| 610 | gndFieldId = jQuery(event.target).data('gndfield'); |
|
| 611 | linkedGroupIndex = jQuery(event.target).data('groupindex'); |
|
| 612 | $('input[data-field="' + gndFieldId + '"][data-groupindex="' + linkedGroupIndex + '"]').val(ui.item.gnd); |
|
| 613 | }, |
|
| 614 | }).autocomplete( "instance" )._renderItem = function( ul, item ) { |
|
| 615 | return $( "<li>" ) |
|
| 616 | .append( "<div class='gnd-autocomplete'><span class='gnd-value' style='display:none;'>" + item.value + "</span>" + |
|
| 617 | "<span class='gnd-label'>" + item.label + "</span></div>" |
|
| 618 | ) |
|
| 619 | .appendTo( ul ); |
|
| 620 | }; |
|
| 621 | } |
|
| 622 | ||
| 623 | var previousNextFormPage = function() { |
|
| 624 | ||
| 625 | $('.prev-next-buttons button').click(function (e) { |
|
| 626 | var activePage = $('.tx-dpf-tabs').find('li.active'); |
|
| 627 | var newActivePage = activePage; |
|
| 628 | ||
| 629 | if ($(this).attr('id') == 'next-form-page') { |
|
| 630 | newActivePage = activePage.next(); |
|
| 631 | } else { |
|
| 632 | newActivePage = activePage.prev(); |
|
| 633 | } |
|
| 634 | ||
| 635 | if (newActivePage.length > 0) { |
|
| 636 | activePage.removeClass('active'); |
|
| 637 | activePage.find('a').attr('aria-expanded', 'false'); |
|
| 638 | $('.tab-content').find('div.active').removeClass('active'); |
|
| 639 | ||
| 640 | newActivePage.addClass('active'); |
|
| 641 | newActivePage.find('a').attr('aria-expanded', 'true'); |
|
| 642 | $('.tab-content').find(newActivePage.find('a').attr('href')).addClass('active'); |
|
| 643 | ||
| 644 | updatePrevNextButtons(newActivePage); |
|
| 645 | ||
| 646 | $('html, body').animate({ |
|
| 647 | scrollTop:$('.tx-dpf').offset().top |
|
| 648 | },'fast'); |
|
| 649 | } |
|
| 650 | ||
| 651 | e.preventDefault(); |
|
| 652 | ||
| 653 | }); |
|
| 654 | ||
| 655 | updatePrevNextButtons($('.tx-dpf-tabs li.active')); |
|
| 656 | ||
| 657 | $('.tx-dpf-tabs li').click(function(){ |
|
| 658 | updatePrevNextButtons($(this)); |
|
| 659 | }); |
|
| 660 | ||
| 661 | } |
|
| 662 | ||
| 663 | var updatePrevNextButtons = function(activePage) { |
|
| 664 | ||
| 665 | if (activePage.prev().length < 1) { |
|
| 666 | $('#prev-form-page').addClass('disabled'); |
|
| 667 | } else { |
|
| 668 | $('#prev-form-page').removeClass('disabled'); |
|
| 669 | } |
|
| 670 | if (activePage.next().length < 1) { |
|
| 671 | $('#next-form-page').addClass('disabled'); |
|
| 672 | } else { |
|
| 673 | $('#next-form-page').removeClass('disabled'); |
|
| 674 | } |
|
| 675 | } |
|
| 676 | ||
| 677 | var inputWithOptions = function() { |
|
| 678 | ||
| 679 | $.widget( "custom.dropdownoptions", { |
|
| 680 | _create: function() { |
|
| 681 | ||
| 682 | var availableTags = []; |
|
| 683 | var test = this.element |
|
| 684 | .closest(".dropdown-options") |
|
| 685 | .find(".dropdown-options-values li") |
|
| 686 | .each(function(){ |
|
| 687 | if (jQuery(this).text().length > 0) { |
|
| 688 | availableTags.push(jQuery(this).text()); |
|
| 689 | } |
|
| 690 | }); |
|
| 691 | ||
| 692 | this.element |
|
| 693 | .addClass( ".dropdown-options-input" ) |
|
| 694 | .autocomplete({ |
|
| 695 | minLength: 0, |
|
| 696 | source: availableTags |
|
| 697 | }); |
|
| 698 | ||
| 699 | this._createShowAllButton(); |
|
| 700 | }, |
|
| 701 | _createShowAllButton: function() { |
|
| 702 | ||
| 703 | var input = this.element; |
|
| 704 | ||
| 705 | wasOpen = false; |
|
| 706 | ||
| 707 | input |
|
| 708 | .closest(".dropdown-options") |
|
| 709 | .find(".dropdown-options-toggle") |
|
| 710 | .on( "mousedown", function() { |
|
| 711 | wasOpen = input.autocomplete( "widget" ).is( ":visible" ); |
|
| 712 | }) |
|
| 713 | .on( "click", function() { |
|
| 714 | input.trigger( "focus" ); |
|
| 715 | if ( wasOpen ) { |
|
| 716 | return; |
|
| 717 | } |
|
| 718 | input.autocomplete( "search", "" ); |
|
| 719 | ||
| 720 | }); |
|
| 721 | input |
|
| 722 | .on( "click", function() { |
|
| 723 | input.autocomplete( "search", "" ); |
|
| 724 | }); |
|
| 725 | } |
|
| 726 | }); |
|
| 727 | ||
| 728 | $( ".dropdown-options-input" ).dropdownoptions(); |
|
| 729 | } |
|
| @@ 14-728 (lines=715) @@ | ||
| 11 | * The TYPO3 project - inspiring people to share! |
|
| 12 | */ |
|
| 13 | ||
| 14 | define(['jquery', 'TYPO3/CMS/Dpf/jquery-ui','twbs/bootstrap-datetimepicker'], function($) { |
|
| 15 | ||
| 16 | var documentListConfirmDialog = function(dialogId) { |
|
| 17 | $(dialogId).modal({ |
|
| 18 | show: false, |
|
| 19 | backdrop: 'static' |
|
| 20 | }); |
|
| 21 | $(dialogId).on('show.bs.modal', function(e) { |
|
| 22 | $(this).find('#discardDocument').attr('href', $(e.relatedTarget).attr('href')); |
|
| 23 | var bodyText = $(this).find('.modal-body p').html(); |
|
| 24 | var title = $(e.relatedTarget).attr('data-documenttitle'); |
|
| 25 | $(this).find('.modal-body p').html(bodyText.replace('%s', title)); |
|
| 26 | $(e.relatedTarget).parent().parent().addClass('danger marked-for-removal'); |
|
| 27 | }); |
|
| 28 | $(dialogId).on('hidden.bs.modal', function(e) { |
|
| 29 | $('.marked-for-removal').removeClass('danger marked-for-removal'); |
|
| 30 | }); |
|
| 31 | } |
|
| 32 | ||
| 33 | var datepicker = function() { |
|
| 34 | $(".datetimepicker").datetimepicker({ |
|
| 35 | useCurrent: false, |
|
| 36 | keepInvalid: false, |
|
| 37 | format: "DD.MM.YYYY" |
|
| 38 | }); |
|
| 39 | } |
|
| 40 | ||
| 41 | var buttonFillOutServiceUrn = function() { |
|
| 42 | $('input.urn').each(function() { |
|
| 43 | var fieldUid = $(this).attr('data-field'); |
|
| 44 | var fieldIndex = $(this).attr('data-index'); |
|
| 45 | var groupUid = $(this).attr('data-group'); |
|
| 46 | var groupIndex = $(this).attr('data-groupindex'); |
|
| 47 | var fillOutButton = $('.fill_out_service_urn[data-field="' + fieldUid + '"][data-index="' + fieldIndex + '"]'); |
|
| 48 | if (($(this).val() && $(this).val().length > 0) || hasQucosaUrn()) { |
|
| 49 | fillOutButton.hide(); |
|
| 50 | } else { |
|
| 51 | fillOutButton.show(); |
|
| 52 | } |
|
| 53 | }); |
|
| 54 | return false; |
|
| 55 | } |
|
| 56 | ||
| 57 | var hasQucosaUrn = function() { |
|
| 58 | var result = false; |
|
| 59 | var qucosaUrn = $('#qucosaUrn').val(); |
|
| 60 | $('input.urn').each(function() { |
|
| 61 | var currentUrn = $(this).val(); |
|
| 62 | if (currentUrn && qucosaUrn && (currentUrn == qucosaUrn)) { |
|
| 63 | result = result || true; |
|
| 64 | } |
|
| 65 | }); |
|
| 66 | return result; |
|
| 67 | } |
|
| 68 | ||
| 69 | ||
| 70 | var validateFormAndSave = function() { |
|
| 71 | $("#validDocument").val("0"); |
|
| 72 | if (validateForm()) { |
|
| 73 | $("#validDocument").val("1"); |
|
| 74 | $("#new-document-form #save").prop("disabled", true); |
|
| 75 | $('#new-document-form').submit(); |
|
| 76 | return true; |
|
| 77 | } |
|
| 78 | return false; |
|
| 79 | } |
|
| 80 | ||
| 81 | var validateFormOnly = function() { |
|
| 82 | if (validateForm()) { |
|
| 83 | showFormSuccess(); |
|
| 84 | } |
|
| 85 | return false; |
|
| 86 | } |
|
| 87 | ||
| 88 | var validateForm = function() { |
|
| 89 | var error = false; |
|
| 90 | $('span.mandatory-error').remove(); |
|
| 91 | $('div.alert').remove(); |
|
| 92 | $('.tx-dpf-tabs li a').each(function() { |
|
| 93 | $(this).removeClass('mandatory-error'); |
|
| 94 | }); |
|
| 95 | ||
| 96 | // check mandatory groups |
|
| 97 | $('fieldset[data-mandatory=1]').each(function() { |
|
| 98 | var fieldset = $(this); |
|
| 99 | if (hasMandatoryInputs(fieldset)) { |
|
| 100 | if (checkMandatoryInputs(fieldset)) { |
|
| 101 | $('<div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-warning-sign pull-right"></span>' + form_error_msg_group_mandatory + '</div>').insertAfter(fieldset.find('legend').last()); |
|
| 102 | showFormError(); |
|
| 103 | error = true; |
|
| 104 | markPage(fieldset, true); |
|
| 105 | } |
|
| 106 | } else { |
|
| 107 | if (checkFilledInputs(fieldset)) { |
|
| 108 | $('<div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-warning-sign pull-right"></span>' + form_error_msg_group_one_required + '</div>').insertAfter(fieldset.find('legend').last()); |
|
| 109 | showFormError(); |
|
| 110 | error = true; |
|
| 111 | markPage(fieldset, true); |
|
| 112 | error = true; |
|
| 113 | } |
|
| 114 | } |
|
| 115 | }); |
|
| 116 | ||
| 117 | $('fieldset[id=primary_file]').each(function() { |
|
| 118 | var fieldset = $(this); |
|
| 119 | if (checkPrimaryFile(fieldset)) { |
|
| 120 | $('<div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-warning-sign pull-right"></span>' + form_error_msg_group_mandatory + '</div>').insertBefore(fieldset.find('legend').last()); |
|
| 121 | showFormError(); |
|
| 122 | error = true; |
|
| 123 | markPage(fieldset, true); |
|
| 124 | } |
|
| 125 | }); |
|
| 126 | ||
| 127 | // check non mandatory groups |
|
| 128 | $('fieldset[data-mandatory=""]').each(function() { |
|
| 129 | var fieldset = $(this); |
|
| 130 | var filledInputs = 0; |
|
| 131 | $(this).find('.input-field').each(function() { |
|
| 132 | if ($(this).val() && $(this).attr('data-default') != '1') { |
|
| 133 | filledInputs++; |
|
| 134 | } |
|
| 135 | $(this).removeClass('mandatory-error'); |
|
| 136 | }); |
|
| 137 | ||
| 138 | // if there are fields with a value then mandatory fields |
|
| 139 | // are relevant. |
|
| 140 | if (filledInputs) { |
|
| 141 | if (checkMandatoryInputs(fieldset)) { |
|
| 142 | $('<div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-warning-sign pull-right"></span>' + form_error_msg_group_mandatory + '</div>').insertAfter(fieldset.find('legend').last()); |
|
| 143 | showFormError(); |
|
| 144 | markPage(fieldset, true); |
|
| 145 | error = true; |
|
| 146 | } |
|
| 147 | } |
|
| 148 | }); |
|
| 149 | ||
| 150 | $('fieldset').each(function() { |
|
| 151 | var fieldset = $(this); |
|
| 152 | fieldset.find('.input-field').each(function() { |
|
| 153 | $(this).removeClass('invalid-error'); |
|
| 154 | var validation = $(this).attr('data-regexp'); |
|
| 155 | if ($(this).val() && $(this).val().length > 0 && validation && validation.length > 0) { |
|
| 156 | try { |
|
| 157 | var regexp = new RegExp(validation); |
|
| 158 | var res = $(this).val().match(regexp); |
|
| 159 | if (!(res && res.length == 1 && res[0] == $(this).val())) { |
|
| 160 | $('<div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-warning-sign pull-right"></span>' + form_error_msg_field_invalid + ': ' + $(this).attr('data-label') + '</div>').insertAfter(fieldset.find('legend').last()); |
|
| 161 | $(this).addClass('invalid-error'); |
|
| 162 | showFormError(); |
|
| 163 | markPage(fieldset, true); |
|
| 164 | error = true; |
|
| 165 | } |
|
| 166 | } catch (err) { |
|
| 167 | $('<div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-warning-sign pull-right"></span>' + form_error_msg_field_invalid + ': ' + $(this).attr('data-label') + '</div>').insertAfter(fieldset.find('legend').last()); |
|
| 168 | $(this).addClass('invalid-error'); |
|
| 169 | showFormError(); |
|
| 170 | markPage(fieldset, true); |
|
| 171 | error = true; |
|
| 172 | } |
|
| 173 | } else { |
|
| 174 | var validateDate = $(this).attr('data-datatype') == 'DATE'; |
|
| 175 | if ($(this).val() && $(this).val().length > 0 && validateDate && !isDate($(this).val())) { |
|
| 176 | $('<div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-warning-sign pull-right"></span>' + form_error_msg_field_invalid + ': ' + $(this).attr('data-label') + '</div>').insertAfter(fieldset.find('legend').last()); |
|
| 177 | $(this).addClass('invalid-error'); |
|
| 178 | showFormError(); |
|
| 179 | markPage(fieldset, true); |
|
| 180 | error = true; |
|
| 181 | } |
|
| 182 | } |
|
| 183 | ||
| 184 | var maxLength = $(this).attr('data-maxlength'); |
|
| 185 | if (maxLength && maxLength > 0) { |
|
| 186 | if ($(this).val().length > maxLength) { |
|
| 187 | var max_lengrth_msg = form_error_msg_field_max_length.replace(/%s/gi, maxLength); |
|
| 188 | $('<div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-warning-sign pull-right"></span>' + max_lengrth_msg + $(this).attr('data-label') + '</div>').insertAfter(fieldset.find('legend').last()); |
|
| 189 | $(this).addClass('invalid-error'); |
|
| 190 | showFormError(); |
|
| 191 | markPage(fieldset, true); |
|
| 192 | error = true; |
|
| 193 | } |
|
| 194 | } |
|
| 195 | }); |
|
| 196 | }); |
|
| 197 | return !error; |
|
| 198 | } |
|
| 199 | ||
| 200 | var showFormError = function() { |
|
| 201 | $('.tx-dpf div.alert-danger').remove(); |
|
| 202 | $('<div class="alert alert-danger" role="alert"><span class="glyphicon glyphicon glyphicon-fire pull-right"></span>' + form_error_msg + '</div>').insertBefore($('.tx-dpf form').first()); |
|
| 203 | $("html, body").animate({scrollTop: 0}, 200); |
|
| 204 | } |
|
| 205 | ||
| 206 | var showFormSuccess = function() { |
|
| 207 | $('.tx-dpf div.alert-danger').remove(); |
|
| 208 | $('<div class="alert alert-success" role="alert"><span class="glyphicon glyphicon glyphicon-fire pull-right"></span>' + form_success_msg + '</div>').insertBefore($('.tx-dpf form').first()); |
|
| 209 | $("html, body").animate({scrollTop: 0}, 200); |
|
| 210 | } |
|
| 211 | ||
| 212 | var hasMandatoryInputs = function(fieldset) { |
|
| 213 | var inputs = fieldset.find(".input-field[data-mandatory=1]"); |
|
| 214 | return inputs.length > 0; |
|
| 215 | } |
|
| 216 | ||
| 217 | var markPage = function(fieldset, error) { |
|
| 218 | var pageId = fieldset.parent().attr('id'); |
|
| 219 | var page = $('.tx-dpf-tabs li a[href=#' + pageId + ']'); |
|
| 220 | if (error) { |
|
| 221 | page.addClass('mandatory-error'); |
|
| 222 | } else { |
|
| 223 | page.removeClass('mandatory-error'); |
|
| 224 | } |
|
| 225 | } |
|
| 226 | ||
| 227 | var checkMandatoryInputs = function(fieldset) { |
|
| 228 | var mandatoryError = false; |
|
| 229 | fieldset.find(".input-field[data-mandatory=1]").each(function() { |
|
| 230 | var id = $(this).attr('id'); |
|
| 231 | if (($(this).attr('type') != 'checkbox' && !$(this).val()) || ($(this).attr('type') == 'checkbox' && ($("#" + id + ":checked").length != 1 || !$("#" + id + ":checked")))) { |
|
| 232 | mandatoryError = mandatoryError || true; |
|
| 233 | $(this).addClass('mandatory-error'); |
|
| 234 | } else { |
|
| 235 | $(this).removeClass('mandatory-error'); |
|
| 236 | } |
|
| 237 | }); |
|
| 238 | return mandatoryError; |
|
| 239 | } |
|
| 240 | ||
| 241 | var checkPrimaryFile = function(fieldset) { |
|
| 242 | var mandatoryError = false; |
|
| 243 | fieldset.find("input#inp_primaryFile[data-virtual!=1]").each(function() { |
|
| 244 | if (!$(this).val()) { |
|
| 245 | mandatoryError = mandatoryError || true; |
|
| 246 | $(this).addClass('mandatory-error'); |
|
| 247 | } else { |
|
| 248 | $(this).removeClass('mandatory-error'); |
|
| 249 | } |
|
| 250 | }); |
|
| 251 | return mandatoryError; |
|
| 252 | } |
|
| 253 | ||
| 254 | var checkFilledInputs = function(fieldset) { |
|
| 255 | var filledInputs = 0; |
|
| 256 | fieldset.find('.input-field').each(function() { |
|
| 257 | if ($(this).val()) { |
|
| 258 | filledInputs++; |
|
| 259 | } |
|
| 260 | $(this).removeClass('mandatory-error'); |
|
| 261 | }); |
|
| 262 | return filledInputs < 1; |
|
| 263 | } |
|
| 264 | ||
| 265 | var addGroup = function() { |
|
| 266 | var element = $(this); |
|
| 267 | // Get the group uid |
|
| 268 | var dataGroup = $(this).attr('data-group'); |
|
| 269 | // Number of the next group item |
|
| 270 | var groupIndex = parseInt($(this).attr('data-index')) + 1; |
|
| 271 | $(this).attr('data-index', groupIndex); |
|
| 272 | var ajaxURL = $(this).attr('data-ajax'); |
|
| 273 | var params = buildAjaxParams(ajaxURL, "groupIndex", groupIndex); |
|
| 274 | //do the ajax-call |
|
| 275 | $.post(ajaxURL, params, function(group) { |
|
| 276 | var group = $(group).find("fieldset"); |
|
| 277 | // add the new group |
|
| 278 | $(group) |
|
| 279 | .css({'display': 'none'}) |
|
| 280 | .insertAfter($('fieldset[data-group="' + dataGroup + '"]').last()); |
|
| 281 | ||
| 282 | var height = $('fieldset[data-group="' + dataGroup + '"]') |
|
| 283 | .last() |
|
| 284 | .outerHeight(true) |
|
| 285 | ||
| 286 | $('html, body') |
|
| 287 | .animate({scrollTop: element.offset().top - height}, 400, function() {$(group).fadeIn();}); |
|
| 288 | ||
| 289 | buttonFillOutServiceUrn(); |
|
| 290 | datepicker(); |
|
| 291 | addRemoveFileButton(); |
|
| 292 | ||
| 293 | // gnd autocomplete for new groups |
|
| 294 | var gndField = $(group).find('.gnd'); |
|
| 295 | if (gndField.length != 0) { |
|
| 296 | setGndAutocomplete(gndField.data('field'),gndField.data('groupindex')); |
|
| 297 | } |
|
| 298 | }); |
|
| 299 | return false; |
|
| 300 | } |
|
| 301 | ||
| 302 | var addField = function() { |
|
| 303 | var addButton = $(this); |
|
| 304 | // Get the field uid |
|
| 305 | var dataField = $(this).attr('data-field'); |
|
| 306 | // Number of the next field item |
|
| 307 | var fieldIndex = parseInt($(this).attr('data-index')) + 1; |
|
| 308 | $(this).attr('data-index', fieldIndex); |
|
| 309 | var ajaxURL = $(this).attr('data-ajax'); |
|
| 310 | var params = buildAjaxParams(ajaxURL, "fieldIndex", fieldIndex); |
|
| 311 | //do the ajax-call |
|
| 312 | $.post(ajaxURL, params, function(element) { |
|
| 313 | var field = $(element).find("#new-element").children(); |
|
| 314 | $(field).css({'display': 'none'}) |
|
| 315 | .insertBefore(addButton).fadeIn(); |
|
| 316 | buttonFillOutServiceUrn(); |
|
| 317 | datepicker(); |
|
| 318 | ||
| 319 | // gnd autocomplete for new fields |
|
| 320 | var gndField = $(group).find('.gnd'); |
|
| 321 | if (gndField.length != 0) { |
|
| 322 | setGndAutocomplete(gndField.data('field'),gndField.data('groupindex')); |
|
| 323 | } |
|
| 324 | }); |
|
| 325 | return false; |
|
| 326 | } |
|
| 327 | ||
| 328 | var deleteFile = function() { |
|
| 329 | var fileGroup = $(this).parent().parent(); |
|
| 330 | var ajaxURL = $(this).attr('data-ajax'); |
|
| 331 | var params = {}; |
|
| 332 | //do the ajax-call |
|
| 333 | $.post(ajaxURL, params, function(element) { |
|
| 334 | var field = $(element).find("#new-element").children(); |
|
| 335 | $(fileGroup).replaceWith(field); |
|
| 336 | }); |
|
| 337 | return false; |
|
| 338 | } |
|
| 339 | ||
| 340 | function buildAjaxParams(ajaxURL, indexName, index) { |
|
| 341 | var res = ajaxURL.match(/(tx\w+?)%/); // get param name |
|
| 342 | var params = {}; |
|
| 343 | var indexParam = {}; |
|
| 344 | if (res && res[1]) { |
|
| 345 | indexParam[indexName] = index; |
|
| 346 | params[res[1]] = indexParam; |
|
| 347 | } |
|
| 348 | return params; |
|
| 349 | } |
|
| 350 | ||
| 351 | var fillOutServiceUrn = function() { |
|
| 352 | // Get the field uid |
|
| 353 | var fieldUid = $(this).attr('data-field'); |
|
| 354 | var fieldIndex = $(this).attr('data-index'); |
|
| 355 | var groupUid = $(this).attr('data-group'); |
|
| 356 | var groupIndex = $(this).attr('data-groupindex'); |
|
| 357 | var ajaxURL = $(this).attr('data-ajax'); |
|
| 358 | var qucosaId = $('#qucosaid').val(); |
|
| 359 | var params = {}; |
|
| 360 | ||
| 361 | if (qucosaId) { |
|
| 362 | params = buildAjaxParams(ajaxURL, "qucosaId", qucosaId); |
|
| 363 | } else { |
|
| 364 | params = buildAjaxParams(ajaxURL, "qucosaId", ""); |
|
| 365 | } |
|
| 366 | ||
| 367 | var group = $(this).closest(".fs_group"); |
|
| 368 | ||
| 369 | //do the ajax-call |
|
| 370 | $.getJSON(ajaxURL, params, function(element) { |
|
| 371 | ||
| 372 | group.find('.alert-filloutservice-urn').remove(); |
|
| 373 | ||
| 374 | if (element.error) { |
|
| 375 | var errorMsg = $('<div class="alert alert-danger alert-filloutservice-urn" role="alert"><span class="glyphicon glyphicon glyphicon-fire pull-right"></span>' + form_error_msg_filloutservice + '</div>'); |
|
| 376 | errorMsg.insertAfter(group.find('legend')); |
|
| 377 | $("html, body").animate({scrollTop: group.offset().top}, 200); |
|
| 378 | } else { |
|
| 379 | $('#qucosaid').val(element.qucosaId); |
|
| 380 | $('#qucosaUrn').val(element.value); |
|
| 381 | var inputField = $('.input-field[data-field="' + fieldUid + '"][data-index="' + fieldIndex + '"][data-group="' + groupUid + '"][data-groupindex="' + groupIndex + '"]'); |
|
| 382 | inputField.val(element.value); |
|
| 383 | buttonFillOutServiceUrn(); |
|
| 384 | } |
|
| 385 | }); |
|
| 386 | return false; |
|
| 387 | } |
|
| 388 | ||
| 389 | var continuousScroll = function() { |
|
| 390 | var ajaxURL = $("#next").attr('href'); |
|
| 391 | $.ajax({ |
|
| 392 | url: ajaxURL, |
|
| 393 | success: function(html) { |
|
| 394 | if (html) { |
|
| 395 | $(html).find("table tbody tr").each(function() { |
|
| 396 | $("#search-results tbody tr").last().parent().append(this); |
|
| 397 | }); |
|
| 398 | if ($(html).find("table tbody tr").length <= 0) { |
|
| 399 | $("#next").hide(); |
|
| 400 | } |
|
| 401 | } else { |
|
| 402 | $("#next").hide(); |
|
| 403 | } |
|
| 404 | } |
|
| 405 | }); |
|
| 406 | return false; |
|
| 407 | } |
|
| 408 | ||
| 409 | var isDate = function(value) { |
|
| 410 | if (value == '') return false; |
|
| 411 | var rxDatePattern = /^(\d{1,2})(\.)(\d{1,2})(\.)(\d{4})$/; //Declare Regex |
|
| 412 | var dtArray = value.match(rxDatePattern); // is format OK? |
|
| 413 | if (dtArray == null) return false; |
|
| 414 | //Checks for mm/dd/yyyy format. |
|
| 415 | var dtMonth = dtArray[3]; |
|
| 416 | var dtDay = dtArray[1]; |
|
| 417 | var dtYear = dtArray[5]; |
|
| 418 | if (dtMonth < 1 || dtMonth > 12) { |
|
| 419 | return false; |
|
| 420 | } |
|
| 421 | if (dtDay < 1 || dtDay > 31) { |
|
| 422 | return false; |
|
| 423 | } |
|
| 424 | if ((dtMonth == 4 || dtMonth == 6 || dtMonth == 9 || dtMonth == 11) && dtDay == 31) { |
|
| 425 | return false; |
|
| 426 | } |
|
| 427 | if (dtMonth == 2) { |
|
| 428 | var isleap = (dtYear % 4 == 0 && (dtYear % 100 != 0 || dtYear % 400 == 0)); |
|
| 429 | if (dtDay > 29 || (dtDay == 29 && !isleap)) return false; |
|
| 430 | } |
|
| 431 | return true; |
|
| 432 | } |
|
| 433 | ||
| 434 | function addRemoveFileButton() { |
|
| 435 | $('.rem_file').unbind('click'); |
|
| 436 | $('.rem_file').bind('click', function (evt) { |
|
| 437 | evt.preventDefault(); |
|
| 438 | $(this).siblings('.input_file_upload').val(''); |
|
| 439 | }); |
|
| 440 | } |
|
| 441 | ||
| 442 | function gndNothingFound(fieldId, groupIndex) { |
|
| 443 | var gndInputField = $('.gnd[data-field="' + fieldId + '"][data-groupindex="' + groupIndex + '"]'); |
|
| 444 | ||
| 445 | if (gndInputField.data('old_gnd_field_value')) { |
|
| 446 | gndInputField.val(gndInputField.data('old_gnd_field_value')); |
|
| 447 | } else { |
|
| 448 | gndInputField.val(); |
|
| 449 | } |
|
| 450 | ||
| 451 | var gndFieldId = gndInputField.data('gndfield'); |
|
| 452 | var linkedGroupIndex = gndInputField.data('groupindex'); |
|
| 453 | var gndLinkedInputField = $('input[data-field="' + gndFieldId + '"][data-groupindex="' + linkedGroupIndex + '"]'); |
|
| 454 | ||
| 455 | if (gndLinkedInputField.data('old_gnd_field_id')) { |
|
| 456 | gndLinkedInputField.val(gndLinkedInputField.data('old_gnd_field_id')); |
|
| 457 | } else { |
|
| 458 | gndLinkedInputField.val(); |
|
| 459 | } |
|
| 460 | ||
| 461 | /** global: form_error_msg_nothing_found */ |
|
| 462 | $('<div id="gnd-nothing-found" class="alert alert-warning" role="alert"><span class="glyphicon glyphicon glyphicon-fire pull-right"></span>' + form_error_msg_nothing_found + '</div>').insertBefore(gndInputField.closest('.form-container')); |
|
| 463 | ||
| 464 | gndInputField.bind("keypress click", function () { |
|
| 465 | $("#gnd-nothing-found").remove(); |
|
| 466 | }); |
|
| 467 | ||
| 468 | gndLinkedInputField.bind("keypress click", function () { |
|
| 469 | $("#gnd-nothing-found").remove(); |
|
| 470 | }); |
|
| 471 | ||
| 472 | } |
|
| 473 | ||
| 474 | function setGndAutocomplete(fieldId, groupIndex) { |
|
| 475 | // GND autocomplete |
|
| 476 | var ajaxURL = $('.gnd[data-field="' + fieldId + '"][data-groupindex="' + groupIndex + '"]').attr('data-ajax'); |
|
| 477 | ||
| 478 | var gndInputField = $('.gnd[data-field="' + fieldId + '"][data-groupindex="' + groupIndex + '"]'); |
|
| 479 | var gndFieldId = gndInputField.data('gndfield'); |
|
| 480 | var linkedGroupIndex = gndInputField.data('groupindex'); |
|
| 481 | var gndLinkedInputField = $('input[data-field="' + gndFieldId + '"][data-groupindex="' + linkedGroupIndex + '"]'); |
|
| 482 | ||
| 483 | gndInputField.attr('data-old_gnd_field_value',gndInputField.val()); |
|
| 484 | gndLinkedInputField.attr('data-old_gnd_field_id',gndLinkedInputField.val()); |
|
| 485 | ||
| 486 | // Get the name of the parameter array (tx_dpf_...), |
|
| 487 | // the name depends on whether the call is from the frontend or the backend |
|
| 488 | var res = ajaxURL.match(/(tx_dpf\w+?)%/); |
|
| 489 | var paramName = "tx_dpf_qucosaform[search]"; |
|
| 490 | if (res && res[1]) { |
|
| 491 | paramName = res[1]+"[search]"; |
|
| 492 | } |
|
| 493 | ||
| 494 | $('.gnd[data-field="' + fieldId + '"][data-groupindex="' + groupIndex + '"]').autocomplete({ |
|
| 495 | source: function (request, response) { |
|
| 496 | ||
| 497 | $('input[data-field="' + gndFieldId + '"][data-groupindex="' + linkedGroupIndex + '"]').val(''); |
|
| 498 | ||
| 499 | var requestData = {}; |
|
| 500 | requestData[paramName] = request.term.replace(" ", "+"); |
|
| 501 | $.ajax({ |
|
| 502 | type: 'POST', |
|
| 503 | url: ajaxURL, |
|
| 504 | data: requestData, |
|
| 505 | dataType: 'json', |
|
| 506 | timeout: 10000, |
|
| 507 | success: function (data) { |
|
| 508 | if (data) { |
|
| 509 | response(data); |
|
| 510 | } else { |
|
| 511 | gndNothingFound(fieldId, groupIndex); |
|
| 512 | response([]); |
|
| 513 | } |
|
| 514 | }, |
|
| 515 | error: function () { |
|
| 516 | gndNothingFound(fieldId, groupIndex); |
|
| 517 | response([]); |
|
| 518 | } |
|
| 519 | }); |
|
| 520 | }, |
|
| 521 | minLength: 3, |
|
| 522 | select: function (event, ui) { |
|
| 523 | gndFieldId = $(event.target).data('gndfield'); |
|
| 524 | linkedGroupIndex = $(event.target).data('groupindex'); |
|
| 525 | $('input[data-field="' + gndFieldId + '"][data-groupindex="' + linkedGroupIndex + '"]').val(ui.item.gnd); |
|
| 526 | }, |
|
| 527 | }).autocomplete( "instance" )._renderItem = function( ul, item ) { |
|
| 528 | return $( "<li>" ) |
|
| 529 | .append( "<div class='gnd-autocomplete'><span class='gnd-value' style='display:none;'>" + item.value + "</span>" + |
|
| 530 | "<span class='gnd-label'>" + item.label + "</span></div>" |
|
| 531 | ) |
|
| 532 | .appendTo( ul ); |
|
| 533 | }; |
|
| 534 | } |
|
| 535 | ||
| 536 | var previousNextFormPage = function() { |
|
| 537 | ||
| 538 | $('.prev-next-buttons button').click(function (e) { |
|
| 539 | var activePage = $('.tx-dpf-tabs').find('li.active'); |
|
| 540 | var newActivePage = activePage; |
|
| 541 | ||
| 542 | if ($(this).attr('id') == 'next-form-page') { |
|
| 543 | newActivePage = activePage.next(); |
|
| 544 | } else { |
|
| 545 | newActivePage = activePage.prev(); |
|
| 546 | } |
|
| 547 | ||
| 548 | if (newActivePage.length > 0) { |
|
| 549 | activePage.removeClass('active'); |
|
| 550 | activePage.find('a').attr('aria-expanded', 'false'); |
|
| 551 | $('.tab-content').find('div.active').removeClass('active'); |
|
| 552 | ||
| 553 | newActivePage.addClass('active'); |
|
| 554 | newActivePage.find('a').attr('aria-expanded', 'true'); |
|
| 555 | $('.tab-content').find(newActivePage.find('a').attr('href')).addClass('active'); |
|
| 556 | ||
| 557 | updatePrevNextButtons(newActivePage); |
|
| 558 | ||
| 559 | $('html, body').animate({ |
|
| 560 | scrollTop:$('.tx-dpf').offset().top |
|
| 561 | },'fast'); |
|
| 562 | } |
|
| 563 | ||
| 564 | e.preventDefault(); |
|
| 565 | ||
| 566 | }); |
|
| 567 | ||
| 568 | updatePrevNextButtons($('.tx-dpf-tabs li.active')); |
|
| 569 | ||
| 570 | $('.tx-dpf-tabs li').click(function(){ |
|
| 571 | updatePrevNextButtons($(this)); |
|
| 572 | }); |
|
| 573 | ||
| 574 | } |
|
| 575 | ||
| 576 | var updatePrevNextButtons = function(activePage) { |
|
| 577 | ||
| 578 | if (activePage.prev().length < 1) { |
|
| 579 | $('#prev-form-page').addClass('disabled'); |
|
| 580 | } else { |
|
| 581 | $('#prev-form-page').removeClass('disabled'); |
|
| 582 | } |
|
| 583 | if (activePage.next().length < 1) { |
|
| 584 | $('#next-form-page').addClass('disabled'); |
|
| 585 | } else { |
|
| 586 | $('#next-form-page').removeClass('disabled'); |
|
| 587 | } |
|
| 588 | } |
|
| 589 | ||
| 590 | var inputWithOptions = function() { |
|
| 591 | ||
| 592 | $.widget( "custom.dropdownoptions", { |
|
| 593 | _create: function() { |
|
| 594 | ||
| 595 | var availableTags = []; |
|
| 596 | var test = this.element |
|
| 597 | .closest(".dropdown-options") |
|
| 598 | .find(".dropdown-options-values li") |
|
| 599 | .each(function(){ |
|
| 600 | if ($(this).text().length > 0) { |
|
| 601 | availableTags.push($(this).text()); |
|
| 602 | } |
|
| 603 | }); |
|
| 604 | ||
| 605 | this.element |
|
| 606 | .addClass( ".dropdown-options-input" ) |
|
| 607 | .autocomplete({ |
|
| 608 | minLength: 0, |
|
| 609 | source: availableTags |
|
| 610 | }); |
|
| 611 | ||
| 612 | this._createShowAllButton(); |
|
| 613 | }, |
|
| 614 | _createShowAllButton: function() { |
|
| 615 | ||
| 616 | var input = this.element; |
|
| 617 | ||
| 618 | wasOpen = false; |
|
| 619 | ||
| 620 | input |
|
| 621 | .closest(".dropdown-options") |
|
| 622 | .find(".dropdown-options-toggle") |
|
| 623 | .on( "mousedown", function() { |
|
| 624 | wasOpen = input.autocomplete( "widget" ).is( ":visible" ); |
|
| 625 | }) |
|
| 626 | .on( "click", function() { |
|
| 627 | input.trigger( "focus" ); |
|
| 628 | if ( wasOpen ) { |
|
| 629 | return; |
|
| 630 | } |
|
| 631 | input.autocomplete( "search", "" ); |
|
| 632 | ||
| 633 | }); |
|
| 634 | input |
|
| 635 | .on( "click", function() { |
|
| 636 | input.autocomplete( "search", "" ); |
|
| 637 | }); |
|
| 638 | } |
|
| 639 | }); |
|
| 640 | ||
| 641 | $( ".dropdown-options-input" ).dropdownoptions(); |
|
| 642 | } |
|
| 643 | ||
| 644 | $(window).scroll(function() { |
|
| 645 | if ($(this).scrollTop() > 330) { |
|
| 646 | $(".tx-dpf-tab-container").addClass("sticky"); |
|
| 647 | } else { |
|
| 648 | $(".tx-dpf-tab-container").removeClass("sticky"); |
|
| 649 | } |
|
| 650 | }); |
|
| 651 | ||
| 652 | $(document).ready(function() { |
|
| 653 | $('#new-document-form').trigger('reset'); |
|
| 654 | documentListConfirmDialog('#confirmDiscard'); |
|
| 655 | documentListConfirmDialog('#confirmPublish'); |
|
| 656 | documentListConfirmDialog('#confirmUpdate'); |
|
| 657 | documentListConfirmDialog('#confirmActivate'); |
|
| 658 | documentListConfirmDialog('#confirmInactivate'); |
|
| 659 | documentListConfirmDialog('#confirmRestore'); |
|
| 660 | documentListConfirmDialog('#confirmDelete'); |
|
| 661 | ||
| 662 | datepicker(); |
|
| 663 | ||
| 664 | $('[data-toggle="tooltip"]').tooltip(); |
|
| 665 | var $disableForm = $('form[data-disabled]').attr('data-disabled'); |
|
| 666 | if ($disableForm) { |
|
| 667 | $('.input-field').each(function() {$(this).attr('disabled', 'disabled');}); |
|
| 668 | $('.rem_file_group').each(function() {$(this).attr('disabled', 'disabled');}); |
|
| 669 | $('.add_file_group').each(function() {$(this).attr('disabled', 'disabled');}); |
|
| 670 | $('.input_file_upload').each(function() {$(this).attr('disabled', 'disabled');}); |
|
| 671 | $('.add_field').each(function() {$(this).attr('disabled', 'disabled');}); |
|
| 672 | $('.add_group').each(function() {$(this).attr('disabled', 'disabled');}); |
|
| 673 | $('.rem_field').each(function() {$(this).attr('disabled', 'disabled');}); |
|
| 674 | $('.rem_group').each(function() {$(this).attr('disabled', 'disabled');}); |
|
| 675 | $('.fill_out_service_urn').each(function() {$(this).attr('disabled', 'disabled');}); |
|
| 676 | } |
|
| 677 | ||
| 678 | buttonFillOutServiceUrn(); |
|
| 679 | ||
| 680 | $(".tx-dpf").on("click", ".rem_group", function() { |
|
| 681 | $(this).parents('fieldset').fadeOut(300, function() {$(this).remove();}); |
|
| 682 | return false; |
|
| 683 | }); |
|
| 684 | $(".tx-dpf").on("click", ".rem_file_group", deleteFile); |
|
| 685 | $(".tx-dpf").on("click", ".rem_secondary_upload", function() { |
|
| 686 | var dataIndex = $(this).data("index"); |
|
| 687 | $(this).parents('.fs_file_group').fadeOut(300, function() {$(this).remove();}); |
|
| 688 | return false; |
|
| 689 | }); |
|
| 690 | $(".tx-dpf").on("click", ".rem_field", function() { |
|
| 691 | var dataIndex = $(this).data("index"); |
|
| 692 | var dataField = $(this).data("field"); |
|
| 693 | $(this).parents('.form-group').fadeOut(300, function() {$(this).remove();}); |
|
| 694 | return false; |
|
| 695 | }); |
|
| 696 | // Add metadata group |
|
| 697 | $(".tx-dpf").on("click", ".add_group", addGroup); |
|
| 698 | $(".tx-dpf").on("click", ".add_file_group", addGroup); |
|
| 699 | $(".tx-dpf").on("click", ".add_field", addField); |
|
| 700 | $(".tx-dpf").on("click", ".fill_out_service_urn", fillOutServiceUrn); |
|
| 701 | $(".tx-dpf").on("keyup", "input.urn", buttonFillOutServiceUrn); |
|
| 702 | $(".tx-dpf").on("click", "#next", continuousScroll); |
|
| 703 | $(".form-submit").on("click", "#save", validateFormAndSave); |
|
| 704 | $(".form-submit").on("click", "#validate", validateFormOnly); |
|
| 705 | ||
| 706 | // hide 'more results' link |
|
| 707 | var countResults = $('#search-results :not(thead) tr').length; |
|
| 708 | var resultCount = $('#next').data('resultCount'); |
|
| 709 | ||
| 710 | if (countResults < resultCount) { |
|
| 711 | $("#next").hide(); |
|
| 712 | } |
|
| 713 | ||
| 714 | addRemoveFileButton(); |
|
| 715 | ||
| 716 | previousNextFormPage(); |
|
| 717 | ||
| 718 | var gnd = $('.gnd'); |
|
| 719 | if(gnd.length > 0) { |
|
| 720 | gnd.each(function() { |
|
| 721 | setGndAutocomplete($(this).data("field"), $(this).data("groupindex")); |
|
| 722 | }); |
|
| 723 | } |
|
| 724 | ||
| 725 | inputWithOptions(); |
|
| 726 | ||
| 727 | }); |
|
| 728 | }); |
|
| 729 | ||
| 730 | ||