User:DodoMan/Gadget-MoreMenu.page.js

From Test Wiki
Revision as of 16:25, 10 May 2024 by DodoMan (talk | contribs) (Created page with "→‎Original from [[metawikimedia:MediaWiki:Gadget-MoreMenu.page.js]] under the terms of CC-BY-SA-3.0 [https://creativecommons.org/licenses/by-sa/3.0]: "use strict"; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } window.MoreMenu = window.MoreMenu || {}; window.MoreMenu.page = function (config) { var _pag...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Original from [[metawikimedia:MediaWiki:Gadget-MoreMenu.page.js]] under the terms of CC-BY-SA-3.0 [https://creativecommons.org/licenses/by-sa/3.0] */

"use strict";

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

window.MoreMenu = window.MoreMenu || {};

window.MoreMenu.page = function (config) {
  var _page;

  return {
    page: (_page = {
      'page-logs': {
        'all-logs': {
          url: mw.util.getUrl('Special:Log', {
            page: config.page.name
          }),
          insertAfter: false
        },
        'abusefilter-log': {
          url: mw.util.getUrl('Special:AbuseLog', {
            wpSearchTitle: config.page.name
          })
        },
        'deletion-log': {
          url: mw.util.getUrl('Special:Log', {
            page: config.page.name,
            type: 'delete'
          })
        },
        'move-log': {
          url: mw.util.getUrl('Special:Log', {
            page: config.page.name,
            type: 'move'
          })
        },
        'pending-changes-log': {
          url: mw.util.getUrl('Special:Log', {
            page: config.page.name,
            type: 'stable'
          }),
        },
        'protection-log': {
          url: mw.util.getUrl('Special:Log', {
            page: config.page.name,
            type: 'protect'
          })
        },
        'spam-blacklist-log': {
          url: mw.util.getUrl('Special:Log', {
            page: config.page.name,
            type: 'spamblacklist'
          })
        }
      },

      /** Tools and links that provide meaningful statistics. */
      'analysis': {
        'basic-statistics': {
          url: mw.util.getUrl(config.page.name, {
            action: 'info'
          }),
          pageExists: true
        },
        'transclusions': {
          url: "https://".concat(config.project.domain, "/w/index.php?title=Special:WhatLinksHere/").concat(config.page.encodedName, "&hidelinks=1&hideredirs=1"),
          namespaceRestrict: [2, 4, 5, 10, 11, 12, 13, 100, 101]
        }
      },
      'search': {
        'latest-diff': {
          url: mw.util.getUrl(config.page.name, {
            diff: 'cur',
            oldid: 'prev'
          }),
          pageExists: true
        },
        'search-subpages': {
          url: mw.util.getUrl('Special:Search', {
            sort: 'relevance',
            prefix: config.page.name
          })
        }
      },

      /** Actions the current user can take on the page. */
      'change-model': {
        url: mw.util.getUrl("Special:ChangeContentModel/".concat(config.page.name)),
        currentUserRights: ['editcontentmodel'],
        pageExists: true,
        namespaceRestrict: [2, 4, 8, 100, 108, 828]
      },
      'delete-page': {
        /** NOTE: must use `decodeURIComponent` because mw.util.getUrl will otherwise double-escape. This should be safe. */
        url: mw.util.getUrl(null, {
          action: 'delete',
          'wpReason': decodeURIComponent($('#delete-reason').text()).replace(/\+/g, ' ')
        }),
        currentUserRights: ['delete'],
        pageExists: true,
        visible: !mw.config.get('wgIsMainPage')
      },
      'edit-intro': {
        url: "//".concat(config.project.domain, "/w/index.php?title=").concat(config.page.encodedName, "&action=edit&section=0"),
        namespaceRestrict: [0, 1, 2, 3, 4, 5, 118],
        pageExists: true,

        /** Don't show the 'Edit intro' link if the edittop gadget is enabled or there is only one section. */
        visible: '1' !== mw.user.options.get('gadget-edittop') && $('.mw-editsection').length
      },

      /** Placeholder for history link in Monobook/Modern, will get replaced by native link */
      'history': {
        url: '#',
        visible: -1 !== ['monobook', 'modern'].indexOf(config.currentUser.skin)
      },
      'merge-page': {
        url: mw.util.getUrl('Special:MergeHistory', {
          target: config.page.name
        }),
        currentUserRights: ['mergehistory'],
        pageExists: true,
        visible: !mw.config.get('wgIsMainPage')
      },
      'move-page': {
        url: mw.util.getUrl("Special:MovePage/".concat(config.page.name)),
        currentUserRights: ['move'],
        pageExists: true,
        pageMovable: true
      }
    }, _defineProperty(_page, config.page["protected"] ? 'change-protection' : 'protect-page', {
      url: mw.util.getUrl(config.page.name, {
        action: 'protect'
      }),
      currentUserRights: ['protect', 'stablesettings']
    }), _defineProperty(_page, 'purge-cache', {
      url: mw.util.getUrl(config.page.name, {
        action: 'purge',
        forcelinkupdate: true
      }),
      pageExists: true
    }), _defineProperty(_page, 'subpages', {
      url: mw.util.getUrl("Special:PrefixIndex/".concat(config.page.name, "/"))
    }), _defineProperty(_page, 'undelete-page', {
      url: mw.util.getUrl("Special:Undelete/".concat(config.page.name)),
      currentUserRights: ['undelete'],
      pageDeleted: true
    }), _defineProperty(_page, 'watch', {
      url: '#',
      visible: -1 !== ['monobook', 'modern'].indexOf(config.currentUser.skin)
    }), _page)
  };
};