mraible commented on code in PR #348:
URL: https://github.com/apache/roller/pull/348#discussion_r4637221477


##########
app/src/main/webapp/themes/gaurav/js/navbar.js:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+// The navbar's collapse button and dropdown menu, using the classes
+// Bootstrap 3's CSS styles, so the theme doesn't need jQuery or Bootstrap's
+// JavaScript.
+(function () {
+    function closeDropdowns(except) {
+        document.querySelectorAll('.dropdown.open').forEach(function 
(dropdown) {
+            if (dropdown !== except) {
+                dropdown.classList.remove('open');
+                var toggle = 
dropdown.querySelector('[data-toggle="dropdown"]');
+                if (toggle) {
+                    toggle.setAttribute('aria-expanded', 'false');
+                }
+            }
+        });
+    }
+
+    document.addEventListener('click', function (event) {
+        var toggle = event.target.closest('[data-toggle]');
+        var kind = toggle ? toggle.getAttribute('data-toggle') : null;
+        if (kind === 'collapse') {
+            var target = 
document.querySelector(toggle.getAttribute('data-target'));
+            if (target) {
+                var shown = target.classList.toggle('in');
+                toggle.classList.toggle('collapsed', !shown);
+                toggle.setAttribute('aria-expanded', String(shown));
+            }
+        } else if (kind === 'dropdown') {
+            event.preventDefault();
+            var dropdown = toggle.parentNode;
+            closeDropdowns(dropdown);
+            var open = dropdown.classList.toggle('open');
+            toggle.setAttribute('aria-expanded', String(open));
+        } else {
+            closeDropdowns(null);
+        }
+    });
+
+    document.addEventListener('keydown', function (event) {

Review Comment:
   Navbar.js now does what Bootstrap 3's dropdown did: Arrow Up/Down on the 
Categories toggle opens the menu and then moves between its links, and Escape 
closes it and puts focus back on the toggle. `NewUserJourneyIT` now previews 
the new weblog in the Gaurav theme and drives the menu from the keyboard; that 
step fails on the previous head and passes now.



##########
app/src/main/webapp/WEB-INF/jsps/tiles/head.jsp:
##########
@@ -26,7 +26,7 @@ You can override it with your own file via 
WEB-INF/tiles-def.xml
 <%-- salt issued with this response, read by refreshSalt() after an AJAX post 
--%>
 <meta name="roller-salt" content="<s:property value="salt"/>" />
 
-<script src="<s:url value='/webjars/jquery/4.0.0/jquery.min.js' />"></script>
+<script src="<s:url value='/webjars/jquery/4.1.0/jquery.min.js' />"></script>

Review Comment:
   Ported from #350: `validateSearch` in weblog.vm now sets `location.hash = 
"searchDialog"`, which the `[data-role="popup"]:target` rule already in 
master's basic-mobile-custom.css shows, so it no longer needs jQuery. I added 
`BasicMobileThemeRenderingTest` with #350's 
`emptySearchOpensTheAlertWithoutJQuery`, which fails on the previous head and 
passes now. The rest of #350's test covers changes that aren't in this PR, so I 
left it out.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to