mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-24 11:26:31 +00:00
Improve dropdown to make it global
Add dropdown for sharing
This commit is contained in:
@@ -15,20 +15,6 @@ define([
|
||||
"sans": 1
|
||||
};
|
||||
|
||||
var togglePopover = function(e) {
|
||||
var $dropdown = $("#font-settings-wrapper .dropdown-menu");
|
||||
|
||||
$dropdown.toggleClass("open");
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
var closePopover = function(e) {
|
||||
var $dropdown = $("#font-settings-wrapper .dropdown-menu");
|
||||
|
||||
$dropdown.removeClass("open");
|
||||
};
|
||||
|
||||
var enlargeFontSize = function(e){
|
||||
if (fontState.size < 4){
|
||||
fontState.size++;
|
||||
@@ -108,10 +94,6 @@ define([
|
||||
|
||||
$(document).on('click', "#font-settings-wrapper .font-family-list .button", changeFontFamily);
|
||||
$(document).on('click', "#font-settings-wrapper .color-theme-list .button", changeColorTheme);
|
||||
|
||||
$(document).on('click', ".book-header .toggle-font-settings", togglePopover);
|
||||
$(document).on('click', "#font-settings-wrapper .dropdown-menu", function(e){ e.stopPropagation(); });
|
||||
$(document).on("click", closePopover);
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -2,6 +2,7 @@ define([
|
||||
"jQuery",
|
||||
"utils/storage",
|
||||
"utils/sharing",
|
||||
"utils/dropdown",
|
||||
|
||||
"core/events",
|
||||
"core/font-settings",
|
||||
@@ -11,7 +12,7 @@ define([
|
||||
"core/progress",
|
||||
"core/sidebar",
|
||||
"core/search"
|
||||
], function($, storage, sharing, events, fontSettings, state, keyboard, navigation, progress, sidebar, search){
|
||||
], function($, storage, sharing, dropdown, events, fontSettings, state, keyboard, navigation, progress, sidebar, search){
|
||||
var start = function(config) {
|
||||
var $book;
|
||||
$book = state.$book;
|
||||
@@ -33,6 +34,9 @@ define([
|
||||
// Bind sharing button
|
||||
sharing.init();
|
||||
|
||||
// Bind dropdown
|
||||
dropdown.init();
|
||||
|
||||
// Init navigation
|
||||
navigation.init();
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
define([
|
||||
"jQuery"
|
||||
], function($) {
|
||||
|
||||
var toggleDropdown = function(e) {
|
||||
var $dropdown = $(e.currentTarget).parent().find(".dropdown-menu");
|
||||
|
||||
$dropdown.toggleClass("open");
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
var closeDropdown = function(e) {
|
||||
$(".dropdown-menu").removeClass("open");
|
||||
};
|
||||
|
||||
// Bind all dropdown
|
||||
var init = function() {
|
||||
$(document).on('click', ".toggle-dropdown", toggleDropdown);
|
||||
$(document).on('click', ".dropdown-menu", function(e){ e.stopPropagation(); });
|
||||
$(document).on("click", closeDropdown);
|
||||
};
|
||||
|
||||
return {
|
||||
init: init
|
||||
};
|
||||
});
|
||||
@@ -22,7 +22,7 @@ define([
|
||||
|
||||
// Bind all sharing button
|
||||
var init = function() {
|
||||
$(document).on("click", "a[data-sharing]", function(e) {
|
||||
$(document).on("click", "a[data-sharing],button[data-sharing]", function(e) {
|
||||
if (e) e.preventDefault();
|
||||
var type = $(this).data("sharing");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user