/* 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('')
.append('');
$xGnb.find('>.close').focus(function(){
$xBody.addClass('wide');
reflow();
});
};
$('.gnb').gnb();
// Default Language Selection
$('.x #lang')
.mouseleave(function(){
$(this).hide();
})
.focusout(function(){
var $this = $(this);
setTimeout(function(){
if(!$this.find('a:focus').length){
$this.mouseleave();
}
}, 500);
});
// Check All
$('.x th>input[type="checkbox"]')
.change(function() {
var $this = $(this), name = $this.data('name');
$this.closest('table')
.find('input:checkbox')
.filter(function(){
var $this = $(this);
return !$this.prop('disabled') && (($this.attr('name') == name) || ($this.data('name') == name));
})
.prop('checked', $this.prop('checked'))
.end()
.end()
.trigger('update.checkbox', [name, this.checked]);
});
// Pagination
$(document.body).on('click', '.x .x_pagination .x_disabled, .x .x_pagination .x_active', function(){
return false;
});
// Section Toggle
if($('.section').length > 1){
var $section_heading = $('.x .section').find('>h1:first');
$section_heading.append('');
$('.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('