MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 1,367: Line 1,367:
     // --- sanitize: kill any inner .print-no-border (when user chose WITH border) ---
     // --- sanitize: kill any inner .print-no-border (when user chose WITH border) ---
     (function () {
     (function () {
      // if the content itself carries print-no-border on any wrapper,
      // it would disable borders regardless of the <html> class. Remove them.
       var stray = doc.querySelectorAll(".print-no-border");
       var stray = doc.querySelectorAll(".print-no-border");
       console.log(
       console.log(
Line 1,384: Line 1,382:
       }
       }


      // Double-check after cleanup
       console.log(
       console.log(
         "[swprint] stray .print-no-border count AFTER:",
         "[swprint] stray .print-no-border count AFTER:",
Line 1,391: Line 1,388:
     })();
     })();


     // border preference -> <html> class (this is your applyBorderPreference)
     // border preference -> <html> class
     (function () {
     (function () {
       var htmlEl = doc.documentElement;
       var htmlEl = doc.documentElement;
Line 1,409: Line 1,406:
           );
           );
       }
       }
       console.log("[swprint] html class after apply:", htmlEl.className);
       console.log(
        "[swprint] html class after apply:",
        htmlEl.className || "<empty>"
      );
     })();
     })();


     // border preference -> <html> class  (this is your applyBorderPreference)
     // (optional) enforcement so the user’s choice always wins
     (function () {
     (function enforceOuterBorderPreference() {
       var htmlEl = doc.documentElement;
       var css =
      if (borderPref === "without") {
        borderPref === "without"
        if (htmlEl.classList) htmlEl.classList.add("print-no-border");
          ? ".entry-wrapper,.entry-wrapper.print-a4-narrow{border:0!important;box-shadow:none!important;}"
        else if (
           : ".entry-wrapper,.entry-wrapper.print-a4-narrow{border:1px solid #000!important;}";
           (" " + htmlEl.className + " ").indexOf(" print-no-border ") === -1
       var style = doc.createElement("style");
        ) {
      style.appendChild(doc.createTextNode(css));
          htmlEl.className += " print-no-border";
       doc.head.appendChild(style);
        }
       console.log("[swprint] outer border rule injected for:", borderPref);
       } else {
        if (htmlEl.classList) htmlEl.classList.remove("print-no-border");
        else
          htmlEl.className = htmlEl.className.replace(
            /\bprint-no-border\b/g,
            ""
          );
       }
       console.log("[swprint] html class after apply:", htmlEl.className);
     })();
     })();


Navigation menu