Permalink
Browse files

Core: Move scrollParent into its own module

Ref #9647
  • Loading branch information...
arschmitz committed Jul 16, 2015
1 parent 6064a5e commit 72bfafbedea4973b803abeefc97637f246b11c89
Showing with 47 additions and 16 deletions.
  1. +1 −14 ui/core.js
  2. +1 −0 ui/dialog.js
  3. +1 −1 ui/draggable.js
  4. +42 −0 ui/scroll-parent.js
  5. +2 −1 ui/sortable.js
@@ -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;
@@ -22,6 +22,7 @@
// AMD. Register as an anonymous module.
define( [
"jquery",
"./core",
"./version",
"./keycode",
"./widget",
@@ -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 );
@@ -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;
};
} ) );
@@ -22,9 +22,10 @@
"jquery",
"./core",
"./data",
"./version",
"./ie",
"./mouse",
"./version",
"./scroll-parent",
"./widget"
], factory );
} else {

0 comments on commit 72bfafb

Please sign in to comment.