PageSourceSearch

https://mportal.cau.ac.kr/common/js/nana.fn.js

js cau.ac.kr collected 2026-09-24 08:44:31 UTC 5,434 bytes, 257 lines download raw bytes

1(function( window, document, $ ){
2	var nana = {};
3
4    var
5        $w          = $(window),
6        $d          = $(document),
7        body        = document.body,
8        $body		= $(body),
9        windowSize  = {
10            width   : window.innerWidth,
11            height  : window.innerHeight
12        };
13    
14
15    var event = nana.event = {
16		resize: function( fn ){
17
18            fn( windowSize );
19
20            var
21                time,
22                resizeFn = function(){
23                    fn(windowSize = {
24                        width   : body.clientWidth,
25                        height  : body.clientHeight
26                    });
27                    time = null;
28                    return 0;
29                };
30
31            $w.on("resize", function(){
32                window.clearTimeout(time);
33                time = setTimeout(resizeFn, 500);
34                return 0;
35            });
36        }
37    };
38
39    /*
40     * custom array methods
41     */
42
43    var array = nana.array = function( arr ){
44        return new array.fn.ini( arr );
45    };
46
47	array.fn = {
48        ini: function( a ){
49            if(!this.isArray(a)){ console.log(a + 'is not a Array'); return 0; }
50            this.data = a;
51            return this;
52        },
53        insert: function(index, value){
54            this.data.splice( (index - 1) , 0, value );
55            return this;
56        },
57        change: function(index, value){
58            this.data.splice( (index-1), 1, value );
59            return this;
60        },
61        die: function(index){
62            this.data.splice(index, 1);
63            return this;
64        },
65        isArray: function( data ){
66            data = data || this.data;
67            try{
68                return Array.isArray( data );
69            }
70            catch (err){
71                return data.constructor === Array;
72            }
73        }
74    };
75    array.fn.ini.prototype = array.fn;
76    //var isArray = array.fn.isArray;
77	
78
79/** CONFIRMATION */
80var confirmation = function( contents, events ){
81	return new confirmation.fn.ini(contents, events);
82};
83confirmation.fn = {
84	super: false,
85	opened: false,
86	doc: body || document.body,
87	ini: function( contents, events ){ // confirmation ini
88
89		var top = window.pageYOffset;
90		$body.addClass("nb-openConfirmUI");
91		body.style.top = '-'+top+'px';
92		this.top = top;
93
94		if(contents){
95			this.self( contents, events );
96			this.super = true;
97		}
98
99		this.evt = events;
100
101		return this;
102	},
103	self: function( contents ){ // default template
104		var context = this.template.context(contents);
105		this.doc.appendChild(context);
106		this.addEvent(context);
107
108		return ;
109	},
110	template: {
111		toHTML: function( string ){
112			 return (function(temp, html){
113                 temp.innerHTML = html;
114                 var result = temp.firstChild;
115                 temp = null;
116                 return result;
117             })( document.createElement('DIV'), string );
118		},
119		context: function( contents ){
120			var html =  [
121				'<div class="nb-confirmation">',
122					'<div class="nb-confirm-context">',
123						'<div class="nb-confirm-close" data-type="close"></div>',
124						'<div class="nb-confirm-contents">',
125							'<section class="nb-confirm-body">',
126								contents,
127							'</section>',
128							'<section>',
129								'<ul class="nb-confirm-buttons">',
130									'<li class="nb-confirm-cancel"><i data-type="close">Cancel</i></li>',
131									'<li class="nb-confirm-agree"><i data-type="ok">Agree</i></li>',
132								'</ul>',
133							'</section>',
134						'</div>',
135					'</div>',
136				'</div>'
137			].join("");
138			return this.toHTML( html );
139		},
140		portletSave: function( msgs ){
141			return [
142				'<div class="nb-confirm-001 nb-confirm-save">',
143					'<h2>'+ msgs[0] +'</h2>',
144				'</div>'
145			].join("");
146		},
147		portletReset: function( msgs ){
148			return [
149				'<div class="nb-confirm-001 nb-confirm-reset">',
150					'<h2>'+ msgs[0] +'</h2>',
151				'</div>'
152			].join("");
153		}
154	},
155	close: function( context ){ // // confirm 닫기
156		
157		$(context).off("click");
158		body.removeChild( context );
159
160		body.removeAttribute("style");
161		$body.removeClass("nb-openConfirmUI");
162
163		window.scrollBy(0, this.top);
164		
165
166//    			this.super = false;
167		return this;
168	},
169	clickFn: function(event, self, context){
170		var target = event.target;
171		var dataType = target.getAttribute("data-type");
172
173		if(dataType === 'close'){
174			if(self.evt[0]){
175				self.evt[0]();
176			}
177			self.close(context);
178			return ;
179		}
180		if(dataType === 'ok'){
181			self.evt[1]();
182			self.close(context);
183			return ;
184		}
185
186		return ;
187	},
188	addEvent: function( context ){ // confirm 클릭 이벤트 추가
189		var self = this;
190		$(context).on("click", function(event){
191			self.clickFn(event, self, context);
192		});
193		return ;
194	},
195	portletSave: function( msgArr ){ // 포틀릿 설정 저장 confirm template
196		if(this.super){ return ; }
197		var context = this.template.context(
198			this.template.portletSave( msgArr )
199		);
200		this.doc.appendChild(context);
201		this.addEvent(context);
202		
203		return this;
204	},
205	portletReset: function( msgArr ){ // 포틀릿 설정 초기화 confirm template
206		
207		if(this.super){ return ; }
208		var context = this.template.context(
209			this.template.portletReset( msgArr )
210		);
211
212		body.appendChild(context);
213		this.addEvent(context);
214
215		return this;
216	},
217};
218confirmation.fn.ini.prototype = confirmation.fn;
219nana.confirm = confirmation;
220/** // CONFIRMATION */
221
222
223window.nana = nana;
224
225})( window, document, jQuery );
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257

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.