PageSourceSearch

https://www.ysu.ac.kr/resources/_Js/comm.LayerPopup.js

js ysu.ac.kr collected 2026-09-30 14:39:38 UTC 10,931 bytes, 285 lines download raw bytes

1;(function($, window, document, undefined)
2{
3
4	var defaults = {
5				title       						: "Layer-Popup"												//  레이어 팝업 타이틀
6    			, width								: "500"																//  처음 창 크기
7	        	, height							: "300"																//  처음 창 크기
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"																//  창이 닫힐때 속도(애니메이션 효과)
21    			, animate_reload					: "0"																//  구현 안됬음
22    			, animate_move						: "slow"															//  창 사이즈 변경시 자동 이동 됨, 이때의 애니메이션 효과
23    			, close_button						: "<button class='btn-close' type='button'><span>현재창 닫기</span></button>" 
24    			, reload_button						: "<button class='btn-reload' type='button'><span>다시열기</span></button>"
25    			, minsize_button					: "<button class='btn-minsize' type='button'><span>창 최소화 하기</span></button>"
26    			, maxsize_button					: "<button class='btn-maxsize' type='button'><span>창 최대화 하기</span></button>"
27    			, close_button_yn					: true
28    			, reload_button_yn					: true
29    			, minmaxsize_button_yn				: true
30        };
31
32    function Plugin(element, options)
33    {
34        this.content = null;
35        this.el = $(element);
36        this.options = $.extend({}, defaults, options);
37        this.init();
38    }
39
40    Plugin.prototype = {
41
42        init: function() {
43            var layer = this;
44            
45            if(this.isNullOrBlank(layer.options.url)&& this.isNullOrBlank(layer.options.div_target)) {
46            	alert("호출 URL 또는 대상이 없습니다.");
47            	return false;
48            }
49            
50            layer.options.min_width  = layer.options.width;
51            layer.options.min_height  = layer.options.height;
52            
53            layer.drawWindow();
54            layer.showLayerPopup();
55            layer.setWindowResizing();
56            layer.pageLoad();            
57                    
58        }
59    
60	   , isNullOrBlank : function(val){
61	    	if(val == null || val == "")return true;
62	    	else return false;
63	    }
64	    
65	   , drawWindow : function(){
66	    	var layer = this;
67	    	layer.window = $("<div id='layout-popup-wrap' style='display:none;'></div>");
68	    	layer.con_wrap = $("<div id='popup-wrap' tabindex='0'></div>");
69	    	layer.con_head = $("<div class='pop-head'></div>");
70	    	layer.con_title = $("<h1 class='htit'></h1>");
71	    	layer.con_cont = $("<div class='pop-cont'></div>");
72	    	
73	    	
74	    	layer.setTitle(layer.options.title);
75	    	
76	    	layer.con_head.append(layer.con_title);
77
78	    	layer.con_wrap.append(layer.con_head).append(layer.con_cont).append(layer.win_close_btn);
79	    	layer.window.append(layer.con_wrap);
80	    	
81
82	    	
83	    	var btn_cnt = 1;
84	    	
85	    	// 닫기 버튼 생성
86	    	if(layer.options.close_button_yn){
87		    	layer.win_close_btn = $(layer.options.close_button);
88		    	layer.con_wrap.append(layer.win_close_btn);
89		    	layer.win_close_btn.bind("click", function(){
90		    		layer.closeLayerPopup();
91				});
92		    	layer.win_close_btn.addClass("pop-btn-" + btn_cnt);
93		    	btn_cnt++;
94	    	}
95	    	
96	    	
97	    	// 리로드 버튼 생성
98	    	if(layer.options.reload_button_yn){
99		    	layer.win_reload_btn = $(layer.options.reload_button);
100		    	layer.con_wrap.append(layer.win_reload_btn);
101		    	layer.win_reload_btn.bind("click", function(){
102		    		layer.reload();
103				});
104		    	layer.win_reload_btn.addClass("pop-btn-" + btn_cnt);
105		    	btn_cnt++;
106	    	}
107	    	
108	    	// 창크키 조절 버튼 생성
109	    	if(layer.options.minmaxsize_button_yn){
110		    	layer.win_minsize_btn = $(layer.options.minsize_button);
111		    	layer.win_maxsize_btn = $(layer.options.maxsize_button);
112		    	layer.con_wrap.append(layer.win_minsize_btn);
113		    	layer.con_wrap.append(layer.win_maxsize_btn);
114		    	layer.win_minsize_btn.bind("click", function(){
115		    		$(this).hide();
116		    		layer.win_maxsize_btn.show();
117		    		layer.options.width  = layer.options.min_width;
118		            layer.options.height  = layer.options.min_height;
119		    		layer.setWindowResizing();
120				});
121		    	layer.win_maxsize_btn.bind("click", function(){
122		    		$(this).hide();
123		    		layer.win_minsize_btn.show();
124		    		layer.options.width  = layer.options.max_width;
125		            layer.options.height  = layer.options.max_height;
126		    		layer.setWindowResizing();
127				});
128		    	layer.win_minsize_btn.addClass("pop-btn-" + btn_cnt).hide();
129		    	layer.win_maxsize_btn.addClass("pop-btn-" + btn_cnt);
130		    	btn_cnt++;
131	    	}
132	    	
133	    	// 윈도우 사이즈 변경 이벤트
134	    	$(window).resize(function() {
135			    if(this.resizeTO) { clearTimeout(this.resizeTO); }
136			    this.resizeTO = setTimeout(function() { $(this).trigger('resizeEnd'); }, 100);
137			});
138			$(window).on('resizeEnd', function() {
139				layer.moveLayer();	
140			});
141	    	
142	    	$(document.body).append(layer.window);
143	    }
144	    
145	   , setWindowResizing : function(){
146	    	var layer = this;
147	    	
148	    	// 창크기 조절
149			// 창 높이 설정
150	    	layer.options.option_height = layer.options.height * 1;
151	    	layer.options.title_height = layer.con_head.css("height").replace("px", "")* 1;
152	    	layer.options.cont_height = (1 * layer.con_cont.css("margin-top").replace("px", "")) + (1 * layer.con_cont.css("margin-bottom").replace("px", ""));
153	    	layer.options.total_height = layer.options.option_height + layer.options.title_height + layer.options.cont_height;
154	    	
155	    	layer.getPosition();
156	    	
157	    	// 지정한 크기보다 창 크기가 작을경우 처리 & 모바일
158	    	var auto_with = layer.options.width;
159	    	var auto_height = layer.options.total_height;
160	    	var auto_cont_height = layer.options.height;
161	    	if($(window).width() <= layer.options.width)	auto_with = $(window).width();
162	    	if($(window).height() <= layer.options.total_height){
163	    		auto_height = $(window).height();
164	    		auto_cont_height = auto_height - (layer.options.title_height + layer.options.cont_height);
165	    	}
166	    	
167	    	// 창 위치 조절 기본
168			layer.con_cont.css("height", auto_cont_height);
169			layer.con_wrap.animate({ 
170				"width": auto_with
171				, "height": auto_height
172				, "top": layer.options.top
173				, "left": layer.options.left
174			}, layer.options.animate_open);	
175			
176			// 바디에 스크롤 숨기기
177			$(document.body).css("overflow", "hidden");
178	    }
179	    
180	   , setTitle : function(title){
181	    	var layer = this;
182	    	var title = title || layer.options.title;
183	    	layer.con_title.html(title);
184	    }
185	    
186	   , setContent : function(content){
187	    	var layer = this;
188	    	var inner_content = content || "" ;
189	   
190	    	layer.con_cont.html(inner_content);
191	    }
192	    
193	   , pageLoad : function(){
194	    	var layer = this;
195	    	
196	    	if(!this.isNullOrBlank(layer.options.div_target)){
197	    		var data = $(layer.options.div_target).html();
198	    		layer.setContent(data);
199	    	}else if(!this.isNullOrBlank(layer.options.url)){
200	    		$.ajax({
201		    		type : "post",
202		    		url : layer.options.url,
203		    		data: layer.options.parameter,
204		    		dataType:"text",
205		    		success : function(data){
206		    			layer.setContent(data);
207		    		},
208		    		error : function(xhr, status, error){ alert("작업 수행중 오류가 발생했습니다.\n다시 시도해 주세요."); }
209		    	});
210	    	}
211	    	
212	    }
213	    
214	   , showLayerPopup : function (){
215	    	var layer = this;
216	    	$(document.body).css("overflow", "hidden");
217	    	layer.window.show(layer.options.animate_open);
218	    	
219	    	if(layer.con_cont.find("select, input[type!=hidden]").length > 0){
220	    		layer.con_cont.find("select, input[type!=hidden]").first().focus();
221	    	}else{
222	    		layer.con_wrap.focus();
223	    	}
224	    	
225	    }
226	    
227	   , closeLayerPopup : function (){
228	    	var layer = this;
229	    	$(document.body).css("overflow","visible");
230    		layer.window.hide(layer.options.animate_close, function(){
231				$(layer.options.returnObj).focus();
232				layer.el.removeData("layerPopup");
233				layer.window.remove();
234				$(window).off('resizeEnd');
235			});
236	    }
237	    
238	   , moveLayer : function(){
239	    	var layer = this;
240			layer.setWindowResizing();
241			layer.con_wrap.animate({ "top": layer.options.top, "left": layer.options.left }, layer.options.animate_move);			
242	    }
243	    
244	   , getPosition : function(){
245	    	var layer = this; 
246	    	layer.options.top = Math.max(0, (($(window).height() - layer.options.total_height)/ 2)) + "px";
247	    	layer.options.left = Math.max(0, (($(window).width() - layer.options.width)/ 2)) + "px";
248	    }
249	    
250	   , reload : function (new_option){
251	    	var layer = this;
252	    	layer.options = $.extend({}, layer.options, new_option);
253	    	layer.setContent();		// 초기화
254	    	layer.setTitle(layer.options.title);
255	    	layer.pageLoad();
256	    	layer.setWindowResizing();
257	    }
258    
259    };
260
261    $.fn.layerPopup = function(params, a)  {
262        var lists  = this,
263            retval = this;
264
265        lists.each(function()
266        {
267        	        	
268            var plugin = $(this).data("layerPopup");
269
270            if(!plugin) {
271                $(this).data("layerPopup", new Plugin(this, params));
272                $(this).data("layerPopup-id", new Date().getTime());
273            } else {
274                if(typeof params === 'string' && typeof plugin[params] === 'function' && typeof a === 'undefined'){
275                    retval = plugin[params]();
276                }else if(typeof params === 'string' && typeof plugin[params] === 'function'){
277                	retval = plugin[params](a);
278                }
279            }
280        });
281
282        return retval || lists;
283    };
284
285})(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.