PageSourceSearch

https://www.miryang.go.kr/js/egovframework/common/common.msgPopup.js

js miryang.go.kr collected 2026-10-02 16:40:40 UTC 11,965 bytes, 352 lines download raw bytes

1;(function($, window, document, undefined)
2{
3
4	var defaults = {
5				title       						: "Notice"												//  레이어 팝업 타이틀
6    			, width								: "280"																//  처음 창 크기
7	        	, height							: "130"																//  처음 창 크기
8	        	, min_width							: "500"																//  구현 안됬음 * 차후, 모바일 지원용
9        		, min_height						: "300"																//  구현 안됬음 * 차후, 모바일 지원용
10        		, max_width							: "1400"															//  큰창 크기
11        		, max_height						: "600"																//  큰창 크기
12    			, url								: ""																	//  URL  입력 **** 필수 조건
13    			, div_target						: ""
14	        	, parameter							: {}																	//  파라미터 입력 시 배열로 입력
15        		, top  								: "0"																	//  위치 값
16        		, left   							: "0"																	//  위치 값
17    			, returnObj							: null																	//  창이 닫혔을때 되돌아가는 객채 **** 필수 조건
18    			, UnderReset						: false																//  구현 안됬음
19    			, animate_open						: 0//"" 																//  창이 열릴때 속도(애니메이션 효과)
20    			, animate_close						: 0//"0"																//  창이 닫힐때 속도(애니메이션 효과)
21    			, animate_reload					: 0//"0"																//  구현 안됬음
22    			, animate_move						: "slow"															//  창 사이즈 변경시 자동 이동 됨, 이때의 애니메이션 효과
23
24    			, close_button_yn					: true
25    			, reload_button_yn					: true
26    			, minmaxsize_button_yn				: true
27    			, pageOnLoadCallBack				: null
28
29				, message : "Loading..."
30
31				, show_title : true
32				, back_click_close			:false
33				, scroll_fix : true
34        };
35
36    function Plugin( element, options)
37    {
38        this.content = null;
39        this.el = $(element);
40        this.options = $.extend({}, defaults, options);
41        this.init();
42
43    }
44
45    Plugin.prototype = {
46
47        init: function() {
48            var layer = this;
49            
50            layer.options.min_width  = layer.options.width;
51            layer.options.min_height  = layer.options.height;
52			
53			if(this.isNullOrBlank(layer.org_scroll)){
54				layer.org_scroll = {"overflow":$("body").css("overflow-x"),"overflowX":$("body").css("overflow-x"),"overflowY":$("body").css("overflow-y")};
55			}
56			layer.setScrollFixed();
57
58			if(this.isNullOrBlank(layer.options.returnObj) && !this.isNullOrBlank(latestFocus) ){
59				layer.options.returnObj = $(latestFocus);
60			}
61            
62            layer.drawWindow();
63            layer.showMsgPopup();
64            layer.setWindowResizing();
65
66
67			layer.pageLoad();           
68
69                    
70        }
71    
72	    , isNullOrBlank : function( val ){
73
74	    	if( typeof(val)=="undefined" || val == null || val == "" ) return true;
75	    	else return false;
76	    }
77	    
78	    , drawWindow : function(){
79	    	var layer = this;
80	    	layer.window = $( "<div class='layout-msgpop-wr' style='display:none;'></div>" );
81			layer.back = $("<span class='back'></span>");
82	    	layer.con_wrap = $( "<div class='msgpop-wr' tabindex='0'></div>" );
83	    	layer.con_head = $( "<div class='msgpop-tit'></div>" );
84	    	layer.con_title = $( "<em ></em>" );
85	    	layer.con_cont = $( "<div class='msgpop-cont'></div>" );
86			
87
88	    	
89	    	
90	    	layer.setTitle( layer.options.title );
91	    	layer.window.prepend(layer.back);
92	    	layer.con_head.append( layer.con_title );
93	    	layer.con_wrap.append( layer.con_head ).append( layer.con_cont ).append( layer.win_close_btn );
94	    	layer.window.append( layer.con_wrap );
95
96			if(this.options.cont_type=="iframe"){
97				layer.cont_frame = $("<iframe width='100%' height='98%' frameborder='0' scrolling='yes'></iframe>");
98				layer.cont_frame.appendTo(layer.con_cont);
99			}
100
101	    	
102	    	var btn_cnt = 1;
103	    	
104	    	// 닫기 버튼 생성
105	    	if( layer.options.close_button_yn ){
106		    	layer.win_close_btn = $( layer.options.close_button );
107		    	layer.con_wrap.append( layer.win_close_btn );
108		    	layer.win_close_btn.bind( "click", function(){
109		    		layer.closeMsgPopup();
110				});
111		    	layer.win_close_btn.addClass( "pop-btn-" + btn_cnt );
112		    	btn_cnt++;
113	    	}
114	    	
115	    	
116	    	// 리로드 버튼 생성
117	    	if( layer.options.reload_button_yn ){
118		    	layer.win_reload_btn = $( layer.options.reload_button );
119		    	layer.con_wrap.append( layer.win_reload_btn );
120		    	layer.win_reload_btn.bind( "click", function(){
121		    		layer.reload();
122				});
123		    	layer.win_reload_btn.addClass( "pop-btn-" + btn_cnt );
124		    	btn_cnt++;
125	    	}
126	    	
127	    	// 창크키 조절 버튼 생성
128	    	if( layer.options.minmaxsize_button_yn ){
129		    	layer.win_minsize_btn = $( layer.options.minsize_button );
130		    	layer.win_maxsize_btn = $( layer.options.maxsize_button );
131		    	layer.con_wrap.append( layer.win_minsize_btn );
132		    	layer.con_wrap.append( layer.win_maxsize_btn );
133		    	layer.win_minsize_btn.bind( "click", function(){
134		    		$( this ).hide();
135		    		layer.win_maxsize_btn.show();
136		    		layer.options.width  = layer.options.min_width;
137		            layer.options.height  = layer.options.min_height;
138		    		layer.setWindowResizing();
139				});
140		    	layer.win_maxsize_btn.bind( "click", function(){
141		    		$( this ).hide();
142		    		layer.win_minsize_btn.show();
143		    		layer.options.width  = layer.options.max_width;
144		            layer.options.height  = layer.options.max_height;
145		    		layer.setWindowResizing();
146				});
147		    	layer.win_minsize_btn.addClass( "pop-btn-" + btn_cnt ).hide();
148		    	layer.win_maxsize_btn.addClass( "pop-btn-" + btn_cnt );
149		    	btn_cnt++;
150	    	}
151
152			if(layer.options.back_click_close){
153				$(layer.back).bind("click",function(){
154					layer.closeMsgPopup();
155				});
156			}
157	    	
158	    	// 윈도우 사이즈 변경 이벤트
159	    	$(window).resize(function() {
160			    if(this.resizeTO) { clearTimeout(this.resizeTO); }
161			    this.resizeTO = setTimeout(function() { $(this).trigger('resizeEnd'); }, 100);
162			});
163			layer.eventListener = {
164				"resize":function(){
165					layer.moveLayer();
166				}
167			}
168			$(window).on('resizeEnd', layer.eventListener.resize);
169	    	
170	    	$( document.body ).append( layer.window );
171	    }
172	    , setScrollFixed:function(){
173			var layer = this
174			
175
176			//$("body").css("overflow-y","hidden");
177		}
178	    , setWindowResizing : function(){
179	    	var layer = this;
180	    	
181	    	// 창크기 조절
182			// 창 높이 설정
183	    	layer.options.option_height = layer.options.height * 1;
184	    	layer.options.title_height = layer.con_head.css( "height" ).replace( "px", "" ) * 1;
185	    	layer.options.cont_height = ( 1 * layer.con_cont.css( "margin-top" ).replace( "px", "" ) ) + ( 1 * layer.con_cont.css( "margin-bottom" ).replace( "px", "" ) );
186	    	layer.options.total_height = layer.options.option_height + layer.options.title_height + layer.options.cont_height;
187	    	
188	    	layer.getPosition();
189	    	
190	    	// 지정한 크기보다 창 크기가 작을경우 처리 & 모바일
191	    	var auto_with = layer.options.width;
192	    	var auto_height = layer.options.total_height;
193	    	var auto_cont_height = layer.options.height;
194	    	if( $( window ).width() <= layer.options.width )	auto_with = $( window ).width();
195	    	if( $( window ).height() <= layer.options.total_height ){
196	    		auto_height = $( window ).height();
197	    		auto_cont_height = auto_height - ( layer.options.title_height + layer.options.cont_height );
198	    	}
199	    	
200	    	// 창 위치 조절 기본
201			layer.con_cont.css( "height", auto_cont_height );
202			layer.con_wrap.animate( { 
203				"width": auto_with
204				, "height": auto_height
205				, "top": layer.options.top
206				, "left": layer.options.left
207			} , layer.options.animate_open );	
208			
209			// 바디에 스크롤 숨기기
210			$( document.body ).css( "overflow", "hidden" );
211	    }
212	    
213	    , setTitle : function( title ){
214	    	var layer = this;
215	    	var title = title || layer.options.title;
216	    	layer.con_title.html( title );
217	    }
218	    
219	    , setContent : function( content ){
220	    	var layer = this;
221	    	var inner_content = content || "" ;
222
223			layer.con_cont.html( inner_content );
224
225			if(inner_content!=""){
226				$(".closeBtn",layer.con_cont).bind("click",function(){
227					layer.closeMsgPopup();
228				});
229			}
230
231	    }
232	    
233	    , pageLoad : function(){
234	    	var layer = this;
235	    	
236	    	if( !this.isNullOrBlank( layer.options.div_target ) ){
237	    		var data = $( layer.options.div_target ).html();
238	    		layer.setContent( data );
239	    	}else if(!this.isNullOrBlank(layer.options.message)){
240				layer.setContent(layer.options.message);
241
242			}else if( !this.isNullOrBlank( layer.options.url ) ){
243			
244					$.ajax({
245						type : "post",
246						url : layer.options.url ,
247						data: layer.options.parameter ,
248						dataType:"text",
249						success : function( data ){
250							layer.setContent( data );
251							if( layer.options.pageOnLoadCallBack != null ){
252								layer.options.pageOnLoadCallBack( layer, data );
253							}
254						},
255						error : function( xhr, status, error ) { alert("작업 수행중 오류가 발생했습니다.\n다시 시도해 주세요."); }
256					});
257
258	    	}	    	
259	    }
260	    
261	    , showMsgPopup : function (){
262	    	var layer = this;
263
264			if(layer.options.scroll_fix){
265				$("body").css({"overflow-y":"hidden","overflow-x":"hidden"});
266			}
267	    	layer.window.show( layer.options.animate_open );
268	    	
269	    	if( layer.con_cont.find( "select, input[type!=hidden]" ).size() > 0 ){
270	    		layer.con_cont.find( "select, input[type!=hidden]" ).first().focus();
271	    	}else{
272	    		layer.con_wrap.focus();
273	    	}
274	    	
275	    }
276	    
277	    , closeMsgPopup : function (){
278	    	var layer = this;
279
280			if(layer.options.scroll_fix){
281				$("body").css({"overflow-x":layer.org_scroll.overflowX,"overflow-y":layer.org_scroll.overflowY});
282			}
283
284    		layer.window.hide( layer.options.animate_close, function(){
285				$( layer.options.returnObj ).focus();
286				layer.el.removeData( "msgPopup" );
287				layer.window.remove();
288				$(window).off('resizeEnd',layer.eventListener.resize);
289
290			});
291	    }
292	    
293	    , moveLayer : function(){
294	    	var layer = this;
295			layer.setWindowResizing();
296			layer.con_wrap.animate( { "top": layer.options.top , "left": layer.options.left }, layer.options.animate_move );			
297	    }
298	    
299	    , getPosition : function(){
300	    	var layer = this; 
301	    	layer.options.top = Math.max( 0, ( ( $( window ).height() - layer.options.total_height ) / 2 ) ) + "px";
302	    	layer.options.left = Math.max( 0, ( ( $( window ).width() - layer.options.width ) / 2 ) ) + "px";
303	    }
304	    
305	    , reload : function ( new_option ){
306	    	var layer = this;
307	    	layer.options = $.extend( {}, layer.options, new_option );
308	    	layer.setContent();		// 초기화
309	    	layer.setTitle( layer.options.title );
310	    	layer.pageLoad();
311
312			
313            layer.showMsgPopup();
314	    	layer.setWindowResizing();
315	    }
316	    
317    
318    };
319
320    $.fn.msgPopup = function( params, a )   {
321        var lists  = this,
322            retval = this;
323
324        lists.each(function()
325        {
326        	        	
327            var plugin = $(this).data( "msgPopup" );
328
329            if (!plugin ) {
330				if((typeof params !== 'string' )){
331					$(this).data("msgPopup", new Plugin( this, params));
332					$(this).data("msgPopup-id", new Date().getTime());
333				}
334            } else {
335                if (typeof params === 'string' && typeof plugin[params] === 'function' && typeof a === 'undefined' ) {
336                    retval = plugin[params]();
337                }else if (typeof params === 'string' && typeof plugin[params] === 'function' ){
338                	retval = plugin[params]( a );
339                }else {
340					plugin.reload(params,a);
341					
342					//retval = plugin["init"](
343					//alert("다시 실행하라고");
344
345				}
346            }
347        });
348
349        return retval || lists;
350    };
351
352})(window.jQuery || window.Zepto, window, document);

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.