tweaks to tablesorter to restore saved filters + minor optimizations
This commit is contained in:
parent
ce94394699
commit
4319b2c2e5
|
@ -1,4 +1,22 @@
|
||||||
$(function(){
|
$(function(){
|
||||||
|
// tablesorter options
|
||||||
|
$("#tblPackages").tablesorter({
|
||||||
|
sortList: [[0,1]],
|
||||||
|
widgets: ["saveSort", "filter", "stickyHeaders"],
|
||||||
|
widgetOptions: {
|
||||||
|
stickyHeaders_filteredToTop: true,
|
||||||
|
filter_hideEmpty: true,
|
||||||
|
filter_liveSearch: true,
|
||||||
|
filter_saveFilters: true,
|
||||||
|
filter_reset: "button.reset",
|
||||||
|
filter_functions: {
|
||||||
|
".filter-version": true,
|
||||||
|
".filter-downloaded": true,
|
||||||
|
".filter-installed": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// "uninstall package" switch and cookie
|
// "uninstall package" switch and cookie
|
||||||
$("#uninstallpkg")
|
$("#uninstallpkg")
|
||||||
.switchButton({
|
.switchButton({
|
||||||
|
@ -23,6 +41,20 @@ $(function(){
|
||||||
$.cookie("nerdpack_packages_delete", $(this).prop("checked") ? "--delete" : "", { expires: 3650 });
|
$.cookie("nerdpack_packages_delete", $(this).prop("checked") ? "--delete" : "", { expires: 3650 });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// select all packages switch
|
||||||
|
$("#checkall")
|
||||||
|
.switchButton({
|
||||||
|
labels_placement: "right",
|
||||||
|
on_label: "Select All",
|
||||||
|
off_label: "Select All",
|
||||||
|
checked: $.cookie("nerdpack_checkall") == "yes"
|
||||||
|
})
|
||||||
|
.change(function () {
|
||||||
|
var myval = $(this).prop("checked");
|
||||||
|
$.cookie("nerdpack_checkall", myval ? "yes" : "no", { expires: 3650 });
|
||||||
|
$("#tblPackages tbody td:visible .pkgcheckbox").switchButton({checked: myval});
|
||||||
|
});
|
||||||
|
|
||||||
// set cookie on apply button press
|
// set cookie on apply button press
|
||||||
$("#btnApply").click(function() {
|
$("#btnApply").click(function() {
|
||||||
checkDepends();
|
checkDepends();
|
||||||
|
@ -70,62 +102,29 @@ function packageQuery(force) {
|
||||||
"<td>"+data[i].size+"</td>"+ // package size
|
"<td>"+data[i].size+"</td>"+ // package size
|
||||||
"<td>"+Downloaded+"</td>"+ // package installed
|
"<td>"+Downloaded+"</td>"+ // package installed
|
||||||
"<td>"+Installed+"</td>"+ // package installed
|
"<td>"+Installed+"</td>"+ // package installed
|
||||||
"<td><input class='pkgcheckbox' id='"+data[i].pkgname+"' type='checkbox'>"+
|
"<td><input class='pkgcheckbox' id='"+data[i].pkgname+"' type='checkbox' "+(data[i].config=="yes"?"checked":"")+">"+
|
||||||
"<input class='pkgvalue' type='hidden' id='"+data[i].pkgname+"_value' name='"+data[i].pkgnver+"' value='"+data[i].config+"'></td>"+
|
"<input class='pkgvalue' type='hidden' id='"+data[i].pkgname+"_value' name='"+data[i].pkgnver+"' value='"+data[i].config+"'></td>"+
|
||||||
"</tr>");
|
"</tr>");
|
||||||
|
|
||||||
$("#"+data[i].pkgname)
|
|
||||||
.switchButton({
|
|
||||||
labels_placement: "right",
|
|
||||||
on_label: "On",
|
|
||||||
off_label: "Off",
|
|
||||||
checked: data[i].config == "yes"
|
|
||||||
})
|
|
||||||
.change(function() {
|
|
||||||
$(this).parent().parent().find(".pkgvalue").val(this.checked ? "yes": "no");
|
|
||||||
if (this.checked)
|
|
||||||
checkDepends();
|
|
||||||
$("#btnApply").prop("disabled", false);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
$("#tblPackages").trigger("update");
|
|
||||||
|
|
||||||
// tablesorter options
|
// attach switch buttons to every package checkbox all at once
|
||||||
$("#tblPackages").tablesorter({
|
$(".pkgcheckbox")
|
||||||
sortList: [[0,0]],
|
|
||||||
widgets: ["saveSort", "filter", "stickyHeaders"],
|
|
||||||
widgetOptions: {
|
|
||||||
stickyHeaders_filteredToTop: true,
|
|
||||||
filter_hideEmpty: true,
|
|
||||||
filter_liveSearch: true,
|
|
||||||
filter_saveFilters: true,
|
|
||||||
filter_reset: ".reset",
|
|
||||||
filter_functions: {
|
|
||||||
".filter-version": true,
|
|
||||||
".filter-downloaded": true,
|
|
||||||
".filter-installed": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// select all packages switch
|
|
||||||
$("#checkall")
|
|
||||||
.switchButton({
|
.switchButton({
|
||||||
labels_placement: "right",
|
labels_placement: "right",
|
||||||
on_label: "Select All",
|
on_label: "On",
|
||||||
off_label: "Select All",
|
off_label: "Off"
|
||||||
checked: $.cookie("nerdpack_checkall") == "yes"
|
|
||||||
})
|
})
|
||||||
.change(function () {
|
.change(function() {
|
||||||
var myval = $(this).prop("checked");
|
$(this).parent().parent().find(".pkgvalue").val(this.checked ? "yes": "no");
|
||||||
$.cookie("nerdpack_checkall", myval ? "yes" : "no", { expires: 3650 });
|
if (this.checked)
|
||||||
$(".pkgcheckbox").each(function() { // loop through each checkbox
|
checkDepends();
|
||||||
$(this).switchButton({checked: myval});
|
$("#btnApply").prop("disabled", false);
|
||||||
});
|
|
||||||
$(".pkgvalue").each(function() { // loop through each value
|
|
||||||
$(this).val(myval ? "yes": "no");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// restore filters
|
||||||
|
var lastSearch = $("#tblPackages")[0].config.lastSearch;
|
||||||
|
$("#tblPackages").trigger("update");
|
||||||
|
$("#tblPackages").trigger("search", [lastSearch]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user