1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-09-01 21:22:04 +03:00

Cleaned up tag edit interface

This commit is contained in:
Dan Brown
2016-05-14 20:02:00 +01:00
parent b80184cd93
commit 78564ec61d
11 changed files with 160 additions and 33 deletions

View File

@@ -301,6 +301,42 @@ module.exports = function (ngApp, events) {
}
}
}])
}]);
ngApp.directive('toolbox', [function() {
return {
restrict: 'A',
link: function(scope, elem, attrs) {
// Get common elements
const $buttons = elem.find('[tab-button]');
const $content = elem.find('[tab-content]');
const $toggle = elem.find('[toolbox-toggle]');
// Handle toolbox toggle click
$toggle.click((e) => {
elem.toggleClass('open');
});
// Set an active tab/content by name
function setActive(tabName, openToolbox) {
$buttons.removeClass('active');
$content.hide();
$buttons.filter(`[tab-button="${tabName}"]`).addClass('active');
$content.filter(`[tab-content="${tabName}"]`).show();
if (openToolbox) elem.addClass('open');
}
// Set the first tab content active on load
setActive($content.first().attr('tab-content'), false);
// Handle tab button click
$buttons.click(function(e) {
let name = $(this).attr('tab-button');
setActive(name, true);
});
}
}
}]);
};