Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CSS-Tricks/The-Printliminator.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMottie <wowmotty@gmail.com>2015-08-23 02:22:14 +0300
committerMottie <wowmotty@gmail.com>2015-08-24 19:05:21 +0300
commit499adbd59e8958c1596b7ae60d410a733de7650a (patch)
tree61c3b3564215d6db01ce6b013b6878dc343c2d45
parentd12145f26c63d37fd029bdb80a2cf0a539c3c8df (diff)
Add grunt build process:
1) The "src/bookmarklet.js" file contains the uncompressed bookmarklet code. 2) In the build process, that file is minified & added into the "src/index.html" file in two places: a) The actual link href (default link). b) development bookmarklet link (inside js code which updates the link). 3) A new "index.html" and minified "printliminator.min.js" file are written to the root folder. 4) When the "index.html" in the root folder is loaded in the browser, and the js detects the origin is "file://", then the links in the "index.html" file get changed and to point to local files to make it easier for development.
-rw-r--r--Gruntfile.js138
-rw-r--r--README.markdown1
-rw-r--r--README.md15
-rw-r--r--demo/css/style.css6
-rw-r--r--index.html32
-rw-r--r--license.txt165
-rw-r--r--package.json45
-rw-r--r--printliminator.min.js1
-rw-r--r--printliminator.png (renamed from demo/images/printliminator2.png)bin9840 -> 9840 bytes
-rw-r--r--src/bookmarklet.js27
-rw-r--r--src/index.html63
-rw-r--r--src/printliminator.js (renamed from js/printliminator.js)10
12 files changed, 493 insertions, 10 deletions
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 0000000..9468751
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,138 @@
+/*global module:false*/
+module.exports = function( grunt ) {
+ 'use strict';
+
+ var pkg = grunt.file.readJSON( 'package.json' ),
+
+ config = {
+ src : 'src/',
+
+ bookmarkletJs : 'bookmarklet',
+
+ printliminatorJs : 'printliminator',
+ printliminatorFunctionName : 'csstricksPrintliminator',
+
+ // bookmarklet builder URLs
+ indexHtml : 'index.html',
+ production : {
+ jQuery : '//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js',
+ printliminator : '//css-tricks.github.io/The-Printliminator/printliminator.min.js'
+ },
+ dev : {
+ jQuery : 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js',
+ printliminator : 'src/printliminator.js'
+ },
+
+ // note to add to dynamically created index.html in the root folder
+ note : '<!--\nThis file is dynamically generated\n' +
+ '█████▄ ▄████▄ █████▄ ▄████▄ ██████ ███████▄ ▄████▄ █████▄ ██ ██████ ██ ██\n' +
+ '██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\n' +
+ '██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀▀██\n' +
+ '█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀\n' +
+ 'To make changes, modify the "src/index.html"\n-->'
+
+ };
+
+ grunt.file.defaultEncoding = 'utf8';
+ grunt.file.preserveBOM = false;
+
+ // Project configuration.
+ grunt.initConfig({
+ pkg: pkg,
+ config: config,
+
+ jshint: {
+ options: {
+ globals: {
+ '<%= config.printliminatorFunctionName %>': false
+ },
+ 'loopfunc': true,
+ 'jquery': true,
+ 'browser': true,
+ 'undef': true
+ },
+ files: {
+ src: [
+ '<%= config.src %><%= config.printliminatorJs %>.js', '!<%= config.src %>*.min.js'
+ ]
+ }
+ },
+
+ uglify: {
+ options: {
+ report: 'gzip'
+ },
+ main: {
+ files : {
+ '<%= config.printliminatorJs %>.min.js' : [ '<%= config.src %><%= config.printliminatorJs %>.js' ]
+ }
+ },
+ mark: {
+ files : {
+ '<%= config.bookmarkletJs %>.min.js' : [ '<%= config.src %><%= config.bookmarkletJs %>.js' ]
+ }
+ }
+ },
+
+ clean: {
+ build: {
+ src: [
+ config.indexHtml,
+ config.src + '*.min.js',
+ '*.min.js'
+ ]
+ },
+ cleanup : {
+ src: [ config.bookmarkletJs + '.min.js' ]
+ }
+ }
+
+ });
+
+ grunt.loadNpmTasks( 'grunt-contrib-clean' );
+ grunt.loadNpmTasks( 'grunt-contrib-jshint' );
+ grunt.loadNpmTasks( 'grunt-contrib-uglify' );
+
+ grunt.registerTask( 'writeBookmarklet', function(){
+ // Add bookmarklet code for both production & development
+ // load bookmarket min file
+ var content = grunt.file.read( config.bookmarkletJs + '.min.js' ),
+ // load index.html template
+ baseHtml = grunt.file.read( config.src + config.indexHtml ),
+
+ modFile = function( mode ) {
+ var file = content
+ // replace URLs in javascript, depending on mode
+ .replace( /\{jQuery\}/, config[ mode ].jQuery )
+ .replace( /\{printliminator\}/, config[ mode ].printliminator )
+ .replace( /\"/g, "'" )
+ // not using encodeURI because it changes "{}" into "%7B%7D"
+ // and just makes the bookmarklet bigger & harder to read
+ .replace( /\x20/g, '%20' );
+ // add javascript to HTML
+ baseHtml = baseHtml.replace( new RegExp('\\{' + mode + '\\}'), file );
+ };
+
+ // update production & dev bookmarklet href
+ modFile( 'production' );
+ modFile( 'dev' );
+
+ // add note so we don't mistakingly update the wrong index.html
+ // then lose all our changes when grunt is run!
+ baseHtml = baseHtml.replace( '<!-- src -->', config.note );
+
+ // write modified index.html
+ grunt.file.write( config.indexHtml, baseHtml );
+ });
+
+ grunt.registerTask( 'default', 'Default build', function() {
+ grunt.task.run([
+ 'clean:build',
+ 'jshint',
+ 'uglify',
+ 'writeBookmarklet',
+ 'clean:cleanup'
+ ]);
+ });
+
+};
diff --git a/README.markdown b/README.markdown
deleted file mode 100644
index 6195be3..0000000
--- a/README.markdown
+++ /dev/null
@@ -1 +0,0 @@
-##Bookmarklet for cleaning up pages to make them print better \ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..4863ed6
--- /dev/null
+++ b/README.md
@@ -0,0 +1,15 @@
+# The Printliminator
+
+The Printliminator is a bookmarklet with some simple tools you can use to makes websites print better.
+One click to activate, and then click to remove elements from the page, remove graphics, and apply better
+print styling.
+
+![Screenshot](//css-tricks.github.io/The-Printliminator/images/screenshot.png)
+
+[Get the Bookmarklet here](//css-tricks.github.io/The-Printliminator/)
+
+## Credits
+
+* By [Chris Coyier](http://chriscoyier.net) and [Devon Govett](http://devongovett.wordpress.com/).
+* Icons by [Function](http://wefunction.com/2008/07/function-free-icon-set/).
+* Print stylesheet based on [Hartija](http://code.google.com/p/hartija/).
diff --git a/demo/css/style.css b/demo/css/style.css
index 2eb1f81..0616b30 100644
--- a/demo/css/style.css
+++ b/demo/css/style.css
@@ -24,6 +24,12 @@ h1 {
letter-spacing: -2px;
margin: 0 0 15px 0;
}
+#dev-mode {
+ margin-left: 20px;
+ vertical-align: middle;
+ font-size: 20px;
+ color: red;
+}
p {
margin: 0 0 15px 0;
}
diff --git a/index.html b/index.html
index d0177f2..98fbb3c 100644
--- a/index.html
+++ b/index.html
@@ -3,10 +3,20 @@
<head>
<meta charset="UTF-8">
<title>The Printliminator</title>
- <link rel="stylesheet" href="css/style.css">
+ <link rel="stylesheet" href="demo/css/style.css">
</head>
<body>
+
+<!--
+This file is dynamically generated
+█████▄ ▄████▄ █████▄ ▄████▄ ██████ ███████▄ ▄████▄ █████▄ ██ ██████ ██ ██
+██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
+██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀▀██
+█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀
+To make changes, modify the "src/index.html"
+-->
+
<div id="demo-top-bar">
<div id="demo-bar-inside">
<h2 id="demo-bar-badge">
@@ -18,7 +28,7 @@
<div id="page-wrap">
- <h1>The Printliminator</h1>
+ <h1>The Printliminator<span id="dev-mode"></span></h1>
<p>The Printliminator is a bookmarklet with some simple tools you can use
to makes websites print better. One click to activate, and then click to remove
@@ -26,8 +36,9 @@
Here is the bookmarklet:</p>
<p>
- <a href="javascript:/*PRINTLIMINATOR*/(function(){function%20loadScript(a,b){var%20c=document.createElement('script');c.type='text/javascript';c.src=a;var%20d=document.getElementsByTagName('head')[0],done=false;c.onload=c.onreadystatechange=function(){if(!done&amp;&amp;(!this.readyState||this.readyState=='loaded'||this.readyState=='complete')){done=true;b()}};d.appendChild(c)}loadScript('//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js',function(){var%20jq=jQuery.noConflict();loadScript('//css-tricks.github.io/The-Printliminator/js/printliminator.js',function(){csstricksPrintliminator(jq)})})})()" class="bookmarklet">Printliminator</a>
- <span style="font-size: 14px;">&lt; drag to your bookmarks bar</span>
+ <a href="javascript:/*PRINTLIMINATOR*/!function(){function%20a(a,b){var%20c=document.createElement('script'),d=document.getElementsByTagName('head')[0],e=!1;c.type='text/javascript',c.src=a,c.onload=c.onreadystatechange=function(){e||this.readyState&&'loaded'!=this.readyState&&'complete'!=this.readyState||(e=!0,b())},d.appendChild(c)}a('//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js',function(){var%20b=jQuery.noConflict();a('//css-tricks.github.io/The-Printliminator/printliminator.min.js',function(){csstricksPrintliminator(b)})})}();" id="bookmarklet" class="bookmarklet">Printliminator</a>
+ <span class="drag-arrow"><strong>&larr;</strong> drag to your bookmarks bar</span>
+ </p>
<h2>Video Demo</h2>
@@ -43,6 +54,17 @@
</div>
+ <script>
+ // file loaded locally, switch to local version for development
+ ( function() {
+ if ( window.location.origin === 'file://' ) {
+ var link = document.getElementById( 'bookmarklet' );
+ link.href = "javascript:/*PRINTLIMINATOR*/!function(){function%20a(a,b){var%20c=document.createElement('script'),d=document.getElementsByTagName('head')[0],e=!1;c.type='text/javascript',c.src=a,c.onload=c.onreadystatechange=function(){e||this.readyState&&'loaded'!=this.readyState&&'complete'!=this.readyState||(e=!0,b())},d.appendChild(c)}a('http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js',function(){var%20b=jQuery.noConflict();a('src/printliminator.js',function(){csstricksPrintliminator(b)})})}();";
+ document.getElementById('dev-mode').textContent = '(Dev Mode)';
+ }
+ })();
+ </script>
+
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/license.txt b/license.txt
new file mode 100644
index 0000000..02bbb60
--- /dev/null
+++ b/license.txt
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library. \ No newline at end of file
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..d69657b
--- /dev/null
+++ b/package.json
@@ -0,0 +1,45 @@
+{
+ "name": "printliminator",
+ "title": "Printliminator",
+ "version": "3.0.0",
+ "description": "The Printliminator is a bookmarklet with some simple tools you can use to makes websites print better. One click to activate, and then click to remove elements from the page, remove graphics, and apply better print styling.",
+ "author": {
+ "name": "Chris Coyier",
+ "url": "http://chriscoyier.net/"
+ },
+ "contributors": [
+ {
+ "name": "Dave Govett",
+ "url": "http://devongovett.wordpress.com/"
+ },
+ {
+ "name": "Rob Garrison",
+ "url": "https://github.com/Mottie",
+ "email": "wowmotty@gmail.com"
+ }
+ ],
+ "license": "GPL-3.0",
+ "homepage": "https://css-tricks.com/examples/ThePrintliminator/",
+ "bugs": "https://github.com/CSS-Tricks/The-Printliminator/issues",
+ "docs": "https://github.com/CSS-Tricks/The-Printliminator/wiki",
+ "demo": "https://css-tricks.github.io/The-Printliminator",
+ "dependencies": {
+ "jquery": "1.3.2"
+ },
+ "keywords": [
+ "print",
+ ""
+ ],
+ "main": "printliminator.js",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/CSS-Tricks/The-Printliminator.git"
+ },
+ "devDependencies": {
+ "grunt": "^0.4.5",
+ "grunt-cli": "~0.1.13",
+ "grunt-contrib-clean": "^0.6.0",
+ "grunt-contrib-jshint": "^0.11.2",
+ "grunt-contrib-uglify": "^0.7.0"
+ }
+}
diff --git a/printliminator.min.js b/printliminator.min.js
new file mode 100644
index 0000000..c9cb424
--- /dev/null
+++ b/printliminator.min.js
@@ -0,0 +1 @@
+function csstricksPrintliminator(a){var b=a.noConflict(),c=[],d={},e=!1,f=("file://"===window.location.origin?"":"//css-tricks.github.io/The-Printliminator/")+"printliminator.png",g="._print_controls { position: fixed; top: 25px; right: 25px; width: 162px; height: 182px; z-index: 10000;-moz-user-select: none; -webkit-user-select: none; -ms-user-select: none;background: url("+f+") no-repeat; }._print_controls_close { position: absolute; top: -20px; right: -20px; width: 33px; height: 33px;background: url("+f+") -222px -3px no-repeat; }._print_controls_close:hover { background-position: -222px -39px; }._print_controls_remove_graphics, ._print_controls_print, ._print_controls_undo, ._print_controls_stylize {position: absolute; height: 74px; width: 74px;background: url("+f+") no-repeat; }._print_controls_remove_graphics { top: 6px; left: 6px; background-position: 0px -182px; }._print_controls_remove_graphics:hover { background-position: 0 -256px; }._print_controls_remove_graphics.active { background-position: 0 -330px; }._print_controls_print { top: 83px; left: 83px; background-position: -74px -182px; }._print_controls_print:hover { background-position: -74px -256px; }._print_controls_print.active { background-position: -74px -330px; }._print_controls_undo { top: 83px; left: 6px; background-position: -148px -182px; }._print_controls_undo:hover { background-position: -148px -256px; }._print_controls_undo.active { background-position: -148px -330px; }._print_controls_stylize { top: 6px; left: 83px; background-position: -222px -182px; }._print_controls_stylize:hover { background-position: -222px -256px; }._print_controls_stylize.active { background-position: -222px -330px; }._print_removed { display: none !important; }._printliminator_highlight { outline: 3px solid red; }@media print{ ._print_controls { display: none; } }",h='@media print, screen {body { margin:0; padding:0; line-height: 1.4; word-spacing: 1.1pt; letter-spacing: 0.2pt;font-family: Garamond, "Times New Roman", serif; color: #000; background: none; font-size: 12pt; }h1, h2, h3, h4, h5, h6 { font-family: Helvetica, Arial, sans-serif; }h1 { font-size: 19pt; }h2 { font-size: 17pt; }h3 { font-size: 15pt; }h4, h5, h6 { font-size: 12pt; }code { font: 10pt Courier, monospace; }blockquote { margin: 1.3em; padding: 1em; font-size: 10pt; }hr { background-color: #ccc; }img { float: left; margin: 1em 1.5em 1.5em 0; }a img { border: none; }table { margin: 1px; text-align: left; border-collapse: collapse; }th { border: 1px solid #333; font-weight: bold; }td { border: 1px solid #333; }th, td { padding: 4px 10px; }tfoot { font-style: italic; }caption { background: #fff; margin-bottom: 20px; text-align: left; }thead {display: table-header-group; }tr { page-break-inside: avoid; }} @media screen { body { padding: 20px; } }';b('<style id="_print_controls_styles">').text(g).appendTo("head"),b("body *:not(._print_controls, ._print_controls *)").live("click",function(a){if(!e){a.preventDefault();var d,f=b(this);d=a.altKey?b("body *").not("._print_controls, ._print_controls *, style").not(f.parents().andSelf()).not(f.find("*")).addClass("_print_removed"):f,d.addClass("_print_removed"),c.push(d)}}).live("mouseover",function(){e||b(this).addClass("_printliminator_highlight")}).live("mouseout",function(){e||b(this).removeClass("_printliminator_highlight")});var i=b('<div class="_print_controls">').appendTo("body");"fixed"!==i.css("position")&&i.css("position","absolute"),b('<div class="_print_controls_remove_graphics">').click(function(){if(!d.removeGraphics){var a,e,f,g=[],h=b("img, iframe, object, embed, input[type=image], ins"),i=b("body *:not(._print_controls, ._print_controls *)"),j=i.length;for(a=0;j>a;a++)e=i.eq(a),f=e.css("background-image"),"none"!==f&&(g.push([e,f]),e.css("background-image","none"));h.addClass("_print_removed"),d.removeGraphics=!0,c.push(function(){d.removeGraphics=!1,h.removeClass("_print_removed");var b,c=g.length;for(a=0;c>a;a++)b=g[a][0],b.css("background-image",g[a][1])})}}).appendTo(i),b('<div class="_print_controls_stylize">').click(function(){window.print()}).appendTo(i),b('<div class="_print_controls_print">').click(function(){if(!d.stylize){var a=b('link[rel="stylesheet"], style:not(#_print_controls_styles)').remove(),e=b("body *:not(._print_controls, ._print_controls > *, ._print_removed)").map(function(){var a=b(this),c=a.attr("style");return a.attr("style",""),{el:this,style:c}}),f=b('<style id="_print_controls_printstylesheet">').text(h).appendTo("head");d.stylize=!0,c.push(function(){d.stylize=!1,f.remove(),a.appendTo("head"),e.each(function(){b(this.el).attr("style",this.style)})})}}).appendTo(i),b('<div class="_print_controls_close">').click(function(){b("._print_controls, #_print_controls_styles").remove()}).appendTo(i),b('<div class="_print_controls_undo">').click(function(){var a=c.pop();a&&("function"!=typeof a?a.removeClass("_print_removed"):a.call())}).appendTo(i),b("._print_controls_remove_graphics, ._print_controls_print, ._print_controls_undo, ._print_controls_stylize").bind("mousedown",function(){b(this).addClass("active")}).bind("mouseleave mouseup",function(){b(this).removeClass("active")})} \ No newline at end of file
diff --git a/demo/images/printliminator2.png b/printliminator.png
index d117275..d117275 100644
--- a/demo/images/printliminator2.png
+++ b/printliminator.png
Binary files differ
diff --git a/src/bookmarklet.js b/src/bookmarklet.js
new file mode 100644
index 0000000..7185f8c
--- /dev/null
+++ b/src/bookmarklet.js
@@ -0,0 +1,27 @@
+// uncompressed bookmarklet code
+(function () {
+ function loadScript(url, callback) {
+ var script = document.createElement('script'),
+ head = document.getElementsByTagName('head')[0],
+ done = false;
+ script.type = 'text/javascript';
+ script.src = url;
+ script.onload = script.onreadystatechange = function() {
+ if ( !done && ( !this.readyState || this.readyState == 'loaded' || this.readyState == 'complete' ) ) {
+ done = true;
+ callback();
+ }
+ };
+ head.appendChild(script);
+ }
+ // dev = http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js
+ // production = //ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
+ loadScript('{jQuery}', function() {
+ var jQ132 = jQuery.noConflict();
+ // dev = src/printliminator.js
+ // production = //css-tricks.github.io/The-Printliminator/printliminator.min.js
+ loadScript('{printliminator}', function() {
+ csstricksPrintliminator( jQ132 );
+ });
+ });
+})();
diff --git a/src/index.html b/src/index.html
new file mode 100644
index 0000000..5034aa9
--- /dev/null
+++ b/src/index.html
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <title>The Printliminator</title>
+ <link rel="stylesheet" href="demo/css/style.css">
+</head>
+
+<body>
+
+<!-- src -->
+
+ <div id="demo-top-bar">
+ <div id="demo-bar-inside">
+ <h2 id="demo-bar-badge">
+ <a href="/">CSS-Tricks Example</a>
+ </h2>
+ <div id="demo-bar-buttons"></div>
+ </div>
+ </div>
+
+ <div id="page-wrap">
+
+ <h1>The Printliminator<span id="dev-mode"></span></h1>
+
+ <p>The Printliminator is a bookmarklet with some simple tools you can use
+ to makes websites print better. One click to activate, and then click to remove
+ elements from the page, remove graphics, and apply better print styling.
+ Here is the bookmarklet:</p>
+
+ <p>
+ <a href="javascript:/*PRINTLIMINATOR*/{production}" id="bookmarklet" class="bookmarklet">Printliminator</a>
+ <span class="drag-arrow"><strong>&larr;</strong> drag to your bookmarks bar</span>
+ </p>
+
+ <h2>Video Demo</h2>
+
+ <p>We used to have a quick video demo here, but Blip.tv deleted it. RUDE. Here's one we found on YouTube about it.</p>
+
+ <iframe width="500" height="320" src="http://www.youtube.com/embed/TAoRvdZaFPk" frameborder="0" allowfullscreen></iframe>
+
+ <h2>Credits</h2>
+
+ <p>By <a href="http://chriscoyier.net">Chris Coyier</a> and <a href="http://devongovett.wordpress.com/">Devon Govett</a>.
+ Icons by <a href="http://wefunction.com/2008/07/function-free-icon-set/">Function</a>.
+ Print stylesheet based on <a href="http://code.google.com/p/hartija/">Hartija</a>.</p>
+
+ </div>
+
+ <script>
+ // file loaded locally, switch to local version for development
+ ( function() {
+ if ( window.location.origin === 'file://' ) {
+ var link = document.getElementById( 'bookmarklet' );
+ link.href = "javascript:/*PRINTLIMINATOR*/{dev}";
+ document.getElementById('dev-mode').textContent = '(Dev Mode)';
+ }
+ })();
+ </script>
+
+ </body>
+
+</html>
diff --git a/js/printliminator.js b/src/printliminator.js
index acce311..12df31a 100644
--- a/js/printliminator.js
+++ b/src/printliminator.js
@@ -5,18 +5,20 @@ function csstricksPrintliminator( jQ ) {
history = [],
flags = {},
dont = false,
+ // if local, load local sprite image
+ sprite = ( window.location.origin === 'file://' ? '' : '//css-tricks.github.io/The-Printliminator/' ) +
+ 'printliminator.png',
// programmically added stylesheets
- root = '', // '//css-tricks.com/examples/ThePrintliminator/';
styles = '' +
'._print_controls { position: fixed; top: 25px; right: 25px; width: 162px; height: 182px; z-index: 10000;' +
'-moz-user-select: none; -webkit-user-select: none; -ms-user-select: none;' +
- 'background: url(' + root + 'images/printliminator2.png) no-repeat; }' +
+ 'background: url(' + sprite + ') no-repeat; }' +
'._print_controls_close { position: absolute; top: -20px; right: -20px; width: 33px; height: 33px;' +
- 'background: url(' + root + 'images/printliminator2.png) -222px -3px no-repeat; }' +
+ 'background: url(' + sprite + ') -222px -3px no-repeat; }' +
'._print_controls_close:hover { background-position: -222px -39px; }' +
'._print_controls_remove_graphics, ._print_controls_print, ._print_controls_undo, ._print_controls_stylize {' +
'position: absolute; height: 74px; width: 74px;' +
- 'background: url(' + root + 'images/printliminator2.png) no-repeat; }' +
+ 'background: url(' + sprite + ') no-repeat; }' +
'._print_controls_remove_graphics { top: 6px; left: 6px; background-position: 0px -182px; }' +
'._print_controls_remove_graphics:hover { background-position: 0 -256px; }' +
'._print_controls_remove_graphics.active { background-position: 0 -330px; }' +