PageSourceSearch

https://mintimate.cn/js/events.js

js mintimate.cn collected 2026-10-03 22:09:48 UTC 5,705 bytes, 192 lines download raw bytes

1/* global Fluid */
2
3HTMLElement.prototype.wrap = function(wrapper) {
4  this.parentNode.insertBefore(wrapper, this);
5  this.parentNode.removeChild(this);
6  wrapper.appendChild(this);
7};
8
9Fluid.events = {
10
11  registerNavbarEvent: function() {
12    var navbar = jQuery('#navbar');
13    if (navbar.length === 0) {
14      return;
15    }
16    var submenu = jQuery('#navbar .dropdown-menu');
17    if (navbar.offset().top > 0) {
18      navbar.removeClass('navbar-dark');
19      submenu.removeClass('navbar-dark');
20    }
21    Fluid.utils.listenScroll(function() {
22      navbar[navbar.offset().top > 50 ? 'addClass' : 'removeClass']('top-nav-collapse');
23      submenu[navbar.offset().top > 50 ? 'addClass' : 'removeClass']('dropdown-collapse');
24      if (navbar.offset().top > 0) {
25        navbar.removeClass('navbar-dark');
26        submenu.removeClass('navbar-dark');
27      } else {
28        navbar.addClass('navbar-dark');
29        submenu.removeClass('navbar-dark');
30      }
31    });
32    jQuery('#navbar-toggler-btn').on('click', function() {
33      var $this = jQuery(this);
34      if ($this.data('animating')) {
35        return;
36      }
37      $this.data('animating', true);
38      jQuery('.animated-icon').toggleClass('open');
39      jQuery('#navbar').toggleClass('navbar-col-show');
40      setTimeout(function() {
41        $this.data('animating', false);
42      }, 300);
43    });
44  },
45
46  registerParallaxEvent: function() {
47    var ph = jQuery('#banner[parallax="true"]');
48    if (ph.length === 0) {
49      return;
50    }
51    var board = jQuery('#board');
52    if (board.length === 0) {
53      return;
54    }
55    var parallax = function() {
56      var pxv = jQuery(window).scrollTop() / 5;
57      var offset = parseInt(board.css('margin-top'), 10);
58      var max = 96 + offset;
59      if (pxv > max) {
60        pxv = max;
61      }
62      ph.css({
63        transform: 'translate3d(0,' + pxv + 'px,0)'
64      });
65      var sideCol = jQuery('.side-col');
66      if (sideCol) {
67        sideCol.css({
68          'padding-top': pxv + 'px'
69        });
70      }
71    };
72    Fluid.utils.listenScroll(parallax);
73  },
74
75  registerScrollDownArrowEvent: function() {
76    var scrollbar = jQuery('.scroll-down-bar');
77    if (scrollbar.length === 0) {
78      return;
79    }
80    scrollbar.on('click', function() {
81      Fluid.utils.scrollToElement('#board', -jQuery('#navbar').height());
82    });
83  },
84
85  registerScrollTopArrowEvent: function() {
86    var topArrow = jQuery('#scroll-top-button');
87    if (topArrow.length === 0) {
88      return;
89    }
90    var board = jQuery('#board');
91    if (board.length === 0) {
92      return;
93    }
94    var posDisplay = false;
95    var scrollDisplay = false;
96    // Position
97    var setTopArrowPos = function() {
98      var boardRight = board[0].getClientRects()[0].right;
99      var bodyWidth = document.body.offsetWidth;
100      var right = bodyWidth - boardRight;
101      posDisplay = right >= 50;
102      topArrow.css({
103        'bottom': posDisplay && scrollDisplay ? '20px' : '-60px',
104        'right' : right - 64 + 'px'
105      });
106    };
107    setTopArrowPos();
108    jQuery(window).resize(setTopArrowPos);
109    // Display
110    var headerHeight = board.offset().top;
111    Fluid.utils.listenScroll(function() {
112      var scrollHeight = document.body.scrollTop + document.documentElement.scrollTop;
113      scrollDisplay = scrollHeight >= headerHeight;
114      topArrow.css({
115        'bottom': posDisplay && scrollDisplay ? '20px' : '-60px'
116      });
117    });
118    // Click
119    topArrow.on('click', function() {
120      jQuery('body,html').animate({
121        scrollTop: 0,
122        easing   : 'swing'
123      });
124    });
125  },
126
127  registerImageLoadedEvent: function() {
128    if (!('NProgress' in window)) { return; }
129
130    var bg = document.getElementById('banner');
131    if (bg) {
132      var src = bg.style.backgroundImage;
133      var url = src.match(/\((.*?)\)/)[1].replace(/(['"])/g, '');
134      var img = new Image();
135      img.onload = function() {
136        window.NProgress && window.NProgress.status !== null && window.NProgress.inc(0.2);
137      };
138      img.src = url;
139      if (img.complete) { img.onload(); }
140    }
141
142    var notLazyImages = jQuery('main img:not([lazyload])');
143    var total = notLazyImages.length;
144    for (const img of notLazyImages) {
145      const old = img.onload;
146      img.onload = function() {
147        old && old();
148        window.NProgress && window.NProgress.status !== null && window.NProgress.inc(0.5 / total);
149      };
150      if (img.complete) { img.onload(); }
151    }
152  },
153
154  registerRefreshCallback: function(callback) {
155    if (!Array.isArray(Fluid.events._refreshCallbacks)) {
156      Fluid.events._refreshCallbacks = [];
157    }
158    Fluid.events._refreshCallbacks.push(callback);
159  },
160
161  refresh: function() {
162    if (Array.isArray(Fluid.events._refreshCallbacks)) {
163      for (var callback of Fluid.events._refreshCallbacks) {
164        if (callback instanceof Function) {
165          callback();
166        }
167      }
168    }
169  },
170
171  billboard: function() {
172    if (!('console' in window)) {
173      return;
174    }
175    // eslint-disable-next-line no-console
176    console.log(`
177-------------------------------------------------
178|                                               |
179|      ________  __            _        __      |
180|     |_   __  |[  |          (_)      |  ]     |
181|       | |_ \\_| | | __   _   __   .--.| |      |
182|       |  _|    | |[  | | | [  |/ /'\`\\' |      |
183|      _| |_     | | | \\_/ |, | || \\__/  |      |
184|     |_____|   [___]'.__.'_/[___]'.__.;__]     |
185|                                               |
186|            Powered by Hexo x Fluid            |
187| https://github.com/fluid-dev/hexo-theme-fluid |
188|                                               |
189-------------------------------------------------
190    `);
191  }
192};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.