Skip to content

Commit 72bfafb

Browse files
committed
Core: Move scrollParent into its own module
Ref #9647
1 parent 6064a5e commit 72bfafb

File tree

5 files changed

+47
-16
lines changed

5 files changed

+47
-16
lines changed

ui/core.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"./safe-active-element",
3333
"./safe-blur",
3434
"./tabbable",
35+
"./scroll-parent",
3536
"./version"
3637
], factory );
3738
} else {
@@ -43,20 +44,6 @@
4344

4445
// plugins
4546
$.fn.extend( {
46-
scrollParent: function( includeHidden ) {
47-
var position = this.css( "position" ),
48-
excludeStaticParent = position === "absolute",
49-
overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
50-
scrollParent = this.parents().filter( function() {
51-
var parent = $( this );
52-
if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
53-
return false;
54-
}
55-
return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
56-
} ).eq( 0 );
57-
58-
return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
59-
},
6047

6148
uniqueId: ( function() {
6249
var uuid = 0;

ui/dialog.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
// AMD. Register as an anonymous module.
2323
define( [
2424
"jquery",
25+
"./core",
2526
"./version",
2627
"./keycode",
2728
"./widget",

ui/draggable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
// AMD. Register as an anonymous module.
2121
define([
2222
"jquery",
23-
"./core",
2423
"./data",
2524
"./mouse",
2625
"./plugin",
2726
"./safe-active-element",
2827
"./safe-blur",
28+
"./scroll-parent",
2929
"./version",
3030
"./widget"
3131
], factory );

ui/scroll-parent.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*!
2+
* jQuery UI Scroll Parent @VERSION
3+
* http://jqueryui.com
4+
*
5+
* Copyright jQuery Foundation and other contributors
6+
* Released under the MIT license.
7+
* http://jquery.org/license
8+
*/
9+
10+
//>>label: scrollParent
11+
//>>group: Core
12+
//>>description: Get the closest ancestor element that is scrollable.
13+
//>>docs: http://api.jqueryui.com/scrollParent/
14+
15+
( function( factory ) {
16+
if ( typeof define === "function" && define.amd ) {
17+
18+
// AMD. Register as an anonymous module.
19+
define( [ "jquery", "./version" ], factory );
20+
} else {
21+
22+
// Browser globals
23+
factory( jQuery );
24+
}
25+
} ( function( $ ) {
26+
27+
return $.fn.scrollParent = function( includeHidden ) {
28+
var position = this.css( "position" ),
29+
excludeStaticParent = position === "absolute",
30+
overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
31+
scrollParent = this.parents().filter( function() {
32+
var parent = $( this );
33+
if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
34+
return false;
35+
}
36+
return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
37+
} ).eq( 0 );
38+
39+
return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
40+
};
41+
42+
} ) );

ui/sortable.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
"jquery",
2323
"./core",
2424
"./data",
25+
"./version",
2526
"./ie",
2627
"./mouse",
27-
"./version",
28+
"./scroll-parent",
2829
"./widget"
2930
], factory );
3031
} else {

0 commit comments

Comments
 (0)