jquery-ui-rails 2.0.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jquery-ui-rails might be problematic. Click here for more details.

Files changed (131) hide show
  1. data/History.md +15 -0
  2. data/License.txt +2 -3
  3. data/README.md +17 -19
  4. data/Rakefile +79 -28
  5. data/lib/jquery/ui/rails/version.rb +1 -1
  6. data/vendor/assets/javascripts/jquery.ui.accordion.js +537 -417
  7. data/vendor/assets/javascripts/jquery.ui.all.js +17 -14
  8. data/vendor/assets/javascripts/jquery.ui.autocomplete.js +311 -339
  9. data/vendor/assets/javascripts/jquery.ui.button.js +63 -59
  10. data/vendor/assets/javascripts/jquery.ui.core.js +134 -112
  11. data/vendor/assets/javascripts/jquery.ui.datepicker-ar-DZ.js +2 -2
  12. data/vendor/assets/javascripts/jquery.ui.datepicker-ar.js +3 -3
  13. data/vendor/assets/javascripts/jquery.ui.datepicker-az.js +3 -3
  14. data/vendor/assets/javascripts/jquery.ui.datepicker-bg.js +16 -16
  15. data/vendor/assets/javascripts/jquery.ui.datepicker-bs.js +5 -5
  16. data/vendor/assets/javascripts/jquery.ui.datepicker-ca.js +13 -13
  17. data/vendor/assets/javascripts/jquery.ui.datepicker-cs.js +3 -3
  18. data/vendor/assets/javascripts/jquery.ui.datepicker-cy-GB.js +1 -1
  19. data/vendor/assets/javascripts/jquery.ui.datepicker-da.js +9 -9
  20. data/vendor/assets/javascripts/jquery.ui.datepicker-de.js +2 -2
  21. data/vendor/assets/javascripts/jquery.ui.datepicker-el.js +1 -1
  22. data/vendor/assets/javascripts/jquery.ui.datepicker-eo.js +2 -2
  23. data/vendor/assets/javascripts/jquery.ui.datepicker-es.js +6 -6
  24. data/vendor/assets/javascripts/jquery.ui.datepicker-et.js +1 -1
  25. data/vendor/assets/javascripts/jquery.ui.datepicker-eu.js +3 -3
  26. data/vendor/assets/javascripts/jquery.ui.datepicker-fa.js +3 -3
  27. data/vendor/assets/javascripts/jquery.ui.datepicker-fi.js +5 -5
  28. data/vendor/assets/javascripts/jquery.ui.datepicker-fo.js +3 -3
  29. data/vendor/assets/javascripts/jquery.ui.datepicker-fr-CH.js +3 -3
  30. data/vendor/assets/javascripts/jquery.ui.datepicker-fr.js +2 -2
  31. data/vendor/assets/javascripts/jquery.ui.datepicker-gl.js +6 -6
  32. data/vendor/assets/javascripts/jquery.ui.datepicker-he.js +2 -2
  33. data/vendor/assets/javascripts/jquery.ui.datepicker-hr.js +3 -3
  34. data/vendor/assets/javascripts/jquery.ui.datepicker-hy.js +3 -3
  35. data/vendor/assets/javascripts/jquery.ui.datepicker-id.js +3 -3
  36. data/vendor/assets/javascripts/jquery.ui.datepicker-is.js +11 -11
  37. data/vendor/assets/javascripts/jquery.ui.datepicker-it.js +3 -3
  38. data/vendor/assets/javascripts/jquery.ui.datepicker-ja.js +3 -3
  39. data/vendor/assets/javascripts/jquery.ui.datepicker-kk.js +2 -2
  40. data/vendor/assets/javascripts/jquery.ui.datepicker-ko.js +1 -1
  41. data/vendor/assets/javascripts/jquery.ui.datepicker-lt.js +3 -3
  42. data/vendor/assets/javascripts/jquery.ui.datepicker-lv.js +1 -1
  43. data/vendor/assets/javascripts/jquery.ui.datepicker-ml.js +1 -1
  44. data/vendor/assets/javascripts/jquery.ui.datepicker-ms.js +3 -3
  45. data/vendor/assets/javascripts/jquery.ui.datepicker-nl.js +1 -1
  46. data/vendor/assets/javascripts/jquery.ui.datepicker-no.js +18 -18
  47. data/vendor/assets/javascripts/jquery.ui.datepicker-pl.js +2 -2
  48. data/vendor/assets/javascripts/jquery.ui.datepicker-pt-BR.js +7 -7
  49. data/vendor/assets/javascripts/jquery.ui.datepicker-pt.js +6 -6
  50. data/vendor/assets/javascripts/jquery.ui.datepicker-rm.js +2 -2
  51. data/vendor/assets/javascripts/jquery.ui.datepicker-ro.js +2 -2
  52. data/vendor/assets/javascripts/jquery.ui.datepicker-ru.js +3 -3
  53. data/vendor/assets/javascripts/jquery.ui.datepicker-sk.js +2 -2
  54. data/vendor/assets/javascripts/jquery.ui.datepicker-sl.js +6 -6
  55. data/vendor/assets/javascripts/jquery.ui.datepicker-sq.js +2 -2
  56. data/vendor/assets/javascripts/jquery.ui.datepicker-sr-SR.js +2 -2
  57. data/vendor/assets/javascripts/jquery.ui.datepicker-sr.js +2 -2
  58. data/vendor/assets/javascripts/jquery.ui.datepicker-sv.js +9 -9
  59. data/vendor/assets/javascripts/jquery.ui.datepicker-th.js +3 -3
  60. data/vendor/assets/javascripts/jquery.ui.datepicker-tj.js +1 -1
  61. data/vendor/assets/javascripts/jquery.ui.datepicker-tr.js +2 -2
  62. data/vendor/assets/javascripts/jquery.ui.datepicker-uk.js +3 -3
  63. data/vendor/assets/javascripts/jquery.ui.datepicker-vi.js +2 -2
  64. data/vendor/assets/javascripts/jquery.ui.datepicker-zh-CN.js +2 -2
  65. data/vendor/assets/javascripts/jquery.ui.datepicker-zh-HK.js +2 -2
  66. data/vendor/assets/javascripts/jquery.ui.datepicker-zh-TW.js +2 -2
  67. data/vendor/assets/javascripts/jquery.ui.datepicker.js +51 -59
  68. data/vendor/assets/javascripts/jquery.ui.dialog.js +402 -409
  69. data/vendor/assets/javascripts/jquery.ui.draggable.js +79 -75
  70. data/vendor/assets/javascripts/jquery.ui.droppable.js +10 -17
  71. data/vendor/assets/javascripts/jquery.ui.effect-blind.js +84 -0
  72. data/vendor/assets/javascripts/jquery.ui.effect-bounce.js +115 -0
  73. data/vendor/assets/javascripts/jquery.ui.effect-clip.js +69 -0
  74. data/vendor/assets/javascripts/jquery.ui.effect-drop.js +67 -0
  75. data/vendor/assets/javascripts/jquery.ui.effect-explode.js +99 -0
  76. data/vendor/assets/javascripts/jquery.ui.effect-fade.js +32 -0
  77. data/vendor/assets/javascripts/jquery.ui.effect-fold.js +78 -0
  78. data/vendor/assets/javascripts/jquery.ui.effect-highlight.js +52 -0
  79. data/vendor/assets/javascripts/jquery.ui.effect-pulsate.js +65 -0
  80. data/vendor/assets/javascripts/jquery.ui.effect-scale.js +320 -0
  81. data/vendor/assets/javascripts/jquery.ui.effect-shake.js +76 -0
  82. data/vendor/assets/javascripts/jquery.ui.effect-slide.js +66 -0
  83. data/vendor/assets/javascripts/jquery.ui.effect-transfer.js +49 -0
  84. data/vendor/assets/javascripts/jquery.ui.effect.all.js +14 -0
  85. data/vendor/assets/javascripts/jquery.ui.effect.js +1276 -0
  86. data/vendor/assets/javascripts/jquery.ui.menu.js +614 -0
  87. data/vendor/assets/javascripts/jquery.ui.mouse.js +22 -20
  88. data/vendor/assets/javascripts/jquery.ui.position.js +367 -158
  89. data/vendor/assets/javascripts/jquery.ui.progressbar.js +10 -14
  90. data/vendor/assets/javascripts/jquery.ui.resizable.js +143 -149
  91. data/vendor/assets/javascripts/jquery.ui.selectable.js +22 -28
  92. data/vendor/assets/javascripts/jquery.ui.slider.js +88 -106
  93. data/vendor/assets/javascripts/jquery.ui.sortable.js +97 -95
  94. data/vendor/assets/javascripts/jquery.ui.spinner.js +482 -0
  95. data/vendor/assets/javascripts/jquery.ui.tabs.js +1189 -580
  96. data/vendor/assets/javascripts/jquery.ui.tooltip.js +402 -0
  97. data/vendor/assets/javascripts/jquery.ui.widget.js +373 -117
  98. data/vendor/assets/stylesheets/jquery.ui.accordion.css.erb +10 -13
  99. data/vendor/assets/stylesheets/jquery.ui.all.css.erb +4 -3
  100. data/vendor/assets/stylesheets/jquery.ui.autocomplete.css.erb +10 -44
  101. data/vendor/assets/stylesheets/jquery.ui.base.css.erb +7 -3
  102. data/vendor/assets/stylesheets/jquery.ui.button.css.erb +6 -4
  103. data/vendor/assets/stylesheets/jquery.ui.core.css.erb +5 -4
  104. data/vendor/assets/stylesheets/jquery.ui.datepicker.css.erb +4 -3
  105. data/vendor/assets/stylesheets/jquery.ui.dialog.css.erb +6 -5
  106. data/vendor/assets/stylesheets/jquery.ui.menu.css.erb +34 -0
  107. data/vendor/assets/stylesheets/jquery.ui.progressbar.css.erb +4 -3
  108. data/vendor/assets/stylesheets/jquery.ui.resizable.css.erb +4 -3
  109. data/vendor/assets/stylesheets/jquery.ui.selectable.css.erb +4 -3
  110. data/vendor/assets/stylesheets/jquery.ui.slider.css.erb +4 -3
  111. data/vendor/assets/stylesheets/jquery.ui.spinner.css.erb +27 -0
  112. data/vendor/assets/stylesheets/jquery.ui.tabs.css.erb +8 -8
  113. data/vendor/assets/stylesheets/jquery.ui.theme.css.erb +8 -7
  114. data/vendor/assets/stylesheets/jquery.ui.tooltip.css.erb +25 -0
  115. metadata +24 -19
  116. data/dependencies.js +0 -31
  117. data/vendor/assets/javascripts/jquery.effects.all.js +0 -14
  118. data/vendor/assets/javascripts/jquery.effects.blind.js +0 -51
  119. data/vendor/assets/javascripts/jquery.effects.bounce.js +0 -80
  120. data/vendor/assets/javascripts/jquery.effects.clip.js +0 -56
  121. data/vendor/assets/javascripts/jquery.effects.core.js +0 -612
  122. data/vendor/assets/javascripts/jquery.effects.drop.js +0 -52
  123. data/vendor/assets/javascripts/jquery.effects.explode.js +0 -81
  124. data/vendor/assets/javascripts/jquery.effects.fade.js +0 -34
  125. data/vendor/assets/javascripts/jquery.effects.fold.js +0 -58
  126. data/vendor/assets/javascripts/jquery.effects.highlight.js +0 -52
  127. data/vendor/assets/javascripts/jquery.effects.pulsate.js +0 -53
  128. data/vendor/assets/javascripts/jquery.effects.scale.js +0 -180
  129. data/vendor/assets/javascripts/jquery.effects.shake.js +0 -59
  130. data/vendor/assets/javascripts/jquery.effects.slide.js +0 -52
  131. data/vendor/assets/javascripts/jquery.effects.transfer.js +0 -47
@@ -2,13 +2,14 @@
2
2
  //= require jquery.ui.widget
3
3
 
4
4
  /*!
5
- * jQuery UI Mouse 1.8.24
5
+ * jQuery UI Mouse 1.9.2
6
+ * http://jqueryui.com
6
7
  *
7
- * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
8
- * Dual licensed under the MIT or GPL Version 2 licenses.
8
+ * Copyright 2012 jQuery Foundation and other contributors
9
+ * Released under the MIT license.
9
10
  * http://jquery.org/license
10
11
  *
11
- * http://docs.jquery.com/UI/Mouse
12
+ * http://api.jqueryui.com/mouse/
12
13
  *
13
14
  * Depends:
14
15
  * jquery.ui.widget.js
@@ -21,21 +22,22 @@ $( document ).mouseup( function( e ) {
21
22
  });
22
23
 
23
24
  $.widget("ui.mouse", {
25
+ version: "1.9.2",
24
26
  options: {
25
- cancel: ':input,option',
27
+ cancel: 'input,textarea,button,select,option',
26
28
  distance: 1,
27
29
  delay: 0
28
30
  },
29
31
  _mouseInit: function() {
30
- var self = this;
32
+ var that = this;
31
33
 
32
34
  this.element
33
35
  .bind('mousedown.'+this.widgetName, function(event) {
34
- return self._mouseDown(event);
36
+ return that._mouseDown(event);
35
37
  })
36
38
  .bind('click.'+this.widgetName, function(event) {
37
- if (true === $.data(event.target, self.widgetName + '.preventClickEvent')) {
38
- $.removeData(event.target, self.widgetName + '.preventClickEvent');
39
+ if (true === $.data(event.target, that.widgetName + '.preventClickEvent')) {
40
+ $.removeData(event.target, that.widgetName + '.preventClickEvent');
39
41
  event.stopImmediatePropagation();
40
42
  return false;
41
43
  }
@@ -57,18 +59,18 @@ $.widget("ui.mouse", {
57
59
 
58
60
  _mouseDown: function(event) {
59
61
  // don't let more than one widget handle mouseStart
60
- if( mouseHandled ) { return };
62
+ if( mouseHandled ) { return; }
61
63
 
62
64
  // we may have missed mouseup (out of window)
63
65
  (this._mouseStarted && this._mouseUp(event));
64
66
 
65
67
  this._mouseDownEvent = event;
66
68
 
67
- var self = this,
68
- btnIsLeft = (event.which == 1),
69
+ var that = this,
70
+ btnIsLeft = (event.which === 1),
69
71
  // event.target.nodeName works around a bug in IE 8 with
70
72
  // disabled inputs (#7620)
71
- elIsCancel = (typeof this.options.cancel == "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
73
+ elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
72
74
  if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
73
75
  return true;
74
76
  }
@@ -76,7 +78,7 @@ $.widget("ui.mouse", {
76
78
  this.mouseDelayMet = !this.options.delay;
77
79
  if (!this.mouseDelayMet) {
78
80
  this._mouseDelayTimer = setTimeout(function() {
79
- self.mouseDelayMet = true;
81
+ that.mouseDelayMet = true;
80
82
  }, this.options.delay);
81
83
  }
82
84
 
@@ -95,24 +97,24 @@ $.widget("ui.mouse", {
95
97
 
96
98
  // these delegates are required to keep context
97
99
  this._mouseMoveDelegate = function(event) {
98
- return self._mouseMove(event);
100
+ return that._mouseMove(event);
99
101
  };
100
102
  this._mouseUpDelegate = function(event) {
101
- return self._mouseUp(event);
103
+ return that._mouseUp(event);
102
104
  };
103
105
  $(document)
104
106
  .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
105
107
  .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
106
108
 
107
109
  event.preventDefault();
108
-
110
+
109
111
  mouseHandled = true;
110
112
  return true;
111
113
  },
112
114
 
113
115
  _mouseMove: function(event) {
114
116
  // IE mouseup check - mouseup happened when mouse was out of window
115
- if ($.browser.msie && !(document.documentMode >= 9) && !event.button) {
117
+ if ($.ui.ie && !(document.documentMode >= 9) && !event.button) {
116
118
  return this._mouseUp(event);
117
119
  }
118
120
 
@@ -138,8 +140,8 @@ $.widget("ui.mouse", {
138
140
  if (this._mouseStarted) {
139
141
  this._mouseStarted = false;
140
142
 
141
- if (event.target == this._mouseDownEvent.target) {
142
- $.data(event.target, this.widgetName + '.preventClickEvent', true);
143
+ if (event.target === this._mouseDownEvent.target) {
144
+ $.data(event.target, this.widgetName + '.preventClickEvent', true);
143
145
  }
144
146
 
145
147
  this._mouseStop(event);
@@ -1,22 +1,87 @@
1
1
  /*!
2
- * jQuery UI Position 1.8.24
2
+ * jQuery UI Position 1.9.2
3
+ * http://jqueryui.com
3
4
  *
4
- * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
5
- * Dual licensed under the MIT or GPL Version 2 licenses.
5
+ * Copyright 2012 jQuery Foundation and other contributors
6
+ * Released under the MIT license.
6
7
  * http://jquery.org/license
7
8
  *
8
- * http://docs.jquery.com/UI/Position
9
+ * http://api.jqueryui.com/position/
9
10
  */
10
11
  (function( $, undefined ) {
11
12
 
12
13
  $.ui = $.ui || {};
13
14
 
14
- var horizontalPositions = /left|center|right/,
15
- verticalPositions = /top|center|bottom/,
16
- center = "center",
17
- support = {},
18
- _position = $.fn.position,
19
- _offset = $.fn.offset;
15
+ var cachedScrollbarWidth,
16
+ max = Math.max,
17
+ abs = Math.abs,
18
+ round = Math.round,
19
+ rhorizontal = /left|center|right/,
20
+ rvertical = /top|center|bottom/,
21
+ roffset = /[\+\-]\d+%?/,
22
+ rposition = /^\w+/,
23
+ rpercent = /%$/,
24
+ _position = $.fn.position;
25
+
26
+ function getOffsets( offsets, width, height ) {
27
+ return [
28
+ parseInt( offsets[ 0 ], 10 ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
29
+ parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
30
+ ];
31
+ }
32
+ function parseCss( element, property ) {
33
+ return parseInt( $.css( element, property ), 10 ) || 0;
34
+ }
35
+
36
+ $.position = {
37
+ scrollbarWidth: function() {
38
+ if ( cachedScrollbarWidth !== undefined ) {
39
+ return cachedScrollbarWidth;
40
+ }
41
+ var w1, w2,
42
+ div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
43
+ innerDiv = div.children()[0];
44
+
45
+ $( "body" ).append( div );
46
+ w1 = innerDiv.offsetWidth;
47
+ div.css( "overflow", "scroll" );
48
+
49
+ w2 = innerDiv.offsetWidth;
50
+
51
+ if ( w1 === w2 ) {
52
+ w2 = div[0].clientWidth;
53
+ }
54
+
55
+ div.remove();
56
+
57
+ return (cachedScrollbarWidth = w1 - w2);
58
+ },
59
+ getScrollInfo: function( within ) {
60
+ var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
61
+ overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
62
+ hasOverflowX = overflowX === "scroll" ||
63
+ ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
64
+ hasOverflowY = overflowY === "scroll" ||
65
+ ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
66
+ return {
67
+ width: hasOverflowX ? $.position.scrollbarWidth() : 0,
68
+ height: hasOverflowY ? $.position.scrollbarWidth() : 0
69
+ };
70
+ },
71
+ getWithinInfo: function( element ) {
72
+ var withinElement = $( element || window ),
73
+ isWindow = $.isWindow( withinElement[0] );
74
+ return {
75
+ element: withinElement,
76
+ isWindow: isWindow,
77
+ offset: withinElement.offset() || { left: 0, top: 0 },
78
+ scrollLeft: withinElement.scrollLeft(),
79
+ scrollTop: withinElement.scrollTop(),
80
+ width: isWindow ? withinElement.width() : withinElement.outerWidth(),
81
+ height: isWindow ? withinElement.height() : withinElement.outerHeight()
82
+ };
83
+ }
84
+ };
20
85
 
21
86
  $.fn.position = function( options ) {
22
87
  if ( !options || !options.of ) {
@@ -26,48 +91,65 @@ $.fn.position = function( options ) {
26
91
  // make a copy, we don't want to modify arguments
27
92
  options = $.extend( {}, options );
28
93
 
29
- var target = $( options.of ),
94
+ var atOffset, targetWidth, targetHeight, targetOffset, basePosition,
95
+ target = $( options.of ),
96
+ within = $.position.getWithinInfo( options.within ),
97
+ scrollInfo = $.position.getScrollInfo( within ),
30
98
  targetElem = target[0],
31
99
  collision = ( options.collision || "flip" ).split( " " ),
32
- offset = options.offset ? options.offset.split( " " ) : [ 0, 0 ],
33
- targetWidth,
34
- targetHeight,
35
- basePosition;
100
+ offsets = {};
36
101
 
37
102
  if ( targetElem.nodeType === 9 ) {
38
103
  targetWidth = target.width();
39
104
  targetHeight = target.height();
40
- basePosition = { top: 0, left: 0 };
41
- // TODO: use $.isWindow() in 1.9
42
- } else if ( targetElem.setTimeout ) {
105
+ targetOffset = { top: 0, left: 0 };
106
+ } else if ( $.isWindow( targetElem ) ) {
43
107
  targetWidth = target.width();
44
108
  targetHeight = target.height();
45
- basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
109
+ targetOffset = { top: target.scrollTop(), left: target.scrollLeft() };
46
110
  } else if ( targetElem.preventDefault ) {
47
111
  // force left top to allow flipping
48
112
  options.at = "left top";
49
113
  targetWidth = targetHeight = 0;
50
- basePosition = { top: options.of.pageY, left: options.of.pageX };
114
+ targetOffset = { top: targetElem.pageY, left: targetElem.pageX };
51
115
  } else {
52
116
  targetWidth = target.outerWidth();
53
117
  targetHeight = target.outerHeight();
54
- basePosition = target.offset();
118
+ targetOffset = target.offset();
55
119
  }
120
+ // clone to reuse original targetOffset later
121
+ basePosition = $.extend( {}, targetOffset );
56
122
 
57
- // force my and at to have valid horizontal and veritcal positions
58
- // if a value is missing or invalid, it will be converted to center
123
+ // force my and at to have valid horizontal and vertical positions
124
+ // if a value is missing or invalid, it will be converted to center
59
125
  $.each( [ "my", "at" ], function() {
60
- var pos = ( options[this] || "" ).split( " " );
126
+ var pos = ( options[ this ] || "" ).split( " " ),
127
+ horizontalOffset,
128
+ verticalOffset;
129
+
61
130
  if ( pos.length === 1) {
62
- pos = horizontalPositions.test( pos[0] ) ?
63
- pos.concat( [center] ) :
64
- verticalPositions.test( pos[0] ) ?
65
- [ center ].concat( pos ) :
66
- [ center, center ];
131
+ pos = rhorizontal.test( pos[ 0 ] ) ?
132
+ pos.concat( [ "center" ] ) :
133
+ rvertical.test( pos[ 0 ] ) ?
134
+ [ "center" ].concat( pos ) :
135
+ [ "center", "center" ];
67
136
  }
68
- pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : center;
69
- pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : center;
70
- options[ this ] = pos;
137
+ pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
138
+ pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
139
+
140
+ // calculate offsets
141
+ horizontalOffset = roffset.exec( pos[ 0 ] );
142
+ verticalOffset = roffset.exec( pos[ 1 ] );
143
+ offsets[ this ] = [
144
+ horizontalOffset ? horizontalOffset[ 0 ] : 0,
145
+ verticalOffset ? verticalOffset[ 0 ] : 0
146
+ ];
147
+
148
+ // reduce to just the positions without the offsets
149
+ options[ this ] = [
150
+ rposition.exec( pos[ 0 ] )[ 0 ],
151
+ rposition.exec( pos[ 1 ] )[ 0 ]
152
+ ];
71
153
  });
72
154
 
73
155
  // normalize collision option
@@ -75,67 +157,63 @@ $.fn.position = function( options ) {
75
157
  collision[ 1 ] = collision[ 0 ];
76
158
  }
77
159
 
78
- // normalize offset option
79
- offset[ 0 ] = parseInt( offset[0], 10 ) || 0;
80
- if ( offset.length === 1 ) {
81
- offset[ 1 ] = offset[ 0 ];
82
- }
83
- offset[ 1 ] = parseInt( offset[1], 10 ) || 0;
84
-
85
- if ( options.at[0] === "right" ) {
160
+ if ( options.at[ 0 ] === "right" ) {
86
161
  basePosition.left += targetWidth;
87
- } else if ( options.at[0] === center ) {
162
+ } else if ( options.at[ 0 ] === "center" ) {
88
163
  basePosition.left += targetWidth / 2;
89
164
  }
90
165
 
91
- if ( options.at[1] === "bottom" ) {
166
+ if ( options.at[ 1 ] === "bottom" ) {
92
167
  basePosition.top += targetHeight;
93
- } else if ( options.at[1] === center ) {
168
+ } else if ( options.at[ 1 ] === "center" ) {
94
169
  basePosition.top += targetHeight / 2;
95
170
  }
96
171
 
97
- basePosition.left += offset[ 0 ];
98
- basePosition.top += offset[ 1 ];
172
+ atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
173
+ basePosition.left += atOffset[ 0 ];
174
+ basePosition.top += atOffset[ 1 ];
99
175
 
100
176
  return this.each(function() {
101
- var elem = $( this ),
177
+ var collisionPosition, using,
178
+ elem = $( this ),
102
179
  elemWidth = elem.outerWidth(),
103
180
  elemHeight = elem.outerHeight(),
104
- marginLeft = parseInt( $.curCSS( this, "marginLeft", true ) ) || 0,
105
- marginTop = parseInt( $.curCSS( this, "marginTop", true ) ) || 0,
106
- collisionWidth = elemWidth + marginLeft +
107
- ( parseInt( $.curCSS( this, "marginRight", true ) ) || 0 ),
108
- collisionHeight = elemHeight + marginTop +
109
- ( parseInt( $.curCSS( this, "marginBottom", true ) ) || 0 ),
181
+ marginLeft = parseCss( this, "marginLeft" ),
182
+ marginTop = parseCss( this, "marginTop" ),
183
+ collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
184
+ collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
110
185
  position = $.extend( {}, basePosition ),
111
- collisionPosition;
186
+ myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
112
187
 
113
- if ( options.my[0] === "right" ) {
188
+ if ( options.my[ 0 ] === "right" ) {
114
189
  position.left -= elemWidth;
115
- } else if ( options.my[0] === center ) {
190
+ } else if ( options.my[ 0 ] === "center" ) {
116
191
  position.left -= elemWidth / 2;
117
192
  }
118
193
 
119
- if ( options.my[1] === "bottom" ) {
194
+ if ( options.my[ 1 ] === "bottom" ) {
120
195
  position.top -= elemHeight;
121
- } else if ( options.my[1] === center ) {
196
+ } else if ( options.my[ 1 ] === "center" ) {
122
197
  position.top -= elemHeight / 2;
123
198
  }
124
199
 
125
- // prevent fractions if jQuery version doesn't support them (see #5280)
126
- if ( !support.fractions ) {
127
- position.left = Math.round( position.left );
128
- position.top = Math.round( position.top );
200
+ position.left += myOffset[ 0 ];
201
+ position.top += myOffset[ 1 ];
202
+
203
+ // if the browser doesn't support fractions, then round for consistent results
204
+ if ( !$.support.offsetFractions ) {
205
+ position.left = round( position.left );
206
+ position.top = round( position.top );
129
207
  }
130
208
 
131
209
  collisionPosition = {
132
- left: position.left - marginLeft,
133
- top: position.top - marginTop
210
+ marginLeft: marginLeft,
211
+ marginTop: marginTop
134
212
  };
135
213
 
136
214
  $.each( [ "left", "top" ], function( i, dir ) {
137
- if ( $.ui.position[ collision[i] ] ) {
138
- $.ui.position[ collision[i] ][ dir ]( position, {
215
+ if ( $.ui.position[ collision[ i ] ] ) {
216
+ $.ui.position[ collision[ i ] ][ dir ]( position, {
139
217
  targetWidth: targetWidth,
140
218
  targetHeight: targetHeight,
141
219
  elemWidth: elemWidth,
@@ -143,9 +221,11 @@ $.fn.position = function( options ) {
143
221
  collisionPosition: collisionPosition,
144
222
  collisionWidth: collisionWidth,
145
223
  collisionHeight: collisionHeight,
146
- offset: offset,
224
+ offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
147
225
  my: options.my,
148
- at: options.at
226
+ at: options.at,
227
+ within: within,
228
+ elem : elem
149
229
  });
150
230
  }
151
231
  });
@@ -153,31 +233,137 @@ $.fn.position = function( options ) {
153
233
  if ( $.fn.bgiframe ) {
154
234
  elem.bgiframe();
155
235
  }
156
- elem.offset( $.extend( position, { using: options.using } ) );
236
+
237
+ if ( options.using ) {
238
+ // adds feedback as second argument to using callback, if present
239
+ using = function( props ) {
240
+ var left = targetOffset.left - position.left,
241
+ right = left + targetWidth - elemWidth,
242
+ top = targetOffset.top - position.top,
243
+ bottom = top + targetHeight - elemHeight,
244
+ feedback = {
245
+ target: {
246
+ element: target,
247
+ left: targetOffset.left,
248
+ top: targetOffset.top,
249
+ width: targetWidth,
250
+ height: targetHeight
251
+ },
252
+ element: {
253
+ element: elem,
254
+ left: position.left,
255
+ top: position.top,
256
+ width: elemWidth,
257
+ height: elemHeight
258
+ },
259
+ horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
260
+ vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
261
+ };
262
+ if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
263
+ feedback.horizontal = "center";
264
+ }
265
+ if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
266
+ feedback.vertical = "middle";
267
+ }
268
+ if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
269
+ feedback.important = "horizontal";
270
+ } else {
271
+ feedback.important = "vertical";
272
+ }
273
+ options.using.call( this, props, feedback );
274
+ };
275
+ }
276
+
277
+ elem.offset( $.extend( position, { using: using } ) );
157
278
  });
158
279
  };
159
280
 
160
281
  $.ui.position = {
161
282
  fit: {
162
283
  left: function( position, data ) {
163
- var win = $( window ),
164
- over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft();
165
- position.left = over > 0 ? position.left - over : Math.max( position.left - data.collisionPosition.left, position.left );
284
+ var within = data.within,
285
+ withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
286
+ outerWidth = within.width,
287
+ collisionPosLeft = position.left - data.collisionPosition.marginLeft,
288
+ overLeft = withinOffset - collisionPosLeft,
289
+ overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
290
+ newOverRight;
291
+
292
+ // element is wider than within
293
+ if ( data.collisionWidth > outerWidth ) {
294
+ // element is initially over the left side of within
295
+ if ( overLeft > 0 && overRight <= 0 ) {
296
+ newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
297
+ position.left += overLeft - newOverRight;
298
+ // element is initially over right side of within
299
+ } else if ( overRight > 0 && overLeft <= 0 ) {
300
+ position.left = withinOffset;
301
+ // element is initially over both left and right sides of within
302
+ } else {
303
+ if ( overLeft > overRight ) {
304
+ position.left = withinOffset + outerWidth - data.collisionWidth;
305
+ } else {
306
+ position.left = withinOffset;
307
+ }
308
+ }
309
+ // too far left -> align with left edge
310
+ } else if ( overLeft > 0 ) {
311
+ position.left += overLeft;
312
+ // too far right -> align with right edge
313
+ } else if ( overRight > 0 ) {
314
+ position.left -= overRight;
315
+ // adjust based on position and margin
316
+ } else {
317
+ position.left = max( position.left - collisionPosLeft, position.left );
318
+ }
166
319
  },
167
320
  top: function( position, data ) {
168
- var win = $( window ),
169
- over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop();
170
- position.top = over > 0 ? position.top - over : Math.max( position.top - data.collisionPosition.top, position.top );
321
+ var within = data.within,
322
+ withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
323
+ outerHeight = data.within.height,
324
+ collisionPosTop = position.top - data.collisionPosition.marginTop,
325
+ overTop = withinOffset - collisionPosTop,
326
+ overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
327
+ newOverBottom;
328
+
329
+ // element is taller than within
330
+ if ( data.collisionHeight > outerHeight ) {
331
+ // element is initially over the top of within
332
+ if ( overTop > 0 && overBottom <= 0 ) {
333
+ newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
334
+ position.top += overTop - newOverBottom;
335
+ // element is initially over bottom of within
336
+ } else if ( overBottom > 0 && overTop <= 0 ) {
337
+ position.top = withinOffset;
338
+ // element is initially over both top and bottom of within
339
+ } else {
340
+ if ( overTop > overBottom ) {
341
+ position.top = withinOffset + outerHeight - data.collisionHeight;
342
+ } else {
343
+ position.top = withinOffset;
344
+ }
345
+ }
346
+ // too far up -> align with top
347
+ } else if ( overTop > 0 ) {
348
+ position.top += overTop;
349
+ // too far down -> align with bottom edge
350
+ } else if ( overBottom > 0 ) {
351
+ position.top -= overBottom;
352
+ // adjust based on position and margin
353
+ } else {
354
+ position.top = max( position.top - collisionPosTop, position.top );
355
+ }
171
356
  }
172
357
  },
173
-
174
358
  flip: {
175
359
  left: function( position, data ) {
176
- if ( data.at[0] === center ) {
177
- return;
178
- }
179
- var win = $( window ),
180
- over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(),
360
+ var within = data.within,
361
+ withinOffset = within.offset.left + within.scrollLeft,
362
+ outerWidth = within.width,
363
+ offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
364
+ collisionPosLeft = position.left - data.collisionPosition.marginLeft,
365
+ overLeft = collisionPosLeft - offsetLeft,
366
+ overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
181
367
  myOffset = data.my[ 0 ] === "left" ?
182
368
  -data.elemWidth :
183
369
  data.my[ 0 ] === "right" ?
@@ -185,88 +371,79 @@ $.ui.position = {
185
371
  0,
186
372
  atOffset = data.at[ 0 ] === "left" ?
187
373
  data.targetWidth :
188
- -data.targetWidth,
189
- offset = -2 * data.offset[ 0 ];
190
- position.left += data.collisionPosition.left < 0 ?
191
- myOffset + atOffset + offset :
192
- over > 0 ?
193
- myOffset + atOffset + offset :
194
- 0;
374
+ data.at[ 0 ] === "right" ?
375
+ -data.targetWidth :
376
+ 0,
377
+ offset = -2 * data.offset[ 0 ],
378
+ newOverRight,
379
+ newOverLeft;
380
+
381
+ if ( overLeft < 0 ) {
382
+ newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
383
+ if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
384
+ position.left += myOffset + atOffset + offset;
385
+ }
386
+ }
387
+ else if ( overRight > 0 ) {
388
+ newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
389
+ if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
390
+ position.left += myOffset + atOffset + offset;
391
+ }
392
+ }
195
393
  },
196
394
  top: function( position, data ) {
197
- if ( data.at[1] === center ) {
198
- return;
199
- }
200
- var win = $( window ),
201
- over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(),
202
- myOffset = data.my[ 1 ] === "top" ?
395
+ var within = data.within,
396
+ withinOffset = within.offset.top + within.scrollTop,
397
+ outerHeight = within.height,
398
+ offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
399
+ collisionPosTop = position.top - data.collisionPosition.marginTop,
400
+ overTop = collisionPosTop - offsetTop,
401
+ overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
402
+ top = data.my[ 1 ] === "top",
403
+ myOffset = top ?
203
404
  -data.elemHeight :
204
405
  data.my[ 1 ] === "bottom" ?
205
406
  data.elemHeight :
206
407
  0,
207
408
  atOffset = data.at[ 1 ] === "top" ?
208
409
  data.targetHeight :
209
- -data.targetHeight,
210
- offset = -2 * data.offset[ 1 ];
211
- position.top += data.collisionPosition.top < 0 ?
212
- myOffset + atOffset + offset :
213
- over > 0 ?
214
- myOffset + atOffset + offset :
215
- 0;
410
+ data.at[ 1 ] === "bottom" ?
411
+ -data.targetHeight :
412
+ 0,
413
+ offset = -2 * data.offset[ 1 ],
414
+ newOverTop,
415
+ newOverBottom;
416
+ if ( overTop < 0 ) {
417
+ newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
418
+ if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
419
+ position.top += myOffset + atOffset + offset;
420
+ }
421
+ }
422
+ else if ( overBottom > 0 ) {
423
+ newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
424
+ if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
425
+ position.top += myOffset + atOffset + offset;
426
+ }
427
+ }
428
+ }
429
+ },
430
+ flipfit: {
431
+ left: function() {
432
+ $.ui.position.flip.left.apply( this, arguments );
433
+ $.ui.position.fit.left.apply( this, arguments );
434
+ },
435
+ top: function() {
436
+ $.ui.position.flip.top.apply( this, arguments );
437
+ $.ui.position.fit.top.apply( this, arguments );
216
438
  }
217
439
  }
218
440
  };
219
441
 
220
- // offset setter from jQuery 1.4
221
- if ( !$.offset.setOffset ) {
222
- $.offset.setOffset = function( elem, options ) {
223
- // set position first, in-case top/left are set even on static elem
224
- if ( /static/.test( $.curCSS( elem, "position" ) ) ) {
225
- elem.style.position = "relative";
226
- }
227
- var curElem = $( elem ),
228
- curOffset = curElem.offset(),
229
- curTop = parseInt( $.curCSS( elem, "top", true ), 10 ) || 0,
230
- curLeft = parseInt( $.curCSS( elem, "left", true ), 10) || 0,
231
- props = {
232
- top: (options.top - curOffset.top) + curTop,
233
- left: (options.left - curOffset.left) + curLeft
234
- };
235
-
236
- if ( 'using' in options ) {
237
- options.using.call( elem, props );
238
- } else {
239
- curElem.css( props );
240
- }
241
- };
242
-
243
- $.fn.offset = function( options ) {
244
- var elem = this[ 0 ];
245
- if ( !elem || !elem.ownerDocument ) { return null; }
246
- if ( options ) {
247
- if ( $.isFunction( options ) ) {
248
- return this.each(function( i ) {
249
- $( this ).offset( options.call( this, i, $( this ).offset() ) );
250
- });
251
- }
252
- return this.each(function() {
253
- $.offset.setOffset( this, options );
254
- });
255
- }
256
- return _offset.call( this );
257
- };
258
- }
259
-
260
- // jQuery <1.4.3 uses curCSS, in 1.4.3 - 1.7.2 curCSS = css, 1.8+ only has css
261
- if ( !$.curCSS ) {
262
- $.curCSS = $.css;
263
- }
264
-
265
- // fraction support test (older versions of jQuery don't support fractions)
442
+ // fraction support test
266
443
  (function () {
267
- var body = document.getElementsByTagName( "body" )[ 0 ],
268
- div = document.createElement( "div" ),
269
- testElement, testElementParent, testElementStyle, offset, offsetTotal;
444
+ var testElement, testElementParent, testElementStyle, offsetLeft, i,
445
+ body = document.getElementsByTagName( "body" )[ 0 ],
446
+ div = document.createElement( "div" );
270
447
 
271
448
  //Create a "fake body" for testing based on method used in jQuery.support
272
449
  testElement = document.createElement( body ? "div" : "body" );
@@ -285,24 +462,56 @@ if ( !$.curCSS ) {
285
462
  top: "-1000px"
286
463
  });
287
464
  }
288
- for ( var i in testElementStyle ) {
465
+ for ( i in testElementStyle ) {
289
466
  testElement.style[ i ] = testElementStyle[ i ];
290
467
  }
291
468
  testElement.appendChild( div );
292
469
  testElementParent = body || document.documentElement;
293
470
  testElementParent.insertBefore( testElement, testElementParent.firstChild );
294
471
 
295
- div.style.cssText = "position: absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 201px;";
472
+ div.style.cssText = "position: absolute; left: 10.7432222px;";
296
473
 
297
- offset = $( div ).offset( function( _, offset ) {
298
- return offset;
299
- }).offset();
474
+ offsetLeft = $( div ).offset().left;
475
+ $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
300
476
 
301
477
  testElement.innerHTML = "";
302
478
  testElementParent.removeChild( testElement );
303
-
304
- offsetTotal = offset.top + offset.left + ( body ? 2000 : 0 );
305
- support.fractions = offsetTotal > 21 && offsetTotal < 22;
306
479
  })();
307
480
 
308
- }( jQuery ));
481
+ // DEPRECATED
482
+ if ( $.uiBackCompat !== false ) {
483
+ // offset option
484
+ (function( $ ) {
485
+ var _position = $.fn.position;
486
+ $.fn.position = function( options ) {
487
+ if ( !options || !options.offset ) {
488
+ return _position.call( this, options );
489
+ }
490
+ var offset = options.offset.split( " " ),
491
+ at = options.at.split( " " );
492
+ if ( offset.length === 1 ) {
493
+ offset[ 1 ] = offset[ 0 ];
494
+ }
495
+ if ( /^\d/.test( offset[ 0 ] ) ) {
496
+ offset[ 0 ] = "+" + offset[ 0 ];
497
+ }
498
+ if ( /^\d/.test( offset[ 1 ] ) ) {
499
+ offset[ 1 ] = "+" + offset[ 1 ];
500
+ }
501
+ if ( at.length === 1 ) {
502
+ if ( /left|center|right/.test( at[ 0 ] ) ) {
503
+ at[ 1 ] = "center";
504
+ } else {
505
+ at[ 1 ] = at[ 0 ];
506
+ at[ 0 ] = "center";
507
+ }
508
+ }
509
+ return _position.call( this, $.extend( options, {
510
+ at: at[ 0 ] + offset[ 0 ] + " " + at[ 1 ] + offset[ 1 ],
511
+ offset: undefined
512
+ } ) );
513
+ };
514
+ }( jQuery ) );
515
+ }
516
+
517
+ }( jQuery ) );