~ubuntu-branches/debian/sid/wordpress/sid

« back to all changes in this revision

Viewing changes to debian/missing-sources/jquery-ui-1.8.23/jquery.ui.position.js

  • Committer: Package Import Robot
  • Author(s): Raphaël Hertzog
  • Date: 2013-09-04 23:18:58 UTC
  • mfrom: (1.2.28)
  • Revision ID: package-import@ubuntu.com-20130904231858-nljmn1buzswh63jk
Tags: 3.6+dfsg-1
* New upstream release.
* Improve wp-settings to verify that $_SERVER['HTTP_X_FORWARDED_PROTO']
  exists before accessing it (avoids a PHP notice).
  Thanks to Paul Dreik <slask@pauldreik.se> for the report and the patch.
* Document in README.Debian the need to login to /wp-admin/ to complete
  an upgrade.
* Drop useless debian/README.source
* Drop 008CVE2008-2392.patch since upstream now disables unfiltered
  uploads by default. See http://core.trac.wordpress.org/ticket/10692
* Drop 009CVE2008-6767.patch since the backto parameter is validated
  against a whitelist, and externally triggered upgrades are not a
  security problem as long as they work.
* Update debian/missing-sources with latest versions.
* Update upstream l10n.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*!
2
 
 * jQuery UI Position 1.8.23
3
 
 *
4
 
 * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
5
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
6
 
 * http://jquery.org/license
7
 
 *
8
 
 * http://docs.jquery.com/UI/Position
9
 
 */
10
 
(function( $, undefined ) {
11
 
 
12
 
$.ui = $.ui || {};
13
 
 
14
 
var horizontalPositions = /left|center|right/,
15
 
        verticalPositions = /top|center|bottom/,
16
 
        center = "center",
17
 
        support = {},
18
 
        _position = $.fn.position,
19
 
        _offset = $.fn.offset;
20
 
 
21
 
$.fn.position = function( options ) {
22
 
        if ( !options || !options.of ) {
23
 
                return _position.apply( this, arguments );
24
 
        }
25
 
 
26
 
        // make a copy, we don't want to modify arguments
27
 
        options = $.extend( {}, options );
28
 
 
29
 
        var target = $( options.of ),
30
 
                targetElem = target[0],
31
 
                collision = ( options.collision || "flip" ).split( " " ),
32
 
                offset = options.offset ? options.offset.split( " " ) : [ 0, 0 ],
33
 
                targetWidth,
34
 
                targetHeight,
35
 
                basePosition;
36
 
 
37
 
        if ( targetElem.nodeType === 9 ) {
38
 
                targetWidth = target.width();
39
 
                targetHeight = target.height();
40
 
                basePosition = { top: 0, left: 0 };
41
 
        // TODO: use $.isWindow() in 1.9
42
 
        } else if ( targetElem.setTimeout ) {
43
 
                targetWidth = target.width();
44
 
                targetHeight = target.height();
45
 
                basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
46
 
        } else if ( targetElem.preventDefault ) {
47
 
                // force left top to allow flipping
48
 
                options.at = "left top";
49
 
                targetWidth = targetHeight = 0;
50
 
                basePosition = { top: options.of.pageY, left: options.of.pageX };
51
 
        } else {
52
 
                targetWidth = target.outerWidth();
53
 
                targetHeight = target.outerHeight();
54
 
                basePosition = target.offset();
55
 
        }
56
 
 
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 
59
 
        $.each( [ "my", "at" ], function() {
60
 
                var pos = ( options[this] || "" ).split( " " );
61
 
                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 ];
67
 
                }
68
 
                pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : center;
69
 
                pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : center;
70
 
                options[ this ] = pos;
71
 
        });
72
 
 
73
 
        // normalize collision option
74
 
        if ( collision.length === 1 ) {
75
 
                collision[ 1 ] = collision[ 0 ];
76
 
        }
77
 
 
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" ) {
86
 
                basePosition.left += targetWidth;
87
 
        } else if ( options.at[0] === center ) {
88
 
                basePosition.left += targetWidth / 2;
89
 
        }
90
 
 
91
 
        if ( options.at[1] === "bottom" ) {
92
 
                basePosition.top += targetHeight;
93
 
        } else if ( options.at[1] === center ) {
94
 
                basePosition.top += targetHeight / 2;
95
 
        }
96
 
 
97
 
        basePosition.left += offset[ 0 ];
98
 
        basePosition.top += offset[ 1 ];
99
 
 
100
 
        return this.each(function() {
101
 
                var elem = $( this ),
102
 
                        elemWidth = elem.outerWidth(),
103
 
                        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 ),
110
 
                        position = $.extend( {}, basePosition ),
111
 
                        collisionPosition;
112
 
 
113
 
                if ( options.my[0] === "right" ) {
114
 
                        position.left -= elemWidth;
115
 
                } else if ( options.my[0] === center ) {
116
 
                        position.left -= elemWidth / 2;
117
 
                }
118
 
 
119
 
                if ( options.my[1] === "bottom" ) {
120
 
                        position.top -= elemHeight;
121
 
                } else if ( options.my[1] === center ) {
122
 
                        position.top -= elemHeight / 2;
123
 
                }
124
 
 
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 );
129
 
                }
130
 
 
131
 
                collisionPosition = {
132
 
                        left: position.left - marginLeft,
133
 
                        top: position.top - marginTop
134
 
                };
135
 
 
136
 
                $.each( [ "left", "top" ], function( i, dir ) {
137
 
                        if ( $.ui.position[ collision[i] ] ) {
138
 
                                $.ui.position[ collision[i] ][ dir ]( position, {
139
 
                                        targetWidth: targetWidth,
140
 
                                        targetHeight: targetHeight,
141
 
                                        elemWidth: elemWidth,
142
 
                                        elemHeight: elemHeight,
143
 
                                        collisionPosition: collisionPosition,
144
 
                                        collisionWidth: collisionWidth,
145
 
                                        collisionHeight: collisionHeight,
146
 
                                        offset: offset,
147
 
                                        my: options.my,
148
 
                                        at: options.at
149
 
                                });
150
 
                        }
151
 
                });
152
 
 
153
 
                if ( $.fn.bgiframe ) {
154
 
                        elem.bgiframe();
155
 
                }
156
 
                elem.offset( $.extend( position, { using: options.using } ) );
157
 
        });
158
 
};
159
 
 
160
 
$.ui.position = {
161
 
        fit: {
162
 
                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 );
166
 
                },
167
 
                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 );
171
 
                }
172
 
        },
173
 
 
174
 
        flip: {
175
 
                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(),
181
 
                                myOffset = data.my[ 0 ] === "left" ?
182
 
                                        -data.elemWidth :
183
 
                                        data.my[ 0 ] === "right" ?
184
 
                                                data.elemWidth :
185
 
                                                0,
186
 
                                atOffset = data.at[ 0 ] === "left" ?
187
 
                                        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;
195
 
                },
196
 
                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" ?
203
 
                                        -data.elemHeight :
204
 
                                        data.my[ 1 ] === "bottom" ?
205
 
                                                data.elemHeight :
206
 
                                                0,
207
 
                                atOffset = data.at[ 1 ] === "top" ?
208
 
                                        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;
216
 
                }
217
 
        }
218
 
};
219
 
 
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)
266
 
(function () {
267
 
        var body = document.getElementsByTagName( "body" )[ 0 ], 
268
 
                div = document.createElement( "div" ),
269
 
                testElement, testElementParent, testElementStyle, offset, offsetTotal;
270
 
 
271
 
        //Create a "fake body" for testing based on method used in jQuery.support
272
 
        testElement = document.createElement( body ? "div" : "body" );
273
 
        testElementStyle = {
274
 
                visibility: "hidden",
275
 
                width: 0,
276
 
                height: 0,
277
 
                border: 0,
278
 
                margin: 0,
279
 
                background: "none"
280
 
        };
281
 
        if ( body ) {
282
 
                $.extend( testElementStyle, {
283
 
                        position: "absolute",
284
 
                        left: "-1000px",
285
 
                        top: "-1000px"
286
 
                });
287
 
        }
288
 
        for ( var i in testElementStyle ) {
289
 
                testElement.style[ i ] = testElementStyle[ i ];
290
 
        }
291
 
        testElement.appendChild( div );
292
 
        testElementParent = body || document.documentElement;
293
 
        testElementParent.insertBefore( testElement, testElementParent.firstChild );
294
 
 
295
 
        div.style.cssText = "position: absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 201px;";
296
 
 
297
 
        offset = $( div ).offset( function( _, offset ) {
298
 
                return offset;
299
 
        }).offset();
300
 
 
301
 
        testElement.innerHTML = "";
302
 
        testElementParent.removeChild( testElement );
303
 
 
304
 
        offsetTotal = offset.top + offset.left + ( body ? 2000 : 0 );
305
 
        support.fractions = offsetTotal > 21 && offsetTotal < 22;
306
 
})();
307
 
 
308
 
}( jQuery ));