Core: Move scrollParent into its own module

Ref #9647
This commit is contained in:
Alexander Schmitz 2015-07-15 20:23:44 -04:00
parent 6064a5e048
commit 72bfafbede
5 changed files with 47 additions and 16 deletions

View File

@ -32,6 +32,7 @@
"./safe-active-element",
"./safe-blur",
"./tabbable",
"./scroll-parent",
"./version"
], factory );
} else {
@ -43,20 +44,6 @@
// plugins
$.fn.extend( {
scrollParent: function( includeHidden ) {
var position = this.css( "position" ),
excludeStaticParent = position === "absolute",
overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
scrollParent = this.parents().filter( function() {
var parent = $( this );
if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
return false;
}
return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
} ).eq( 0 );
return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
},
uniqueId: ( function() {
var uuid = 0;

View File

@ -22,6 +22,7 @@
// AMD. Register as an anonymous module.
define( [
"jquery",
"./core",
"./version",
"./keycode",
"./widget",

View File

@ -20,12 +20,12 @@
// AMD. Register as an anonymous module.
define([
"jquery",
"./core",
"./data",
"./mouse",
"./plugin",
"./safe-active-element",
"./safe-blur",
"./scroll-parent",
"./version",
"./widget"
], factory );

42
ui/scroll-parent.js Normal file
View File

@ -0,0 +1,42 @@
/*!
* jQuery UI Scroll Parent @VERSION
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*/
//>>label: scrollParent
//>>group: Core
//>>description: Get the closest ancestor element that is scrollable.
//>>docs: http://api.jqueryui.com/scrollParent/
( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
define( [ "jquery", "./version" ], factory );
} else {
// Browser globals
factory( jQuery );
}
} ( function( $ ) {
return $.fn.scrollParent = function( includeHidden ) {
var position = this.css( "position" ),
excludeStaticParent = position === "absolute",
overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
scrollParent = this.parents().filter( function() {
var parent = $( this );
if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
return false;
}
return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
} ).eq( 0 );
return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
};
} ) );

View File

@ -22,9 +22,10 @@
"jquery",
"./core",
"./data",
"./version",
"./ie",
"./mouse",
"./version",
"./scroll-parent",
"./widget"
], factory );
} else {