/[svn]/doc/tmpl/js/crd.js
ViewVC logotype

Diff of /doc/tmpl/js/crd.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3271 by schoenebeck, Fri Jun 2 18:31:00 2017 UTC revision 3272 by schoenebeck, Sat Jun 3 15:38:32 2017 UTC
# Line 5  Line 5 
5  */  */
6    
7  var g_isTouch = false;  var g_isTouch = false;
8    var g_isMouse = false;
9    
10  function crdWindowWidth() {  function crdWindowWidth() {
11      return window.innerWidth ||      return window.innerWidth ||
# Line 73  function crdUpdateTOCStatus() { Line 74  function crdUpdateTOCStatus() {
74    
75  function crdToggleTOC() {  function crdToggleTOC() {
76      $("html").toggleClass("no-toc");      $("html").toggleClass("no-toc");
77        if (typeof(Storage) !== "undefined") {
78            sessionStorage.setItem("show-toc", $("html").hasClass("no-toc") ? "no" : "yes");
79        }
80      crdUpdateTOCStatus();      crdUpdateTOCStatus();
81  }  }
82    
# Line 89  function crdDetectFeatures() { Line 93  function crdDetectFeatures() {
93          g_isTouch = false;          g_isTouch = false;
94          document.documentElement.className += ' no-touch';          document.documentElement.className += ' no-touch';
95      }      }
96        $(window).bind('mousemove.hasMouse', function(){
97            $(window).unbind('.hasMouse');
98            g_isMouse = true;
99            $(document).tooltip();
100        }).bind('touchstart.hasMouse', function(){
101            $(window).unbind('.hasMouse');
102            g_isMouse = false;
103        });
104      if ($.support["transform"]) {      if ($.support["transform"]) {
105          $("body").addClass("hasTransform");          $("body").addClass("hasTransform");
106      }      }
# Line 100  function crdDetectFeatures() { Line 112  function crdDetectFeatures() {
112    
113  $(function() {  $(function() {
114      crdDetectFeatures();      crdDetectFeatures();
     $(document).tooltip();  
     if (g_isTouch) {  
         $("header a[title]" ).tooltip({  
             disabled: true  
         });  
         $("nav a[title]" ).tooltip({  
             disabled: true  
         });  
     }  
115      $("article img[caption]").each(function() {      $("article img[caption]").each(function() {
116          $(this).after(          $(this).after(
117              "<div class='imgcptn'>" +              "<div class='imgcptn'>" +
# Line 129  $(function() { Line 132  $(function() {
132              crdScrollToHash();              crdScrollToHash();
133          };          };
134      }      }
135        if (g_isTouch) {
136            $("nav > ul > li").each(function() {
137                $(this).click(function() {
138                    var active = $(this).hasClass("active");
139                    $("nav li.active").removeClass("active");
140                    if (!active)
141                        $(this).addClass("active");
142                });
143            });
144            $("article").click(function() {
145                $("nav li.active").removeClass("active");
146            });
147        }
148      $("article a[href]").each(function() {      $("article a[href]").each(function() {
149          var href = $(this).attr("href");          var href = $(this).attr("href");
150          if (href && href.length > 1 && href.charAt(0) == '#') {          if (href && href.length > 1 && href.charAt(0) == '#') {
# Line 138  $(function() { Line 154  $(function() {
154              });              });
155          }          }
156      });      });
157      var w = crdWindowWidth();      var showToc = null;
158      if (w < 1200) {      if (typeof(Storage) !== "undefined") {
159            var s = sessionStorage.getItem("show-toc");
160            if (s)
161                showToc = s != "no";
162        }
163        if (!$("body aside") || !$("body aside").length)
164            showToc = false;
165        if (showToc === null) {
166            var w = crdWindowWidth();
167            showToc = (w >= 1200);
168        }
169        $("html").addClass("no-effect");
170        if (!showToc) {
171          $("html").addClass("no-toc");          $("html").addClass("no-toc");
172      }      }
173        document.body.offsetHeight;
174        $("html").removeClass("no-effect");
175      crdUpdateTOCStatus();      crdUpdateTOCStatus();
176  });  });
177    

Legend:
Removed from v.3271  
changed lines
  Added in v.3272

  ViewVC Help
Powered by ViewVC