Lines 334-340
$( document ).ready( function () {
Link Here
|
334 |
const id = 'ConsentJS_' + idx; |
334 |
const id = 'ConsentJS_' + idx; |
335 |
const code = item.code && item.code.length > 0 ? atob(item.code) : ''; |
335 |
const code = item.code && item.code.length > 0 ? atob(item.code) : ''; |
336 |
const itemId = item.id && item.id.length > 0 ? item.id : ''; |
336 |
const itemId = item.id && item.id.length > 0 ? item.id : ''; |
337 |
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>'; |
337 |
return '<div id="' + id + '" class="consentJSItem" data-id="' + itemId + '">' + |
|
|
338 |
' <div class="consentRow">' + |
339 |
' <div class="consentItem">' + |
340 |
' <label class="required" for="name_' + id + '">' + __('Name') + ':</label>' + |
341 |
' <input id="name_' + id + '" class="metaName" type="text" value="' + item.name + '"><span class="required">' + __('Required') + '</span>' + |
342 |
' </div >' + |
343 |
' <div class="consentItem">' + |
344 |
' <label class="required" for="description_' + id + '">' + __('Description') + ':</label>' + |
345 |
' <input id="description_' + id + '" class="metaDescription" type="text" value="' + item.description + '"><span class="required">' + __('Required') + '</span>' + |
346 |
' </div>' + |
347 |
' <div class="consentItem">' + |
348 |
' <label for="opacConsent_' + id + '">' + __('Requires consent in OPAC') + ':</label>' + |
349 |
checkBox('opacConsent_' + id, 'opacConsent', item.opacConsent) + |
350 |
' </div>' + |
351 |
' <div class="consentItem">' + |
352 |
' <label for="staffConsent_' + id + '">' + __('Requires consent in staff interface') + ':</label>' + |
353 |
checkBox('staffConsent_' + id, 'staffConsent', item.staffConsent) + |
354 |
' </div >' + |
355 |
' <div class="consentItem">' + |
356 |
' <label for="matchPattern_' + id + '">' + __('String used to identify cookie name') + ':</label>' + |
357 |
' <input id="matchPattern_' + id + '" class="metaMatchPattern" type="text" value="' + item.matchPattern + '"><span class="required">' + __('Required') + '</span>' + |
358 |
' </div >' + |
359 |
' </div >' + |
360 |
' <div class="consentRow codeRow">' + |
361 |
' <textarea style="display:none;" id="pref_' + id + '" class="preference preference-code codemirror" rows="10" cols="40">' + code + '</textarea>' + |
362 |
' <div>' + |
363 |
' <a id="expand_' + id + '" class="expand-textarea" data-target="' + id + '" data-syntax="javascript" href="#">' + __('Click to expand') + '</a>' + |
364 |
' <a id="collapse_' + id + '" class="collapse-textarea" data-target="' + id + '" data-syntax="javascript" href="#" style="display:none">' + __('Click to collapse') + '</a>' + |
365 |
' </div >' + |
366 |
' </div>' + |
367 |
' <a class="consentDelete" data-target="' + id + '" href="#">Delete</a>' + |
368 |
'</div > '; |
338 |
} |
369 |
} |
339 |
|
370 |
|
340 |
// Return the markup for all consentJS items concatenated |
371 |
// Return the markup for all consentJS items concatenated |
Lines 354-359
$( document ).ready( function () {
Link Here
|
354 |
return { |
385 |
return { |
355 |
name: '', |
386 |
name: '', |
356 |
description: '', |
387 |
description: '', |
|
|
388 |
matchPattern: '', |
357 |
code: '', |
389 |
code: '', |
358 |
consentInOpac: false, |
390 |
consentInOpac: false, |
359 |
consentInStaff: false |
391 |
consentInStaff: false |
Lines 431-448
$( document ).ready( function () {
Link Here
|
431 |
'_' + Math.random().toString(36).substr(2, 9); |
463 |
'_' + Math.random().toString(36).substr(2, 9); |
432 |
const name = $(this).find('.metaName').val(); |
464 |
const name = $(this).find('.metaName').val(); |
433 |
const desc = $(this).find('.metaDescription').val(); |
465 |
const desc = $(this).find('.metaDescription').val(); |
|
|
466 |
const matchPattern = $(this).find('.metaMatchPattern').val(); |
434 |
const opacConsent = $(this).find('.opacConsent').is(':checked') |
467 |
const opacConsent = $(this).find('.opacConsent').is(':checked') |
435 |
const staffConsent = $(this).find('.staffConsent').is(':checked'); |
468 |
const staffConsent = $(this).find('.staffConsent').is(':checked'); |
436 |
const code = $(this).find('.preference-code').val(); |
469 |
const code = $(this).find('.preference-code').val(); |
437 |
// If the name, description and code are empty, then they've |
470 |
// If the name, description, match pattern code are empty, then they've |
438 |
// added a new entry, but not filled it in, we can skip it |
471 |
// added a new entry, but not filled it in, we can skip it |
439 |
if (name.length === 0 && desc.length === 0 && code.length === 0) { |
472 |
if ( |
|
|
473 |
name.length === 0 && |
474 |
desc.length === 0 && |
475 |
matchPattern.length === 0 && |
476 |
code.length === 0 |
477 |
) { |
440 |
return; |
478 |
return; |
441 |
} |
479 |
} |
442 |
// They've filled in at least some info |
480 |
// They've filled in at least some info |
443 |
if ( |
481 |
if ( |
444 |
(name.length === 0) || |
482 |
(name.length === 0) || |
445 |
(desc.length === 0) || |
483 |
(desc.length === 0) || |
|
|
484 |
(matchPattern.length === 0) || |
446 |
(code.length === 0) |
485 |
(code.length === 0) |
447 |
) { |
486 |
) { |
448 |
invalid.push(this); |
487 |
invalid.push(this); |
Lines 451-456
$( document ).ready( function () {
Link Here
|
451 |
id: id, |
490 |
id: id, |
452 |
name: name, |
491 |
name: name, |
453 |
description: desc, |
492 |
description: desc, |
|
|
493 |
matchPattern: matchPattern, |
454 |
opacConsent: opacConsent, |
494 |
opacConsent: opacConsent, |
455 |
staffConsent: staffConsent, |
495 |
staffConsent: staffConsent, |
456 |
code: btoa(code) |
496 |
code: btoa(code) |