PageSourceSearch

https://daemyungresort.com/jquery/plugin/jquery.print-preview.js

js daemyungresort.com collected 2026-10-02 11:21:09 UTC 8,017 bytes, 208 lines download raw bytes

1/*!
2 * jQuery Print Previw Plugin v1.0.1
3 *
4 * Copyright 2011, Tim Connell
5 * Licensed under the GPL Version 2 license
6 * http://www.gnu.org/licenses/gpl-2.0.html
7 *
8 * Date: Wed Jan 25 00:00:00 2012 -000
9 */
10 
11(function($){ 
12	// Initialization
13	$.fn.printPreview = function() {
14		this.each(function() {
15			$(this).bind('click', function(e) {
16			    e.preventDefault();
17			    if (!$('#print-modal').length) {
18			        $.printPreview.loadPrintPreview();
19			    }
20			});
21		});
22		return this;
23	};
24    
25    // Private functions
26    var mask, size, print_modal, print_controls;
27    $.printPreview = {
28        loadPrintPreview: function() {
29            // Declare DOM objects
30            print_modal = $('<div id="print-modal"></div>');
31            print_controls = $('<div id="print-modal-controls">' + 
32                                    '<a href="#" class="print" title="Print page">Print page</a>' +
33                                    '<a href="#" class="close" title="Close print preview">Close</a>').hide();
34            var print_frame = $('<iframe id="print-modal-content" scrolling="no" border="0" frameborder="0" name="print-frame" />');
35
36            // Raise print preview window from the dead, zooooooombies
37            print_modal
38                .hide()
39                .append(print_controls)
40                .append(print_frame)
41                .appendTo('body');
42
43            // The frame lives
44            for (var i=0; i < window.frames.length; i++) {
45                if (window.frames[i].name == "print-frame") {    
46                    var print_frame_ref = window.frames[i].document;
47                    break;
48                }
49            }
50            print_frame_ref.open();
51            print_frame_ref.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
52                '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">' + 
53                '<head><title>' + document.title + '</title></head>' +
54                '<body></body>' +
55                '</html>');
56            print_frame_ref.close();
57            
58            var $iframe_head = $('head link[media*=print], head link[media=all]').clone();
59            var $iframe_body = $('body > *:not(#print-modal):not(script)').clone();
60            
61            $($iframe_body).find(".sidemenu").remove().end();
62            $($iframe_body).find(".sidebg").remove().end();
63            $($iframe_body).find("#side_menu").remove().end();
64            $($iframe_body).find(".header").remove().end();
65            $($iframe_body).find("#footer").remove().end();
66            
67            //관리자 안나와도 될 부분 삭제
68            $($iframe_body).find("#header").remove().end();
69            $($iframe_body).find("#menuListForm").remove().end();
70            $($iframe_body).find("#snb").remove().end();
71            
72            $iframe_head.each(function() {
73                $(this).attr('media', 'all');
74            });
75            //if (!$.browser.msie && !($.browser.version < 7) ) {
76            if(BrowserDetect.browser != 'MSIE' && BrowserDetect.version > 6){            
77                $('head', print_frame_ref).append($iframe_head);
78                $('body', print_frame_ref).append($iframe_body);
79            }else{
80/*                $('body > *:not(#print-modal):not(script)').clone().each(function() {
81                    $('body', print_frame_ref).append(this.outerHTML);
82                });*/
83            	$('body', print_frame_ref).append($iframe_body);
84            	
85                $('head link[media*=print], head link[media=all]').each(function() {
86                    $('head', print_frame_ref).append($(this).clone().attr('media', 'all')[0].outerHTML);
87                });
88            }
89            
90            // Disable all links
91            $('a', print_frame_ref).bind('click.printPreview', function(e) {
92                e.preventDefault();
93            });
94            
95            // Introduce print styles
96            $('head').append('<style type="text/css">' +
97                '@media print {' +
98                    '/* -- Print Preview --*/' +
99                    '#print-modal-mask,' +
100                    '#print-modal {' +
101                        'display: none !important;' +
102                    '}' +
103                '}' +
104                '</style>'
105            );
106
107            // Load mask
108            $.printPreview.loadMask();
109
110            // Disable scrolling
111            $('body').css({overflowY: 'hidden', height: '100%'});
112            $('img', print_frame_ref).load(function() {
113                print_frame.height($('body', print_frame.contents())[0].scrollHeight);
114            });
115            
116            // Position modal            
117            starting_position = $(window).height() + $(window).scrollTop();
118            var css = {
119                    top:         starting_position,
120                    height:      '100%',
121                    overflowY:   'auto',
122                    zIndex:      10000,
123                    display:     'block'
124                };
125            print_modal
126                .css(css)
127                .animate({ top: $(window).scrollTop()}, 400, 'linear', function() {
128                    print_controls.fadeIn('slow').focus();
129                });
130            print_frame.height($('body', print_frame.contents())[0].scrollHeight);
131            
132            // Bind closure
133            $('a', print_controls).bind('click', function(e) {
134                e.preventDefault();
135                if ($(this).hasClass('print')){
136            		frames["print-frame"].focus();
137            		frames["print-frame"].print();
138                }else{
139                	$.printPreview.distroyPrintPreview(); 
140            	}
141            });
142    	},
143    	
144    	distroyPrintPreview: function() {
145    	    print_controls.fadeOut(100);
146    	    print_modal.animate({ top: $(window).scrollTop() - $(window).height(), opacity: 1}, 400, 'linear', function(){
147    	        print_modal.remove();
148    	        $('body').css({overflowY: 'auto', height: 'auto'});
149    	    });
150    	    mask.fadeOut('slow', function()  {
151    			mask.remove();
152    		});				
153
154    		$(document).unbind("keydown.printPreview.mask");
155    		mask.unbind("click.printPreview.mask");
156    		$(window).unbind("resize.printPreview.mask");
157	    },
158	    
159    	/* -- Mask Functions --*/
160	    loadMask: function() {
161	        size = $.printPreview.sizeUpMask();
162            mask = $('<div id="print-modal-mask" />').appendTo($('body'));
163    	    mask.css({				
164    			position:           'absolute', 
165    			top:                0, 
166    			left:               0,
167    			width:              size[0],
168    			height:             size[1],
169    			display:            'none',
170    			opacity:            0,					 		
171    			zIndex:             9999,
172    			backgroundColor:    '#000'
173    		});
174	
175    		mask.css({display: 'block'}).fadeTo('400', 0.75);
176    		
177            $(window).bind("resize..printPreview.mask", function() {
178				$.printPreview.updateMaskSize();
179			});
180			
181			mask.bind("click.printPreview.mask", function(e)  {
182				$.printPreview.distroyPrintPreview();
183			});
184			
185			$(document).bind("keydown.printPreview.mask", function(e) {
186			    if (e.keyCode == 27) {  $.printPreview.distroyPrintPreview(); }
187			});
188        },
189    
190        sizeUpMask: function() {
191            if ($.browser.msie) {
192            	// if there are no scrollbars then use window.height
193            	var d = $(document).height(), w = $(window).height();
194            	return [
195            		window.innerWidth || 						// ie7+
196            		document.documentElement.clientWidth || 	// ie6  
197            		document.body.clientWidth, 					// ie6 quirks mode
198            		d - w < 20 ? w : d
199            	];
200            } else { return [$(document).width(), $(document).height()]; }
201        },
202    
203        updateMaskSize: function() {
204    		var size = $.printPreview.sizeUpMask();
205    		mask.css({width: size[0], height: size[1]});
206        }
207    };
208})(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.