Search
Other Tabs & Accordions questions
Forum

Suggestion / alias in body classes

Schmakowski, Boris's Avatar Schmakowski, Boris
Hi Peter!

You are still doing a great work – many thanks for that!

In a special use-case I am working on, it made sense to get the alias of an accordion into the class-list of the body tag
to get the option for an indivdual styling via CSS on other elements, depending wich accordion is open/closed.
So I spent some time, as I am really not the pro von JavaScript or JQuery 😉 – but finally got it working.
<script>
		$(document).ready(function() {
		  var aliasplus = "acc-";	// diesen Zusatz vor den  Accordion-Aliasen einfügen
		  // Aktualisierung der Klassenliste auf Basis von data-rlta-state
		  function UpdateBodyClasses() {
		    // kill alle klassen die mit "acc-" beginnen
		    $('body').removeClass(function(index, className) {
		      return (className.match(/\bacc-\S+/g) || []).join(' ');
		    });
		    // Füge Klassen aus data-rlta-alias von allen Elementen mit data-rlta-state="open" ein
		    $('[data-rlta-state="open"]').each(function() {
		      var alias = $(this).data('rlta-alias');
		      if (alias !== undefined) {				// nur wenn ein eindeutiger Wert zu erhalten ist
		        $('body').addClass(aliasplus + alias);
		      }
		    });
		  }
		  // Überwache die Änderungen an data-rlta-state auf allen Elementen
		  $('[data-rlta-state]').on('DOMSubtreeModified propertychange', function() {
		    UpdateBodyClasses();	// wenn sich ein Status ändert, dann ...
		  });
		  UpdateBodyClasses();		// Aktualisere die Klassenliste in Body
		});
	</script>
In my special use-case CSS now interacts with the styling of a SVG-map.

As working on that, it comes in my mind if that will be something as an additional option for the system-plugin of accordions/tabs to get the alias (only if set?) injected/removed within the class-list of BODY or HTML or both ...

Just a thought.
All the best,
Boris

Confidential information:
(hidden)
Peter van Westen's Avatar Peter van Westen ADMIN
No, I don't see this as an option/functionality that will be included in Tabs & Accordions itself.
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription