aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Schmitz <arschmitz@gmail.com>2015-07-15 20:23:44 -0400
committerAlexander Schmitz <arschmitz@gmail.com>2015-08-08 00:29:37 -0400
commit72bfafbedea4973b803abeefc97637f246b11c89 (patch)
tree501addde9d778f56695ce48b405e97f86dd72cdc
parent6064a5e0487428d53bd694dcebce952730992c46 (diff)
downloadjquery-ui-72bfafbedea4973b803abeefc97637f246b11c89.tar.gz
jquery-ui-72bfafbedea4973b803abeefc97637f246b11c89.zip
Core: Move scrollParent into its own module
Ref #9647
-rw-r--r--ui/core.js15
-rw-r--r--ui/dialog.js1
-rw-r--r--ui/draggable.js2
-rw-r--r--ui/scroll-parent.js42
-rw-r--r--ui/sortable.js3
5 files changed, 47 insertions, 16 deletions
diff --git a/ui/core.js b/ui/core.js
index d443346e8..b77338720 100644
--- a/ui/core.js
+++ b/ui/core.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;
diff --git a/ui/dialog.js b/ui/dialog.js
index 16d650f97..10c9c18f9 100644
--- a/ui/dialog.js
+++ b/ui/dialog.js
@@ -22,6 +22,7 @@
// AMD. Register as an anonymous module.
define( [
"jquery",
+ "./core",
"./version",
"./keycode",
"./widget",
diff --git a/ui/draggable.js b/ui/draggable.js
index b2169703f..007adf58d 100644
--- a/ui/draggable.js
+++ b/ui/draggable.js
@@ -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 );
diff --git a/ui/scroll-parent.js b/ui/scroll-parent.js
new file mode 100644
index 000000000..478b86ae3
--- /dev/null
+++ b/ui/scroll-parent.js
@@ -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;
+};
+
+} ) );
diff --git a/ui/sortable.js b/ui/sortable.js
index 2258e3c62..cb89c30e6 100644
--- a/ui/sortable.js
+++ b/ui/sortable.js
@@ -22,9 +22,10 @@
"jquery",
"./core",
"./data",
+ "./version",
"./ie",
"./mouse",
- "./version",
+ "./scroll-parent",
"./widget"
], factory );
} else {