مدیاویکی:Common.js: تفاوت میان نسخه‌ها

بدون خلاصۀ ویرایش
خنثی‌سازی نسخهٔ 55143 از Engineer (بحث)
برچسب: خنثی‌سازی
 
(۶ نسخهٔ میانیِ ایجادشده توسط همین کاربر نشان داده نشد)
خط ۶: خط ۶:
});
});


/* تنظیمات پاپ آپ ها */
/* تنظیمات پاپ آپ ها  
mw.loader.using( [ 'ext.popups' ], function() { // wait for popups to be loaded
mw.loader.using( [ 'ext.popups' ], function() { // wait for popups to be loaded


خط ۲۴: خط ۲۴:
var scrollto = offset.top - 100; // minus fixed header height
var scrollto = offset.top - 100; // minus fixed header height
$('html, body').animate({scrollTop:scrollto}, 0);
$('html, body').animate({scrollTop:scrollto}, 0);
 
*/
/* global mw, $ */
/* global mw, $ */
// Editing-related javascripts
// Editing-related javascripts
خط ۳۸۲: خط ۳۸۲:
  */
  */
mw.loader.using(["mediawiki.util"], function() {
mw.loader.using(["mediawiki.util"], function() {
/**
  * Extract a URL parameter from the current URL
  * @deprecated: Use mw.util.getParamValue with proper escaping
  */
  mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink, 'Use mw.util.addPortletLink instead' );
   if (["صفحهٔ_اصلی", "بحث:صفحه_اصلی"].indexOf(mw.config.get("wgPageName")) !== -1) {
   if (["صفحهٔ_اصلی", "بحث:صفحه_اصلی"].indexOf(mw.config.get("wgPageName")) !== -1) {
     $(function() {
     $(function() {
خط ۴۶۸: خط ۴۷۳:
// Hide the FileExporter portlet link if the file is not free content
// Hide the FileExporter portlet link if the file is not free content
$(function() {
$(function() {
   if ($('#ca-fileExporter').length == 1 & $(mw.config.get('wgCategories')).filter(['محتویات غیر آزاد', 'تصویرهای با منبع نامعلوم', 'تصویرهای با پدیدآور نامشخص']).length > 0) {
   if ($('#ca-fileExporter').length == 1 & $(mw.config.get('wgCategories')).filter(['محتویات غیر آزاد', 'تصویرهای با منبع نامعلوم', 'تصویرهای با پدیدآور نامشخص', 'پرونده‌های بدون مجوز قابل خواندن برای ماشین']).length > 0) {
   $('#ca-fileExporter').hide();
   $('#ca-fileExporter').find('a').css('color', 'grey').attr('title', 'غیرفعال برای محتوای غیر آزاد');
   }
   }
});
});


/*
function updateUserScriptWarning( msg, newMsg ) {
// sticky sidebar
return function () {
/**
var userScript = '/wiki/Special:MyPage/' + mw.config.get('skin') + '.js';
*  Adds common WordPress functionality to the window.
var commonScript = '/wiki/Special:MyPage/common.js';
*
mw.notify(
*  @param {jQuery} $        jQuery object.
$('<div>').html(
*  @param {Object} window  The window object.
// please translate to Farsi
*  @param {mixed} undefined Unused.
'One of the scripts you are running is broken and using a deprecated function <strong>' + msg + '</strong>. Please check your <a href="' + userScript + '">skin scripts</a> and <a href="' + commonScript + '">common scripts</a>, to update the reference to' + newMsg + 'to restore your script.'
*/
),
(function($, window, undefined) {
{ type: 'error' }
        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>