mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +03:00
Merge pull request #386 from marco-jantke/window-location-hash-fix
Remove hash when closing a method container again. Added small hash help...
This commit is contained in:
commit
221f109ad6
@ -52,8 +52,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() {
|
||||||
@ -63,8 +87,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