|
|
| خط ۱: |
خط ۱: |
| /* global mw, $ */ | | /* ===================================================== |
|
| |
|
| /**********************************************************************
| | MediaWiki Common.js |
| * Load edit.js for edit-related pages
| | |
| **********************************************************************/
| | Optimized for Vector 2010 |
| if (
| | |
| mw.config.get("wgAction") === "edit" ||
| | ===================================================== */ |
| mw.config.get("wgAction") === "submit" ||
| | |
| mw.config.get("wgCanonicalSpecialPageName") === "Upload"
| | mw.loader.using([‘mediawiki.util’,‘jquery’], function () { |
| ) {
| |
| importScript("مدیاویکی:Common.js/edit.js");
| |
| }
| |
|
| |
|
| /**********************************************************************
| | $(function () { |
| * Magic editintros
| |
| **********************************************************************/
| |
| function addEditIntro(name) {
| |
| $(".mw-editsection, #ca-edit")
| |
| .find("a")
| |
| .each(function () {
| |
| this.href = $(this).attr("href") + "&editintro=" + name;
| |
| });
| |
| }
| |
|
| |
|
| if (mw.config.get("wgNamespaceNumber") === 0) {
| | /* ---------- External links open in new tab ---------- */ |
| $(function () {
| |
| if (document.getElementById("disambigbox")) {
| |
| addEditIntro("Template:Disambig_editintro");
| |
| }
| |
| });
| |
|
| |
|
| $(function () {
| | $(‘#mw-content-text a.external’).attr(‘target’,‘_blank’); |
| var cats = mw.config.get("wgCategories") || [];
| |
| if (cats.includes("افراد زنده")) {
| |
| addEditIntro("Template:BLP_editintro");
| |
| }
| |
| });
| |
| }
| |
|
| |
|
| /********************************************************************** | | /* ---------- Confirm page delete ---------- */ |
| * Load additional JS/CSS via URL (Secure)
| |
| **********************************************************************/
| |
| mw.loader.using(["mediawiki.util"], function () {
| |
| var extraCSS = mw.util.getParamValue("withCSS"),
| |
| extraJS = mw.util.getParamValue("withJS");
| |
|
| |
|
| if (extraCSS) {
| | $(‘#ca-delete a’).on(‘click’, function(){ |
| if (/^MediaWiki:[^&<>=%#]*\.css$/.test(extraCSS)) {
| |
| mw.loader.load(
| |
| "/w/index.php?title=" +
| |
| encodeURIComponent(extraCSS) +
| |
| "&action=raw&ctype=text/css",
| |
| "text/css"
| |
| );
| |
| } else {
| |
| mw.notify("Only pages from the MediaWiki namespace are allowed.", {
| |
| title: "Invalid withCSS value",
| |
| });
| |
| }
| |
| }
| |
|
| |
|
| if (extraJS) {
| | return confirm(‘آیا مطمئن هستید که میخواهید این صفحه حذف شود؟’); |
| if (/^MediaWiki:[^&<>=%#]*\.js$/.test(extraJS)) {
| |
| mw.loader.load(
| |
| "/w/index.php?title=" +
| |
| encodeURIComponent(extraJS) +
| |
| "&action=raw&ctype=text/javascript"
| |
| );
| |
| } else {
| |
| mw.notify("Only pages from the MediaWiki namespace are allowed.", {
| |
| title: "Invalid withJS value",
| |
| });
| |
| }
| |
| }
| |
| });
| |
|
| |
|
| /**********************************************************************
| |
| * Auto-load Preloaded.js when needed
| |
| **********************************************************************/
| |
| mw.loader.using(["mediawiki.util"], function () {
| |
| if (mw.util.getParamValue("preload")) {
| |
| mw.loader.load("MediaWiki:Preloaded.js");
| |
| }
| |
| }); | | }); |
|
| |
|
| /********************************************************************** | | /* ---------- Back to top button ---------- */ |
| * Collapsible tables (modern, safe)
| |
| **********************************************************************/
| |
| function makeCollapsibleMwCollapsible($content) {
| |
| var $tables = $content
| |
| .find("table.collapsible:not(.mw-collapsible)")
| |
| .addClass("mw-collapsible");
| |
|
| |
|
| $.each($tables, function (index, table) {
| | var backTop = $(‘<div id=“backToTop”>▲</div>’); |
| if ($(table).hasClass("collapsed")) {
| |
| $(table).addClass("mw-collapsed");
| |
| }
| |
| });
| |
|
| |
|
| if ($tables.length > 0) {
| | $(‘body’).append(backTop); |
| mw.loader.using("jquery.makeCollapsible").then(function () {
| |
| $tables.makeCollapsible();
| |
| });
| |
| }
| |
| }
| |
| mw.hook("wikipage.content").add(makeCollapsibleMwCollapsible);
| |
|
| |
|
| /**********************************************************************
| | $(‘#backToTop’).css({ |
| * AutoCollapse, InnerCollapse, OuterCollapse
| |
| **********************************************************************/
| |
| function mwCollapsibleSetup($collapsibleContent) {
| |
| var autoCollapseThreshold = 2;
| |
|
| |
|
| $.each($collapsibleContent, function (index, element) {
| | position:‘fixed’, |
| var $element = $(element);
| |
|
| |
|
| if ($element.hasClass("collapsible")) {
| | bottom:‘30px’, |
| $element
| |
| .find("tr:first-child > th:first-child")
| |
| .prepend(
| |
| $element.find("tr:first-child > * > .mw-collapsible-toggle")
| |
| );
| |
| }
| |
|
| |
|
| // Auto collapse
| | right:‘25px’, |
| if (
| |
| $collapsibleContent.length >= autoCollapseThreshold &&
| |
| $element.hasClass("autocollapse")
| |
| ) {
| |
| $element.data("mw-collapsible").collapse();
| |
| }
| |
|
| |
|
| // Inner collapse (requires outercollapse ancestor)
| | width:‘40px’, |
| if ($element.hasClass("innercollapse")) {
| |
| if ($element.parents(".outercollapse").length > 0) {
| |
| $element.data("mw-collapsible").collapse();
| |
| }
| |
| }
| |
|
| |
|
| // Ensure toggle inherits proper text color
| | height:‘40px’, |
| var $toggle = $element.find(".mw-collapsible-toggle");
| |
| if ($toggle.length && $toggle.parent()[0].style.color) {
| |
| $toggle.find("a").css("color", "inherit");
| |
| }
| |
| });
| |
| }
| |
| mw.hook("wikipage.collapsibleContent").add(mwCollapsibleSetup);
| |
|
| |
|
| /**********************************************************************
| | ‘line-height’:‘40px’, |
| * Dynamic Navigation Bars (single clean version)
| |
| **********************************************************************/
| |
| var collapseCaption = "نهفتن";
| |
| var expandCaption = "نمایش";
| |
| var navigationBarHide = "[" + collapseCaption + "]";
| |
| var navigationBarShow = "[" + expandCaption + "]";
| |
|
| |
|
| function toggleNavigationBar(indexNavigationBar, event) {
| | ‘text-align’:‘center’, |
| var navToggle = document.getElementById("NavToggle" + indexNavigationBar);
| |
| var navFrame = document.getElementById("NavFrame" + indexNavigationBar);
| |
| var navChild;
| |
|
| |
|
| if (!navFrame || !navToggle) return false;
| | background:‘#3366cc’, |
|
| |
|
| var isShown = navToggle.firstChild.data === navigationBarHide;
| | color:‘#fff’, |
|
| |
|
| for (
| | cursor:‘pointer’, |
| navChild = navFrame.firstChild;
| |
| navChild !== null;
| |
| navChild = navChild.nextSibling
| |
| ) {
| |
| if (navChild.nodeType === 1) {
| |
| if (
| |
| $(navChild).hasClass("NavContent") ||
| |
| $(navChild).hasClass("NavPic")
| |
| ) {
| |
| navChild.style.display = isShown ? "none" : "block";
| |
| }
| |
| }
| |
| }
| |
|
| |
|
| navToggle.firstChild.data = isShown
| | ‘border-radius’:‘4px’, |
| ? navigationBarShow
| |
| : navigationBarHide;
| |
|
| |
|
| event.preventDefault();
| | ‘font-size’:‘18px’, |
| }
| |
|
| |
|
| function createNavigationBarToggleButton($content) {
| | display:‘none’, |
| var indexNavigationBar = 0;
| |
|
| |
|
| $content.find("div.NavFrame:not(.mw-collapsible)").each(function (_, navFrame) {
| | ‘z-index’:‘999’ |
| indexNavigationBar++;
| |
|
| |
|
| var $navFrame = $(navFrame);
| | }); |
| var navToggle = document.createElement("a");
| |
| navToggle.className = "NavToggle";
| |
| navToggle.id = "NavToggle" + indexNavigationBar;
| |
| navToggle.href = "#";
| |
|
| |
|
| $(navToggle).on(
| | $(window).scroll(function(){ |
| "click",
| |
| $.proxy(toggleNavigationBar, null, indexNavigationBar)
| |
| );
| |
|
| |
|
| var isCollapsed = $navFrame.hasClass("collapsed");
| | if($(this).scrollTop()>200){ |
|
| |
|
| // Determine if any child is hidden (compatibility)
| | $(‘#backToTop’).fadeIn(); |
| $(navFrame)
| |
| .children()
| |
| .each(function () {
| |
| if (
| |
| this.nodeType === 1 &&
| |
| (this.style.display === "none") &&
| |
| ($(this).hasClass("NavContent") || $(this).hasClass("NavPic"))
| |
| ) {
| |
| isCollapsed = true;
| |
| }
| |
| });
| |
|
| |
|
| // Apply initial collapsed state
| | } else{ |
| if (isCollapsed) {
| |
| $(navFrame)
| |
| .children()
| |
| .each(function () {
| |
| if (
| |
| $(this).hasClass("NavContent") ||
| |
| $(this).hasClass("NavPic")
| |
| ) {
| |
| this.style.display = "none";
| |
| }
| |
| });
| |
| }
| |
|
| |
|
| navToggle.appendChild(
| | $(‘#backToTop’).fadeOut(); |
| document.createTextNode(
| |
| isCollapsed ? navigationBarShow : navigationBarHide
| |
| )
| |
| );
| |
|
| |
|
| // Attach toggle to NavHead
| | } |
| $(navFrame)
| |
| .children()
| |
| .each(function () {
| |
| if ($(this).hasClass("NavHead")) {
| |
| navToggle.style.color = this.style.color;
| |
| this.appendChild(navToggle);
| |
| }
| |
| });
| |
|
| |
|
| navFrame.id = "NavFrame" + indexNavigationBar;
| | }); |
| });
| |
| }
| |
|
| |
|
| mw.hook("wikipage.content").add(createNavigationBarToggleButton);
| | $(‘#backToTop’).click(function(){ |
|
| |
|
| /**********************************************************************
| | $(‘html, body’).animate({scrollTop:0},500); |
| * Add “Complete list of languages” link on Main Page
| |
| **********************************************************************/
| |
| mw.loader.using(["mediawiki.util"], function () {
| |
| mw.log.deprecate(
| |
| window,
| |
| "addPortletLink",
| |
| mw.util.addPortletLink,
| |
| "Use mw.util.addPortletLink instead"
| |
| );
| |
|
| |
|
| if (["صفحهٔ_اصلی", "بحث:صفحه_اصلی"].includes(mw.config.get("wgPageName"))) {
| |
| $(function () {
| |
| mw.util.addPortletLink(
| |
| "p-lang",
| |
| "//meta.wikimedia.org/wiki/List_of_Wikipedias/fa",
| |
| "فهرست کامل",
| |
| "interwiki-completelist",
| |
| "فهرست کامل"
| |
| );
| |
| });
| |
| }
| |
| }); | | }); |
|
| |
|
| /********************************************************************** | | /* ---------- Close site notice ---------- */ |
| * WikiMiniAtlas loader
| | |
| **********************************************************************/
| | if($(‘#siteNotice’).length){ |
| (function () { | | |
| var require_wikiminiatlas = false;
| | var closeBtn = $(‘<span id=“closeNotice”>✖</span>’); |
| var coord_filter = /geohack/;
| |
|
| |
|
| $(function () {
| | $(‘#siteNotice’).css(‘position’,‘relative’); |
| $("a.external.text").each(function (_, link) {
| |
| if (link.href && coord_filter.test(link.href)) {
| |
| require_wikiminiatlas = true;
| |
| return false;
| |
| }
| |
| });
| |
|
| |
|
| if ($("div.kmldata").length) {
| | $(‘#closeNotice’).css({ |
| require_wikiminiatlas = true;
| |
| }
| |
|
| |
|
| if (require_wikiminiatlas) {
| | position:‘absolute’, |
| mw.loader.load(
| |
| "//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript"
| |
| );
| |
| }
| |
| });
| |
| })();
| |
|
| |
|
| /**********************************************************************
| | top:‘5px’, |
| * Source code pages should be LTR
| | |
| **********************************************************************/
| | left:‘10px’, |
| mw.loader.using(["mediawiki.util"], function () {
| | |
| if ([2, 4, 8].includes(mw.config.get("wgNamespaceNumber"))) {
| | cursor:‘pointer’, |
| if (/\.(js|css|py)$/.test(mw.config.get("wgPageName"))) {
| | |
| mw.util.addCSS(
| | ‘font-size’:‘16px’ |
| ".diff-addedline, .diff-deletedline, .diff-context { direction: ltr; } " +
| |
| "#wpTextbox1 { direction: ltr; }"
| |
| );
| |
| }
| |
| }
| |
|
| |
|
| // Hide WikiLove for newbies
| |
| if (
| |
| !mw.config.get("wgUserGroups").includes("autoconfirmed") ||
| |
| mw.config.get("wgUserEditCount") < 100
| |
| ) {
| |
| mw.util.addCSS("#ca-wikilove { display: none; }");
| |
| }
| |
| }); | | }); |
|
| |
|
| /**********************************************************************
| | $(‘#siteNotice’).append(closeBtn); |
| * بهتر کردن نمایش فرمولها در RTL
| | |
| **********************************************************************/
| | $(‘#closeNotice’).click(function(){ |
| $(function () { | | |
| $("span.mwe-math-mathml-inline").each(function () {
| | $(‘#siteNotice’).fadeOut(); |
| var $parent = $(this).parent();
| |
| var $grand = $parent.parent();
| |
|
| |
|
| if (
| |
| $grand.is("p, dd") &&
| |
| $grand.text().trim() === $parent.text().trim()
| |
| ) {
| |
| $grand.css({
| |
| direction: "ltr",
| |
| padding: "1em 0",
| |
| });
| |
| }
| |
| });
| |
| }); | | }); |
|
| |
|
| /********************************************************************** | | } |
| * هشدار برای عنوان نادرست ایمیل
| | |
| **********************************************************************/
| | /* ---------- Improve sortable tables ---------- */ |
| $(function () { | | |
| var row = $("#mw-input-wpSubject").parents("tr");
| | $(‘.sortable th’).css(‘cursor’,‘pointer’); |
| if (row.length) {
| | |
| row.before(
| | /* ---------- Copy link to heading ---------- */ |
| '<tr><td></td><td style="color:red;font-weight:bold">لطفاً عبارت Wikipedia e-mail را با یک عنوان مناسب جایگزین کنید!</td></tr>'
| | |
| );
| | $(‘.mw-headline’).each(function(){ |
| }
| | |
| });
| | var id=$(this).attr(‘id’); |
| | |
| | if(id){ |
| | |
| | var link=$(‘<a class=“headerCopy”> 🔗</a>’); |
| | |
| | link.attr(‘href’,‘#’+id); |
| | |
| | link.css({ |
| | |
| | ‘font-size’:‘12px’, |
|
| |
|
| /**********************************************************************
| | ‘margin-right’:‘6px’, |
| * Bold reference numbers on click
| |
| **********************************************************************/
| |
| $("sup.reference").click(function () {
| |
| var citeId = $(this).attr("id");
| |
| var selector = 'sup > a[href="#' + citeId + '"]';
| |
|
| |
|
| $(selector).css({ color: "#2a4b8d", "font-weight": "bold" });
| | ‘text-decoration’:‘none’, |
| $(selector).one("click", function () {
| |
| $(this).css({ color: "", "font-weight": "" });
| |
| });
| |
| });
| |
|
| |
|
| /**********************************************************************
| | ‘opacity’:‘0.5’ |
| * Hide FileExporter for non-free files (fixed)
| |
| **********************************************************************/
| |
| $(function () {
| |
| var nonFreeCats = [
| |
| "محتویات غیر آزاد",
| |
| "تصویرهای با منبع نامعلوم",
| |
| "تصویرهای با پدیدآور نامشخص",
| |
| ];
| |
|
| |
|
| if (
| |
| $("#ca-fileExporter").length === 1 &&
| |
| (mw.config.get("wgCategories") || []).some(function (cat) {
| |
| return nonFreeCats.includes(cat);
| |
| })
| |
| ) {
| |
| $("#ca-fileExporter").hide();
| |
| }
| |
| }); | | }); |
|
| |
|
| /**********************************************************************
| | $(this).append(link); |
| * Advertisement banner (only for logged-out users)
| |
| **********************************************************************/
| |
| mw.loader.using("jquery", function () {
| |
| $(function () {
| |
| var disableAd = false;
| |
|
| |
|
| if (mw.config.get("wgUserName") !== null || disableAd) return;
| | } |
|
| |
|
| var adBanner = $(
| | }); |
| '<div id="site-ad-banner">' +
| |
| '<a href="https://ble.ir/iranian_law" target="_blank">' +
| |
| '<img src="https://www.illrc.ac.ir/wp-content/uploads/2026/03/1.jpg" alt="Advertisement" class="ad-img">' +
| |
| "</a>" +
| |
| '<button id="close-ad" title="بستن">✖</button>' +
| |
| "</div>"
| |
| );
| |
|
| |
|
| $("body").append(adBanner);
| | }); |
|
| |
|
| $("#close-ad").on("click", function () {
| |
| $("#site-ad-banner").fadeOut();
| |
| });
| |
| });
| |
| }); | | }); |
| `
| | |
| | ::: |