PageSourceSearch

https://www.uljin.go.kr/js/printThis.js

js uljin.go.kr collected 2026-10-02 05:50:44 UTC 6,089 bytes, 146 lines download raw bytes

vendor: 6,089 bytes, lines 1-146
1/*
2* printThis v1.2
3* @desc Printing plug-in for jQuery
4* @author Jason Day
5* 
6* Resources (based on) :
7*              jPrintArea: http://plugins.jquery.com/project/jPrintArea
8*              jqPrint: https://github.com/permanenttourist/jquery.jqprint
9*              Ben Nadal: http://www.bennadel.com/blog/1591-Ask-Ben-Print-Part-Of-A-Web-Page-With-jQuery.htm
10*
11* Dual licensed under the MIT and GPL licenses:
12*              http://www.opensource.org/licenses/mit-license.php
13*              http://www.gnu.org/licenses/gpl.html
14*
15* (c) Jason Day 2013
16*
17* Usage:
18*
19*  $("#mySelector").printThis({
20*      debug: false,              * show the iframe for debugging
21*      importCSS: true,           * import page CSS
22*      printContainer: true,      * grab outer container as well as the contents of the selector
23*      loadCSS: "path/to/my.css", * path to additional css file
24*      pageTitle: "",             * add title to print page
25*      removeInline: false        * remove all inline styles from print elements
26*  });
27*
28* Notes:
29*  - the loadCSS will load additional css (with or without @media print) into the iframe, adjusting layout
30*/
31;(function ($) {
32    var opt;
33    $.fn.printThis = function (options) {
34        opt = $.extend({}, $.fn.printThis.defaults, options);
35        var $element = this instanceof jQuery ? this : $(this);
36        
37            var strFrameName = "printThis-" + (new Date()).getTime();
38
39            if(window.location.hostname !== document.domain && navigator.userAgent.match(/msie/i)){
40                // Ugly IE hacks due to IE not inheriting document.domain from parent
41                // checks if document.domain is set by comparing the host name against document.domain
42                var iframeSrc = "javascript:document.write(\"<head><script>document.domain=\\\"" + document.domain + "\\\";</script></head><body></body>\")";
43                var printI= document.createElement('iframe');
44                printI.name = "printIframe";
45                printI.id = strFrameName;
46                printI.className = "MSIE";
47                document.body.appendChild(printI);
48                printI.src = iframeSrc;
49                
50            } else {
51                 // other browsers inherit document.domain, and IE works if document.domain is not explicitly set
52                var $frame = $("<iframe id='" + strFrameName +"' name='printIframe' />");
53                $frame.appendTo("body");
54            }
55            
56                       
57            var $iframe = $("#" + strFrameName);
58            
59            // show frame if in debug mode
60            if (!opt.debug) $iframe.css({
61                position: "absolute",
62                width: "0px",
63                height: "0px",
64                left: "-600px",
65                top: "-600px"
66            });
67            
68            
69        // $iframe.ready() and $iframe.load were inconsistent between browsers    
70        setTimeout ( function () {
71            
72            var $doc = $iframe.contents();
73            
74            // import page stylesheets
75            if (opt.importCSS) $("link[rel=stylesheet]").each(function () {
76                var href = $(this).attr("href");
77                if (href) {
78                    var media = $(this).attr("media") || "all";
79                    $doc.find("head").append("<link type='text/css' rel='stylesheet' href='" + href + "' media='" + media + "'>")
80                }
81            });
82            
83            //add title of the page
84            if (opt.pageTitle) $doc.find("head").append("<title>" + opt.pageTitle + "</title>");
85            
86            // import additional stylesheet
87            if (opt.loadCSS) $doc.find("head").append("<link type='text/css' rel='stylesheet' href='" + opt.loadCSS + "'>");
88            
89            // grab $.selector as container
90            if (opt.printContainer) $doc.find("body").append($element.outer());
91            
92            // otherwise just print interior elements of container
93            else $element.each(function () {
94                $doc.find("body").append($(this).html())
95            });
96            
97            // remove inline styles
98            if (opt.removeInline) {
99                // $.removeAttr available jQuery 1.7+
100                if ($.isFunction($.removeAttr)) {
101                    $doc.find("body *").removeAttr("style");
102                } else {
103                    $doc.find("body *").attr("style", "");
104                }
105            } 
106            
107            setTimeout(function () {
108                if($iframe.hasClass("MSIE")){
109                    // check if the iframe was created with the ugly hack
110                    // and perform another ugly hack out of neccessity
111                    window.frames["printIframe"].focus();
112                    $doc.find("head").append("<script>  window.print(); </script>");
113                } else {
114                    // proper method
115                    $iframe[0].contentWindow.focus();
116                    $iframe[0].contentWindow.print();  
117                }
118                
119                 //remove iframe after print
120                if (!opt.debug) {
121                    setTimeout(function () {
122                        $iframe.remove();
123                    }, 1000);
124                }
125                
126            }, 333);
127             
128        }, 333 );
129        
130    };
131    
132    // defaults
133    $.fn.printThis.defaults = {
134        debug: false,           // show the iframe for debugging
135        importCSS: true,        // import parent page css
136        printContainer: true,   // print outer container/$.selector
137        loadCSS: "",            // load an additional css file
138        pageTitle: "",          // add title to print page
139        removeInline: false     // remove all inline styles
140    };
141    
142    // $.selector container
143    jQuery.fn.outer = function () {
144        return $($("<div></div>").html(this.clone())).html()
145    }
146})(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.