diff --git a/core-js-offset-mess-1870006-10.patch b/core-js-offset-mess-1870006-10.patch new file mode 100644 index 0000000..700c654 --- /dev/null +++ b/core-js-offset-mess-1870006-10.patch @@ -0,0 +1,84 @@ +diff --git a/core/misc/offset/fragment.js b/core/misc/offset/fragment.js +new file mode 100644 +index 0000000..b2aac4f +--- /dev/null ++++ b/core/misc/offset/fragment.js +@@ -0,0 +1,26 @@ ++/** ++ * @file ++ * Offsets the window to allow fragments navigation with fixed positioning elements. ++ */ ++(function ($, Drupal, displace) { ++ ++ "use strict"; ++ ++ function adjustOffset () { ++ var hash = window.location.hash; ++ if (hash) { ++ var element = document.getElementById(hash.replace('#', '')); ++ if (element) { ++ // Display the element in the viewport. ++ setTimeout(function () { ++ window.scrollTo(0, $(element).offset().top - displace.offsets.top); ++ }, 5); ++ } ++ } ++ } ++ ++ // Checks for a fragment on page load, outside Drupal behaviors. ++ Drupal.behaviors.adjustOffset = { attach: adjustOffset }; ++ $(window).on('hashchange', adjustOffset); ++ ++})(jQuery, Drupal, Drupal.displace); +diff --git a/core/misc/offset/html5forms.js b/core/misc/offset/html5forms.js +new file mode 100644 +index 0000000..32e0d33 +--- /dev/null ++++ b/core/misc/offset/html5forms.js +@@ -0,0 +1,13 @@ ++/** ++ * @file ++ * Focus the HTML5 validation error in view. ++ */ ++(function (displace) { ++ ++ "use strict"; ++ ++ document.addEventListener('invalid', function (event) { ++ setTimeout(function () { window.scrollBy(0, -displace.offsets.top); }, 5); ++ }, true); ++ ++})(Drupal.displace); +diff --git a/core/modules/system/system.module b/core/modules/system/system.module +index 10bc48d..364e848 100644 +--- a/core/modules/system/system.module ++++ b/core/modules/system/system.module +@@ -952,6 +952,10 @@ function system_library_info() { + 'version' => Drupal::VERSION, + 'js' => array( + 'core/misc/drupal.js' => array('group' => JS_LIBRARY, 'weight' => -18), ++ 'core/misc/debounce.js' => array('group' => JS_LIBRARY), ++ 'core/misc/displace.js' => array('group' => JS_LIBRARY), ++ 'core/misc/offset/fragment.js' => array('group' => JS_LIBRARY), ++ 'core/misc/offset/html5forms.js' => array('group' => JS_LIBRARY), + ), + 'dependencies' => array( + array('system', 'domready'), +@@ -1162,7 +1166,7 @@ function system_library_info() { + 'title' => 'Drupal displace', + 'version' => Drupal::VERSION, + 'js' => array( +- 'core/misc/displace.js' => array('group' => JS_LIBRARY), ++ //'core/misc/displace.js' => array('group' => JS_LIBRARY), + ), + 'dependencies' => array( + array('system', 'jquery'), +@@ -1191,7 +1195,7 @@ function system_library_info() { + 'title' => 'Drupal debounce', + 'version' => Drupal::VERSION, + 'js' => array( +- 'core/misc/debounce.js' => array('group' => JS_LIBRARY), ++ //'core/misc/debounce.js' => array('group' => JS_LIBRARY), + ), + 'dependencies' => array( + // @todo remove drupal dependency. diff --git a/core/misc/offset/fragment.js b/core/misc/offset/fragment.js new file mode 100644 index 0000000..46aa63e --- /dev/null +++ b/core/misc/offset/fragment.js @@ -0,0 +1,26 @@ +/** + * @file + * Offsets the window to allow fragments navigation with fixed positioning elements. + */ +(function ($, Drupal, displace) { + + "use strict"; + + function adjustOffset () { + var hash = window.location.hash; + if (hash) { + var element = document.getElementById(hash.replace('#', '')); + if (element) { + // Display the element in the viewport. + setTimeout(function () { + window.scrollTo(0, $(element).offset().top - displace.offsets.top); + }, 5); + } + } + } + + // Checks for a fragment on page load, outside Drupal behaviors. + Drupal.behaviors.adjustOffset = { attach: adjustOffset }; + $(window).on('hashchange', adjustOffset); + +})(jQuery, Drupal, Drupal.displace); \ No newline at end of file diff --git a/core/misc/offset/html5forms.js b/core/misc/offset/html5forms.js new file mode 100644 index 0000000..c7dbda5 --- /dev/null +++ b/core/misc/offset/html5forms.js @@ -0,0 +1,13 @@ +/** + * @file + * Focus the HTML5 validation error in view. + */ +(function (displace) { + + "use strict"; + + document.addEventListener('invalid', function (event) { + setTimeout(function () { window.scrollBy(0, -displace.offsets.top); }, 5); + }, true); + +})(Drupal.displace); \ No newline at end of file