BioTorrents.de’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.

cssgallery.js 3.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. $(document).ready(function () {
  2. // If the custom stylesheet field is empty, select the current style from the previews
  3. if (!$('input#styleurl').val()) {
  4. var radiobutton = $('input[name="stylesheet_gallery"][value="' + $('select#stylesheet').val() + '"]');
  5. radiobutton.click();
  6. $('.preview_wrapper').removeClass('selected');
  7. radiobutton.parent().parent().addClass('selected');
  8. }
  9. // If the input is clicked, redirect it to the overlay click event
  10. $('input[name="stylesheet_gallery"]').click(function () {
  11. $('.preview_wrapper').removeClass('selected');
  12. var parent = $(this).parent();
  13. parent.addClass('selected');
  14. var radiobutton = parent.find('input');
  15. radiobutton.prop('checked', true);
  16. $('select#stylesheet').val(radiobutton.attr('value'));
  17. $('select#stylesheet').change();
  18. $('input#styleurl').val('');
  19. })
  20. // Passthrough image click to radio button
  21. $('.preview_image').click(function (e) {
  22. e.currentTarget.children[1].children[0].children[0].click();
  23. })
  24. // If the drop-down is changed, select the appropriate item in gallery, clear the custom CSS field
  25. $('select#stylesheet').change(function () {
  26. var radiobutton = $('input[name="stylesheet_gallery"][value="' + $(this).val() + '"]');
  27. radiobutton.prop('checked', true);
  28. $('.preview_wrapper').removeClass('selected');
  29. radiobutton.parent().parent().addClass('selected');
  30. $('input#styleurl').val('');
  31. })
  32. // If the custom CSS field is changed, clear radio buttons
  33. $('input#styleurl').keydown(function () {
  34. $('input[name="stylesheet_gallery"]').each(function () {
  35. $(this).prop('checked', false);
  36. })
  37. $('.preview_wrapper').removeClass('selected');
  38. })
  39. // If the input is empty, select appropriate gallery item again by the drop-down
  40. $('input#styleurl').keyup(function () {
  41. if (!$(this).val()) {
  42. $('select#stylesheet').change();
  43. }
  44. })
  45. // Allow the CSS gallery to be expanded/contracted
  46. $('#toggle_css_gallery').click(function (e) {
  47. e.preventDefault();
  48. $('#css_gallery').slideToggle(function () {
  49. $('#toggle_css_gallery').text($(this).is(':visible') ? 'Hide gallery' : 'Show gallery');
  50. });
  51. });
  52. document.querySelectorAll('[name=style_additions\\[\\]]').forEach(function (el) {
  53. el.addEventListener('change', function (e) {
  54. document.body.classList.toggle('style_' + e.target.value);
  55. /*
  56. if (e.target.checked) {
  57. document.body.classList.add('style_' + e.target.value);
  58. } else {
  59. document.body.classList.remove('style_' + e.target.value);
  60. }
  61. */
  62. })
  63. })
  64. var userstyle = $('link[rel=stylesheet][title]')[0]
  65. $('select#stylesheet').on('change', function (e) {
  66. var changetext = e.target.options[e.target.selectedIndex].text.toLowerCase();
  67. userstyle.href = userstyle.href.replace(/\w+\.css/i, changetext + '.css');
  68. $('.style_addition').each(function (i, el) {
  69. if (el.id == 'style_addition_' + changetext) {
  70. if (el.children.length) {
  71. el.classList.remove('hidden');
  72. $('#style_additions_tr')[0].classList.remove('hidden');
  73. } else {
  74. $('#style_additions_tr')[0].classList.add('hidden');
  75. }
  76. } else {
  77. el.classList.add('hidden');
  78. }
  79. })
  80. })
  81. });