page-bilibiliFavList.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <?php
  2. /**
  3. Template Name: 哔哩哔哩收藏模板
  4. */
  5. get_header();
  6. ?>
  7. <meta name="referrer" content="same-origin" />
  8. <style>
  9. .comments {
  10. display: none;
  11. }
  12. .site-content {
  13. max-width: 1280px;
  14. }
  15. </style>
  16. </head>
  17. <?php while(have_posts()) : the_post(); ?>
  18. <?php $bgm = (iro_opt('bilibili_id')) ? new \Sakura\API\BilibiliFavList() : null; ?>
  19. <?php if (!empty($bgm) && (!iro_opt('patternimg') || !get_post_thumbnail_id(get_the_ID()))) : ?>
  20. <span class="linkss-title"><?php the_title();?></span>
  21. <?php endif; ?>
  22. <article <?php post_class("post-item"); ?>>
  23. <?php the_content(); ?>
  24. <?php if (!empty($bgm)) : ?>
  25. <section class="fav-list">
  26. <?php echo $bgm->get_folders(); ?>
  27. </section>
  28. <?php else: ?>
  29. <div class="row">
  30. <p> <?php _e("Please fill in the Bilibili UID in Sakura Options.", "sakurairo"); ?></p>
  31. </div>
  32. <?php endif; ?>
  33. <script>
  34. document.addEventListener('DOMContentLoaded', function() {
  35. let expandButton = document.querySelectorAll('.expand-button');
  36. if (expandButton.length) {
  37. expandButton.forEach(function(elem) {
  38. elem.addEventListener('click', function() {
  39. let folder = elem.closest('.folder');
  40. let folderStyle = getComputedStyle(folder);
  41. if (folderStyle.maxHeight === '200px'){
  42. let folderContent = folder.querySelector(".folder-content");
  43. folder.style.maxHeight = parseInt(folderStyle.maxHeight) + folderContent.scrollHeight + 'px';
  44. } else {
  45. folder.style.maxHeight = '200px';
  46. }
  47. }, true);
  48. });
  49. }
  50. window.addEventListener('resize', function() {
  51. expandButton.forEach(function(elem) {
  52. let folder = elem.closest('.folder');
  53. let folderStyle = getComputedStyle(folder);
  54. if (folderStyle.maxHeight !== '200px'){
  55. let folderContent = folder.querySelector(".folder-content");
  56. folder.style.maxHeight = parseInt(folderStyle.maxHeight) + folderContent.scrollHeight + 'px';
  57. }
  58. });
  59. }, true);
  60. document.addEventListener('click',function(e){
  61. if(e.target && e.target.classList.contains('load-more')){
  62. let elem = e.target;
  63. let href = elem.getAttribute('data-href') + "&_wpnonce=" + _iro.nonce;
  64. fetch(href, {method: 'POST'})
  65. .then((response) => {
  66. return response.json();
  67. })
  68. .then((html) => {
  69. var htmlObject = document.createElement('div');
  70. htmlObject.innerHTML = html;
  71. while (htmlObject.childNodes.length > 0) {
  72. elem.parentNode.appendChild(htmlObject.childNodes[0]);
  73. }
  74. let folder = elem.closest('.folder');
  75. let folderContent = folder.querySelector(".folder-content");
  76. folder.style.maxHeight = parseInt(folderStyle.maxHeight) + folderContent.scrollHeight + 'px';
  77. elem.remove();
  78. });
  79. }
  80. });
  81. });
  82. </script>
  83. </article>
  84. <?php endwhile; ?>
  85. <style>
  86. .fav-list{
  87. margin: 0 -10px -20px;
  88. flex-wrap: wrap;
  89. padding: 1rem 3%;
  90. justify-content: center;
  91. }
  92. .folder{
  93. border: 1px solid gray;
  94. overflow: hidden;
  95. transition: max-height .5s ease-out;
  96. max-height: 200px;
  97. border-radius: 10px;
  98. color: #fff;
  99. box-shadow: 0 0 10px rgb(0 0 0 / 10%), 0 5px 20px rgb(0 0 0 / 20%);
  100. }
  101. .folder-img{
  102. height: 200px;
  103. object-fit: cover;
  104. width: 100%;
  105. }
  106. .folder-top{
  107. height: 200px;
  108. display: block;
  109. position: relative;
  110. }
  111. .folder-detail{
  112. height: 100%;
  113. top: 0;
  114. left: 0;
  115. right: 0;
  116. position: absolute;
  117. text-align: center;
  118. background: rgba(0, 0, 0, .5);
  119. }
  120. .expand-button{
  121. background-color: transparent;
  122. height: 50px;
  123. align-self: center;
  124. font-size: 16px;
  125. border: 0;
  126. outline: 0;
  127. background-color: rgba(255, 255, 255, 0.6);
  128. color: var(--theme-skin,#505050);
  129. padding: 15px;
  130. border-radius: var(--style_menu_radius,12px);
  131. box-shadow: 0 0 2px 0 rgb(0 0 0 / 12%), 0 2px 2px 0 rgb(0 0 0 / 24%);
  132. transition: all 0.8s ease !important;
  133. }
  134. .folder hr{
  135. margin: 0;
  136. background: grey;
  137. }
  138. .folder-content{
  139. padding: 5px;
  140. display: flex;
  141. justify-content: center;
  142. flex-wrap: wrap;
  143. }
  144. .column{
  145. margin-bottom: 20px;
  146. padding: 0 5px;
  147. transition: .5s;
  148. max-width: 100%;
  149. flex: 0 0 100%;
  150. }
  151. .folder-item{
  152. border: 1px solid gray;
  153. height: 0;
  154. color: #fff;
  155. display: block;
  156. overflow: hidden;
  157. text-align: center;
  158. position: relative;
  159. padding-bottom: 60%;
  160. box-shadow: 0 0 10px rgb(0 0 0 / 10%), 0 5px 20px rgb(0 0 0 / 20%);
  161. border-radius: 10px;
  162. }
  163. .item-img{
  164. width: 100%;
  165. user-select: none;
  166. object-fit: cover;
  167. transition: filter 2s;
  168. }
  169. .item-info{
  170. height: 40%;
  171. top: 0;
  172. left: 0;
  173. right: 0;
  174. padding: 10px;
  175. position: absolute;
  176. background: rgba(0, 0, 0, .5);
  177. transition: transform 1s;
  178. transform: translateY(150%);
  179. }
  180. .item-title{
  181. overflow: hidden;
  182. white-space: nowrap;
  183. text-overflow: ellipsis;
  184. margin-top: 0;
  185. }
  186. .item-intro{
  187. overflow: hidden;
  188. white-space: nowrap;
  189. text-overflow: ellipsis;
  190. }
  191. .load-more{
  192. flex: 0 0 100%;
  193. text-align: center;
  194. padding-top: 5px;
  195. padding-bottom: 5px;
  196. }
  197. @media screen and (min-width: 600px){
  198. .folder-img{
  199. height: 200px;
  200. object-fit: cover;
  201. width: auto;
  202. }
  203. .folder-detail{
  204. height: 200px;
  205. display: flex;
  206. flex-direction: column;
  207. justify-content: center;
  208. position: inherit;
  209. align-self: center;
  210. width: 100%;
  211. text-align: center;
  212. background: rgba(0, 0, 0, .3);
  213. }
  214. .folder-top{
  215. display: flex;
  216. position: relative;
  217. }
  218. .folder-content{
  219. padding: 15px;
  220. }
  221. .column{
  222. max-width: 33.33333%;
  223. flex: 0 0 33.33333%;
  224. }
  225. .load-more{
  226. padding-top: 10px;
  227. padding-bottom: 10px;
  228. }
  229. }
  230. body.dark .expand-button {
  231. background-color: rgba(38, 38, 38, 0.6);
  232. color: var(--theme-skin-dark);
  233. }
  234. </style>
  235. <?php
  236. get_footer();