1
0
mirror of synced 2024-12-15 23:56:02 +03:00
doctrine2/manual/new/scripts/toc.js

77 lines
2.3 KiB
JavaScript
Raw Normal View History

function initializeTocToggles()
2007-06-29 18:10:15 +04:00
{
var container = new Element('div', {
'id': 'toc-toggles'
});
2007-06-29 18:10:15 +04:00
container.injectTop($('table-of-contents'));
$('table-of-contents').setStyle('padding-top', '0');
2007-06-29 18:10:15 +04:00
var hideToggle = new Element('a', {
'href': 'javascript:void(0);',
'events': {
'click': function() {
var toc = $E('ul', 'table-of-contents');
2007-06-29 18:10:15 +04:00
if (toc.getStyle('display') == 'none') {
this.setHTML(tocHideText);
toc.setStyle('display', 'block');
stickyToggle.setStyle('display', 'inline');
Cookie.set('hidetoc', 0, {duration: 1000});
} else {
this.setHTML(tocShowText);
toc.setStyle('display', 'none');
stickyToggle.setStyle('display', 'none');
Cookie.set('hidetoc', 1, {duration: 1000});
}
}
}
});
2007-06-29 18:10:15 +04:00
var stickyToggle = new Element('a', {
'href': 'javascript:void(0);',
'events': {
'click': function() {
var wrap = $('wrap');
if ( ! wrap.hasClass('sticky-toc')) {
this.setHTML(tocUnstickyText);
wrap.addClass('sticky-toc');
hideToggle.setStyle('display', 'none');
Cookie.set('stickytoc', 1, {duration: 1000});
} else {
this.setHTML(tocStickyText);
wrap.removeClass('sticky-toc');
hideToggle.setStyle('display', 'inline');
Cookie.set('stickytoc', 0, {duration: 1000});
}
}
}
});
2007-06-29 18:10:15 +04:00
hideToggle.setHTML(tocHideText);
hideToggle.injectInside(container);
2007-06-29 18:10:15 +04:00
stickyToggle.setHTML(tocStickyText);
stickyToggle.injectInside(container);
2007-06-29 18:10:15 +04:00
if (Cookie.get('hidetoc') == 1) {
hideToggle.fireEvent('click');
stickyToggle.setStyle('display', 'none');
2007-06-29 18:10:15 +04:00
}
if (Cookie.get('stickytoc') == 1) {
stickyToggle.fireEvent('click');
hideToggle.setStyle('display', 'none');
2007-06-29 18:10:15 +04:00
}
}
window.addEvent('domready', function() {
initializeTocToggles();
});
window.addEvent('domready', function() {
new SmoothScroll();
});
2007-06-29 18:10:15 +04:00