summaryrefslogtreecommitdiffstats
path: root/data/js/script.js
blob: e49733b972cd4e7abaec93a7dd9d888a9ff7da76 (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
(function($) {

	$(function() {

		$(window).bind('hashchange', function(e) {
			var hash = window.location.hash;

			$('#highlight_line').remove();

			if (hash.match(/^#n\d+$/) === null) {
				return;
			}

			var link = $(hash);

			$('<div id="highlight_line" />').prependTo('.highlight').css({
				top: link.get(0).offsetTop - 10 + parseInt(link.css("padding-top")) + 'px'
			});
		});

		$(window).trigger('hashchange');

		var lexer_source = [];
		for (var key in window.lexers) {
			lexer_source.push({ label: window.lexers[key], value: key });
		}

		$('#language').autocomplete({
			source: lexer_source,
			select: function(event, ui) {
				window.location = window.paste_base + '/' + ui.item.value;
			}
		});

		$('#language-toggle').click(function() {
			setTimeout(function() {
				$('#language').focus();
			}, 0);
		});

		$('[rel="tooltip"]').tooltip({
			placement: 'bottom'
		});

		$('#history-all').bind('change', function() {
			$('.delete-history').prop('checked', $(this).is(':checked'));
		});

		$('.modal').on('shown', function(e) {
			var modal = $(this);

			modal.css('margin-top', (modal.outerHeight() / 2) * -1)
			.css('margin-left', (modal.outerWidth() / 2) * -1);

		return this;
		});

	});

})(jQuery);