4,554
edits
No edit summary |
No edit summary |
||
Line 1,283: | Line 1,283: | ||
$chooser = jQuery( | $chooser = jQuery( | ||
'<div id="print-chooser" class="print-chooser" style="display:none;">' + | '<div id="print-chooser" class="print-chooser" style="display:none;">' + | ||
'<a href="#" id="print-with | '<a href="#" id="sw-print-with" class="print-choice">border</a> ' + | ||
'<a href="#" id="print-no | '<a href="#" id="sw-print-no" class="print-choice">no border</a>' + | ||
"</div>" | "</div>" | ||
); | ); | ||
Line 1,829: | Line 1,829: | ||
// --- extra safety bindings for Entry page / widgets --- | // --- extra safety bindings for Entry page / widgets --- | ||
// | // Delegated: clicks on choices inside the chooser | ||
jQuery(document).on( | jQuery(document).on( | ||
"click.swprintChoice", | "click.swprintChoice", | ||
" | "#print-chooser a#sw-print-with, #print-chooser a#sw-print-no", | ||
function (e) { | function (e) { | ||
e.preventDefault(); | e.preventDefault(); | ||
swHandlePrintChoice( | var id = | ||
this.id === "sw-print-no" ? "print-no-border" : "print-with-border"; | |||
swHandlePrintChoice(id, jQuery(this)); | |||
} | } | ||
); | ); | ||
// | // If the UI uses <button> inside the <a>, map button → parent <a> (still scoped to chooser) | ||
jQuery(document).on( | jQuery(document).on( | ||
"click.swprintChoiceBtn", | "click.swprintChoiceBtn", | ||
"#print- | "#print-chooser button", | ||
function (e) { | function (e) { | ||
var | var host = this.closest( | ||
"#print-chooser a#sw-print-with, #print-chooser a#sw-print-no" | |||
" | |||
); | ); | ||
if (!host) return; | |||
e.preventDefault(); | e.preventDefault(); | ||
swHandlePrintChoice( | var id = | ||
host.id === "sw-print-no" ? "print-no-border" : "print-with-border"; | |||
swHandlePrintChoice(id, (window.jQuery && jQuery(host)) || null); | |||
} | } | ||
); | ); | ||
// If a widget uses <button> inside the chooser, map it to the nearest id node | // If a widget uses <button> inside the chooser, map it to the nearest id node |