diff --git a/js/ckeditor-accordion.js b/js/ckeditor-accordion.js
index 866d2f0..bd77180 100644
--- a/js/ckeditor-accordion.js
+++ b/js/ckeditor-accordion.js
@@ -30,7 +30,8 @@
var $tab = $(this);
var tabText = $tab.text().trim();
var toggleClass = $tab.hasClass('active') ? ' active' : '';
- $tab.html('' + tabText + '');
+ var hashBit = encodeURIComponent(tabText.replace(/[^A-Za-z0-9]/g, ""));
+ $tab.html('' + tabText + '');
});
// Wrap the accordion in a div element so that quick edit function shows the source correctly.
@@ -48,25 +49,54 @@
// Clicking on open element, close it.
if ($t.hasClass('active')) {
$t.removeClass('active');
- $t.next().slideUp();
+ $t.next().slideUp(200);
}
else {
if(!drupalSettings.ckeditorAccordion.accordionStyle.keepRowsOpen) {
// Remove active classes.
$parent.children('dt.active').removeClass('active').children('a').removeClass('active');
- $parent.children('dd.active').slideUp(function () {
+ $parent.children('dd.active').slideUp(200, 'swing', function () {
$(this).removeClass('active');
});
}
// Show the selected tab.
$t.addClass('active');
- $t.next().slideDown(300).addClass('active');
+ $t.next().slideDown(200, 'swing', function() {
+ // scroll back
+ setTimeout(function(){
+ $('html, body').animate({
+ scrollTop: $t.offset().top
+ }, 300, 'swing', function() {
+ });
+ }, 250);
+ }).addClass('active');
+
+ /* scroll back
+ $('html, body').animate({
+ scrollTop: $t.offset().top //scrollTop: $parent.offset().top
+ }, 1000);
+ //window.scrollTo(0, $(parent).offset().top);
+ */
+ return true;
}
// Don't add hash to url.
e.preventDefault();
});
+
+ //Open content that matches the hash.
+ $( window ).on('hashchange', function(e) {
+ var ele = $(window.location.hash.replace('__hash', ''));
+ if (typeof ele != 'undefined' && !ele.parent().hasClass('active')) {
+//alert('before ele.click();');
+// meg kell akadályozni az alértelmezett odaugrást ( ?? nem biztos ?? )
+// Ha igen, most ez van alkalmazva:
+// https://stackoverflow.com/questions/3503559/prevent-default-hash-behavior-on-page-load#answer-3503621
+ ele.click();
+ location.hash = window.location.hash;
+ }
+ }).trigger('hashchange');
}
}
};