jqueryui-requirejs-rails 0.1.0

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