Lines 340-346
$( document ).ready( function () {
Link Here
|
340 |
const id = 'ConsentJS_' + idx; |
340 |
const id = 'ConsentJS_' + idx; |
341 |
const code = item.code && item.code.length > 0 ? atob(item.code) : ''; |
341 |
const code = item.code && item.code.length > 0 ? atob(item.code) : ''; |
342 |
const itemId = item.id && item.id.length > 0 ? item.id : ''; |
342 |
const itemId = item.id && item.id.length > 0 ? item.id : ''; |
343 |
return '<div id="' + id + '" class="consentJSItem" data-id="' + itemId + '"><div class="consentRow"><div class="consentItem"><label class="required" for="name_' + id + '">' + __('Name') + ':</label><input id="name_' + id + '" class="metaName" type="text" value="' + item.name + '"><span class="required">' + __('Required') + '</span></div><div class="consentItem"><label class="required" for="description_' + id + '">' + __('Description') + ':</label><input id="description_' + id + '" class="metaDescription" type="text" value="' + item.description + '"><span class="required">' + __('Required') + '</span></div><div class="consentItem"><label for="opacConsent_' + id + '">' + __('Requires consent in OPAC') + ':</label>' + checkBox('opacConsent_' + id, 'opacConsent', item.opacConsent) + '</div><div class="consentItem"><label for="staffConsent_' + id + '">' + __('Requires consent in staff interface') + ':</label>' + checkBox('staffConsent_' + id, 'staffConsent', item.staffConsent) + '</div></div><div class="consentRow codeRow"><textarea style="display:none;" id="pref_' + id + '" class="preference preference-code codemirror" rows="10" cols="40">' + code + '</textarea><div><a id="expand_' + id + '" class="expand-textarea" data-target="' + id + '" data-syntax="javascript" href="#">' + __('Click to expand') + '</a><a id="collapse_' + id + '" class="collapse-textarea" data-target="' + id + '" data-syntax="javascript" href="#" style="display:none">' + __('Click to collapse') + '</a></div></div><a class="consentDelete" data-target="' + id + '" href="#">Delete</a></div>'; |
343 |
return '<div id="' + id + '" class="consentJSItem" data-id="' + itemId + '">' + |
|
|
344 |
' <div class="consentRow">' + |
345 |
' <div class="consentItem">' + |
346 |
' <label class="required" for="name_' + id + '">' + __('Name') + ':</label>' + |
347 |
' <input id="name_' + id + '" class="metaName" type="text" value="' + item.name + '"><span class="required">' + __('Required') + '</span>' + |
348 |
' </div >' + |
349 |
' <div class="consentItem">' + |
350 |
' <label class="required" for="description_' + id + '">' + __('Description') + ':</label>' + |
351 |
' <input id="description_' + id + '" class="metaDescription" type="text" value="' + item.description + '"><span class="required">' + __('Required') + '</span>' + |
352 |
' </div>' + |
353 |
' <div class="consentItem">' + |
354 |
' <label for="opacConsent_' + id + '">' + __('Requires consent in OPAC') + ':</label>' + |
355 |
checkBox('opacConsent_' + id, 'opacConsent', item.opacConsent) + |
356 |
' </div>' + |
357 |
' <div class="consentItem">' + |
358 |
' <label for="staffConsent_' + id + '">' + __('Requires consent in staff interface') + ':</label>' + |
359 |
checkBox('staffConsent_' + id, 'staffConsent', item.staffConsent) + |
360 |
' </div >' + |
361 |
' <div class="consentItem">' + |
362 |
' <label for="matchPattern_' + id + '">' + __('String used to identify cookie name') + ':</label>' + |
363 |
' <input id="matchPattern_' + id + '" class="metaMatchPattern" type="text" value="' + item.matchPattern + '"><span class="required">' + __('Required') + '</span>' + |
364 |
' </div >' + |
365 |
' </div >' + |
366 |
' <div class="consentRow codeRow">' + |
367 |
' <textarea style="display:none;" id="pref_' + id + '" class="preference preference-code codemirror" rows="10" cols="40">' + code + '</textarea>' + |
368 |
' <div>' + |
369 |
' <a id="expand_' + id + '" class="expand-textarea" data-target="' + id + '" data-syntax="javascript" href="#">' + __('Click to expand') + '</a>' + |
370 |
' <a id="collapse_' + id + '" class="collapse-textarea" data-target="' + id + '" data-syntax="javascript" href="#" style="display:none">' + __('Click to collapse') + '</a>' + |
371 |
' </div >' + |
372 |
' </div>' + |
373 |
' <a class="consentDelete" data-target="' + id + '" href="#">Delete</a>' + |
374 |
'</div > '; |
344 |
} |
375 |
} |
345 |
|
376 |
|
346 |
// Return the markup for all consentJS items concatenated |
377 |
// Return the markup for all consentJS items concatenated |
Lines 360-365
$( document ).ready( function () {
Link Here
|
360 |
return { |
391 |
return { |
361 |
name: '', |
392 |
name: '', |
362 |
description: '', |
393 |
description: '', |
|
|
394 |
matchPattern: '', |
363 |
code: '', |
395 |
code: '', |
364 |
consentInOpac: false, |
396 |
consentInOpac: false, |
365 |
consentInStaff: false |
397 |
consentInStaff: false |
Lines 437-454
$( document ).ready( function () {
Link Here
|
437 |
'_' + Math.random().toString(36).substr(2, 9); |
469 |
'_' + Math.random().toString(36).substr(2, 9); |
438 |
const name = $(this).find('.metaName').val(); |
470 |
const name = $(this).find('.metaName').val(); |
439 |
const desc = $(this).find('.metaDescription').val(); |
471 |
const desc = $(this).find('.metaDescription').val(); |
|
|
472 |
const matchPattern = $(this).find('.metaMatchPattern').val(); |
440 |
const opacConsent = $(this).find('.opacConsent').is(':checked') |
473 |
const opacConsent = $(this).find('.opacConsent').is(':checked') |
441 |
const staffConsent = $(this).find('.staffConsent').is(':checked'); |
474 |
const staffConsent = $(this).find('.staffConsent').is(':checked'); |
442 |
const code = $(this).find('.preference-code').val(); |
475 |
const code = $(this).find('.preference-code').val(); |
443 |
// If the name, description and code are empty, then they've |
476 |
// If the name, description, match pattern code are empty, then they've |
444 |
// added a new entry, but not filled it in, we can skip it |
477 |
// added a new entry, but not filled it in, we can skip it |
445 |
if (name.length === 0 && desc.length === 0 && code.length === 0) { |
478 |
if ( |
|
|
479 |
name.length === 0 && |
480 |
desc.length === 0 && |
481 |
matchPattern.length === 0 && |
482 |
code.length === 0 |
483 |
) { |
446 |
return; |
484 |
return; |
447 |
} |
485 |
} |
448 |
// They've filled in at least some info |
486 |
// They've filled in at least some info |
449 |
if ( |
487 |
if ( |
450 |
(name.length === 0) || |
488 |
(name.length === 0) || |
451 |
(desc.length === 0) || |
489 |
(desc.length === 0) || |
|
|
490 |
(matchPattern.length === 0) || |
452 |
(code.length === 0) |
491 |
(code.length === 0) |
453 |
) { |
492 |
) { |
454 |
invalid.push(this); |
493 |
invalid.push(this); |
Lines 457-462
$( document ).ready( function () {
Link Here
|
457 |
id: id, |
496 |
id: id, |
458 |
name: name, |
497 |
name: name, |
459 |
description: desc, |
498 |
description: desc, |
|
|
499 |
matchPattern: matchPattern, |
460 |
opacConsent: opacConsent, |
500 |
opacConsent: opacConsent, |
461 |
staffConsent: staffConsent, |
501 |
staffConsent: staffConsent, |
462 |
code: btoa(code) |
502 |
code: btoa(code) |