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 || |
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 |
|
|
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 |
} |
} |
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'>" + |
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) == '#') { |
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 |
|
|