[FOLLOWUP][TASK] Hide document header navigation on scroll 00/43800/5
authorMathias Schreiber <mathias.schreiber@wmdb.de>
Sun, 4 Oct 2015 21:15:40 +0000 (23:15 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 5 Oct 2015 06:46:42 +0000 (08:46 +0200)
Adjusted code style and do not put the module into public space.

Resolves: #70328
Releases: master
Change-Id: I84677603a31b3587c801ef69eba7098aeef5a2c0
Reviewed-on: http://review.typo3.org/43800
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Resources/Public/JavaScript/DocumentHeader.js

index 20faa0e..df7ce55 100644 (file)
  * The TYPO3 project - inspiring people to share!
  */
 
  * The TYPO3 project - inspiring people to share!
  */
 
+/**
+ * Calculates the height of the docHeader and hides it upon scrolling
+ */
 define('TYPO3/CMS/Backend/DocumentHeader', ['jquery'], function($) {
 define('TYPO3/CMS/Backend/DocumentHeader', ['jquery'], function($) {
+       "use strict";
 
        var DocumentHeader = {
                $documentHeader: null,
 
        var DocumentHeader = {
                $documentHeader: null,
@@ -35,7 +39,7 @@ define('TYPO3/CMS/Backend/DocumentHeader', ['jquery'], function($) {
                                moduleSearchBar: '.t3js-module-docheader-bar-search',
                                moduleBody: '.t3js-module-body'
 
                                moduleSearchBar: '.t3js-module-docheader-bar-search',
                                moduleBody: '.t3js-module-body'
 
-                       },
+                       }
                }
        };
 
                }
        };
 
@@ -49,32 +53,25 @@ define('TYPO3/CMS/Backend/DocumentHeader', ['jquery'], function($) {
        };
 
        /**
        };
 
        /**
-        * Resize
-        */
-       DocumentHeader.resize = function() {
-               DocumentHeader.reposition();
-       };
-
-       /**
         * Scroll
         */
        DocumentHeader.scroll = function() {
                DocumentHeader.currentPosition = $(window).scrollTop();
         * Scroll
         */
        DocumentHeader.scroll = function() {
                DocumentHeader.currentPosition = $(window).scrollTop();
-               if (DocumentHeader.currentPosition > DocumentHeader.lastPosition){
-                       if (DocumentHeader.direction !== 'down'){
+               if (DocumentHeader.currentPosition > DocumentHeader.lastPosition) {
+                       if (DocumentHeader.direction !== 'down') {
                                DocumentHeader.direction = 'down';
                                DocumentHeader.changedPosition = DocumentHeader.currentPosition;
                        }
                                DocumentHeader.direction = 'down';
                                DocumentHeader.changedPosition = DocumentHeader.currentPosition;
                        }
-               } else if (DocumentHeader.currentPosition < DocumentHeader.lastPosition){
-                       if (DocumentHeader.direction !== 'up'){
+               } else if (DocumentHeader.currentPosition < DocumentHeader.lastPosition) {
+                       if (DocumentHeader.direction !== 'up') {
                                DocumentHeader.direction = 'up';
                                DocumentHeader.changedPosition = DocumentHeader.currentPosition;
                        }
                }
                                DocumentHeader.direction = 'up';
                                DocumentHeader.changedPosition = DocumentHeader.currentPosition;
                        }
                }
-               if(DocumentHeader.direction === "up" && (DocumentHeader.changedPosition - DocumentHeader.reactionRange) < DocumentHeader.currentPosition){
+               if (DocumentHeader.direction === 'up' && (DocumentHeader.changedPosition - DocumentHeader.reactionRange) < DocumentHeader.currentPosition) {
                        DocumentHeader.$documentHeader.css('margin-top', 0);
                }
                        DocumentHeader.$documentHeader.css('margin-top', 0);
                }
-               if(DocumentHeader.direction === "down" && (DocumentHeader.changedPosition + DocumentHeader.reactionRange) < DocumentHeader.currentPosition){
+               if (DocumentHeader.direction === 'down' && (DocumentHeader.changedPosition + DocumentHeader.reactionRange) < DocumentHeader.currentPosition) {
                        DocumentHeader.$documentHeader.css('margin-top', (DocumentHeader.$documentHeaderNavigationBar.outerHeight() + 4) * -1);
                }
                DocumentHeader.lastPosition = DocumentHeader.currentPosition;
                        DocumentHeader.$documentHeader.css('margin-top', (DocumentHeader.$documentHeaderNavigationBar.outerHeight() + 4) * -1);
                }
                DocumentHeader.lastPosition = DocumentHeader.currentPosition;
@@ -85,7 +82,7 @@ define('TYPO3/CMS/Backend/DocumentHeader', ['jquery'], function($) {
         */
        DocumentHeader.start = function() {
                DocumentHeader.reposition();
         */
        DocumentHeader.start = function() {
                DocumentHeader.reposition();
-               $(window).on('resize', DocumentHeader.resize);
+               $(window).on('resize', DocumentHeader.reposition);
                $(window).on('scroll', DocumentHeader.scroll);
        };
 
                $(window).on('scroll', DocumentHeader.scroll);
        };
 
@@ -94,11 +91,11 @@ define('TYPO3/CMS/Backend/DocumentHeader', ['jquery'], function($) {
         */
        DocumentHeader.initialize = function() {
                DocumentHeader.$documentHeader = $(DocumentHeader.settings.selectors.moduleDocumentHeader);
         */
        DocumentHeader.initialize = function() {
                DocumentHeader.$documentHeader = $(DocumentHeader.settings.selectors.moduleDocumentHeader);
-               if(DocumentHeader.$documentHeader.length > 0){
+               if (DocumentHeader.$documentHeader.length > 0) {
                        DocumentHeader.$documentHeaderBars = $(DocumentHeader.settings.selectors.moduleDocheaderBar);
                        DocumentHeader.$documentHeaderNavigationBar = $(DocumentHeader.settings.selectors.moduleNavigationBar);
                        DocumentHeader.$documentHeaderSearchBar = $(DocumentHeader.settings.selectors.moduleSearchBar).remove();
                        DocumentHeader.$documentHeaderBars = $(DocumentHeader.settings.selectors.moduleDocheaderBar);
                        DocumentHeader.$documentHeaderNavigationBar = $(DocumentHeader.settings.selectors.moduleNavigationBar);
                        DocumentHeader.$documentHeaderSearchBar = $(DocumentHeader.settings.selectors.moduleSearchBar).remove();
-                       if(DocumentHeader.$documentHeaderSearchBar.length > 0){
+                       if (DocumentHeader.$documentHeaderSearchBar.length > 0) {
                                DocumentHeader.$documentHeader.append(DocumentHeader.$documentHeaderSearchBar);
                        }
                        DocumentHeader.$moduleBody = $(DocumentHeader.settings.selectors.moduleBody);
                                DocumentHeader.$documentHeader.append(DocumentHeader.$documentHeaderSearchBar);
                        }
                        DocumentHeader.$moduleBody = $(DocumentHeader.settings.selectors.moduleBody);
@@ -106,12 +103,7 @@ define('TYPO3/CMS/Backend/DocumentHeader', ['jquery'], function($) {
                }
        };
 
                }
        };
 
-       return function () {
-               $(document).ready(function() {
-                       DocumentHeader.initialize();
-               });
-               TYPO3.DocumentHeader = DocumentHeader;
-               return DocumentHeader;
-       }();
+       $(DocumentHeader.initialize);
 
 
-});
\ No newline at end of file
+       return DocumentHeader;
+});