MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 1,272: Line 1,272:
   function cacheBust(url) {
   function cacheBust(url) {
     return url + (url.indexOf("?") > -1 ? "&" : "?") + "_=" + Date.now();
     return url + (url.indexOf("?") > -1 ? "&" : "?") + "_=" + Date.now();
  }
  // --- tiny inline chooser for border preference ---
  function ensurePrintChooser() {
    var $chooser = $("#print-chooser");
    if ($chooser.length) return $chooser;
    // MediaWiki-safe: use <div> + <a>, no <button> needed
    $chooser = $(
      '<div id="print-chooser" class="print-chooser" style="display:none;">' +
        '<a href="#" id="print-with-border" class="print-choice">[with border]</a> ' +
        '<a href="#" id="print-no-border" class="print-choice">[no border]</a>' +
        "</div>"
    );
    $("#print-button").after($chooser);
    return $chooser;
   }
   }


Line 1,287: Line 1,303:
       e.preventDefault();
       e.preventDefault();


      var id = this.id;
      // If the main [print] is clicked, just toggle the chooser and stop.
      if (id === "print-button") {
        var $chooser = ensurePrintChooser();
        $chooser.toggle();
        return; // <-- don't start printing yet
      }
      // otherwise it's one of the two choices; proceed with your existing flow…
       var $btn = $(this);
       var $btn = $(this);
       if ($btn.data("busy")) return;
       if ($btn.data("busy")) return;
Line 1,292: Line 1,317:


       // decide the border preference from the clicked button id
       // decide the border preference from the clicked button id
      // #print-no-border => no border; everything else => with border
       var borderPref = id === "print-no-border" ? "without" : "with";
       var borderPref =
      console.log("[print] option chosen:", borderPref);
        $btn.attr("id") === "print-no-border" ? "without" : "with";


       preloadFontForPrint();
       preloadFontForPrint();

Navigation menu