From e883af153ea37aa3f2460179b044f703c6d67e50 Mon Sep 17 00:00:00 2001 From: taggon Date: Tue, 6 Sep 2011 07:30:11 +0000 Subject: [PATCH] As now, some UIPatterns are also jQuery plugins git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9051 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- modules/admin/tpl/js/admin.js | 482 +++++++++++++++++++--------------- 1 file changed, 265 insertions(+), 217 deletions(-) diff --git a/modules/admin/tpl/js/admin.js b/modules/admin/tpl/js/admin.js index 0a730f61e..3007668c1 100644 --- a/modules/admin/tpl/js/admin.js +++ b/modules/admin/tpl/js/admin.js @@ -96,8 +96,73 @@ jQuery(function($){ }) .end() - // Modal Window - $('a.modalAnchor') + // pagination + $.fn.xePagination = function(){ + this + .find('span.tgContent').css('whiteSpace', 'nowrap').end() + .find('a.tgAnchor[href="#goTo"]') + .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 + $('.dashboard>.section>.portlet:odd').after('
'); + + + // 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(); + }); +}); + +// Modal Window +jQuery(function($){ + +$.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; @@ -193,40 +258,21 @@ jQuery(function($){ $modal.fadeOut(duration, after); $this.focus(); }); +}; +$('a.modalAnchor').xeModalWindow(); - $('div.modal').addClass('x').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(); +// Content Toggler +jQuery(function($){ - // 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') +$.fn.xeContentToggler = function(){ + this + .not('.xe-content-toggler') + .addClass('xe-content-toggler') + .each(function(){ + $($(this).attr('href')).hide().focusout(focusoutContent); + }) .click(function(){ var $this = $(this), $layer; @@ -340,122 +386,114 @@ jQuery(function($){ $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(); - }); + return this; +}; + +$('a.tgAnchor').xeContentToggler(); + +function focusoutContent(event) { + var $this = $(this), $anchor = $this.data('anchor'); + setTimeout(function(){ + if(!$this.find(':focus').length && $this.data('state') == 'showing') $anchor.trigger('close.tc'); + }, 1); +}; + }); // Module finder jQuery(function($){ -$('.modulefinder') - .find('a.tgAnchor.findsite') - .bind('before-open.tc', function(){ - var $this, $ul, val; +$.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(); + $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; + function on_complete(data) { + var $li, list = data.site_list, i, c; - $ul.empty(); - $this.closest('.modulefinder').find('.moduleList,.moduleIdList').attr('disabled','disabled'); + $ul.empty(); + $this.closest('.modulefinder').find('.moduleList,.moduleIdList').attr('disabled','disabled'); - if(data.error || !$.isArray(list)) { - $this.trigger('close.tc'); - return; - } + if(data.error || !$.isArray(list)) { + $this.trigger('close.tc'); + return; + } - for(i=0,c=list.length; i < c; i++) { - $li = $('
  • ').appendTo($ul); - $('