Add JS files
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
/*!
|
||||
* custom pager controls (beta) for TableSorter 9/15/2014 (v2.17.8)
|
||||
initialize custom pager script BEFORE initializing tablesorter/tablesorter pager
|
||||
custom pager looks like this:
|
||||
1 | 2 … 5 | 6 | 7 … 99 | 100
|
||||
_ _ _ _ adjacentSpacer
|
||||
_ _ distanceSpacer
|
||||
_____ ________ ends (2 default)
|
||||
_________ aroundCurrent (1 default)
|
||||
|
||||
*/
|
||||
/*jshint browser:true, jquery:true, unused:false, loopfunc:true */
|
||||
/*global jQuery: false */
|
||||
|
||||
;(function($){
|
||||
"use strict";
|
||||
|
||||
$.tablesorter = $.tablesorter || {};
|
||||
|
||||
$.tablesorter.customPagerControls = function(settings) {
|
||||
var defaults = {
|
||||
table : 'table',
|
||||
pager : '.pager',
|
||||
pageSize : '.left a',
|
||||
currentPage : '.right a',
|
||||
ends : 2, // number of pages to show of either end
|
||||
aroundCurrent : 1, // number of pages surrounding the current page
|
||||
link : '<a href="#">{page}</a>', // page element; use {page} to include the page number
|
||||
currentClass : 'current', // current page class name
|
||||
adjacentSpacer : ' | ', // spacer for page numbers next to each other
|
||||
distanceSpacer : ' … ', // spacer for page numbers away from each other (ellipsis)
|
||||
addKeyboard : true // add left/right keyboard arrows to change current page
|
||||
},
|
||||
options = $.extend({}, defaults, settings),
|
||||
$table = $(options.table),
|
||||
$pager = $(options.pager);
|
||||
|
||||
$table
|
||||
.on('pagerInitialized pagerComplete', function (e, c) {
|
||||
var indx,
|
||||
p = c.pager ? c.pager : c, // using widget
|
||||
pages = $('<div/>'),
|
||||
pageArray = [],
|
||||
cur = p.page + 1,
|
||||
start = cur > 1 ? (p.filteredPages - cur < options.aroundCurrent ? -(options.aroundCurrent + 1) + (p.filteredPages - cur) : -options.aroundCurrent) : 0,
|
||||
end = cur < options.aroundCurrent + 1 ? options.aroundCurrent + 3 - cur : options.aroundCurrent + 1;
|
||||
for (indx = start; indx < end; indx++) {
|
||||
if (cur + indx >= 1 && cur + indx < p.filteredPages) { pageArray.push( cur + indx ); }
|
||||
}
|
||||
if (pageArray.length) {
|
||||
// include first and last pages (ends) in the pagination
|
||||
for (indx = 0; indx < options.ends; indx++){
|
||||
if ($.inArray(indx + 1, pageArray) === -1) { pageArray.push(indx + 1); }
|
||||
if ($.inArray(p.filteredPages - indx, pageArray) === -1) { pageArray.push(p.filteredPages - indx); }
|
||||
}
|
||||
// sort the list
|
||||
pageArray = pageArray.sort(function(a, b){ return a - b; });
|
||||
// make links and spacers
|
||||
$.each(pageArray, function(indx, value){
|
||||
pages
|
||||
.append( $(options.link.replace(/\{page\}/g, value)).toggleClass(options.currentClass, value === cur).attr('data-page', value) )
|
||||
.append( '<span>' + (indx < pageArray.length - 1 && ( pageArray[ indx + 1 ] - 1 !== value ) ? options.distanceSpacer :
|
||||
( indx >= pageArray.length - 1 ? '' : options.adjacentSpacer )) + '</span>' );
|
||||
});
|
||||
}
|
||||
$pager.find('.pagecount').html(pages.html());
|
||||
});
|
||||
|
||||
// set up pager controls
|
||||
$pager.find(options.pageSize).on('click', function () {
|
||||
$(this)
|
||||
.addClass(options.currentClass)
|
||||
.siblings()
|
||||
.removeClass(options.currentClass);
|
||||
$table.trigger('pageSize', $(this).html());
|
||||
return false;
|
||||
}).end()
|
||||
.on('click', options.currentPage, function(){
|
||||
$(this)
|
||||
.addClass(options.currentClass)
|
||||
.siblings()
|
||||
.removeClass(options.currentClass);
|
||||
$table.trigger('pageSet', $(this).attr('data-page'));
|
||||
return false;
|
||||
});
|
||||
|
||||
// make right/left arrow keys work
|
||||
if (options.addKeyboard) {
|
||||
$(document).on('keydown', function(events){
|
||||
// ignore arrows inside form elements
|
||||
if (/input|select|textarea/i.test(events.target.tagName)) { return; }
|
||||
if (events.which === 37) {
|
||||
// left
|
||||
$pager.find(options.currentPage).filter('.' + options.currentClass).prevAll(':not(span):first').click();
|
||||
} else if (events.which === 39) {
|
||||
// right
|
||||
$pager.find(options.currentPage).filter('.' + options.currentClass).nextAll(':not(span):first').click();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
182
modules/EcmReports/TableSorterNew/beta-testing/widget-reorder.js
Normal file
182
modules/EcmReports/TableSorterNew/beta-testing/widget-reorder.js
Normal file
@@ -0,0 +1,182 @@
|
||||
/*! tablesorter column reorder - beta testing
|
||||
* Requires tablesorter v2.8+ and jQuery 1.7+
|
||||
* by Rob Garrison
|
||||
*/
|
||||
/*jshint browser:true, jquery:true, unused:false */
|
||||
/*global jQuery: false */
|
||||
;(function($){
|
||||
"use strict";
|
||||
|
||||
$.tablesorter.addWidget({
|
||||
id: 'reorder',
|
||||
priority: 70,
|
||||
options : {
|
||||
reorder_axis : 'xy', // x or xy
|
||||
reorder_delay : 300,
|
||||
reorder_helperClass : 'tablesorter-reorder-helper',
|
||||
reorder_helperBar : 'tablesorter-reorder-helper-bar',
|
||||
reorder_noReorder : 'reorder-false',
|
||||
reorder_blocked : 'reorder-block-left reorder-block-end',
|
||||
reorder_complete : null // callback
|
||||
},
|
||||
init: function(table, thisWidget, c, wo) {
|
||||
var i, timer, $helper, $bar, clickOffset,
|
||||
lastIndx = -1,
|
||||
ts = $.tablesorter,
|
||||
endIndex = -1,
|
||||
startIndex = -1,
|
||||
t = wo.reorder_blocked.split(' '),
|
||||
noReorderLeft = t[0] || 'reorder-block-left',
|
||||
noReorderLast = t[1] || 'reorder-block-end',
|
||||
lastOffset = c.$headers.not('.' + noReorderLeft).first(),
|
||||
offsets = c.$headers.map(function(i){
|
||||
var s, $t = $(this);
|
||||
if ($t.hasClass(noReorderLeft)) {
|
||||
s = lastOffset;
|
||||
$t = s;
|
||||
//lastOffset = $t;
|
||||
}
|
||||
lastOffset = $t;
|
||||
return $t.offset().left;
|
||||
}).get(),
|
||||
len = offsets.length,
|
||||
startReorder = function(e, $th){
|
||||
var p = $th.position(),
|
||||
r = $th.parent().position(),
|
||||
i = startIndex = $th.index();
|
||||
clickOffset = [ e.pageX - p.left, e.pageY - r.top ];
|
||||
$helper = c.$table.clone();
|
||||
$helper.find('> thead > tr:first').children('[data-column!=' + i + ']').remove();
|
||||
$helper.find('thead tr:gt(0), caption, colgroup, tbody, tfoot').remove();
|
||||
$helper
|
||||
.css({
|
||||
position: 'absolute',
|
||||
zIndex : 1,
|
||||
left: p.left - clickOffset[0],
|
||||
top: r.top - clickOffset[1],
|
||||
width: $th.outerWidth()
|
||||
})
|
||||
.appendTo('body')
|
||||
.find('th, td').addClass(wo.reorder_helperClass);
|
||||
$bar = $('<div class="' + wo.reorder_helperBar + '" />')
|
||||
.css({
|
||||
position : 'absolute',
|
||||
top : c.$table.find('thead').offset().top,
|
||||
height : $th.closest('thead').outerHeight() + c.$table.find('tbody').height()
|
||||
})
|
||||
.appendTo('body');
|
||||
positionBar(e);
|
||||
lastIndx = endIndex;
|
||||
},
|
||||
positionBar = function(e){
|
||||
for (i = 0; i <= len; i++) {
|
||||
if ( i > 0 && e.pageX < offsets[i-1] + (offsets[i] - offsets[i-1])/2 && !c.$headers.eq(i).hasClass(noReorderLeft) ) {
|
||||
endIndex = i - 1;
|
||||
// endIndex = offsets.lastIndexOf( offsets[i-1] ); // lastIndexOf not supported by IE8 and older
|
||||
if (endIndex >= 0 && lastIndx === endIndex) { return false; }
|
||||
lastIndx = endIndex;
|
||||
if (c.debug) {
|
||||
ts.log( endIndex === 0 ? 'target before column 0' : endIndex === len ? 'target after last column' : 'target between columns ' + startIndex + ' and ' + endIndex);
|
||||
}
|
||||
$bar.css('left', offsets[i-1]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (endIndex < 0) {
|
||||
endIndex = len;
|
||||
$bar.css('left', offsets[len]);
|
||||
}
|
||||
},
|
||||
finishReorder = function(){
|
||||
$helper.remove();
|
||||
$bar.remove();
|
||||
// finish reorder
|
||||
var adj, s = startIndex,
|
||||
rows = c.$table.find('tr'),
|
||||
cols;
|
||||
startIndex = -1; // stop mousemove updates
|
||||
if ( s > -1 && endIndex > -1 && s != endIndex && s + 1 !== endIndex ) {
|
||||
adj = endIndex !== 0;
|
||||
if (c.debug) {
|
||||
ts.log( 'Inserting column ' + s + (adj ? ' after' : ' before') + ' column ' + (endIndex - adj ? 1 : 0) );
|
||||
}
|
||||
rows.each(function() {
|
||||
cols = $(this).children();
|
||||
cols.eq(s)[ adj ? 'insertAfter' : 'insertBefore' ]( cols.eq( endIndex - (adj ? 1 : 0) ) );
|
||||
});
|
||||
cols = [];
|
||||
// stored header info needs to be modified too!
|
||||
for (i = 0; i < len; i++) {
|
||||
if (i === s) { continue; }
|
||||
if (i === endIndex - (adj ? 1 : 0)) {
|
||||
if (!adj) { cols.push(c.headerContent[s]); }
|
||||
cols.push(c.headerContent[i]);
|
||||
if (adj) { cols.push(c.headerContent[s]); }
|
||||
} else {
|
||||
cols.push(c.headerContent[i]);
|
||||
}
|
||||
}
|
||||
c.headerContent = cols;
|
||||
// cols = c.headerContent.splice(s, 1);
|
||||
// c.headerContent.splice(endIndex - (adj ? 1 : 0), 0, cols);
|
||||
c.$table.trigger('updateAll', [ true, wo.reorder_complete ]);
|
||||
}
|
||||
endIndex = -1;
|
||||
},
|
||||
mdown = function(e, el){
|
||||
var $t = $(el), evt = e;
|
||||
if ($t.hasClass(wo.reorder_noReorder)) { return; }
|
||||
timer = setTimeout(function(){
|
||||
$t.addClass('tablesorter-reorder');
|
||||
startReorder(evt, $t);
|
||||
}, wo.reorder_delay);
|
||||
};
|
||||
|
||||
console.log( c.$headers.last().hasClass(noReorderLast) );
|
||||
|
||||
if ( c.$headers.last().hasClass(noReorderLast) ) {
|
||||
offsets.push( offsets[ offsets.length - 1 ] );
|
||||
} else {
|
||||
offsets.push( c.$table.offset().left + c.$table.outerWidth() );
|
||||
}
|
||||
|
||||
c.$headers.not('.' + wo.reorder_noReorder).bind('mousedown.reorder', function(e){
|
||||
mdown(e, this);
|
||||
});
|
||||
|
||||
$(document)
|
||||
.bind('mousemove.reorder', function(e){
|
||||
if (startIndex !== -1){
|
||||
var c = { left : e.pageX - clickOffset[0] };
|
||||
endIndex = -1;
|
||||
if (/y/.test(wo.reorder_axis)) {
|
||||
c.top = e.pageY - clickOffset[1];
|
||||
}
|
||||
$helper.css(c);
|
||||
positionBar(e);
|
||||
}
|
||||
})
|
||||
.add( c.$headers )
|
||||
.bind('mouseup.reorder', function(){
|
||||
clearTimeout(timer);
|
||||
if (startIndex !== -1 && endIndex !== -1){
|
||||
finishReorder();
|
||||
} else {
|
||||
startIndex = -1;
|
||||
}
|
||||
});
|
||||
|
||||
// has sticky headers?
|
||||
c.$table.bind('stickyHeadersInit', function(){
|
||||
wo.$sticky.find('thead').children().not('.' + wo.reorder_noReorder).bind('mousedown.reorder', function(e){
|
||||
mdown(e, this);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// add mouse coordinates
|
||||
$x = $('#main h1:last'); $(document).mousemove(function(e){ $x.html( e.pageX ); });
|
||||
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user