Improve dropdown to make it global

Add dropdown for sharing
This commit is contained in:
Samy Pessé
2014-08-10 11:04:10 -07:00
parent a54959ee4f
commit 691d04e994
8 changed files with 81 additions and 39 deletions
-18
View File
@@ -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 {
+5 -1
View File
@@ -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();
+27
View File
@@ -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
};
});
+1 -1
View File
@@ -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");