Add an option to set the icon's content based on order#1352
Closed
timoschwarzer wants to merge 1 commit intoMottie:masterfrom
Closed
Add an option to set the icon's content based on order#1352timoschwarzer wants to merge 1 commit intoMottie:masterfrom
timoschwarzer wants to merge 1 commit intoMottie:masterfrom
Conversation
This is useful for e.g. Material icons, where you have to write <i class="material-icons">arrow_downward</i>
Owner
|
Hi @timoschwarzer! Thanks for your contribution! As much as I love having tons of options, I don't think these three new ones are necessary...
CSS (along with Materialize) .tablesorter-header .material-icons {
font-size: 20px;
position: absolute;
right: 2px;
top: 50%;
margin-top: -.5em;
}Script $.tablesorter.addWidget({
id: 'material-icons',
options: {
icon_text: {
asc: "keyboard_arrow_up",
desc: "keyboard_arrow_down",
unsorted: "format_line_spacing"
}
},
format: function(table, c, wo) {
var icon = "." + c.cssIcon;
c.$headers.find(icon).text(wo.icon_text.unsorted);
$.each(c.sortList, function(indx, val) {
var dir = val[1] === 0 ? 'asc' : 'desc';
c.$headers.eq(val[0]).find(icon).text(wo.icon_text[dir]);
});
}
});
$(function() {
$("table").tablesorter({
theme: "materialize",
widthFixed: true,
// add material icons to headers
headerTemplate: "{content}{icon}",
cssIcon: "material-icons",
// widget code contained in the jquery.tablesorter.widgets.js file
// use the zebra stripe widget if you plan on hiding any
// rows (filter widget)
widgets: ["filter", "zebra", "material-icons"],
widgetOptions: {
// using the default zebra striping class name, so it actually
// isn't included in the theme variable above; this is ONLY
// needed for materialize theming if you are using the filter
// widget, because rows are hidden
zebra: ["even", "odd"],
// reset filters button
filter_reset: ".reset",
// extra css class name (string or array) added to the filter
// element (input or select); select needs a "browser-default"
// class or it gets hidden
filter_cssFilter: ["", "", "browser-default"]
}
});
}); |
Author
|
@Mottie |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is useful for e.g. Material icon font, where you have to write
<i class="material-icons">arrow_downward</i>