2013-05-11 11:44:25 -05:00
|
|
|
|
// # Toggle Support
|
|
|
|
|
|
2013-06-25 07:23:09 -05:00
|
|
|
|
/*global document, $, Ghost */
|
|
|
|
|
(function () {
|
2013-05-11 11:44:25 -05:00
|
|
|
|
"use strict";
|
|
|
|
|
|
2013-06-01 18:45:02 -05:00
|
|
|
|
Ghost.temporary.initToggles = function ($el) {
|
|
|
|
|
|
|
|
|
|
$el.find('[data-toggle]').each(function () {
|
2013-05-11 11:44:25 -05:00
|
|
|
|
var toggle = $(this).data('toggle');
|
|
|
|
|
$(this).parent().children(toggle).hide();
|
|
|
|
|
});
|
|
|
|
|
|
2013-06-01 18:45:02 -05:00
|
|
|
|
$el.find('[data-toggle]').on('click', function (e) {
|
2013-05-11 11:44:25 -05:00
|
|
|
|
e.preventDefault();
|
2013-06-25 06:30:00 -05:00
|
|
|
|
e.stopPropagation();
|
2013-05-11 11:44:25 -05:00
|
|
|
|
$(this).toggleClass('active');
|
|
|
|
|
var toggle = $(this).data('toggle');
|
2013-06-25 06:30:00 -05:00
|
|
|
|
$(this).parent().children(toggle).fadeToggle(200).toggleClass('open');
|
2013-05-11 11:44:25 -05:00
|
|
|
|
});
|
|
|
|
|
|
2013-06-01 18:45:02 -05:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(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>
|
|
|
|
|
Ghost.temporary.initToggles($(document));
|
2013-05-11 11:44:25 -05:00
|
|
|
|
});
|
2013-06-01 18:45:02 -05:00
|
|
|
|
|
2013-06-25 08:45:30 -05:00
|
|
|
|
}());
|