You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

jquery-ui.js 96KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476
  1. /*! jQuery UI - v1.12.1 - 2018-11-27
  2. * http://jqueryui.com
  3. * Includes: widget.js, position.js, data.js, disable-selection.js, focusable.js, form-reset-mixin.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/sortable.js, widgets/mouse.js
  4. * Copyright jQuery Foundation and other contributors; Licensed MIT */
  5. (function( factory ) {
  6. if ( typeof define === "function" && define.amd ) {
  7. // AMD. Register as an anonymous module.
  8. define([ "jquery" ], factory );
  9. } else {
  10. // Browser globals
  11. factory( jQuery );
  12. }
  13. }(function( $ ) {
  14. $.ui = $.ui || {};
  15. var version = $.ui.version = "1.12.1";
  16. /*!
  17. * jQuery UI Widget 1.12.1
  18. * http://jqueryui.com
  19. *
  20. * Copyright jQuery Foundation and other contributors
  21. * Released under the MIT license.
  22. * http://jquery.org/license
  23. */
  24. //>>label: Widget
  25. //>>group: Core
  26. //>>description: Provides a factory for creating stateful widgets with a common API.
  27. //>>docs: http://api.jqueryui.com/jQuery.widget/
  28. //>>demos: http://jqueryui.com/widget/
  29. var widgetUuid = 0;
  30. var widgetSlice = Array.prototype.slice;
  31. $.cleanData = ( function( orig ) {
  32. return function( elems ) {
  33. var events, elem, i;
  34. for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) {
  35. try {
  36. // Only trigger remove when necessary to save time
  37. events = $._data( elem, "events" );
  38. if ( events && events.remove ) {
  39. $( elem ).triggerHandler( "remove" );
  40. }
  41. // Http://bugs.jquery.com/ticket/8235
  42. } catch ( e ) {}
  43. }
  44. orig( elems );
  45. };
  46. } )( $.cleanData );
  47. $.widget = function( name, base, prototype ) {
  48. var existingConstructor, constructor, basePrototype;
  49. // ProxiedPrototype allows the provided prototype to remain unmodified
  50. // so that it can be used as a mixin for multiple widgets (#8876)
  51. var proxiedPrototype = {};
  52. var namespace = name.split( "." )[ 0 ];
  53. name = name.split( "." )[ 1 ];
  54. var fullName = namespace + "-" + name;
  55. if ( !prototype ) {
  56. prototype = base;
  57. base = $.Widget;
  58. }
  59. if ( $.isArray( prototype ) ) {
  60. prototype = $.extend.apply( null, [ {} ].concat( prototype ) );
  61. }
  62. // Create selector for plugin
  63. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  64. return !!$.data( elem, fullName );
  65. };
  66. $[ namespace ] = $[ namespace ] || {};
  67. existingConstructor = $[ namespace ][ name ];
  68. constructor = $[ namespace ][ name ] = function( options, element ) {
  69. // Allow instantiation without "new" keyword
  70. if ( !this._createWidget ) {
  71. return new constructor( options, element );
  72. }
  73. // Allow instantiation without initializing for simple inheritance
  74. // must use "new" keyword (the code above always passes args)
  75. if ( arguments.length ) {
  76. this._createWidget( options, element );
  77. }
  78. };
  79. // Extend with the existing constructor to carry over any static properties
  80. $.extend( constructor, existingConstructor, {
  81. version: prototype.version,
  82. // Copy the object used to create the prototype in case we need to
  83. // redefine the widget later
  84. _proto: $.extend( {}, prototype ),
  85. // Track widgets that inherit from this widget in case this widget is
  86. // redefined after a widget inherits from it
  87. _childConstructors: []
  88. } );
  89. basePrototype = new base();
  90. // We need to make the options hash a property directly on the new instance
  91. // otherwise we'll modify the options hash on the prototype that we're
  92. // inheriting from
  93. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  94. $.each( prototype, function( prop, value ) {
  95. if ( !$.isFunction( value ) ) {
  96. proxiedPrototype[ prop ] = value;
  97. return;
  98. }
  99. proxiedPrototype[ prop ] = ( function() {
  100. function _super() {
  101. return base.prototype[ prop ].apply( this, arguments );
  102. }
  103. function _superApply( args ) {
  104. return base.prototype[ prop ].apply( this, args );
  105. }
  106. return function() {
  107. var __super = this._super;
  108. var __superApply = this._superApply;
  109. var returnValue;
  110. this._super = _super;
  111. this._superApply = _superApply;
  112. returnValue = value.apply( this, arguments );
  113. this._super = __super;
  114. this._superApply = __superApply;
  115. return returnValue;
  116. };
  117. } )();
  118. } );
  119. constructor.prototype = $.widget.extend( basePrototype, {
  120. // TODO: remove support for widgetEventPrefix
  121. // always use the name + a colon as the prefix, e.g., draggable:start
  122. // don't prefix for widgets that aren't DOM-based
  123. widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name
  124. }, proxiedPrototype, {
  125. constructor: constructor,
  126. namespace: namespace,
  127. widgetName: name,
  128. widgetFullName: fullName
  129. } );
  130. // If this widget is being redefined then we need to find all widgets that
  131. // are inheriting from it and redefine all of them so that they inherit from
  132. // the new version of this widget. We're essentially trying to replace one
  133. // level in the prototype chain.
  134. if ( existingConstructor ) {
  135. $.each( existingConstructor._childConstructors, function( i, child ) {
  136. var childPrototype = child.prototype;
  137. // Redefine the child widget using the same prototype that was
  138. // originally used, but inherit from the new version of the base
  139. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor,
  140. child._proto );
  141. } );
  142. // Remove the list of existing child constructors from the old constructor
  143. // so the old child constructors can be garbage collected
  144. delete existingConstructor._childConstructors;
  145. } else {
  146. base._childConstructors.push( constructor );
  147. }
  148. $.widget.bridge( name, constructor );
  149. return constructor;
  150. };
  151. $.widget.extend = function( target ) {
  152. var input = widgetSlice.call( arguments, 1 );
  153. var inputIndex = 0;
  154. var inputLength = input.length;
  155. var key;
  156. var value;
  157. for ( ; inputIndex < inputLength; inputIndex++ ) {
  158. for ( key in input[ inputIndex ] ) {
  159. value = input[ inputIndex ][ key ];
  160. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  161. // Clone objects
  162. if ( $.isPlainObject( value ) ) {
  163. target[ key ] = $.isPlainObject( target[ key ] ) ?
  164. $.widget.extend( {}, target[ key ], value ) :
  165. // Don't extend strings, arrays, etc. with objects
  166. $.widget.extend( {}, value );
  167. // Copy everything else by reference
  168. } else {
  169. target[ key ] = value;
  170. }
  171. }
  172. }
  173. }
  174. return target;
  175. };
  176. $.widget.bridge = function( name, object ) {
  177. var fullName = object.prototype.widgetFullName || name;
  178. $.fn[ name ] = function( options ) {
  179. var isMethodCall = typeof options === "string";
  180. var args = widgetSlice.call( arguments, 1 );
  181. var returnValue = this;
  182. if ( isMethodCall ) {
  183. // If this is an empty collection, we need to have the instance method
  184. // return undefined instead of the jQuery instance
  185. if ( !this.length && options === "instance" ) {
  186. returnValue = undefined;
  187. } else {
  188. this.each( function() {
  189. var methodValue;
  190. var instance = $.data( this, fullName );
  191. if ( options === "instance" ) {
  192. returnValue = instance;
  193. return false;
  194. }
  195. if ( !instance ) {
  196. return $.error( "cannot call methods on " + name +
  197. " prior to initialization; " +
  198. "attempted to call method '" + options + "'" );
  199. }
  200. if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) {
  201. return $.error( "no such method '" + options + "' for " + name +
  202. " widget instance" );
  203. }
  204. methodValue = instance[ options ].apply( instance, args );
  205. if ( methodValue !== instance && methodValue !== undefined ) {
  206. returnValue = methodValue && methodValue.jquery ?
  207. returnValue.pushStack( methodValue.get() ) :
  208. methodValue;
  209. return false;
  210. }
  211. } );
  212. }
  213. } else {
  214. // Allow multiple hashes to be passed on init
  215. if ( args.length ) {
  216. options = $.widget.extend.apply( null, [ options ].concat( args ) );
  217. }
  218. this.each( function() {
  219. var instance = $.data( this, fullName );
  220. if ( instance ) {
  221. instance.option( options || {} );
  222. if ( instance._init ) {
  223. instance._init();
  224. }
  225. } else {
  226. $.data( this, fullName, new object( options, this ) );
  227. }
  228. } );
  229. }
  230. return returnValue;
  231. };
  232. };
  233. $.Widget = function( /* options, element */ ) {};
  234. $.Widget._childConstructors = [];
  235. $.Widget.prototype = {
  236. widgetName: "widget",
  237. widgetEventPrefix: "",
  238. defaultElement: "<div>",
  239. options: {
  240. classes: {},
  241. disabled: false,
  242. // Callbacks
  243. create: null
  244. },
  245. _createWidget: function( options, element ) {
  246. element = $( element || this.defaultElement || this )[ 0 ];
  247. this.element = $( element );
  248. this.uuid = widgetUuid++;
  249. this.eventNamespace = "." + this.widgetName + this.uuid;
  250. this.bindings = $();
  251. this.hoverable = $();
  252. this.focusable = $();
  253. this.classesElementLookup = {};
  254. if ( element !== this ) {
  255. $.data( element, this.widgetFullName, this );
  256. this._on( true, this.element, {
  257. remove: function( event ) {
  258. if ( event.target === element ) {
  259. this.destroy();
  260. }
  261. }
  262. } );
  263. this.document = $( element.style ?
  264. // Element within the document
  265. element.ownerDocument :
  266. // Element is window or document
  267. element.document || element );
  268. this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow );
  269. }
  270. this.options = $.widget.extend( {},
  271. this.options,
  272. this._getCreateOptions(),
  273. options );
  274. this._create();
  275. if ( this.options.disabled ) {
  276. this._setOptionDisabled( this.options.disabled );
  277. }
  278. this._trigger( "create", null, this._getCreateEventData() );
  279. this._init();
  280. },
  281. _getCreateOptions: function() {
  282. return {};
  283. },
  284. _getCreateEventData: $.noop,
  285. _create: $.noop,
  286. _init: $.noop,
  287. destroy: function() {
  288. var that = this;
  289. this._destroy();
  290. $.each( this.classesElementLookup, function( key, value ) {
  291. that._removeClass( value, key );
  292. } );
  293. // We can probably remove the unbind calls in 2.0
  294. // all event bindings should go through this._on()
  295. this.element
  296. .off( this.eventNamespace )
  297. .removeData( this.widgetFullName );
  298. this.widget()
  299. .off( this.eventNamespace )
  300. .removeAttr( "aria-disabled" );
  301. // Clean up events and states
  302. this.bindings.off( this.eventNamespace );
  303. },
  304. _destroy: $.noop,
  305. widget: function() {
  306. return this.element;
  307. },
  308. option: function( key, value ) {
  309. var options = key;
  310. var parts;
  311. var curOption;
  312. var i;
  313. if ( arguments.length === 0 ) {
  314. // Don't return a reference to the internal hash
  315. return $.widget.extend( {}, this.options );
  316. }
  317. if ( typeof key === "string" ) {
  318. // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  319. options = {};
  320. parts = key.split( "." );
  321. key = parts.shift();
  322. if ( parts.length ) {
  323. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  324. for ( i = 0; i < parts.length - 1; i++ ) {
  325. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  326. curOption = curOption[ parts[ i ] ];
  327. }
  328. key = parts.pop();
  329. if ( arguments.length === 1 ) {
  330. return curOption[ key ] === undefined ? null : curOption[ key ];
  331. }
  332. curOption[ key ] = value;
  333. } else {
  334. if ( arguments.length === 1 ) {
  335. return this.options[ key ] === undefined ? null : this.options[ key ];
  336. }
  337. options[ key ] = value;
  338. }
  339. }
  340. this._setOptions( options );
  341. return this;
  342. },
  343. _setOptions: function( options ) {
  344. var key;
  345. for ( key in options ) {
  346. this._setOption( key, options[ key ] );
  347. }
  348. return this;
  349. },
  350. _setOption: function( key, value ) {
  351. if ( key === "classes" ) {
  352. this._setOptionClasses( value );
  353. }
  354. this.options[ key ] = value;
  355. if ( key === "disabled" ) {
  356. this._setOptionDisabled( value );
  357. }
  358. return this;
  359. },
  360. _setOptionClasses: function( value ) {
  361. var classKey, elements, currentElements;
  362. for ( classKey in value ) {
  363. currentElements = this.classesElementLookup[ classKey ];
  364. if ( value[ classKey ] === this.options.classes[ classKey ] ||
  365. !currentElements ||
  366. !currentElements.length ) {
  367. continue;
  368. }
  369. // We are doing this to create a new jQuery object because the _removeClass() call
  370. // on the next line is going to destroy the reference to the current elements being
  371. // tracked. We need to save a copy of this collection so that we can add the new classes
  372. // below.
  373. elements = $( currentElements.get() );
  374. this._removeClass( currentElements, classKey );
  375. // We don't use _addClass() here, because that uses this.options.classes
  376. // for generating the string of classes. We want to use the value passed in from
  377. // _setOption(), this is the new value of the classes option which was passed to
  378. // _setOption(). We pass this value directly to _classes().
  379. elements.addClass( this._classes( {
  380. element: elements,
  381. keys: classKey,
  382. classes: value,
  383. add: true
  384. } ) );
  385. }
  386. },
  387. _setOptionDisabled: function( value ) {
  388. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value );
  389. // If the widget is becoming disabled, then nothing is interactive
  390. if ( value ) {
  391. this._removeClass( this.hoverable, null, "ui-state-hover" );
  392. this._removeClass( this.focusable, null, "ui-state-focus" );
  393. }
  394. },
  395. enable: function() {
  396. return this._setOptions( { disabled: false } );
  397. },
  398. disable: function() {
  399. return this._setOptions( { disabled: true } );
  400. },
  401. _classes: function( options ) {
  402. var full = [];
  403. var that = this;
  404. options = $.extend( {
  405. element: this.element,
  406. classes: this.options.classes || {}
  407. }, options );
  408. function processClassString( classes, checkOption ) {
  409. var current, i;
  410. for ( i = 0; i < classes.length; i++ ) {
  411. current = that.classesElementLookup[ classes[ i ] ] || $();
  412. if ( options.add ) {
  413. current = $( $.unique( current.get().concat( options.element.get() ) ) );
  414. } else {
  415. current = $( current.not( options.element ).get() );
  416. }
  417. that.classesElementLookup[ classes[ i ] ] = current;
  418. full.push( classes[ i ] );
  419. if ( checkOption && options.classes[ classes[ i ] ] ) {
  420. full.push( options.classes[ classes[ i ] ] );
  421. }
  422. }
  423. }
  424. this._on( options.element, {
  425. "remove": "_untrackClassesElement"
  426. } );
  427. if ( options.keys ) {
  428. processClassString( options.keys.match( /\S+/g ) || [], true );
  429. }
  430. if ( options.extra ) {
  431. processClassString( options.extra.match( /\S+/g ) || [] );
  432. }
  433. return full.join( " " );
  434. },
  435. _untrackClassesElement: function( event ) {
  436. var that = this;
  437. $.each( that.classesElementLookup, function( key, value ) {
  438. if ( $.inArray( event.target, value ) !== -1 ) {
  439. that.classesElementLookup[ key ] = $( value.not( event.target ).get() );
  440. }
  441. } );
  442. },
  443. _removeClass: function( element, keys, extra ) {
  444. return this._toggleClass( element, keys, extra, false );
  445. },
  446. _addClass: function( element, keys, extra ) {
  447. return this._toggleClass( element, keys, extra, true );
  448. },
  449. _toggleClass: function( element, keys, extra, add ) {
  450. add = ( typeof add === "boolean" ) ? add : extra;
  451. var shift = ( typeof element === "string" || element === null ),
  452. options = {
  453. extra: shift ? keys : extra,
  454. keys: shift ? element : keys,
  455. element: shift ? this.element : element,
  456. add: add
  457. };
  458. options.element.toggleClass( this._classes( options ), add );
  459. return this;
  460. },
  461. _on: function( suppressDisabledCheck, element, handlers ) {
  462. var delegateElement;
  463. var instance = this;
  464. // No suppressDisabledCheck flag, shuffle arguments
  465. if ( typeof suppressDisabledCheck !== "boolean" ) {
  466. handlers = element;
  467. element = suppressDisabledCheck;
  468. suppressDisabledCheck = false;
  469. }
  470. // No element argument, shuffle and use this.element
  471. if ( !handlers ) {
  472. handlers = element;
  473. element = this.element;
  474. delegateElement = this.widget();
  475. } else {
  476. element = delegateElement = $( element );
  477. this.bindings = this.bindings.add( element );
  478. }
  479. $.each( handlers, function( event, handler ) {
  480. function handlerProxy() {
  481. // Allow widgets to customize the disabled handling
  482. // - disabled as an array instead of boolean
  483. // - disabled class as method for disabling individual parts
  484. if ( !suppressDisabledCheck &&
  485. ( instance.options.disabled === true ||
  486. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  487. return;
  488. }
  489. return ( typeof handler === "string" ? instance[ handler ] : handler )
  490. .apply( instance, arguments );
  491. }
  492. // Copy the guid so direct unbinding works
  493. if ( typeof handler !== "string" ) {
  494. handlerProxy.guid = handler.guid =
  495. handler.guid || handlerProxy.guid || $.guid++;
  496. }
  497. var match = event.match( /^([\w:-]*)\s*(.*)$/ );
  498. var eventName = match[ 1 ] + instance.eventNamespace;
  499. var selector = match[ 2 ];
  500. if ( selector ) {
  501. delegateElement.on( eventName, selector, handlerProxy );
  502. } else {
  503. element.on( eventName, handlerProxy );
  504. }
  505. } );
  506. },
  507. _off: function( element, eventName ) {
  508. eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) +
  509. this.eventNamespace;
  510. element.off( eventName ).off( eventName );
  511. // Clear the stack to avoid memory leaks (#10056)
  512. this.bindings = $( this.bindings.not( element ).get() );
  513. this.focusable = $( this.focusable.not( element ).get() );
  514. this.hoverable = $( this.hoverable.not( element ).get() );
  515. },
  516. _delay: function( handler, delay ) {
  517. function handlerProxy() {
  518. return ( typeof handler === "string" ? instance[ handler ] : handler )
  519. .apply( instance, arguments );
  520. }
  521. var instance = this;
  522. return setTimeout( handlerProxy, delay || 0 );
  523. },
  524. _hoverable: function( element ) {
  525. this.hoverable = this.hoverable.add( element );
  526. this._on( element, {
  527. mouseenter: function( event ) {
  528. this._addClass( $( event.currentTarget ), null, "ui-state-hover" );
  529. },
  530. mouseleave: function( event ) {
  531. this._removeClass( $( event.currentTarget ), null, "ui-state-hover" );
  532. }
  533. } );
  534. },
  535. _focusable: function( element ) {
  536. this.focusable = this.focusable.add( element );
  537. this._on( element, {
  538. focusin: function( event ) {
  539. this._addClass( $( event.currentTarget ), null, "ui-state-focus" );
  540. },
  541. focusout: function( event ) {
  542. this._removeClass( $( event.currentTarget ), null, "ui-state-focus" );
  543. }
  544. } );
  545. },
  546. _trigger: function( type, event, data ) {
  547. var prop, orig;
  548. var callback = this.options[ type ];
  549. data = data || {};
  550. event = $.Event( event );
  551. event.type = ( type === this.widgetEventPrefix ?
  552. type :
  553. this.widgetEventPrefix + type ).toLowerCase();
  554. // The original event may come from any element
  555. // so we need to reset the target on the new event
  556. event.target = this.element[ 0 ];
  557. // Copy original event properties over to the new event
  558. orig = event.originalEvent;
  559. if ( orig ) {
  560. for ( prop in orig ) {
  561. if ( !( prop in event ) ) {
  562. event[ prop ] = orig[ prop ];
  563. }
  564. }
  565. }
  566. this.element.trigger( event, data );
  567. return !( $.isFunction( callback ) &&
  568. callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false ||
  569. event.isDefaultPrevented() );
  570. }
  571. };
  572. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  573. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  574. if ( typeof options === "string" ) {
  575. options = { effect: options };
  576. }
  577. var hasOptions;
  578. var effectName = !options ?
  579. method :
  580. options === true || typeof options === "number" ?
  581. defaultEffect :
  582. options.effect || defaultEffect;
  583. options = options || {};
  584. if ( typeof options === "number" ) {
  585. options = { duration: options };
  586. }
  587. hasOptions = !$.isEmptyObject( options );
  588. options.complete = callback;
  589. if ( options.delay ) {
  590. element.delay( options.delay );
  591. }
  592. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  593. element[ method ]( options );
  594. } else if ( effectName !== method && element[ effectName ] ) {
  595. element[ effectName ]( options.duration, options.easing, callback );
  596. } else {
  597. element.queue( function( next ) {
  598. $( this )[ method ]();
  599. if ( callback ) {
  600. callback.call( element[ 0 ] );
  601. }
  602. next();
  603. } );
  604. }
  605. };
  606. } );
  607. var widget = $.widget;
  608. /*!
  609. * jQuery UI Position 1.12.1
  610. * http://jqueryui.com
  611. *
  612. * Copyright jQuery Foundation and other contributors
  613. * Released under the MIT license.
  614. * http://jquery.org/license
  615. *
  616. * http://api.jqueryui.com/position/
  617. */
  618. //>>label: Position
  619. //>>group: Core
  620. //>>description: Positions elements relative to other elements.
  621. //>>docs: http://api.jqueryui.com/position/
  622. //>>demos: http://jqueryui.com/position/
  623. ( function() {
  624. var cachedScrollbarWidth,
  625. max = Math.max,
  626. abs = Math.abs,
  627. rhorizontal = /left|center|right/,
  628. rvertical = /top|center|bottom/,
  629. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  630. rposition = /^\w+/,
  631. rpercent = /%$/,
  632. _position = $.fn.position;
  633. function getOffsets( offsets, width, height ) {
  634. return [
  635. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  636. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  637. ];
  638. }
  639. function parseCss( element, property ) {
  640. return parseInt( $.css( element, property ), 10 ) || 0;
  641. }
  642. function getDimensions( elem ) {
  643. var raw = elem[ 0 ];
  644. if ( raw.nodeType === 9 ) {
  645. return {
  646. width: elem.width(),
  647. height: elem.height(),
  648. offset: { top: 0, left: 0 }
  649. };
  650. }
  651. if ( $.isWindow( raw ) ) {
  652. return {
  653. width: elem.width(),
  654. height: elem.height(),
  655. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  656. };
  657. }
  658. if ( raw.preventDefault ) {
  659. return {
  660. width: 0,
  661. height: 0,
  662. offset: { top: raw.pageY, left: raw.pageX }
  663. };
  664. }
  665. return {
  666. width: elem.outerWidth(),
  667. height: elem.outerHeight(),
  668. offset: elem.offset()
  669. };
  670. }
  671. $.position = {
  672. scrollbarWidth: function() {
  673. if ( cachedScrollbarWidth !== undefined ) {
  674. return cachedScrollbarWidth;
  675. }
  676. var w1, w2,
  677. div = $( "<div " +
  678. "style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'>" +
  679. "<div style='height:100px;width:auto;'></div></div>" ),
  680. innerDiv = div.children()[ 0 ];
  681. $( "body" ).append( div );
  682. w1 = innerDiv.offsetWidth;
  683. div.css( "overflow", "scroll" );
  684. w2 = innerDiv.offsetWidth;
  685. if ( w1 === w2 ) {
  686. w2 = div[ 0 ].clientWidth;
  687. }
  688. div.remove();
  689. return ( cachedScrollbarWidth = w1 - w2 );
  690. },
  691. getScrollInfo: function( within ) {
  692. var overflowX = within.isWindow || within.isDocument ? "" :
  693. within.element.css( "overflow-x" ),
  694. overflowY = within.isWindow || within.isDocument ? "" :
  695. within.element.css( "overflow-y" ),
  696. hasOverflowX = overflowX === "scroll" ||
  697. ( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ),
  698. hasOverflowY = overflowY === "scroll" ||
  699. ( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight );
  700. return {
  701. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  702. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  703. };
  704. },
  705. getWithinInfo: function( element ) {
  706. var withinElement = $( element || window ),
  707. isWindow = $.isWindow( withinElement[ 0 ] ),
  708. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9,
  709. hasOffset = !isWindow && !isDocument;
  710. return {
  711. element: withinElement,
  712. isWindow: isWindow,
  713. isDocument: isDocument,
  714. offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 },
  715. scrollLeft: withinElement.scrollLeft(),
  716. scrollTop: withinElement.scrollTop(),
  717. width: withinElement.outerWidth(),
  718. height: withinElement.outerHeight()
  719. };
  720. }
  721. };
  722. $.fn.position = function( options ) {
  723. if ( !options || !options.of ) {
  724. return _position.apply( this, arguments );
  725. }
  726. // Make a copy, we don't want to modify arguments
  727. options = $.extend( {}, options );
  728. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  729. target = $( options.of ),
  730. within = $.position.getWithinInfo( options.within ),
  731. scrollInfo = $.position.getScrollInfo( within ),
  732. collision = ( options.collision || "flip" ).split( " " ),
  733. offsets = {};
  734. dimensions = getDimensions( target );
  735. if ( target[ 0 ].preventDefault ) {
  736. // Force left top to allow flipping
  737. options.at = "left top";
  738. }
  739. targetWidth = dimensions.width;
  740. targetHeight = dimensions.height;
  741. targetOffset = dimensions.offset;
  742. // Clone to reuse original targetOffset later
  743. basePosition = $.extend( {}, targetOffset );
  744. // Force my and at to have valid horizontal and vertical positions
  745. // if a value is missing or invalid, it will be converted to center
  746. $.each( [ "my", "at" ], function() {
  747. var pos = ( options[ this ] || "" ).split( " " ),
  748. horizontalOffset,
  749. verticalOffset;
  750. if ( pos.length === 1 ) {
  751. pos = rhorizontal.test( pos[ 0 ] ) ?
  752. pos.concat( [ "center" ] ) :
  753. rvertical.test( pos[ 0 ] ) ?
  754. [ "center" ].concat( pos ) :
  755. [ "center", "center" ];
  756. }
  757. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  758. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  759. // Calculate offsets
  760. horizontalOffset = roffset.exec( pos[ 0 ] );
  761. verticalOffset = roffset.exec( pos[ 1 ] );
  762. offsets[ this ] = [
  763. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  764. verticalOffset ? verticalOffset[ 0 ] : 0
  765. ];
  766. // Reduce to just the positions without the offsets
  767. options[ this ] = [
  768. rposition.exec( pos[ 0 ] )[ 0 ],
  769. rposition.exec( pos[ 1 ] )[ 0 ]
  770. ];
  771. } );
  772. // Normalize collision option
  773. if ( collision.length === 1 ) {
  774. collision[ 1 ] = collision[ 0 ];
  775. }
  776. if ( options.at[ 0 ] === "right" ) {
  777. basePosition.left += targetWidth;
  778. } else if ( options.at[ 0 ] === "center" ) {
  779. basePosition.left += targetWidth / 2;
  780. }
  781. if ( options.at[ 1 ] === "bottom" ) {
  782. basePosition.top += targetHeight;
  783. } else if ( options.at[ 1 ] === "center" ) {
  784. basePosition.top += targetHeight / 2;
  785. }
  786. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  787. basePosition.left += atOffset[ 0 ];
  788. basePosition.top += atOffset[ 1 ];
  789. return this.each( function() {
  790. var collisionPosition, using,
  791. elem = $( this ),
  792. elemWidth = elem.outerWidth(),
  793. elemHeight = elem.outerHeight(),
  794. marginLeft = parseCss( this, "marginLeft" ),
  795. marginTop = parseCss( this, "marginTop" ),
  796. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) +
  797. scrollInfo.width,
  798. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) +
  799. scrollInfo.height,
  800. position = $.extend( {}, basePosition ),
  801. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  802. if ( options.my[ 0 ] === "right" ) {
  803. position.left -= elemWidth;
  804. } else if ( options.my[ 0 ] === "center" ) {
  805. position.left -= elemWidth / 2;
  806. }
  807. if ( options.my[ 1 ] === "bottom" ) {
  808. position.top -= elemHeight;
  809. } else if ( options.my[ 1 ] === "center" ) {
  810. position.top -= elemHeight / 2;
  811. }
  812. position.left += myOffset[ 0 ];
  813. position.top += myOffset[ 1 ];
  814. collisionPosition = {
  815. marginLeft: marginLeft,
  816. marginTop: marginTop
  817. };
  818. $.each( [ "left", "top" ], function( i, dir ) {
  819. if ( $.ui.position[ collision[ i ] ] ) {
  820. $.ui.position[ collision[ i ] ][ dir ]( position, {
  821. targetWidth: targetWidth,
  822. targetHeight: targetHeight,
  823. elemWidth: elemWidth,
  824. elemHeight: elemHeight,
  825. collisionPosition: collisionPosition,
  826. collisionWidth: collisionWidth,
  827. collisionHeight: collisionHeight,
  828. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  829. my: options.my,
  830. at: options.at,
  831. within: within,
  832. elem: elem
  833. } );
  834. }
  835. } );
  836. if ( options.using ) {
  837. // Adds feedback as second argument to using callback, if present
  838. using = function( props ) {
  839. var left = targetOffset.left - position.left,
  840. right = left + targetWidth - elemWidth,
  841. top = targetOffset.top - position.top,
  842. bottom = top + targetHeight - elemHeight,
  843. feedback = {
  844. target: {
  845. element: target,
  846. left: targetOffset.left,
  847. top: targetOffset.top,
  848. width: targetWidth,
  849. height: targetHeight
  850. },
  851. element: {
  852. element: elem,
  853. left: position.left,
  854. top: position.top,
  855. width: elemWidth,
  856. height: elemHeight
  857. },
  858. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  859. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  860. };
  861. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  862. feedback.horizontal = "center";
  863. }
  864. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  865. feedback.vertical = "middle";
  866. }
  867. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  868. feedback.important = "horizontal";
  869. } else {
  870. feedback.important = "vertical";
  871. }
  872. options.using.call( this, props, feedback );
  873. };
  874. }
  875. elem.offset( $.extend( position, { using: using } ) );
  876. } );
  877. };
  878. $.ui.position = {
  879. fit: {
  880. left: function( position, data ) {
  881. var within = data.within,
  882. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  883. outerWidth = within.width,
  884. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  885. overLeft = withinOffset - collisionPosLeft,
  886. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  887. newOverRight;
  888. // Element is wider than within
  889. if ( data.collisionWidth > outerWidth ) {
  890. // Element is initially over the left side of within
  891. if ( overLeft > 0 && overRight <= 0 ) {
  892. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth -
  893. withinOffset;
  894. position.left += overLeft - newOverRight;
  895. // Element is initially over right side of within
  896. } else if ( overRight > 0 && overLeft <= 0 ) {
  897. position.left = withinOffset;
  898. // Element is initially over both left and right sides of within
  899. } else {
  900. if ( overLeft > overRight ) {
  901. position.left = withinOffset + outerWidth - data.collisionWidth;
  902. } else {
  903. position.left = withinOffset;
  904. }
  905. }
  906. // Too far left -> align with left edge
  907. } else if ( overLeft > 0 ) {
  908. position.left += overLeft;
  909. // Too far right -> align with right edge
  910. } else if ( overRight > 0 ) {
  911. position.left -= overRight;
  912. // Adjust based on position and margin
  913. } else {
  914. position.left = max( position.left - collisionPosLeft, position.left );
  915. }
  916. },
  917. top: function( position, data ) {
  918. var within = data.within,
  919. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  920. outerHeight = data.within.height,
  921. collisionPosTop = position.top - data.collisionPosition.marginTop,
  922. overTop = withinOffset - collisionPosTop,
  923. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  924. newOverBottom;
  925. // Element is taller than within
  926. if ( data.collisionHeight > outerHeight ) {
  927. // Element is initially over the top of within
  928. if ( overTop > 0 && overBottom <= 0 ) {
  929. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight -
  930. withinOffset;
  931. position.top += overTop - newOverBottom;
  932. // Element is initially over bottom of within
  933. } else if ( overBottom > 0 && overTop <= 0 ) {
  934. position.top = withinOffset;
  935. // Element is initially over both top and bottom of within
  936. } else {
  937. if ( overTop > overBottom ) {
  938. position.top = withinOffset + outerHeight - data.collisionHeight;
  939. } else {
  940. position.top = withinOffset;
  941. }
  942. }
  943. // Too far up -> align with top
  944. } else if ( overTop > 0 ) {
  945. position.top += overTop;
  946. // Too far down -> align with bottom edge
  947. } else if ( overBottom > 0 ) {
  948. position.top -= overBottom;
  949. // Adjust based on position and margin
  950. } else {
  951. position.top = max( position.top - collisionPosTop, position.top );
  952. }
  953. }
  954. },
  955. flip: {
  956. left: function( position, data ) {
  957. var within = data.within,
  958. withinOffset = within.offset.left + within.scrollLeft,
  959. outerWidth = within.width,
  960. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  961. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  962. overLeft = collisionPosLeft - offsetLeft,
  963. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  964. myOffset = data.my[ 0 ] === "left" ?
  965. -data.elemWidth :
  966. data.my[ 0 ] === "right" ?
  967. data.elemWidth :
  968. 0,
  969. atOffset = data.at[ 0 ] === "left" ?
  970. data.targetWidth :
  971. data.at[ 0 ] === "right" ?
  972. -data.targetWidth :
  973. 0,
  974. offset = -2 * data.offset[ 0 ],
  975. newOverRight,
  976. newOverLeft;
  977. if ( overLeft < 0 ) {
  978. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth -
  979. outerWidth - withinOffset;
  980. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  981. position.left += myOffset + atOffset + offset;
  982. }
  983. } else if ( overRight > 0 ) {
  984. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset +
  985. atOffset + offset - offsetLeft;
  986. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  987. position.left += myOffset + atOffset + offset;
  988. }
  989. }
  990. },
  991. top: function( position, data ) {
  992. var within = data.within,
  993. withinOffset = within.offset.top + within.scrollTop,
  994. outerHeight = within.height,
  995. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  996. collisionPosTop = position.top - data.collisionPosition.marginTop,
  997. overTop = collisionPosTop - offsetTop,
  998. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  999. top = data.my[ 1 ] === "top",
  1000. myOffset = top ?
  1001. -data.elemHeight :
  1002. data.my[ 1 ] === "bottom" ?
  1003. data.elemHeight :
  1004. 0,
  1005. atOffset = data.at[ 1 ] === "top" ?
  1006. data.targetHeight :
  1007. data.at[ 1 ] === "bottom" ?
  1008. -data.targetHeight :
  1009. 0,
  1010. offset = -2 * data.offset[ 1 ],
  1011. newOverTop,
  1012. newOverBottom;
  1013. if ( overTop < 0 ) {
  1014. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight -
  1015. outerHeight - withinOffset;
  1016. if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
  1017. position.top += myOffset + atOffset + offset;
  1018. }
  1019. } else if ( overBottom > 0 ) {
  1020. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset +
  1021. offset - offsetTop;
  1022. if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
  1023. position.top += myOffset + atOffset + offset;
  1024. }
  1025. }
  1026. }
  1027. },
  1028. flipfit: {
  1029. left: function() {
  1030. $.ui.position.flip.left.apply( this, arguments );
  1031. $.ui.position.fit.left.apply( this, arguments );
  1032. },
  1033. top: function() {
  1034. $.ui.position.flip.top.apply( this, arguments );
  1035. $.ui.position.fit.top.apply( this, arguments );
  1036. }
  1037. }
  1038. };
  1039. } )();
  1040. var position = $.ui.position;
  1041. /*!
  1042. * jQuery UI :data 1.12.1
  1043. * http://jqueryui.com
  1044. *
  1045. * Copyright jQuery Foundation and other contributors
  1046. * Released under the MIT license.
  1047. * http://jquery.org/license
  1048. */
  1049. //>>label: :data Selector
  1050. //>>group: Core
  1051. //>>description: Selects elements which have data stored under the specified key.
  1052. //>>docs: http://api.jqueryui.com/data-selector/
  1053. var data = $.extend( $.expr[ ":" ], {
  1054. data: $.expr.createPseudo ?
  1055. $.expr.createPseudo( function( dataName ) {
  1056. return function( elem ) {
  1057. return !!$.data( elem, dataName );
  1058. };
  1059. } ) :
  1060. // Support: jQuery <1.8
  1061. function( elem, i, match ) {
  1062. return !!$.data( elem, match[ 3 ] );
  1063. }
  1064. } );
  1065. /*!
  1066. * jQuery UI Disable Selection 1.12.1
  1067. * http://jqueryui.com
  1068. *
  1069. * Copyright jQuery Foundation and other contributors
  1070. * Released under the MIT license.
  1071. * http://jquery.org/license
  1072. */
  1073. //>>label: disableSelection
  1074. //>>group: Core
  1075. //>>description: Disable selection of text content within the set of matched elements.
  1076. //>>docs: http://api.jqueryui.com/disableSelection/
  1077. // This file is deprecated
  1078. var disableSelection = $.fn.extend( {
  1079. disableSelection: ( function() {
  1080. var eventType = "onselectstart" in document.createElement( "div" ) ?
  1081. "selectstart" :
  1082. "mousedown";
  1083. return function() {
  1084. return this.on( eventType + ".ui-disableSelection", function( event ) {
  1085. event.preventDefault();
  1086. } );
  1087. };
  1088. } )(),
  1089. enableSelection: function() {
  1090. return this.off( ".ui-disableSelection" );
  1091. }
  1092. } );
  1093. /*!
  1094. * jQuery UI Focusable 1.12.1
  1095. * http://jqueryui.com
  1096. *
  1097. * Copyright jQuery Foundation and other contributors
  1098. * Released under the MIT license.
  1099. * http://jquery.org/license
  1100. */
  1101. //>>label: :focusable Selector
  1102. //>>group: Core
  1103. //>>description: Selects elements which can be focused.
  1104. //>>docs: http://api.jqueryui.com/focusable-selector/
  1105. // Selectors
  1106. $.ui.focusable = function( element, hasTabindex ) {
  1107. var map, mapName, img, focusableIfVisible, fieldset,
  1108. nodeName = element.nodeName.toLowerCase();
  1109. if ( "area" === nodeName ) {
  1110. map = element.parentNode;
  1111. mapName = map.name;
  1112. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  1113. return false;
  1114. }
  1115. img = $( "img[usemap='#" + mapName + "']" );
  1116. return img.length > 0 && img.is( ":visible" );
  1117. }
  1118. if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) {
  1119. focusableIfVisible = !element.disabled;
  1120. if ( focusableIfVisible ) {
  1121. // Form controls within a disabled fieldset are disabled.
  1122. // However, controls within the fieldset's legend do not get disabled.
  1123. // Since controls generally aren't placed inside legends, we skip
  1124. // this portion of the check.
  1125. fieldset = $( element ).closest( "fieldset" )[ 0 ];
  1126. if ( fieldset ) {
  1127. focusableIfVisible = !fieldset.disabled;
  1128. }
  1129. }
  1130. } else if ( "a" === nodeName ) {
  1131. focusableIfVisible = element.href || hasTabindex;
  1132. } else {
  1133. focusableIfVisible = hasTabindex;
  1134. }
  1135. return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) );
  1136. };
  1137. // Support: IE 8 only
  1138. // IE 8 doesn't resolve inherit to visible/hidden for computed values
  1139. function visible( element ) {
  1140. var visibility = element.css( "visibility" );
  1141. while ( visibility === "inherit" ) {
  1142. element = element.parent();
  1143. visibility = element.css( "visibility" );
  1144. }
  1145. return visibility !== "hidden";
  1146. }
  1147. $.extend( $.expr[ ":" ], {
  1148. focusable: function( element ) {
  1149. return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
  1150. }
  1151. } );
  1152. var focusable = $.ui.focusable;
  1153. // Support: IE8 Only
  1154. // IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
  1155. // with a string, so we need to find the proper form.
  1156. var form = $.fn.form = function() {
  1157. return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
  1158. };
  1159. /*!
  1160. * jQuery UI Form Reset Mixin 1.12.1
  1161. * http://jqueryui.com
  1162. *
  1163. * Copyright jQuery Foundation and other contributors
  1164. * Released under the MIT license.
  1165. * http://jquery.org/license
  1166. */
  1167. //>>label: Form Reset Mixin
  1168. //>>group: Core
  1169. //>>description: Refresh input widgets when their form is reset
  1170. //>>docs: http://api.jqueryui.com/form-reset-mixin/
  1171. var formResetMixin = $.ui.formResetMixin = {
  1172. _formResetHandler: function() {
  1173. var form = $( this );
  1174. // Wait for the form reset to actually happen before refreshing
  1175. setTimeout( function() {
  1176. var instances = form.data( "ui-form-reset-instances" );
  1177. $.each( instances, function() {
  1178. this.refresh();
  1179. } );
  1180. } );
  1181. },
  1182. _bindFormResetHandler: function() {
  1183. this.form = this.element.form();
  1184. if ( !this.form.length ) {
  1185. return;
  1186. }
  1187. var instances = this.form.data( "ui-form-reset-instances" ) || [];
  1188. if ( !instances.length ) {
  1189. // We don't use _on() here because we use a single event handler per form
  1190. this.form.on( "reset.ui-form-reset", this._formResetHandler );
  1191. }
  1192. instances.push( this );
  1193. this.form.data( "ui-form-reset-instances", instances );
  1194. },
  1195. _unbindFormResetHandler: function() {
  1196. if ( !this.form.length ) {
  1197. return;
  1198. }
  1199. var instances = this.form.data( "ui-form-reset-instances" );
  1200. instances.splice( $.inArray( this, instances ), 1 );
  1201. if ( instances.length ) {
  1202. this.form.data( "ui-form-reset-instances", instances );
  1203. } else {
  1204. this.form
  1205. .removeData( "ui-form-reset-instances" )
  1206. .off( "reset.ui-form-reset" );
  1207. }
  1208. }
  1209. };
  1210. /*!
  1211. * jQuery UI Support for jQuery core 1.7.x 1.12.1
  1212. * http://jqueryui.com
  1213. *
  1214. * Copyright jQuery Foundation and other contributors
  1215. * Released under the MIT license.
  1216. * http://jquery.org/license
  1217. *
  1218. */
  1219. //>>label: jQuery 1.7 Support
  1220. //>>group: Core
  1221. //>>description: Support version 1.7.x of jQuery core
  1222. // Support: jQuery 1.7 only
  1223. // Not a great way to check versions, but since we only support 1.7+ and only
  1224. // need to detect <1.8, this is a simple check that should suffice. Checking
  1225. // for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0
  1226. // and we'll never reach 1.70.0 (if we do, we certainly won't be supporting
  1227. // 1.7 anymore). See #11197 for why we're not using feature detection.
  1228. if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
  1229. // Setters for .innerWidth(), .innerHeight(), .outerWidth(), .outerHeight()
  1230. // Unlike jQuery Core 1.8+, these only support numeric values to set the
  1231. // dimensions in pixels
  1232. $.each( [ "Width", "Height" ], function( i, name ) {
  1233. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  1234. type = name.toLowerCase(),
  1235. orig = {
  1236. innerWidth: $.fn.innerWidth,
  1237. innerHeight: $.fn.innerHeight,
  1238. outerWidth: $.fn.outerWidth,
  1239. outerHeight: $.fn.outerHeight
  1240. };
  1241. function reduce( elem, size, border, margin ) {
  1242. $.each( side, function() {
  1243. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  1244. if ( border ) {
  1245. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  1246. }
  1247. if ( margin ) {
  1248. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  1249. }
  1250. } );
  1251. return size;
  1252. }
  1253. $.fn[ "inner" + name ] = function( size ) {
  1254. if ( size === undefined ) {
  1255. return orig[ "inner" + name ].call( this );
  1256. }
  1257. return this.each( function() {
  1258. $( this ).css( type, reduce( this, size ) + "px" );
  1259. } );
  1260. };
  1261. $.fn[ "outer" + name ] = function( size, margin ) {
  1262. if ( typeof size !== "number" ) {
  1263. return orig[ "outer" + name ].call( this, size );
  1264. }
  1265. return this.each( function() {
  1266. $( this ).css( type, reduce( this, size, true, margin ) + "px" );
  1267. } );
  1268. };
  1269. } );
  1270. $.fn.addBack = function( selector ) {
  1271. return this.add( selector == null ?
  1272. this.prevObject : this.prevObject.filter( selector )
  1273. );
  1274. };
  1275. }
  1276. ;
  1277. /*!
  1278. * jQuery UI Keycode 1.12.1
  1279. * http://jqueryui.com
  1280. *
  1281. * Copyright jQuery Foundation and other contributors
  1282. * Released under the MIT license.
  1283. * http://jquery.org/license
  1284. */
  1285. //>>label: Keycode
  1286. //>>group: Core
  1287. //>>description: Provide keycodes as keynames
  1288. //>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/
  1289. var keycode = $.ui.keyCode = {
  1290. BACKSPACE: 8,
  1291. COMMA: 188,
  1292. DELETE: 46,
  1293. DOWN: 40,
  1294. END: 35,
  1295. ENTER: 13,
  1296. ESCAPE: 27,
  1297. HOME: 36,
  1298. LEFT: 37,
  1299. PAGE_DOWN: 34,
  1300. PAGE_UP: 33,
  1301. PERIOD: 190,
  1302. RIGHT: 39,
  1303. SPACE: 32,
  1304. TAB: 9,
  1305. UP: 38
  1306. };
  1307. // Internal use only
  1308. var escapeSelector = $.ui.escapeSelector = ( function() {
  1309. var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;
  1310. return function( selector ) {
  1311. return selector.replace( selectorEscape, "\\$1" );
  1312. };
  1313. } )();
  1314. /*!
  1315. * jQuery UI Labels 1.12.1
  1316. * http://jqueryui.com
  1317. *
  1318. * Copyright jQuery Foundation and other contributors
  1319. * Released under the MIT license.
  1320. * http://jquery.org/license
  1321. */
  1322. //>>label: labels
  1323. //>>group: Core
  1324. //>>description: Find all the labels associated with a given input
  1325. //>>docs: http://api.jqueryui.com/labels/
  1326. var labels = $.fn.labels = function() {
  1327. var ancestor, selector, id, labels, ancestors;
  1328. // Check control.labels first
  1329. if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
  1330. return this.pushStack( this[ 0 ].labels );
  1331. }
  1332. // Support: IE <= 11, FF <= 37, Android <= 2.3 only
  1333. // Above browsers do not support control.labels. Everything below is to support them
  1334. // as well as document fragments. control.labels does not work on document fragments
  1335. labels = this.eq( 0 ).parents( "label" );
  1336. // Look for the label based on the id
  1337. id = this.attr( "id" );
  1338. if ( id ) {
  1339. // We don't search against the document in case the element
  1340. // is disconnected from the DOM
  1341. ancestor = this.eq( 0 ).parents().last();
  1342. // Get a full set of top level ancestors
  1343. ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
  1344. // Create a selector for the label based on the id
  1345. selector = "label[for='" + $.ui.escapeSelector( id ) + "']";
  1346. labels = labels.add( ancestors.find( selector ).addBack( selector ) );
  1347. }
  1348. // Return whatever we have found for labels
  1349. return this.pushStack( labels );
  1350. };
  1351. /*!
  1352. * jQuery UI Scroll Parent 1.12.1
  1353. * http://jqueryui.com
  1354. *
  1355. * Copyright jQuery Foundation and other contributors
  1356. * Released under the MIT license.
  1357. * http://jquery.org/license
  1358. */
  1359. //>>label: scrollParent
  1360. //>>group: Core
  1361. //>>description: Get the closest ancestor element that is scrollable.
  1362. //>>docs: http://api.jqueryui.com/scrollParent/
  1363. var scrollParent = $.fn.scrollParent = function( includeHidden ) {
  1364. var position = this.css( "position" ),
  1365. excludeStaticParent = position === "absolute",
  1366. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  1367. scrollParent = this.parents().filter( function() {
  1368. var parent = $( this );
  1369. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  1370. return false;
  1371. }
  1372. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) +
  1373. parent.css( "overflow-x" ) );
  1374. } ).eq( 0 );
  1375. return position === "fixed" || !scrollParent.length ?
  1376. $( this[ 0 ].ownerDocument || document ) :
  1377. scrollParent;
  1378. };
  1379. /*!
  1380. * jQuery UI Tabbable 1.12.1
  1381. * http://jqueryui.com
  1382. *
  1383. * Copyright jQuery Foundation and other contributors
  1384. * Released under the MIT license.
  1385. * http://jquery.org/license
  1386. */
  1387. //>>label: :tabbable Selector
  1388. //>>group: Core
  1389. //>>description: Selects elements which can be tabbed to.
  1390. //>>docs: http://api.jqueryui.com/tabbable-selector/
  1391. var tabbable = $.extend( $.expr[ ":" ], {
  1392. tabbable: function( element ) {
  1393. var tabIndex = $.attr( element, "tabindex" ),
  1394. hasTabindex = tabIndex != null;
  1395. return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex );
  1396. }
  1397. } );
  1398. /*!
  1399. * jQuery UI Unique ID 1.12.1
  1400. * http://jqueryui.com
  1401. *
  1402. * Copyright jQuery Foundation and other contributors
  1403. * Released under the MIT license.
  1404. * http://jquery.org/license
  1405. */
  1406. //>>label: uniqueId
  1407. //>>group: Core
  1408. //>>description: Functions to generate and remove uniqueId's
  1409. //>>docs: http://api.jqueryui.com/uniqueId/
  1410. var uniqueId = $.fn.extend( {
  1411. uniqueId: ( function() {
  1412. var uuid = 0;
  1413. return function() {
  1414. return this.each( function() {
  1415. if ( !this.id ) {
  1416. this.id = "ui-id-" + ( ++uuid );
  1417. }
  1418. } );
  1419. };
  1420. } )(),
  1421. removeUniqueId: function() {
  1422. return this.each( function() {
  1423. if ( /^ui-id-\d+$/.test( this.id ) ) {
  1424. $( this ).removeAttr( "id" );
  1425. }
  1426. } );
  1427. }
  1428. } );
  1429. // This file is deprecated
  1430. var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  1431. /*!
  1432. * jQuery UI Mouse 1.12.1
  1433. * http://jqueryui.com
  1434. *
  1435. * Copyright jQuery Foundation and other contributors
  1436. * Released under the MIT license.
  1437. * http://jquery.org/license
  1438. */
  1439. //>>label: Mouse
  1440. //>>group: Widgets
  1441. //>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
  1442. //>>docs: http://api.jqueryui.com/mouse/
  1443. var mouseHandled = false;
  1444. $( document ).on( "mouseup", function() {
  1445. mouseHandled = false;
  1446. } );
  1447. var widgetsMouse = $.widget( "ui.mouse", {
  1448. version: "1.12.1",
  1449. options: {
  1450. cancel: "input, textarea, button, select, option",
  1451. distance: 1,
  1452. delay: 0
  1453. },
  1454. _mouseInit: function() {
  1455. var that = this;
  1456. this.element
  1457. .on( "mousedown." + this.widgetName, function( event ) {
  1458. return that._mouseDown( event );
  1459. } )
  1460. .on( "click." + this.widgetName, function( event ) {
  1461. if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
  1462. $.removeData( event.target, that.widgetName + ".preventClickEvent" );
  1463. event.stopImmediatePropagation();
  1464. return false;
  1465. }
  1466. } );
  1467. this.started = false;
  1468. },
  1469. // TODO: make sure destroying one instance of mouse doesn't mess with
  1470. // other instances of mouse
  1471. _mouseDestroy: function() {
  1472. this.element.off( "." + this.widgetName );
  1473. if ( this._mouseMoveDelegate ) {
  1474. this.document
  1475. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  1476. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  1477. }
  1478. },
  1479. _mouseDown: function( event ) {
  1480. // don't let more than one widget handle mouseStart
  1481. if ( mouseHandled ) {
  1482. return;
  1483. }
  1484. this._mouseMoved = false;
  1485. // We may have missed mouseup (out of window)
  1486. ( this._mouseStarted && this._mouseUp( event ) );
  1487. this._mouseDownEvent = event;
  1488. var that = this,
  1489. btnIsLeft = ( event.which === 1 ),
  1490. // event.target.nodeName works around a bug in IE 8 with
  1491. // disabled inputs (#7620)
  1492. elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ?
  1493. $( event.target ).closest( this.options.cancel ).length : false );
  1494. if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
  1495. return true;
  1496. }
  1497. this.mouseDelayMet = !this.options.delay;
  1498. if ( !this.mouseDelayMet ) {
  1499. this._mouseDelayTimer = setTimeout( function() {
  1500. that.mouseDelayMet = true;
  1501. }, this.options.delay );
  1502. }
  1503. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  1504. this._mouseStarted = ( this._mouseStart( event ) !== false );
  1505. if ( !this._mouseStarted ) {
  1506. event.preventDefault();
  1507. return true;
  1508. }
  1509. }
  1510. // Click event may never have fired (Gecko & Opera)
  1511. if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
  1512. $.removeData( event.target, this.widgetName + ".preventClickEvent" );
  1513. }
  1514. // These delegates are required to keep context
  1515. this._mouseMoveDelegate = function( event ) {
  1516. return that._mouseMove( event );
  1517. };
  1518. this._mouseUpDelegate = function( event ) {
  1519. return that._mouseUp( event );
  1520. };
  1521. this.document
  1522. .on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  1523. .on( "mouseup." + this.widgetName, this._mouseUpDelegate );
  1524. event.preventDefault();
  1525. mouseHandled = true;
  1526. return true;
  1527. },
  1528. _mouseMove: function( event ) {
  1529. // Only check for mouseups outside the document if you've moved inside the document
  1530. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  1531. // fire a mousemove event if content is placed under the cursor. See #7778
  1532. // Support: IE <9
  1533. if ( this._mouseMoved ) {
  1534. // IE mouseup check - mouseup happened when mouse was out of window
  1535. if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) &&
  1536. !event.button ) {
  1537. return this._mouseUp( event );
  1538. // Iframe mouseup check - mouseup occurred in another document
  1539. } else if ( !event.which ) {
  1540. // Support: Safari <=8 - 9
  1541. // Safari sets which to 0 if you press any of the following keys
  1542. // during a drag (#14461)
  1543. if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
  1544. event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
  1545. this.ignoreMissingWhich = true;
  1546. } else if ( !this.ignoreMissingWhich ) {
  1547. return this._mouseUp( event );
  1548. }
  1549. }
  1550. }
  1551. if ( event.which || event.button ) {
  1552. this._mouseMoved = true;
  1553. }
  1554. if ( this._mouseStarted ) {
  1555. this._mouseDrag( event );
  1556. return event.preventDefault();
  1557. }
  1558. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  1559. this._mouseStarted =
  1560. ( this._mouseStart( this._mouseDownEvent, event ) !== false );
  1561. ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) );
  1562. }
  1563. return !this._mouseStarted;
  1564. },
  1565. _mouseUp: function( event ) {
  1566. this.document
  1567. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  1568. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  1569. if ( this._mouseStarted ) {
  1570. this._mouseStarted = false;
  1571. if ( event.target === this._mouseDownEvent.target ) {
  1572. $.data( event.target, this.widgetName + ".preventClickEvent", true );
  1573. }
  1574. this._mouseStop( event );
  1575. }
  1576. if ( this._mouseDelayTimer ) {
  1577. clearTimeout( this._mouseDelayTimer );
  1578. delete this._mouseDelayTimer;
  1579. }
  1580. this.ignoreMissingWhich = false;
  1581. mouseHandled = false;
  1582. event.preventDefault();
  1583. },
  1584. _mouseDistanceMet: function( event ) {
  1585. return ( Math.max(
  1586. Math.abs( this._mouseDownEvent.pageX - event.pageX ),
  1587. Math.abs( this._mouseDownEvent.pageY - event.pageY )
  1588. ) >= this.options.distance
  1589. );
  1590. },
  1591. _mouseDelayMet: function( /* event */ ) {
  1592. return this.mouseDelayMet;
  1593. },
  1594. // These are placeholder methods, to be overriden by extending plugin
  1595. _mouseStart: function( /* event */ ) {},
  1596. _mouseDrag: function( /* event */ ) {},
  1597. _mouseStop: function( /* event */ ) {},
  1598. _mouseCapture: function( /* event */ ) { return true; }
  1599. } );
  1600. /*!
  1601. * jQuery UI Sortable 1.12.1
  1602. * http://jqueryui.com
  1603. *
  1604. * Copyright jQuery Foundation and other contributors
  1605. * Released under the MIT license.
  1606. * http://jquery.org/license
  1607. */
  1608. //>>label: Sortable
  1609. //>>group: Interactions
  1610. //>>description: Enables items in a list to be sorted using the mouse.
  1611. //>>docs: http://api.jqueryui.com/sortable/
  1612. //>>demos: http://jqueryui.com/sortable/
  1613. //>>css.structure: ../../themes/base/sortable.css
  1614. var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, {
  1615. version: "1.12.1",
  1616. widgetEventPrefix: "sort",
  1617. ready: false,
  1618. options: {
  1619. appendTo: "parent",
  1620. axis: false,
  1621. connectWith: false,
  1622. containment: false,
  1623. cursor: "auto",
  1624. cursorAt: false,
  1625. dropOnEmpty: true,
  1626. forcePlaceholderSize: false,
  1627. forceHelperSize: false,
  1628. grid: false,
  1629. handle: false,
  1630. helper: "original",
  1631. items: "> *",
  1632. opacity: false,
  1633. placeholder: false,
  1634. revert: false,
  1635. scroll: true,
  1636. scrollSensitivity: 20,
  1637. scrollSpeed: 20,
  1638. scope: "default",
  1639. tolerance: "intersect",
  1640. zIndex: 1000,
  1641. // Callbacks
  1642. activate: null,
  1643. beforeStop: null,
  1644. change: null,
  1645. deactivate: null,
  1646. out: null,
  1647. over: null,
  1648. receive: null,
  1649. remove: null,
  1650. sort: null,
  1651. start: null,
  1652. stop: null,
  1653. update: null
  1654. },
  1655. _isOverAxis: function( x, reference, size ) {
  1656. return ( x >= reference ) && ( x < ( reference + size ) );
  1657. },
  1658. _isFloating: function( item ) {
  1659. return ( /left|right/ ).test( item.css( "float" ) ) ||
  1660. ( /inline|table-cell/ ).test( item.css( "display" ) );
  1661. },
  1662. _create: function() {
  1663. this.containerCache = {};
  1664. this._addClass( "ui-sortable" );
  1665. //Get the items
  1666. this.refresh();
  1667. //Let's determine the parent's offset
  1668. this.offset = this.element.offset();
  1669. //Initialize mouse events for interaction
  1670. this._mouseInit();
  1671. this._setHandleClassName();
  1672. //We're ready to go
  1673. this.ready = true;
  1674. },
  1675. _setOption: function( key, value ) {
  1676. this._super( key, value );
  1677. if ( key === "handle" ) {
  1678. this._setHandleClassName();
  1679. }
  1680. },
  1681. _setHandleClassName: function() {
  1682. var that = this;
  1683. this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" );
  1684. $.each( this.items, function() {
  1685. that._addClass(
  1686. this.instance.options.handle ?
  1687. this.item.find( this.instance.options.handle ) :
  1688. this.item,
  1689. "ui-sortable-handle"
  1690. );
  1691. } );
  1692. },
  1693. _destroy: function() {
  1694. this._mouseDestroy();
  1695. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  1696. this.items[ i ].item.removeData( this.widgetName + "-item" );
  1697. }
  1698. return this;
  1699. },
  1700. _mouseCapture: function( event, overrideHandle ) {
  1701. var currentItem = null,
  1702. validHandle = false,
  1703. that = this;
  1704. if ( this.reverting ) {
  1705. return false;
  1706. }
  1707. if ( this.options.disabled || this.options.type === "static" ) {
  1708. return false;
  1709. }
  1710. //We have to refresh the items data once first
  1711. this._refreshItems( event );
  1712. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  1713. $( event.target ).parents().each( function() {
  1714. if ( $.data( this, that.widgetName + "-item" ) === that ) {
  1715. currentItem = $( this );
  1716. return false;
  1717. }
  1718. } );
  1719. if ( $.data( event.target, that.widgetName + "-item" ) === that ) {
  1720. currentItem = $( event.target );
  1721. }
  1722. if ( !currentItem ) {
  1723. return false;
  1724. }
  1725. if ( this.options.handle && !overrideHandle ) {
  1726. $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() {
  1727. if ( this === event.target ) {
  1728. validHandle = true;
  1729. }
  1730. } );
  1731. if ( !validHandle ) {
  1732. return false;
  1733. }
  1734. }
  1735. this.currentItem = currentItem;
  1736. this._removeCurrentsFromItems();
  1737. return true;
  1738. },
  1739. _mouseStart: function( event, overrideHandle, noActivation ) {
  1740. var i, body,
  1741. o = this.options;
  1742. this.currentContainer = this;
  1743. //We only need to call refreshPositions, because the refreshItems call has been moved to
  1744. // mouseCapture
  1745. this.refreshPositions();
  1746. //Create and append the visible helper
  1747. this.helper = this._createHelper( event );
  1748. //Cache the helper size
  1749. this._cacheHelperProportions();
  1750. /*
  1751. * - Position generation -
  1752. * This block generates everything position related - it's the core of draggables.
  1753. */
  1754. //Cache the margins of the original element
  1755. this._cacheMargins();
  1756. //Get the next scrolling parent
  1757. this.scrollParent = this.helper.scrollParent();
  1758. //The element's absolute position on the page minus margins
  1759. this.offset = this.currentItem.offset();
  1760. this.offset = {
  1761. top: this.offset.top - this.margins.top,
  1762. left: this.offset.left - this.margins.left
  1763. };
  1764. $.extend( this.offset, {
  1765. click: { //Where the click happened, relative to the element
  1766. left: event.pageX - this.offset.left,
  1767. top: event.pageY - this.offset.top
  1768. },
  1769. parent: this._getParentOffset(),
  1770. // This is a relative to absolute position minus the actual position calculation -
  1771. // only used for relative positioned helper
  1772. relative: this._getRelativeOffset()
  1773. } );
  1774. // Only after we got the offset, we can change the helper's position to absolute
  1775. // TODO: Still need to figure out a way to make relative sorting possible
  1776. this.helper.css( "position", "absolute" );
  1777. this.cssPosition = this.helper.css( "position" );
  1778. //Generate the original position
  1779. this.originalPosition = this._generatePosition( event );
  1780. this.originalPageX = event.pageX;
  1781. this.originalPageY = event.pageY;
  1782. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  1783. ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
  1784. //Cache the former DOM position
  1785. this.domPosition = {
  1786. prev: this.currentItem.prev()[ 0 ],
  1787. parent: this.currentItem.parent()[ 0 ]
  1788. };
  1789. // If the helper is not the original, hide the original so it's not playing any role during
  1790. // the drag, won't cause anything bad this way
  1791. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  1792. this.currentItem.hide();
  1793. }
  1794. //Create the placeholder
  1795. this._createPlaceholder();
  1796. //Set a containment if given in the options
  1797. if ( o.containment ) {
  1798. this._setContainment();
  1799. }
  1800. if ( o.cursor && o.cursor !== "auto" ) { // cursor option
  1801. body = this.document.find( "body" );
  1802. // Support: IE
  1803. this.storedCursor = body.css( "cursor" );
  1804. body.css( "cursor", o.cursor );
  1805. this.storedStylesheet =
  1806. $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body );
  1807. }
  1808. if ( o.opacity ) { // opacity option
  1809. if ( this.helper.css( "opacity" ) ) {
  1810. this._storedOpacity = this.helper.css( "opacity" );
  1811. }
  1812. this.helper.css( "opacity", o.opacity );
  1813. }
  1814. if ( o.zIndex ) { // zIndex option
  1815. if ( this.helper.css( "zIndex" ) ) {
  1816. this._storedZIndex = this.helper.css( "zIndex" );
  1817. }
  1818. this.helper.css( "zIndex", o.zIndex );
  1819. }
  1820. //Prepare scrolling
  1821. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  1822. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  1823. this.overflowOffset = this.scrollParent.offset();
  1824. }
  1825. //Call callbacks
  1826. this._trigger( "start", event, this._uiHash() );
  1827. //Recache the helper size
  1828. if ( !this._preserveHelperProportions ) {
  1829. this._cacheHelperProportions();
  1830. }
  1831. //Post "activate" events to possible containers
  1832. if ( !noActivation ) {
  1833. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  1834. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  1835. }
  1836. }
  1837. //Prepare possible droppables
  1838. if ( $.ui.ddmanager ) {
  1839. $.ui.ddmanager.current = this;
  1840. }
  1841. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  1842. $.ui.ddmanager.prepareOffsets( this, event );
  1843. }
  1844. this.dragging = true;
  1845. this._addClass( this.helper, "ui-sortable-helper" );
  1846. // Execute the drag once - this causes the helper not to be visiblebefore getting its
  1847. // correct position
  1848. this._mouseDrag( event );
  1849. return true;
  1850. },
  1851. _mouseDrag: function( event ) {
  1852. var i, item, itemElement, intersection,
  1853. o = this.options,
  1854. scrolled = false;
  1855. //Compute the helpers position
  1856. this.position = this._generatePosition( event );
  1857. this.positionAbs = this._convertPositionTo( "absolute" );
  1858. if ( !this.lastPositionAbs ) {
  1859. this.lastPositionAbs = this.positionAbs;
  1860. }
  1861. //Do scrolling
  1862. if ( this.options.scroll ) {
  1863. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  1864. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  1865. if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) -
  1866. event.pageY < o.scrollSensitivity ) {
  1867. this.scrollParent[ 0 ].scrollTop =
  1868. scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
  1869. } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
  1870. this.scrollParent[ 0 ].scrollTop =
  1871. scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
  1872. }
  1873. if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) -
  1874. event.pageX < o.scrollSensitivity ) {
  1875. this.scrollParent[ 0 ].scrollLeft = scrolled =
  1876. this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
  1877. } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
  1878. this.scrollParent[ 0 ].scrollLeft = scrolled =
  1879. this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
  1880. }
  1881. } else {
  1882. if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
  1883. scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
  1884. } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) <
  1885. o.scrollSensitivity ) {
  1886. scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
  1887. }
  1888. if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
  1889. scrolled = this.document.scrollLeft(
  1890. this.document.scrollLeft() - o.scrollSpeed
  1891. );
  1892. } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) <
  1893. o.scrollSensitivity ) {
  1894. scrolled = this.document.scrollLeft(
  1895. this.document.scrollLeft() + o.scrollSpeed
  1896. );
  1897. }
  1898. }
  1899. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  1900. $.ui.ddmanager.prepareOffsets( this, event );
  1901. }
  1902. }
  1903. //Regenerate the absolute position used for position checks
  1904. this.positionAbs = this._convertPositionTo( "absolute" );
  1905. //Set the helper position
  1906. if ( !this.options.axis || this.options.axis !== "y" ) {
  1907. this.helper[ 0 ].style.left = this.position.left + "px";
  1908. }
  1909. if ( !this.options.axis || this.options.axis !== "x" ) {
  1910. this.helper[ 0 ].style.top = this.position.top + "px";
  1911. }
  1912. //Rearrange
  1913. for ( i = this.items.length - 1; i >= 0; i-- ) {
  1914. //Cache variables and intersection, continue if no intersection
  1915. item = this.items[ i ];
  1916. itemElement = item.item[ 0 ];
  1917. intersection = this._intersectsWithPointer( item );
  1918. if ( !intersection ) {
  1919. continue;
  1920. }
  1921. // Only put the placeholder inside the current Container, skip all
  1922. // items from other containers. This works because when moving
  1923. // an item from one container to another the
  1924. // currentContainer is switched before the placeholder is moved.
  1925. //
  1926. // Without this, moving items in "sub-sortables" can cause
  1927. // the placeholder to jitter between the outer and inner container.
  1928. if ( item.instance !== this.currentContainer ) {
  1929. continue;
  1930. }
  1931. // Cannot intersect with itself
  1932. // no useless actions that have been done before
  1933. // no action if the item moved is the parent of the item checked
  1934. if ( itemElement !== this.currentItem[ 0 ] &&
  1935. this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement &&
  1936. !$.contains( this.placeholder[ 0 ], itemElement ) &&
  1937. ( this.options.type === "semi-dynamic" ?
  1938. !$.contains( this.element[ 0 ], itemElement ) :
  1939. true
  1940. )
  1941. ) {
  1942. this.direction = intersection === 1 ? "down" : "up";
  1943. if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) {
  1944. this._rearrange( event, item );
  1945. } else {
  1946. break;
  1947. }
  1948. this._trigger( "change", event, this._uiHash() );
  1949. break;
  1950. }
  1951. }
  1952. //Post events to containers
  1953. this._contactContainers( event );
  1954. //Interconnect with droppables
  1955. if ( $.ui.ddmanager ) {
  1956. $.ui.ddmanager.drag( this, event );
  1957. }
  1958. //Call callbacks
  1959. this._trigger( "sort", event, this._uiHash() );
  1960. this.lastPositionAbs = this.positionAbs;
  1961. return false;
  1962. },
  1963. _mouseStop: function( event, noPropagation ) {
  1964. if ( !event ) {
  1965. return;
  1966. }
  1967. //If we are using droppables, inform the manager about the drop
  1968. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  1969. $.ui.ddmanager.drop( this, event );
  1970. }
  1971. if ( this.options.revert ) {
  1972. var that = this,
  1973. cur = this.placeholder.offset(),
  1974. axis = this.options.axis,
  1975. animation = {};
  1976. if ( !axis || axis === "x" ) {
  1977. animation.left = cur.left - this.offset.parent.left - this.margins.left +
  1978. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  1979. 0 :
  1980. this.offsetParent[ 0 ].scrollLeft
  1981. );
  1982. }
  1983. if ( !axis || axis === "y" ) {
  1984. animation.top = cur.top - this.offset.parent.top - this.margins.top +
  1985. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  1986. 0 :
  1987. this.offsetParent[ 0 ].scrollTop
  1988. );
  1989. }
  1990. this.reverting = true;
  1991. $( this.helper ).animate(
  1992. animation,
  1993. parseInt( this.options.revert, 10 ) || 500,
  1994. function() {
  1995. that._clear( event );
  1996. }
  1997. );
  1998. } else {
  1999. this._clear( event, noPropagation );
  2000. }
  2001. return false;
  2002. },
  2003. cancel: function() {
  2004. if ( this.dragging ) {
  2005. this._mouseUp( new $.Event( "mouseup", { target: null } ) );
  2006. if ( this.options.helper === "original" ) {
  2007. this.currentItem.css( this._storedCSS );
  2008. this._removeClass( this.currentItem, "ui-sortable-helper" );
  2009. } else {
  2010. this.currentItem.show();
  2011. }
  2012. //Post deactivating events to containers
  2013. for ( var i = this.containers.length - 1; i >= 0; i-- ) {
  2014. this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) );
  2015. if ( this.containers[ i ].containerCache.over ) {
  2016. this.containers[ i ]._trigger( "out", null, this._uiHash( this ) );
  2017. this.containers[ i ].containerCache.over = 0;
  2018. }
  2019. }
  2020. }
  2021. if ( this.placeholder ) {
  2022. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  2023. // it unbinds ALL events from the original node!
  2024. if ( this.placeholder[ 0 ].parentNode ) {
  2025. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  2026. }
  2027. if ( this.options.helper !== "original" && this.helper &&
  2028. this.helper[ 0 ].parentNode ) {
  2029. this.helper.remove();
  2030. }
  2031. $.extend( this, {
  2032. helper: null,
  2033. dragging: false,
  2034. reverting: false,
  2035. _noFinalSort: null
  2036. } );
  2037. if ( this.domPosition.prev ) {
  2038. $( this.domPosition.prev ).after( this.currentItem );
  2039. } else {
  2040. $( this.domPosition.parent ).prepend( this.currentItem );
  2041. }
  2042. }
  2043. return this;
  2044. },
  2045. serialize: function( o ) {
  2046. var items = this._getItemsAsjQuery( o && o.connected ),
  2047. str = [];
  2048. o = o || {};
  2049. $( items ).each( function() {
  2050. var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" )
  2051. .match( o.expression || ( /(.+)[\-=_](.+)/ ) );
  2052. if ( res ) {
  2053. str.push(
  2054. ( o.key || res[ 1 ] + "[]" ) +
  2055. "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) );
  2056. }
  2057. } );
  2058. if ( !str.length && o.key ) {
  2059. str.push( o.key + "=" );
  2060. }
  2061. return str.join( "&" );
  2062. },
  2063. toArray: function( o ) {
  2064. var items = this._getItemsAsjQuery( o && o.connected ),
  2065. ret = [];
  2066. o = o || {};
  2067. items.each( function() {
  2068. ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" );
  2069. } );
  2070. return ret;
  2071. },
  2072. /* Be careful with the following core functions */
  2073. _intersectsWith: function( item ) {
  2074. var x1 = this.positionAbs.left,
  2075. x2 = x1 + this.helperProportions.width,
  2076. y1 = this.positionAbs.top,
  2077. y2 = y1 + this.helperProportions.height,
  2078. l = item.left,
  2079. r = l + item.width,
  2080. t = item.top,
  2081. b = t + item.height,
  2082. dyClick = this.offset.click.top,
  2083. dxClick = this.offset.click.left,
  2084. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t &&
  2085. ( y1 + dyClick ) < b ),
  2086. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l &&
  2087. ( x1 + dxClick ) < r ),
  2088. isOverElement = isOverElementHeight && isOverElementWidth;
  2089. if ( this.options.tolerance === "pointer" ||
  2090. this.options.forcePointerForContainers ||
  2091. ( this.options.tolerance !== "pointer" &&
  2092. this.helperProportions[ this.floating ? "width" : "height" ] >
  2093. item[ this.floating ? "width" : "height" ] )
  2094. ) {
  2095. return isOverElement;
  2096. } else {
  2097. return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half
  2098. x2 - ( this.helperProportions.width / 2 ) < r && // Left Half
  2099. t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half
  2100. y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half
  2101. }
  2102. },
  2103. _intersectsWithPointer: function( item ) {
  2104. var verticalDirection, horizontalDirection,
  2105. isOverElementHeight = ( this.options.axis === "x" ) ||
  2106. this._isOverAxis(
  2107. this.positionAbs.top + this.offset.click.top, item.top, item.height ),
  2108. isOverElementWidth = ( this.options.axis === "y" ) ||
  2109. this._isOverAxis(
  2110. this.positionAbs.left + this.offset.click.left, item.left, item.width ),
  2111. isOverElement = isOverElementHeight && isOverElementWidth;
  2112. if ( !isOverElement ) {
  2113. return false;
  2114. }
  2115. verticalDirection = this._getDragVerticalDirection();
  2116. horizontalDirection = this._getDragHorizontalDirection();
  2117. return this.floating ?
  2118. ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 )
  2119. : ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) );
  2120. },
  2121. _intersectsWithSides: function( item ) {
  2122. var isOverBottomHalf = this._isOverAxis( this.positionAbs.top +
  2123. this.offset.click.top, item.top + ( item.height / 2 ), item.height ),
  2124. isOverRightHalf = this._isOverAxis( this.positionAbs.left +
  2125. this.offset.click.left, item.left + ( item.width / 2 ), item.width ),
  2126. verticalDirection = this._getDragVerticalDirection(),
  2127. horizontalDirection = this._getDragHorizontalDirection();
  2128. if ( this.floating && horizontalDirection ) {
  2129. return ( ( horizontalDirection === "right" && isOverRightHalf ) ||
  2130. ( horizontalDirection === "left" && !isOverRightHalf ) );
  2131. } else {
  2132. return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) ||
  2133. ( verticalDirection === "up" && !isOverBottomHalf ) );
  2134. }
  2135. },
  2136. _getDragVerticalDirection: function() {
  2137. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  2138. return delta !== 0 && ( delta > 0 ? "down" : "up" );
  2139. },
  2140. _getDragHorizontalDirection: function() {
  2141. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  2142. return delta !== 0 && ( delta > 0 ? "right" : "left" );
  2143. },
  2144. refresh: function( event ) {
  2145. this._refreshItems( event );
  2146. this._setHandleClassName();
  2147. this.refreshPositions();
  2148. return this;
  2149. },
  2150. _connectWith: function() {
  2151. var options = this.options;
  2152. return options.connectWith.constructor === String ?
  2153. [ options.connectWith ] :
  2154. options.connectWith;
  2155. },
  2156. _getItemsAsjQuery: function( connected ) {
  2157. var i, j, cur, inst,
  2158. items = [],
  2159. queries = [],
  2160. connectWith = this._connectWith();
  2161. if ( connectWith && connected ) {
  2162. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  2163. cur = $( connectWith[ i ], this.document[ 0 ] );
  2164. for ( j = cur.length - 1; j >= 0; j-- ) {
  2165. inst = $.data( cur[ j ], this.widgetFullName );
  2166. if ( inst && inst !== this && !inst.options.disabled ) {
  2167. queries.push( [ $.isFunction( inst.options.items ) ?
  2168. inst.options.items.call( inst.element ) :
  2169. $( inst.options.items, inst.element )
  2170. .not( ".ui-sortable-helper" )
  2171. .not( ".ui-sortable-placeholder" ), inst ] );
  2172. }
  2173. }
  2174. }
  2175. }
  2176. queries.push( [ $.isFunction( this.options.items ) ?
  2177. this.options.items
  2178. .call( this.element, null, { options: this.options, item: this.currentItem } ) :
  2179. $( this.options.items, this.element )
  2180. .not( ".ui-sortable-helper" )
  2181. .not( ".ui-sortable-placeholder" ), this ] );
  2182. function addItems() {
  2183. items.push( this );
  2184. }
  2185. for ( i = queries.length - 1; i >= 0; i-- ) {
  2186. queries[ i ][ 0 ].each( addItems );
  2187. }
  2188. return $( items );
  2189. },
  2190. _removeCurrentsFromItems: function() {
  2191. var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" );
  2192. this.items = $.grep( this.items, function( item ) {
  2193. for ( var j = 0; j < list.length; j++ ) {
  2194. if ( list[ j ] === item.item[ 0 ] ) {
  2195. return false;
  2196. }
  2197. }
  2198. return true;
  2199. } );
  2200. },
  2201. _refreshItems: function( event ) {
  2202. this.items = [];
  2203. this.containers = [ this ];
  2204. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  2205. items = this.items,
  2206. queries = [ [ $.isFunction( this.options.items ) ?
  2207. this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) :
  2208. $( this.options.items, this.element ), this ] ],
  2209. connectWith = this._connectWith();
  2210. //Shouldn't be run the first time through due to massive slow-down
  2211. if ( connectWith && this.ready ) {
  2212. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  2213. cur = $( connectWith[ i ], this.document[ 0 ] );
  2214. for ( j = cur.length - 1; j >= 0; j-- ) {
  2215. inst = $.data( cur[ j ], this.widgetFullName );
  2216. if ( inst && inst !== this && !inst.options.disabled ) {
  2217. queries.push( [ $.isFunction( inst.options.items ) ?
  2218. inst.options.items
  2219. .call( inst.element[ 0 ], event, { item: this.currentItem } ) :
  2220. $( inst.options.items, inst.element ), inst ] );
  2221. this.containers.push( inst );
  2222. }
  2223. }
  2224. }
  2225. }
  2226. for ( i = queries.length - 1; i >= 0; i-- ) {
  2227. targetData = queries[ i ][ 1 ];
  2228. _queries = queries[ i ][ 0 ];
  2229. for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) {
  2230. item = $( _queries[ j ] );
  2231. // Data for target checking (mouse manager)
  2232. item.data( this.widgetName + "-item", targetData );
  2233. items.push( {
  2234. item: item,
  2235. instance: targetData,
  2236. width: 0, height: 0,
  2237. left: 0, top: 0
  2238. } );
  2239. }
  2240. }
  2241. },
  2242. refreshPositions: function( fast ) {
  2243. // Determine whether items are being displayed horizontally
  2244. this.floating = this.items.length ?
  2245. this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
  2246. false;
  2247. //This has to be redone because due to the item being moved out/into the offsetParent,
  2248. // the offsetParent's position will change
  2249. if ( this.offsetParent && this.helper ) {
  2250. this.offset.parent = this._getParentOffset();
  2251. }
  2252. var i, item, t, p;
  2253. for ( i = this.items.length - 1; i >= 0; i-- ) {
  2254. item = this.items[ i ];
  2255. //We ignore calculating positions of all connected containers when we're not over them
  2256. if ( item.instance !== this.currentContainer && this.currentContainer &&
  2257. item.item[ 0 ] !== this.currentItem[ 0 ] ) {
  2258. continue;
  2259. }
  2260. t = this.options.toleranceElement ?
  2261. $( this.options.toleranceElement, item.item ) :
  2262. item.item;
  2263. if ( !fast ) {
  2264. item.width = t.outerWidth();
  2265. item.height = t.outerHeight();
  2266. }
  2267. p = t.offset();
  2268. item.left = p.left;
  2269. item.top = p.top;
  2270. }
  2271. if ( this.options.custom && this.options.custom.refreshContainers ) {
  2272. this.options.custom.refreshContainers.call( this );
  2273. } else {
  2274. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  2275. p = this.containers[ i ].element.offset();
  2276. this.containers[ i ].containerCache.left = p.left;
  2277. this.containers[ i ].containerCache.top = p.top;
  2278. this.containers[ i ].containerCache.width =
  2279. this.containers[ i ].element.outerWidth();
  2280. this.containers[ i ].containerCache.height =
  2281. this.containers[ i ].element.outerHeight();
  2282. }
  2283. }
  2284. return this;
  2285. },
  2286. _createPlaceholder: function( that ) {
  2287. that = that || this;
  2288. var className,
  2289. o = that.options;
  2290. if ( !o.placeholder || o.placeholder.constructor === String ) {
  2291. className = o.placeholder;
  2292. o.placeholder = {
  2293. element: function() {
  2294. var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(),
  2295. element = $( "<" + nodeName + ">", that.document[ 0 ] );
  2296. that._addClass( element, "ui-sortable-placeholder",
  2297. className || that.currentItem[ 0 ].className )
  2298. ._removeClass( element, "ui-sortable-helper" );
  2299. if ( nodeName === "tbody" ) {
  2300. that._createTrPlaceholder(
  2301. that.currentItem.find( "tr" ).eq( 0 ),
  2302. $( "<tr>", that.document[ 0 ] ).appendTo( element )
  2303. );
  2304. } else if ( nodeName === "tr" ) {
  2305. that._createTrPlaceholder( that.currentItem, element );
  2306. } else if ( nodeName === "img" ) {
  2307. element.attr( "src", that.currentItem.attr( "src" ) );
  2308. }
  2309. if ( !className ) {
  2310. element.css( "visibility", "hidden" );
  2311. }
  2312. return element;
  2313. },
  2314. update: function( container, p ) {
  2315. // 1. If a className is set as 'placeholder option, we don't force sizes -
  2316. // the class is responsible for that
  2317. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a
  2318. // class name is specified
  2319. if ( className && !o.forcePlaceholderSize ) {
  2320. return;
  2321. }
  2322. //If the element doesn't have a actual height by itself (without styles coming
  2323. // from a stylesheet), it receives the inline height from the dragged item
  2324. if ( !p.height() ) {
  2325. p.height(
  2326. that.currentItem.innerHeight() -
  2327. parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -
  2328. parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) );
  2329. }
  2330. if ( !p.width() ) {
  2331. p.width(
  2332. that.currentItem.innerWidth() -
  2333. parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) -
  2334. parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) );
  2335. }
  2336. }
  2337. };
  2338. }
  2339. //Create the placeholder
  2340. that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) );
  2341. //Append it after the actual current item
  2342. that.currentItem.after( that.placeholder );
  2343. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  2344. o.placeholder.update( that, that.placeholder );
  2345. },
  2346. _createTrPlaceholder: function( sourceTr, targetTr ) {
  2347. var that = this;
  2348. sourceTr.children().each( function() {
  2349. $( "<td>&#160;</td>", that.document[ 0 ] )
  2350. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  2351. .appendTo( targetTr );
  2352. } );
  2353. },
  2354. _contactContainers: function( event ) {
  2355. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom,
  2356. floating, axis,
  2357. innermostContainer = null,
  2358. innermostIndex = null;
  2359. // Get innermost container that intersects with item
  2360. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  2361. // Never consider a container that's located within the item itself
  2362. if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) {
  2363. continue;
  2364. }
  2365. if ( this._intersectsWith( this.containers[ i ].containerCache ) ) {
  2366. // If we've already found a container and it's more "inner" than this, then continue
  2367. if ( innermostContainer &&
  2368. $.contains(
  2369. this.containers[ i ].element[ 0 ],
  2370. innermostContainer.element[ 0 ] ) ) {
  2371. continue;
  2372. }
  2373. innermostContainer = this.containers[ i ];
  2374. innermostIndex = i;
  2375. } else {
  2376. // container doesn't intersect. trigger "out" event if necessary
  2377. if ( this.containers[ i ].containerCache.over ) {
  2378. this.containers[ i ]._trigger( "out", event, this._uiHash( this ) );
  2379. this.containers[ i ].containerCache.over = 0;
  2380. }
  2381. }
  2382. }
  2383. // If no intersecting containers found, return
  2384. if ( !innermostContainer ) {
  2385. return;
  2386. }
  2387. // Move the item into the container if it's not there already
  2388. if ( this.containers.length === 1 ) {
  2389. if ( !this.containers[ innermostIndex ].containerCache.over ) {
  2390. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  2391. this.containers[ innermostIndex ].containerCache.over = 1;
  2392. }
  2393. } else {
  2394. // When entering a new container, we will find the item with the least distance and
  2395. // append our item near it
  2396. dist = 10000;
  2397. itemWithLeastDistance = null;
  2398. floating = innermostContainer.floating || this._isFloating( this.currentItem );
  2399. posProperty = floating ? "left" : "top";
  2400. sizeProperty = floating ? "width" : "height";
  2401. axis = floating ? "pageX" : "pageY";
  2402. for ( j = this.items.length - 1; j >= 0; j-- ) {
  2403. if ( !$.contains(
  2404. this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] )
  2405. ) {
  2406. continue;
  2407. }
  2408. if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
  2409. continue;
  2410. }
  2411. cur = this.items[ j ].item.offset()[ posProperty ];
  2412. nearBottom = false;
  2413. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  2414. nearBottom = true;
  2415. }
  2416. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  2417. dist = Math.abs( event[ axis ] - cur );
  2418. itemWithLeastDistance = this.items[ j ];
  2419. this.direction = nearBottom ? "up" : "down";
  2420. }
  2421. }
  2422. //Check if dropOnEmpty is enabled
  2423. if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) {
  2424. return;
  2425. }
  2426. if ( this.currentContainer === this.containers[ innermostIndex ] ) {
  2427. if ( !this.currentContainer.containerCache.over ) {
  2428. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  2429. this.currentContainer.containerCache.over = 1;
  2430. }
  2431. return;
  2432. }
  2433. itemWithLeastDistance ?
  2434. this._rearrange( event, itemWithLeastDistance, null, true ) :
  2435. this._rearrange( event, null, this.containers[ innermostIndex ].element, true );
  2436. this._trigger( "change", event, this._uiHash() );
  2437. this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) );
  2438. this.currentContainer = this.containers[ innermostIndex ];
  2439. //Update the placeholder
  2440. this.options.placeholder.update( this.currentContainer, this.placeholder );
  2441. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  2442. this.containers[ innermostIndex ].containerCache.over = 1;
  2443. }
  2444. },
  2445. _createHelper: function( event ) {
  2446. var o = this.options,
  2447. helper = $.isFunction( o.helper ) ?
  2448. $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) :
  2449. ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem );
  2450. //Add the helper to the DOM if that didn't happen already
  2451. if ( !helper.parents( "body" ).length ) {
  2452. $( o.appendTo !== "parent" ?
  2453. o.appendTo :
  2454. this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] );
  2455. }
  2456. if ( helper[ 0 ] === this.currentItem[ 0 ] ) {
  2457. this._storedCSS = {
  2458. width: this.currentItem[ 0 ].style.width,
  2459. height: this.currentItem[ 0 ].style.height,
  2460. position: this.currentItem.css( "position" ),
  2461. top: this.currentItem.css( "top" ),
  2462. left: this.currentItem.css( "left" )
  2463. };
  2464. }
  2465. if ( !helper[ 0 ].style.width || o.forceHelperSize ) {
  2466. helper.width( this.currentItem.width() );
  2467. }
  2468. if ( !helper[ 0 ].style.height || o.forceHelperSize ) {
  2469. helper.height( this.currentItem.height() );
  2470. }
  2471. return helper;
  2472. },
  2473. _adjustOffsetFromHelper: function( obj ) {
  2474. if ( typeof obj === "string" ) {
  2475. obj = obj.split( " " );
  2476. }
  2477. if ( $.isArray( obj ) ) {
  2478. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  2479. }
  2480. if ( "left" in obj ) {
  2481. this.offset.click.left = obj.left + this.margins.left;
  2482. }
  2483. if ( "right" in obj ) {
  2484. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  2485. }
  2486. if ( "top" in obj ) {
  2487. this.offset.click.top = obj.top + this.margins.top;
  2488. }
  2489. if ( "bottom" in obj ) {
  2490. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  2491. }
  2492. },
  2493. _getParentOffset: function() {
  2494. //Get the offsetParent and cache its position
  2495. this.offsetParent = this.helper.offsetParent();
  2496. var po = this.offsetParent.offset();
  2497. // This is a special case where we need to modify a offset calculated on start, since the
  2498. // following happened:
  2499. // 1. The position of the helper is absolute, so it's position is calculated based on the
  2500. // next positioned parent
  2501. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  2502. // the document, which means that the scroll is included in the initial calculation of the
  2503. // offset of the parent, and never recalculated upon drag
  2504. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  2505. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  2506. po.left += this.scrollParent.scrollLeft();
  2507. po.top += this.scrollParent.scrollTop();
  2508. }
  2509. // This needs to be actually done for all browsers, since pageX/pageY includes this
  2510. // information with an ugly IE fix
  2511. if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ||
  2512. ( this.offsetParent[ 0 ].tagName &&
  2513. this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
  2514. po = { top: 0, left: 0 };
  2515. }
  2516. return {
  2517. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  2518. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  2519. };
  2520. },
  2521. _getRelativeOffset: function() {
  2522. if ( this.cssPosition === "relative" ) {
  2523. var p = this.currentItem.position();
  2524. return {
  2525. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  2526. this.scrollParent.scrollTop(),
  2527. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  2528. this.scrollParent.scrollLeft()
  2529. };
  2530. } else {
  2531. return { top: 0, left: 0 };
  2532. }
  2533. },
  2534. _cacheMargins: function() {
  2535. this.margins = {
  2536. left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ),
  2537. top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 )
  2538. };
  2539. },
  2540. _cacheHelperProportions: function() {
  2541. this.helperProportions = {
  2542. width: this.helper.outerWidth(),
  2543. height: this.helper.outerHeight()
  2544. };
  2545. },
  2546. _setContainment: function() {
  2547. var ce, co, over,
  2548. o = this.options;
  2549. if ( o.containment === "parent" ) {
  2550. o.containment = this.helper[ 0 ].parentNode;
  2551. }
  2552. if ( o.containment === "document" || o.containment === "window" ) {
  2553. this.containment = [
  2554. 0 - this.offset.relative.left - this.offset.parent.left,
  2555. 0 - this.offset.relative.top - this.offset.parent.top,
  2556. o.containment === "document" ?
  2557. this.document.width() :
  2558. this.window.width() - this.helperProportions.width - this.margins.left,
  2559. ( o.containment === "document" ?
  2560. ( this.document.height() || document.body.parentNode.scrollHeight ) :
  2561. this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight
  2562. ) - this.helperProportions.height - this.margins.top
  2563. ];
  2564. }
  2565. if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
  2566. ce = $( o.containment )[ 0 ];
  2567. co = $( o.containment ).offset();
  2568. over = ( $( ce ).css( "overflow" ) !== "hidden" );
  2569. this.containment = [
  2570. co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) +
  2571. ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
  2572. co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) +
  2573. ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
  2574. co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  2575. ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) -
  2576. ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) -
  2577. this.helperProportions.width - this.margins.left,
  2578. co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  2579. ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) -
  2580. ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) -
  2581. this.helperProportions.height - this.margins.top
  2582. ];
  2583. }
  2584. },
  2585. _convertPositionTo: function( d, pos ) {
  2586. if ( !pos ) {
  2587. pos = this.position;
  2588. }
  2589. var mod = d === "absolute" ? 1 : -1,
  2590. scroll = this.cssPosition === "absolute" &&
  2591. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  2592. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  2593. this.offsetParent :
  2594. this.scrollParent,
  2595. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  2596. return {
  2597. top: (
  2598. // The absolute mouse position
  2599. pos.top +
  2600. // Only for relative positioned nodes: Relative offset from element to offset parent
  2601. this.offset.relative.top * mod +
  2602. // The offsetParent's offset without borders (offset + border)
  2603. this.offset.parent.top * mod -
  2604. ( ( this.cssPosition === "fixed" ?
  2605. -this.scrollParent.scrollTop() :
  2606. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod )
  2607. ),
  2608. left: (
  2609. // The absolute mouse position
  2610. pos.left +
  2611. // Only for relative positioned nodes: Relative offset from element to offset parent
  2612. this.offset.relative.left * mod +
  2613. // The offsetParent's offset without borders (offset + border)
  2614. this.offset.parent.left * mod -
  2615. ( ( this.cssPosition === "fixed" ?
  2616. -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 :
  2617. scroll.scrollLeft() ) * mod )
  2618. )
  2619. };
  2620. },
  2621. _generatePosition: function( event ) {
  2622. var top, left,
  2623. o = this.options,
  2624. pageX = event.pageX,
  2625. pageY = event.pageY,
  2626. scroll = this.cssPosition === "absolute" &&
  2627. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  2628. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  2629. this.offsetParent :
  2630. this.scrollParent,
  2631. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  2632. // This is another very weird special case that only happens for relative elements:
  2633. // 1. If the css position is relative
  2634. // 2. and the scroll parent is the document or similar to the offset parent
  2635. // we have to refresh the relative offset during the scroll so there are no jumps
  2636. if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  2637. this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
  2638. this.offset.relative = this._getRelativeOffset();
  2639. }
  2640. /*
  2641. * - Position constraining -
  2642. * Constrain the position to a mix of grid, containment.
  2643. */
  2644. if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options
  2645. if ( this.containment ) {
  2646. if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) {
  2647. pageX = this.containment[ 0 ] + this.offset.click.left;
  2648. }
  2649. if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) {
  2650. pageY = this.containment[ 1 ] + this.offset.click.top;
  2651. }
  2652. if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) {
  2653. pageX = this.containment[ 2 ] + this.offset.click.left;
  2654. }
  2655. if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) {
  2656. pageY = this.containment[ 3 ] + this.offset.click.top;
  2657. }
  2658. }
  2659. if ( o.grid ) {
  2660. top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) /
  2661. o.grid[ 1 ] ) * o.grid[ 1 ];
  2662. pageY = this.containment ?
  2663. ( ( top - this.offset.click.top >= this.containment[ 1 ] &&
  2664. top - this.offset.click.top <= this.containment[ 3 ] ) ?
  2665. top :
  2666. ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ?
  2667. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) :
  2668. top;
  2669. left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) /
  2670. o.grid[ 0 ] ) * o.grid[ 0 ];
  2671. pageX = this.containment ?
  2672. ( ( left - this.offset.click.left >= this.containment[ 0 ] &&
  2673. left - this.offset.click.left <= this.containment[ 2 ] ) ?
  2674. left :
  2675. ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ?
  2676. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) :
  2677. left;
  2678. }
  2679. }
  2680. return {
  2681. top: (
  2682. // The absolute mouse position
  2683. pageY -
  2684. // Click offset (relative to the element)
  2685. this.offset.click.top -
  2686. // Only for relative positioned nodes: Relative offset from element to offset parent
  2687. this.offset.relative.top -
  2688. // The offsetParent's offset without borders (offset + border)
  2689. this.offset.parent.top +
  2690. ( ( this.cssPosition === "fixed" ?
  2691. -this.scrollParent.scrollTop() :
  2692. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) )
  2693. ),
  2694. left: (
  2695. // The absolute mouse position
  2696. pageX -
  2697. // Click offset (relative to the element)
  2698. this.offset.click.left -
  2699. // Only for relative positioned nodes: Relative offset from element to offset parent
  2700. this.offset.relative.left -
  2701. // The offsetParent's offset without borders (offset + border)
  2702. this.offset.parent.left +
  2703. ( ( this.cssPosition === "fixed" ?
  2704. -this.scrollParent.scrollLeft() :
  2705. scrollIsRootNode ? 0 : scroll.scrollLeft() ) )
  2706. )
  2707. };
  2708. },
  2709. _rearrange: function( event, i, a, hardRefresh ) {
  2710. a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) :
  2711. i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ],
  2712. ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) );
  2713. //Various things done here to improve the performance:
  2714. // 1. we create a setTimeout, that calls refreshPositions
  2715. // 2. on the instance, we have a counter variable, that get's higher after every append
  2716. // 3. on the local scope, we copy the counter variable, and check in the timeout,
  2717. // if it's still the same
  2718. // 4. this lets only the last addition to the timeout stack through
  2719. this.counter = this.counter ? ++this.counter : 1;
  2720. var counter = this.counter;
  2721. this._delay( function() {
  2722. if ( counter === this.counter ) {
  2723. //Precompute after each DOM insertion, NOT on mousemove
  2724. this.refreshPositions( !hardRefresh );
  2725. }
  2726. } );
  2727. },
  2728. _clear: function( event, noPropagation ) {
  2729. this.reverting = false;
  2730. // We delay all events that have to be triggered to after the point where the placeholder
  2731. // has been removed and everything else normalized again
  2732. var i,
  2733. delayedTriggers = [];
  2734. // We first have to update the dom position of the actual currentItem
  2735. // Note: don't do it if the current item is already removed (by a user), or it gets
  2736. // reappended (see #4088)
  2737. if ( !this._noFinalSort && this.currentItem.parent().length ) {
  2738. this.placeholder.before( this.currentItem );
  2739. }
  2740. this._noFinalSort = null;
  2741. if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) {
  2742. for ( i in this._storedCSS ) {
  2743. if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) {
  2744. this._storedCSS[ i ] = "";
  2745. }
  2746. }
  2747. this.currentItem.css( this._storedCSS );
  2748. this._removeClass( this.currentItem, "ui-sortable-helper" );
  2749. } else {
  2750. this.currentItem.show();
  2751. }
  2752. if ( this.fromOutside && !noPropagation ) {
  2753. delayedTriggers.push( function( event ) {
  2754. this._trigger( "receive", event, this._uiHash( this.fromOutside ) );
  2755. } );
  2756. }
  2757. if ( ( this.fromOutside ||
  2758. this.domPosition.prev !==
  2759. this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] ||
  2760. this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {
  2761. // Trigger update callback if the DOM position has changed
  2762. delayedTriggers.push( function( event ) {
  2763. this._trigger( "update", event, this._uiHash() );
  2764. } );
  2765. }
  2766. // Check if the items Container has Changed and trigger appropriate
  2767. // events.
  2768. if ( this !== this.currentContainer ) {
  2769. if ( !noPropagation ) {
  2770. delayedTriggers.push( function( event ) {
  2771. this._trigger( "remove", event, this._uiHash() );
  2772. } );
  2773. delayedTriggers.push( ( function( c ) {
  2774. return function( event ) {
  2775. c._trigger( "receive", event, this._uiHash( this ) );
  2776. };
  2777. } ).call( this, this.currentContainer ) );
  2778. delayedTriggers.push( ( function( c ) {
  2779. return function( event ) {
  2780. c._trigger( "update", event, this._uiHash( this ) );
  2781. };
  2782. } ).call( this, this.currentContainer ) );
  2783. }
  2784. }
  2785. //Post events to containers
  2786. function delayEvent( type, instance, container ) {
  2787. return function( event ) {
  2788. container._trigger( type, event, instance._uiHash( instance ) );
  2789. };
  2790. }
  2791. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  2792. if ( !noPropagation ) {
  2793. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  2794. }
  2795. if ( this.containers[ i ].containerCache.over ) {
  2796. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  2797. this.containers[ i ].containerCache.over = 0;
  2798. }
  2799. }
  2800. //Do what was originally in plugins
  2801. if ( this.storedCursor ) {
  2802. this.document.find( "body" ).css( "cursor", this.storedCursor );
  2803. this.storedStylesheet.remove();
  2804. }
  2805. if ( this._storedOpacity ) {
  2806. this.helper.css( "opacity", this._storedOpacity );
  2807. }
  2808. if ( this._storedZIndex ) {
  2809. this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex );
  2810. }
  2811. this.dragging = false;
  2812. if ( !noPropagation ) {
  2813. this._trigger( "beforeStop", event, this._uiHash() );
  2814. }
  2815. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  2816. // it unbinds ALL events from the original node!
  2817. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  2818. if ( !this.cancelHelperRemoval ) {
  2819. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  2820. this.helper.remove();
  2821. }
  2822. this.helper = null;
  2823. }
  2824. if ( !noPropagation ) {
  2825. for ( i = 0; i < delayedTriggers.length; i++ ) {
  2826. // Trigger all delayed events
  2827. delayedTriggers[ i ].call( this, event );
  2828. }
  2829. this._trigger( "stop", event, this._uiHash() );
  2830. }
  2831. this.fromOutside = false;
  2832. return !this.cancelHelperRemoval;
  2833. },
  2834. _trigger: function() {
  2835. if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) {
  2836. this.cancel();
  2837. }
  2838. },
  2839. _uiHash: function( _inst ) {
  2840. var inst = _inst || this;
  2841. return {
  2842. helper: inst.helper,
  2843. placeholder: inst.placeholder || $( [] ),
  2844. position: inst.position,
  2845. originalPosition: inst.originalPosition,
  2846. offset: inst.positionAbs,
  2847. item: inst.currentItem,
  2848. sender: _inst ? _inst.element : null
  2849. };
  2850. }
  2851. } );
  2852. }));