blob: b9f60ceea5e1b0e181d240115fe9ad5dc747534d (
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
68
69
70
71
72
73
74
75
|
(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;
});
// check file size before uploading if browser support html5
if (window.File && window.FileList) {
function checkFileUpload(evt) {
var f = evt.target.files[0];
if (f.size > max_upload_size) {
document.getElementById('upload_button').innerHTML = "File too big";
document.getElementById('upload_button').disabled = true;
} else {
document.getElementById('upload_button').innerHTML = "Upload it!";
document.getElementById('upload_button').disabled = false;
}
}
document.getElementById('file').addEventListener('change', checkFileUpload, false);
}
});
})(jQuery);
|