Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

user_settings.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. $(document).ready(function() {
  2. var top = $('#settings_sections').offset().top - parseFloat($('#settings_sections').css('marginTop').replace(/auto/, 0));
  3. $(window).scroll(function (event) {
  4. var y = $(this).scrollTop();
  5. if (y >= top) {
  6. $('#settings_sections').addClass('fixed');
  7. } else {
  8. $('#settings_sections').removeClass('fixed');
  9. }
  10. });
  11. $("#settings_sections li").each(function(index) {
  12. $(this).click(function(e) {
  13. var id = $(this).data("gazelle-section-id");
  14. if (id) {
  15. e.preventDefault();
  16. if (id == "all_settings" || id == "live_search") {
  17. $("#userform table").show();
  18. } else {
  19. $("#userform table").hide();
  20. $("#" + id).show();
  21. }
  22. }
  23. });
  24. });
  25. $("#settings_search").on("keyup", function() {
  26. var search = $(this).val().toLowerCase();
  27. if ($.trim(search).length > 0) {
  28. $("#userform tr").not(".colhead_dark").each(function(index) {
  29. var text = $(this).find("td:first").text().toLowerCase();
  30. if (text.length > 0 && search.length > 0 && fuzzyMatch(text, search)) {
  31. $(this).show();
  32. }
  33. else {
  34. $(this).hide();
  35. }
  36. });
  37. } else {
  38. $("#userform tr").show();
  39. }
  40. });
  41. // I'm sure there is a better way to do this but this will do for now.
  42. $("#notifications_Inbox_traditional").click(function() {
  43. $("#notifications_Inbox_popup").prop('checked', false);
  44. });
  45. $("#notifications_Inbox_popup").click(function() {
  46. $("#notifications_Inbox_traditional").prop('checked', false);
  47. });
  48. $("#notifications_Torrents_traditional").click(function() {
  49. $("#notifications_Torrents_popup").prop('checked', false);
  50. });
  51. $("#notifications_Torrents_popup").click(function() {
  52. $("#notifications_Torrents_traditional").prop('checked', false);
  53. });
  54. });
  55. function fuzzyMatch(str, pattern){
  56. pattern = pattern.split("").reduce(function(a,b){ return a+".*"+b; });
  57. return new RegExp(pattern).test(str);
  58. };