|
|
خط ۴۷۲: |
خط ۴۷۲: |
| } | | } |
| }); | | }); |
|
| |
| /*
| |
| // sticky sidebar
| |
| /**
| |
| * Adds common WordPress functionality to the window.
| |
| *
| |
| * @param {jQuery} $ jQuery object.
| |
| * @param {Object} window The window object.
| |
| * @param {mixed} undefined Unused.
| |
| */
| |
| (function($, window, undefined) {
| |
| var $document = $(document),
| |
| $window = $(window),
| |
| $body = $(document.body),
| |
| __ = wp.i18n.__,
| |
| sprintf = wp.i18n.sprintf;
| |
|
| |
| $(function() {
| |
| var checks, first, last, checked, sliced, mobileEvent, transitionTimeout, focusedRowActions,
| |
| // lastClicked = false,
| |
| // pageInput = $('input.current-page'),
| |
| // currentPage = pageInput.val(),
| |
| isIOS = /iPhone|iPad|iPod/.test(navigator.userAgent),
| |
| isAndroid = navigator.userAgent.indexOf('Android') !== -1,
| |
| $adminMenuWrap = $('#mw-panel'), //#adminmenuwrap
| |
| $wpwrap = $('.mediawiki'), //#wpwrap
| |
| $adminmenu = $('#adminmenu'),
| |
| // $overlay = $( '#wp-responsive-overlay' ),
| |
| // $toolbar = $( '#wp-toolbar' ),
| |
| // $toolbarPopups = $toolbar.find( 'a[aria-haspopup="true"]' ),
| |
| // $sortables = $('.meta-box-sortables'),
| |
| // wpResponsiveActive = false,
| |
| // $adminbar = $( '#wpadminbar' ),
| |
| lastScrollPosition = 0,
| |
| // pinnedMenuTop = false,
| |
| // pinnedMenuBottom = false,
| |
| menuTop = 0,
| |
| menuState,
| |
| menuIsPinned = false,
| |
| height = {
| |
| window: $window.height(),
| |
| wpwrap: $wpwrap.height(),
| |
| adminbar: $adminbar.height(),
| |
| menu: $adminMenuWrap.height()
| |
| },
| |
| $headerEnd = $('.wp-header-end');
| |
|
| |
| // If the menu is higher than the window, compensate on scroll.
| |
| if (height.menu + height.adminbar > height.window) {
| |
| // Check for overscrolling, this happens when swiping up at the top of the document in modern browsers.
| |
| if (windowPos < 0) {
| |
| // Stick the menu to the top.
| |
| if (!pinnedMenuTop) {
| |
| pinnedMenuTop = true;
| |
| pinnedMenuBottom = false;
| |
|
| |
| $adminMenuWrap.css({
| |
| position: 'fixed',
| |
| top: '',
| |
| bottom: ''
| |
| });
| |
| }
| |
|
| |
| return;
| |
| } else if (windowPos + height.window > $document.height() - 1) {
| |
| // When overscrolling at the bottom, stick the menu to the bottom.
| |
| if (!pinnedMenuBottom) {
| |
| pinnedMenuBottom = true;
| |
| pinnedMenuTop = false;
| |
|
| |
| $adminMenuWrap.css({
| |
| position: 'fixed',
| |
| top: '',
| |
| bottom: 0
| |
| });
| |
| }
| |
|
| |
| return;
| |
| }
| |
|
| |
| if (windowPos > lastScrollPosition) {
| |
| // When a down scroll has been detected.
| |
|
| |
| // If it was pinned to the top, unpin and calculate relative scroll.
| |
| if (pinnedMenuTop) {
| |
| pinnedMenuTop = false;
| |
| // Calculate new offset position.
| |
| menuTop = $adminMenuWrap.offset().top - height.adminbar - (windowPos - lastScrollPosition);
| |
|
| |
| if (menuTop + height.menu + height.adminbar < windowPos + height.window) {
| |
| menuTop = windowPos + height.window - height.menu - height.adminbar;
| |
| }
| |
|
| |
| $adminMenuWrap.css({
| |
| position: 'absolute',
| |
| top: menuTop,
| |
| bottom: ''
| |
| });
| |
| } else if (!pinnedMenuBottom && $adminMenuWrap.offset().top + height.menu < windowPos + height.window) {
| |
| // Pin it to the bottom.
| |
| pinnedMenuBottom = true;
| |
|
| |
| $adminMenuWrap.css({
| |
| position: 'fixed',
| |
| top: '',
| |
| bottom: 0
| |
| });
| |
| }
| |
| } else if (windowPos < lastScrollPosition) {
| |
| // When a scroll up is detected.
| |
|
| |
| // If it was pinned to the bottom, unpin and calculate relative scroll.
| |
| if (pinnedMenuBottom) {
| |
| pinnedMenuBottom = false;
| |
|
| |
| // Calculate new offset position.
| |
| menuTop = $adminMenuWrap.offset().top - height.adminbar + (lastScrollPosition - windowPos);
| |
|
| |
| if (menuTop + height.menu > windowPos + height.window) {
| |
| menuTop = windowPos;
| |
| }
| |
|
| |
| $adminMenuWrap.css({
| |
| position: 'absolute',
| |
| top: menuTop,
| |
| bottom: ''
| |
| });
| |
| } else if (!pinnedMenuTop && $adminMenuWrap.offset().top >= windowPos + height.adminbar) {
| |
|
| |
| // Pin it to the top.
| |
| pinnedMenuTop = true;
| |
|
| |
| $adminMenuWrap.css({
| |
| position: 'fixed',
| |
| top: '',
| |
| bottom: ''
| |
| });
| |
| }
| |
| } else if (resizing) {
| |
| // Window is being resized.
| |
|
| |
| pinnedMenuTop = pinnedMenuBottom = false;
| |
|
| |
| // Calculate the new offset.
| |
| menuTop = windowPos + height.window - height.menu - height.adminbar - 1;
| |
|
| |
| if (menuTop > 0) {
| |
| $adminMenuWrap.css({
| |
| position: 'absolute',
| |
| top: menuTop,
| |
| bottom: ''
| |
| });
| |
| } else {
| |
| unpinMenu();
| |
| }
| |
| }
| |
| }
| |
|
| |
| lastScrollPosition = windowPos;
| |
| }
| |
|
| |
| /**
| |
| * Determines the height of certain elements.
| |
| *
| |
| * @since 4.1.0
| |
| *
| |
| * @return {void}
| |
| */
| |
| function resetHeights() {
| |
| height = {
| |
| window: $window.height(),
| |
| wpwrap: $wpwrap.height(),
| |
| adminbar: $adminbar.height(),
| |
| menu: $adminMenuWrap.height()
| |
| };
| |
| }
| |
|
| |
| /**
| |
| * Unpins the menu.
| |
| *
| |
| * @since 4.1.0
| |
| *
| |
| * @return {void}
| |
| */
| |
| function unpinMenu() {
| |
| if (isIOS || !menuIsPinned) {
| |
| return;
| |
| }
| |
|
| |
| pinnedMenuTop = pinnedMenuBottom = menuIsPinned = false;
| |
| $adminMenuWrap.css({
| |
| position: '',
| |
| top: '',
| |
| bottom: ''
| |
| });
| |
| }
| |
|
| |
| /**
| |
| * Pins and unpins the menu when applicable.
| |
| *
| |
| * @since 4.1.0
| |
| *
| |
| * @return {void}
| |
| */
| |
| function setPinMenu() {
| |
| resetHeights();
| |
|
| |
| if ($adminmenu.data('wp-responsive')) {
| |
| $body.removeClass('sticky-menu');
| |
| unpinMenu();
| |
| } else if (height.menu + height.adminbar > height.window) {
| |
| pinMenu();
| |
| $body.removeClass('sticky-menu');
| |
| } else {
| |
| $body.addClass('sticky-menu');
| |
| unpinMenu();
| |
| }
| |
| }
| |
|
| |
| if (!isIOS) {
| |
| $window.on('scroll.pin-menu', pinMenu);
| |
| $document.on('tinymce-editor-init.pin-menu', function(event, editor) {
| |
| editor.on('wp-autoresize', resetHeights);
| |
| });
| |
| }
| |
| }(jQuery, window));
| |
| */
| |
| importScript("./design/sticky-sidebar.min.js");
| |
|
| |
| var sidebar = new StickySidebar('#mw-panel', {
| |
| // topSpacing: 20,
| |
| // bottomSpacing: 20,
| |
| containerSelector: '.mediawiki',
| |
| innerWrapperSelector: false
| |
| });
| |
| </script>
| |