/* NHN (developers@xpressengine.com) */ jQuery(function($){ // Constants var ESC_KEY = 27; // Overlapping label $('.form li').find('>input:text,>input:password,>textarea') .filter('input[value!=""],textarea:not(:empty)').prev('label').css('visibility','hidden').end().end() .prev('label') .css({position:'absolute',top:'15px',left:'5px'}) .next() .focus(function(){ var $label = $(this).prev().stop().animate({opacity:0, left:'25px'},'fast',function(){ $label.css('visibility','hidden') }); }) .blur(function(){ var $this = $(this), $label; if($.trim($this.val()) == '') { $label = $this.prev().stop().css('visibility','visible').animate({opacity:1, left:'5px'},'fast'); } }) .end() .parent() .css('position', 'relative'); // Make selected checkbox elements bold var $rc_label = $('input:radio+label,input:checkbox+label'), $input_rc = $rc_label.prev('input'); $input_rc .change(function(){ var name = $(this).attr('name'); $input_rc .filter(function(){ return this.name == name }) .next('label').css('font-weight', 'normal').end() .filter(':checked') .next('label').css('font-weight', 'bold').end(); }) .change(); // Toogle checkbox all $('.form th>input: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]); }); // Global Navigation Bar var $menuitems = $('div.gnb') .removeClass('jx') .attr('role', 'navigation') // WAI-ARIA role .find('li') .attr('role', 'menuitem') // WAI-ARIA role .filter(':has(>ul)') .attr('aria-haspopup', 'true') // WAI-ARIA .find('>ul').hide().end() .mouseover(function(){ var $this = $(this); if($this.css('float') == 'left') $this.find('>ul:hidden').prev('a').click(); }) .mouseleave(function(){ var $this = $(this); if($this.css('float') == 'left') $this.find('>ul:visible').slideUp(100); }) .find('>a') .focus(function(){ $(this).click() }) .click(function(){ $menuitems.removeClass('active'); $(this) .next('ul').slideToggle(100).end() .parent().addClass('active'); return false; }) .end() .end() .find('>a') .blur(function(){ var anchor = this; setTimeout(function(){ var $a = $(anchor), $ul = $a.closest('ul'), $focus = $ul.find('a:focus'); if(!$focus.length || $focus.closest('ul').parent('div.gnb').length) { if($ul.parent('div.gnb').length) $ul = $a.next('ul'); $ul.filter(':visible').slideUp(100); } }, 10); }) .end() // Modal Window $('a.modalAnchor') .click(function(){ var $this = $(this), $modal, $btnClose, disabled; // get and initialize modal window $modal = $( $this.attr('href') ); if(!$modal.parent('body').length) { $btnClose = $(''); $btnClose.click(function(){ $modal.data('anchor').trigger('close.mw') }); $modal .prepend('') .append('') .find('>.fg') .prepend($btnClose) .append($btnClose.clone(true)) .end() .appendTo('body'); } // set the related anchor $modal.data('anchor', $this); if($modal.data('state') == 'showing') { $this.trigger('close.mw'); } else { $this.trigger('open.mw'); } return false; }) .bind('open.mw', function(){ var $this = $(this), before_event, $modal, duration; // 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'); // workaroud for IE6 $('html,body').addClass('modalContainer'); // after event trigger function after(){ $this.trigger('after-open.mw') }; $(document).bind('keydown.mw', function(event){ if(event.which == ESC_KEY) { $this.trigger('close.mw'); return false; } }); $modal .fadeIn(duration, after) .find('>.bg').height($(document).height()).end() .find('button.modalClose:first').focus(); }) .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'); // workaroud for IE6 $('html,body').removeClass('modalContainer'); // after event trigger function after(){ $this.trigger('after-close.mw') }; $modal.fadeOut(duration, after); $this.focus(); }); $('div.modal').hide(); // pagination $('.pagination') .find('span.tgContent').css('whiteSpace', 'nowrap').end() .find('a.tgAnchor[href="#goTo"]') .each(function(idx){ var $this = $(this); $this.after( $($this.attr('href')) ); }) .end(); // Portlet Action $('.portlet .action') .css({display:'none',position:'absolute'}) .parent() .mouseleave(function(){ $(this).find('>.action').fadeOut(100); }) .mouseenter(function(){ $(this).find('>.action').fadeIn(100); }) .focusin(function(){ $(this).mouseenter() }) .focusout(function(){ var $this = $(this), timer; clearTimeout($this.data('timer')); timer = setTimeout(function(){ if(!$this.find(':focus').length) $this.mouseleave() }, 10); $this.data('timer', timer); }); // Display the dashboard in two column $('.dashboard>.section>.portlet:odd').after('
'); // Toggle Contents $('a.tgAnchor') .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'); // 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 && ( (event.type == 'keydown' && event.which != ESC_KEY) || (event.type == 'mousedown' && ($(event.target).is('.tgAnchor,.tgContent') || $layer.has(event.target)[0])) )) 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'); } }); $('.tgContent') .hide() .focusout(function(event){ var $this = $(this), $anchor = $this.data('anchor'); setTimeout(function(){ if(!$this.find(':focus').length && $this.data('state') == 'showing') $anchor.trigger('close.tc'); }, 1); }) // Popup list : 'Move to site' and 'Site map' $('.header>.siteTool>a.i') .bind('before-open.tc', function(){ $(this) .addClass('active') .next('div.tgContent') .find('>.section:gt(0)').hide().end() .find('>.btnArea>button').show(); }) .bind('after-close.tc', function(){ $(this).removeClass('active'); }) .next('#siteMapList') .find('>.section:last') .after('

') .find('+p>button') .click(function(){ // Display all sections then hide this button $(this).hide().parent().prevAll('.section').show(); }); }); // Module finder jQuery(function($){ $('.modulefinder') .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); $('