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
This commit is contained in:
taggon 2011-09-06 07:30:11 +00:00
parent b8a597e219
commit e883af153e

View file

@ -96,8 +96,73 @@ jQuery(function($){
}) })
.end() .end()
// Modal Window // pagination
$('a.modalAnchor') $.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('<br style="clear:both" />');
// 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('<p class="btnArea"><button type="button">&rsaquo; more</button></p>')
.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(){ .click(function(){
var $this = $(this), $modal, $btnClose, disabled; var $this = $(this), $modal, $btnClose, disabled;
@ -193,40 +258,21 @@ jQuery(function($){
$modal.fadeOut(duration, after); $modal.fadeOut(duration, after);
$this.focus(); $this.focus();
}); });
};
$('a.modalAnchor').xeModalWindow();
$('div.modal').addClass('x').hide(); });
// pagination // Content Toggler
$('.pagination') jQuery(function($){
.find('span.tgContent').css('whiteSpace', 'nowrap').end()
.find('a.tgAnchor[href="#goTo"]') $.fn.xeContentToggler = function(){
.each(function(idx){ this
var $this = $(this); .not('.xe-content-toggler')
$this.after( $($this.attr('href')) ); .addClass('xe-content-toggler')
.each(function(){
$($(this).attr('href')).hide().focusout(focusoutContent);
}) })
.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('<br style="clear:both" />');
// Toggle Contents
$('a.tgAnchor')
.click(function(){ .click(function(){
var $this = $(this), $layer; var $this = $(this), $layer;
@ -340,41 +386,28 @@ jQuery(function($){
$this.trigger('after-close.tc'); $this.trigger('after-close.tc');
} }
}); });
$('.tgContent')
.hide() return this;
.focusout(function(event){ };
$('a.tgAnchor').xeContentToggler();
function focusoutContent(event) {
var $this = $(this), $anchor = $this.data('anchor'); var $this = $(this), $anchor = $this.data('anchor');
setTimeout(function(){ setTimeout(function(){
if(!$this.find(':focus').length && $this.data('state') == 'showing') $anchor.trigger('close.tc'); if(!$this.find(':focus').length && $this.data('state') == 'showing') $anchor.trigger('close.tc');
}, 1); }, 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('<p class="btnArea"><button type="button">&rsaquo; more</button></p>')
.find('+p>button')
.click(function(){
// Display all sections then hide this button
$(this).hide().parent().prevAll('.section').show();
});
}); });
// Module finder // Module finder
jQuery(function($){ jQuery(function($){
$('.modulefinder') $.fn.xeModuleFinder = function(){
this
.not('.xe-module-finder')
.addClass('xe-module-finder')
.find('a.tgAnchor.findsite') .find('a.tgAnchor.findsite')
.bind('before-open.tc', function(){ .bind('before-open.tc', function(){
var $this, $ul, val; var $this, $ul, val;
@ -456,6 +489,11 @@ $('.modulefinder')
} }
$mid_select.prop('selectedIndex', 0); $mid_select.prop('selectedIndex', 0);
}); });
return this;
};
$('.modulefinder').xeModuleFinder();
}); });
// Sortable table // Sortable table
@ -465,7 +503,10 @@ var
dragging = false, dragging = false,
$holder = $('<tr class="placeholder"><td>&nbsp;</td></tr>'); $holder = $('<tr class="placeholder"><td>&nbsp;</td></tr>');
$('table.sortable') $.fn.xeSortableTable = function(){
this
.not('.xe-sortable-table')
.addClass('xe-sortable-table')
.delegate('button.dragBtn', 'mousedown.st', function(event){ .delegate('button.dragBtn', 'mousedown.st', function(event){
var $this, $tr, $table, $th, height, width, offset, position, offsets, i, dropzone, cols; var $this, $tr, $table, $th, height, width, offset, position, offsets, i, dropzone, cols;
@ -578,6 +619,11 @@ $('table.sortable')
}); });
}) })
return this;
};
$('table.sortable').xeSortableTable();
function getOffset(elem, offsetParent) { function getOffset(elem, offsetParent) {
var top = 0, left = 0; var top = 0, left = 0;
@ -662,6 +708,8 @@ $('.multiLangEdit')
.blur(function(){ .blur(function(){
clearTimeout(w_timer); clearTimeout(w_timer);
w_timer = null; w_timer = null;
$(this).closest('.multiLangEdit').focusout();
}) })
.end() .end()
.find('a.tgAnchor.editUserLang') .find('a.tgAnchor.editUserLang')