You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2017/09/08 15:22:57 UTC
[myfaces-tobago] branch master updated: TOBAGO-1759 Update
Bootstrap to 4.0.0 beta 1 (from alpha 6) * fix for dropdown menus if the
parent got an ajax update
This is an automated email from the ASF dual-hosted git repository.
hnoeth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/master by this push:
new fc677a8 TOBAGO-1759 Update Bootstrap to 4.0.0 beta 1 (from alpha 6) * fix for dropdown menus if the parent got an ajax update
fc677a8 is described below
commit fc677a84b81e78cc5bec2f3bbce4f446800611b3
Author: henning <he...@irian.eu>
AuthorDate: Fri Sep 8 17:22:27 2017 +0200
TOBAGO-1759 Update Bootstrap to 4.0.0 beta 1 (from alpha 6)
* fix for dropdown menus if the parent got an ajax update
---
.../_version/js/tobago-dropdown.js | 36 +++++++++++++++++++---
1 file changed, 32 insertions(+), 4 deletions(-)
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-dropdown.js b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-dropdown.js
index 209b7f9..f65deb8 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-dropdown.js
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-dropdown.js
@@ -18,14 +18,19 @@
Tobago.Dropdown = {};
Tobago.Dropdown.init = function (elements) {
- var $dropdownMenus = jQuery(".dropdown-menu");
+ var $dropdownMenus = jQuery(":not(.tobago-page-menuStore) > .dropdown-menu");
+ var $tobagoPageMenuStore = jQuery(".tobago-page-menuStore");
+
$dropdownMenus.each(function () {
var $dropdownMenu = jQuery(this);
var $parent = $dropdownMenu.parent();
- var $tobagoPageMenuStore = jQuery('.tobago-page-menuStore');
- if (!$parent.hasClass('tobago-dropdown-submenu')
- && !$parent.closest('.navbar').length > 0) {
+ if (!$parent.hasClass('tobago-dropdown-submenu') && !$parent.closest('.navbar').length > 0) {
+
+ // remove duplicated dropdown menus from menu store
+ // this could happen if the dropdown component is updated by ajax
+ removeDuplicates($dropdownMenu);
+
$parent.on('shown.bs.dropdown', function (event) {
$tobagoPageMenuStore.append($dropdownMenu.detach());
}).on('hidden.bs.dropdown', function (event) {
@@ -35,5 +40,28 @@ Tobago.Dropdown.init = function (elements) {
});
};
+function removeDuplicates($dropdownMenu) {
+ var $menuStoreDropdowns = jQuery(".tobago-page-menuStore .dropdown-menu");
+ $menuStoreDropdowns.each(function () {
+ var $menuStoreDropdown = jQuery(this);
+
+ var dropdownIds = getIds($dropdownMenu);
+ var menuStoreIds = getIds($menuStoreDropdown);
+
+ for (var i = 0; i < dropdownIds.length; i++) {
+ if (jQuery.inArray(dropdownIds[i], menuStoreIds) >= 0) {
+ $menuStoreDropdown.remove();
+ return false;
+ }
+ }
+ });
+}
+
+function getIds($dropdownMenu) {
+ return $dropdownMenu.find("[id]").map(function () {
+ return this.id;
+ });
+}
+
Tobago.registerListener(Tobago.Dropdown.init, Tobago.Phase.DOCUMENT_READY, Tobago.Phase.Order.NORMAL);
Tobago.registerListener(Tobago.Dropdown.init, Tobago.Phase.AFTER_UPDATE, Tobago.Phase.Order.NORMAL);
--
To stop receiving notification emails like this one, please contact
['"commits@myfaces.apache.org" <co...@myfaces.apache.org>'].