Commit aacbbf1b authored by alexandre's avatar alexandre

L'interface graphique de HTML2print dans le bazar

parent b8489729
#viewport {
position: fixed;
top: 0;
bottom: 2em;
left: 0;
right: 0;
}
#toolbar {
position: fixed;
height: 2em;
bottom: 0em;
left: 0;
right: 0;
background-color: lightgrey;
}
iframe {
width: 100%;
height: 100%;
}
$(function() {
$('iframe').load(function() {
var doc = $("iframe").contents().find("html");
$('[name="preview"]').change(function() {
if($(this).is(":checked")) {
doc.addClass("preview");
doc.removeClass("normal");
} else {
doc.removeClass("preview");
doc.addClass("normal");
}
});
$('[name="debug"]').change(function() {
if($(this).is(":checked")) {
doc.addClass("debug");
} else {
doc.removeClass("debug");
}
});
$('[name="spread"]').change(function() {
if($(this).is(":checked")) {
doc.addClass("spread");
} else {
doc.removeClass("spread");
}
});
//$('[name="hi-res"]').change(function() {
//if($(this).is(":checked")) {
//doc.addClass("export");
//} else {
//doc.removeClass("export");
//}
//});
$('[name="zoom"]').change(function() {
zoomLevel = $(this).val() / 100;
doc.find("#pages").css({
"-webkit-transform": "scale(" + zoomLevel + ")",
"-webkit-transform-origin": "0 0"
});
});
//$(".paper").each(function(){
//page = $(this).attr("id");
//$("#toc-pages").append("<li><a href='#" + page + "'>" + page.replace("-", " ") + "</a></li>")
//});
$('[name="page"]').change(function() {
var pageNumber = $(this).val() - 1;
var target = doc.find('.paper:eq(' + pageNumber + ')');
var offsetTop = target.offset().top;
doc.find('body').scrollTop(offsetTop);
});
$("#print").on('click', function() {
$("iframe").get(0).contentWindow.print();
});
});
//// __________________________________ HIGH RESOLUTION __________________________________ //
//$("#hi-res").click(function(e){
//e.preventDefault();
//$(this).toggleClass("button-active");
//$("html").toggleClass("export");
//$("img").each(function(){
//var hires = $(this).attr("data-alt-src");
//var lores = $(this).attr("src");
//$(this).attr("data-alt-src", lores)
//$(this).attr("src", hires)
//});
//console.log("Wait for hi-res images to load");
//window.setTimeout(function(){
//console.log("Check image resolution");
//// Redlights images too small for printing
//$("img").each(function(){
//if (Math.ceil(this.naturalHeight / $(this).height()) < 3) {
//console.log($(this).attr("src") + ": " + Math.floor(this.naturalHeight / $(this).height()) );
//if($(this).parent().hasClass("moveable")) {
//$(this).parent().toggleClass("lo-res");
//} else {
//$(this).toggleClass("lo-res");
//}
//}
//});
//}, 2000);
//});
});
//(function($) {
//'use strict';
//$('iframe')[0].addEventListener("load", function(event) {
//console.log(arguments);
//}, false);
//})(document.querySelectorAll.bind(document));
......@@ -16,6 +16,7 @@
"tests"
],
"dependencies": {
"less": "~2.5.1"
"less": "~2.5.1",
"jquery": "~2.1.4"
}
}
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>HTML2print</title>
<link rel="stylesheet" href="assets/css/gui.css" media="screen">
</head>
<body>
<div id="viewport">
<iframe src="doc.html"></iframe>
</div>
<div id="toolbar">
<input name="preview" value="true" type="checkbox">
<label for="preview">preview</label>
<input name="debug" value="true" type="checkbox">
<label for="debug">debug</label>
<input name="spread" value="true" type="checkbox">
<label for="spread">spread</label>
<input name="hi-res" value="true" type="checkbox">
<label for="hi-res">hi-res</label>
<input name="zoom" value="100" type="number" min="25" max="1600" step="25">
<label for="zoom">zoom</label>
<select name="page">
<option value="1">1</option>
<option value="2">2</option>
</select>
<label for="page">page</label>
<button id="print">print</button>
</div>
<!-- JAVASCRIPT -->
<script type="text/javascript" src="assets/components/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="assets/js/gui.js"></script>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment