Don't immediately print on Safari -- give the user a chance to resize the window
authorMichael Ang <mang@archive.org>
Wed, 23 Sep 2009 01:53:19 +0000 (01:53 +0000)
committerMichael Ang <mang@archive.org>
Wed, 23 Sep 2009 01:53:19 +0000 (01:53 +0000)
GnuBookIA/www/print.php

index fd21f42..c704fc8 100644 (file)
@@ -79,8 +79,16 @@ echo '<link rel="stylesheet" type="text/css" href="GnuBook.css" />';
 echo "<style type='text/css'>";
 echo "  @media print { .noprint { font-size: 40pt; display: none; } }";
 echo "</style>";
+echo "<script type='text/javascript'>";
+echo "  function conditionalPrint() {";
+echo "    var doPrint = true; var agent = navigator.userAgent.toLowerCase();";
+echo "    if (agent.indexOf('safari') != -1) { doPrint = false; }";
+echo "    if (doPrint) { print(); }";
+echo "  }";
+echo "</script>";
 echo "<title>" . $id . "</title><body onload='print(); return false;'>";
-echo   "<p class='noprint' style='text-align: right'><button class='GBicon rollover print' title='Print' onclick='print(); return false;'></button> <a href='#' onclick='print(); return false;'>Print</a></p>";
+echo   "<p class='noprint' style='text-align: right'>";
+echo     "<button class='GBicon rollover print' title='Print' onclick='conditionalPrint(); return false;'></button> <a href='#' onclick='print(); return false;'>Print</a></p>";
 echo   "<p style='text-align:center;'>";
 echo     imageURL($paperAspect, $index, $format, $width, $height);
 echo   "</p>";