mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Core/Filter: remove widget temp parameter added indicating refreshWidgets was trigger
This commit is contained in:
parent
638d070f3a
commit
61b339dd3b
@ -139,6 +139,13 @@
|
||||
</li>
|
||||
<li>The <code>remove</code> block (added v2.4):
|
||||
<ul>
|
||||
<li>In <span class="version">v2.18.5</span> the <code>temp</code> parameter was added:
|
||||
<ul>
|
||||
<li>It is a parameter used to indicate that the <a href="index.html#refreshwidgets"><code>refreshWidgets</code></a> method was triggered.</li>
|
||||
<li>When widgets are refreshed, the <code>remove</code> method is called, then the widget <code>init</code> function is immediately called to reapply the widget.</li>
|
||||
<li>In this update, this parameter is used by the filter widget to retain filtered rows and prevent a "flash" of showing all rows, then returning to its previous state after applying the filter again.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>This code is called when either the <a href="index.html#refreshwidgets"><code>refreshWidgets</code></a> or <a href="index.html#destroy"><code>destroy</code></a> methods are called.</li>
|
||||
<li>The code contained within this block must remove all additional content/elements added by the widget. Also, any rows or content that is hidden must be restored.</li>
|
||||
<li>If additional rows are added to the table, make sure to include the class name within the <a href="index.html#selectorremove"><code>selectorRemove</code></a> option.</li>
|
||||
@ -180,9 +187,11 @@ $.tablesorter.addWidget({
|
||||
// function above otherwise initFlag is undefined
|
||||
// * see the saveSort widget for a full example *
|
||||
},
|
||||
remove: function(table, config, widgetOptions){
|
||||
remove: function(table, config, widgetOptions, temp){
|
||||
// do what ever needs to be done to remove stuff added by your widget
|
||||
// unbind events, restore hidden content, etc.
|
||||
// temp flag is true when the refreshWidgets method is triggered, meaning
|
||||
// the widget will be removed, then immediately reapplied
|
||||
}
|
||||
});</pre>
|
||||
</div>
|
||||
|
@ -5799,7 +5799,7 @@ $.tablesorter.isValueInArray(2, sortList);</pre>
|
||||
|
||||
<tr id="function-addwidget">
|
||||
<td><a href="#" class="permalink">addWidget</a></td>
|
||||
<td>This function allows the adding of custom widget scripts to the tablesorter core.
|
||||
<td>This function allows the adding of custom widget scripts to the tablesorter core (<span class="version updated">v2.18.5</span>).
|
||||
<div class="collapsible"><br>
|
||||
Access it as follows:
|
||||
<pre class="prettyprint lang-js">$.tablesorter.addWidget(myWidget);</pre>
|
||||
|
@ -879,7 +879,7 @@
|
||||
.bind("updateAll" + c.namespace, function(e, resort, callback){
|
||||
e.stopPropagation();
|
||||
table.isUpdating = true;
|
||||
ts.refreshWidgets(table, true, true);
|
||||
ts.refreshWidgets(table, true, true, true);
|
||||
ts.restoreHeaders(table);
|
||||
buildHeaders(table);
|
||||
ts.bindEvents(table, c.$headers, true);
|
||||
@ -1025,9 +1025,9 @@
|
||||
// apply widgets
|
||||
ts.applyWidget(table, init);
|
||||
})
|
||||
.bind("refreshWidgets" + c.namespace, function(e, all, dontapply){
|
||||
.bind("refreshWidgets" + c.namespace, function(e, all, dontapply, temp){
|
||||
e.stopPropagation();
|
||||
ts.refreshWidgets(table, all, dontapply);
|
||||
ts.refreshWidgets(table, all, dontapply, temp);
|
||||
})
|
||||
.bind("destroy" + c.namespace, function(e, c, cb){
|
||||
e.stopPropagation();
|
||||
@ -1666,7 +1666,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
ts.refreshWidgets = function(table, doAll, dontapply) {
|
||||
ts.refreshWidgets = function(table, doAll, dontapply, temp) {
|
||||
table = $(table)[0]; // see issue #243
|
||||
var i, c = table.config,
|
||||
cw = c.widgets,
|
||||
@ -1677,7 +1677,7 @@
|
||||
if (c.debug) { log( 'Refeshing widgets: Removing "' + w[i].id + '"' ); }
|
||||
// only remove widgets that have been initialized - fixes #442
|
||||
if (w[i].hasOwnProperty('remove') && c.widgetInit[w[i].id]) {
|
||||
w[i].remove(table, c, c.widgetOptions);
|
||||
w[i].remove(table, c, c.widgetOptions, temp);
|
||||
c.widgetInit[w[i].id] = false;
|
||||
}
|
||||
}
|
||||
|
@ -256,15 +256,15 @@ ts.addWidget({
|
||||
ts.benchmark("Applying " + theme + " theme", time);
|
||||
}
|
||||
},
|
||||
remove: function(table, c) {
|
||||
remove: function(table, c, wo, temp) {
|
||||
var $table = c.$table,
|
||||
theme = c.theme || 'jui',
|
||||
themes = ts.themes[ theme ] || ts.themes.jui,
|
||||
$headers = $table.children('thead').children(),
|
||||
remove = themes.sortNone + ' ' + themes.sortDesc + ' ' + themes.sortAsc;
|
||||
$table
|
||||
.removeClass('tablesorter-' + theme + ' ' + themes.table)
|
||||
.find(ts.css.header).removeClass(themes.header);
|
||||
$table.removeClass('tablesorter-' + theme + ' ' + themes.table);
|
||||
if (temp) { return; }
|
||||
$table.find(ts.css.header).removeClass(themes.header);
|
||||
$headers
|
||||
.unbind('mouseenter.tsuitheme mouseleave.tsuitheme') // remove hover
|
||||
.removeClass(themes.hover + ' ' + remove + ' ' + themes.active)
|
||||
@ -388,7 +388,7 @@ ts.addWidget({
|
||||
ts.filter.init(table, c, wo);
|
||||
}
|
||||
},
|
||||
remove: function(table, c, wo) {
|
||||
remove: function(table, c, wo, temp) {
|
||||
var tbodyIndex, $tbody,
|
||||
$table = c.$table,
|
||||
$tbodies = c.$tbodies;
|
||||
@ -397,6 +397,7 @@ ts.addWidget({
|
||||
// add .tsfilter namespace to all BUT search
|
||||
.unbind('addRows updateCell update updateRows updateComplete appendCache filterReset filterEnd search '.split(' ').join(c.namespace + 'filter '))
|
||||
.find('.' + ts.css.filterRow).remove();
|
||||
if (temp) { return; }
|
||||
for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
|
||||
$tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // remove tbody
|
||||
$tbody.children().removeClass(wo.filter_filteredRow).show();
|
||||
|
Loading…
Reference in New Issue
Block a user