PageSourceSearch

https://bexco.co.kr/resources/_Js/comm.LayerPopup.js

js bexco.co.kr collected 2026-10-02 07:46:17 UTC 9,764 bytes, 252 lines download raw bytes

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