kea-rails 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kea-rails/version.rb +1 -1
- data/vendor/assets/components/Keypress/LICENSE +191 -0
- data/vendor/assets/components/Keypress/README.md +78 -0
- data/vendor/assets/components/Keypress/bower.json +28 -0
- data/vendor/assets/components/Keypress/keypress-2.1.0.min.js +33 -0
- data/vendor/assets/components/Keypress/keypress.coffee +921 -0
- data/vendor/assets/components/Keypress/keypress.js +1132 -0
- data/vendor/assets/components/Keypress/package.json +15 -0
- data/vendor/assets/components/attachejs/attache-jquery.js +47 -0
- data/vendor/assets/components/attachejs/attache-knockout.js +56 -0
- data/vendor/assets/components/attachejs/attache.css +10 -0
- data/vendor/assets/components/attachejs/attache.js +589 -0
- data/vendor/assets/components/attachejs/bower.json +36 -0
- data/vendor/assets/components/humane-js/bower.json +8 -0
- data/vendor/assets/components/humane-js/changelog.md +165 -0
- data/vendor/assets/components/humane-js/humane.js +238 -0
- data/vendor/assets/components/humane-js/humane.min.js +11 -0
- data/vendor/assets/components/humane-js/index.html +190 -0
- data/vendor/assets/components/humane-js/package.json +25 -0
- data/vendor/assets/components/humane-js/readme.md +85 -0
- data/vendor/assets/components/humane-js/test/issue23.html +11 -0
- data/vendor/assets/components/humane-js/test/issue36.html +9 -0
- data/vendor/assets/components/humane-js/test/issue38.html +15 -0
- data/vendor/assets/components/humane-js/test/issue49.html +9 -0
- data/vendor/assets/components/humane-js/theme-src/bigbox.styl +65 -0
- data/vendor/assets/components/humane-js/theme-src/boldlight.styl +64 -0
- data/vendor/assets/components/humane-js/theme-src/jackedup.styl +69 -0
- data/vendor/assets/components/humane-js/theme-src/libnotify.styl +61 -0
- data/vendor/assets/components/humane-js/theme-src/original.styl +51 -0
- data/vendor/assets/components/humane-js/themes/bigbox.css +123 -0
- data/vendor/assets/components/humane-js/themes/boldlight.css +122 -0
- data/vendor/assets/components/humane-js/themes/flatty.css +94 -0
- data/vendor/assets/components/humane-js/themes/jackedup.css +123 -0
- data/vendor/assets/components/humane-js/themes/libnotify.css +115 -0
- data/vendor/assets/components/humane-js/themes/original.css +72 -0
- data/vendor/assets/components/knockout-sortable/README.md +129 -0
- data/vendor/assets/components/knockout-sortable/bower.json +15 -0
- data/vendor/assets/components/knockout-sortable/build/knockout-sortable.js +358 -0
- data/vendor/assets/components/knockout-sortable/build/knockout-sortable.min.js +2 -0
- data/vendor/assets/components/uri.js/README.md +437 -0
- data/vendor/assets/components/uri.js/URI.jquery.json +38 -0
- data/vendor/assets/components/uri.js/about-uris.html +156 -0
- data/vendor/assets/components/uri.js/build.html +66 -0
- data/vendor/assets/components/uri.js/build.js +78 -0
- data/vendor/assets/components/uri.js/component.json +15 -0
- data/vendor/assets/components/uri.js/contribute.md +11 -0
- data/vendor/assets/components/uri.js/docs.html +1280 -0
- data/vendor/assets/components/uri.js/index.html +173 -0
- data/vendor/assets/components/uri.js/jquery-1.10.2.min.js +6 -0
- data/vendor/assets/components/uri.js/jquery-1.7.2.min.js +4 -0
- data/vendor/assets/components/uri.js/jquery-1.8.2.min.js +2 -0
- data/vendor/assets/components/uri.js/jquery-1.9.1.min.js +5 -0
- data/vendor/assets/components/uri.js/jquery-uri-plugin.html +203 -0
- data/vendor/assets/components/uri.js/package.json +75 -0
- data/vendor/assets/components/uri.js/prettify/lang-apollo.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-clj.js +18 -0
- data/vendor/assets/components/uri.js/prettify/lang-css.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-go.js +1 -0
- data/vendor/assets/components/uri.js/prettify/lang-hs.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-lisp.js +3 -0
- data/vendor/assets/components/uri.js/prettify/lang-lua.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-ml.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-n.js +4 -0
- data/vendor/assets/components/uri.js/prettify/lang-proto.js +1 -0
- data/vendor/assets/components/uri.js/prettify/lang-scala.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-sql.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-tex.js +1 -0
- data/vendor/assets/components/uri.js/prettify/lang-vb.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-vhdl.js +3 -0
- data/vendor/assets/components/uri.js/prettify/lang-wiki.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-xq.js +3 -0
- data/vendor/assets/components/uri.js/prettify/lang-yaml.js +2 -0
- data/vendor/assets/components/uri.js/prettify/prettify.css +1 -0
- data/vendor/assets/components/uri.js/prettify/prettify.js +28 -0
- data/vendor/assets/components/uri.js/prettify/prettify.sunburst.css +52 -0
- data/vendor/assets/components/uri.js/screen.css +167 -0
- data/vendor/assets/components/uri.js/screen.js +39 -0
- data/vendor/assets/components/uri.js/src/IPv6.js +185 -0
- data/vendor/assets/components/uri.js/src/SecondLevelDomains.js +220 -0
- data/vendor/assets/components/uri.js/src/URI.fragmentQuery.js +103 -0
- data/vendor/assets/components/uri.js/src/URI.fragmentURI.js +96 -0
- data/vendor/assets/components/uri.js/src/URI.js +1938 -0
- data/vendor/assets/components/uri.js/src/URI.min.js +81 -0
- data/vendor/assets/components/uri.js/src/URITemplate.js +494 -0
- data/vendor/assets/components/uri.js/src/jquery.URI.js +232 -0
- data/vendor/assets/components/uri.js/src/jquery.URI.min.js +7 -0
- data/vendor/assets/components/uri.js/src/punycode.js +508 -0
- data/vendor/assets/components/uri.js/test/index.html +26 -0
- data/vendor/assets/components/uri.js/test/pre_libs.js +4 -0
- data/vendor/assets/components/uri.js/test/qunit/qunit-composite.css +13 -0
- data/vendor/assets/components/uri.js/test/qunit/qunit-composite.js +167 -0
- data/vendor/assets/components/uri.js/test/qunit/qunit.css +244 -0
- data/vendor/assets/components/uri.js/test/qunit/qunit.js +2212 -0
- data/vendor/assets/components/uri.js/test/test.URI.html +26 -0
- data/vendor/assets/components/uri.js/test/test.fragmentQuery.html +31 -0
- data/vendor/assets/components/uri.js/test/test.fragmentURI.html +31 -0
- data/vendor/assets/components/uri.js/test/test.jQuery-1.10.html +31 -0
- data/vendor/assets/components/uri.js/test/test.jQuery-1.7.html +31 -0
- data/vendor/assets/components/uri.js/test/test.jQuery-1.8.html +31 -0
- data/vendor/assets/components/uri.js/test/test.jQuery-1.9.html +31 -0
- data/vendor/assets/components/uri.js/test/test.js +1409 -0
- data/vendor/assets/components/uri.js/test/test_fragmentQuery.js +57 -0
- data/vendor/assets/components/uri.js/test/test_fragmentURI.js +59 -0
- data/vendor/assets/components/uri.js/test/test_jim.js +143 -0
- data/vendor/assets/components/uri.js/test/test_jquery.js +138 -0
- data/vendor/assets/components/uri.js/test/test_template.js +385 -0
- data/vendor/assets/components/uri.js/test/urls.js +1236 -0
- data/vendor/assets/components/uri.js/uri-template.html +234 -0
- data/vendor/assets/components/uri.js/utils/SLDs.php +37 -0
- data/vendor/assets/components/uri.js/utils/sld.js +101 -0
- data/vendor/assets/components/veiljs/bower.json +36 -0
- data/vendor/assets/components/veiljs/veil-jquery.js +47 -0
- data/vendor/assets/components/veiljs/veil-knockout.js +55 -0
- data/vendor/assets/components/veiljs/veil.js +465 -0
- data/vendor/assets/javascripts/fuse.js +472 -0
- data/vendor/assets/javascripts/jquery-ui.js +3844 -0
- data/vendor/assets/javascripts/knockout-3.2.0-debug.js +5299 -0
- data/vendor/assets/javascripts/moment.js +1902 -0
- data/vendor/assets/javascripts/pikaday.js +896 -0
- data/vendor/assets/stylesheets/pikaday.css +171 -0
- metadata +120 -1
@@ -0,0 +1,3844 @@
|
|
1
|
+
/*! jQuery UI - v1.11.2 - 2015-01-21
|
2
|
+
* http://jqueryui.com
|
3
|
+
* Includes: core.js, widget.js, mouse.js, draggable.js, droppable.js, sortable.js
|
4
|
+
* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */
|
5
|
+
|
6
|
+
(function( factory ) {
|
7
|
+
if ( typeof define === "function" && define.amd ) {
|
8
|
+
|
9
|
+
// AMD. Register as an anonymous module.
|
10
|
+
define([ "jquery" ], factory );
|
11
|
+
} else {
|
12
|
+
|
13
|
+
// Browser globals
|
14
|
+
factory( jQuery );
|
15
|
+
}
|
16
|
+
}(function( $ ) {
|
17
|
+
/*!
|
18
|
+
* jQuery UI Core 1.11.2
|
19
|
+
* http://jqueryui.com
|
20
|
+
*
|
21
|
+
* Copyright 2014 jQuery Foundation and other contributors
|
22
|
+
* Released under the MIT license.
|
23
|
+
* http://jquery.org/license
|
24
|
+
*
|
25
|
+
* http://api.jqueryui.com/category/ui-core/
|
26
|
+
*/
|
27
|
+
|
28
|
+
|
29
|
+
// $.ui might exist from components with no dependencies, e.g., $.ui.position
|
30
|
+
$.ui = $.ui || {};
|
31
|
+
|
32
|
+
$.extend( $.ui, {
|
33
|
+
version: "1.11.2",
|
34
|
+
|
35
|
+
keyCode: {
|
36
|
+
BACKSPACE: 8,
|
37
|
+
COMMA: 188,
|
38
|
+
DELETE: 46,
|
39
|
+
DOWN: 40,
|
40
|
+
END: 35,
|
41
|
+
ENTER: 13,
|
42
|
+
ESCAPE: 27,
|
43
|
+
HOME: 36,
|
44
|
+
LEFT: 37,
|
45
|
+
PAGE_DOWN: 34,
|
46
|
+
PAGE_UP: 33,
|
47
|
+
PERIOD: 190,
|
48
|
+
RIGHT: 39,
|
49
|
+
SPACE: 32,
|
50
|
+
TAB: 9,
|
51
|
+
UP: 38
|
52
|
+
}
|
53
|
+
});
|
54
|
+
|
55
|
+
// plugins
|
56
|
+
$.fn.extend({
|
57
|
+
scrollParent: function( includeHidden ) {
|
58
|
+
var position = this.css( "position" ),
|
59
|
+
excludeStaticParent = position === "absolute",
|
60
|
+
overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
|
61
|
+
scrollParent = this.parents().filter( function() {
|
62
|
+
var parent = $( this );
|
63
|
+
if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
|
64
|
+
return false;
|
65
|
+
}
|
66
|
+
return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
|
67
|
+
}).eq( 0 );
|
68
|
+
|
69
|
+
return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
|
70
|
+
},
|
71
|
+
|
72
|
+
uniqueId: (function() {
|
73
|
+
var uuid = 0;
|
74
|
+
|
75
|
+
return function() {
|
76
|
+
return this.each(function() {
|
77
|
+
if ( !this.id ) {
|
78
|
+
this.id = "ui-id-" + ( ++uuid );
|
79
|
+
}
|
80
|
+
});
|
81
|
+
};
|
82
|
+
})(),
|
83
|
+
|
84
|
+
removeUniqueId: function() {
|
85
|
+
return this.each(function() {
|
86
|
+
if ( /^ui-id-\d+$/.test( this.id ) ) {
|
87
|
+
$( this ).removeAttr( "id" );
|
88
|
+
}
|
89
|
+
});
|
90
|
+
}
|
91
|
+
});
|
92
|
+
|
93
|
+
// selectors
|
94
|
+
function focusable( element, isTabIndexNotNaN ) {
|
95
|
+
var map, mapName, img,
|
96
|
+
nodeName = element.nodeName.toLowerCase();
|
97
|
+
if ( "area" === nodeName ) {
|
98
|
+
map = element.parentNode;
|
99
|
+
mapName = map.name;
|
100
|
+
if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
|
101
|
+
return false;
|
102
|
+
}
|
103
|
+
img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
|
104
|
+
return !!img && visible( img );
|
105
|
+
}
|
106
|
+
return ( /input|select|textarea|button|object/.test( nodeName ) ?
|
107
|
+
!element.disabled :
|
108
|
+
"a" === nodeName ?
|
109
|
+
element.href || isTabIndexNotNaN :
|
110
|
+
isTabIndexNotNaN) &&
|
111
|
+
// the element and all of its ancestors must be visible
|
112
|
+
visible( element );
|
113
|
+
}
|
114
|
+
|
115
|
+
function visible( element ) {
|
116
|
+
return $.expr.filters.visible( element ) &&
|
117
|
+
!$( element ).parents().addBack().filter(function() {
|
118
|
+
return $.css( this, "visibility" ) === "hidden";
|
119
|
+
}).length;
|
120
|
+
}
|
121
|
+
|
122
|
+
$.extend( $.expr[ ":" ], {
|
123
|
+
data: $.expr.createPseudo ?
|
124
|
+
$.expr.createPseudo(function( dataName ) {
|
125
|
+
return function( elem ) {
|
126
|
+
return !!$.data( elem, dataName );
|
127
|
+
};
|
128
|
+
}) :
|
129
|
+
// support: jQuery <1.8
|
130
|
+
function( elem, i, match ) {
|
131
|
+
return !!$.data( elem, match[ 3 ] );
|
132
|
+
},
|
133
|
+
|
134
|
+
focusable: function( element ) {
|
135
|
+
return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
|
136
|
+
},
|
137
|
+
|
138
|
+
tabbable: function( element ) {
|
139
|
+
var tabIndex = $.attr( element, "tabindex" ),
|
140
|
+
isTabIndexNaN = isNaN( tabIndex );
|
141
|
+
return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
|
142
|
+
}
|
143
|
+
});
|
144
|
+
|
145
|
+
// support: jQuery <1.8
|
146
|
+
if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
|
147
|
+
$.each( [ "Width", "Height" ], function( i, name ) {
|
148
|
+
var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
|
149
|
+
type = name.toLowerCase(),
|
150
|
+
orig = {
|
151
|
+
innerWidth: $.fn.innerWidth,
|
152
|
+
innerHeight: $.fn.innerHeight,
|
153
|
+
outerWidth: $.fn.outerWidth,
|
154
|
+
outerHeight: $.fn.outerHeight
|
155
|
+
};
|
156
|
+
|
157
|
+
function reduce( elem, size, border, margin ) {
|
158
|
+
$.each( side, function() {
|
159
|
+
size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
|
160
|
+
if ( border ) {
|
161
|
+
size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
|
162
|
+
}
|
163
|
+
if ( margin ) {
|
164
|
+
size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
|
165
|
+
}
|
166
|
+
});
|
167
|
+
return size;
|
168
|
+
}
|
169
|
+
|
170
|
+
$.fn[ "inner" + name ] = function( size ) {
|
171
|
+
if ( size === undefined ) {
|
172
|
+
return orig[ "inner" + name ].call( this );
|
173
|
+
}
|
174
|
+
|
175
|
+
return this.each(function() {
|
176
|
+
$( this ).css( type, reduce( this, size ) + "px" );
|
177
|
+
});
|
178
|
+
};
|
179
|
+
|
180
|
+
$.fn[ "outer" + name] = function( size, margin ) {
|
181
|
+
if ( typeof size !== "number" ) {
|
182
|
+
return orig[ "outer" + name ].call( this, size );
|
183
|
+
}
|
184
|
+
|
185
|
+
return this.each(function() {
|
186
|
+
$( this).css( type, reduce( this, size, true, margin ) + "px" );
|
187
|
+
});
|
188
|
+
};
|
189
|
+
});
|
190
|
+
}
|
191
|
+
|
192
|
+
// support: jQuery <1.8
|
193
|
+
if ( !$.fn.addBack ) {
|
194
|
+
$.fn.addBack = function( selector ) {
|
195
|
+
return this.add( selector == null ?
|
196
|
+
this.prevObject : this.prevObject.filter( selector )
|
197
|
+
);
|
198
|
+
};
|
199
|
+
}
|
200
|
+
|
201
|
+
// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
|
202
|
+
if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
|
203
|
+
$.fn.removeData = (function( removeData ) {
|
204
|
+
return function( key ) {
|
205
|
+
if ( arguments.length ) {
|
206
|
+
return removeData.call( this, $.camelCase( key ) );
|
207
|
+
} else {
|
208
|
+
return removeData.call( this );
|
209
|
+
}
|
210
|
+
};
|
211
|
+
})( $.fn.removeData );
|
212
|
+
}
|
213
|
+
|
214
|
+
// deprecated
|
215
|
+
$.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
|
216
|
+
|
217
|
+
$.fn.extend({
|
218
|
+
focus: (function( orig ) {
|
219
|
+
return function( delay, fn ) {
|
220
|
+
return typeof delay === "number" ?
|
221
|
+
this.each(function() {
|
222
|
+
var elem = this;
|
223
|
+
setTimeout(function() {
|
224
|
+
$( elem ).focus();
|
225
|
+
if ( fn ) {
|
226
|
+
fn.call( elem );
|
227
|
+
}
|
228
|
+
}, delay );
|
229
|
+
}) :
|
230
|
+
orig.apply( this, arguments );
|
231
|
+
};
|
232
|
+
})( $.fn.focus ),
|
233
|
+
|
234
|
+
disableSelection: (function() {
|
235
|
+
var eventType = "onselectstart" in document.createElement( "div" ) ?
|
236
|
+
"selectstart" :
|
237
|
+
"mousedown";
|
238
|
+
|
239
|
+
return function() {
|
240
|
+
return this.bind( eventType + ".ui-disableSelection", function( event ) {
|
241
|
+
event.preventDefault();
|
242
|
+
});
|
243
|
+
};
|
244
|
+
})(),
|
245
|
+
|
246
|
+
enableSelection: function() {
|
247
|
+
return this.unbind( ".ui-disableSelection" );
|
248
|
+
},
|
249
|
+
|
250
|
+
zIndex: function( zIndex ) {
|
251
|
+
if ( zIndex !== undefined ) {
|
252
|
+
return this.css( "zIndex", zIndex );
|
253
|
+
}
|
254
|
+
|
255
|
+
if ( this.length ) {
|
256
|
+
var elem = $( this[ 0 ] ), position, value;
|
257
|
+
while ( elem.length && elem[ 0 ] !== document ) {
|
258
|
+
// Ignore z-index if position is set to a value where z-index is ignored by the browser
|
259
|
+
// This makes behavior of this function consistent across browsers
|
260
|
+
// WebKit always returns auto if the element is positioned
|
261
|
+
position = elem.css( "position" );
|
262
|
+
if ( position === "absolute" || position === "relative" || position === "fixed" ) {
|
263
|
+
// IE returns 0 when zIndex is not specified
|
264
|
+
// other browsers return a string
|
265
|
+
// we ignore the case of nested elements with an explicit value of 0
|
266
|
+
// <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
|
267
|
+
value = parseInt( elem.css( "zIndex" ), 10 );
|
268
|
+
if ( !isNaN( value ) && value !== 0 ) {
|
269
|
+
return value;
|
270
|
+
}
|
271
|
+
}
|
272
|
+
elem = elem.parent();
|
273
|
+
}
|
274
|
+
}
|
275
|
+
|
276
|
+
return 0;
|
277
|
+
}
|
278
|
+
});
|
279
|
+
|
280
|
+
// $.ui.plugin is deprecated. Use $.widget() extensions instead.
|
281
|
+
$.ui.plugin = {
|
282
|
+
add: function( module, option, set ) {
|
283
|
+
var i,
|
284
|
+
proto = $.ui[ module ].prototype;
|
285
|
+
for ( i in set ) {
|
286
|
+
proto.plugins[ i ] = proto.plugins[ i ] || [];
|
287
|
+
proto.plugins[ i ].push( [ option, set[ i ] ] );
|
288
|
+
}
|
289
|
+
},
|
290
|
+
call: function( instance, name, args, allowDisconnected ) {
|
291
|
+
var i,
|
292
|
+
set = instance.plugins[ name ];
|
293
|
+
|
294
|
+
if ( !set ) {
|
295
|
+
return;
|
296
|
+
}
|
297
|
+
|
298
|
+
if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
|
299
|
+
return;
|
300
|
+
}
|
301
|
+
|
302
|
+
for ( i = 0; i < set.length; i++ ) {
|
303
|
+
if ( instance.options[ set[ i ][ 0 ] ] ) {
|
304
|
+
set[ i ][ 1 ].apply( instance.element, args );
|
305
|
+
}
|
306
|
+
}
|
307
|
+
}
|
308
|
+
};
|
309
|
+
|
310
|
+
|
311
|
+
/*!
|
312
|
+
* jQuery UI Widget 1.11.2
|
313
|
+
* http://jqueryui.com
|
314
|
+
*
|
315
|
+
* Copyright 2014 jQuery Foundation and other contributors
|
316
|
+
* Released under the MIT license.
|
317
|
+
* http://jquery.org/license
|
318
|
+
*
|
319
|
+
* http://api.jqueryui.com/jQuery.widget/
|
320
|
+
*/
|
321
|
+
|
322
|
+
|
323
|
+
var widget_uuid = 0,
|
324
|
+
widget_slice = Array.prototype.slice;
|
325
|
+
|
326
|
+
$.cleanData = (function( orig ) {
|
327
|
+
return function( elems ) {
|
328
|
+
var events, elem, i;
|
329
|
+
for ( i = 0; (elem = elems[i]) != null; i++ ) {
|
330
|
+
try {
|
331
|
+
|
332
|
+
// Only trigger remove when necessary to save time
|
333
|
+
events = $._data( elem, "events" );
|
334
|
+
if ( events && events.remove ) {
|
335
|
+
$( elem ).triggerHandler( "remove" );
|
336
|
+
}
|
337
|
+
|
338
|
+
// http://bugs.jquery.com/ticket/8235
|
339
|
+
} catch ( e ) {}
|
340
|
+
}
|
341
|
+
orig( elems );
|
342
|
+
};
|
343
|
+
})( $.cleanData );
|
344
|
+
|
345
|
+
$.widget = function( name, base, prototype ) {
|
346
|
+
var fullName, existingConstructor, constructor, basePrototype,
|
347
|
+
// proxiedPrototype allows the provided prototype to remain unmodified
|
348
|
+
// so that it can be used as a mixin for multiple widgets (#8876)
|
349
|
+
proxiedPrototype = {},
|
350
|
+
namespace = name.split( "." )[ 0 ];
|
351
|
+
|
352
|
+
name = name.split( "." )[ 1 ];
|
353
|
+
fullName = namespace + "-" + name;
|
354
|
+
|
355
|
+
if ( !prototype ) {
|
356
|
+
prototype = base;
|
357
|
+
base = $.Widget;
|
358
|
+
}
|
359
|
+
|
360
|
+
// create selector for plugin
|
361
|
+
$.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
|
362
|
+
return !!$.data( elem, fullName );
|
363
|
+
};
|
364
|
+
|
365
|
+
$[ namespace ] = $[ namespace ] || {};
|
366
|
+
existingConstructor = $[ namespace ][ name ];
|
367
|
+
constructor = $[ namespace ][ name ] = function( options, element ) {
|
368
|
+
// allow instantiation without "new" keyword
|
369
|
+
if ( !this._createWidget ) {
|
370
|
+
return new constructor( options, element );
|
371
|
+
}
|
372
|
+
|
373
|
+
// allow instantiation without initializing for simple inheritance
|
374
|
+
// must use "new" keyword (the code above always passes args)
|
375
|
+
if ( arguments.length ) {
|
376
|
+
this._createWidget( options, element );
|
377
|
+
}
|
378
|
+
};
|
379
|
+
// extend with the existing constructor to carry over any static properties
|
380
|
+
$.extend( constructor, existingConstructor, {
|
381
|
+
version: prototype.version,
|
382
|
+
// copy the object used to create the prototype in case we need to
|
383
|
+
// redefine the widget later
|
384
|
+
_proto: $.extend( {}, prototype ),
|
385
|
+
// track widgets that inherit from this widget in case this widget is
|
386
|
+
// redefined after a widget inherits from it
|
387
|
+
_childConstructors: []
|
388
|
+
});
|
389
|
+
|
390
|
+
basePrototype = new base();
|
391
|
+
// we need to make the options hash a property directly on the new instance
|
392
|
+
// otherwise we'll modify the options hash on the prototype that we're
|
393
|
+
// inheriting from
|
394
|
+
basePrototype.options = $.widget.extend( {}, basePrototype.options );
|
395
|
+
$.each( prototype, function( prop, value ) {
|
396
|
+
if ( !$.isFunction( value ) ) {
|
397
|
+
proxiedPrototype[ prop ] = value;
|
398
|
+
return;
|
399
|
+
}
|
400
|
+
proxiedPrototype[ prop ] = (function() {
|
401
|
+
var _super = function() {
|
402
|
+
return base.prototype[ prop ].apply( this, arguments );
|
403
|
+
},
|
404
|
+
_superApply = function( args ) {
|
405
|
+
return base.prototype[ prop ].apply( this, args );
|
406
|
+
};
|
407
|
+
return function() {
|
408
|
+
var __super = this._super,
|
409
|
+
__superApply = this._superApply,
|
410
|
+
returnValue;
|
411
|
+
|
412
|
+
this._super = _super;
|
413
|
+
this._superApply = _superApply;
|
414
|
+
|
415
|
+
returnValue = value.apply( this, arguments );
|
416
|
+
|
417
|
+
this._super = __super;
|
418
|
+
this._superApply = __superApply;
|
419
|
+
|
420
|
+
return returnValue;
|
421
|
+
};
|
422
|
+
})();
|
423
|
+
});
|
424
|
+
constructor.prototype = $.widget.extend( basePrototype, {
|
425
|
+
// TODO: remove support for widgetEventPrefix
|
426
|
+
// always use the name + a colon as the prefix, e.g., draggable:start
|
427
|
+
// don't prefix for widgets that aren't DOM-based
|
428
|
+
widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
|
429
|
+
}, proxiedPrototype, {
|
430
|
+
constructor: constructor,
|
431
|
+
namespace: namespace,
|
432
|
+
widgetName: name,
|
433
|
+
widgetFullName: fullName
|
434
|
+
});
|
435
|
+
|
436
|
+
// If this widget is being redefined then we need to find all widgets that
|
437
|
+
// are inheriting from it and redefine all of them so that they inherit from
|
438
|
+
// the new version of this widget. We're essentially trying to replace one
|
439
|
+
// level in the prototype chain.
|
440
|
+
if ( existingConstructor ) {
|
441
|
+
$.each( existingConstructor._childConstructors, function( i, child ) {
|
442
|
+
var childPrototype = child.prototype;
|
443
|
+
|
444
|
+
// redefine the child widget using the same prototype that was
|
445
|
+
// originally used, but inherit from the new version of the base
|
446
|
+
$.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
|
447
|
+
});
|
448
|
+
// remove the list of existing child constructors from the old constructor
|
449
|
+
// so the old child constructors can be garbage collected
|
450
|
+
delete existingConstructor._childConstructors;
|
451
|
+
} else {
|
452
|
+
base._childConstructors.push( constructor );
|
453
|
+
}
|
454
|
+
|
455
|
+
$.widget.bridge( name, constructor );
|
456
|
+
|
457
|
+
return constructor;
|
458
|
+
};
|
459
|
+
|
460
|
+
$.widget.extend = function( target ) {
|
461
|
+
var input = widget_slice.call( arguments, 1 ),
|
462
|
+
inputIndex = 0,
|
463
|
+
inputLength = input.length,
|
464
|
+
key,
|
465
|
+
value;
|
466
|
+
for ( ; inputIndex < inputLength; inputIndex++ ) {
|
467
|
+
for ( key in input[ inputIndex ] ) {
|
468
|
+
value = input[ inputIndex ][ key ];
|
469
|
+
if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
|
470
|
+
// Clone objects
|
471
|
+
if ( $.isPlainObject( value ) ) {
|
472
|
+
target[ key ] = $.isPlainObject( target[ key ] ) ?
|
473
|
+
$.widget.extend( {}, target[ key ], value ) :
|
474
|
+
// Don't extend strings, arrays, etc. with objects
|
475
|
+
$.widget.extend( {}, value );
|
476
|
+
// Copy everything else by reference
|
477
|
+
} else {
|
478
|
+
target[ key ] = value;
|
479
|
+
}
|
480
|
+
}
|
481
|
+
}
|
482
|
+
}
|
483
|
+
return target;
|
484
|
+
};
|
485
|
+
|
486
|
+
$.widget.bridge = function( name, object ) {
|
487
|
+
var fullName = object.prototype.widgetFullName || name;
|
488
|
+
$.fn[ name ] = function( options ) {
|
489
|
+
var isMethodCall = typeof options === "string",
|
490
|
+
args = widget_slice.call( arguments, 1 ),
|
491
|
+
returnValue = this;
|
492
|
+
|
493
|
+
// allow multiple hashes to be passed on init
|
494
|
+
options = !isMethodCall && args.length ?
|
495
|
+
$.widget.extend.apply( null, [ options ].concat(args) ) :
|
496
|
+
options;
|
497
|
+
|
498
|
+
if ( isMethodCall ) {
|
499
|
+
this.each(function() {
|
500
|
+
var methodValue,
|
501
|
+
instance = $.data( this, fullName );
|
502
|
+
if ( options === "instance" ) {
|
503
|
+
returnValue = instance;
|
504
|
+
return false;
|
505
|
+
}
|
506
|
+
if ( !instance ) {
|
507
|
+
return $.error( "cannot call methods on " + name + " prior to initialization; " +
|
508
|
+
"attempted to call method '" + options + "'" );
|
509
|
+
}
|
510
|
+
if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
|
511
|
+
return $.error( "no such method '" + options + "' for " + name + " widget instance" );
|
512
|
+
}
|
513
|
+
methodValue = instance[ options ].apply( instance, args );
|
514
|
+
if ( methodValue !== instance && methodValue !== undefined ) {
|
515
|
+
returnValue = methodValue && methodValue.jquery ?
|
516
|
+
returnValue.pushStack( methodValue.get() ) :
|
517
|
+
methodValue;
|
518
|
+
return false;
|
519
|
+
}
|
520
|
+
});
|
521
|
+
} else {
|
522
|
+
this.each(function() {
|
523
|
+
var instance = $.data( this, fullName );
|
524
|
+
if ( instance ) {
|
525
|
+
instance.option( options || {} );
|
526
|
+
if ( instance._init ) {
|
527
|
+
instance._init();
|
528
|
+
}
|
529
|
+
} else {
|
530
|
+
$.data( this, fullName, new object( options, this ) );
|
531
|
+
}
|
532
|
+
});
|
533
|
+
}
|
534
|
+
|
535
|
+
return returnValue;
|
536
|
+
};
|
537
|
+
};
|
538
|
+
|
539
|
+
$.Widget = function( /* options, element */ ) {};
|
540
|
+
$.Widget._childConstructors = [];
|
541
|
+
|
542
|
+
$.Widget.prototype = {
|
543
|
+
widgetName: "widget",
|
544
|
+
widgetEventPrefix: "",
|
545
|
+
defaultElement: "<div>",
|
546
|
+
options: {
|
547
|
+
disabled: false,
|
548
|
+
|
549
|
+
// callbacks
|
550
|
+
create: null
|
551
|
+
},
|
552
|
+
_createWidget: function( options, element ) {
|
553
|
+
element = $( element || this.defaultElement || this )[ 0 ];
|
554
|
+
this.element = $( element );
|
555
|
+
this.uuid = widget_uuid++;
|
556
|
+
this.eventNamespace = "." + this.widgetName + this.uuid;
|
557
|
+
|
558
|
+
this.bindings = $();
|
559
|
+
this.hoverable = $();
|
560
|
+
this.focusable = $();
|
561
|
+
|
562
|
+
if ( element !== this ) {
|
563
|
+
$.data( element, this.widgetFullName, this );
|
564
|
+
this._on( true, this.element, {
|
565
|
+
remove: function( event ) {
|
566
|
+
if ( event.target === element ) {
|
567
|
+
this.destroy();
|
568
|
+
}
|
569
|
+
}
|
570
|
+
});
|
571
|
+
this.document = $( element.style ?
|
572
|
+
// element within the document
|
573
|
+
element.ownerDocument :
|
574
|
+
// element is window or document
|
575
|
+
element.document || element );
|
576
|
+
this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
|
577
|
+
}
|
578
|
+
|
579
|
+
this.options = $.widget.extend( {},
|
580
|
+
this.options,
|
581
|
+
this._getCreateOptions(),
|
582
|
+
options );
|
583
|
+
|
584
|
+
this._create();
|
585
|
+
this._trigger( "create", null, this._getCreateEventData() );
|
586
|
+
this._init();
|
587
|
+
},
|
588
|
+
_getCreateOptions: $.noop,
|
589
|
+
_getCreateEventData: $.noop,
|
590
|
+
_create: $.noop,
|
591
|
+
_init: $.noop,
|
592
|
+
|
593
|
+
destroy: function() {
|
594
|
+
this._destroy();
|
595
|
+
// we can probably remove the unbind calls in 2.0
|
596
|
+
// all event bindings should go through this._on()
|
597
|
+
this.element
|
598
|
+
.unbind( this.eventNamespace )
|
599
|
+
.removeData( this.widgetFullName )
|
600
|
+
// support: jquery <1.6.3
|
601
|
+
// http://bugs.jquery.com/ticket/9413
|
602
|
+
.removeData( $.camelCase( this.widgetFullName ) );
|
603
|
+
this.widget()
|
604
|
+
.unbind( this.eventNamespace )
|
605
|
+
.removeAttr( "aria-disabled" )
|
606
|
+
.removeClass(
|
607
|
+
this.widgetFullName + "-disabled " +
|
608
|
+
"ui-state-disabled" );
|
609
|
+
|
610
|
+
// clean up events and states
|
611
|
+
this.bindings.unbind( this.eventNamespace );
|
612
|
+
this.hoverable.removeClass( "ui-state-hover" );
|
613
|
+
this.focusable.removeClass( "ui-state-focus" );
|
614
|
+
},
|
615
|
+
_destroy: $.noop,
|
616
|
+
|
617
|
+
widget: function() {
|
618
|
+
return this.element;
|
619
|
+
},
|
620
|
+
|
621
|
+
option: function( key, value ) {
|
622
|
+
var options = key,
|
623
|
+
parts,
|
624
|
+
curOption,
|
625
|
+
i;
|
626
|
+
|
627
|
+
if ( arguments.length === 0 ) {
|
628
|
+
// don't return a reference to the internal hash
|
629
|
+
return $.widget.extend( {}, this.options );
|
630
|
+
}
|
631
|
+
|
632
|
+
if ( typeof key === "string" ) {
|
633
|
+
// handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
|
634
|
+
options = {};
|
635
|
+
parts = key.split( "." );
|
636
|
+
key = parts.shift();
|
637
|
+
if ( parts.length ) {
|
638
|
+
curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
|
639
|
+
for ( i = 0; i < parts.length - 1; i++ ) {
|
640
|
+
curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
|
641
|
+
curOption = curOption[ parts[ i ] ];
|
642
|
+
}
|
643
|
+
key = parts.pop();
|
644
|
+
if ( arguments.length === 1 ) {
|
645
|
+
return curOption[ key ] === undefined ? null : curOption[ key ];
|
646
|
+
}
|
647
|
+
curOption[ key ] = value;
|
648
|
+
} else {
|
649
|
+
if ( arguments.length === 1 ) {
|
650
|
+
return this.options[ key ] === undefined ? null : this.options[ key ];
|
651
|
+
}
|
652
|
+
options[ key ] = value;
|
653
|
+
}
|
654
|
+
}
|
655
|
+
|
656
|
+
this._setOptions( options );
|
657
|
+
|
658
|
+
return this;
|
659
|
+
},
|
660
|
+
_setOptions: function( options ) {
|
661
|
+
var key;
|
662
|
+
|
663
|
+
for ( key in options ) {
|
664
|
+
this._setOption( key, options[ key ] );
|
665
|
+
}
|
666
|
+
|
667
|
+
return this;
|
668
|
+
},
|
669
|
+
_setOption: function( key, value ) {
|
670
|
+
this.options[ key ] = value;
|
671
|
+
|
672
|
+
if ( key === "disabled" ) {
|
673
|
+
this.widget()
|
674
|
+
.toggleClass( this.widgetFullName + "-disabled", !!value );
|
675
|
+
|
676
|
+
// If the widget is becoming disabled, then nothing is interactive
|
677
|
+
if ( value ) {
|
678
|
+
this.hoverable.removeClass( "ui-state-hover" );
|
679
|
+
this.focusable.removeClass( "ui-state-focus" );
|
680
|
+
}
|
681
|
+
}
|
682
|
+
|
683
|
+
return this;
|
684
|
+
},
|
685
|
+
|
686
|
+
enable: function() {
|
687
|
+
return this._setOptions({ disabled: false });
|
688
|
+
},
|
689
|
+
disable: function() {
|
690
|
+
return this._setOptions({ disabled: true });
|
691
|
+
},
|
692
|
+
|
693
|
+
_on: function( suppressDisabledCheck, element, handlers ) {
|
694
|
+
var delegateElement,
|
695
|
+
instance = this;
|
696
|
+
|
697
|
+
// no suppressDisabledCheck flag, shuffle arguments
|
698
|
+
if ( typeof suppressDisabledCheck !== "boolean" ) {
|
699
|
+
handlers = element;
|
700
|
+
element = suppressDisabledCheck;
|
701
|
+
suppressDisabledCheck = false;
|
702
|
+
}
|
703
|
+
|
704
|
+
// no element argument, shuffle and use this.element
|
705
|
+
if ( !handlers ) {
|
706
|
+
handlers = element;
|
707
|
+
element = this.element;
|
708
|
+
delegateElement = this.widget();
|
709
|
+
} else {
|
710
|
+
element = delegateElement = $( element );
|
711
|
+
this.bindings = this.bindings.add( element );
|
712
|
+
}
|
713
|
+
|
714
|
+
$.each( handlers, function( event, handler ) {
|
715
|
+
function handlerProxy() {
|
716
|
+
// allow widgets to customize the disabled handling
|
717
|
+
// - disabled as an array instead of boolean
|
718
|
+
// - disabled class as method for disabling individual parts
|
719
|
+
if ( !suppressDisabledCheck &&
|
720
|
+
( instance.options.disabled === true ||
|
721
|
+
$( this ).hasClass( "ui-state-disabled" ) ) ) {
|
722
|
+
return;
|
723
|
+
}
|
724
|
+
return ( typeof handler === "string" ? instance[ handler ] : handler )
|
725
|
+
.apply( instance, arguments );
|
726
|
+
}
|
727
|
+
|
728
|
+
// copy the guid so direct unbinding works
|
729
|
+
if ( typeof handler !== "string" ) {
|
730
|
+
handlerProxy.guid = handler.guid =
|
731
|
+
handler.guid || handlerProxy.guid || $.guid++;
|
732
|
+
}
|
733
|
+
|
734
|
+
var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
|
735
|
+
eventName = match[1] + instance.eventNamespace,
|
736
|
+
selector = match[2];
|
737
|
+
if ( selector ) {
|
738
|
+
delegateElement.delegate( selector, eventName, handlerProxy );
|
739
|
+
} else {
|
740
|
+
element.bind( eventName, handlerProxy );
|
741
|
+
}
|
742
|
+
});
|
743
|
+
},
|
744
|
+
|
745
|
+
_off: function( element, eventName ) {
|
746
|
+
eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) +
|
747
|
+
this.eventNamespace;
|
748
|
+
element.unbind( eventName ).undelegate( eventName );
|
749
|
+
|
750
|
+
// Clear the stack to avoid memory leaks (#10056)
|
751
|
+
this.bindings = $( this.bindings.not( element ).get() );
|
752
|
+
this.focusable = $( this.focusable.not( element ).get() );
|
753
|
+
this.hoverable = $( this.hoverable.not( element ).get() );
|
754
|
+
},
|
755
|
+
|
756
|
+
_delay: function( handler, delay ) {
|
757
|
+
function handlerProxy() {
|
758
|
+
return ( typeof handler === "string" ? instance[ handler ] : handler )
|
759
|
+
.apply( instance, arguments );
|
760
|
+
}
|
761
|
+
var instance = this;
|
762
|
+
return setTimeout( handlerProxy, delay || 0 );
|
763
|
+
},
|
764
|
+
|
765
|
+
_hoverable: function( element ) {
|
766
|
+
this.hoverable = this.hoverable.add( element );
|
767
|
+
this._on( element, {
|
768
|
+
mouseenter: function( event ) {
|
769
|
+
$( event.currentTarget ).addClass( "ui-state-hover" );
|
770
|
+
},
|
771
|
+
mouseleave: function( event ) {
|
772
|
+
$( event.currentTarget ).removeClass( "ui-state-hover" );
|
773
|
+
}
|
774
|
+
});
|
775
|
+
},
|
776
|
+
|
777
|
+
_focusable: function( element ) {
|
778
|
+
this.focusable = this.focusable.add( element );
|
779
|
+
this._on( element, {
|
780
|
+
focusin: function( event ) {
|
781
|
+
$( event.currentTarget ).addClass( "ui-state-focus" );
|
782
|
+
},
|
783
|
+
focusout: function( event ) {
|
784
|
+
$( event.currentTarget ).removeClass( "ui-state-focus" );
|
785
|
+
}
|
786
|
+
});
|
787
|
+
},
|
788
|
+
|
789
|
+
_trigger: function( type, event, data ) {
|
790
|
+
var prop, orig,
|
791
|
+
callback = this.options[ type ];
|
792
|
+
|
793
|
+
data = data || {};
|
794
|
+
event = $.Event( event );
|
795
|
+
event.type = ( type === this.widgetEventPrefix ?
|
796
|
+
type :
|
797
|
+
this.widgetEventPrefix + type ).toLowerCase();
|
798
|
+
// the original event may come from any element
|
799
|
+
// so we need to reset the target on the new event
|
800
|
+
event.target = this.element[ 0 ];
|
801
|
+
|
802
|
+
// copy original event properties over to the new event
|
803
|
+
orig = event.originalEvent;
|
804
|
+
if ( orig ) {
|
805
|
+
for ( prop in orig ) {
|
806
|
+
if ( !( prop in event ) ) {
|
807
|
+
event[ prop ] = orig[ prop ];
|
808
|
+
}
|
809
|
+
}
|
810
|
+
}
|
811
|
+
|
812
|
+
this.element.trigger( event, data );
|
813
|
+
return !( $.isFunction( callback ) &&
|
814
|
+
callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
|
815
|
+
event.isDefaultPrevented() );
|
816
|
+
}
|
817
|
+
};
|
818
|
+
|
819
|
+
$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
|
820
|
+
$.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
|
821
|
+
if ( typeof options === "string" ) {
|
822
|
+
options = { effect: options };
|
823
|
+
}
|
824
|
+
var hasOptions,
|
825
|
+
effectName = !options ?
|
826
|
+
method :
|
827
|
+
options === true || typeof options === "number" ?
|
828
|
+
defaultEffect :
|
829
|
+
options.effect || defaultEffect;
|
830
|
+
options = options || {};
|
831
|
+
if ( typeof options === "number" ) {
|
832
|
+
options = { duration: options };
|
833
|
+
}
|
834
|
+
hasOptions = !$.isEmptyObject( options );
|
835
|
+
options.complete = callback;
|
836
|
+
if ( options.delay ) {
|
837
|
+
element.delay( options.delay );
|
838
|
+
}
|
839
|
+
if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
|
840
|
+
element[ method ]( options );
|
841
|
+
} else if ( effectName !== method && element[ effectName ] ) {
|
842
|
+
element[ effectName ]( options.duration, options.easing, callback );
|
843
|
+
} else {
|
844
|
+
element.queue(function( next ) {
|
845
|
+
$( this )[ method ]();
|
846
|
+
if ( callback ) {
|
847
|
+
callback.call( element[ 0 ] );
|
848
|
+
}
|
849
|
+
next();
|
850
|
+
});
|
851
|
+
}
|
852
|
+
};
|
853
|
+
});
|
854
|
+
|
855
|
+
var widget = $.widget;
|
856
|
+
|
857
|
+
|
858
|
+
/*!
|
859
|
+
* jQuery UI Mouse 1.11.2
|
860
|
+
* http://jqueryui.com
|
861
|
+
*
|
862
|
+
* Copyright 2014 jQuery Foundation and other contributors
|
863
|
+
* Released under the MIT license.
|
864
|
+
* http://jquery.org/license
|
865
|
+
*
|
866
|
+
* http://api.jqueryui.com/mouse/
|
867
|
+
*/
|
868
|
+
|
869
|
+
|
870
|
+
var mouseHandled = false;
|
871
|
+
$( document ).mouseup( function() {
|
872
|
+
mouseHandled = false;
|
873
|
+
});
|
874
|
+
|
875
|
+
var mouse = $.widget("ui.mouse", {
|
876
|
+
version: "1.11.2",
|
877
|
+
options: {
|
878
|
+
cancel: "input,textarea,button,select,option",
|
879
|
+
distance: 1,
|
880
|
+
delay: 0
|
881
|
+
},
|
882
|
+
_mouseInit: function() {
|
883
|
+
var that = this;
|
884
|
+
|
885
|
+
this.element
|
886
|
+
.bind("mousedown." + this.widgetName, function(event) {
|
887
|
+
return that._mouseDown(event);
|
888
|
+
})
|
889
|
+
.bind("click." + this.widgetName, function(event) {
|
890
|
+
if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
|
891
|
+
$.removeData(event.target, that.widgetName + ".preventClickEvent");
|
892
|
+
event.stopImmediatePropagation();
|
893
|
+
return false;
|
894
|
+
}
|
895
|
+
});
|
896
|
+
|
897
|
+
this.started = false;
|
898
|
+
},
|
899
|
+
|
900
|
+
// TODO: make sure destroying one instance of mouse doesn't mess with
|
901
|
+
// other instances of mouse
|
902
|
+
_mouseDestroy: function() {
|
903
|
+
this.element.unbind("." + this.widgetName);
|
904
|
+
if ( this._mouseMoveDelegate ) {
|
905
|
+
this.document
|
906
|
+
.unbind("mousemove." + this.widgetName, this._mouseMoveDelegate)
|
907
|
+
.unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
|
908
|
+
}
|
909
|
+
},
|
910
|
+
|
911
|
+
_mouseDown: function(event) {
|
912
|
+
// don't let more than one widget handle mouseStart
|
913
|
+
if ( mouseHandled ) {
|
914
|
+
return;
|
915
|
+
}
|
916
|
+
|
917
|
+
this._mouseMoved = false;
|
918
|
+
|
919
|
+
// we may have missed mouseup (out of window)
|
920
|
+
(this._mouseStarted && this._mouseUp(event));
|
921
|
+
|
922
|
+
this._mouseDownEvent = event;
|
923
|
+
|
924
|
+
var that = this,
|
925
|
+
btnIsLeft = (event.which === 1),
|
926
|
+
// event.target.nodeName works around a bug in IE 8 with
|
927
|
+
// disabled inputs (#7620)
|
928
|
+
elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
|
929
|
+
if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
|
930
|
+
return true;
|
931
|
+
}
|
932
|
+
|
933
|
+
this.mouseDelayMet = !this.options.delay;
|
934
|
+
if (!this.mouseDelayMet) {
|
935
|
+
this._mouseDelayTimer = setTimeout(function() {
|
936
|
+
that.mouseDelayMet = true;
|
937
|
+
}, this.options.delay);
|
938
|
+
}
|
939
|
+
|
940
|
+
if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
|
941
|
+
this._mouseStarted = (this._mouseStart(event) !== false);
|
942
|
+
if (!this._mouseStarted) {
|
943
|
+
event.preventDefault();
|
944
|
+
return true;
|
945
|
+
}
|
946
|
+
}
|
947
|
+
|
948
|
+
// Click event may never have fired (Gecko & Opera)
|
949
|
+
if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
|
950
|
+
$.removeData(event.target, this.widgetName + ".preventClickEvent");
|
951
|
+
}
|
952
|
+
|
953
|
+
// these delegates are required to keep context
|
954
|
+
this._mouseMoveDelegate = function(event) {
|
955
|
+
return that._mouseMove(event);
|
956
|
+
};
|
957
|
+
this._mouseUpDelegate = function(event) {
|
958
|
+
return that._mouseUp(event);
|
959
|
+
};
|
960
|
+
|
961
|
+
this.document
|
962
|
+
.bind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
|
963
|
+
.bind( "mouseup." + this.widgetName, this._mouseUpDelegate );
|
964
|
+
|
965
|
+
event.preventDefault();
|
966
|
+
|
967
|
+
mouseHandled = true;
|
968
|
+
return true;
|
969
|
+
},
|
970
|
+
|
971
|
+
_mouseMove: function(event) {
|
972
|
+
// Only check for mouseups outside the document if you've moved inside the document
|
973
|
+
// at least once. This prevents the firing of mouseup in the case of IE<9, which will
|
974
|
+
// fire a mousemove event if content is placed under the cursor. See #7778
|
975
|
+
// Support: IE <9
|
976
|
+
if ( this._mouseMoved ) {
|
977
|
+
// IE mouseup check - mouseup happened when mouse was out of window
|
978
|
+
if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
|
979
|
+
return this._mouseUp(event);
|
980
|
+
|
981
|
+
// Iframe mouseup check - mouseup occurred in another document
|
982
|
+
} else if ( !event.which ) {
|
983
|
+
return this._mouseUp( event );
|
984
|
+
}
|
985
|
+
}
|
986
|
+
|
987
|
+
if ( event.which || event.button ) {
|
988
|
+
this._mouseMoved = true;
|
989
|
+
}
|
990
|
+
|
991
|
+
if (this._mouseStarted) {
|
992
|
+
this._mouseDrag(event);
|
993
|
+
return event.preventDefault();
|
994
|
+
}
|
995
|
+
|
996
|
+
if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
|
997
|
+
this._mouseStarted =
|
998
|
+
(this._mouseStart(this._mouseDownEvent, event) !== false);
|
999
|
+
(this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
|
1000
|
+
}
|
1001
|
+
|
1002
|
+
return !this._mouseStarted;
|
1003
|
+
},
|
1004
|
+
|
1005
|
+
_mouseUp: function(event) {
|
1006
|
+
this.document
|
1007
|
+
.unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
|
1008
|
+
.unbind( "mouseup." + this.widgetName, this._mouseUpDelegate );
|
1009
|
+
|
1010
|
+
if (this._mouseStarted) {
|
1011
|
+
this._mouseStarted = false;
|
1012
|
+
|
1013
|
+
if (event.target === this._mouseDownEvent.target) {
|
1014
|
+
$.data(event.target, this.widgetName + ".preventClickEvent", true);
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
this._mouseStop(event);
|
1018
|
+
}
|
1019
|
+
|
1020
|
+
mouseHandled = false;
|
1021
|
+
return false;
|
1022
|
+
},
|
1023
|
+
|
1024
|
+
_mouseDistanceMet: function(event) {
|
1025
|
+
return (Math.max(
|
1026
|
+
Math.abs(this._mouseDownEvent.pageX - event.pageX),
|
1027
|
+
Math.abs(this._mouseDownEvent.pageY - event.pageY)
|
1028
|
+
) >= this.options.distance
|
1029
|
+
);
|
1030
|
+
},
|
1031
|
+
|
1032
|
+
_mouseDelayMet: function(/* event */) {
|
1033
|
+
return this.mouseDelayMet;
|
1034
|
+
},
|
1035
|
+
|
1036
|
+
// These are placeholder methods, to be overriden by extending plugin
|
1037
|
+
_mouseStart: function(/* event */) {},
|
1038
|
+
_mouseDrag: function(/* event */) {},
|
1039
|
+
_mouseStop: function(/* event */) {},
|
1040
|
+
_mouseCapture: function(/* event */) { return true; }
|
1041
|
+
});
|
1042
|
+
|
1043
|
+
|
1044
|
+
/*!
|
1045
|
+
* jQuery UI Draggable 1.11.2
|
1046
|
+
* http://jqueryui.com
|
1047
|
+
*
|
1048
|
+
* Copyright 2014 jQuery Foundation and other contributors
|
1049
|
+
* Released under the MIT license.
|
1050
|
+
* http://jquery.org/license
|
1051
|
+
*
|
1052
|
+
* http://api.jqueryui.com/draggable/
|
1053
|
+
*/
|
1054
|
+
|
1055
|
+
|
1056
|
+
$.widget("ui.draggable", $.ui.mouse, {
|
1057
|
+
version: "1.11.2",
|
1058
|
+
widgetEventPrefix: "drag",
|
1059
|
+
options: {
|
1060
|
+
addClasses: true,
|
1061
|
+
appendTo: "parent",
|
1062
|
+
axis: false,
|
1063
|
+
connectToSortable: false,
|
1064
|
+
containment: false,
|
1065
|
+
cursor: "auto",
|
1066
|
+
cursorAt: false,
|
1067
|
+
grid: false,
|
1068
|
+
handle: false,
|
1069
|
+
helper: "original",
|
1070
|
+
iframeFix: false,
|
1071
|
+
opacity: false,
|
1072
|
+
refreshPositions: false,
|
1073
|
+
revert: false,
|
1074
|
+
revertDuration: 500,
|
1075
|
+
scope: "default",
|
1076
|
+
scroll: true,
|
1077
|
+
scrollSensitivity: 20,
|
1078
|
+
scrollSpeed: 20,
|
1079
|
+
snap: false,
|
1080
|
+
snapMode: "both",
|
1081
|
+
snapTolerance: 20,
|
1082
|
+
stack: false,
|
1083
|
+
zIndex: false,
|
1084
|
+
|
1085
|
+
// callbacks
|
1086
|
+
drag: null,
|
1087
|
+
start: null,
|
1088
|
+
stop: null
|
1089
|
+
},
|
1090
|
+
_create: function() {
|
1091
|
+
|
1092
|
+
if ( this.options.helper === "original" ) {
|
1093
|
+
this._setPositionRelative();
|
1094
|
+
}
|
1095
|
+
if (this.options.addClasses){
|
1096
|
+
this.element.addClass("ui-draggable");
|
1097
|
+
}
|
1098
|
+
if (this.options.disabled){
|
1099
|
+
this.element.addClass("ui-draggable-disabled");
|
1100
|
+
}
|
1101
|
+
this._setHandleClassName();
|
1102
|
+
|
1103
|
+
this._mouseInit();
|
1104
|
+
},
|
1105
|
+
|
1106
|
+
_setOption: function( key, value ) {
|
1107
|
+
this._super( key, value );
|
1108
|
+
if ( key === "handle" ) {
|
1109
|
+
this._removeHandleClassName();
|
1110
|
+
this._setHandleClassName();
|
1111
|
+
}
|
1112
|
+
},
|
1113
|
+
|
1114
|
+
_destroy: function() {
|
1115
|
+
if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
|
1116
|
+
this.destroyOnClear = true;
|
1117
|
+
return;
|
1118
|
+
}
|
1119
|
+
this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
|
1120
|
+
this._removeHandleClassName();
|
1121
|
+
this._mouseDestroy();
|
1122
|
+
},
|
1123
|
+
|
1124
|
+
_mouseCapture: function(event) {
|
1125
|
+
var o = this.options;
|
1126
|
+
|
1127
|
+
this._blurActiveElement( event );
|
1128
|
+
|
1129
|
+
// among others, prevent a drag on a resizable-handle
|
1130
|
+
if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
|
1131
|
+
return false;
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
//Quit if we're not on a valid handle
|
1135
|
+
this.handle = this._getHandle(event);
|
1136
|
+
if (!this.handle) {
|
1137
|
+
return false;
|
1138
|
+
}
|
1139
|
+
|
1140
|
+
this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
|
1141
|
+
|
1142
|
+
return true;
|
1143
|
+
|
1144
|
+
},
|
1145
|
+
|
1146
|
+
_blockFrames: function( selector ) {
|
1147
|
+
this.iframeBlocks = this.document.find( selector ).map(function() {
|
1148
|
+
var iframe = $( this );
|
1149
|
+
|
1150
|
+
return $( "<div>" )
|
1151
|
+
.css( "position", "absolute" )
|
1152
|
+
.appendTo( iframe.parent() )
|
1153
|
+
.outerWidth( iframe.outerWidth() )
|
1154
|
+
.outerHeight( iframe.outerHeight() )
|
1155
|
+
.offset( iframe.offset() )[ 0 ];
|
1156
|
+
});
|
1157
|
+
},
|
1158
|
+
|
1159
|
+
_unblockFrames: function() {
|
1160
|
+
if ( this.iframeBlocks ) {
|
1161
|
+
this.iframeBlocks.remove();
|
1162
|
+
delete this.iframeBlocks;
|
1163
|
+
}
|
1164
|
+
},
|
1165
|
+
|
1166
|
+
_blurActiveElement: function( event ) {
|
1167
|
+
var document = this.document[ 0 ];
|
1168
|
+
|
1169
|
+
// Only need to blur if the event occurred on the draggable itself, see #10527
|
1170
|
+
if ( !this.handleElement.is( event.target ) ) {
|
1171
|
+
return;
|
1172
|
+
}
|
1173
|
+
|
1174
|
+
// support: IE9
|
1175
|
+
// IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
|
1176
|
+
try {
|
1177
|
+
|
1178
|
+
// Support: IE9, IE10
|
1179
|
+
// If the <body> is blurred, IE will switch windows, see #9520
|
1180
|
+
if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
|
1181
|
+
|
1182
|
+
// Blur any element that currently has focus, see #4261
|
1183
|
+
$( document.activeElement ).blur();
|
1184
|
+
}
|
1185
|
+
} catch ( error ) {}
|
1186
|
+
},
|
1187
|
+
|
1188
|
+
_mouseStart: function(event) {
|
1189
|
+
|
1190
|
+
var o = this.options;
|
1191
|
+
|
1192
|
+
//Create and append the visible helper
|
1193
|
+
this.helper = this._createHelper(event);
|
1194
|
+
|
1195
|
+
this.helper.addClass("ui-draggable-dragging");
|
1196
|
+
|
1197
|
+
//Cache the helper size
|
1198
|
+
this._cacheHelperProportions();
|
1199
|
+
|
1200
|
+
//If ddmanager is used for droppables, set the global draggable
|
1201
|
+
if ($.ui.ddmanager) {
|
1202
|
+
$.ui.ddmanager.current = this;
|
1203
|
+
}
|
1204
|
+
|
1205
|
+
/*
|
1206
|
+
* - Position generation -
|
1207
|
+
* This block generates everything position related - it's the core of draggables.
|
1208
|
+
*/
|
1209
|
+
|
1210
|
+
//Cache the margins of the original element
|
1211
|
+
this._cacheMargins();
|
1212
|
+
|
1213
|
+
//Store the helper's css position
|
1214
|
+
this.cssPosition = this.helper.css( "position" );
|
1215
|
+
this.scrollParent = this.helper.scrollParent( true );
|
1216
|
+
this.offsetParent = this.helper.offsetParent();
|
1217
|
+
this.hasFixedAncestor = this.helper.parents().filter(function() {
|
1218
|
+
return $( this ).css( "position" ) === "fixed";
|
1219
|
+
}).length > 0;
|
1220
|
+
|
1221
|
+
//The element's absolute position on the page minus margins
|
1222
|
+
this.positionAbs = this.element.offset();
|
1223
|
+
this._refreshOffsets( event );
|
1224
|
+
|
1225
|
+
//Generate the original position
|
1226
|
+
this.originalPosition = this.position = this._generatePosition( event, false );
|
1227
|
+
this.originalPageX = event.pageX;
|
1228
|
+
this.originalPageY = event.pageY;
|
1229
|
+
|
1230
|
+
//Adjust the mouse offset relative to the helper if "cursorAt" is supplied
|
1231
|
+
(o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
|
1232
|
+
|
1233
|
+
//Set a containment if given in the options
|
1234
|
+
this._setContainment();
|
1235
|
+
|
1236
|
+
//Trigger event + callbacks
|
1237
|
+
if (this._trigger("start", event) === false) {
|
1238
|
+
this._clear();
|
1239
|
+
return false;
|
1240
|
+
}
|
1241
|
+
|
1242
|
+
//Recache the helper size
|
1243
|
+
this._cacheHelperProportions();
|
1244
|
+
|
1245
|
+
//Prepare the droppable offsets
|
1246
|
+
if ($.ui.ddmanager && !o.dropBehaviour) {
|
1247
|
+
$.ui.ddmanager.prepareOffsets(this, event);
|
1248
|
+
}
|
1249
|
+
|
1250
|
+
// Reset helper's right/bottom css if they're set and set explicit width/height instead
|
1251
|
+
// as this prevents resizing of elements with right/bottom set (see #7772)
|
1252
|
+
this._normalizeRightBottom();
|
1253
|
+
|
1254
|
+
this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
|
1255
|
+
|
1256
|
+
//If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
|
1257
|
+
if ( $.ui.ddmanager ) {
|
1258
|
+
$.ui.ddmanager.dragStart(this, event);
|
1259
|
+
}
|
1260
|
+
|
1261
|
+
return true;
|
1262
|
+
},
|
1263
|
+
|
1264
|
+
_refreshOffsets: function( event ) {
|
1265
|
+
this.offset = {
|
1266
|
+
top: this.positionAbs.top - this.margins.top,
|
1267
|
+
left: this.positionAbs.left - this.margins.left,
|
1268
|
+
scroll: false,
|
1269
|
+
parent: this._getParentOffset(),
|
1270
|
+
relative: this._getRelativeOffset()
|
1271
|
+
};
|
1272
|
+
|
1273
|
+
this.offset.click = {
|
1274
|
+
left: event.pageX - this.offset.left,
|
1275
|
+
top: event.pageY - this.offset.top
|
1276
|
+
};
|
1277
|
+
},
|
1278
|
+
|
1279
|
+
_mouseDrag: function(event, noPropagation) {
|
1280
|
+
// reset any necessary cached properties (see #5009)
|
1281
|
+
if ( this.hasFixedAncestor ) {
|
1282
|
+
this.offset.parent = this._getParentOffset();
|
1283
|
+
}
|
1284
|
+
|
1285
|
+
//Compute the helpers position
|
1286
|
+
this.position = this._generatePosition( event, true );
|
1287
|
+
this.positionAbs = this._convertPositionTo("absolute");
|
1288
|
+
|
1289
|
+
//Call plugins and callbacks and use the resulting position if something is returned
|
1290
|
+
if (!noPropagation) {
|
1291
|
+
var ui = this._uiHash();
|
1292
|
+
if (this._trigger("drag", event, ui) === false) {
|
1293
|
+
this._mouseUp({});
|
1294
|
+
return false;
|
1295
|
+
}
|
1296
|
+
this.position = ui.position;
|
1297
|
+
}
|
1298
|
+
|
1299
|
+
this.helper[ 0 ].style.left = this.position.left + "px";
|
1300
|
+
this.helper[ 0 ].style.top = this.position.top + "px";
|
1301
|
+
|
1302
|
+
if ($.ui.ddmanager) {
|
1303
|
+
$.ui.ddmanager.drag(this, event);
|
1304
|
+
}
|
1305
|
+
|
1306
|
+
return false;
|
1307
|
+
},
|
1308
|
+
|
1309
|
+
_mouseStop: function(event) {
|
1310
|
+
|
1311
|
+
//If we are using droppables, inform the manager about the drop
|
1312
|
+
var that = this,
|
1313
|
+
dropped = false;
|
1314
|
+
if ($.ui.ddmanager && !this.options.dropBehaviour) {
|
1315
|
+
dropped = $.ui.ddmanager.drop(this, event);
|
1316
|
+
}
|
1317
|
+
|
1318
|
+
//if a drop comes from outside (a sortable)
|
1319
|
+
if (this.dropped) {
|
1320
|
+
dropped = this.dropped;
|
1321
|
+
this.dropped = false;
|
1322
|
+
}
|
1323
|
+
|
1324
|
+
if ((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
|
1325
|
+
$(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
|
1326
|
+
if (that._trigger("stop", event) !== false) {
|
1327
|
+
that._clear();
|
1328
|
+
}
|
1329
|
+
});
|
1330
|
+
} else {
|
1331
|
+
if (this._trigger("stop", event) !== false) {
|
1332
|
+
this._clear();
|
1333
|
+
}
|
1334
|
+
}
|
1335
|
+
|
1336
|
+
return false;
|
1337
|
+
},
|
1338
|
+
|
1339
|
+
_mouseUp: function( event ) {
|
1340
|
+
this._unblockFrames();
|
1341
|
+
|
1342
|
+
//If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
|
1343
|
+
if ( $.ui.ddmanager ) {
|
1344
|
+
$.ui.ddmanager.dragStop(this, event);
|
1345
|
+
}
|
1346
|
+
|
1347
|
+
// Only need to focus if the event occurred on the draggable itself, see #10527
|
1348
|
+
if ( this.handleElement.is( event.target ) ) {
|
1349
|
+
// The interaction is over; whether or not the click resulted in a drag, focus the element
|
1350
|
+
this.element.focus();
|
1351
|
+
}
|
1352
|
+
|
1353
|
+
return $.ui.mouse.prototype._mouseUp.call(this, event);
|
1354
|
+
},
|
1355
|
+
|
1356
|
+
cancel: function() {
|
1357
|
+
|
1358
|
+
if (this.helper.is(".ui-draggable-dragging")) {
|
1359
|
+
this._mouseUp({});
|
1360
|
+
} else {
|
1361
|
+
this._clear();
|
1362
|
+
}
|
1363
|
+
|
1364
|
+
return this;
|
1365
|
+
|
1366
|
+
},
|
1367
|
+
|
1368
|
+
_getHandle: function(event) {
|
1369
|
+
return this.options.handle ?
|
1370
|
+
!!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
|
1371
|
+
true;
|
1372
|
+
},
|
1373
|
+
|
1374
|
+
_setHandleClassName: function() {
|
1375
|
+
this.handleElement = this.options.handle ?
|
1376
|
+
this.element.find( this.options.handle ) : this.element;
|
1377
|
+
this.handleElement.addClass( "ui-draggable-handle" );
|
1378
|
+
},
|
1379
|
+
|
1380
|
+
_removeHandleClassName: function() {
|
1381
|
+
this.handleElement.removeClass( "ui-draggable-handle" );
|
1382
|
+
},
|
1383
|
+
|
1384
|
+
_createHelper: function(event) {
|
1385
|
+
|
1386
|
+
var o = this.options,
|
1387
|
+
helperIsFunction = $.isFunction( o.helper ),
|
1388
|
+
helper = helperIsFunction ?
|
1389
|
+
$( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
|
1390
|
+
( o.helper === "clone" ?
|
1391
|
+
this.element.clone().removeAttr( "id" ) :
|
1392
|
+
this.element );
|
1393
|
+
|
1394
|
+
if (!helper.parents("body").length) {
|
1395
|
+
helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
|
1396
|
+
}
|
1397
|
+
|
1398
|
+
// http://bugs.jqueryui.com/ticket/9446
|
1399
|
+
// a helper function can return the original element
|
1400
|
+
// which wouldn't have been set to relative in _create
|
1401
|
+
if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
|
1402
|
+
this._setPositionRelative();
|
1403
|
+
}
|
1404
|
+
|
1405
|
+
if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
|
1406
|
+
helper.css("position", "absolute");
|
1407
|
+
}
|
1408
|
+
|
1409
|
+
return helper;
|
1410
|
+
|
1411
|
+
},
|
1412
|
+
|
1413
|
+
_setPositionRelative: function() {
|
1414
|
+
if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
|
1415
|
+
this.element[ 0 ].style.position = "relative";
|
1416
|
+
}
|
1417
|
+
},
|
1418
|
+
|
1419
|
+
_adjustOffsetFromHelper: function(obj) {
|
1420
|
+
if (typeof obj === "string") {
|
1421
|
+
obj = obj.split(" ");
|
1422
|
+
}
|
1423
|
+
if ($.isArray(obj)) {
|
1424
|
+
obj = { left: +obj[0], top: +obj[1] || 0 };
|
1425
|
+
}
|
1426
|
+
if ("left" in obj) {
|
1427
|
+
this.offset.click.left = obj.left + this.margins.left;
|
1428
|
+
}
|
1429
|
+
if ("right" in obj) {
|
1430
|
+
this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
|
1431
|
+
}
|
1432
|
+
if ("top" in obj) {
|
1433
|
+
this.offset.click.top = obj.top + this.margins.top;
|
1434
|
+
}
|
1435
|
+
if ("bottom" in obj) {
|
1436
|
+
this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
|
1437
|
+
}
|
1438
|
+
},
|
1439
|
+
|
1440
|
+
_isRootNode: function( element ) {
|
1441
|
+
return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
|
1442
|
+
},
|
1443
|
+
|
1444
|
+
_getParentOffset: function() {
|
1445
|
+
|
1446
|
+
//Get the offsetParent and cache its position
|
1447
|
+
var po = this.offsetParent.offset(),
|
1448
|
+
document = this.document[ 0 ];
|
1449
|
+
|
1450
|
+
// This is a special case where we need to modify a offset calculated on start, since the following happened:
|
1451
|
+
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
|
1452
|
+
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
|
1453
|
+
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
|
1454
|
+
if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
|
1455
|
+
po.left += this.scrollParent.scrollLeft();
|
1456
|
+
po.top += this.scrollParent.scrollTop();
|
1457
|
+
}
|
1458
|
+
|
1459
|
+
if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
|
1460
|
+
po = { top: 0, left: 0 };
|
1461
|
+
}
|
1462
|
+
|
1463
|
+
return {
|
1464
|
+
top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
|
1465
|
+
left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
|
1466
|
+
};
|
1467
|
+
|
1468
|
+
},
|
1469
|
+
|
1470
|
+
_getRelativeOffset: function() {
|
1471
|
+
if ( this.cssPosition !== "relative" ) {
|
1472
|
+
return { top: 0, left: 0 };
|
1473
|
+
}
|
1474
|
+
|
1475
|
+
var p = this.element.position(),
|
1476
|
+
scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
|
1477
|
+
|
1478
|
+
return {
|
1479
|
+
top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
|
1480
|
+
left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
|
1481
|
+
};
|
1482
|
+
|
1483
|
+
},
|
1484
|
+
|
1485
|
+
_cacheMargins: function() {
|
1486
|
+
this.margins = {
|
1487
|
+
left: (parseInt(this.element.css("marginLeft"), 10) || 0),
|
1488
|
+
top: (parseInt(this.element.css("marginTop"), 10) || 0),
|
1489
|
+
right: (parseInt(this.element.css("marginRight"), 10) || 0),
|
1490
|
+
bottom: (parseInt(this.element.css("marginBottom"), 10) || 0)
|
1491
|
+
};
|
1492
|
+
},
|
1493
|
+
|
1494
|
+
_cacheHelperProportions: function() {
|
1495
|
+
this.helperProportions = {
|
1496
|
+
width: this.helper.outerWidth(),
|
1497
|
+
height: this.helper.outerHeight()
|
1498
|
+
};
|
1499
|
+
},
|
1500
|
+
|
1501
|
+
_setContainment: function() {
|
1502
|
+
|
1503
|
+
var isUserScrollable, c, ce,
|
1504
|
+
o = this.options,
|
1505
|
+
document = this.document[ 0 ];
|
1506
|
+
|
1507
|
+
this.relativeContainer = null;
|
1508
|
+
|
1509
|
+
if ( !o.containment ) {
|
1510
|
+
this.containment = null;
|
1511
|
+
return;
|
1512
|
+
}
|
1513
|
+
|
1514
|
+
if ( o.containment === "window" ) {
|
1515
|
+
this.containment = [
|
1516
|
+
$( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
|
1517
|
+
$( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
|
1518
|
+
$( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
|
1519
|
+
$( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
|
1520
|
+
];
|
1521
|
+
return;
|
1522
|
+
}
|
1523
|
+
|
1524
|
+
if ( o.containment === "document") {
|
1525
|
+
this.containment = [
|
1526
|
+
0,
|
1527
|
+
0,
|
1528
|
+
$( document ).width() - this.helperProportions.width - this.margins.left,
|
1529
|
+
( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
|
1530
|
+
];
|
1531
|
+
return;
|
1532
|
+
}
|
1533
|
+
|
1534
|
+
if ( o.containment.constructor === Array ) {
|
1535
|
+
this.containment = o.containment;
|
1536
|
+
return;
|
1537
|
+
}
|
1538
|
+
|
1539
|
+
if ( o.containment === "parent" ) {
|
1540
|
+
o.containment = this.helper[ 0 ].parentNode;
|
1541
|
+
}
|
1542
|
+
|
1543
|
+
c = $( o.containment );
|
1544
|
+
ce = c[ 0 ];
|
1545
|
+
|
1546
|
+
if ( !ce ) {
|
1547
|
+
return;
|
1548
|
+
}
|
1549
|
+
|
1550
|
+
isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
|
1551
|
+
|
1552
|
+
this.containment = [
|
1553
|
+
( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
|
1554
|
+
( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
|
1555
|
+
( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
|
1556
|
+
( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
|
1557
|
+
( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
|
1558
|
+
this.helperProportions.width -
|
1559
|
+
this.margins.left -
|
1560
|
+
this.margins.right,
|
1561
|
+
( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
|
1562
|
+
( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
|
1563
|
+
( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
|
1564
|
+
this.helperProportions.height -
|
1565
|
+
this.margins.top -
|
1566
|
+
this.margins.bottom
|
1567
|
+
];
|
1568
|
+
this.relativeContainer = c;
|
1569
|
+
},
|
1570
|
+
|
1571
|
+
_convertPositionTo: function(d, pos) {
|
1572
|
+
|
1573
|
+
if (!pos) {
|
1574
|
+
pos = this.position;
|
1575
|
+
}
|
1576
|
+
|
1577
|
+
var mod = d === "absolute" ? 1 : -1,
|
1578
|
+
scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
|
1579
|
+
|
1580
|
+
return {
|
1581
|
+
top: (
|
1582
|
+
pos.top + // The absolute mouse position
|
1583
|
+
this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
|
1584
|
+
this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
|
1585
|
+
( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
|
1586
|
+
),
|
1587
|
+
left: (
|
1588
|
+
pos.left + // The absolute mouse position
|
1589
|
+
this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
|
1590
|
+
this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
|
1591
|
+
( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod)
|
1592
|
+
)
|
1593
|
+
};
|
1594
|
+
|
1595
|
+
},
|
1596
|
+
|
1597
|
+
_generatePosition: function( event, constrainPosition ) {
|
1598
|
+
|
1599
|
+
var containment, co, top, left,
|
1600
|
+
o = this.options,
|
1601
|
+
scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
|
1602
|
+
pageX = event.pageX,
|
1603
|
+
pageY = event.pageY;
|
1604
|
+
|
1605
|
+
// Cache the scroll
|
1606
|
+
if ( !scrollIsRootNode || !this.offset.scroll ) {
|
1607
|
+
this.offset.scroll = {
|
1608
|
+
top: this.scrollParent.scrollTop(),
|
1609
|
+
left: this.scrollParent.scrollLeft()
|
1610
|
+
};
|
1611
|
+
}
|
1612
|
+
|
1613
|
+
/*
|
1614
|
+
* - Position constraining -
|
1615
|
+
* Constrain the position to a mix of grid, containment.
|
1616
|
+
*/
|
1617
|
+
|
1618
|
+
// If we are not dragging yet, we won't check for options
|
1619
|
+
if ( constrainPosition ) {
|
1620
|
+
if ( this.containment ) {
|
1621
|
+
if ( this.relativeContainer ){
|
1622
|
+
co = this.relativeContainer.offset();
|
1623
|
+
containment = [
|
1624
|
+
this.containment[ 0 ] + co.left,
|
1625
|
+
this.containment[ 1 ] + co.top,
|
1626
|
+
this.containment[ 2 ] + co.left,
|
1627
|
+
this.containment[ 3 ] + co.top
|
1628
|
+
];
|
1629
|
+
} else {
|
1630
|
+
containment = this.containment;
|
1631
|
+
}
|
1632
|
+
|
1633
|
+
if (event.pageX - this.offset.click.left < containment[0]) {
|
1634
|
+
pageX = containment[0] + this.offset.click.left;
|
1635
|
+
}
|
1636
|
+
if (event.pageY - this.offset.click.top < containment[1]) {
|
1637
|
+
pageY = containment[1] + this.offset.click.top;
|
1638
|
+
}
|
1639
|
+
if (event.pageX - this.offset.click.left > containment[2]) {
|
1640
|
+
pageX = containment[2] + this.offset.click.left;
|
1641
|
+
}
|
1642
|
+
if (event.pageY - this.offset.click.top > containment[3]) {
|
1643
|
+
pageY = containment[3] + this.offset.click.top;
|
1644
|
+
}
|
1645
|
+
}
|
1646
|
+
|
1647
|
+
if (o.grid) {
|
1648
|
+
//Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
|
1649
|
+
top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
|
1650
|
+
pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
|
1651
|
+
|
1652
|
+
left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
|
1653
|
+
pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
|
1654
|
+
}
|
1655
|
+
|
1656
|
+
if ( o.axis === "y" ) {
|
1657
|
+
pageX = this.originalPageX;
|
1658
|
+
}
|
1659
|
+
|
1660
|
+
if ( o.axis === "x" ) {
|
1661
|
+
pageY = this.originalPageY;
|
1662
|
+
}
|
1663
|
+
}
|
1664
|
+
|
1665
|
+
return {
|
1666
|
+
top: (
|
1667
|
+
pageY - // The absolute mouse position
|
1668
|
+
this.offset.click.top - // Click offset (relative to the element)
|
1669
|
+
this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
|
1670
|
+
this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
|
1671
|
+
( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
|
1672
|
+
),
|
1673
|
+
left: (
|
1674
|
+
pageX - // The absolute mouse position
|
1675
|
+
this.offset.click.left - // Click offset (relative to the element)
|
1676
|
+
this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
|
1677
|
+
this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
|
1678
|
+
( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
|
1679
|
+
)
|
1680
|
+
};
|
1681
|
+
|
1682
|
+
},
|
1683
|
+
|
1684
|
+
_clear: function() {
|
1685
|
+
this.helper.removeClass("ui-draggable-dragging");
|
1686
|
+
if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
|
1687
|
+
this.helper.remove();
|
1688
|
+
}
|
1689
|
+
this.helper = null;
|
1690
|
+
this.cancelHelperRemoval = false;
|
1691
|
+
if ( this.destroyOnClear ) {
|
1692
|
+
this.destroy();
|
1693
|
+
}
|
1694
|
+
},
|
1695
|
+
|
1696
|
+
_normalizeRightBottom: function() {
|
1697
|
+
if ( this.options.axis !== "y" && this.helper.css( "right" ) !== "auto" ) {
|
1698
|
+
this.helper.width( this.helper.width() );
|
1699
|
+
this.helper.css( "right", "auto" );
|
1700
|
+
}
|
1701
|
+
if ( this.options.axis !== "x" && this.helper.css( "bottom" ) !== "auto" ) {
|
1702
|
+
this.helper.height( this.helper.height() );
|
1703
|
+
this.helper.css( "bottom", "auto" );
|
1704
|
+
}
|
1705
|
+
},
|
1706
|
+
|
1707
|
+
// From now on bulk stuff - mainly helpers
|
1708
|
+
|
1709
|
+
_trigger: function( type, event, ui ) {
|
1710
|
+
ui = ui || this._uiHash();
|
1711
|
+
$.ui.plugin.call( this, type, [ event, ui, this ], true );
|
1712
|
+
|
1713
|
+
// Absolute position and offset (see #6884 ) have to be recalculated after plugins
|
1714
|
+
if ( /^(drag|start|stop)/.test( type ) ) {
|
1715
|
+
this.positionAbs = this._convertPositionTo( "absolute" );
|
1716
|
+
ui.offset = this.positionAbs;
|
1717
|
+
}
|
1718
|
+
return $.Widget.prototype._trigger.call( this, type, event, ui );
|
1719
|
+
},
|
1720
|
+
|
1721
|
+
plugins: {},
|
1722
|
+
|
1723
|
+
_uiHash: function() {
|
1724
|
+
return {
|
1725
|
+
helper: this.helper,
|
1726
|
+
position: this.position,
|
1727
|
+
originalPosition: this.originalPosition,
|
1728
|
+
offset: this.positionAbs
|
1729
|
+
};
|
1730
|
+
}
|
1731
|
+
|
1732
|
+
});
|
1733
|
+
|
1734
|
+
$.ui.plugin.add( "draggable", "connectToSortable", {
|
1735
|
+
start: function( event, ui, draggable ) {
|
1736
|
+
var uiSortable = $.extend( {}, ui, {
|
1737
|
+
item: draggable.element
|
1738
|
+
});
|
1739
|
+
|
1740
|
+
draggable.sortables = [];
|
1741
|
+
$( draggable.options.connectToSortable ).each(function() {
|
1742
|
+
var sortable = $( this ).sortable( "instance" );
|
1743
|
+
|
1744
|
+
if ( sortable && !sortable.options.disabled ) {
|
1745
|
+
draggable.sortables.push( sortable );
|
1746
|
+
|
1747
|
+
// refreshPositions is called at drag start to refresh the containerCache
|
1748
|
+
// which is used in drag. This ensures it's initialized and synchronized
|
1749
|
+
// with any changes that might have happened on the page since initialization.
|
1750
|
+
sortable.refreshPositions();
|
1751
|
+
sortable._trigger("activate", event, uiSortable);
|
1752
|
+
}
|
1753
|
+
});
|
1754
|
+
},
|
1755
|
+
stop: function( event, ui, draggable ) {
|
1756
|
+
var uiSortable = $.extend( {}, ui, {
|
1757
|
+
item: draggable.element
|
1758
|
+
});
|
1759
|
+
|
1760
|
+
draggable.cancelHelperRemoval = false;
|
1761
|
+
|
1762
|
+
$.each( draggable.sortables, function() {
|
1763
|
+
var sortable = this;
|
1764
|
+
|
1765
|
+
if ( sortable.isOver ) {
|
1766
|
+
sortable.isOver = 0;
|
1767
|
+
|
1768
|
+
// Allow this sortable to handle removing the helper
|
1769
|
+
draggable.cancelHelperRemoval = true;
|
1770
|
+
sortable.cancelHelperRemoval = false;
|
1771
|
+
|
1772
|
+
// Use _storedCSS To restore properties in the sortable,
|
1773
|
+
// as this also handles revert (#9675) since the draggable
|
1774
|
+
// may have modified them in unexpected ways (#8809)
|
1775
|
+
sortable._storedCSS = {
|
1776
|
+
position: sortable.placeholder.css( "position" ),
|
1777
|
+
top: sortable.placeholder.css( "top" ),
|
1778
|
+
left: sortable.placeholder.css( "left" )
|
1779
|
+
};
|
1780
|
+
|
1781
|
+
sortable._mouseStop(event);
|
1782
|
+
|
1783
|
+
// Once drag has ended, the sortable should return to using
|
1784
|
+
// its original helper, not the shared helper from draggable
|
1785
|
+
sortable.options.helper = sortable.options._helper;
|
1786
|
+
} else {
|
1787
|
+
// Prevent this Sortable from removing the helper.
|
1788
|
+
// However, don't set the draggable to remove the helper
|
1789
|
+
// either as another connected Sortable may yet handle the removal.
|
1790
|
+
sortable.cancelHelperRemoval = true;
|
1791
|
+
|
1792
|
+
sortable._trigger( "deactivate", event, uiSortable );
|
1793
|
+
}
|
1794
|
+
});
|
1795
|
+
},
|
1796
|
+
drag: function( event, ui, draggable ) {
|
1797
|
+
$.each( draggable.sortables, function() {
|
1798
|
+
var innermostIntersecting = false,
|
1799
|
+
sortable = this;
|
1800
|
+
|
1801
|
+
// Copy over variables that sortable's _intersectsWith uses
|
1802
|
+
sortable.positionAbs = draggable.positionAbs;
|
1803
|
+
sortable.helperProportions = draggable.helperProportions;
|
1804
|
+
sortable.offset.click = draggable.offset.click;
|
1805
|
+
|
1806
|
+
if ( sortable._intersectsWith( sortable.containerCache ) ) {
|
1807
|
+
innermostIntersecting = true;
|
1808
|
+
|
1809
|
+
$.each( draggable.sortables, function() {
|
1810
|
+
// Copy over variables that sortable's _intersectsWith uses
|
1811
|
+
this.positionAbs = draggable.positionAbs;
|
1812
|
+
this.helperProportions = draggable.helperProportions;
|
1813
|
+
this.offset.click = draggable.offset.click;
|
1814
|
+
|
1815
|
+
if ( this !== sortable &&
|
1816
|
+
this._intersectsWith( this.containerCache ) &&
|
1817
|
+
$.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
|
1818
|
+
innermostIntersecting = false;
|
1819
|
+
}
|
1820
|
+
|
1821
|
+
return innermostIntersecting;
|
1822
|
+
});
|
1823
|
+
}
|
1824
|
+
|
1825
|
+
if ( innermostIntersecting ) {
|
1826
|
+
// If it intersects, we use a little isOver variable and set it once,
|
1827
|
+
// so that the move-in stuff gets fired only once.
|
1828
|
+
if ( !sortable.isOver ) {
|
1829
|
+
sortable.isOver = 1;
|
1830
|
+
|
1831
|
+
sortable.currentItem = ui.helper
|
1832
|
+
.appendTo( sortable.element )
|
1833
|
+
.data( "ui-sortable-item", true );
|
1834
|
+
|
1835
|
+
// Store helper option to later restore it
|
1836
|
+
sortable.options._helper = sortable.options.helper;
|
1837
|
+
|
1838
|
+
sortable.options.helper = function() {
|
1839
|
+
return ui.helper[ 0 ];
|
1840
|
+
};
|
1841
|
+
|
1842
|
+
// Fire the start events of the sortable with our passed browser event,
|
1843
|
+
// and our own helper (so it doesn't create a new one)
|
1844
|
+
event.target = sortable.currentItem[ 0 ];
|
1845
|
+
sortable._mouseCapture( event, true );
|
1846
|
+
sortable._mouseStart( event, true, true );
|
1847
|
+
|
1848
|
+
// Because the browser event is way off the new appended portlet,
|
1849
|
+
// modify necessary variables to reflect the changes
|
1850
|
+
sortable.offset.click.top = draggable.offset.click.top;
|
1851
|
+
sortable.offset.click.left = draggable.offset.click.left;
|
1852
|
+
sortable.offset.parent.left -= draggable.offset.parent.left -
|
1853
|
+
sortable.offset.parent.left;
|
1854
|
+
sortable.offset.parent.top -= draggable.offset.parent.top -
|
1855
|
+
sortable.offset.parent.top;
|
1856
|
+
|
1857
|
+
draggable._trigger( "toSortable", event );
|
1858
|
+
|
1859
|
+
// Inform draggable that the helper is in a valid drop zone,
|
1860
|
+
// used solely in the revert option to handle "valid/invalid".
|
1861
|
+
draggable.dropped = sortable.element;
|
1862
|
+
|
1863
|
+
// Need to refreshPositions of all sortables in the case that
|
1864
|
+
// adding to one sortable changes the location of the other sortables (#9675)
|
1865
|
+
$.each( draggable.sortables, function() {
|
1866
|
+
this.refreshPositions();
|
1867
|
+
});
|
1868
|
+
|
1869
|
+
// hack so receive/update callbacks work (mostly)
|
1870
|
+
draggable.currentItem = draggable.element;
|
1871
|
+
sortable.fromOutside = draggable;
|
1872
|
+
}
|
1873
|
+
|
1874
|
+
if ( sortable.currentItem ) {
|
1875
|
+
sortable._mouseDrag( event );
|
1876
|
+
// Copy the sortable's position because the draggable's can potentially reflect
|
1877
|
+
// a relative position, while sortable is always absolute, which the dragged
|
1878
|
+
// element has now become. (#8809)
|
1879
|
+
ui.position = sortable.position;
|
1880
|
+
}
|
1881
|
+
} else {
|
1882
|
+
// If it doesn't intersect with the sortable, and it intersected before,
|
1883
|
+
// we fake the drag stop of the sortable, but make sure it doesn't remove
|
1884
|
+
// the helper by using cancelHelperRemoval.
|
1885
|
+
if ( sortable.isOver ) {
|
1886
|
+
|
1887
|
+
sortable.isOver = 0;
|
1888
|
+
sortable.cancelHelperRemoval = true;
|
1889
|
+
|
1890
|
+
// Calling sortable's mouseStop would trigger a revert,
|
1891
|
+
// so revert must be temporarily false until after mouseStop is called.
|
1892
|
+
sortable.options._revert = sortable.options.revert;
|
1893
|
+
sortable.options.revert = false;
|
1894
|
+
|
1895
|
+
sortable._trigger( "out", event, sortable._uiHash( sortable ) );
|
1896
|
+
sortable._mouseStop( event, true );
|
1897
|
+
|
1898
|
+
// restore sortable behaviors that were modfied
|
1899
|
+
// when the draggable entered the sortable area (#9481)
|
1900
|
+
sortable.options.revert = sortable.options._revert;
|
1901
|
+
sortable.options.helper = sortable.options._helper;
|
1902
|
+
|
1903
|
+
if ( sortable.placeholder ) {
|
1904
|
+
sortable.placeholder.remove();
|
1905
|
+
}
|
1906
|
+
|
1907
|
+
// Recalculate the draggable's offset considering the sortable
|
1908
|
+
// may have modified them in unexpected ways (#8809)
|
1909
|
+
draggable._refreshOffsets( event );
|
1910
|
+
ui.position = draggable._generatePosition( event, true );
|
1911
|
+
|
1912
|
+
draggable._trigger( "fromSortable", event );
|
1913
|
+
|
1914
|
+
// Inform draggable that the helper is no longer in a valid drop zone
|
1915
|
+
draggable.dropped = false;
|
1916
|
+
|
1917
|
+
// Need to refreshPositions of all sortables just in case removing
|
1918
|
+
// from one sortable changes the location of other sortables (#9675)
|
1919
|
+
$.each( draggable.sortables, function() {
|
1920
|
+
this.refreshPositions();
|
1921
|
+
});
|
1922
|
+
}
|
1923
|
+
}
|
1924
|
+
});
|
1925
|
+
}
|
1926
|
+
});
|
1927
|
+
|
1928
|
+
$.ui.plugin.add("draggable", "cursor", {
|
1929
|
+
start: function( event, ui, instance ) {
|
1930
|
+
var t = $( "body" ),
|
1931
|
+
o = instance.options;
|
1932
|
+
|
1933
|
+
if (t.css("cursor")) {
|
1934
|
+
o._cursor = t.css("cursor");
|
1935
|
+
}
|
1936
|
+
t.css("cursor", o.cursor);
|
1937
|
+
},
|
1938
|
+
stop: function( event, ui, instance ) {
|
1939
|
+
var o = instance.options;
|
1940
|
+
if (o._cursor) {
|
1941
|
+
$("body").css("cursor", o._cursor);
|
1942
|
+
}
|
1943
|
+
}
|
1944
|
+
});
|
1945
|
+
|
1946
|
+
$.ui.plugin.add("draggable", "opacity", {
|
1947
|
+
start: function( event, ui, instance ) {
|
1948
|
+
var t = $( ui.helper ),
|
1949
|
+
o = instance.options;
|
1950
|
+
if (t.css("opacity")) {
|
1951
|
+
o._opacity = t.css("opacity");
|
1952
|
+
}
|
1953
|
+
t.css("opacity", o.opacity);
|
1954
|
+
},
|
1955
|
+
stop: function( event, ui, instance ) {
|
1956
|
+
var o = instance.options;
|
1957
|
+
if (o._opacity) {
|
1958
|
+
$(ui.helper).css("opacity", o._opacity);
|
1959
|
+
}
|
1960
|
+
}
|
1961
|
+
});
|
1962
|
+
|
1963
|
+
$.ui.plugin.add("draggable", "scroll", {
|
1964
|
+
start: function( event, ui, i ) {
|
1965
|
+
if ( !i.scrollParentNotHidden ) {
|
1966
|
+
i.scrollParentNotHidden = i.helper.scrollParent( false );
|
1967
|
+
}
|
1968
|
+
|
1969
|
+
if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
|
1970
|
+
i.overflowOffset = i.scrollParentNotHidden.offset();
|
1971
|
+
}
|
1972
|
+
},
|
1973
|
+
drag: function( event, ui, i ) {
|
1974
|
+
|
1975
|
+
var o = i.options,
|
1976
|
+
scrolled = false,
|
1977
|
+
scrollParent = i.scrollParentNotHidden[ 0 ],
|
1978
|
+
document = i.document[ 0 ];
|
1979
|
+
|
1980
|
+
if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
|
1981
|
+
if ( !o.axis || o.axis !== "x" ) {
|
1982
|
+
if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) {
|
1983
|
+
scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
|
1984
|
+
} else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
|
1985
|
+
scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
|
1986
|
+
}
|
1987
|
+
}
|
1988
|
+
|
1989
|
+
if ( !o.axis || o.axis !== "y" ) {
|
1990
|
+
if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) {
|
1991
|
+
scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
|
1992
|
+
} else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
|
1993
|
+
scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
|
1994
|
+
}
|
1995
|
+
}
|
1996
|
+
|
1997
|
+
} else {
|
1998
|
+
|
1999
|
+
if (!o.axis || o.axis !== "x") {
|
2000
|
+
if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
|
2001
|
+
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
|
2002
|
+
} else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
|
2003
|
+
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
|
2004
|
+
}
|
2005
|
+
}
|
2006
|
+
|
2007
|
+
if (!o.axis || o.axis !== "y") {
|
2008
|
+
if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
|
2009
|
+
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
|
2010
|
+
} else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
|
2011
|
+
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
|
2012
|
+
}
|
2013
|
+
}
|
2014
|
+
|
2015
|
+
}
|
2016
|
+
|
2017
|
+
if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
|
2018
|
+
$.ui.ddmanager.prepareOffsets(i, event);
|
2019
|
+
}
|
2020
|
+
|
2021
|
+
}
|
2022
|
+
});
|
2023
|
+
|
2024
|
+
$.ui.plugin.add("draggable", "snap", {
|
2025
|
+
start: function( event, ui, i ) {
|
2026
|
+
|
2027
|
+
var o = i.options;
|
2028
|
+
|
2029
|
+
i.snapElements = [];
|
2030
|
+
|
2031
|
+
$(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
|
2032
|
+
var $t = $(this),
|
2033
|
+
$o = $t.offset();
|
2034
|
+
if (this !== i.element[0]) {
|
2035
|
+
i.snapElements.push({
|
2036
|
+
item: this,
|
2037
|
+
width: $t.outerWidth(), height: $t.outerHeight(),
|
2038
|
+
top: $o.top, left: $o.left
|
2039
|
+
});
|
2040
|
+
}
|
2041
|
+
});
|
2042
|
+
|
2043
|
+
},
|
2044
|
+
drag: function( event, ui, inst ) {
|
2045
|
+
|
2046
|
+
var ts, bs, ls, rs, l, r, t, b, i, first,
|
2047
|
+
o = inst.options,
|
2048
|
+
d = o.snapTolerance,
|
2049
|
+
x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
|
2050
|
+
y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
|
2051
|
+
|
2052
|
+
for (i = inst.snapElements.length - 1; i >= 0; i--){
|
2053
|
+
|
2054
|
+
l = inst.snapElements[i].left - inst.margins.left;
|
2055
|
+
r = l + inst.snapElements[i].width;
|
2056
|
+
t = inst.snapElements[i].top - inst.margins.top;
|
2057
|
+
b = t + inst.snapElements[i].height;
|
2058
|
+
|
2059
|
+
if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
|
2060
|
+
if (inst.snapElements[i].snapping) {
|
2061
|
+
(inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
|
2062
|
+
}
|
2063
|
+
inst.snapElements[i].snapping = false;
|
2064
|
+
continue;
|
2065
|
+
}
|
2066
|
+
|
2067
|
+
if (o.snapMode !== "inner") {
|
2068
|
+
ts = Math.abs(t - y2) <= d;
|
2069
|
+
bs = Math.abs(b - y1) <= d;
|
2070
|
+
ls = Math.abs(l - x2) <= d;
|
2071
|
+
rs = Math.abs(r - x1) <= d;
|
2072
|
+
if (ts) {
|
2073
|
+
ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
|
2074
|
+
}
|
2075
|
+
if (bs) {
|
2076
|
+
ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
|
2077
|
+
}
|
2078
|
+
if (ls) {
|
2079
|
+
ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
|
2080
|
+
}
|
2081
|
+
if (rs) {
|
2082
|
+
ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
|
2083
|
+
}
|
2084
|
+
}
|
2085
|
+
|
2086
|
+
first = (ts || bs || ls || rs);
|
2087
|
+
|
2088
|
+
if (o.snapMode !== "outer") {
|
2089
|
+
ts = Math.abs(t - y1) <= d;
|
2090
|
+
bs = Math.abs(b - y2) <= d;
|
2091
|
+
ls = Math.abs(l - x1) <= d;
|
2092
|
+
rs = Math.abs(r - x2) <= d;
|
2093
|
+
if (ts) {
|
2094
|
+
ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
|
2095
|
+
}
|
2096
|
+
if (bs) {
|
2097
|
+
ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
|
2098
|
+
}
|
2099
|
+
if (ls) {
|
2100
|
+
ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
|
2101
|
+
}
|
2102
|
+
if (rs) {
|
2103
|
+
ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
|
2104
|
+
}
|
2105
|
+
}
|
2106
|
+
|
2107
|
+
if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
|
2108
|
+
(inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
|
2109
|
+
}
|
2110
|
+
inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
|
2111
|
+
|
2112
|
+
}
|
2113
|
+
|
2114
|
+
}
|
2115
|
+
});
|
2116
|
+
|
2117
|
+
$.ui.plugin.add("draggable", "stack", {
|
2118
|
+
start: function( event, ui, instance ) {
|
2119
|
+
var min,
|
2120
|
+
o = instance.options,
|
2121
|
+
group = $.makeArray($(o.stack)).sort(function(a, b) {
|
2122
|
+
return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
|
2123
|
+
});
|
2124
|
+
|
2125
|
+
if (!group.length) { return; }
|
2126
|
+
|
2127
|
+
min = parseInt($(group[0]).css("zIndex"), 10) || 0;
|
2128
|
+
$(group).each(function(i) {
|
2129
|
+
$(this).css("zIndex", min + i);
|
2130
|
+
});
|
2131
|
+
this.css("zIndex", (min + group.length));
|
2132
|
+
}
|
2133
|
+
});
|
2134
|
+
|
2135
|
+
$.ui.plugin.add("draggable", "zIndex", {
|
2136
|
+
start: function( event, ui, instance ) {
|
2137
|
+
var t = $( ui.helper ),
|
2138
|
+
o = instance.options;
|
2139
|
+
|
2140
|
+
if (t.css("zIndex")) {
|
2141
|
+
o._zIndex = t.css("zIndex");
|
2142
|
+
}
|
2143
|
+
t.css("zIndex", o.zIndex);
|
2144
|
+
},
|
2145
|
+
stop: function( event, ui, instance ) {
|
2146
|
+
var o = instance.options;
|
2147
|
+
|
2148
|
+
if (o._zIndex) {
|
2149
|
+
$(ui.helper).css("zIndex", o._zIndex);
|
2150
|
+
}
|
2151
|
+
}
|
2152
|
+
});
|
2153
|
+
|
2154
|
+
var draggable = $.ui.draggable;
|
2155
|
+
|
2156
|
+
|
2157
|
+
/*!
|
2158
|
+
* jQuery UI Droppable 1.11.2
|
2159
|
+
* http://jqueryui.com
|
2160
|
+
*
|
2161
|
+
* Copyright 2014 jQuery Foundation and other contributors
|
2162
|
+
* Released under the MIT license.
|
2163
|
+
* http://jquery.org/license
|
2164
|
+
*
|
2165
|
+
* http://api.jqueryui.com/droppable/
|
2166
|
+
*/
|
2167
|
+
|
2168
|
+
|
2169
|
+
$.widget( "ui.droppable", {
|
2170
|
+
version: "1.11.2",
|
2171
|
+
widgetEventPrefix: "drop",
|
2172
|
+
options: {
|
2173
|
+
accept: "*",
|
2174
|
+
activeClass: false,
|
2175
|
+
addClasses: true,
|
2176
|
+
greedy: false,
|
2177
|
+
hoverClass: false,
|
2178
|
+
scope: "default",
|
2179
|
+
tolerance: "intersect",
|
2180
|
+
|
2181
|
+
// callbacks
|
2182
|
+
activate: null,
|
2183
|
+
deactivate: null,
|
2184
|
+
drop: null,
|
2185
|
+
out: null,
|
2186
|
+
over: null
|
2187
|
+
},
|
2188
|
+
_create: function() {
|
2189
|
+
|
2190
|
+
var proportions,
|
2191
|
+
o = this.options,
|
2192
|
+
accept = o.accept;
|
2193
|
+
|
2194
|
+
this.isover = false;
|
2195
|
+
this.isout = true;
|
2196
|
+
|
2197
|
+
this.accept = $.isFunction( accept ) ? accept : function( d ) {
|
2198
|
+
return d.is( accept );
|
2199
|
+
};
|
2200
|
+
|
2201
|
+
this.proportions = function( /* valueToWrite */ ) {
|
2202
|
+
if ( arguments.length ) {
|
2203
|
+
// Store the droppable's proportions
|
2204
|
+
proportions = arguments[ 0 ];
|
2205
|
+
} else {
|
2206
|
+
// Retrieve or derive the droppable's proportions
|
2207
|
+
return proportions ?
|
2208
|
+
proportions :
|
2209
|
+
proportions = {
|
2210
|
+
width: this.element[ 0 ].offsetWidth,
|
2211
|
+
height: this.element[ 0 ].offsetHeight
|
2212
|
+
};
|
2213
|
+
}
|
2214
|
+
};
|
2215
|
+
|
2216
|
+
this._addToManager( o.scope );
|
2217
|
+
|
2218
|
+
o.addClasses && this.element.addClass( "ui-droppable" );
|
2219
|
+
|
2220
|
+
},
|
2221
|
+
|
2222
|
+
_addToManager: function( scope ) {
|
2223
|
+
// Add the reference and positions to the manager
|
2224
|
+
$.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
|
2225
|
+
$.ui.ddmanager.droppables[ scope ].push( this );
|
2226
|
+
},
|
2227
|
+
|
2228
|
+
_splice: function( drop ) {
|
2229
|
+
var i = 0;
|
2230
|
+
for ( ; i < drop.length; i++ ) {
|
2231
|
+
if ( drop[ i ] === this ) {
|
2232
|
+
drop.splice( i, 1 );
|
2233
|
+
}
|
2234
|
+
}
|
2235
|
+
},
|
2236
|
+
|
2237
|
+
_destroy: function() {
|
2238
|
+
var drop = $.ui.ddmanager.droppables[ this.options.scope ];
|
2239
|
+
|
2240
|
+
this._splice( drop );
|
2241
|
+
|
2242
|
+
this.element.removeClass( "ui-droppable ui-droppable-disabled" );
|
2243
|
+
},
|
2244
|
+
|
2245
|
+
_setOption: function( key, value ) {
|
2246
|
+
|
2247
|
+
if ( key === "accept" ) {
|
2248
|
+
this.accept = $.isFunction( value ) ? value : function( d ) {
|
2249
|
+
return d.is( value );
|
2250
|
+
};
|
2251
|
+
} else if ( key === "scope" ) {
|
2252
|
+
var drop = $.ui.ddmanager.droppables[ this.options.scope ];
|
2253
|
+
|
2254
|
+
this._splice( drop );
|
2255
|
+
this._addToManager( value );
|
2256
|
+
}
|
2257
|
+
|
2258
|
+
this._super( key, value );
|
2259
|
+
},
|
2260
|
+
|
2261
|
+
_activate: function( event ) {
|
2262
|
+
var draggable = $.ui.ddmanager.current;
|
2263
|
+
if ( this.options.activeClass ) {
|
2264
|
+
this.element.addClass( this.options.activeClass );
|
2265
|
+
}
|
2266
|
+
if ( draggable ){
|
2267
|
+
this._trigger( "activate", event, this.ui( draggable ) );
|
2268
|
+
}
|
2269
|
+
},
|
2270
|
+
|
2271
|
+
_deactivate: function( event ) {
|
2272
|
+
var draggable = $.ui.ddmanager.current;
|
2273
|
+
if ( this.options.activeClass ) {
|
2274
|
+
this.element.removeClass( this.options.activeClass );
|
2275
|
+
}
|
2276
|
+
if ( draggable ){
|
2277
|
+
this._trigger( "deactivate", event, this.ui( draggable ) );
|
2278
|
+
}
|
2279
|
+
},
|
2280
|
+
|
2281
|
+
_over: function( event ) {
|
2282
|
+
|
2283
|
+
var draggable = $.ui.ddmanager.current;
|
2284
|
+
|
2285
|
+
// Bail if draggable and droppable are same element
|
2286
|
+
if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
|
2287
|
+
return;
|
2288
|
+
}
|
2289
|
+
|
2290
|
+
if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
|
2291
|
+
if ( this.options.hoverClass ) {
|
2292
|
+
this.element.addClass( this.options.hoverClass );
|
2293
|
+
}
|
2294
|
+
this._trigger( "over", event, this.ui( draggable ) );
|
2295
|
+
}
|
2296
|
+
|
2297
|
+
},
|
2298
|
+
|
2299
|
+
_out: function( event ) {
|
2300
|
+
|
2301
|
+
var draggable = $.ui.ddmanager.current;
|
2302
|
+
|
2303
|
+
// Bail if draggable and droppable are same element
|
2304
|
+
if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
|
2305
|
+
return;
|
2306
|
+
}
|
2307
|
+
|
2308
|
+
if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
|
2309
|
+
if ( this.options.hoverClass ) {
|
2310
|
+
this.element.removeClass( this.options.hoverClass );
|
2311
|
+
}
|
2312
|
+
this._trigger( "out", event, this.ui( draggable ) );
|
2313
|
+
}
|
2314
|
+
|
2315
|
+
},
|
2316
|
+
|
2317
|
+
_drop: function( event, custom ) {
|
2318
|
+
|
2319
|
+
var draggable = custom || $.ui.ddmanager.current,
|
2320
|
+
childrenIntersection = false;
|
2321
|
+
|
2322
|
+
// Bail if draggable and droppable are same element
|
2323
|
+
if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
|
2324
|
+
return false;
|
2325
|
+
}
|
2326
|
+
|
2327
|
+
this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() {
|
2328
|
+
var inst = $( this ).droppable( "instance" );
|
2329
|
+
if (
|
2330
|
+
inst.options.greedy &&
|
2331
|
+
!inst.options.disabled &&
|
2332
|
+
inst.options.scope === draggable.options.scope &&
|
2333
|
+
inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
|
2334
|
+
$.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event )
|
2335
|
+
) { childrenIntersection = true; return false; }
|
2336
|
+
});
|
2337
|
+
if ( childrenIntersection ) {
|
2338
|
+
return false;
|
2339
|
+
}
|
2340
|
+
|
2341
|
+
if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
|
2342
|
+
if ( this.options.activeClass ) {
|
2343
|
+
this.element.removeClass( this.options.activeClass );
|
2344
|
+
}
|
2345
|
+
if ( this.options.hoverClass ) {
|
2346
|
+
this.element.removeClass( this.options.hoverClass );
|
2347
|
+
}
|
2348
|
+
this._trigger( "drop", event, this.ui( draggable ) );
|
2349
|
+
return this.element;
|
2350
|
+
}
|
2351
|
+
|
2352
|
+
return false;
|
2353
|
+
|
2354
|
+
},
|
2355
|
+
|
2356
|
+
ui: function( c ) {
|
2357
|
+
return {
|
2358
|
+
draggable: ( c.currentItem || c.element ),
|
2359
|
+
helper: c.helper,
|
2360
|
+
position: c.position,
|
2361
|
+
offset: c.positionAbs
|
2362
|
+
};
|
2363
|
+
}
|
2364
|
+
|
2365
|
+
});
|
2366
|
+
|
2367
|
+
$.ui.intersect = (function() {
|
2368
|
+
function isOverAxis( x, reference, size ) {
|
2369
|
+
return ( x >= reference ) && ( x < ( reference + size ) );
|
2370
|
+
}
|
2371
|
+
|
2372
|
+
return function( draggable, droppable, toleranceMode, event ) {
|
2373
|
+
|
2374
|
+
if ( !droppable.offset ) {
|
2375
|
+
return false;
|
2376
|
+
}
|
2377
|
+
|
2378
|
+
var x1 = ( draggable.positionAbs || draggable.position.absolute ).left + draggable.margins.left,
|
2379
|
+
y1 = ( draggable.positionAbs || draggable.position.absolute ).top + draggable.margins.top,
|
2380
|
+
x2 = x1 + draggable.helperProportions.width,
|
2381
|
+
y2 = y1 + draggable.helperProportions.height,
|
2382
|
+
l = droppable.offset.left,
|
2383
|
+
t = droppable.offset.top,
|
2384
|
+
r = l + droppable.proportions().width,
|
2385
|
+
b = t + droppable.proportions().height;
|
2386
|
+
|
2387
|
+
switch ( toleranceMode ) {
|
2388
|
+
case "fit":
|
2389
|
+
return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
|
2390
|
+
case "intersect":
|
2391
|
+
return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
|
2392
|
+
x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
|
2393
|
+
t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
|
2394
|
+
y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
|
2395
|
+
case "pointer":
|
2396
|
+
return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width );
|
2397
|
+
case "touch":
|
2398
|
+
return (
|
2399
|
+
( y1 >= t && y1 <= b ) || // Top edge touching
|
2400
|
+
( y2 >= t && y2 <= b ) || // Bottom edge touching
|
2401
|
+
( y1 < t && y2 > b ) // Surrounded vertically
|
2402
|
+
) && (
|
2403
|
+
( x1 >= l && x1 <= r ) || // Left edge touching
|
2404
|
+
( x2 >= l && x2 <= r ) || // Right edge touching
|
2405
|
+
( x1 < l && x2 > r ) // Surrounded horizontally
|
2406
|
+
);
|
2407
|
+
default:
|
2408
|
+
return false;
|
2409
|
+
}
|
2410
|
+
};
|
2411
|
+
})();
|
2412
|
+
|
2413
|
+
/*
|
2414
|
+
This manager tracks offsets of draggables and droppables
|
2415
|
+
*/
|
2416
|
+
$.ui.ddmanager = {
|
2417
|
+
current: null,
|
2418
|
+
droppables: { "default": [] },
|
2419
|
+
prepareOffsets: function( t, event ) {
|
2420
|
+
|
2421
|
+
var i, j,
|
2422
|
+
m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
|
2423
|
+
type = event ? event.type : null, // workaround for #2317
|
2424
|
+
list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
|
2425
|
+
|
2426
|
+
droppablesLoop: for ( i = 0; i < m.length; i++ ) {
|
2427
|
+
|
2428
|
+
// No disabled and non-accepted
|
2429
|
+
if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) {
|
2430
|
+
continue;
|
2431
|
+
}
|
2432
|
+
|
2433
|
+
// Filter out elements in the current dragged item
|
2434
|
+
for ( j = 0; j < list.length; j++ ) {
|
2435
|
+
if ( list[ j ] === m[ i ].element[ 0 ] ) {
|
2436
|
+
m[ i ].proportions().height = 0;
|
2437
|
+
continue droppablesLoop;
|
2438
|
+
}
|
2439
|
+
}
|
2440
|
+
|
2441
|
+
m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
|
2442
|
+
if ( !m[ i ].visible ) {
|
2443
|
+
continue;
|
2444
|
+
}
|
2445
|
+
|
2446
|
+
// Activate the droppable if used directly from draggables
|
2447
|
+
if ( type === "mousedown" ) {
|
2448
|
+
m[ i ]._activate.call( m[ i ], event );
|
2449
|
+
}
|
2450
|
+
|
2451
|
+
m[ i ].offset = m[ i ].element.offset();
|
2452
|
+
m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
|
2453
|
+
|
2454
|
+
}
|
2455
|
+
|
2456
|
+
},
|
2457
|
+
drop: function( draggable, event ) {
|
2458
|
+
|
2459
|
+
var dropped = false;
|
2460
|
+
// Create a copy of the droppables in case the list changes during the drop (#9116)
|
2461
|
+
$.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
|
2462
|
+
|
2463
|
+
if ( !this.options ) {
|
2464
|
+
return;
|
2465
|
+
}
|
2466
|
+
if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
|
2467
|
+
dropped = this._drop.call( this, event ) || dropped;
|
2468
|
+
}
|
2469
|
+
|
2470
|
+
if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
|
2471
|
+
this.isout = true;
|
2472
|
+
this.isover = false;
|
2473
|
+
this._deactivate.call( this, event );
|
2474
|
+
}
|
2475
|
+
|
2476
|
+
});
|
2477
|
+
return dropped;
|
2478
|
+
|
2479
|
+
},
|
2480
|
+
dragStart: function( draggable, event ) {
|
2481
|
+
// Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
|
2482
|
+
draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
|
2483
|
+
if ( !draggable.options.refreshPositions ) {
|
2484
|
+
$.ui.ddmanager.prepareOffsets( draggable, event );
|
2485
|
+
}
|
2486
|
+
});
|
2487
|
+
},
|
2488
|
+
drag: function( draggable, event ) {
|
2489
|
+
|
2490
|
+
// If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
|
2491
|
+
if ( draggable.options.refreshPositions ) {
|
2492
|
+
$.ui.ddmanager.prepareOffsets( draggable, event );
|
2493
|
+
}
|
2494
|
+
|
2495
|
+
// Run through all droppables and check their positions based on specific tolerance options
|
2496
|
+
$.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
|
2497
|
+
|
2498
|
+
if ( this.options.disabled || this.greedyChild || !this.visible ) {
|
2499
|
+
return;
|
2500
|
+
}
|
2501
|
+
|
2502
|
+
var parentInstance, scope, parent,
|
2503
|
+
intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
|
2504
|
+
c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
|
2505
|
+
if ( !c ) {
|
2506
|
+
return;
|
2507
|
+
}
|
2508
|
+
|
2509
|
+
if ( this.options.greedy ) {
|
2510
|
+
// find droppable parents with same scope
|
2511
|
+
scope = this.options.scope;
|
2512
|
+
parent = this.element.parents( ":data(ui-droppable)" ).filter(function() {
|
2513
|
+
return $( this ).droppable( "instance" ).options.scope === scope;
|
2514
|
+
});
|
2515
|
+
|
2516
|
+
if ( parent.length ) {
|
2517
|
+
parentInstance = $( parent[ 0 ] ).droppable( "instance" );
|
2518
|
+
parentInstance.greedyChild = ( c === "isover" );
|
2519
|
+
}
|
2520
|
+
}
|
2521
|
+
|
2522
|
+
// we just moved into a greedy child
|
2523
|
+
if ( parentInstance && c === "isover" ) {
|
2524
|
+
parentInstance.isover = false;
|
2525
|
+
parentInstance.isout = true;
|
2526
|
+
parentInstance._out.call( parentInstance, event );
|
2527
|
+
}
|
2528
|
+
|
2529
|
+
this[ c ] = true;
|
2530
|
+
this[c === "isout" ? "isover" : "isout"] = false;
|
2531
|
+
this[c === "isover" ? "_over" : "_out"].call( this, event );
|
2532
|
+
|
2533
|
+
// we just moved out of a greedy child
|
2534
|
+
if ( parentInstance && c === "isout" ) {
|
2535
|
+
parentInstance.isout = false;
|
2536
|
+
parentInstance.isover = true;
|
2537
|
+
parentInstance._over.call( parentInstance, event );
|
2538
|
+
}
|
2539
|
+
});
|
2540
|
+
|
2541
|
+
},
|
2542
|
+
dragStop: function( draggable, event ) {
|
2543
|
+
draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
|
2544
|
+
// Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
|
2545
|
+
if ( !draggable.options.refreshPositions ) {
|
2546
|
+
$.ui.ddmanager.prepareOffsets( draggable, event );
|
2547
|
+
}
|
2548
|
+
}
|
2549
|
+
};
|
2550
|
+
|
2551
|
+
var droppable = $.ui.droppable;
|
2552
|
+
|
2553
|
+
|
2554
|
+
/*!
|
2555
|
+
* jQuery UI Sortable 1.11.2
|
2556
|
+
* http://jqueryui.com
|
2557
|
+
*
|
2558
|
+
* Copyright 2014 jQuery Foundation and other contributors
|
2559
|
+
* Released under the MIT license.
|
2560
|
+
* http://jquery.org/license
|
2561
|
+
*
|
2562
|
+
* http://api.jqueryui.com/sortable/
|
2563
|
+
*/
|
2564
|
+
|
2565
|
+
|
2566
|
+
var sortable = $.widget("ui.sortable", $.ui.mouse, {
|
2567
|
+
version: "1.11.2",
|
2568
|
+
widgetEventPrefix: "sort",
|
2569
|
+
ready: false,
|
2570
|
+
options: {
|
2571
|
+
appendTo: "parent",
|
2572
|
+
axis: false,
|
2573
|
+
connectWith: false,
|
2574
|
+
containment: false,
|
2575
|
+
cursor: "auto",
|
2576
|
+
cursorAt: false,
|
2577
|
+
dropOnEmpty: true,
|
2578
|
+
forcePlaceholderSize: false,
|
2579
|
+
forceHelperSize: false,
|
2580
|
+
grid: false,
|
2581
|
+
handle: false,
|
2582
|
+
helper: "original",
|
2583
|
+
items: "> *",
|
2584
|
+
opacity: false,
|
2585
|
+
placeholder: false,
|
2586
|
+
revert: false,
|
2587
|
+
scroll: true,
|
2588
|
+
scrollSensitivity: 20,
|
2589
|
+
scrollSpeed: 20,
|
2590
|
+
scope: "default",
|
2591
|
+
tolerance: "intersect",
|
2592
|
+
zIndex: 1000,
|
2593
|
+
|
2594
|
+
// callbacks
|
2595
|
+
activate: null,
|
2596
|
+
beforeStop: null,
|
2597
|
+
change: null,
|
2598
|
+
deactivate: null,
|
2599
|
+
out: null,
|
2600
|
+
over: null,
|
2601
|
+
receive: null,
|
2602
|
+
remove: null,
|
2603
|
+
sort: null,
|
2604
|
+
start: null,
|
2605
|
+
stop: null,
|
2606
|
+
update: null
|
2607
|
+
},
|
2608
|
+
|
2609
|
+
_isOverAxis: function( x, reference, size ) {
|
2610
|
+
return ( x >= reference ) && ( x < ( reference + size ) );
|
2611
|
+
},
|
2612
|
+
|
2613
|
+
_isFloating: function( item ) {
|
2614
|
+
return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
|
2615
|
+
},
|
2616
|
+
|
2617
|
+
_create: function() {
|
2618
|
+
|
2619
|
+
var o = this.options;
|
2620
|
+
this.containerCache = {};
|
2621
|
+
this.element.addClass("ui-sortable");
|
2622
|
+
|
2623
|
+
//Get the items
|
2624
|
+
this.refresh();
|
2625
|
+
|
2626
|
+
//Let's determine if the items are being displayed horizontally
|
2627
|
+
this.floating = this.items.length ? o.axis === "x" || this._isFloating(this.items[0].item) : false;
|
2628
|
+
|
2629
|
+
//Let's determine the parent's offset
|
2630
|
+
this.offset = this.element.offset();
|
2631
|
+
|
2632
|
+
//Initialize mouse events for interaction
|
2633
|
+
this._mouseInit();
|
2634
|
+
|
2635
|
+
this._setHandleClassName();
|
2636
|
+
|
2637
|
+
//We're ready to go
|
2638
|
+
this.ready = true;
|
2639
|
+
|
2640
|
+
},
|
2641
|
+
|
2642
|
+
_setOption: function( key, value ) {
|
2643
|
+
this._super( key, value );
|
2644
|
+
|
2645
|
+
if ( key === "handle" ) {
|
2646
|
+
this._setHandleClassName();
|
2647
|
+
}
|
2648
|
+
},
|
2649
|
+
|
2650
|
+
_setHandleClassName: function() {
|
2651
|
+
this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" );
|
2652
|
+
$.each( this.items, function() {
|
2653
|
+
( this.instance.options.handle ?
|
2654
|
+
this.item.find( this.instance.options.handle ) : this.item )
|
2655
|
+
.addClass( "ui-sortable-handle" );
|
2656
|
+
});
|
2657
|
+
},
|
2658
|
+
|
2659
|
+
_destroy: function() {
|
2660
|
+
this.element
|
2661
|
+
.removeClass( "ui-sortable ui-sortable-disabled" )
|
2662
|
+
.find( ".ui-sortable-handle" )
|
2663
|
+
.removeClass( "ui-sortable-handle" );
|
2664
|
+
this._mouseDestroy();
|
2665
|
+
|
2666
|
+
for ( var i = this.items.length - 1; i >= 0; i-- ) {
|
2667
|
+
this.items[i].item.removeData(this.widgetName + "-item");
|
2668
|
+
}
|
2669
|
+
|
2670
|
+
return this;
|
2671
|
+
},
|
2672
|
+
|
2673
|
+
_mouseCapture: function(event, overrideHandle) {
|
2674
|
+
var currentItem = null,
|
2675
|
+
validHandle = false,
|
2676
|
+
that = this;
|
2677
|
+
|
2678
|
+
if (this.reverting) {
|
2679
|
+
return false;
|
2680
|
+
}
|
2681
|
+
|
2682
|
+
if(this.options.disabled || this.options.type === "static") {
|
2683
|
+
return false;
|
2684
|
+
}
|
2685
|
+
|
2686
|
+
//We have to refresh the items data once first
|
2687
|
+
this._refreshItems(event);
|
2688
|
+
|
2689
|
+
//Find out if the clicked node (or one of its parents) is a actual item in this.items
|
2690
|
+
$(event.target).parents().each(function() {
|
2691
|
+
if($.data(this, that.widgetName + "-item") === that) {
|
2692
|
+
currentItem = $(this);
|
2693
|
+
return false;
|
2694
|
+
}
|
2695
|
+
});
|
2696
|
+
if($.data(event.target, that.widgetName + "-item") === that) {
|
2697
|
+
currentItem = $(event.target);
|
2698
|
+
}
|
2699
|
+
|
2700
|
+
if(!currentItem) {
|
2701
|
+
return false;
|
2702
|
+
}
|
2703
|
+
if(this.options.handle && !overrideHandle) {
|
2704
|
+
$(this.options.handle, currentItem).find("*").addBack().each(function() {
|
2705
|
+
if(this === event.target) {
|
2706
|
+
validHandle = true;
|
2707
|
+
}
|
2708
|
+
});
|
2709
|
+
if(!validHandle) {
|
2710
|
+
return false;
|
2711
|
+
}
|
2712
|
+
}
|
2713
|
+
|
2714
|
+
this.currentItem = currentItem;
|
2715
|
+
this._removeCurrentsFromItems();
|
2716
|
+
return true;
|
2717
|
+
|
2718
|
+
},
|
2719
|
+
|
2720
|
+
_mouseStart: function(event, overrideHandle, noActivation) {
|
2721
|
+
|
2722
|
+
var i, body,
|
2723
|
+
o = this.options;
|
2724
|
+
|
2725
|
+
this.currentContainer = this;
|
2726
|
+
|
2727
|
+
//We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
|
2728
|
+
this.refreshPositions();
|
2729
|
+
|
2730
|
+
//Create and append the visible helper
|
2731
|
+
this.helper = this._createHelper(event);
|
2732
|
+
|
2733
|
+
//Cache the helper size
|
2734
|
+
this._cacheHelperProportions();
|
2735
|
+
|
2736
|
+
/*
|
2737
|
+
* - Position generation -
|
2738
|
+
* This block generates everything position related - it's the core of draggables.
|
2739
|
+
*/
|
2740
|
+
|
2741
|
+
//Cache the margins of the original element
|
2742
|
+
this._cacheMargins();
|
2743
|
+
|
2744
|
+
//Get the next scrolling parent
|
2745
|
+
this.scrollParent = this.helper.scrollParent();
|
2746
|
+
|
2747
|
+
//The element's absolute position on the page minus margins
|
2748
|
+
this.offset = this.currentItem.offset();
|
2749
|
+
this.offset = {
|
2750
|
+
top: this.offset.top - this.margins.top,
|
2751
|
+
left: this.offset.left - this.margins.left
|
2752
|
+
};
|
2753
|
+
|
2754
|
+
$.extend(this.offset, {
|
2755
|
+
click: { //Where the click happened, relative to the element
|
2756
|
+
left: event.pageX - this.offset.left,
|
2757
|
+
top: event.pageY - this.offset.top
|
2758
|
+
},
|
2759
|
+
parent: this._getParentOffset(),
|
2760
|
+
relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
|
2761
|
+
});
|
2762
|
+
|
2763
|
+
// Only after we got the offset, we can change the helper's position to absolute
|
2764
|
+
// TODO: Still need to figure out a way to make relative sorting possible
|
2765
|
+
this.helper.css("position", "absolute");
|
2766
|
+
this.cssPosition = this.helper.css("position");
|
2767
|
+
|
2768
|
+
//Generate the original position
|
2769
|
+
this.originalPosition = this._generatePosition(event);
|
2770
|
+
this.originalPageX = event.pageX;
|
2771
|
+
this.originalPageY = event.pageY;
|
2772
|
+
|
2773
|
+
//Adjust the mouse offset relative to the helper if "cursorAt" is supplied
|
2774
|
+
(o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
|
2775
|
+
|
2776
|
+
//Cache the former DOM position
|
2777
|
+
this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
|
2778
|
+
|
2779
|
+
//If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
|
2780
|
+
if(this.helper[0] !== this.currentItem[0]) {
|
2781
|
+
this.currentItem.hide();
|
2782
|
+
}
|
2783
|
+
|
2784
|
+
//Create the placeholder
|
2785
|
+
this._createPlaceholder();
|
2786
|
+
|
2787
|
+
//Set a containment if given in the options
|
2788
|
+
if(o.containment) {
|
2789
|
+
this._setContainment();
|
2790
|
+
}
|
2791
|
+
|
2792
|
+
if( o.cursor && o.cursor !== "auto" ) { // cursor option
|
2793
|
+
body = this.document.find( "body" );
|
2794
|
+
|
2795
|
+
// support: IE
|
2796
|
+
this.storedCursor = body.css( "cursor" );
|
2797
|
+
body.css( "cursor", o.cursor );
|
2798
|
+
|
2799
|
+
this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
|
2800
|
+
}
|
2801
|
+
|
2802
|
+
if(o.opacity) { // opacity option
|
2803
|
+
if (this.helper.css("opacity")) {
|
2804
|
+
this._storedOpacity = this.helper.css("opacity");
|
2805
|
+
}
|
2806
|
+
this.helper.css("opacity", o.opacity);
|
2807
|
+
}
|
2808
|
+
|
2809
|
+
if(o.zIndex) { // zIndex option
|
2810
|
+
if (this.helper.css("zIndex")) {
|
2811
|
+
this._storedZIndex = this.helper.css("zIndex");
|
2812
|
+
}
|
2813
|
+
this.helper.css("zIndex", o.zIndex);
|
2814
|
+
}
|
2815
|
+
|
2816
|
+
//Prepare scrolling
|
2817
|
+
if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
|
2818
|
+
this.overflowOffset = this.scrollParent.offset();
|
2819
|
+
}
|
2820
|
+
|
2821
|
+
//Call callbacks
|
2822
|
+
this._trigger("start", event, this._uiHash());
|
2823
|
+
|
2824
|
+
//Recache the helper size
|
2825
|
+
if(!this._preserveHelperProportions) {
|
2826
|
+
this._cacheHelperProportions();
|
2827
|
+
}
|
2828
|
+
|
2829
|
+
|
2830
|
+
//Post "activate" events to possible containers
|
2831
|
+
if( !noActivation ) {
|
2832
|
+
for ( i = this.containers.length - 1; i >= 0; i-- ) {
|
2833
|
+
this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
|
2834
|
+
}
|
2835
|
+
}
|
2836
|
+
|
2837
|
+
//Prepare possible droppables
|
2838
|
+
if($.ui.ddmanager) {
|
2839
|
+
$.ui.ddmanager.current = this;
|
2840
|
+
}
|
2841
|
+
|
2842
|
+
if ($.ui.ddmanager && !o.dropBehaviour) {
|
2843
|
+
$.ui.ddmanager.prepareOffsets(this, event);
|
2844
|
+
}
|
2845
|
+
|
2846
|
+
this.dragging = true;
|
2847
|
+
|
2848
|
+
this.helper.addClass("ui-sortable-helper");
|
2849
|
+
this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
|
2850
|
+
return true;
|
2851
|
+
|
2852
|
+
},
|
2853
|
+
|
2854
|
+
_mouseDrag: function(event) {
|
2855
|
+
var i, item, itemElement, intersection,
|
2856
|
+
o = this.options,
|
2857
|
+
scrolled = false;
|
2858
|
+
|
2859
|
+
//Compute the helpers position
|
2860
|
+
this.position = this._generatePosition(event);
|
2861
|
+
this.positionAbs = this._convertPositionTo("absolute");
|
2862
|
+
|
2863
|
+
if (!this.lastPositionAbs) {
|
2864
|
+
this.lastPositionAbs = this.positionAbs;
|
2865
|
+
}
|
2866
|
+
|
2867
|
+
//Do scrolling
|
2868
|
+
if(this.options.scroll) {
|
2869
|
+
if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
|
2870
|
+
|
2871
|
+
if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
|
2872
|
+
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
|
2873
|
+
} else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
|
2874
|
+
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
|
2875
|
+
}
|
2876
|
+
|
2877
|
+
if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
|
2878
|
+
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
|
2879
|
+
} else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
|
2880
|
+
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
|
2881
|
+
}
|
2882
|
+
|
2883
|
+
} else {
|
2884
|
+
|
2885
|
+
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
|
2886
|
+
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
|
2887
|
+
} else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
|
2888
|
+
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
|
2889
|
+
}
|
2890
|
+
|
2891
|
+
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
|
2892
|
+
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
|
2893
|
+
} else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
|
2894
|
+
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
|
2895
|
+
}
|
2896
|
+
|
2897
|
+
}
|
2898
|
+
|
2899
|
+
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
|
2900
|
+
$.ui.ddmanager.prepareOffsets(this, event);
|
2901
|
+
}
|
2902
|
+
}
|
2903
|
+
|
2904
|
+
//Regenerate the absolute position used for position checks
|
2905
|
+
this.positionAbs = this._convertPositionTo("absolute");
|
2906
|
+
|
2907
|
+
//Set the helper position
|
2908
|
+
if(!this.options.axis || this.options.axis !== "y") {
|
2909
|
+
this.helper[0].style.left = this.position.left+"px";
|
2910
|
+
}
|
2911
|
+
if(!this.options.axis || this.options.axis !== "x") {
|
2912
|
+
this.helper[0].style.top = this.position.top+"px";
|
2913
|
+
}
|
2914
|
+
|
2915
|
+
//Rearrange
|
2916
|
+
for (i = this.items.length - 1; i >= 0; i--) {
|
2917
|
+
|
2918
|
+
//Cache variables and intersection, continue if no intersection
|
2919
|
+
item = this.items[i];
|
2920
|
+
itemElement = item.item[0];
|
2921
|
+
intersection = this._intersectsWithPointer(item);
|
2922
|
+
if (!intersection) {
|
2923
|
+
continue;
|
2924
|
+
}
|
2925
|
+
|
2926
|
+
// Only put the placeholder inside the current Container, skip all
|
2927
|
+
// items from other containers. This works because when moving
|
2928
|
+
// an item from one container to another the
|
2929
|
+
// currentContainer is switched before the placeholder is moved.
|
2930
|
+
//
|
2931
|
+
// Without this, moving items in "sub-sortables" can cause
|
2932
|
+
// the placeholder to jitter between the outer and inner container.
|
2933
|
+
if (item.instance !== this.currentContainer) {
|
2934
|
+
continue;
|
2935
|
+
}
|
2936
|
+
|
2937
|
+
// cannot intersect with itself
|
2938
|
+
// no useless actions that have been done before
|
2939
|
+
// no action if the item moved is the parent of the item checked
|
2940
|
+
if (itemElement !== this.currentItem[0] &&
|
2941
|
+
this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
|
2942
|
+
!$.contains(this.placeholder[0], itemElement) &&
|
2943
|
+
(this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
|
2944
|
+
) {
|
2945
|
+
|
2946
|
+
this.direction = intersection === 1 ? "down" : "up";
|
2947
|
+
|
2948
|
+
if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
|
2949
|
+
this._rearrange(event, item);
|
2950
|
+
} else {
|
2951
|
+
break;
|
2952
|
+
}
|
2953
|
+
|
2954
|
+
this._trigger("change", event, this._uiHash());
|
2955
|
+
break;
|
2956
|
+
}
|
2957
|
+
}
|
2958
|
+
|
2959
|
+
//Post events to containers
|
2960
|
+
this._contactContainers(event);
|
2961
|
+
|
2962
|
+
//Interconnect with droppables
|
2963
|
+
if($.ui.ddmanager) {
|
2964
|
+
$.ui.ddmanager.drag(this, event);
|
2965
|
+
}
|
2966
|
+
|
2967
|
+
//Call callbacks
|
2968
|
+
this._trigger("sort", event, this._uiHash());
|
2969
|
+
|
2970
|
+
this.lastPositionAbs = this.positionAbs;
|
2971
|
+
return false;
|
2972
|
+
|
2973
|
+
},
|
2974
|
+
|
2975
|
+
_mouseStop: function(event, noPropagation) {
|
2976
|
+
|
2977
|
+
if(!event) {
|
2978
|
+
return;
|
2979
|
+
}
|
2980
|
+
|
2981
|
+
//If we are using droppables, inform the manager about the drop
|
2982
|
+
if ($.ui.ddmanager && !this.options.dropBehaviour) {
|
2983
|
+
$.ui.ddmanager.drop(this, event);
|
2984
|
+
}
|
2985
|
+
|
2986
|
+
if(this.options.revert) {
|
2987
|
+
var that = this,
|
2988
|
+
cur = this.placeholder.offset(),
|
2989
|
+
axis = this.options.axis,
|
2990
|
+
animation = {};
|
2991
|
+
|
2992
|
+
if ( !axis || axis === "x" ) {
|
2993
|
+
animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
|
2994
|
+
}
|
2995
|
+
if ( !axis || axis === "y" ) {
|
2996
|
+
animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
|
2997
|
+
}
|
2998
|
+
this.reverting = true;
|
2999
|
+
$(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
|
3000
|
+
that._clear(event);
|
3001
|
+
});
|
3002
|
+
} else {
|
3003
|
+
this._clear(event, noPropagation);
|
3004
|
+
}
|
3005
|
+
|
3006
|
+
return false;
|
3007
|
+
|
3008
|
+
},
|
3009
|
+
|
3010
|
+
cancel: function() {
|
3011
|
+
|
3012
|
+
if(this.dragging) {
|
3013
|
+
|
3014
|
+
this._mouseUp({ target: null });
|
3015
|
+
|
3016
|
+
if(this.options.helper === "original") {
|
3017
|
+
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
|
3018
|
+
} else {
|
3019
|
+
this.currentItem.show();
|
3020
|
+
}
|
3021
|
+
|
3022
|
+
//Post deactivating events to containers
|
3023
|
+
for (var i = this.containers.length - 1; i >= 0; i--){
|
3024
|
+
this.containers[i]._trigger("deactivate", null, this._uiHash(this));
|
3025
|
+
if(this.containers[i].containerCache.over) {
|
3026
|
+
this.containers[i]._trigger("out", null, this._uiHash(this));
|
3027
|
+
this.containers[i].containerCache.over = 0;
|
3028
|
+
}
|
3029
|
+
}
|
3030
|
+
|
3031
|
+
}
|
3032
|
+
|
3033
|
+
if (this.placeholder) {
|
3034
|
+
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
|
3035
|
+
if(this.placeholder[0].parentNode) {
|
3036
|
+
this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
|
3037
|
+
}
|
3038
|
+
if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
|
3039
|
+
this.helper.remove();
|
3040
|
+
}
|
3041
|
+
|
3042
|
+
$.extend(this, {
|
3043
|
+
helper: null,
|
3044
|
+
dragging: false,
|
3045
|
+
reverting: false,
|
3046
|
+
_noFinalSort: null
|
3047
|
+
});
|
3048
|
+
|
3049
|
+
if(this.domPosition.prev) {
|
3050
|
+
$(this.domPosition.prev).after(this.currentItem);
|
3051
|
+
} else {
|
3052
|
+
$(this.domPosition.parent).prepend(this.currentItem);
|
3053
|
+
}
|
3054
|
+
}
|
3055
|
+
|
3056
|
+
return this;
|
3057
|
+
|
3058
|
+
},
|
3059
|
+
|
3060
|
+
serialize: function(o) {
|
3061
|
+
|
3062
|
+
var items = this._getItemsAsjQuery(o && o.connected),
|
3063
|
+
str = [];
|
3064
|
+
o = o || {};
|
3065
|
+
|
3066
|
+
$(items).each(function() {
|
3067
|
+
var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
|
3068
|
+
if (res) {
|
3069
|
+
str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
|
3070
|
+
}
|
3071
|
+
});
|
3072
|
+
|
3073
|
+
if(!str.length && o.key) {
|
3074
|
+
str.push(o.key + "=");
|
3075
|
+
}
|
3076
|
+
|
3077
|
+
return str.join("&");
|
3078
|
+
|
3079
|
+
},
|
3080
|
+
|
3081
|
+
toArray: function(o) {
|
3082
|
+
|
3083
|
+
var items = this._getItemsAsjQuery(o && o.connected),
|
3084
|
+
ret = [];
|
3085
|
+
|
3086
|
+
o = o || {};
|
3087
|
+
|
3088
|
+
items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
|
3089
|
+
return ret;
|
3090
|
+
|
3091
|
+
},
|
3092
|
+
|
3093
|
+
/* Be careful with the following core functions */
|
3094
|
+
_intersectsWith: function(item) {
|
3095
|
+
|
3096
|
+
var x1 = this.positionAbs.left,
|
3097
|
+
x2 = x1 + this.helperProportions.width,
|
3098
|
+
y1 = this.positionAbs.top,
|
3099
|
+
y2 = y1 + this.helperProportions.height,
|
3100
|
+
l = item.left,
|
3101
|
+
r = l + item.width,
|
3102
|
+
t = item.top,
|
3103
|
+
b = t + item.height,
|
3104
|
+
dyClick = this.offset.click.top,
|
3105
|
+
dxClick = this.offset.click.left,
|
3106
|
+
isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
|
3107
|
+
isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
|
3108
|
+
isOverElement = isOverElementHeight && isOverElementWidth;
|
3109
|
+
|
3110
|
+
if ( this.options.tolerance === "pointer" ||
|
3111
|
+
this.options.forcePointerForContainers ||
|
3112
|
+
(this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
|
3113
|
+
) {
|
3114
|
+
return isOverElement;
|
3115
|
+
} else {
|
3116
|
+
|
3117
|
+
return (l < x1 + (this.helperProportions.width / 2) && // Right Half
|
3118
|
+
x2 - (this.helperProportions.width / 2) < r && // Left Half
|
3119
|
+
t < y1 + (this.helperProportions.height / 2) && // Bottom Half
|
3120
|
+
y2 - (this.helperProportions.height / 2) < b ); // Top Half
|
3121
|
+
|
3122
|
+
}
|
3123
|
+
},
|
3124
|
+
|
3125
|
+
_intersectsWithPointer: function(item) {
|
3126
|
+
|
3127
|
+
var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
|
3128
|
+
isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
|
3129
|
+
isOverElement = isOverElementHeight && isOverElementWidth,
|
3130
|
+
verticalDirection = this._getDragVerticalDirection(),
|
3131
|
+
horizontalDirection = this._getDragHorizontalDirection();
|
3132
|
+
|
3133
|
+
if (!isOverElement) {
|
3134
|
+
return false;
|
3135
|
+
}
|
3136
|
+
|
3137
|
+
return this.floating ?
|
3138
|
+
( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
|
3139
|
+
: ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
|
3140
|
+
|
3141
|
+
},
|
3142
|
+
|
3143
|
+
_intersectsWithSides: function(item) {
|
3144
|
+
|
3145
|
+
var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
|
3146
|
+
isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
|
3147
|
+
verticalDirection = this._getDragVerticalDirection(),
|
3148
|
+
horizontalDirection = this._getDragHorizontalDirection();
|
3149
|
+
|
3150
|
+
if (this.floating && horizontalDirection) {
|
3151
|
+
return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
|
3152
|
+
} else {
|
3153
|
+
return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
|
3154
|
+
}
|
3155
|
+
|
3156
|
+
},
|
3157
|
+
|
3158
|
+
_getDragVerticalDirection: function() {
|
3159
|
+
var delta = this.positionAbs.top - this.lastPositionAbs.top;
|
3160
|
+
return delta !== 0 && (delta > 0 ? "down" : "up");
|
3161
|
+
},
|
3162
|
+
|
3163
|
+
_getDragHorizontalDirection: function() {
|
3164
|
+
var delta = this.positionAbs.left - this.lastPositionAbs.left;
|
3165
|
+
return delta !== 0 && (delta > 0 ? "right" : "left");
|
3166
|
+
},
|
3167
|
+
|
3168
|
+
refresh: function(event) {
|
3169
|
+
this._refreshItems(event);
|
3170
|
+
this._setHandleClassName();
|
3171
|
+
this.refreshPositions();
|
3172
|
+
return this;
|
3173
|
+
},
|
3174
|
+
|
3175
|
+
_connectWith: function() {
|
3176
|
+
var options = this.options;
|
3177
|
+
return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
|
3178
|
+
},
|
3179
|
+
|
3180
|
+
_getItemsAsjQuery: function(connected) {
|
3181
|
+
|
3182
|
+
var i, j, cur, inst,
|
3183
|
+
items = [],
|
3184
|
+
queries = [],
|
3185
|
+
connectWith = this._connectWith();
|
3186
|
+
|
3187
|
+
if(connectWith && connected) {
|
3188
|
+
for (i = connectWith.length - 1; i >= 0; i--){
|
3189
|
+
cur = $(connectWith[i]);
|
3190
|
+
for ( j = cur.length - 1; j >= 0; j--){
|
3191
|
+
inst = $.data(cur[j], this.widgetFullName);
|
3192
|
+
if(inst && inst !== this && !inst.options.disabled) {
|
3193
|
+
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]);
|
3194
|
+
}
|
3195
|
+
}
|
3196
|
+
}
|
3197
|
+
}
|
3198
|
+
|
3199
|
+
queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]);
|
3200
|
+
|
3201
|
+
function addItems() {
|
3202
|
+
items.push( this );
|
3203
|
+
}
|
3204
|
+
for (i = queries.length - 1; i >= 0; i--){
|
3205
|
+
queries[i][0].each( addItems );
|
3206
|
+
}
|
3207
|
+
|
3208
|
+
return $(items);
|
3209
|
+
|
3210
|
+
},
|
3211
|
+
|
3212
|
+
_removeCurrentsFromItems: function() {
|
3213
|
+
|
3214
|
+
var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
|
3215
|
+
|
3216
|
+
this.items = $.grep(this.items, function (item) {
|
3217
|
+
for (var j=0; j < list.length; j++) {
|
3218
|
+
if(list[j] === item.item[0]) {
|
3219
|
+
return false;
|
3220
|
+
}
|
3221
|
+
}
|
3222
|
+
return true;
|
3223
|
+
});
|
3224
|
+
|
3225
|
+
},
|
3226
|
+
|
3227
|
+
_refreshItems: function(event) {
|
3228
|
+
|
3229
|
+
this.items = [];
|
3230
|
+
this.containers = [this];
|
3231
|
+
|
3232
|
+
var i, j, cur, inst, targetData, _queries, item, queriesLength,
|
3233
|
+
items = this.items,
|
3234
|
+
queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
|
3235
|
+
connectWith = this._connectWith();
|
3236
|
+
|
3237
|
+
if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
|
3238
|
+
for (i = connectWith.length - 1; i >= 0; i--){
|
3239
|
+
cur = $(connectWith[i]);
|
3240
|
+
for (j = cur.length - 1; j >= 0; j--){
|
3241
|
+
inst = $.data(cur[j], this.widgetFullName);
|
3242
|
+
if(inst && inst !== this && !inst.options.disabled) {
|
3243
|
+
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
|
3244
|
+
this.containers.push(inst);
|
3245
|
+
}
|
3246
|
+
}
|
3247
|
+
}
|
3248
|
+
}
|
3249
|
+
|
3250
|
+
for (i = queries.length - 1; i >= 0; i--) {
|
3251
|
+
targetData = queries[i][1];
|
3252
|
+
_queries = queries[i][0];
|
3253
|
+
|
3254
|
+
for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
|
3255
|
+
item = $(_queries[j]);
|
3256
|
+
|
3257
|
+
item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
|
3258
|
+
|
3259
|
+
items.push({
|
3260
|
+
item: item,
|
3261
|
+
instance: targetData,
|
3262
|
+
width: 0, height: 0,
|
3263
|
+
left: 0, top: 0
|
3264
|
+
});
|
3265
|
+
}
|
3266
|
+
}
|
3267
|
+
|
3268
|
+
},
|
3269
|
+
|
3270
|
+
refreshPositions: function(fast) {
|
3271
|
+
|
3272
|
+
//This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
|
3273
|
+
if(this.offsetParent && this.helper) {
|
3274
|
+
this.offset.parent = this._getParentOffset();
|
3275
|
+
}
|
3276
|
+
|
3277
|
+
var i, item, t, p;
|
3278
|
+
|
3279
|
+
for (i = this.items.length - 1; i >= 0; i--){
|
3280
|
+
item = this.items[i];
|
3281
|
+
|
3282
|
+
//We ignore calculating positions of all connected containers when we're not over them
|
3283
|
+
if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
|
3284
|
+
continue;
|
3285
|
+
}
|
3286
|
+
|
3287
|
+
t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
|
3288
|
+
|
3289
|
+
if (!fast) {
|
3290
|
+
item.width = t.outerWidth();
|
3291
|
+
item.height = t.outerHeight();
|
3292
|
+
}
|
3293
|
+
|
3294
|
+
p = t.offset();
|
3295
|
+
item.left = p.left;
|
3296
|
+
item.top = p.top;
|
3297
|
+
}
|
3298
|
+
|
3299
|
+
if(this.options.custom && this.options.custom.refreshContainers) {
|
3300
|
+
this.options.custom.refreshContainers.call(this);
|
3301
|
+
} else {
|
3302
|
+
for (i = this.containers.length - 1; i >= 0; i--){
|
3303
|
+
p = this.containers[i].element.offset();
|
3304
|
+
this.containers[i].containerCache.left = p.left;
|
3305
|
+
this.containers[i].containerCache.top = p.top;
|
3306
|
+
this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
|
3307
|
+
this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
|
3308
|
+
}
|
3309
|
+
}
|
3310
|
+
|
3311
|
+
return this;
|
3312
|
+
},
|
3313
|
+
|
3314
|
+
_createPlaceholder: function(that) {
|
3315
|
+
that = that || this;
|
3316
|
+
var className,
|
3317
|
+
o = that.options;
|
3318
|
+
|
3319
|
+
if(!o.placeholder || o.placeholder.constructor === String) {
|
3320
|
+
className = o.placeholder;
|
3321
|
+
o.placeholder = {
|
3322
|
+
element: function() {
|
3323
|
+
|
3324
|
+
var nodeName = that.currentItem[0].nodeName.toLowerCase(),
|
3325
|
+
element = $( "<" + nodeName + ">", that.document[0] )
|
3326
|
+
.addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
|
3327
|
+
.removeClass("ui-sortable-helper");
|
3328
|
+
|
3329
|
+
if ( nodeName === "tr" ) {
|
3330
|
+
that.currentItem.children().each(function() {
|
3331
|
+
$( "<td> </td>", that.document[0] )
|
3332
|
+
.attr( "colspan", $( this ).attr( "colspan" ) || 1 )
|
3333
|
+
.appendTo( element );
|
3334
|
+
});
|
3335
|
+
} else if ( nodeName === "img" ) {
|
3336
|
+
element.attr( "src", that.currentItem.attr( "src" ) );
|
3337
|
+
}
|
3338
|
+
|
3339
|
+
if ( !className ) {
|
3340
|
+
element.css( "visibility", "hidden" );
|
3341
|
+
}
|
3342
|
+
|
3343
|
+
return element;
|
3344
|
+
},
|
3345
|
+
update: function(container, p) {
|
3346
|
+
|
3347
|
+
// 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
|
3348
|
+
// 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
|
3349
|
+
if(className && !o.forcePlaceholderSize) {
|
3350
|
+
return;
|
3351
|
+
}
|
3352
|
+
|
3353
|
+
//If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
|
3354
|
+
if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
|
3355
|
+
if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
|
3356
|
+
}
|
3357
|
+
};
|
3358
|
+
}
|
3359
|
+
|
3360
|
+
//Create the placeholder
|
3361
|
+
that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
|
3362
|
+
|
3363
|
+
//Append it after the actual current item
|
3364
|
+
that.currentItem.after(that.placeholder);
|
3365
|
+
|
3366
|
+
//Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
|
3367
|
+
o.placeholder.update(that, that.placeholder);
|
3368
|
+
|
3369
|
+
},
|
3370
|
+
|
3371
|
+
_contactContainers: function(event) {
|
3372
|
+
var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
|
3373
|
+
innermostContainer = null,
|
3374
|
+
innermostIndex = null;
|
3375
|
+
|
3376
|
+
// get innermost container that intersects with item
|
3377
|
+
for (i = this.containers.length - 1; i >= 0; i--) {
|
3378
|
+
|
3379
|
+
// never consider a container that's located within the item itself
|
3380
|
+
if($.contains(this.currentItem[0], this.containers[i].element[0])) {
|
3381
|
+
continue;
|
3382
|
+
}
|
3383
|
+
|
3384
|
+
if(this._intersectsWith(this.containers[i].containerCache)) {
|
3385
|
+
|
3386
|
+
// if we've already found a container and it's more "inner" than this, then continue
|
3387
|
+
if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
|
3388
|
+
continue;
|
3389
|
+
}
|
3390
|
+
|
3391
|
+
innermostContainer = this.containers[i];
|
3392
|
+
innermostIndex = i;
|
3393
|
+
|
3394
|
+
} else {
|
3395
|
+
// container doesn't intersect. trigger "out" event if necessary
|
3396
|
+
if(this.containers[i].containerCache.over) {
|
3397
|
+
this.containers[i]._trigger("out", event, this._uiHash(this));
|
3398
|
+
this.containers[i].containerCache.over = 0;
|
3399
|
+
}
|
3400
|
+
}
|
3401
|
+
|
3402
|
+
}
|
3403
|
+
|
3404
|
+
// if no intersecting containers found, return
|
3405
|
+
if(!innermostContainer) {
|
3406
|
+
return;
|
3407
|
+
}
|
3408
|
+
|
3409
|
+
// move the item into the container if it's not there already
|
3410
|
+
if(this.containers.length === 1) {
|
3411
|
+
if (!this.containers[innermostIndex].containerCache.over) {
|
3412
|
+
this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
|
3413
|
+
this.containers[innermostIndex].containerCache.over = 1;
|
3414
|
+
}
|
3415
|
+
} else {
|
3416
|
+
|
3417
|
+
//When entering a new container, we will find the item with the least distance and append our item near it
|
3418
|
+
dist = 10000;
|
3419
|
+
itemWithLeastDistance = null;
|
3420
|
+
floating = innermostContainer.floating || this._isFloating(this.currentItem);
|
3421
|
+
posProperty = floating ? "left" : "top";
|
3422
|
+
sizeProperty = floating ? "width" : "height";
|
3423
|
+
axis = floating ? "clientX" : "clientY";
|
3424
|
+
|
3425
|
+
for (j = this.items.length - 1; j >= 0; j--) {
|
3426
|
+
if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
|
3427
|
+
continue;
|
3428
|
+
}
|
3429
|
+
if(this.items[j].item[0] === this.currentItem[0]) {
|
3430
|
+
continue;
|
3431
|
+
}
|
3432
|
+
|
3433
|
+
cur = this.items[j].item.offset()[posProperty];
|
3434
|
+
nearBottom = false;
|
3435
|
+
if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
|
3436
|
+
nearBottom = true;
|
3437
|
+
}
|
3438
|
+
|
3439
|
+
if ( Math.abs( event[ axis ] - cur ) < dist ) {
|
3440
|
+
dist = Math.abs( event[ axis ] - cur );
|
3441
|
+
itemWithLeastDistance = this.items[ j ];
|
3442
|
+
this.direction = nearBottom ? "up": "down";
|
3443
|
+
}
|
3444
|
+
}
|
3445
|
+
|
3446
|
+
//Check if dropOnEmpty is enabled
|
3447
|
+
if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
|
3448
|
+
return;
|
3449
|
+
}
|
3450
|
+
|
3451
|
+
if(this.currentContainer === this.containers[innermostIndex]) {
|
3452
|
+
if ( !this.currentContainer.containerCache.over ) {
|
3453
|
+
this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
|
3454
|
+
this.currentContainer.containerCache.over = 1;
|
3455
|
+
}
|
3456
|
+
return;
|
3457
|
+
}
|
3458
|
+
|
3459
|
+
itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
|
3460
|
+
this._trigger("change", event, this._uiHash());
|
3461
|
+
this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
|
3462
|
+
this.currentContainer = this.containers[innermostIndex];
|
3463
|
+
|
3464
|
+
//Update the placeholder
|
3465
|
+
this.options.placeholder.update(this.currentContainer, this.placeholder);
|
3466
|
+
|
3467
|
+
this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
|
3468
|
+
this.containers[innermostIndex].containerCache.over = 1;
|
3469
|
+
}
|
3470
|
+
|
3471
|
+
|
3472
|
+
},
|
3473
|
+
|
3474
|
+
_createHelper: function(event) {
|
3475
|
+
|
3476
|
+
var o = this.options,
|
3477
|
+
helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
|
3478
|
+
|
3479
|
+
//Add the helper to the DOM if that didn't happen already
|
3480
|
+
if(!helper.parents("body").length) {
|
3481
|
+
$(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
|
3482
|
+
}
|
3483
|
+
|
3484
|
+
if(helper[0] === this.currentItem[0]) {
|
3485
|
+
this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
|
3486
|
+
}
|
3487
|
+
|
3488
|
+
if(!helper[0].style.width || o.forceHelperSize) {
|
3489
|
+
helper.width(this.currentItem.width());
|
3490
|
+
}
|
3491
|
+
if(!helper[0].style.height || o.forceHelperSize) {
|
3492
|
+
helper.height(this.currentItem.height());
|
3493
|
+
}
|
3494
|
+
|
3495
|
+
return helper;
|
3496
|
+
|
3497
|
+
},
|
3498
|
+
|
3499
|
+
_adjustOffsetFromHelper: function(obj) {
|
3500
|
+
if (typeof obj === "string") {
|
3501
|
+
obj = obj.split(" ");
|
3502
|
+
}
|
3503
|
+
if ($.isArray(obj)) {
|
3504
|
+
obj = {left: +obj[0], top: +obj[1] || 0};
|
3505
|
+
}
|
3506
|
+
if ("left" in obj) {
|
3507
|
+
this.offset.click.left = obj.left + this.margins.left;
|
3508
|
+
}
|
3509
|
+
if ("right" in obj) {
|
3510
|
+
this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
|
3511
|
+
}
|
3512
|
+
if ("top" in obj) {
|
3513
|
+
this.offset.click.top = obj.top + this.margins.top;
|
3514
|
+
}
|
3515
|
+
if ("bottom" in obj) {
|
3516
|
+
this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
|
3517
|
+
}
|
3518
|
+
},
|
3519
|
+
|
3520
|
+
_getParentOffset: function() {
|
3521
|
+
|
3522
|
+
|
3523
|
+
//Get the offsetParent and cache its position
|
3524
|
+
this.offsetParent = this.helper.offsetParent();
|
3525
|
+
var po = this.offsetParent.offset();
|
3526
|
+
|
3527
|
+
// This is a special case where we need to modify a offset calculated on start, since the following happened:
|
3528
|
+
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
|
3529
|
+
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
|
3530
|
+
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
|
3531
|
+
if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
|
3532
|
+
po.left += this.scrollParent.scrollLeft();
|
3533
|
+
po.top += this.scrollParent.scrollTop();
|
3534
|
+
}
|
3535
|
+
|
3536
|
+
// This needs to be actually done for all browsers, since pageX/pageY includes this information
|
3537
|
+
// with an ugly IE fix
|
3538
|
+
if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
|
3539
|
+
po = { top: 0, left: 0 };
|
3540
|
+
}
|
3541
|
+
|
3542
|
+
return {
|
3543
|
+
top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
|
3544
|
+
left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
|
3545
|
+
};
|
3546
|
+
|
3547
|
+
},
|
3548
|
+
|
3549
|
+
_getRelativeOffset: function() {
|
3550
|
+
|
3551
|
+
if(this.cssPosition === "relative") {
|
3552
|
+
var p = this.currentItem.position();
|
3553
|
+
return {
|
3554
|
+
top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
|
3555
|
+
left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
|
3556
|
+
};
|
3557
|
+
} else {
|
3558
|
+
return { top: 0, left: 0 };
|
3559
|
+
}
|
3560
|
+
|
3561
|
+
},
|
3562
|
+
|
3563
|
+
_cacheMargins: function() {
|
3564
|
+
this.margins = {
|
3565
|
+
left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
|
3566
|
+
top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
|
3567
|
+
};
|
3568
|
+
},
|
3569
|
+
|
3570
|
+
_cacheHelperProportions: function() {
|
3571
|
+
this.helperProportions = {
|
3572
|
+
width: this.helper.outerWidth(),
|
3573
|
+
height: this.helper.outerHeight()
|
3574
|
+
};
|
3575
|
+
},
|
3576
|
+
|
3577
|
+
_setContainment: function() {
|
3578
|
+
|
3579
|
+
var ce, co, over,
|
3580
|
+
o = this.options;
|
3581
|
+
if(o.containment === "parent") {
|
3582
|
+
o.containment = this.helper[0].parentNode;
|
3583
|
+
}
|
3584
|
+
if(o.containment === "document" || o.containment === "window") {
|
3585
|
+
this.containment = [
|
3586
|
+
0 - this.offset.relative.left - this.offset.parent.left,
|
3587
|
+
0 - this.offset.relative.top - this.offset.parent.top,
|
3588
|
+
$(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
|
3589
|
+
($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
|
3590
|
+
];
|
3591
|
+
}
|
3592
|
+
|
3593
|
+
if(!(/^(document|window|parent)$/).test(o.containment)) {
|
3594
|
+
ce = $(o.containment)[0];
|
3595
|
+
co = $(o.containment).offset();
|
3596
|
+
over = ($(ce).css("overflow") !== "hidden");
|
3597
|
+
|
3598
|
+
this.containment = [
|
3599
|
+
co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
|
3600
|
+
co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
|
3601
|
+
co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
|
3602
|
+
co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
|
3603
|
+
];
|
3604
|
+
}
|
3605
|
+
|
3606
|
+
},
|
3607
|
+
|
3608
|
+
_convertPositionTo: function(d, pos) {
|
3609
|
+
|
3610
|
+
if(!pos) {
|
3611
|
+
pos = this.position;
|
3612
|
+
}
|
3613
|
+
var mod = d === "absolute" ? 1 : -1,
|
3614
|
+
scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
|
3615
|
+
scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
|
3616
|
+
|
3617
|
+
return {
|
3618
|
+
top: (
|
3619
|
+
pos.top + // The absolute mouse position
|
3620
|
+
this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
|
3621
|
+
this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
|
3622
|
+
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
|
3623
|
+
),
|
3624
|
+
left: (
|
3625
|
+
pos.left + // The absolute mouse position
|
3626
|
+
this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
|
3627
|
+
this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
|
3628
|
+
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
|
3629
|
+
)
|
3630
|
+
};
|
3631
|
+
|
3632
|
+
},
|
3633
|
+
|
3634
|
+
_generatePosition: function(event) {
|
3635
|
+
|
3636
|
+
var top, left,
|
3637
|
+
o = this.options,
|
3638
|
+
pageX = event.pageX,
|
3639
|
+
pageY = event.pageY,
|
3640
|
+
scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
|
3641
|
+
|
3642
|
+
// This is another very weird special case that only happens for relative elements:
|
3643
|
+
// 1. If the css position is relative
|
3644
|
+
// 2. and the scroll parent is the document or similar to the offset parent
|
3645
|
+
// we have to refresh the relative offset during the scroll so there are no jumps
|
3646
|
+
if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
|
3647
|
+
this.offset.relative = this._getRelativeOffset();
|
3648
|
+
}
|
3649
|
+
|
3650
|
+
/*
|
3651
|
+
* - Position constraining -
|
3652
|
+
* Constrain the position to a mix of grid, containment.
|
3653
|
+
*/
|
3654
|
+
|
3655
|
+
if(this.originalPosition) { //If we are not dragging yet, we won't check for options
|
3656
|
+
|
3657
|
+
if(this.containment) {
|
3658
|
+
if(event.pageX - this.offset.click.left < this.containment[0]) {
|
3659
|
+
pageX = this.containment[0] + this.offset.click.left;
|
3660
|
+
}
|
3661
|
+
if(event.pageY - this.offset.click.top < this.containment[1]) {
|
3662
|
+
pageY = this.containment[1] + this.offset.click.top;
|
3663
|
+
}
|
3664
|
+
if(event.pageX - this.offset.click.left > this.containment[2]) {
|
3665
|
+
pageX = this.containment[2] + this.offset.click.left;
|
3666
|
+
}
|
3667
|
+
if(event.pageY - this.offset.click.top > this.containment[3]) {
|
3668
|
+
pageY = this.containment[3] + this.offset.click.top;
|
3669
|
+
}
|
3670
|
+
}
|
3671
|
+
|
3672
|
+
if(o.grid) {
|
3673
|
+
top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
|
3674
|
+
pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
|
3675
|
+
|
3676
|
+
left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
|
3677
|
+
pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
|
3678
|
+
}
|
3679
|
+
|
3680
|
+
}
|
3681
|
+
|
3682
|
+
return {
|
3683
|
+
top: (
|
3684
|
+
pageY - // The absolute mouse position
|
3685
|
+
this.offset.click.top - // Click offset (relative to the element)
|
3686
|
+
this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
|
3687
|
+
this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
|
3688
|
+
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
|
3689
|
+
),
|
3690
|
+
left: (
|
3691
|
+
pageX - // The absolute mouse position
|
3692
|
+
this.offset.click.left - // Click offset (relative to the element)
|
3693
|
+
this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
|
3694
|
+
this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
|
3695
|
+
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
|
3696
|
+
)
|
3697
|
+
};
|
3698
|
+
|
3699
|
+
},
|
3700
|
+
|
3701
|
+
_rearrange: function(event, i, a, hardRefresh) {
|
3702
|
+
|
3703
|
+
a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling));
|
3704
|
+
|
3705
|
+
//Various things done here to improve the performance:
|
3706
|
+
// 1. we create a setTimeout, that calls refreshPositions
|
3707
|
+
// 2. on the instance, we have a counter variable, that get's higher after every append
|
3708
|
+
// 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
|
3709
|
+
// 4. this lets only the last addition to the timeout stack through
|
3710
|
+
this.counter = this.counter ? ++this.counter : 1;
|
3711
|
+
var counter = this.counter;
|
3712
|
+
|
3713
|
+
this._delay(function() {
|
3714
|
+
if(counter === this.counter) {
|
3715
|
+
this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
|
3716
|
+
}
|
3717
|
+
});
|
3718
|
+
|
3719
|
+
},
|
3720
|
+
|
3721
|
+
_clear: function(event, noPropagation) {
|
3722
|
+
|
3723
|
+
this.reverting = false;
|
3724
|
+
// We delay all events that have to be triggered to after the point where the placeholder has been removed and
|
3725
|
+
// everything else normalized again
|
3726
|
+
var i,
|
3727
|
+
delayedTriggers = [];
|
3728
|
+
|
3729
|
+
// We first have to update the dom position of the actual currentItem
|
3730
|
+
// Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
|
3731
|
+
if(!this._noFinalSort && this.currentItem.parent().length) {
|
3732
|
+
this.placeholder.before(this.currentItem);
|
3733
|
+
}
|
3734
|
+
this._noFinalSort = null;
|
3735
|
+
|
3736
|
+
if(this.helper[0] === this.currentItem[0]) {
|
3737
|
+
for(i in this._storedCSS) {
|
3738
|
+
if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
|
3739
|
+
this._storedCSS[i] = "";
|
3740
|
+
}
|
3741
|
+
}
|
3742
|
+
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
|
3743
|
+
} else {
|
3744
|
+
this.currentItem.show();
|
3745
|
+
}
|
3746
|
+
|
3747
|
+
if(this.fromOutside && !noPropagation) {
|
3748
|
+
delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
|
3749
|
+
}
|
3750
|
+
if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
|
3751
|
+
delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
|
3752
|
+
}
|
3753
|
+
|
3754
|
+
// Check if the items Container has Changed and trigger appropriate
|
3755
|
+
// events.
|
3756
|
+
if (this !== this.currentContainer) {
|
3757
|
+
if(!noPropagation) {
|
3758
|
+
delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
|
3759
|
+
delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
|
3760
|
+
delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
|
3761
|
+
}
|
3762
|
+
}
|
3763
|
+
|
3764
|
+
|
3765
|
+
//Post events to containers
|
3766
|
+
function delayEvent( type, instance, container ) {
|
3767
|
+
return function( event ) {
|
3768
|
+
container._trigger( type, event, instance._uiHash( instance ) );
|
3769
|
+
};
|
3770
|
+
}
|
3771
|
+
for (i = this.containers.length - 1; i >= 0; i--){
|
3772
|
+
if (!noPropagation) {
|
3773
|
+
delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
|
3774
|
+
}
|
3775
|
+
if(this.containers[i].containerCache.over) {
|
3776
|
+
delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
|
3777
|
+
this.containers[i].containerCache.over = 0;
|
3778
|
+
}
|
3779
|
+
}
|
3780
|
+
|
3781
|
+
//Do what was originally in plugins
|
3782
|
+
if ( this.storedCursor ) {
|
3783
|
+
this.document.find( "body" ).css( "cursor", this.storedCursor );
|
3784
|
+
this.storedStylesheet.remove();
|
3785
|
+
}
|
3786
|
+
if(this._storedOpacity) {
|
3787
|
+
this.helper.css("opacity", this._storedOpacity);
|
3788
|
+
}
|
3789
|
+
if(this._storedZIndex) {
|
3790
|
+
this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
|
3791
|
+
}
|
3792
|
+
|
3793
|
+
this.dragging = false;
|
3794
|
+
|
3795
|
+
if(!noPropagation) {
|
3796
|
+
this._trigger("beforeStop", event, this._uiHash());
|
3797
|
+
}
|
3798
|
+
|
3799
|
+
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
|
3800
|
+
this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
|
3801
|
+
|
3802
|
+
if ( !this.cancelHelperRemoval ) {
|
3803
|
+
if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
|
3804
|
+
this.helper.remove();
|
3805
|
+
}
|
3806
|
+
this.helper = null;
|
3807
|
+
}
|
3808
|
+
|
3809
|
+
if(!noPropagation) {
|
3810
|
+
for (i=0; i < delayedTriggers.length; i++) {
|
3811
|
+
delayedTriggers[i].call(this, event);
|
3812
|
+
} //Trigger all delayed events
|
3813
|
+
this._trigger("stop", event, this._uiHash());
|
3814
|
+
}
|
3815
|
+
|
3816
|
+
this.fromOutside = false;
|
3817
|
+
return !this.cancelHelperRemoval;
|
3818
|
+
|
3819
|
+
},
|
3820
|
+
|
3821
|
+
_trigger: function() {
|
3822
|
+
if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
|
3823
|
+
this.cancel();
|
3824
|
+
}
|
3825
|
+
},
|
3826
|
+
|
3827
|
+
_uiHash: function(_inst) {
|
3828
|
+
var inst = _inst || this;
|
3829
|
+
return {
|
3830
|
+
helper: inst.helper,
|
3831
|
+
placeholder: inst.placeholder || $([]),
|
3832
|
+
position: inst.position,
|
3833
|
+
originalPosition: inst.originalPosition,
|
3834
|
+
offset: inst.positionAbs,
|
3835
|
+
item: inst.currentItem,
|
3836
|
+
sender: _inst ? _inst.element : null
|
3837
|
+
};
|
3838
|
+
}
|
3839
|
+
|
3840
|
+
});
|
3841
|
+
|
3842
|
+
|
3843
|
+
|
3844
|
+
}));
|