Permalink
Browse files

fix: load jQuery UI until it is needed

jQuery UI is unused on mobile
  • Loading branch information...
MOxFIVE committed May 25, 2016
1 parent 0280f6a commit 07e495813917d7db8cec5b5e2c96ca1d8154ffcb
Showing with 62 additions and 49 deletions.
  1. +0 −3 layout/_partial/after-footer.ejs
  2. +10 −3 layout/_partial/head.ejs
  3. +52 −43 source/js/pc.js
@@ -8,8 +8,5 @@
<%- partial('mathjax') %>
<% } %>
<%- partial('scrolling-button') %>
<% if (theme.jquery_ui){ %>
<script src="<%- theme.CDN.jquery_ui_js %>"></script>
<% } %>
<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
View
@@ -32,9 +32,6 @@
<% if (theme.animate){ %>
<link href="<%- theme.CDN.animate_css %>" rel="stylesheet">
<% } %>
<% if (theme.jquery_ui){ %>
<link href="<%- theme.CDN.jquery_ui_css %>" rel="stylesheet">
<% } %>
<% if (theme.progressBar.on) { %>
<script src="<%- theme.CDN.pace_js %>"></script>
<link href="//cdn.bootcss.com/pace/1.0.2/themes/<%= theme.progressBar.color || 'blue'%>/pace-theme-<%= theme.progressBar.type || 'minimal'%>.css" rel="stylesheet">
@@ -74,6 +71,16 @@
}
</script>
<% if (theme.jquery_ui) { %>
<script>
yiliaConfig.jquery_ui = [true, "<%- theme.CDN.jquery_ui_js %>", "<%- theme.CDN.jquery_ui_css %>"];
</script>
<% } else { %>
<script>
yiliaConfig.jquery_ui = [false];
</script>
<% } %>
<% if (theme.root_url){ %>
<script>
yiliaConfig.rootUrl = <%=theme.root_url%>;
View
@@ -109,51 +109,60 @@ define([], function(){
}
}
var tooltip = function(){
$(function() {
// if _config.yml => jquery_ui: false
if (!$().tooltip) return;
if (navigator.userAgent.match(/(iPhone|iPad|Android|ios|PlayBook|Touch)/i)) return;
$("[title]").tooltip({
show: {
effect: 'blind',
delay: 250,
duration: 55,
if (yiliaConfig.jquery_ui[0]) {
var tooltip = function(){
require([yiliaConfig.jquery_ui[1]], function(){
var loadCSS = function (url, num) {
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = url;
var head = document.querySelector("head");
head.insertBefore(link, head.childNodes[num]);
}
loadCSS(yiliaConfig.jquery_ui[2], 25);
if (!$().tooltip) return;
if (navigator.userAgent.match(/(iPhone|iPad|Android|ios|PlayBook|Touch)/i)) return;
$("[title]").tooltip({
show: {
effect: 'blind',
delay: 250,
duration: 55,
}
})
$("#scroll").tooltip({
show: {
effect: 'clip',
delay: 600,
duration: 50,
}
})
$("#tocButton, #comments").tooltip({
show: {
delay: 1200,
}
})
$(".ds-replybox form").off("tooltip")
$("#post-nav-button").tooltip({
show: {
effect: 'clip',
delay: 280,
duration: 65,
}
})
$("#post-nav-button > a:nth-child(2)").tooltip({
show: {
delay: 1500,
}
})
$(".social").tooltip({
show: {
effect: 'scale',
delay: 350,
duration: 70,
}
})
})
$("#scroll").tooltip({
show: {
effect: 'clip',
delay: 600,
duration: 50,
}
})
$("#tocButton, #comments").tooltip({
show: {
delay: 1200,
}
})
$(".ds-replybox form").off("tooltip")
$("#post-nav-button").tooltip({
show: {
effect: 'clip',
delay: 280,
duration: 65,
}
})
$("#post-nav-button > a:nth-child(2)").tooltip({
show: {
delay: 1500,
}
})
$(".social").tooltip({
show: {
effect: 'scale',
delay: 350,
duration: 70,
}
})
});
}
}
var search = function(){

0 comments on commit 07e4958

Please sign in to comment.