2013-05-11 20:44:25 +04:00
|
|
|
|
// # Toggle Support
|
|
|
|
|
|
2013-06-25 16:23:09 +04:00
|
|
|
|
/*global document, $, Ghost */
|
|
|
|
|
(function () {
|
2013-05-11 20:44:25 +04:00
|
|
|
|
"use strict";
|
|
|
|
|
|
2013-09-18 05:59:35 +04:00
|
|
|
|
Ghost.temporary.hideToggles = function () {
|
|
|
|
|
$('[data-toggle]').each(function () {
|
|
|
|
|
var toggle = $(this).data('toggle');
|
|
|
|
|
$(this).parent().children(toggle + ':visible').fadeOut();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Toggle active classes on menu headers
|
|
|
|
|
$("[data-toggle].active").removeClass("active");
|
|
|
|
|
};
|
|
|
|
|
|
2013-06-02 03:45:02 +04:00
|
|
|
|
Ghost.temporary.initToggles = function ($el) {
|
|
|
|
|
|
|
|
|
|
$el.find('[data-toggle]').each(function () {
|
2013-05-11 20:44:25 +04:00
|
|
|
|
var toggle = $(this).data('toggle');
|
|
|
|
|
$(this).parent().children(toggle).hide();
|
|
|
|
|
});
|
|
|
|
|
|
2013-06-02 03:45:02 +04:00
|
|
|
|
$el.find('[data-toggle]').on('click', function (e) {
|
2013-05-11 20:44:25 +04:00
|
|
|
|
e.preventDefault();
|
2013-06-25 15:30:00 +04:00
|
|
|
|
e.stopPropagation();
|
2013-09-18 05:59:35 +04:00
|
|
|
|
var $this = $(this),
|
|
|
|
|
toggle = $this.data('toggle'),
|
|
|
|
|
isAlreadyActive = $this.is('.active');
|
|
|
|
|
|
|
|
|
|
// Close all the other open toggle menus
|
|
|
|
|
Ghost.temporary.hideToggles();
|
|
|
|
|
|
|
|
|
|
if (!isAlreadyActive) {
|
|
|
|
|
$this.toggleClass('active');
|
|
|
|
|
$(this).parent().children(toggle).toggleClass('open').fadeToggle(200);
|
|
|
|
|
}
|
2013-05-11 20:44:25 +04:00
|
|
|
|
});
|
|
|
|
|
|
2013-06-02 03:45:02 +04: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 20:44:25 +04:00
|
|
|
|
});
|
2013-06-02 03:45:02 +04:00
|
|
|
|
|
2013-06-25 17:45:30 +04:00
|
|
|
|
}());
|