4,554
edits
No edit summary |
No edit summary |
||
Line 1,329: | Line 1,329: | ||
} catch (e) {} | } catch (e) {} | ||
})(); | })(); | ||
try { | |||
swBindChoiceAnchors(); | |||
} catch (e) {} | |||
/* core: build iframe and print */ | /* core: build iframe and print */ | ||
Line 1,749: | Line 1,753: | ||
jQuery("#print-button").data("busy", false); | jQuery("#print-button").data("busy", false); | ||
}); | }); | ||
} | |||
function swBindChoiceAnchors() { | |||
var els = document.querySelectorAll("#print-with-border, #print-no-border"); | |||
for (var i = 0; i < els.length; i++) { | |||
(function (el) { | |||
if (el.__swChoiceBound) return; // bind once | |||
el.__swChoiceBound = true; | |||
function handler(ev) { | |||
try { | |||
console.log("[swprint] ELEMENT click ->", el.id); | |||
} catch (e) {} | |||
ev.preventDefault(); | |||
// stop anything else from eating it | |||
if (ev.stopImmediatePropagation) ev.stopImmediatePropagation(); | |||
if (ev.stopPropagation) ev.stopPropagation(); | |||
var $a = (window.jQuery && jQuery(el)) || null; | |||
swHandlePrintChoice(el.id, $a); | |||
return false; | |||
} | |||
// bind in CAPTURE and BUBBLE, plus legacy onclick | |||
el.addEventListener("click", handler, true); // capture | |||
el.addEventListener("click", handler, false); // bubble | |||
if (!el.onclick) el.onclick = handler; | |||
try { | |||
console.log("[swprint] bound element-level handler to", el.id); | |||
} catch (e) {} | |||
})(els[i]); | |||
} | |||
} | } | ||
Line 1,775: | Line 1,812: | ||
var visible = $chooser.is(":visible"); | var visible = $chooser.is(":visible"); | ||
jQuery("#show-article").toggleClass("print-opts-open", visible); | jQuery("#show-article").toggleClass("print-opts-open", visible); | ||
// Bind directly on any choice anchors currently in the DOM | |||
swBindChoiceAnchors(); | |||
// Bind native handlers to ALL nodes that currently exist with those IDs | // Bind native handlers to ALL nodes that currently exist with those IDs |