0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00
ghost/core/admin/assets/js/toggle.js

30 lines
911 B
JavaScript
Raw Normal View History

2013-05-11 11:44:25 -05:00
// # Toggle Support
/*global document, jQuery */
(function ($) {
"use strict";
$(document).ready(function () {
// ## Toggle Up In Your Grill
// Allows for toggling via data-attributes.
// ### Usage
// <nav>
// <a href="#" data-toggle=".toggle-me">Toggle</a>
// <ul class="toggle-me">
// <li>Toggled yo</li>
// </ul>
// </nav>
$('[data-toggle]').each(function () {
var toggle = $(this).data('toggle');
$(this).parent().children(toggle).hide();
});
$('[data-toggle]').on('click', function (e) {
e.preventDefault();
$(this).toggleClass('active');
var toggle = $(this).data('toggle');
$(this).parent().children(toggle).fadeToggle(100).toggleClass('open');
});
});
}(jQuery));