PrintPreview: A bookmarklet to preview the print version of a web page.
Created
January 13, 2012 16:48
-
-
Save tzi/1607453 to your computer and use it in GitHub Desktop.
PrintPreview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>PrintPreview - A bookmarklet to preview the print version of a web page</title> | |
<meta name="viewport" content="initial-scale=1.0"> | |
<link rel="stylesheet" href="style.css" > | |
</head> | |
<body> | |
<h1>PrintPreview</h1> | |
<p>A bookmarklet to preview the print version of a web page.</p> | |
<p>Drag this button to your bookmarks : <a class="btn" href="javascript:var%20e=document.createElement('script');e.setAttribute('language','javascript');e.setAttribute('src','https://gist.github.com/raw/1839073');document.body.appendChild(e);var%20i;i=setInterval(function(){if(typeof(bm_popin)=='function'){e=document.createElement('script');e.setAttribute('language','javascript');e.setAttribute('src','https://gist.github.com/raw/1607453/print_preview.js');document.body.appendChild(e);clearInterval(i);}},50);void(0);">PrintPreview</a></p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
if ( typeof( bm_popin ) == 'undefined' ) { | |
alert( 'Please update your Bookmarklet here: http://zilliox.me/bm' ); | |
} else { | |
var popin = new bm_popin( 1607453 ); | |
popin.title( 'Print Preview' ); | |
var is_print_preview = false; | |
var switch_view = function() { | |
var links = document.getElementsByTagName( 'link' ); | |
if ( links ) { | |
for ( i=0; i<links.length; i++) { | |
if ( links[ i ].getAttribute( 'rel' ) == 'stylesheet' ) { | |
if ( links[ i ].getAttribute( 'media' ) == 'screen' ) { | |
links[ i ].setAttribute( 'media', 'print' ); | |
} else if ( links[ i ].getAttribute( 'media' ) == 'print' ) { | |
links[ i ].setAttribute( 'media', 'screen' ); | |
} | |
} | |
} | |
} | |
if ( is_print_preview ) { | |
is_print_preview = false; | |
popin.clear_button( ); | |
popin.add_button( 'Go to Print Preview', switch_view ); | |
} else { | |
is_print_preview = true; | |
popin.clear_button( ); | |
popin.add_button( 'Back to Screen View', switch_view ); | |
} | |
}; | |
switch_view(); | |
} | |
}) (); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.btn { | |
display: inline-block; | |
*display: inline; | |
padding: 4px 10px 4px; | |
margin-bottom: 0; | |
*margin-left: .3em; | |
font-size: 13px; | |
line-height: 18px; | |
*line-height: 20px; | |
color: #333333; | |
text-align: center; | |
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); | |
vertical-align: middle; | |
cursor: pointer; | |
background-color: #f5f5f5; | |
*background-color: #e6e6e6; | |
background-image: -ms-linear-gradient(top, #ffffff, #e6e6e6); | |
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6)); | |
background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6); | |
background-image: -o-linear-gradient(top, #ffffff, #e6e6e6); | |
background-image: linear-gradient(top, #ffffff, #e6e6e6); | |
background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6); | |
background-repeat: repeat-x; | |
border: 1px solid #cccccc; | |
*border: 0; | |
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); | |
border-color: #e6e6e6 #e6e6e6 #bfbfbf; | |
border-bottom-color: #b3b3b3; | |
-webkit-border-radius: 4px; | |
-moz-border-radius: 4px; | |
border-radius: 4px; | |
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffffff', endColorstr='#e6e6e6', GradientType=0); | |
filter: progid:dximagetransform.microsoft.gradient(enabled=false); | |
*zoom: 1; | |
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); | |
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); | |
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); | |
} | |
.btn:hover, | |
.btn:active, | |
.btn.active { | |
background-color: #e6e6e6; | |
*background-color: #d9d9d9; | |
} | |
.btn:active, | |
.btn.active { | |
background-color: #cccccc \9; | |
} | |
.btn:hover { | |
color: #333333; | |
text-decoration: none; | |
background-color: #e6e6e6; | |
*background-color: #d9d9d9; | |
/* Buttons in IE7 don't get borders, so darken on hover */ | |
background-position: 0 -15px; | |
-webkit-transition: background-position 0.1s linear; | |
-moz-transition: background-position 0.1s linear; | |
-ms-transition: background-position 0.1s linear; | |
-o-transition: background-position 0.1s linear; | |
transition: background-position 0.1s linear; | |
} | |
.btn:focus { | |
outline: thin dotted #333; | |
outline: 5px auto -webkit-focus-ring-color; | |
outline-offset: -2px; | |
} | |
.btn.active, | |
.btn:active { | |
background-color: #e6e6e6; | |
background-color: #d9d9d9 \9; | |
background-image: none; | |
outline: 0; | |
-webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); | |
-moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); | |
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment