1(function(window, document, $) { 2 3 var $html = $("html"), html = $html[0], $head = $("head"), $d = $(document), $body = $("body"); 4 5 var location = window.location; 6 7 var global = { 8 firstMenu: null, 9 secondMenu: null, 10 currentMenu: null 11 }; 12 13 var screenMode = window.innerWidth > 959 ? true : false; 14 15 var fn = { 16 isArray: function( data ){ 17 try { 18 return Array.isArra(data); 19 } 20 catch(e){ 21 if(Object.prototype.toString.call( data ) === '[object Array]'){ 22 return true; 23 }else{ 24 return false; 25 } 26 } 27 } 28 }; 29 30 // //// ê²ì 31 // var header = $("#nbHeaderContext"); 32 // $("#nbSearchBtn").on("click", function(){ 33 // header.addClass("nb-onSearch"); 34 // }); 35 36 // //// 37 var getScrollBarWidth = function(e, t) { 38 e = e || document.createElement('div'); 39 e.className = 'getScrollBarWidth'; 40 t = t || document.body; 41 t.appendChild(e); 42 var width = e.offsetWidth - e.clientWidth; 43 t.removeChild(e); 44 return width; 45 }; 46 47 ////// 48 window.nbLink = function( path, blank, e ){ 49 console.log(e); 50 //window.location = path; 51 return ; 52 }; 53 ///// 54 var style = { 55 makeStyle : function() { 56 return $('<style></style>'); 57 }, 58 pc : function(css) { 59 if (typeof css != 'string') { 60 var i = 0; 61 length = css.length, req = []; 62 for (; i < length; i++) { 63 req.push(css[i][0] + ' {' + (css[i][1]) + '}'); 64 } 65 css = req.join(''); 66 } 67 var context = this.makeStyle(), content = [ 68 '@media screen and (min-width: 960px) {', css, '}' ] 69 .join(''); 70 71 $head.append(context.html(content)); 72 }, 73 mobile : function(css) { 74 if (typeof css != 'string') { 75 var i = 0; 76 length = css.length, req = []; 77 for (; i < length; i++) { 78 req.push(css[i][0] + ' {' + (css[i][1]) + '}'); 79 } 80 css = req.join(''); 81 } 82 var context = this.makeStyle(), content = [ 83 '@media screen and (max-width: 959px) {', css, '}' ] 84 .join(''); 85 86 $head.append(context.html(content)); 87 }, 88 all : function(css) { 89 if (typeof css != 'string') { 90 var i = 0; 91 length = css.length, req = []; 92 for (; i < length; i++) { 93 req.push(css[i][0] + ' {' + (css[i][1]) + '}'); 94 } 95 css = req.join(''); 96 } 97 98 $head.append(this.makeStyle().html(css)); 99 } 100 }; 101 102 // //// 103 104 $(function() { 105 var scrollWidth = getScrollBarWidth(); 106 style 107 .all([ 108 "@media screen and (max-width: 959px) {", 109 ".nb-scroll-y-hide {width: calc(100% + 30px);padding-right: " + (30 - scrollWidth) + "px;}", 110 ".nb-onMenuMobile body {padding-right: " + scrollWidth + "px;}", 111 "}", 112 "body.nb-openConfirmUI {overflow: hidden;padding-right: "+ scrollWidth +"px !important;position: fixed;width: 100%;height: 100%;}" 113 ].join('')); 114 }); 115 116 var menuListContext = $("#nbMenuListContext"), // ì¦ê²¨ì°¾ê¸° & depth 1, 2 context 117 nbHeaderMenuContext = $("#nbHeaderMenuContext"), // ë©ë´ 리ì¤í¸ event 118 nbHeaderMenuListContext = $("#nbHeaderMenuListContext"); // ë©ë´ 리ì¤í¸ class 119 120 var nId = null, nId_el = null, 121 122 bookMarkList = null, markSave = function(data) { // ì¦ê²¨ì°¾ê¸° ì ì¥ 123 sessionStorage.setItem('favoMenuList', JSON.stringify(data)); 124 var params = { 125 privateInfo : JSON.stringify(data), 126 privateCd : '5' 127 }; 128 129 gfnc_transaction("/menu/saveFavorMenuList.ajax", params, 130 callbackSaveFavorite, false); 131 132 // console.log(data); 133 return; 134 }, bookMark = function(e) { 135 136 var self = e, dd = self.parentElement.parentElement, id = dd.getAttribute("data-key"); 137 138 var interFace = false; 139 140 if (id === nId) { 141 if (nId_el === null) { 142 nId_el = $("#n" + id)[0]; 143 } 144 interFace = true; 145 } 146 147 if (dd.className === 'on clear') { // ì¦ê²¨ì°¾ê¸° ì·¨ì 148 dd.className = ''; 149 bookMarkList.splice(bookMarkList.indexOf(id), 1); 150 markSave(bookMarkList); 151 152 if (interFace) { 153 nId_el.className = 'nb-interStar'; 154 }// controller nav mark 155 return; 156 } 157 158 dd.className = "on"; 159 160 $(self.firstElementChild).on( 161 'animationend webkitAnimationEnd MSAnimationEnd oanimationend', 162 function() { // ì¦ê²¨ì°¾ê¸° ì¶ê° 163 dd.className = "on clear"; 164 $(this).off(); 165 return; 166 }); 167 bookMarkList.push(id); 168 markSave(bookMarkList); 169 if (interFace) { 170 nId_el.className = 'nb-interStar on clear'; 171 }// controller nav mark 172 173 return; 174 }; 175 176 var callbackSaveFavorite = function(data) { 177 // console.log(data); 178 return; 179 }; 180 181 182 183 184 185 var _headerCurrentTarget = null, _headerMouseLeaveTime = null, 186 187 _headerMouseFns = { 188 leave : function() { // header 189 if (html.className.indexOf('nb-onMenuPc') > -1) { 190 $html.removeClass('nb-onMenuPc'); 191 } 192 if (_headerCurrentTarget != null) { 193 _headerCurrentTarget.className = ''; 194 _headerCurrentTarget = null; 195 } 196 nbHeaderMenuListContext[0].removeAttribute('data-menu') 197 return this; 198 }, 199 hover : function(current) { // menus context 200 clearTimeout(_headerMouseLeaveTime); 201 return this; 202 } 203 }, _headerMenuMouseMove = function(e) { 204 e = e.target; 205 if (e != _headerCurrentTarget) { 206 nbHeaderMenuListContext[0].setAttribute('data-menu', e 207 .getAttribute('data-id')); 208 if (_headerCurrentTarget != null) { 209 _headerCurrentTarget.className = ''; 210 } 211 e.className = 'hover'; 212 _headerCurrentTarget = e; 213 } 214 return; 215 }, _headerMenuMouseOut = function(e) { // leave 216 _headerMouseLeaveTime = setTimeout(_headerMouseFns.leave, 10); 217 return; 218 }, _headerMenuMouseHover = function(e) { // hover 219 if (html.className.indexOf('nb-onMenuPc') < 0) { 220 $html.addClass('nb-onMenuPc'); 221 } 222 e = e.target; 223 nbHeaderMenuListContext[0].setAttribute('data-menu', e 224 .getAttribute('data-id')); 225 if (_headerCurrentTarget != null) { 226 _headerCurrentTarget.className = ''; 227 } 228 e.className = 'hover'; 229 _headerCurrentTarget = e; 230 return; 231 }; 232 233 var _get = { 234 json : function(path, fn) { 235 $.ajax({
236 url : path, 237 dataType : 'json', 238 method : 'GET', 239 success : fn 240 }); 241 return 0; 242 } 243 }, _session = { 244 set : function(key, val) { 245 sessionStorage.setItem(key, val); 246 return this; 247 }, 248 get : function(key) { 249 return sessionStorage.getItem(key); 250 }, 251 remove : function(key) { 252 sessionStorage.removeItem(key); 253 return this; 254 }, 255 clear : function() { 256 sessionStorage.clear(); 257 return this; 258 } 259 }; 260 261 ////// 262 var headerMenuSetting = { 263 ini : function(data, mark, login) { 264 265 if (data && data.length) { 266 267 var a = headerMenuSetting.foreach(data, headerMenuSetting, login ? ['<li data-id="myPocket"><em>'+favorite+'</em></li>'] : [], mark, login); 268 269 if (!$.isArray(mark)){ 270 mark = JSON.parse(mark); 271 } 272 // painting marked 273 if (mark && mark.length) { 274 var i = 0, length = mark.length, str = ''; 275 for ( ; i < length; i++) { 276 str = 'data-key="' + (mark[i]) + '"'; 277 if (~a[1].indexOf(str)) { 278 a[1] = a[1].replace(str, str + ' class="on clear"'); 279 } else { 280 mark.splice(i--, 1); 281 length--; 282 } 283 } 284 } else { 285 mark = []; 286 } 287 288 } 289 try{ 290 nbHeaderMenuContext[0].innerHTML = a[0]; // depth 1 291 menuListContext[0].innerHTML = a[1]; // depth 2 & 3 292 style.all(a[2]); 293 }catch(e){ 294 console.log('error'); 295 } 296 bookMarkList = mark; 297 298 //menuListContext.on("click", "i", bookMark); 299 300 // ë©ë´ë§í¬ ì¤ì 301 var menuListContextFn = function( event ){ 302 var target = event.target; 303 if(target.nodeName === "A"){ 304 // not support mobile 305 if( headerMenuSetting.linkerMobile(target, 'data-mobile') ){ return ; } 306 307 event.currentTarget.setAttribute("data-clicked", "true"); 308 headerMenuSetting.linker( 309 [event.currentTarget, target], 310 target.getAttribute("data-path"), 311 target.getAttribute("data-blank"), 312 target.getAttribute("data-name") 313 ); 314 return ; 315 } 316 317 if(target.nodeName === "I"){ 318 bookMark(target); 319 return ; 320 } 321 return ; 322 }; 323 324 menuListContext.on("click", menuListContextFn); 325 326 /* 327 // first menu id 328 if(a[3] !== null){ 329 console.log(a[3]); 330 } 331 */ 332 333 return this; 334 }, 335 linkerTarget: null, 336 linker: function( target, path, blank, title, mobile ){ 337 // ì´ëí ë©ë´ 미리 í기 338 if(this.linkerTarget){ this.linkerTarget.className = ''; } 339 target[1].className = 'nb-active'; 340 this.linkerTarget = target[1]; 341 342 // í í릿 ìì± 343 this.appendMsg([title, 'íì´ì§ë¡ ì´ëí©ëë¤'], 'linker'); 344 345 var temp = this.tempFile; 346 347 // ì´ë ìì 348 if(this.t){ clearTimeout(this.t); } 349 350 //GET ë°©ìì¼ë¡ íì´ì§ í¸ì¶í ë©ë´ ìì´ë ì¤ì 351 var getMenuId = ["080106","100101"]; 352 353 this.t = setTimeout(function(){ 354 355 // open in current window 356 if(blank === 'false'){ 357 //includes í¨ì ie11ìì ì§ìì´ ìë¨ 358 if(getMenuId.indexOf(target[1].getAttribute("data-id")) !== -1){ 359 // ì ì°¨ì¥ë ìì² ì¬í 360 submitWithJson({ 361 url: path, 362 data: { 363 menuId: target[1].getAttribute("data-id") 364 }, 365 method : "GET" 366 }); 367 //window.location = path; 368 }else{ 369 // ì ì°¨ì¥ë ìì² ì¬í 370 submitWithJson({ 371 url: path, 372 data: { 373 menuId: target[1].getAttribute("data-id") 374 } 375 }); 376 //window.location = path; 377 } 378 return ; 379 } 380 381 // open in new window 382 if(blank === 'true'){ 383 window.open(path); 384 temp.parentNode.removeChild(temp); 385 target[1].className = ''; 386 target[0].removeAttribute("data-clicked"); 387 headerMenuSetting.tempFile = null; 388 return ; 389 } 390 391 return ; 392 }, 600); 393 394 return ; 395 }, 396 linkerMobile: function( target, attrName ){ 397 if(target.getAttribute(attrName) === 'false' && screenMode){ 398 headerMenuSetting.appendMsg([target.getAttribute('data-name'), 'íì´ì§ë PCë§ ì§ìí©ëë¤'], "mobileNotice"); 399 400 if(this.searchSetMsgTime){ 401 clearTimeout(this.searchSetMsgTime); 402 } 403 this.searchSetMsgTime = setTimeout(function(){ 404 headerMenuSetting.removeMsg(); 405 }, 2000); 406 return true; 407 } 408 return false; 409 }, 410 removeMsg: function(temp){ 411 temp = temp || this.tempFile; 412 if(temp){ 413 temp.parentNode.removeChild(temp); 414 this.tempFile = null; 415 } 416 return ; 417 }, 418 appendMsg: function( options, mode ){ 419 if(this.tempFile){ 420 this.tempFile.parentNode.removeChild(this.tempFile); 421 } 422 423 var temp = $(this.template( mode, options ))[0]; 424 425 $body[0].appendChild(temp); 426 427 this.tempFile = temp; 428 429 return ; 430 }, 431 template: function( mode, options ){ 432 if(mode === 'linker'){ 433 return '<section class="nb-linker-st"><p><span>'+ options[0] +'</span> '+ options[1] +'</p></section>'; 434 } 435 436 if(mode === 'notice'){ 437 return '<section class="nb-linker-st"><p><span>'+ options[0] +'</span> '+ options[1] +'</p></section>'; 438 } 439 440 if(mode === 'search'){ 441 return '<section class="nb-linker-st st-search"><p><span>'+ options[0] +'</span> '+ options[1] +'</p></section>'; 442 } 443 444 if(mode === 'mobileNotice'){ 445 return '<section class="nb-linker-st st-mobile-notice"><p><span>'+ options[0] +'</span> '+ options[1] +'</p></section>'; 446 } 447 448 return ; 449 }, 450 foreach : function(data, fn, res, mark, login) {// menuListContext 451 452 var 453 ss = login ? '<i class="nb-interStar"><span>mark</span></i>' : '', 454 navHader = $("#nbNav2ds"), 455 firstMenu = null,
456 navOn = navHader.length > 0 ? true : false; 457 458 if (navOn) { 459 var pid = navHader.attr("data-pid"), mid = navHader.attr("data-mid"), pidChild = null, midHTML = '<dl>'; 460 nId = mid; // global 461 462 navHader.on("click", "a", function(event){ 463 //event.prevnetDeafult(); 464 var target = event.target; 465 submitWithJson({ 466 url: target.getAttribute("data-url"), 467 data: { 468 menuId: target.getAttribute("data-id") 469 } 470 }); 471 472 return ; 473 }); 474 } 475 476 var i = 0, length = data.length, current = null, position = 0; 477 menus = [ [ '<div>' ], [ '<div>' ], [ '<div>' ], [ '<div>' ] ], 478 createCSS = []; 479 // res = res || []; 480 /* 481 * .nb-h-menu-list[data-menu="B010000"] .nb-h-menuList-context 482 * dl[data-id="B010000"] {display: block;} 483 */ 484 for (; i < length; i++) { 485 current = data[i]; 486 487 if (current.nodes) { 488 489 var nodes = current.nodes; 490 var ii = 0, length2 = nodes.length; 491 position = 0; 492 for (; ii < length2; ii++, position++) { 493 var currentDepth2 = nodes[ii], p = menus[position % 4]; 494 if (navOn && currentDepth2.menuId === pid ) { 495 firstMenu = nodes[0].prtMenuId; 496 this.createNav(currentDepth2, mid, navHader, mark, login); // #nav 497 } 498 p.push('<dl data-id="' + (currentDepth2.prtMenuId) + '">'); 499 p.push(this.depthHTML_02(currentDepth2)); 500 501 if (currentDepth2.nodes) { 502 var iii = 0, length3 = currentDepth2.nodes.length; 503 for (; iii < length3; iii++) { 504 //console.log(currentDepth2.nodes[iii]); 505 p.push(this.depthHTML_03(currentDepth2.nodes[iii], ss)); 506 } 507 } 508 p.push('</dl>'); 509 } 510 511 res.push(fn.depthHTML_01( current.menuId, current.menuNm, firstMenu )); 512 createCSS.push('.nb-h-menu-list[data-menu="' + (current.menuId) + '"] .nb-h-menuList-context dl[data-id="' + (current.menuId) + '"] {display: block;}'); 513 514 } else { 515 if(current.menuId.substring(1,5) =="0000") 516 res.push(fn.depthHTML_04(current.menuId, current.menuNm, current.menuUrl)); 517 } 518 } 519 520 if(navOn){ // sub pages #21 521 522 global.firstMenu = firstMenu; 523 global.secondMenu = pid; 524 global.currentMenu = mid; 525 526 var midCSS = [ 527 ".nb-theme-0 #h"+mid+" a {color: #0F2787;}", 528 ".nb-theme-1 #h"+mid+" a {color: #0F2787;}", 529 ".nb-theme-2 #h"+mid+" a {color: #378D33;}", 530 ".nb-theme-3 #h"+mid+" a {color: #E50F49;}", 531 ".nb-theme-4 #h"+mid+" a {color: #B91CA4;}", 532 ".nb-h-menuList-context:not([data-clicked='true']) #h"+mid+" a::first-letter {font-size: 18px;display: inline-block;vertical-align: bottom;line-height: 16px;}" 533 ].join(''); 534 535 style.mobile(midCSS); 536 537 }else{ // main page 538 539 //res[0] = res[0].replace('data-id="myPocket"', 'data-id="myPocket" active="true"') 540 541 var mainFindex = login ? 1 : 0; 542 543 if(res[mainFindex]){ 544 545 res[mainFindex] = res[mainFindex].replace('data-id', 'active="true" data-id'); 546 547 global.firstMenu = (function( str ){ 548 var index = str.indexOf('data-id="') + 9; 549 return str.substr( index, str.indexOf('"', index) - index ); 550 })( res[mainFindex] ); 551 552 } 553 554 555 } 556 557 if( login === true ){ 558 res.push('<li data-menu="theme"><em>Theme Skin</em></li>'); 559 res.push('<li data-menu="signout"><em>Logout</em></li>') 560 } 561 562 menus[0].push('</div>'); 563 menus[0] = menus[0].join(''); 564 565 menus[1].push('</div>'); 566 menus[1] = menus[1].join(''); 567 568 menus[2].push('</div>'); 569 menus[2] = menus[2].join(''); 570 571 menus[3].push('</div>'); 572 menus[3] = menus[3].join(''); 573 574 return [ res.join(''), menus.join(''), createCSS.join(''), firstMenu ]; 575 576 }, 577 createNav: function(parent, id, context, mark, login) { 578 579 parent = parent.nodes; 580 var html = '', dt = '', dd = '', i = 0, length = parent&&parent.length||0; 581 582 for (; i < length; i++) { 583 if (parent[i].menuId === id) { 584 dt = '<dt>' + parent[i].menuNm + '</dt>'; 585 continue; 586 } 587 /* 588 dd += '<dd><a href="' + (parent[i].menuUrl) + '">' 589 + (parent[i].menuNm) + '</a></dd>'; 590 */ 591 dd += [ 592 '<dd>', 593 '<a href="javascript:void(0);" data-url="'+(parent[i].menuUrl)+'" data-id="'+(parent[i].menuId)+'" data-name="'+(parent[i].menuNm)+'">', 594 (parent[i].menuNm), 595 '</a>', 596 '</dd>' 597 ].join(''); 598 } 599 600 html = [ '<dl>', dt, dd, '</dl>' ].join(''); 601 602 context.html(html); 603 604 if(!login){ return ; } 605 var bookMark = $('<i class="nb-interStar" data-key="' + id + '" id="n' + id + '"><span></span></<i>'); 606 607 //return ; 608 /* 609 if( mark === null || !mark ){ 610 mark = []; 611 }else{ 612 if(typeof mark !== 'string'){ 613 mark = mark.join(','); 614 }else{ 615 console.log('header.js ERROR : 20171201'); 616 } 617 } 618 */ 619 620 if( !mark ){ mark = "[]"; } 621 622 if(typeof mark !== 'string'){ mark = mark.join(','); } 623 624 if (~mark.indexOf(id)) { 625 bookMark[0].className = 'nb-interStar on clear'; 626 } 627 628 var hId = null; 629 630 var bookMarkClickFn = function(event) { // toggle 631 event = event.target; 632 633 if (hId === null) { 634 hId = $('#h' + id)[0]; 635 } 636 637 if (event.className === 'nb-interStar on clear') { // ë¤ë¹: ì¦ê²¨ì°¾ê¸° 638 // ì·¨ì 639 event.className = 'nb-interStar'; 640 bookMarkList.splice(bookMarkList.indexOf(id), 1); 641 markSave(bookMarkList); 642 643 hId.className = ''; // controller header mark 644 return; 645 } 646 647 event.className = 'nb-interStar on clear'; // ë¤ë¹: ì¦ê²¨ì°¾ê¸° ì¶ê° 648 bookMarkList.push(id); 649 markSave(bookMarkList); 650 651 hId.className = 'on clear';// controller header mark 652 653 return; 654 }; 655 656 bookMark.on("click", bookMarkClickFn); 657 658 context.append(bookMark); 659 return; 660 }, 661 depthHTML_01 : function(id, menuNm, firstMenu){ 662 return '<li '+ (firstMenu === id ? 'active="true" ' : '') +'data-id="' + (id) + '"><em>' + (menuNm) + '</em></li>'; 663 }, 664 depthHTML_02 : function(data) { 665 return '<dt>' + (data.menuNm) + '</dt>'; 666 }, 667 depthHTML_03 : function(data, mark) { 668 return [ 669 '<dd data-key="' + (data.menuId) + '" id="h' + (data.menuId) + '">', 670 //'<em>', '<a href="' + (data.menuUrl) + '">'+ (data.menuNm) +'</a>', mark, '</em>', 671 '<em>', 672 '<a href="javascript:void(0);" data-id="' + (data.menuId) + '" data-mobile="'+(data.mobileYn === 'N' ? false : true)+'" data-path="'+(data.menuUrl)+'" data-blank="'+( Number(data.menuPath) ? true : false )+'" data-name="'+(data.menuNm)+'">'+ (data.menuNm) +'</a>' , mark, 673 '</em>', 674 '</dd>' 675 ].join(''); 676 }, 677 depthHTML_04 : function(id, menuNm, url) { 678 return '<li data-id="' + (id) + '"><em><a href="' + (url) + '" target="_blank">' + (menuNm) + '</a></em></li>'; 679 } 680 }; 681 682 var openNBuserInfoKEY = false; 683 684 var openNBuserInfo = $("#openNBuserInfo"); 685 686 var userSettings = {
687 open : function(event) { // ì¤ì ì´ê¸° 688 if (!openNBuserInfoKEY) { 689 event.stopPropagation(); 690 691 openNBuserInfo.addClass("on"); 692 693 if(typeof this.nbUcontext === 'undefined' || !this.nbUcontext){ 694 this.nbUcontext = $("#nbUcontext"); 695 } 696 697 this.nbUcontext.on("click", function( event ){ 698 event.stopPropagation(); 699 return true; 700 }); 701 702 $d.on("click", userSettings.close); 703 openNBuserInfoKEY = true; 704 } 705 return; 706 }, 707 close : function() { // ì¤ì ë«ê¸° 708 $d.off("click"); 709 openNBuserInfo.removeClass("on"); 710 openNBuserInfoKEY = false; 711 712 return; 713 } 714 }; 715 716 openNBuserInfo.on("click", userSettings.open); 717 718 var more = { 719 screen: false, 720 currentData: { 721 PC: { 722 theme: '', 723 fontSize: '' 724 }, 725 MOBILE: { 726 theme: '', 727 fontSize: '' 728 }, 729 theme: 'nb-theme-1', 730 fontSize: 'nb-fontSize-1' 731 }, 732 started: false, 733 privateInfo: null, 734 setting: function( privs ){ 735 736 /* 737 if(!this.screen){ 738 console.log("%cNot fined this.screen", "color: green"); 739 return ; 740 } 741 742 if( (typeof privs !== 'string') || privs.length === 0 || !(privs = JSON.parse(privs)) ){ 743 console.log("%cNot fined privateInfo", "color: green"); 744 return ; 745 } 746 */ 747 748 //this.privateInfo = privs = privs[0]; 749 750 if(!privs){ 751 console.log("%cNot fined privateInfo", "color: green"); 752 } 753 754 this.privateInfo = privs; 755 this.started = true; 756 this.setTheme().setFont(); 757 758 759 return ; 760 }, 761 setTheme: function(){ // data setting 762 763 var mobile, pc; 764 765 if( (mobile = this.getStorage('themeMOBILE')) && (pc = this.getStorage('themePC')) ){ // cache 766 767 this.currentData.MOBILE.theme = mobile = 'nb-theme-' + mobile; 768 this.currentData.PC.theme = pc = 'nb-theme-' + pc; 769 770 this.changeName(this.currentData[this.screen].theme, 'theme'); 771 772 return this; 773 } 774 775 this.setStorage('themeMOBILE', this.privateInfo.MOBILE.theme); 776 this.setStorage('themePC', this.privateInfo.PC.theme); 777 778 this.setTheme(); 779 780 return this; 781 }, 782 setFont: function(){ 783 784 var mobile, pc; 785 786 if( (mobile = this.getStorage('fontSizeMOBILE')) && (pc = this.getStorage('fontSizePC')) ){ // cache 787 788 this.currentData.MOBILE.fontSize = mobile = 'nb-fontSize-' + mobile; 789 this.currentData.PC.fontSize = pc = 'nb-fontSize-' + pc; 790 791 this.changeName(this.currentData[this.screen].fontSize, 'fontSize'); 792 793 return this; 794 } 795 796 this.setStorage('fontSizeMOBILE', this.privateInfo.MOBILE.fontSize); 797 this.setStorage('fontSizePC', this.privateInfo.PC.fontSize); 798 799 this.setFont(); 800 801 return this; 802 }, 803 changeName: function( add, mode ){ 804 805 if(this.started){ 806 $html.removeClass(this.currentData[mode]).addClass(add); 807 this.currentData[mode] = add; 808 } 809 810 return ; 811 }, 812 changeData: function( mode ){ // toggle mobile and pc names 813 814 this.screen = mode; 815 816 if(mode === 'PC'){ 817 818 this.changeName( this.currentData.PC.theme, 'theme' ); 819 this.changeName( this.currentData.PC.fontSize, 'fontSize' ); 820 821 return this; 822 } 823 if(mode === 'MOBILE'){ 824 825 this.changeName( this.currentData.MOBILE.theme, 'theme' ); 826 this.changeName( this.currentData.MOBILE.fontSize, 'fontSize' ); 827 828 return this; 829 } 830 console.log("%cERROR 0611221217", "color: red"); 831 return this; 832 }, 833 getStorage: function( name ){ 834 return window.sessionStorage.getItem(name); 835 }, 836 setStorage: function( name, val ){ 837 return window.sessionStorage.setItem(name, val); 838 }, 839 840 template: { 841 url: { 842 theme: '/html/ajax/more_temp_theme.html', 843 fontSize: '/html/ajax/more_temp_font.html' 844 }, 845 context: function( contents, mode ){ 846 if(mode === 'theme'){ 847 return [ 848 '<section class="nb-2-more">', 849 '<div class="nb-2-context" id="nbMoreContext">', 850 contents, 851 '</div>', 852 '</div>' 853 ].join(""); 854 } 855 856 if(mode === 'fontSize'){ 857 return [ 858 '<section class="nb-2-more">', 859 '<div class="nb-2-context" id="nbMoreContext">', 860 contents, 861 '<div class="nb-2-more-buttons">', 862 '<a href="javascript:void(0);" class="nb-more-save">íì¸</a>', 863 '</div>', 864 '</div>', 865 '</div>' 866 ].join(""); 867 } 868 869 }, 870 theme: function( fn ){ 871 this.get(this.url.theme, fn, 'theme'); 872 return 0; 873 }, 874 fontSize: function( fn ){ 875 this.get(this.url.fontSize, fn, 'fontSize'); 876 return 0; 877 }, 878 get: function( url, fn, mode ){ 879 var context = this.context; 880 this.ajax(url, function(data){ 881 fn( context(data, mode) ); 882 return 1; 883 });
884 return 0; 885 }, 886 ajax: function( path, fn ){ 887 $.ajax({ url : path, method : 'GET', success : fn }); 888 return 0; 889 } 890 }, 891 open: function( mode ){ 892 893 userSettings.close(); 894 895 this.template[mode](function(data){ 896 data = $(data); 897 $body.append(data); 898 var context = $("#nbMoreContext"); 899 900 context.on("click", function(event){ 901 902 event = event.target; 903 var myName = event.className; 904 905 if(myName === 'nb-more-save'){ // save 906 more.save(data, context, mode); 907 return ; 908 } 909 910 if(myName === 'nb-data-items'){ // *** 911 912 more.reset(event.getAttribute("data-code"), mode); 913 914 if(mode === 'theme'){ // í ë§ì¼ ë íì¸ ë²í¼ ìì. auto save ì¶ê° 915 more.save(data, context, mode); 916 } 917 918 return ; 919 } 920 921 return ; // break 922 if(myName === 'nb-2-more'){ // close 923 more.close(data, context, mode); 924 return ; 925 } 926 927 return ; 928 }); 929 }); 930 }, 931 save: function( data, context, mode ){ //mode : theme, font size ... // SAVE *** 932 933 var n = this["new_"+mode]; 934 935 if(n === null){ 936 this.close(data, context, mode); 937 return ; 938 } 939 940 this.setStorage(mode + this.screen, this.new_id); 941 942 if(typeof privateSave !== 'undefined'){ // main page 943 privateSave(this.screen, false, ['more', this.new_id, mode]); 944 this.close(data, context, mode); 945 946 }else{ // if not a main page 947 var self = this; 948 var priv = typeof this.priv === 'undefined' ? (this.priv = JSON.parse(this.getStorage('privateInfo'))[0]) : this.priv; 949 950 if(typeof this.new_id !== 'number'){ // if more data type not a NUMBER 951 return false; 952 } 953 954 priv[ this.screen ][ mode ] = this.new_id; 955 956 if( (function( pc, mobile ){ // data check 957 if( fn.isArray(pc) && fn.isArray(pc[0]) && fn.isArray(pc[1]) && fn.isArray(pc[2]) && fn.isArray(mobile) ){ 958 return false; 959 } 960 return true; 961 })(priv.PC.portlet, priv.MOBILE.portlet) ){ 962 console.log("%c SAVE ERROR : 2407310118", "color: red"); 963 return 0; 964 } 965 966 var privateInfo = JSON.stringify(priv); 967 this.setStorage("privateInfo", "["+privateInfo+"]"); 968 var param = {privateInfo: "["+privateInfo+"]" , privateCd : '6'}; 969 gfnc_transaction("/menu/saveUserPortletList.ajax", param, function(){ 970 self.close(data, context, mode); 971 return ; 972 }, false, "json"); 973 } 974 975 return ; 976 }, 977 close: function( target, context, mode ){ 978 979 context.off(); 980 981 target.remove(); 982 this.new_theme = null; 983 this.new_fontSize = null; 984 this.new_id = null; 985 return ; 986 }, 987 new_theme: null, 988 new_fontSize: null, 989 new_id: null, 990 reset: function(newId, mode){ 991 992 var n = 'nb-' + mode + '-' + newId, 993 o = this.currentData[mode]; 994 995 if(n !== o){ 996 this[ "new_"+mode ] = n; 997 998 $html.removeClass(o).addClass(n); 999 this.currentData[mode] = n; 1000 this.currentData[this.screen][mode] = n; 1001 1002 //this.privateInfo[this.screen][mode] = this.new_id = Number(newId); 1003 this.new_id = Number(newId); 1004 1005 return ; 1006 } 1007 1008 1009 return ; 1010 } 1011 }; 1012 1013 1014 1015 1016 window.nbMore = more; 1017 1018 1019 1020 var nbInformation = { 1021 close: userSettings.close 1022 }; 1023 1024 // --- 1025 nbInformation.top = function() { 1026 1027 var scTop = function() { 1028 1029 if (window.pageYOffset > 0) { 1030 window.requestAnimationFrame(scTop); 1031 } 1032 1033 window.scrollBy(0, -100); 1034 1035 return; 1036 }; 1037 1038 window.requestAnimationFrame(scTop); 1039 }; 1040 // --- 1041 1042 1043 1044 1045 window.nbInformation = nbInformation; 1046 1047/* 1048 * 모ë°ì¼ ë©ë´ open & close 1049 * 1050 */ 1051 1052 var mobile_fn = { 1053 openMenu : function() { // #22 1054 location.hash = '/menu'; 1055 return; 1056 }, 1057 closeMenu : function() { 1058 location.hash = ''; 1059 return; 1060 }, 1061 setOpenMenu: function( mode ){ // change event [menu] 1062 1063 if(mode){ // open 1064 1065 nbHeaderMenuListContext.attr("data-menu", global.firstMenu); 1066 /* 1067 if(global.secondMenu !== null){ 1068 nbHeaderMenuListContext.attr("data-menu", global.firstMenu); 1069 1070 }else{ // main page 1071 //nbHeaderMenuListContext.attr("data-menu", "myPocket"); 1072 //nbHeaderMenuListContext.attr("data-menu", "main"); 1073 1074 nbHeaderMenuListContext.attr("data-menu", global.firstMenu); 1075 } 1076 */ 1077 1078 if(mobile_fn.clicked){ 1079 mobile_fn.clicked.removeAttribute("data-click"); 1080 mobile_fn.clicked = null; 1081 } 1082 1083 }else{ // close 1084 if(mobile_fn.target){ 1085 mobile_fn.target.removeAttribute("class"); 1086 mobile_fn.target = null; 1087 } 1088 } 1089 1090 return ; 1091 }, 1092 clicked: null, 1093 target: null, 1094 firstMenu: function(e){ // 모ë°ì¼ íë©´ 1depth menu click 1095 1096 if (e.target.nodeName === 'LI') { 1097 var dataMenu = e.target.getAttribute("data-menu"); 1098 if(dataMenu === "theme"){ 1099 more.open('theme'); 1100 return ; 1101 } 1102 1103 if(dataMenu === 'signout'){ 1104 fncLogout(); 1105 return ; 1106 } 1107 1108 nbHeaderMenuListContext[0].setAttribute('data-menu', e.target.getAttribute('data-id')); 1109 1110 (function(m_fn, currentTarget){ // for 1 depth 1111 if(m_fn.clicked === null){ 1112 currentTarget.setAttribute("data-click", "true"); 1113 m_fn.clicked = currentTarget; 1114 } 1115 return ; 1116 })(mobile_fn, e.currentTarget); 1117 1118 (function(m_fn, target){ // for 2 depth 1119 if(m_fn.target){ m_fn.target.removeAttribute("class"); } 1120 target.className = "nb-active"; 1121 m_fn.target = target; 1122 return ; 1123 })(mobile_fn, e.target); 1124 1125 } 1126 1127 return; 1128 1129 } 1130 }; 1131 1132 var mobileMenu = function( res ){ 1133 if(res === 'load'){ 1134 mobile_fn.closeMenu(); 1135 return ; 1136 } 1137 1138 if (location.hash.slice(1) === '/menu') { 1139 $html.addClass('nb-onMenuMobile'); 1140 mobile_fn.setOpenMenu(true); 1141 } else { 1142 $html.removeClass('nb-onMenuMobile'); 1143 mobile_fn.setOpenMenu(false); 1144 } 1145 return ; 1146 }; 1147 1148 $(function(){ 1149 $(window).on("hashchange", mobileMenu); 1150 mobileMenu('load'); 1151 }); 1152 1153 $("#nbHeaderMenuMobile").on("click", mobile_fn.openMenu); 1154 $("#nbCloseMobileMenu01, #nbCloseMobileMenu02").on("click", mobile_fn.closeMenu); 1155/* 1156 * 모ë°ì¼ ë©ë´ open & close 1157 * 1158 */// 1159 1160/* 1161 * 모ë°ì¼ & PC, screen toggle 1162 * 1163 */ 1164
1165 // pc & mobile events 1166 var pc = function() { 1167 nbHeaderMenuContext.off("click").on("mousemove", _headerMenuMouseMove).on("mouseenter", _headerMenuMouseHover).on("mouseleave",_headerMenuMouseOut); 1168 1169 nbHeaderMenuListContext.on("mouseenter", _headerMouseFns.hover).on("mouseleave", _headerMouseFns.leave); 1170 nbHeaderMenuListContext[0].removeAttribute('data-menu'); 1171 1172 mobile_fn.closeMenu(); 1173 1174 return ; 1175 }, 1176 mobile = function() { 1177 nbHeaderMenuListContext.off(); 1178 nbHeaderMenuContext.off().on('click', mobile_fn.firstMenu); 1179 return ; 1180 }; 1181 1182 // window resize functions 1183 nana.event.resize(function(e) { 1184 if (e.width > 959) { 1185 if (screenMode) { 1186 pc(); 1187 more.changeData("PC"); 1188 screenMode = false; 1189 } 1190 } else { 1191 if (!screenMode) { 1192 mobile(); 1193 more.changeData("MOBILE"); 1194 screenMode = true; 1195 } 1196 } 1197 1198 return; 1199 }); 1200/* 1201 * 모ë°ì¼ & PC, screen toggle 1202 * 1203 */// 1204 1205 1206/* 1207 * ê²ì UI 1208 */ 1209function SetCaretAtEnd(elem) { 1210 var elemLen = elem.value.length; 1211 // For IE Only 1212 if (document.selection) { 1213 // Set focus 1214 elem.focus(); 1215 // Use IE Ranges 1216 var oSel = document.selection.createRange(); 1217 // Reset position to 0 & then set at end 1218 oSel.moveStart('character', -elemLen); 1219 oSel.moveStart('character', elemLen); 1220 oSel.moveEnd('character', 0); 1221 oSel.select(); 1222 }else if (elem.selectionStart || elem.selectionStart == '0') { 1223 // Firefox/Chrome 1224 elem.selectionStart = elemLen; 1225 elem.selectionEnd = elemLen; 1226 elem.focus(); 1227 } 1228} 1229 1230//2018.05.16 ê²ì기ë¥ìì 1231//var searchForm = $("#searchForm"), 1232// searchInput = searchForm[0]['keyword'], 1233// searchSetMsgTime = null, 1234// searchFormSend = function(input){ 1235// if(input.value === ''){ 1236// headerMenuSetting.appendMsg(["ê²ìì´ë¥¼ ì ë ¥í´ì£¼ì¸ì", ""], "search"); 1237// if(searchSetMsgTime){ 1238// clearTimeout(searchSetMsgTime); 1239// } 1240// searchSetMsgTime = setTimeout(function(){ 1241// headerMenuSetting.removeMsg(); 1242// }, 2000); 1243// 1244// return false; 1245// }else{ 1246// headerMenuSetting.appendMsg([input.value, "ê²ì ì¤ì ëë¤"], "search"); 1247// } 1248// return true; 1249// }; 1250// 1251 1252var search = { 1253 selected: function(){ 1254 return { 1255 header: typeof this.header === 'undefined' ? (this.header = $("#nbHeader")) : this.header, 1256 submit: typeof this.searchMobileBtn === 'undefined' ? (this.searchMobileBtn = $("#nbSearchMobileBtn")) : this.searchMobileBtn 1257 }; 1258 }, 1259 click: function(e){ 1260 search[ screenMode ? 'mobile' : 'pc' ](e); 1261 return ; 1262 }, 1263 mobileSearch: false, 1264 mobile: function(e){ 1265 1266 var get = this.selected(); 1267 //var input = searchForm[0]['keyword']; 1268 1269 if(this.mobileSearch = !this.mobileSearch){ // toggle 1270 get.header.addClass("nb-searchOn"); 1271 1272 e.preventDefault(); 1273 SetCaretAtEnd(searchInput); 1274 1275 get.submit.on("click", function(){ 1276 searchInput.focus(); 1277 searchForm.submit(); 1278 return ; 1279 }); 1280 1281 }else{ 1282 get.header.removeClass("nb-searchOn"); 1283 get.submit.off("click"); 1284 headerMenuSetting.removeMsg(); 1285 } 1286 1287 return ; 1288 }, 1289 pc: function(e){ 1290 searchForm.submit(); 1291 return ; 1292 } 1293}; 1294 1295$("#nbSearchBtn").on("click", search.click); 1296 1297// 2018.05.16 ê²ì기ë¥ìì 1298//searchForm.on("submit", function(){ 1299// return searchFormSend( searchInput ); 1300//}); 1301 1302 1303/* 1304 * ê²ì UI 1305 */// 1306 1307window.nanaBand = { 1308 header : headerMenuSetting.ini, 1309 get : _get, 1310 care: headerMenuSetting 1311}; 1312 1313 1314 1315})(window, document, jQuery); 1316 1317 1318 1319 1320
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.