사용자:다메즈마/index-button.js

참고: 설정을 저장한 후에 바뀐 점을 확인하기 위해서는 브라우저의 캐시를 새로 고쳐야 합니다.

  • 파이어폭스 / 사파리: Shift 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5 또는 Ctrl-R을 입력 (Mac에서는 ⌘-R)
  • 구글 크롬: Ctrl-Shift-R키를 입력 (Mac에서는 ⌘-Shift-R)
  • 인터넷 익스플로러 / 엣지: Ctrl 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5를 입력.
  • 오페라: Ctrl-F5를 입력.
//목차리스트를 고정해서 볼 수 있는 버튼을 만들어 줍니다.
if(mw.config.get("skin")=="liberty"){
  var a = "<button type=\"button\" class=\"btn btn-default\" aria-label=\"Left Align\">  <span class=\"fa fa-list\" aria-hidden=\"true\"></span></button>";
  var indexButton = document.createElement("button");
  indexButton.type = "button";
  indexButton.className = "btn btn-default";
  indexButton.innerHTML = "<span class=\"fa fa-list\" aria-hidden=\"true\"></span>";
  indexButton.style.position = "fixed";
  indexButton.style.top = "48px";
  indexButton.style.left = "0px";
  window.damezuma = {doc:null};
  $(indexButton).click(function(){
    if(window.damezuma.doc == null){
      window.damezuma.doc = $("#toc").clone();
      $(document.body).append(window.damezuma.doc);
      $(window.damezuma.doc).css({
        "position":"fixed",
        "top":0,
        "left":0,
        "background-color":"#333",
        "color":"#FFF",
        "padding":"16px",
        "bottom":0,
        "overflow-y":"scroll",
        "z-index":3000
      });
      $(window.damezuma.doc).children("#togglelink").click(function(){
        $(window.damezuma.doc).remove();
        window.damezuma.doc = null;
      });
    }


  });

  $(document.body).append(indexButton);
}