diff --git a/addons/pager/jquery.tablesorter.pager.js b/addons/pager/jquery.tablesorter.pager.js index fed5bcf9..02a809ad 100644 --- a/addons/pager/jquery.tablesorter.pager.js +++ b/addons/pager/jquery.tablesorter.pager.js @@ -484,7 +484,8 @@ p.last.currentFilters = p.currentFilters; p.last.sortList = (c.sortList || []).join(','); updatePageDisplay(table, p, false); - $table.trigger('updateCache', [ function(){ + // tablesorter core updateCache (not pager) + ts.updateCache( c, function(){ if (p.initialized) { // apply widgets after table has rendered & after a delay to prevent // multiple applyWidget blocking code from blocking this trigger @@ -492,13 +493,12 @@ if (c.debug) { console.log('Pager: Triggering pagerChange'); } - $table - .trigger('applyWidgets') - .trigger('pagerChange', p); + $table.trigger( 'pagerChange', p ); + ts.applyWidget( table ); updatePageDisplay(table, p, true); }, 0); } - } ]); + }); } if (!p.initialized) { @@ -507,9 +507,8 @@ if (table.config.debug) { console.log('Pager: Triggering pagerInitialized'); } - $(table) - .trigger('applyWidgets') - .trigger('pagerInitialized', p); + $(table).trigger( 'pagerInitialized', p ); + ts.applyWidget( table ); updatePageDisplay(table, p); } }, @@ -619,7 +618,7 @@ if (c.debug) { console.log('Pager: Triggering pagerChange'); } - $t.trigger('pagerChange', p); + $t.trigger( 'pagerChange', p ); } if ( !p.removeRows && !p.showAll ) { hideRows(table, p); @@ -670,7 +669,7 @@ .find('tr.pagerSavedHeightSpacer').remove(); renderTable(table, table.config.rowsCopy, p); p.isDisabled = true; - $(table).trigger('applyWidgets'); + ts.applyWidget( table ); if (table.config.debug) { console.log('Pager: Disabled'); } @@ -691,7 +690,8 @@ updateCache = function(table) { var c = table.config, p = c.pager; - c.$table.trigger('updateCache', [ function(){ + // tablesorter core updateCache (not pager) + ts.updateCache( c, function(){ var i, rows = [], n = table.config.cache[0].normalized; @@ -701,7 +701,7 @@ } c.rowsCopy = rows; moveToPage(table, p, true); - } ]); + }); }, moveToPage = function(table, p, pageMoved) { @@ -753,9 +753,8 @@ if (c.debug) { console.log('Pager: Triggering pageMoved'); } - $t - .trigger('pageMoved', p) - .trigger('applyWidgets'); + $t.trigger('pageMoved', p); + ts.applyWidget( table ); if (table.isUpdating) { if (c.debug) { console.log('Pager: Triggering updateComplete'); @@ -842,7 +841,8 @@ } changeHeight(table, p); if ( triggered ) { - c.$table.trigger('updateRows'); + // tablesorter core update table + ts.update( c ); setPageSize(table, p.size, p); hideRowsSetup(table, p); if (c.debug) { @@ -917,7 +917,7 @@ } updatePageDisplay(table, p, false); moveToPage(table, p, false); - c.$table.trigger('applyWidgets'); + ts.applyWidget( table ); } }) .bind('disablePager' + namespace, function(e){ @@ -1046,7 +1046,7 @@ } else { p.ajax = false; // Regular pager; all rows stored in memory - $(this).trigger('appendCache', true); + ts.appendCache( c, true ); // true = don't apply widgets hideRowsSetup(table, p); } @@ -1058,7 +1058,7 @@ if (c.debug) { console.log('Pager: Triggering pagerInitialized'); } - c.$table.trigger('pagerInitialized', p); + c.$table.trigger( 'pagerInitialized', p ); if ( !( c.widgetOptions.filter_initialized && ts.hasWidget(table, 'filter') ) ) { updatePageDisplay(table, p, false); } diff --git a/dist/js/extras/jquery.dragtable.mod.min.js b/dist/js/extras/jquery.dragtable.mod.min.js index 638aec54..c48d0bea 100644 --- a/dist/js/extras/jquery.dragtable.mod.min.js +++ b/dist/js/extras/jquery.dragtable.mod.min.js @@ -1,3 +1,3 @@ /*! Dragtable Mod for TableSorter - 2/7/2015 (v2.19.0) */ -!function(a){"use strict";function b(){var b=a('');a(document.head).append(b),a(document.body).attr("onselectstart","return false;").attr("unselectable","on"),window.getSelection?window.getSelection().removeAllRanges():document.selection.empty()}function c(){a("#__dragtable_disable_text_selection__").remove(),f?a(document.body).attr("onselectstart",f):a(document.body).removeAttr("onselectstart"),g?a(document.body).attr("unselectable",g):a(document.body).removeAttr("unselectable")}var d,e=a.tablesorter;e.dragtable={create:function(b){var c,d=b.originalTable.el,e=b.options.dragHandle.replace(".","");d.children("thead").children().children("th,td").each(function(){var d=a(this);d.find(b.options.dragHandle+",."+e+"-disabled").length||(c=b.options.dragaccept?d.hasClass(b.options.dragaccept.replace(".","")):!0,d.wrapInner('
').prepend(''))})},start:function(b){b=a(b)[0],b&&b.config&&(b.config.widgetOptions.dragtableLast={search:a(b).data("lastSearch"),order:e.dragtable.getOrder(b)})},update:function(b){var c,d,f,g=b.originalTable,h=g.el[0],i=a(h),j=h.config,k=j&&j.widgetOptions,l=g.startIndex-1,m=g.endIndex-1,n=e.dragtable.getOrder(h)||[],o=e.hasWidget(i,"filter")||!1,p=k&&k.dragtableLast||{},q=[];(p.order||[]).join("")!==n.join("")&&(j.sortList.length&&(d=a.extend(!0,[],j.sortList),a.each(n,function(a,b){f=e.isValueInArray(parseInt(b,10),d),b!==p.order[a]&&f>=0&&(j.sortList[f][0]=a)})),o&&a.each(p.search||[],function(a){q[a]=p.search[n[a]]}),c=e.hasWidget(j.$table,"editable")?k.editable_columnsArray:!1,c&&(j.widgetOptions.editable_columnsArray=e.dragtable.reindexArrayItem(c,l,m)),c=e.hasWidget(j.$table,"math")?k.math_ignore:!1,c&&(j.widgetOptions.math_ignore=e.dragtable.reindexArrayItem(c,l,m)),c=e.hasWidget(j.$table,"resizable")?k.resizable_widths:!1,c&&(k.resizable_widths=e.dragtable.moveArrayItem(c,l,m)),i.trigger("updateAll",[!1,function(){o&&setTimeout(function(){j.lastCombinedFilter=null,j.$table.data("lastSearch",q),e.setFilters(i,q),a.isFunction(b.options.tablesorterComplete)&&b.options.tablesorterComplete(j.table)},10)}]))},getOrder:function(b){return a(b).children("thead").children("."+e.css.headerRow).children().map(function(){return a(this).attr("data-column")}).get()||[]},startColumnMove:function(b){var c,d=b.el[0].config,e=b.startIndex-1,f=b.endIndex-1,g=d.columns-1,h=f===g?!1:e>=f,i=d.$table.children().children("tr");d.debug&&console.log("Inserting column "+e+(h?" before":" after")+" column "+f),i.each(function(){c=a(this).children(),c.eq(e)[h?"insertBefore":"insertAfter"](c.eq(f))}),c=d.$table.children("colgroup").children(),c.eq(e)[h?"insertBefore":"insertAfter"](c.eq(f))},swapNodes:function(a,b){var c,d,e,f=a.length;for(c=0;f>c;c++)d=a[c].parentNode,e=a[c].nextSibling===b[c]?a[c]:a[c].nextSibling,b[c].parentNode.insertBefore(a[c],b[c]),d.insertBefore(b[c],e)},moveArrayItem:function(a,b,c){var e,f=a.length;if(c>=f)for(e=c-f;e--+1;)a.push(d);return a.splice(c,0,a.splice(b,1)[0]),a},reindexArrayItem:function(b,c,d){var e=a.inArray(d,b),f=a.inArray(c,b),g=(Math.max.apply(Math,b),[]);return e>=0&&f>=0?b:(a.each(b,function(a,b){c>d?b>=d?g.push(b+(c>b?1:0)):g.push(b):d>c&&(b===c?g.push(d):d>b&&b>=c?g.push(b-1):d>=b?g.push(b):b>c&&g.push(b+(d>b?0:1)))}),g.sort())}},/*! dragtable v2.0.14 Mod */ +!function(a){"use strict";function b(){var b=a('');a(document.head).append(b),a(document.body).attr("onselectstart","return false;").attr("unselectable","on"),window.getSelection?window.getSelection().removeAllRanges():document.selection.empty()}function c(){a("#__dragtable_disable_text_selection__").remove(),f?a(document.body).attr("onselectstart",f):a(document.body).removeAttr("onselectstart"),g?a(document.body).attr("unselectable",g):a(document.body).removeAttr("unselectable")}var d,e=a.tablesorter;e.dragtable={create:function(b){var c,d=b.originalTable.el,e=b.options.dragHandle.replace(".","");d.children("thead").children().children("th,td").each(function(){var d=a(this);d.find(b.options.dragHandle+",."+e+"-disabled").length||(c=b.options.dragaccept?d.hasClass(b.options.dragaccept.replace(".","")):!0,d.wrapInner('').prepend(''))})},start:function(b){b=a(b)[0],b&&b.config&&(b.config.widgetOptions.dragtableLast={search:a(b).data("lastSearch"),order:e.dragtable.getOrder(b)})},update:function(b){var c,d,f,g=b.originalTable,h=g.el[0],i=a(h),j=h.config,k=j&&j.widgetOptions,l=g.startIndex-1,m=g.endIndex-1,n=e.dragtable.getOrder(h)||[],o=e.hasWidget(i,"filter")||!1,p=k&&k.dragtableLast||{},q=[];(p.order||[]).join("")!==n.join("")&&(j.sortList.length&&(d=a.extend(!0,[],j.sortList),a.each(n,function(a,b){f=e.isValueInArray(parseInt(b,10),d),b!==p.order[a]&&f>=0&&(j.sortList[f][0]=a)})),o&&a.each(p.search||[],function(a){q[a]=p.search[n[a]]}),c=e.hasWidget(j.$table,"editable")?k.editable_columnsArray:!1,c&&(j.widgetOptions.editable_columnsArray=e.dragtable.reindexArrayItem(c,l,m)),c=e.hasWidget(j.$table,"math")?k.math_ignore:!1,c&&(j.widgetOptions.math_ignore=e.dragtable.reindexArrayItem(c,l,m)),c=e.hasWidget(j.$table,"resizable")?k.resizable_widths:!1,c&&(k.resizable_widths=e.dragtable.moveArrayItem(c,l,m)),e.updateAll(j,!1,function(){o&&setTimeout(function(){j.lastCombinedFilter=null,j.$table.data("lastSearch",q),e.setFilters(i,q),a.isFunction(b.options.tablesorterComplete)&&b.options.tablesorterComplete(j.table)},10)}))},getOrder:function(b){return a(b).children("thead").children("."+e.css.headerRow).children().map(function(){return a(this).attr("data-column")}).get()||[]},startColumnMove:function(b){var c,d=b.el[0].config,e=b.startIndex-1,f=b.endIndex-1,g=d.columns-1,h=f===g?!1:e>=f,i=d.$table.children().children("tr");d.debug&&console.log("Inserting column "+e+(h?" before":" after")+" column "+f),i.each(function(){c=a(this).children(),c.eq(e)[h?"insertBefore":"insertAfter"](c.eq(f))}),c=d.$table.children("colgroup").children(),c.eq(e)[h?"insertBefore":"insertAfter"](c.eq(f))},swapNodes:function(a,b){var c,d,e,f=a.length;for(c=0;f>c;c++)d=a[c].parentNode,e=a[c].nextSibling===b[c]?a[c]:a[c].nextSibling,b[c].parentNode.insertBefore(a[c],b[c]),d.insertBefore(b[c],e)},moveArrayItem:function(a,b,c){var e,f=a.length;if(c>=f)for(e=c-f;e--+1;)a.push(d);return a.splice(c,0,a.splice(b,1)[0]),a},reindexArrayItem:function(b,c,d){var e=a.inArray(d,b),f=a.inArray(c,b),g=(Math.max.apply(Math,b),[]);return e>=0&&f>=0?b:(a.each(b,function(a,b){c>d?b>=d?g.push(b+(c>b?1:0)):g.push(b):d>c&&(b===c?g.push(d):d>b&&b>=c?g.push(b-1):d>=b?g.push(b):b>c&&g.push(b+(d>b?0:1)))}),g.sort())}},/*! dragtable v2.0.14 Mod */ a.widget("akottr.dragtable",{options:{revert:!1,dragHandle:".table-handle",maxMovingRows:40,excludeFooter:!1,onlyHeaderThreshold:100,dragaccept:null,persistState:null,restoreState:null,exact:!0,clickDelay:10,containment:null,cursor:"move",cursorAt:!1,distance:0,tolerance:"pointer",axis:"x",beforeStart:a.noop,beforeMoving:a.noop,beforeReorganize:a.noop,beforeStop:a.noop,tablesorterComplete:null,sortClass:".sorter"},originalTable:{el:null,selectedHandle:null,sortOrder:null,startIndex:0,endIndex:0},sortableTable:{el:a(),selectedHandle:a(),movingRow:a()},persistState:function(){var b=this;this.originalTable.el.find("th").each(function(a){""!==this.id&&(b.originalTable.sortOrder[this.id]=a)}),a.ajax({url:this.options.persistState,data:this.originalTable.sortOrder})},_restoreState:function(b){for(var c in b)c in b&&(this.originalTable.startIndex=a("#"+c).closest("th").prevAll().length+1,this.originalTable.endIndex=parseInt(b[c],10)+1,this._bubbleCols())},_bubbleCols:function(){e.dragtable.startColumnMove(this.originalTable)},_rearrangeTableBackroundProcessing:function(){var b=this;return function(){b._bubbleCols(),b.options.beforeStop(b.originalTable),b.sortableTable.el.remove(),c(),e.dragtable.update(b),a.isFunction(b.options.persistState)?b.options.persistState(b.originalTable):b.persistState()}},_rearrangeTable:function(){var a=this;return function(){a.originalTable.selectedHandle.removeClass("dragtable-handle-selected"),a.sortableTable.el.sortable("disable"),a.sortableTable.el.addClass("dragtable-disabled"),a.options.beforeReorganize(a.originalTable,a.sortableTable),a.originalTable.endIndex=a.sortableTable.movingRow.prevAll().length+1,setTimeout(a._rearrangeTableBackroundProcessing(),50)}},_generateSortable:function(c){c.cancelBubble?c.cancelBubble=!0:c.stopPropagation();for(var d=this,e=this.originalTable.el[0].attributes,f="",g=0;g