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>
|
||||||
<li>The <code>remove</code> block (added v2.4):
|
<li>The <code>remove</code> block (added v2.4):
|
||||||
<ul>
|
<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>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>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>
|
<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
|
// function above otherwise initFlag is undefined
|
||||||
// * see the saveSort widget for a full example *
|
// * 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
|
// do what ever needs to be done to remove stuff added by your widget
|
||||||
// unbind events, restore hidden content, etc.
|
// 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>
|
});</pre>
|
||||||
</div>
|
</div>
|
||||||
|
@ -5799,7 +5799,7 @@ $.tablesorter.isValueInArray(2, sortList);</pre>
|
|||||||
|
|
||||||
<tr id="function-addwidget">
|
<tr id="function-addwidget">
|
||||||
<td><a href="#" class="permalink">addWidget</a></td>
|
<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>
|
<div class="collapsible"><br>
|
||||||
Access it as follows:
|
Access it as follows:
|
||||||
<pre class="prettyprint lang-js">$.tablesorter.addWidget(myWidget);</pre>
|
<pre class="prettyprint lang-js">$.tablesorter.addWidget(myWidget);</pre>
|
||||||
|
@ -879,7 +879,7 @@
|
|||||||
.bind("updateAll" + c.namespace, function(e, resort, callback){
|
.bind("updateAll" + c.namespace, function(e, resort, callback){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
table.isUpdating = true;
|
table.isUpdating = true;
|
||||||
ts.refreshWidgets(table, true, true);
|
ts.refreshWidgets(table, true, true, true);
|
||||||
ts.restoreHeaders(table);
|
ts.restoreHeaders(table);
|
||||||
buildHeaders(table);
|
buildHeaders(table);
|
||||||
ts.bindEvents(table, c.$headers, true);
|
ts.bindEvents(table, c.$headers, true);
|
||||||
@ -1025,9 +1025,9 @@
|
|||||||
// apply widgets
|
// apply widgets
|
||||||
ts.applyWidget(table, init);
|
ts.applyWidget(table, init);
|
||||||
})
|
})
|
||||||
.bind("refreshWidgets" + c.namespace, function(e, all, dontapply){
|
.bind("refreshWidgets" + c.namespace, function(e, all, dontapply, temp){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
ts.refreshWidgets(table, all, dontapply);
|
ts.refreshWidgets(table, all, dontapply, temp);
|
||||||
})
|
})
|
||||||
.bind("destroy" + c.namespace, function(e, c, cb){
|
.bind("destroy" + c.namespace, function(e, c, cb){
|
||||||
e.stopPropagation();
|
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
|
table = $(table)[0]; // see issue #243
|
||||||
var i, c = table.config,
|
var i, c = table.config,
|
||||||
cw = c.widgets,
|
cw = c.widgets,
|
||||||
@ -1677,7 +1677,7 @@
|
|||||||
if (c.debug) { log( 'Refeshing widgets: Removing "' + w[i].id + '"' ); }
|
if (c.debug) { log( 'Refeshing widgets: Removing "' + w[i].id + '"' ); }
|
||||||
// only remove widgets that have been initialized - fixes #442
|
// only remove widgets that have been initialized - fixes #442
|
||||||
if (w[i].hasOwnProperty('remove') && c.widgetInit[w[i].id]) {
|
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;
|
c.widgetInit[w[i].id] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,15 +256,15 @@ ts.addWidget({
|
|||||||
ts.benchmark("Applying " + theme + " theme", time);
|
ts.benchmark("Applying " + theme + " theme", time);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
remove: function(table, c) {
|
remove: function(table, c, wo, temp) {
|
||||||
var $table = c.$table,
|
var $table = c.$table,
|
||||||
theme = c.theme || 'jui',
|
theme = c.theme || 'jui',
|
||||||
themes = ts.themes[ theme ] || ts.themes.jui,
|
themes = ts.themes[ theme ] || ts.themes.jui,
|
||||||
$headers = $table.children('thead').children(),
|
$headers = $table.children('thead').children(),
|
||||||
remove = themes.sortNone + ' ' + themes.sortDesc + ' ' + themes.sortAsc;
|
remove = themes.sortNone + ' ' + themes.sortDesc + ' ' + themes.sortAsc;
|
||||||
$table
|
$table.removeClass('tablesorter-' + theme + ' ' + themes.table);
|
||||||
.removeClass('tablesorter-' + theme + ' ' + themes.table)
|
if (temp) { return; }
|
||||||
.find(ts.css.header).removeClass(themes.header);
|
$table.find(ts.css.header).removeClass(themes.header);
|
||||||
$headers
|
$headers
|
||||||
.unbind('mouseenter.tsuitheme mouseleave.tsuitheme') // remove hover
|
.unbind('mouseenter.tsuitheme mouseleave.tsuitheme') // remove hover
|
||||||
.removeClass(themes.hover + ' ' + remove + ' ' + themes.active)
|
.removeClass(themes.hover + ' ' + remove + ' ' + themes.active)
|
||||||
@ -388,7 +388,7 @@ ts.addWidget({
|
|||||||
ts.filter.init(table, c, wo);
|
ts.filter.init(table, c, wo);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
remove: function(table, c, wo) {
|
remove: function(table, c, wo, temp) {
|
||||||
var tbodyIndex, $tbody,
|
var tbodyIndex, $tbody,
|
||||||
$table = c.$table,
|
$table = c.$table,
|
||||||
$tbodies = c.$tbodies;
|
$tbodies = c.$tbodies;
|
||||||
@ -397,6 +397,7 @@ ts.addWidget({
|
|||||||
// add .tsfilter namespace to all BUT search
|
// add .tsfilter namespace to all BUT search
|
||||||
.unbind('addRows updateCell update updateRows updateComplete appendCache filterReset filterEnd search '.split(' ').join(c.namespace + 'filter '))
|
.unbind('addRows updateCell update updateRows updateComplete appendCache filterReset filterEnd search '.split(' ').join(c.namespace + 'filter '))
|
||||||
.find('.' + ts.css.filterRow).remove();
|
.find('.' + ts.css.filterRow).remove();
|
||||||
|
if (temp) { return; }
|
||||||
for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
|
for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
|
||||||
$tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // remove tbody
|
$tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // remove tbody
|
||||||
$tbody.children().removeClass(wo.filter_filteredRow).show();
|
$tbody.children().removeClass(wo.filter_filteredRow).show();
|
||||||
|
Loading…
Reference in New Issue
Block a user