1(function($) { 2 3 $.fn.printLink = function(options) { 4 var iframe = null; 5 var settings = $.extend({ 6 url: null 7 }, options); 8 9 // Apply to all elements 10 return this.each(function() { 11 12 // Click handler on the link 13 $(this).on('click', function(event) { 14 event.preventDefault(); 15 16 // Target element 17 var element = $(this); 18 19 // Get the url from the anchor or overwrite it 20 var url = element.attr('href'); 21 if(settings.url) { 22 url = settings.url; 23 } 24 25 // Open the url directly when an iframe printing is not supported. 26 if(navigator.userAgent.match(/opera/i) || navigator.userAgent.match(/trident/i) || (navigator.userAgent.match(/msie/i) && window.addEventListener)) { 27 element.trigger('printLinkError'); 28 return false; 29 } 30 31 // Trigger load 32 element.trigger('printLinkInit'); 33 34 // Print the url with a hidden iframe 35 if(!$('#printLinkIframe')[0]) { 36 // Create a new iframe 37 var iframe = '<iframe id="printLinkIframe" name="printLinkIframe" src=' + url + ' style="position:absolute;top:-9999px;left:-9999px;border:0px;overfow:none; z-index:-1"></iframe>'; 38 $('body').append(iframe); 39 40 // Start the printing when the url is loaded 41 $('#printLinkIframe').on('load',function() { 42 element.trigger('printLinkComplete'); 43 frames['printLinkIframe'].focus(); 44 frames['printLinkIframe'].print(); 45 }); 46 } else { 47 // Change the iframe src in case the iframe already exists 48 $('#printLinkIframe').attr('src', url); 49 } 50 }); 51 52 }); 53 54 return this; 55 }; 56 57}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.