]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1426685 - Fix regressions from fixed-positioning global header
authorKohei Yoshino <kohei.yoshino@gmail.com>
Wed, 3 Jan 2018 15:32:05 +0000 (10:32 -0500)
committerDylan William Hardison <dylan@hardison.net>
Wed, 3 Jan 2018 15:32:05 +0000 (10:32 -0500)
15 files changed:
extensions/BugModal/web/bug_modal.css
extensions/BugModal/web/bug_modal.js
extensions/BugModal/web/common_bug_modal.css
extensions/BugModal/web/common_bug_modal.js
js/global.js
js/instant-search.js
skins/standard/global.css
skins/standard/page.css
template/en/default/bug/summarize-time.html.tmpl
template/en/default/global/footer.html.tmpl
template/en/default/global/header.html.tmpl
template/en/default/search/field.html.tmpl
template/en/default/search/form.html.tmpl
template/en/default/search/search-instant.html.tmpl
template/en/default/search/search-specific.html.tmpl

index b70a838c16df67f4f845c62852243dbf03b5e891..0fbc536b9b8befeceae25a9cab731f54c0125521 100644 (file)
@@ -826,10 +826,10 @@ body.platform-Win32 .comment-text, body.platform-Win64 .comment-text {
 
 /* theme */
 
-#bugzilla-body {
+#main-inner {
+    margin: 15px auto;
     max-width: 1024px;
     min-width: 800px;
-    width: 100%;
 }
 
 .vcard {
index 1218b4f27147e21c3dd35a14f049852c420033a4..c1080cde8fa97af9a4e97c994bb93b97a294a6d4 100644 (file)
@@ -141,7 +141,7 @@ $(function() {
     $('#top-btn')
         .click(function(event) {
             event.preventDefault();
-            $.scrollTo($('body'));
+            $.scrollTo($('#main-inner'));
         });
 
     // bottom btn
@@ -1421,31 +1421,26 @@ $(function() {
             return -1;
         },
 
-        // Bring an element into view, leaving space for the outline.
-        // If passed a string, it will be treated as an id - the page will scroll
-        // unanimated and the url will be added to the browser's history.
-        // If passed an element, an smooth scroll will take place and no entry
-        // will be added to the history.
+        // Bring an element into view, leaving space for the outline. If passed
+        // a string, it will be treated as an id - the page will scroll and the
+        // url will be added to the browser's history. If passed an element, no
+        // entry will be added to the history.
         scrollTo: function(target, complete) {
+            let $target;
+
             if (typeof target === 'string') {
-                var el = $('#' + target);
+                $target = $('#' + target);
                 window.location.hash = target;
-                var $html = $('html');
-                if (Math.abs($html.scrollTop() - el.offset().top) <= 1) {
-                    $html.scrollTop($html.scrollTop() - 10);
-                }
-                $html.scrollLeft(0);
+            } else {
+                $target = target;
             }
-            else {
-                var offset = target.offset();
-                $('html')
-                    .animate({
-                            scrollTop: offset.top - 20,
-                            scrollLeft: 0
-                        },
-                        200,
-                        complete
-                    );
+
+            if ($target.length) {
+                $('main').scrollTop(Math.round($target.position().top) - 20);
+            }
+
+            if (complete) {
+                complete();
             }
         }
 
index b71254cc0e9efeff97ba0b451f466674e243fcde..473c4a4456904c98aa979e69174d1c2ba128f5d0 100644 (file)
@@ -815,10 +815,10 @@ body.platform-Win32 .comment-text, body.platform-Win64 .comment-text {
 
 /* theme */
 
-#bugzilla-body {
+#main-inner {
+    margin: 15px auto;
     max-width: 1024px;
     min-width: 800px;
-    width: 100%;
 }
 
 .vcard {
index cc7f31dfda20b2b360365c8f77dd04fa06c99e47..160f922ccac38d9f6c2070f5541b4a6c765031c3 100644 (file)
@@ -141,7 +141,7 @@ $(function() {
     $('#top-btn')
         .click(function(event) {
             event.preventDefault();
-            $.scrollTo($('body'));
+            $.scrollTo($('#main-inner'));
         });
 
     // bottom btn
@@ -1348,31 +1348,26 @@ $(function() {
             return -1;
         },
 
-        // Bring an element into view, leaving space for the outline.
-        // If passed a string, it will be treated as an id - the page will scroll
-        // unanimated and the url will be added to the browser's history.
-        // If passed an element, an smooth scroll will take place and no entry
-        // will be added to the history.
+        // Bring an element into view, leaving space for the outline. If passed
+        // a string, it will be treated as an id - the page will scroll and the
+        // url will be added to the browser's history. If passed an element, no
+        // entry will be added to the history.
         scrollTo: function(target, complete) {
+            let $target;
+
             if (typeof target === 'string') {
-                var el = $('#' + target);
+                $target = $('#' + target);
                 window.location.hash = target;
-                var $html = $('html');
-                if (Math.abs($html.scrollTop() - el.offset().top) <= 1) {
-                    $html.scrollTop($html.scrollTop() - 10);
-                }
-                $html.scrollLeft(0);
+            } else {
+                $target = target;
             }
-            else {
-                var offset = target.offset();
-                $('html')
-                    .animate({
-                            scrollTop: offset.top - 20,
-                            scrollLeft: 0
-                        },
-                        200,
-                        complete
-                    );
+
+            if ($target.length) {
+                $('main').scrollTop(Math.round($target.position().top) - 20);
+            }
+
+            if (complete) {
+                complete();
             }
         }
 
index 2b353a69e12cd2423adf7368a07a4698ddc895f6..93f364c9e7343cb35a44c0adcde7f83b2d799344 100644 (file)
@@ -191,6 +191,16 @@ $().ready(function() {
     });
 });
 
+/**
+ * Focus the main content when the page is loaded and there is no autofocus
+ * element, so the user can immediately scroll down the page using keyboard.
+ */
+const focus_main_content = () => {
+    if (!document.querySelector('[autofocus]')) {
+        document.querySelector('main').focus();
+    }
+}
+
 /**
  * Check if Gravatar images on the page are successfully loaded, and if blocked
  * (by any content blocker), replace them with the default/fallback image.
@@ -210,17 +220,16 @@ const detect_blocked_gravatars = () => {
  */
 const scroll_element_into_view = () => {
     if (location.hash) {
-        const $header = document.querySelector('#header');
-        const $comment = document.querySelector(location.hash);
+        const $main = document.querySelector('main');
+        const $target = document.querySelector(location.hash);
 
-        if ($comment) {
-            window.setTimeout(() => {
-                window.scrollTo(0, $comment.offsetTop - $header.offsetHeight - 20);
-            }, 250);
+        if ($target) {
+            window.setTimeout(() => $main.scrollTop = $target.offsetTop - 20, 50);
         }
     }
 }
 
+window.addEventListener('DOMContentLoaded', focus_main_content, { once: true });
 window.addEventListener('load', detect_blocked_gravatars, { once: true });
 window.addEventListener('load', scroll_element_into_view, { once: true });
 window.addEventListener('hashchange', scroll_element_into_view);
index 8277b97a95fb3990c5778accf60836139b033a31..946f8ccfc286115af400fa7bbab94aee8c09d067 100644 (file)
@@ -15,7 +15,6 @@ Event.onDOMReady(function() {
   } else {
     YAHOO.bugzilla.instantSearch.reset();
   }
-  Dom.get('content').focus();
 });
 
 YAHOO.bugzilla.instantSearch = {
index a00839de93ac25f7869e03e01c55dc1f464a36f2..ab0a68a1119fd53696ace1d0aeec8a3fd39962d5 100644 (file)
 
 /* global (begin) */
     body {
+        position: absolute;
+        margin: 0;
+        width: 100%;
+        height: 100%;
         font-family: sans-serif;
         color: #000;
         background: #fff url("global/body-back.gif") repeat-x;
-        scroll-behavior: smooth;
     }
     body, td, th, input {
         font-family: Verdana, sans-serif;
     }
 /* global (end) */
 
-/* header (begin) */
-    #header {
+/* wrapper (begin) */
+    #wrapper {
+        display: flex;
+        flex-direction: column;
         position: absolute;
-        top: 0;
-        left: 0;
-        z-index: 1000;
         width: 100%;
+        height: 100%;
+    }
+/* wrapper (end) */
+
+/* header (begin) */
+    #header {
+        flex: none;
         border-bottom: 1px solid rgba(0, 0, 0, 0.2);
         box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
         color: #555;
         background-color: #FFF;
     }
 
-    @media only screen and (min-device-width: 1024px) {
-        #header {
-            position: fixed; /* Make the header fixed on desktop */
-        }
-    }
-
     #header a,
     #header a:visited,
     #header a:hover {
         position: absolute;
         top: 48px;
         right: 0;
+        z-index: 100;
         display: flex;
         align-items: center;
         padding: 8px;
@@ -1127,6 +1131,7 @@ hr {
 }
 
 #mfa-warning {
+    flex: none;
     margin: 0 -15px;
     padding: 10px 15px;
     color: #FFF;
@@ -1134,10 +1139,17 @@ hr {
 }
 
 #bugzilla-body {
-    background: none;
-    border: none;
-    color: #404040;
-    margin: 15px auto 0;
+    flex: auto;
+    position: relative;
+    outline: none;
+    padding: 0 15px;
+    overflow-x: hidden;
+    overflow-y: scroll;
+    scroll-behavior: smooth;
+}
+
+#main-inner {
+    margin: 15px 0;
 }
 
 #bugzilla-body th {
@@ -1625,11 +1637,6 @@ table.tabs {
     padding-bottom: 6px;
 }
 
-body {
-    margin: 0;
-    padding: 50px 15px 15px;
-}
-
 #header .btn, #header .txt {
     font-size: 100%;
 }
index da0c3be8d84f144d70e01e38c399e81a506cf12b..82d4bacb1651cb0eeba642bfdaaaef3e41f4234e 100644 (file)
 /* This CSS is used by various informational pages in the
    template/en/default/pages/ directory. */
 
-#bugzilla-body {
-    padding: 0 1em;
-}
-
-#bugzilla-body > * {
+#main-inner {
+    margin: 15px auto;
     /* People have an easier time reading narrower columns of text. */
     max-width: 45em;
 }
index 50c7770637f5b841b8bcb2885a67be89e0a495b5..120bd74ad097ac3fac84dab3f28d3e69485558b6 100644 (file)
   <b><label accesskey="s" 
              for="start_date">Period <u>s</u>tarting</label></b>: 
 </td><td colspan="3">
-  <input type="text" id="start_date" name="start_date" size="11"
+  <input type="text" id="start_date" name="start_date" size="11" autofocus
          align="right" value="[% start_date FILTER html %]" maxlength="10"
          onchange="updateCalendarFromField(this)">
   <button type="button" class="calendar_button"
 <!--
   createCalendar('start_date');
   createCalendar('end_date');
-  document.forms['summary'].start_date.focus();
 //--></script>
 <hr noshade size=1>
 [% END %]
index 7922e494b74524f0a2a5cc2279f1a843e4def753..f1ad69fc9f2b020f6f13d0bd7fe10d4a4d9b674b 100644 (file)
@@ -19,7 +19,9 @@
   #                 Svetlana Harisova <light@rathedg.com>
   #%]
 
+</div> [%# main-inner %]
 </main> [%# bugzilla-body %]
+</div> [%# wrapper %]
 
 [% Hook.process("end") %]
 
index f339b80b127d0a838a3f1fe59b0cd7c904eeb3e7..5d00b721611f7be78bd23a9247d31a99fef4de3f 100644 (file)
   # 'bannerhtml'
   #%]
 
+<div id="wrapper">
 <header id="header" role="banner">
   <div class="inner">
     <h1 id="header-title" class="title"><a href="./" title="Go to home page">[% terms.Bugzilla %]</a></h1>
   </aside>
 [% END %]
 
-<main id="bugzilla-body">
+<main id="bugzilla-body" tabindex="-1">
+<div id="main-inner">
 
 [%# in most cases the "header" variable provides redundant information, however
   # there are exceptions where not displaying this text is problematic. %]
index a2ff5718b44114fde96550aba7160933cfccdeae..0d10d4f6ba4dd0b402bd70805ecedb5263934b42 100644 (file)
@@ -43,6 +43,7 @@
     %]    
     <input name="[% field.name FILTER html %]" 
            id="[% field.name FILTER html %]" size="40"
+           [% IF autofocus %] autofocus[% END %]
            [% IF onchange %] onchange="[% onchange FILTER html %]"[% END %]
            value="[% value FILTER html %]">              
   [% CASE constants.FIELD_TYPE_KEYWORDS %]
index 02357e4739509de407befd65532a053fe451b348..49c31180661028bd16d8b27099de36b91353cb02 100644 (file)
@@ -141,11 +141,8 @@ TUI_hide_default('information_query');
          value = default.short_desc.0
          type_selected = default.short_desc_type.0 
          accesskey = "s"
+         autofocus = 1
          %]
-      <script> <!--
-          document.forms[queryform].short_desc.focus(); 
-      // -->
-      </script>
 
       [% IF button_name %]
         <input type="submit" id="[% button_name FILTER css_class_quote %]_top"
index 8e4298654c49a974606eef68ac9c6e4e05058b6a..01af804fc96c63fc48a6cb3187e09c28eb420f3b 100644 (file)
@@ -71,7 +71,7 @@ YAHOO.bugzilla.instantSearch.setLabels( {
       <b><label for="content">Words:</label></b>
     </td>
     <td>
-      <input id="content" spellcheck="true" size="60"
+      <input id="content" spellcheck="true" size="60" autofocus
              value="[% default.content.0 FILTER html %]">
     </td>
   </tr>
index 79b5b2932db10bb9b11c6430f82ddf03825d2936..3b4cc35149a4d69ad8fa3e488c4be21e8cd6893f 100644 (file)
@@ -98,12 +98,8 @@ for "crash secure SSL flash".
       <label for="content">Words:</label>
     </th>
     <td>
-      <input name="content" size="60" id="content"
+      <input name="content" size="60" id="content" autofocus
              value="[% default.content.0 FILTER html %]">
-      <script> <!--
-          document.forms['queryform'].content.focus(); 
-      // -->
-      </script>
     </td>
   </tr>
   <tr>