master
Raw Download raw file
 1(function($){
 2	// Open external links in new window
 3	var externalLinks = function(){
 4		var host = location.host;
 5
 6		$('body').on('click', 'a', function(e){
 7			var href = this.href,
 8				link = href.replace(/https?:\/\/([^\/]+)(.*)/, '$1');
 9
10			if (link != '' && link != host && !$(this).hasClass('fancybox')){
11				window.open(href);
12				e.preventDefault();
13			}
14		});
15	};
16
17	// Append caption after pictures
18	var appendCaption = function(){
19		$('.entry-content').each(function(i){
20			var _i = i;
21			$(this).find('img').each(function(){
22				var alt = this.alt;
23
24				if (alt != ''){
25					$(this).after('<span class="caption">'+alt+'</span>');
26				}
27
28				$(this).wrap('<a href="'+this.src+'" title="'+alt+'" class="fancybox" rel="gallery'+_i+'" />');
29			});
30		});
31	};
32
33	externalLinks(); // Delete or comment this line to disable opening external links in new window
34	appendCaption(); // Delete or comment this line to disable caption
35
36	var mobilenav = $('#mobile-nav');
37
38	$('html').click(function(){
39		mobilenav.find('.on').each(function(){
40			$(this).removeClass('on').next().hide();
41		});
42	});
43
44	mobilenav.on('click', '.menu .button', function(){
45		if (!$(this).hasClass('on')){
46			var width = $(this).width() + 42;
47			$(this).addClass('on').next().show().css({width: width});
48		} else {
49			$(this).removeClass('on').next().hide();
50		}
51	}).on('click', '.search .button', function(){
52		if (!$(this).hasClass('on')){
53			var width = mobilenav.width() - 51;
54			mobilenav.children('.menu').children().eq(0).removeClass('on').next().hide();
55			$(this).addClass('on').next().show().css({width: width}).children().children().eq(0).focus();
56		} else {
57			$(this).removeClass('on').next().hide().children().children().eq(0).val('');
58		}
59	}).click(function(e){
60		e.stopPropagation();
61	});
62})(jQuery);