2 var $body = $(document.body);
3 $body.scrollspy({ target: '.sphinxsidebarwrapper' });
4 $(window).on('load', function () {
5 $body.scrollspy('refresh');
9 setTimeout(function () {
10 var $sideBar = $('.sphinxsidebarwrapper');
15 var offsetTop = $sideBar.offset().top;
16 var sideBarMargin = parseInt($sideBar.children(0).css('margin-top'), 10);
17 var navOuterHeight = $('.docs-nav').height();
19 return (this.top = offsetTop - navOuterHeight - sideBarMargin);
22 return (this.bottom = $('div.footer').outerHeight(true));
28 // Config ZeroClipboard
29 ZeroClipboard.config({
30 moviePath: '_static/ZeroClipboard.swf',
31 hoverClass: 'btn-clipboard-hover'
34 // Insert copy to clipboard button before .highlight or .example
35 $('.highlight-html, .highlight-scss').each(function () {
36 var highlight = $(this);
37 var previous = highlight.prev();
38 var btnHtml = '<div class="zero-clipboard"><span class="btn-clipboard">Copy</span></div>';
40 if (previous.hasClass('example')) {
41 previous.before(btnHtml.replace(/btn-clipboard/, 'btn-clipboard with-example'));
43 highlight.before(btnHtml);
46 var zeroClipboard = new ZeroClipboard($('.btn-clipboard'));
47 var htmlBridge = $('#global-zeroclipboard-html-bridge');
49 // Handlers for ZeroClipboard
50 zeroClipboard.on('load', function () {
52 .data('placement', 'top')
53 .attr('title', 'Copy to clipboard')
58 zeroClipboard.on('dataRequested', function (client) {
59 var highlight = $(this).parent().nextAll('.highlight').first();
60 client.setText(highlight.text());
63 // Notify copy success and reset tooltip title
64 zeroClipboard.on('complete', function () {
66 .attr('title', 'Copied!')
69 .attr('title', 'Copy to clipboard')
73 // Notify copy failure
74 zeroClipboard.on('noflash wrongflash', function () {
75 htmlBridge.attr('title', 'Flash required')