forked from mustache/mustache.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtom.js
40 lines (39 loc) · 1006 Bytes
/
tom.js
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
// Generated by CoffeeScript 1.7.1
$.fn.scrollTo = function(speed) {
var container, offset, target;
target = this;
container = 'html,body';
offset = $(target).offset().top - 30;
$(container).animate({
scrollTop: offset
}, speed || 1000);
return this;
};
$(function() {
$('#demo').click(function() {
$('#demo-box').toggle();
if ($('#demo-box:visible').length > 0) {
$('#demo').scrollTo(1);
window.location.hash = '#demo';
} else {
window.location.hash = '';
}
return false;
});
if (window.location.hash === "#demo") {
$('#demo').click();
}
return $('.run').click(function() {
var e, html, json, template;
try {
template = $('.template').val();
json = $.parseJSON($('.json').val());
html = Mustache.to_html(template, json).replace(/^\s*/mg, '');
} catch (_error) {
e = _error;
html = e.toString();
}
$('.html').text(html).scrollTo(1);
return Highlight.highlightDocument();
});
});