跳转到内容

User:Dr.Cravix/iwlcompat.js

维基百科,自由的百科全书

这是本页的一个历史版本,由Dr.Cravix留言 | 贡献2012年5月22日 (二) 10:34 (back)编辑。这可能和当前版本存在着巨大的差异。

注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/* a fork of [[User:Shyc2001/SandBox/iwlold.js]] , just for compatibility with ilh-family templates */

mw.loader.using( ['mediawiki.util'] );

importScript('MediaWiki:Tooltips.js');
 
(function ($, mw) {
  'use strict';
 
  addOnloadHook(function () {
    var baseUrl = '/media/wikipedia/commons/';
    var buttonImages = [
      'f/f8/Tooltip-CloseButton.png',
      '5/5a/Tooltip-CloseButton-Hover.png',
      'd/df/Tooltip-CloseButton-Active.png',
    ];
    var close_imgs = buttonImages.map(function(src) {
      return $('<img/>').attr('src', baseUrl + src).attr('width', 16)[0];
    });
    var createTips = function (clsname, tipclsname, attrs, isChild) {
      $('span.ilh-all').each(function(_, item) {
        item = $(item);
        if ($('.ilh-comment', item).length == 0) return;
 
        var chinese = $('span.ilh-page', item);
 
        chinese.addClass(clsname);
 
        var tipHtml = wgULS(
          '条目$0不存在,可参考$1维基百科的对应页面$2。',
          '條目$0不存在,可參考$1維基百科的對應頁面$2。'
          )
          .replace('$0', $('span.ilh-page', item).html())
          .replace('$1', $('span.ilh-lang', item).html())
          .replace('$2', $('span.ilh-link', item).html());
 
        var tip = $('<div/>').addClass(tipclsname).hide();
        tip.html(tipHtml);
 
        new Tooltip(isChild ? chinese[0].firstChild : chinese[0], tip[0], attrs);
      });
    };
 
    createTips(
      'ILHClickButton',
      'ILHClickButton_tip',
      {
        mode : Tooltip.MOUSE,
        close_button : close_imgs,
        activate: Tooltip.CLICK,
        deactivate : Tooltip.CLICK_ELEM
      },
      true
    );
 
  });
 
})(jQuery, mediaWiki);