Widget:TalkToc:修订间差异

H萌娘,万物皆可H的百科全书!
跳到导航 跳到搜索
imported>=海豚=
([InPageEdit] 没有编辑摘要 (编辑自Special:Diff/43088))
imported>=海豚=
([InPageEdit] 没有编辑摘要 (编辑自Special:Diff/43088))
第254行: 第254行:
          } else {
          } else {
            $('#tocBox').show();
            $('#tocBox').show();
           $('.cbutton').text('');
           $(toclist.filter(function(l) {
             return l !== "tocBox";
           }).map(function(l) {
             return 'a[href="#' + l + '"';
           }).join(', ')).attr("href", "#tocBox");
         }
         $('.cbutton').parent().append(' <' + 'a class="disableWidgetTalkToc"><' + '/a>');
         $('.disableWidgetTalkToc').on('click', function() {
           localStorage.setItem('widgetTalkToc', 'disable');
           $(this).text('禁用成功!刷新页面中……');
           setTimeout(location.reload.bind(location), 150);
         });
         $tocBox.css({
           position: 'relative',
           'z-index': 10
         });
         $(window).on('hashchange', function(e) {
           try {
             var hash = location.hash.substring(1);
             var target = $('[id="' + decodeURIComponent(hash).replace(/"/g, '\\\"') + '"]');
             if (target[0]) {
               var scrollTop = target.offset().top;
               if (target.closest('.discussionHead').length === 0) {
                 var parent = target.closest('h1, h2, h3, h4, h5, h6');
                 if (parent.length > 0) {
                   scrollTop -= parent.outerHeight(true) - parent.height();
                   var h = parent.prevAll('h1, h2, h3, h4, h5, h6').filter(function() {
                     return $(this).css('position') === 'sticky';
                   });
                   if (h.length > 0) scrollTop -= h.outerHeight();
                 }
               } else scrollTop = target.closest('.discussionContainer').offset().top;
               setTimeout(function() {
                 $('html,body').animate({
                   scrollTop: scrollTop
                 }, 0);
               }, 1);
               return false;
             }
           } catch (e) {
             return;
           }
         }).trigger('hashchange');
         const g = ["sysop", "patroller"];
         if (mw.config.get("wgUserGroups").filter(n => g.includes(n)).length === 0 && mw.config.get("wgPageName").startsWith("讨论:讨论版")) {
           $("#right-navigation").addClass("no-need-to-edit-whole-page").find("#p-views > ul").append('<li id="ca-no-need-to-edit-whole-page-notice" class="collapsible"><span><a href="javascript:void(0);">请勿编辑全文</a></span></li>').find("#ca-no-need-to-edit-whole-page-notice a").on("click", function() {
             var messageDialog = new OO.ui.MessageDialog();
             var windowManager = new OO.ui.WindowManager();
             $("body").append(windowManager.$element);
             windowManager.addWindows([messageDialog]);
             messageDialog.title.$label.html("萌娘百科提醒您<br>公共讨论页无需编辑全文");
             messageDialog.message.$label.html("<br>提问求助区、讨论版属于公共讨论页,一般来说无须编辑全文,故我们隐藏了入口。<hr>您可以点击下方标题旁的<b>【编辑】链接</b>来编辑对应段落,也可以点击右上方<b>【添加话题】链接</b>来新增话题。");
             windowManager.openWindow(messageDialog, {
               actions: [{
                 action: 'accept',
                 label: '我知道了',
                 flags: 'primary'
               }]
              });
              });
            });
            });

2020年5月1日 (五) 20:37的版本