2011-07-16 20:59:15 +04:00
|
|
|
/*
|
2011-09-12 22:35:37 +04:00
|
|
|
* html2canvas v0.30 <http://html2canvas.hertzen.com>
|
2011-07-16 20:59:15 +04:00
|
|
|
* Copyright (c) 2011 Niklas von Hertzen. All rights reserved.
|
|
|
|
* http://www.twitter.com/niklasvh
|
|
|
|
*
|
|
|
|
* Released under MIT License
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The MIT License
|
|
|
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* jQuery helper plugin for examples and tests
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function( $ ){
|
2011-07-21 04:12:17 +04:00
|
|
|
$.fn.html2canvas = function(options) {
|
2011-07-16 20:59:15 +04:00
|
|
|
|
|
|
|
var date = new Date();
|
|
|
|
var message,
|
|
|
|
timeoutTimer,
|
|
|
|
timer = date.getTime();
|
2011-09-12 22:35:37 +04:00
|
|
|
|
|
|
|
var preload = html2canvas.Preload(this[0], {
|
|
|
|
"complete": function(images){
|
|
|
|
|
|
|
|
var queue = html2canvas.Parse(this[0], images);
|
|
|
|
|
|
|
|
|
|
|
|
var canvas = $(html2canvas.Renderer(queue));
|
|
|
|
var finishTime = new Date();
|
|
|
|
|
|
|
|
|
|
|
|
canvas.css('position','absolute')
|
|
|
|
.css('left',0).css('top',0);
|
|
|
|
$('body').append(canvas);
|
|
|
|
$(canvas).siblings().toggle();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(window).click(function(){
|
|
|
|
if (!canvas.is(':visible')){
|
|
|
|
$(canvas).toggle().siblings().toggle();
|
|
|
|
throwMessage("Canvas Render visible");
|
|
|
|
} else{
|
|
|
|
$(canvas).siblings().toggle();
|
|
|
|
$(canvas).toggle();
|
|
|
|
throwMessage("Canvas Render hidden");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
throwMessage('Screenshot created in '+ ((finishTime.getTime()-timer)/1000) + " seconds<br />",4000);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
var date = new Date();
|
|
|
|
var message,
|
|
|
|
timeoutTimer,
|
|
|
|
timer = date.getTime();
|
2011-07-16 20:59:15 +04:00
|
|
|
|
2011-07-21 04:12:17 +04:00
|
|
|
var object = $.extend({},{
|
|
|
|
logging: false,
|
|
|
|
proxyUrl: "http://html2canvas.appspot.com/", // running html2canvas-python proxy
|
2011-07-17 03:42:45 +04:00
|
|
|
ready: function(renderer) {
|
2011-07-16 20:59:15 +04:00
|
|
|
|
|
|
|
var finishTime = new Date();
|
|
|
|
// console.log((finishTime.getTime()-timer)/1000);
|
|
|
|
|
2011-07-17 03:42:45 +04:00
|
|
|
|
|
|
|
document.body.appendChild(renderer.canvas);
|
|
|
|
|
|
|
|
|
2011-07-16 20:59:15 +04:00
|
|
|
|
2011-07-17 03:42:45 +04:00
|
|
|
var canvas = $(renderer.canvas);
|
2011-07-16 20:59:15 +04:00
|
|
|
canvas.css('position','absolute')
|
|
|
|
.css('left',0).css('top',0);
|
2011-07-17 03:42:45 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-07-16 20:59:15 +04:00
|
|
|
// $('body').append(canvas);
|
|
|
|
$(canvas).siblings().toggle();
|
2011-07-17 03:42:45 +04:00
|
|
|
|
|
|
|
throwMessage('Screenshot created in '+ ((finishTime.getTime()-timer)/1000) + " seconds<br />Total of "+renderer.numDraws+" draws performed",4000);
|
|
|
|
|
|
|
|
|
2011-07-16 20:59:15 +04:00
|
|
|
$(window).click(function(){
|
|
|
|
if (!canvas.is(':visible')){
|
|
|
|
$(canvas).toggle().siblings().toggle();
|
|
|
|
throwMessage("Canvas Render visible");
|
|
|
|
} else{
|
|
|
|
$(canvas).siblings().toggle();
|
|
|
|
$(canvas).toggle();
|
|
|
|
throwMessage("Canvas Render hidden");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-07-21 04:12:17 +04:00
|
|
|
},options)
|
|
|
|
|
|
|
|
new html2canvas(this.get(0), object);
|
2011-07-16 20:59:15 +04:00
|
|
|
|
2011-09-12 22:35:37 +04:00
|
|
|
*/
|
2011-07-16 20:59:15 +04:00
|
|
|
|
2011-07-17 03:42:45 +04:00
|
|
|
function throwMessage(msg,duration){
|
|
|
|
|
2011-07-16 20:59:15 +04:00
|
|
|
window.clearTimeout(timeoutTimer);
|
|
|
|
timeoutTimer = window.setTimeout(function(){
|
|
|
|
message.fadeOut(function(){
|
|
|
|
message.remove();
|
|
|
|
});
|
2011-07-17 03:42:45 +04:00
|
|
|
},duration || 2000);
|
2011-07-16 20:59:15 +04:00
|
|
|
$(message).remove();
|
2011-07-17 03:42:45 +04:00
|
|
|
message = $('<div />').html(msg).css({
|
2011-07-16 20:59:15 +04:00
|
|
|
margin:0,
|
|
|
|
padding:10,
|
|
|
|
background: "#000",
|
|
|
|
opacity:0.7,
|
|
|
|
position:"fixed",
|
|
|
|
top:10,
|
|
|
|
right:10,
|
|
|
|
fontFamily: 'Tahoma' ,
|
|
|
|
color:'#fff',
|
|
|
|
fontSize:12,
|
|
|
|
borderRadius:12,
|
|
|
|
width:'auto',
|
2011-07-16 23:35:21 +04:00
|
|
|
height:'auto',
|
2011-07-17 03:42:45 +04:00
|
|
|
textAlign:'center',
|
2011-07-16 23:35:21 +04:00
|
|
|
textDecoration:'none'
|
2011-07-16 20:59:15 +04:00
|
|
|
}).hide().fadeIn().appendTo('body');
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
2011-09-12 22:35:37 +04:00
|
|
|
|
2011-07-16 20:59:15 +04:00
|
|
|
})( jQuery );
|
|
|
|
|