mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Remove hash when closing a method container again. Added small hash helper functions.
This commit is contained in:
parent
968a162544
commit
df7be182cd
@ -51,8 +51,32 @@
|
|||||||
</p>
|
</p>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
var getHash = function() {
|
||||||
|
return window.location.hash || '';
|
||||||
|
};
|
||||||
|
|
||||||
|
var setHash = function(hash) {
|
||||||
|
window.location.hash = hash;
|
||||||
|
};
|
||||||
|
|
||||||
|
var clearHash = function() {
|
||||||
|
var scrollTop, scrollLeft;
|
||||||
|
|
||||||
|
if(typeof history === 'object' && typeof history.pushState === 'function') {
|
||||||
|
history.replaceState('', document.title, window.location.pathname + window.location.search);
|
||||||
|
} else {
|
||||||
|
scrollTop = document.body.scrollTop;
|
||||||
|
scrollLeft = document.body.scrollLeft;
|
||||||
|
|
||||||
|
setHash('');
|
||||||
|
|
||||||
|
document.body.scrollTop = scrollTop;
|
||||||
|
document.body.scrollLeft = scrollLeft;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$(window).load(function() {
|
$(window).load(function() {
|
||||||
var id = (window.location.hash || '').substr(1).replace( /([:\.\[\]\{\}])/g, "\\$1");
|
var id = getHash().substr(1).replace( /([:\.\[\]\{\}])/g, "\\$1");
|
||||||
var elem = $('#' + id);
|
var elem = $('#' + id);
|
||||||
if (elem.length) {
|
if (elem.length) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
@ -62,8 +86,17 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.toggler').click(function() {
|
$('.toggler').click(function(event) {
|
||||||
$(this).next().slideToggle('fast');
|
var contentContainer = $(this).next();
|
||||||
|
|
||||||
|
if(contentContainer.is(':visible')) {
|
||||||
|
clearHash();
|
||||||
|
} else {
|
||||||
|
setHash($(this).attr('href'));
|
||||||
|
}
|
||||||
|
|
||||||
|
contentContainer.slideToggle('fast');
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
{% if enableSandbox %}
|
{% if enableSandbox %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user