/* NHN (developers@xpressengine.com) */ // insert fog layer function showWaitingFogLayer() { var $bg = jQuery(''); $bg.height(jQuery(window).height()); jQuery('.wfsr') .wrap('
') .before($bg); } function hideWaitingFogLayer() { jQuery('.wfsr').prev('span').remove(); jQuery('.wfsr').unwrap(); } // install module function doInstallModule(module) { var params = new Array(); params['module_name'] = module; exec_xml('install','procInstallAdminInstall',params, completeInstallModule); showWaitingFogLayer(); } // upgrade module function doUpdateModule(module) { var params = new Array(); params['module_name'] = module; exec_xml('install','procInstallAdminUpdate',params, completeInstallModule); showWaitingFogLayer(); } function completeInstallModule(ret_obj) { alert(ret_obj['message']); location.reload(); } jQuery(function($){ // iSO mobile device toolbar remove window.scrollTo(0,0); // Skip to content $('.x .skipNav>a').click(function(){ $($(this).attr('href')).attr('tabindex','0').css('outline','0').focus(); }); // TARGET toggle $(document.body).on('click', '.x [data-toggle]', function(){ var $this = $(this); var $target = $($this.attr('data-toggle')); var focusable = 'a,input,button,textarea,select'; $target.toggle(); if($target.is(':visible') && !$target.find(focusable).length){ $target.attr('tabindex','0').not(':disabled').focus(); } else if($target.is(':visible') && $target.find(focusable).length) { $target.find(focusable).not(':disabled').eq(0).focus(); } else { $this.focus(); } return false; }); // TARGET show $(document.body).on('click', '.x [data-show]', function(){ $($(this).attr('data-show')).show().attr('tabindex','0').focus(); return false; }); // TARGET hide $(document.body).on('click', '.x [data-hide]', function(){ var $this = $(this); $($this.attr('data-hide')).hide(); $this.focus(); return false; }); // Tab Navigation $.fn.xeTabbable = function(){ $(this).each(function(){ var $this = $(this); $this.find('>.x_nav-tabs>li>a').each(function(index){ $(this).attr('data-index', index+1); }); $this.find('>.x_tab-content>.x_tab-pane').each(function(index){ $(this).attr('data-index', index+1); }); }); $('.x .x_tab-content>.x_tab-pane:not(".x_active")').hide(); } $('.x .x_tabbable').xeTabbable(); $(document.body).on('click', '.x .x_nav-tabs>li>a[href*="#"]', function(){ var $this = $(this); $this.parent('li').addClass('x_active').siblings().removeClass('x_active'); $this.closest('.x_nav-tabs').next('.x_tab-content').find('>.x_tab-pane').eq($this.attr('data-index')-1).addClass('x_active').show().siblings().removeClass('x_active').hide(); $(this).parents('.x_tabbable').trigger('tab_change', [parseInt($(this).attr('data-index'))-1, $(this)]); return false; }); // GNB $.fn.gnb = function(){ var $xBody = $('.x>.xin>.body'); var $xContent = $xBody.children('#content.content'); var $xGnb = $xBody.find('>.gnb'); var $xGnb_li = $xGnb.find('>ul>li'); // Add icon $xGnb_li.find('>a').prepend(''); // Active Submenu Copy $xGnb_li.each(function(index){ $(this).attr('data-index', index+1); }); var parentIndex = $xGnb_li.find('>ul>li.active_').closest('li.active').attr('data-index'); $xGnb_li.find('>ul>li.active_').clone().addClass('active').attr('data-index', parentIndex).prependTo('#gnbNav').find('>a').prepend(''); // Index // GNB Hover toggle function reflow(){ // Browser bug fix & resize height $xContent.width('99.99%'); setTimeout(function(){ $xContent.removeAttr('style'); if($xGnb.height() > $xContent.height()){ $xContent.height($xGnb.height()); } }, 100); } // GNB Click toggle $xGnb_li.find('ul').prev('a') .bind('click focus', function(){ var $this = $(this); $this.parent('li').addClass('open').siblings('li').removeClass('open'); $xBody.removeClass('wide'); reflow(); return false; }); // GNB Mobile Toggle $xGnb.find('>a[href="#gnbNav"]').click(function(){ $(this).parent('.gnb').toggleClass('open'); $xBody.toggleClass('wide'); reflow(); return false; }); // GNB Close $xGnb .prepend(''); $('.x .section.collapse>h1>.snToggle').removeClass('x_icon-chevron-up').addClass('x_icon-chevron-down'); $section_heading.find('>.snToggle').click(function(){ var $this = $(this); var $section = $this.closest('.section'); if(!$section.hasClass('collapse')){ $section.addClass('collapse').children('h1:first').siblings().hide(); $this.removeClass('x_icon-chevron-up').addClass('x_icon-chevron-down'); } else { $section.removeClass('collapse').children('h1:first').siblings().show(); $this.removeClass('x_icon-chevron-down').addClass('x_icon-chevron-up'); } reflow(); }); } // Alert Closer var $xAlert = $('.x .x_alert'); $xAlert.prepend(''); $xAlert.children('.x_close').click(function(){ $(this).parent('.x_alert').hide(); }); // Desabled Buttons $('.x .x_btn').click(function(){ if($(this).hasClass('x_disabled')){ return false; } }); // Vertical Divider $.fn.vr = function(){ this.each(function(){ var $this = $(this); if($this.text() == '|'){ $this.addClass('vr').filter(':first-child, :last-child').remove(); } }); }; $('.x i').vr(); // label[for] + input[id]/textarea[id]/select[id] creator $.fn.labelMaker = function(){ this.each(function(index){ index = index + 1; var $this = $(this); var input = 'input, textarea, select'; var check = ':radio, :checkbox'; var id = '[id]'; var value = 'i' + index; if($this.next(input).filter(id).not(check).length){ // next input, textarea, select id true $this.attr('for', $this.next().attr('id')); } else if ($this.next(input).not(id).not(check).length) { // next input, textarea, select id false $this.attr('for', value).next().attr('id', value); } else if ($this.prev(check).filter(id).length) { // prev :radio :checkbox id true $this.attr('for', $this.prev().attr('id')); } else if ($this.prev(check).not(id).length) { // prev :radio :checkbox id false $this.attr('for', value).prev().attr('id', value); } else if ($this.children(input).filter(id).length) { // children id true $this.attr('for', $this.children(input).filter(id).eq(0).attr('id')); } else if ($this.children(input).not(id).length) { // children id false $this.attr('for', value).children(input).not(id).eq(0).attr('id', value); } }); }; $('label:not([for])').labelMaker(); // :radio, :checkbox checked class $.fn.checkToggle = function(){ function check(){ setTimeout(function(){ $(':checked').parent('label').addClass('checked'); $(':not(":checked")').parent('label').removeClass('checked'); },0); } this.change(check); check(); }; $(':radio, :checkbox').checkToggle(); // File input .overlap style $.fn.fileTypeOverlap = function(){ this.each(function(){ var $this = $(this); $this.wrap('').before(''); $btnClose.click(function(){ $modal.data('anchor').trigger('close.mw') }); $modal.find('[data-hide]').click(function(){ $modal.data('anchor').trigger('close.mw') }); $('body').append('
').append($modal); // append background $modal.prepend($btnClose); // prepend close button } // set the related anchor $modal.data('anchor', $this); // before event trigger before_event = $.Event('before-open.mw'); $this.trigger(before_event); // is event canceled? if(before_event.isDefaultPrevented()) return false; // get modal window $modal = $( $this.attr('href') ); // get duration duration = $this.data('duration') || 'fast'; // set state : showing $modal.data('state', 'showing'); // after event trigger function after(){ $this.trigger('after-open.mw') }; $(document).bind('keydown.mw', function(event){ if(event.which == ESC) { $this.trigger('close.mw'); return false; } }); $modal .fadeIn(duration, after) .find('button.x_close:first').focus().end() .prev('.x_modal-backdrop').show(); $('body').css('overflow','hidden'); }) .bind('close.mw', function(){ var $this = $(this), before_event, $modal, duration; // before event trigger before_event = $.Event('before-close.mw'); $this.trigger(before_event); // is event canceled? if(before_event.isDefaultPrevented()) return false; // get modal window $modal = $( $this.attr('href') ); // get duration duration = $this.data('duration') || 'fast'; // set state : hiding $modal.data('state', 'hiding'); // after event trigger function after(){ $this.trigger('after-close.mw') }; $modal.fadeOut(duration, after) .prev('.x_modal-backdrop').hide(); $('body').css('overflow','auto'); $this.focus(); }); $('div.x_modal').addClass('x').hide(); }; $('a.modalAnchor').xeModalWindow(); }); // Content Toggler jQuery(function($){ var dont_close_this_time = false; var ESC = 27; $.fn.xeContentToggler = function(){ this .not('.xe-content-toggler') .addClass('xe-content-toggler') .each(function(){ var $anchor = $(this); $layer = $($anchor.attr('href')); $layer.hide() .not('.xe-toggling-content') .addClass('xe-toggling-content') .mousedown(function(event){ dont_close_this_time = true }) .focusout(function(event){ setTimeout(function(){ if(!dont_close_this_time && !$layer.find(':focus').length && $layer.data('state') == 'showing') $anchor.trigger('close.tc'); dont_close_this_time = false; }, 1); }); }) .click(function(){ var $this = $(this), $layer; // get content container $layer = $( $this.attr('href') ); // set anchor object $layer.data('anchor', $this); if($layer.data('state') == 'showing') { $this.trigger('close.tc'); } else { $this.trigger('open.tc'); } return false; }) .bind('open.tc', function(){ var $this = $(this), $layer, effect, duration; // get content container $layer = $( $this.attr('href') ); // get effeect effect = $this.data('effect'); // get duration duration = $this.data('duration') || 'fast'; // set state : showing $layer.data('state', 'showing'); // before event trigger $this.trigger('before-open.tc'); dont_close_this_time = false; // When mouse button is down or when ESC key is pressed close this layer $(document) .unbind('mousedown.tc keydown.tc') .bind('mousedown.tc keydown.tc', function(event){ if(event) { if(event.type == 'keydown' && event.which != ESC) return true; if(event.type == 'mousedown') { var $t = $(event.target); if($t.is('html,.tgAnchor,.tgContent') || $layer.has($t).length) return true; } } $this.trigger('close.tc'); return false; } ); // triggering after function trigger_after(){ $this.trigger('after-open.tc') } switch(effect) { case 'slide': $layer.slideDown(duration, trigger_after); break; case 'slide-h': var w = $layer.css({'overflow-x':'',width:''}).width(); $layer .show() .css({'overflow-x':'hidden',width:'0px'}) .animate({width:w}, duration, function(){ $layer.css({'overflow-x':'',width:''}); trigger_after(); }); break; case 'fade': $layer.fadeIn(duration, trigger_after); break; default: $layer.show(); $this.trigger('after-open.tc'); } }) .bind('close.tc', function(){ var $this = $(this), $layer, effect, duration; // unbind document's event handlers $(document).unbind('mousedown.tc keydown.tc'); // get content container $layer = $( $this.attr('href') ); // get effeect effect = $this.data('effect'); // get duration duration = $this.data('duration') || 'fast'; // set state : hiding $layer.data('state', 'hiding'); // before event trigger $this.trigger('before-close.tc'); // triggering after function trigger_after(){ $this.trigger('after-close.tc') }; // close this layer switch(effect) { case 'slide': $layer.slideUp(duration, trigger_after); break; case 'slide-h': $layer.animate({width:0}, duration, function(){ $layer.hide(); trigger_after(); }); break; case 'fade': $layer.fadeOut(duration, trigger_after); break; default: $layer.hide(); $this.trigger('after-close.tc'); } }); return this; }; $('a.tgAnchor').xeContentToggler(); }); // Module finder jQuery(function($){ $.fn.xeModuleFinder = function(){ this .not('.xe-module-finder') .addClass('xe-module-finder') .find('a.tgAnchor.findsite') .bind('before-open.tc', function(){ var $this, $ul, val; $this = $(this); $ul = $($this.attr('href')).find('>ul'); val = $this.prev('input:text').val(); function on_complete(data) { var $li, list = data.site_list, i, c; $ul.empty(); $this.closest('.modulefinder').find('.moduleList,.moduleIdList').attr('disabled','disabled'); if(data.error || !$.isArray(list)) { $this.trigger('close.tc'); return; } for(i=0,c=list.length; i < c; i++) { $li = $('
  • ').appendTo($ul); $('