1/* @license 2 * jQuery.print, version 1.5.1 3 * (c) Sathvik Ponangi, Doers' Guild 4 * Licence: CC-By (http://creativecommons.org/licenses/by/3.0/) 5 *--------------------------------------------------------------------------*/ 6(function($){"use strict";function getjQueryObject(string){var jqObj=$("");try{jqObj=$(string).clone()}catch(e){jqObj=$("<span />").html(string)} 7return jqObj} 8function printFrame(frameWindow,content,options){var def=$.Deferred();try{frameWindow=frameWindow.contentWindow||frameWindow.contentDocument||frameWindow;var wdoc=frameWindow.document||frameWindow.contentDocument||frameWindow;if(options.doctype){wdoc.write(options.doctype)} 9wdoc.write(content);wdoc.close();var printed=!1;var callPrint=function(){if(printed){return} 10frameWindow.focus();try{if(!frameWindow.document.execCommand('print',!1,null)){frameWindow.print()} 11$('body').focus()}catch(e){frameWindow.print()} 12frameWindow.close();printed=!0;def.resolve()} 13$(frameWindow).on("load",callPrint);setTimeout(callPrint,options.timeout)}catch(err){def.reject(err)} 14return def} 15function printContentInIFrame(content,options){var $iframe=$(options.iframe+"");var iframeCount=$iframe.length;if(iframeCount===0){$iframe=$('<iframe height="0" width="0" border="0" wmode="Opaque"/>').prependTo('body').css({"position":"absolute","top":-999,"left":-999})} 16var frameWindow=$iframe.get(0);return printFrame(frameWindow,content,options).done(function(){setTimeout(function(){if(iframeCount===0){$iframe.remove()}},1000)}).fail(function(err){console.error("Failed to print from iframe",err);printContentInNewWindow(content,options)}).always(function(){try{options.deferred.resolve()}catch(err){console.warn('Error notifying deferred',err)}})} 17function printContentInNewWindow(content,options){var frameWindow=window.open();return printFrame(frameWindow,content,options).always(function(){try{options.deferred.resolve()}catch(err){console.warn('Error notifying deferred',err)}})} 18function isNode(o){return!!(typeof Node==="object"?o instanceof Node:o&&typeof o==="object"&&typeof o.nodeType==="number"&&typeof o.nodeName==="string")} 19$.print=$.fn.print=function(){var options,$this,self=this;if(self instanceof $){self=self.get(0)} 20if(isNode(self)){$this=$(self);if(arguments.length>0){options=arguments[0]}}else{if(arguments.length>0){$this=$(arguments[0]);if(isNode($this[0])){if(arguments.length>1){options=arguments[1]}}else{options=arguments[0];$this=$("html")}}else{$this=$("html")}} 21var defaults={globalStyles:!0,mediaPrint:!1,stylesheet:null,noPrintSelector:".no-print",iframe:!0,append:null,prepend:null,manuallyCopyFormValues:!0,deferred:$.Deferred(),timeout:750,title:null,doctype:'<!doctype html>'};options=$.extend({},defaults,(options||{}));var $styles=$("");if(options.globalStyles){$styles=$("style, link, meta, base, title")}else if(options.mediaPrint){$styles=$("link[media=print]")} 22if(options.stylesheet){$styles=$.merge($styles,$('<link rel="stylesheet" href="'+options.stylesheet+'">'))} 23var copy=$this.clone();copy=$("<span/>").append(copy);copy.find(options.noPrintSelector).remove();copy.append($styles.clone());if(options.title){var title=$("title",copy);if(title.length===0){title=$("<title />");copy.append(title)} 24title.text(options.title)} 25copy.append(getjQueryObject(options.append));copy.prepend(getjQueryObject(options.prepend));if(options.manuallyCopyFormValues){copy.find("input").each(function(){var $field=$(this);if($field.is("[type='radio']")||$field.is("[type='checkbox']")){if($field.prop("checked")){$field.attr("checked","checked")}}else{$field.attr("value",$field.val())}});copy.find("select").each(function(){var $field=$(this);$field.find(":selected").attr("selected","selected")});copy.find("textarea").each(function(){var $field=$(this);$field.text($field.val())})} 26var content=copy.html();try{options.deferred.notify('generated_markup',content,copy)}catch(err){console.warn('Error notifying deferred',err)} 27copy.remove();if(options.iframe){try{printContentInIFrame(content,options)}catch(e){console.error("Failed to print from iframe",e.stack,e.message);printContentInNewWindow(content,options)}}else{printContentInNewWindow(content,options)} 28return this}})(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.