/* NHN (developers@xpressengine.com) */ jQuery(function($){ // Constants var ESC_KEY = 27; // Overlapping label $('.form li').find('>input:text:not(".notmulti"),>input:password,>textarea') .filter('input[value!=""],textarea:not(:empty)').prev('label').css('visibility','hidden').end().end() .prev('label') .addClass('overlap') .css({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]); }); // pagination $.fn.xePagination = function(){ this .not('.xe-pagination') .addClass('xe-pagination') .find('span.tgContent').css('whiteSpace', 'nowrap').end() .find('a.tgAnchor') .each(function(idx){ var $this = $(this); $this.after( $($this.attr('href')) ); }) .end(); return this; }; $('.pagination').xePagination(); // 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 $(window).resize(function(){ if($(document).width() < 1300){ $('.dashboard>.section>br').remove(); $('.dashboard>.section>.portlet:odd').after('
'); } else { $('.dashboard>.section>br').remove(); $('.dashboard>.section>.portlet:eq(2),.dashboard>.section>.portlet:eq(5)').after('
'); } }); $(window).resize(); // 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(); }); $.fn.xeMask = function(){ this .each(function(){ var $this = $(this), text = $this.text(); var reg_mail = /^([\w\-\.]+?)@(([\w-]+\.)+[a-z]{2,})$/ig; if(reg_mail.test(text)) { $this .html(text.replace(/(@.+)$/, '...$1')) .find('>.ellipsis') .css({position:'absolute',zIndex:1}) .hover( function(){ $(this).next('.cover').mouseover() }, function(){ $(this).next('.cover').mouseout() } ) .end() .find('>.cover') .css({zIndex:2,opacity:0}) .hover( function(){ $(this).css('opacity',1).prev('span').css('visibility','hidden') }, function(){ $(this).css('opacity',0).prev('span').css('visibility','visible') } ) .end(); } }) }; $('.masked').xeMask(); }); // Global Navigation Bar jQuery(function($){ $.fn.xeMenu = function(){ this .attr('role', 'navigation') // WAI-ARIA role .find('>.nav-gnb>li') .attr('role', 'menuitem') // WAI-ARIA role .filter(':has(>ul)') .attr('aria-haspopup', 'true') // WAI-ARIA .end() .end() .find('>.nav-gnb') .mouseover(function(){ $(this) .parent('.gnb').addClass('active').end() .find('>li>ul').css('height','auto').end() }) .mouseleave(function(){ $(this) .parent('.gnb').removeClass('active').end() .find('>li>ul').css('height','0').end() }) .focusout(function(){ var $this = $(this); setTimeout(function(){ if(!$this.find(':focus').length) { $this.mouseleave(); } }, 1); }) .delegate('a', { focus : function(){ $(this).mouseover(); } }); }; $('div.gnb').xeMenu(); $('.gnb>.mnv').change(function(){ window.location.href=$(this).find('option:selected').val(); }); }); // Modal Window jQuery(function($){ var ESC = 27; $.fn.xeModalWindow = function(){ this .not('.xe-modal-window') .addClass('xe-modal-window') .each(function(){ $( $(this).attr('href') ).addClass('x').hide(); }) .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) { $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(); }); }; $('a.modalAnchor').xeModalWindow(); $('div.modal').addClass('x').hide(); }); // 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); $(''); $(this).append($sTog); $sTog.click(function(){ var $t = $(this); var $sTogObj = $t.parent().nextUntil('.h2, .h3').not('.langEdit, .tgContent, .modal'); if($t.parent().next().is(':hidden')){ $t.find('i').attr('class','icon-chevron-up'); $sTogObj.slideDown(200); } else { $t.find('i').attr('class','icon-chevron-down'); $sTogObj.slideUp(200); } }); }); });