123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- /**
- * jQuery printPage Plugin
- * @version: 1.0
- * @author: Cedric Dugas, http://www.position-absolute.com
- * @licence: MIT
- * @desciption: jQuery page print plugin help you print your page in a better way
- */
- (function( $ ){
- $.fn.printPage = function(options) {
- // EXTEND options for this button
- var pluginOptions = {
- attr : "href",
- url : false,
- message: "Please wait while we create your document"
- };
- $.extend(pluginOptions, options);
- this.on("click", function(){ loadPrintDocument(this, pluginOptions); return false; });
-
- /**
- * Load & show message box, call iframe
- * @param {jQuery} el - The button calling the plugin
- * @param {Object} pluginOptions - options for this print button
- */
- function loadPrintDocument(el, pluginOptions){
- $("body").append(components.messageBox(pluginOptions.message));
- $("#printMessageBox").css("opacity", 0);
- $("#printMessageBox").animate({opacity:1}, 300, function() { addIframeToPage(el, pluginOptions); });
- }
- /**
- * Inject iframe into document and attempt to hide, it, can't use display:none
- * You can't print if the element is not dsplayed
- * @param {jQuery} el - The button calling the plugin
- * @param {Object} pluginOptions - options for this print button
- */
- function addIframeToPage(el, pluginOptions){
- var url = (pluginOptions.url) ? pluginOptions.url : $(el).attr(pluginOptions.attr);
- if(!$('#printPage')[0]){
- $("body").append(components.iframe(url));
- $('#printPage').on("load",function() { printit(); })
- }else{
- $('#printPage').attr("src", url);
- }
- }
- /*
- * Call the print browser functionnality, focus is needed for IE
- */
- function printit(){
- frames["printPage"].focus();
- frames["printPage"].print();
- unloadMessage();
- }
- /*
- * Hide & Delete the message box with a small delay
- */
- function unloadMessage(){
- $("#printMessageBox").delay(1000).animate({opacity:0}, 700, function(){
- $(this).remove();
- });
- }
- /*
- * Build html compononents for thois plugin
- */
- var components = {
- iframe: function(url){
- return '<iframe id="printPage" name="printPage" src='+url+' style="position:absolute;top:0px; left:0px;width:0px; height:0px;border:0px;overfow:none; z-index:-1"></iframe>';
- },
- messageBox: function(message){
- return "<div id='printMessageBox' style='\
- position:fixed;\
- top:50%; left:50%;\
- text-align:center;\
- margin: -60px 0 0 -155px;\
- width:310px; height:120px; font-size:16px; padding:10px; color:#222; font-family:helvetica, arial;\
- opacity:0;\
- background:#fff url(data:image/gif;base64,R0lGODlhZABkAOYAACsrK0xMTIiIiKurq56enrW1ta6urh4eHpycnJSUlNLS0ry8vIODg7m5ucLCwsbGxo+Pj7a2tqysrHNzc2lpaVlZWTg4OF1dXW5uboqKigICAmRkZLq6uhEREYaGhnV1dWFhYQsLC0FBQVNTU8nJyYyMjFRUVCEhIaCgoM7OztDQ0Hx8fHh4eISEhEhISICAgKioqDU1NT4+PpCQkLCwsJiYmL6+vsDAwJKSknBwcDs7O2ZmZnZ2dpaWlrKysnp6emxsbEVFRUpKSjAwMCYmJlBQUBgYGPX19d/f3/n5+ff39/Hx8dfX1+bm5vT09N3d3fLy8ujo6PDw8Pr6+u3t7f39/fj4+Pv7+39/f/b29svLy+/v7+Pj46Ojo+Dg4Pz8/NjY2Nvb2+rq6tXV1eXl5cTExOzs7Nra2u7u7qWlpenp6c3NzaSkpJqamtbW1uLi4qKiovPz85ubm6enp8zMzNzc3NnZ2eTk5Kampufn597e3uHh4crKyv7+/gAAAP///yH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS4wLWMwNjAgNjEuMTM0Nzc3LCAyMDEwLzAyLzEyLTE3OjMyOjAwICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vb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AQ0DnOHABEYQQSLgBjS6oZyQBHVwAS5wAUQAUFfDEFRABAFQAS6gAKNUo59QC0lgB/SzAjJQBwWiBCKAATxQAWPwmka6CUnABQzwAV2wA1KQpveQBSyAAizAA2eQBDvho5ZAC95gAB+ABxngBGVVWTJ5qIhqWX8QByVgABPQBVGwXi36CUnwBDDQOa+ZqJq6qTkhkm1QB4VlXTYqEkhKAC8wb+eRAALgBnGgE3yaCbpWBVvQAAgAGIKUFLiaq7pKFAOAB2igBK/aCWZ1BgQgANajOruSrMq6rMz6KS1QAyqgBJ7FE7TgBHmwNW7AN9q6rVxzBnngBMAVOaye4Fl1lQS5c67omq7qmjvmKp9WIa4FEg75QAu+Q62KVSCbmq+JGq+5ZhxPyq8AG7ACO7AEKwiBAAA7) center 40px no-repeat;\
- border: 6px solid #555;\
- border-radius:8px; -webkit-border-radius:8px; -moz-border-radius:8px;\
- box-shadow:0px 0px 10px #888; -webkit-box-shadow:0px 0px 10px #888; -moz-box-shadow:0px 0px 10px #888'>\
- "+message+"</div>";
- }
- }
- };
- })( jQuery );
|