blob: 0105d69200bb2ca0f0788c4c4f890adb1cc45245 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
(function($){
// Open external links in new window
var externalLinks = function(){
var host = location.host;
$('body').on('click', 'a', function(e){
var href = this.href,
link = href.replace(/https?:\/\/([^\/]+)(.*)/, '$1');
if (link != host){
window.open(href);
e.preventDefault();
}
});
};
// Append menu for mobile device
var navigationMenu = function(){
var appends = '<option>Menu</option>';
var search = function(obj, level){
var children = obj.children(),
link = children.eq(0),
_level = level + 1;
appends += '<option value="'+link.attr('href')+'">';
if (level > 0) appends += '|';
for (var i=0; i<level; i++){
appends += '—';
}
appends += link.text()+'</option>';
if (children.length > 1){
children.eq(1).children('li').each(function(){
search($(this), _level);
});
}
};
$('#header .menu .main').children('li').each(function(){
search($(this), 0);
});
$('#header .menu').append('<select>'+appends+'</select>').on('change', 'select', function(){
location.href = $(this).val();
});
};
/* caption.js */
$('.entry').each(function(i){
var _i = i;
$(this).find('img').each(function(){
var alt = $(this).attr('alt');
if (alt == '' || typeof alt == 'undefined'){
$(this).wrap('<a href="'+$(this).attr('src')+'" class="fancybox" rel="gallery'+_i+'" />');
} else {
$(this).after('<span class="caption">'+alt+'</span>').wrap('<a href="'+$(this).attr('src')+'" class="fancybox" title="'+alt+'" rel="gallery'+_i+'" />');
}
});
});
$('.fancybox').fancybox();
externalLinks(); // Delete or comment this line to disable opening external links in new window
})(jQuery);
|