Node-Red configuration
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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034
  1. /*! jQuery UI - v1.12.1 - 2019-11-20
  2. * http://jqueryui.com
  3. * Includes: widget.js, data.js, disable-selection.js, scroll-parent.js, widgets/draggable.js, widgets/droppable.js, widgets/resizable.js, widgets/mouse.js
  4. * Copyright jQuery Foundation and other contributors; Licensed MIT @preserve*/
  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 :data 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. //>>label: :data Selector
  617. //>>group: Core
  618. //>>description: Selects elements which have data stored under the specified key.
  619. //>>docs: http://api.jqueryui.com/data-selector/
  620. var data = $.extend( $.expr[ ":" ], {
  621. data: $.expr.createPseudo ?
  622. $.expr.createPseudo( function( dataName ) {
  623. return function( elem ) {
  624. return !!$.data( elem, dataName );
  625. };
  626. } ) :
  627. // Support: jQuery <1.8
  628. function( elem, i, match ) {
  629. return !!$.data( elem, match[ 3 ] );
  630. }
  631. } );
  632. /*!
  633. * jQuery UI Disable Selection 1.12.1
  634. * http://jqueryui.com
  635. *
  636. * Copyright jQuery Foundation and other contributors
  637. * Released under the MIT license.
  638. * http://jquery.org/license
  639. */
  640. //>>label: disableSelection
  641. //>>group: Core
  642. //>>description: Disable selection of text content within the set of matched elements.
  643. //>>docs: http://api.jqueryui.com/disableSelection/
  644. // This file is deprecated
  645. var disableSelection = $.fn.extend( {
  646. disableSelection: ( function() {
  647. var eventType = "onselectstart" in document.createElement( "div" ) ?
  648. "selectstart" :
  649. "mousedown";
  650. return function() {
  651. return this.on( eventType + ".ui-disableSelection", function( event ) {
  652. event.preventDefault();
  653. } );
  654. };
  655. } )(),
  656. enableSelection: function() {
  657. return this.off( ".ui-disableSelection" );
  658. }
  659. } );
  660. /*!
  661. * jQuery UI Scroll Parent 1.12.1
  662. * http://jqueryui.com
  663. *
  664. * Copyright jQuery Foundation and other contributors
  665. * Released under the MIT license.
  666. * http://jquery.org/license
  667. */
  668. //>>label: scrollParent
  669. //>>group: Core
  670. //>>description: Get the closest ancestor element that is scrollable.
  671. //>>docs: http://api.jqueryui.com/scrollParent/
  672. var scrollParent = $.fn.scrollParent = function( includeHidden ) {
  673. var position = this.css( "position" ),
  674. excludeStaticParent = position === "absolute",
  675. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  676. scrollParent = this.parents().filter( function() {
  677. var parent = $( this );
  678. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  679. return false;
  680. }
  681. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) +
  682. parent.css( "overflow-x" ) );
  683. } ).eq( 0 );
  684. return position === "fixed" || !scrollParent.length ?
  685. $( this[ 0 ].ownerDocument || document ) :
  686. scrollParent;
  687. };
  688. // This file is deprecated
  689. var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  690. /*!
  691. * jQuery UI Mouse 1.12.1
  692. * http://jqueryui.com
  693. *
  694. * Copyright jQuery Foundation and other contributors
  695. * Released under the MIT license.
  696. * http://jquery.org/license
  697. */
  698. //>>label: Mouse
  699. //>>group: Widgets
  700. //>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
  701. //>>docs: http://api.jqueryui.com/mouse/
  702. var mouseHandled = false;
  703. $( document ).on( "mouseup", function() {
  704. mouseHandled = false;
  705. } );
  706. var widgetsMouse = $.widget( "ui.mouse", {
  707. version: "1.12.1",
  708. options: {
  709. cancel: "input, textarea, button, select, option",
  710. distance: 1,
  711. delay: 0
  712. },
  713. _mouseInit: function() {
  714. var that = this;
  715. this.element
  716. .on( "mousedown." + this.widgetName, function( event ) {
  717. return that._mouseDown( event );
  718. } )
  719. .on( "click." + this.widgetName, function( event ) {
  720. if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
  721. $.removeData( event.target, that.widgetName + ".preventClickEvent" );
  722. event.stopImmediatePropagation();
  723. return false;
  724. }
  725. } );
  726. this.started = false;
  727. },
  728. // TODO: make sure destroying one instance of mouse doesn't mess with
  729. // other instances of mouse
  730. _mouseDestroy: function() {
  731. this.element.off( "." + this.widgetName );
  732. if ( this._mouseMoveDelegate ) {
  733. this.document
  734. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  735. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  736. }
  737. },
  738. _mouseDown: function( event ) {
  739. // don't let more than one widget handle mouseStart
  740. if ( mouseHandled ) {
  741. return;
  742. }
  743. this._mouseMoved = false;
  744. // We may have missed mouseup (out of window)
  745. ( this._mouseStarted && this._mouseUp( event ) );
  746. this._mouseDownEvent = event;
  747. var that = this,
  748. btnIsLeft = ( event.which === 1 ),
  749. // event.target.nodeName works around a bug in IE 8 with
  750. // disabled inputs (#7620)
  751. elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ?
  752. $( event.target ).closest( this.options.cancel ).length : false );
  753. if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
  754. return true;
  755. }
  756. this.mouseDelayMet = !this.options.delay;
  757. if ( !this.mouseDelayMet ) {
  758. this._mouseDelayTimer = setTimeout( function() {
  759. that.mouseDelayMet = true;
  760. }, this.options.delay );
  761. }
  762. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  763. this._mouseStarted = ( this._mouseStart( event ) !== false );
  764. if ( !this._mouseStarted ) {
  765. event.preventDefault();
  766. return true;
  767. }
  768. }
  769. // Click event may never have fired (Gecko & Opera)
  770. if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
  771. $.removeData( event.target, this.widgetName + ".preventClickEvent" );
  772. }
  773. // These delegates are required to keep context
  774. this._mouseMoveDelegate = function( event ) {
  775. return that._mouseMove( event );
  776. };
  777. this._mouseUpDelegate = function( event ) {
  778. return that._mouseUp( event );
  779. };
  780. this.document
  781. .on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  782. .on( "mouseup." + this.widgetName, this._mouseUpDelegate );
  783. event.preventDefault();
  784. mouseHandled = true;
  785. return true;
  786. },
  787. _mouseMove: function( event ) {
  788. // Only check for mouseups outside the document if you've moved inside the document
  789. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  790. // fire a mousemove event if content is placed under the cursor. See #7778
  791. // Support: IE <9
  792. if ( this._mouseMoved ) {
  793. // IE mouseup check - mouseup happened when mouse was out of window
  794. if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) &&
  795. !event.button ) {
  796. return this._mouseUp( event );
  797. // Iframe mouseup check - mouseup occurred in another document
  798. } else if ( !event.which ) {
  799. // Support: Safari <=8 - 9
  800. // Safari sets which to 0 if you press any of the following keys
  801. // during a drag (#14461)
  802. if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
  803. event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
  804. this.ignoreMissingWhich = true;
  805. } else if ( !this.ignoreMissingWhich ) {
  806. return this._mouseUp( event );
  807. }
  808. }
  809. }
  810. if ( event.which || event.button ) {
  811. this._mouseMoved = true;
  812. }
  813. if ( this._mouseStarted ) {
  814. this._mouseDrag( event );
  815. return event.preventDefault();
  816. }
  817. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  818. this._mouseStarted =
  819. ( this._mouseStart( this._mouseDownEvent, event ) !== false );
  820. ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) );
  821. }
  822. return !this._mouseStarted;
  823. },
  824. _mouseUp: function( event ) {
  825. this.document
  826. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  827. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  828. if ( this._mouseStarted ) {
  829. this._mouseStarted = false;
  830. if ( event.target === this._mouseDownEvent.target ) {
  831. $.data( event.target, this.widgetName + ".preventClickEvent", true );
  832. }
  833. this._mouseStop( event );
  834. }
  835. if ( this._mouseDelayTimer ) {
  836. clearTimeout( this._mouseDelayTimer );
  837. delete this._mouseDelayTimer;
  838. }
  839. this.ignoreMissingWhich = false;
  840. mouseHandled = false;
  841. event.preventDefault();
  842. },
  843. _mouseDistanceMet: function( event ) {
  844. return ( Math.max(
  845. Math.abs( this._mouseDownEvent.pageX - event.pageX ),
  846. Math.abs( this._mouseDownEvent.pageY - event.pageY )
  847. ) >= this.options.distance
  848. );
  849. },
  850. _mouseDelayMet: function( /* event */ ) {
  851. return this.mouseDelayMet;
  852. },
  853. // These are placeholder methods, to be overriden by extending plugin
  854. _mouseStart: function( /* event */ ) {},
  855. _mouseDrag: function( /* event */ ) {},
  856. _mouseStop: function( /* event */ ) {},
  857. _mouseCapture: function( /* event */ ) { return true; }
  858. } );
  859. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  860. var plugin = $.ui.plugin = {
  861. add: function( module, option, set ) {
  862. var i,
  863. proto = $.ui[ module ].prototype;
  864. for ( i in set ) {
  865. proto.plugins[ i ] = proto.plugins[ i ] || [];
  866. proto.plugins[ i ].push( [ option, set[ i ] ] );
  867. }
  868. },
  869. call: function( instance, name, args, allowDisconnected ) {
  870. var i,
  871. set = instance.plugins[ name ];
  872. if ( !set ) {
  873. return;
  874. }
  875. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode ||
  876. instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  877. return;
  878. }
  879. for ( i = 0; i < set.length; i++ ) {
  880. if ( instance.options[ set[ i ][ 0 ] ] ) {
  881. set[ i ][ 1 ].apply( instance.element, args );
  882. }
  883. }
  884. }
  885. };
  886. var safeActiveElement = $.ui.safeActiveElement = function( document ) {
  887. var activeElement;
  888. // Support: IE 9 only
  889. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  890. try {
  891. activeElement = document.activeElement;
  892. } catch ( error ) {
  893. activeElement = document.body;
  894. }
  895. // Support: IE 9 - 11 only
  896. // IE may return null instead of an element
  897. // Interestingly, this only seems to occur when NOT in an iframe
  898. if ( !activeElement ) {
  899. activeElement = document.body;
  900. }
  901. // Support: IE 11 only
  902. // IE11 returns a seemingly empty object in some cases when accessing
  903. // document.activeElement from an <iframe>
  904. if ( !activeElement.nodeName ) {
  905. activeElement = document.body;
  906. }
  907. return activeElement;
  908. };
  909. var safeBlur = $.ui.safeBlur = function( element ) {
  910. // Support: IE9 - 10 only
  911. // If the <body> is blurred, IE will switch windows, see #9420
  912. if ( element && element.nodeName.toLowerCase() !== "body" ) {
  913. $( element ).trigger( "blur" );
  914. }
  915. };
  916. /*!
  917. * jQuery UI Draggable 1.12.1
  918. * http://jqueryui.com
  919. *
  920. * Copyright jQuery Foundation and other contributors
  921. * Released under the MIT license.
  922. * http://jquery.org/license
  923. */
  924. //>>label: Draggable
  925. //>>group: Interactions
  926. //>>description: Enables dragging functionality for any element.
  927. //>>docs: http://api.jqueryui.com/draggable/
  928. //>>demos: http://jqueryui.com/draggable/
  929. //>>css.structure: ../../themes/base/draggable.css
  930. $.widget( "ui.draggable", $.ui.mouse, {
  931. version: "1.12.1",
  932. widgetEventPrefix: "drag",
  933. options: {
  934. addClasses: true,
  935. appendTo: "parent",
  936. axis: false,
  937. connectToSortable: false,
  938. containment: false,
  939. cursor: "auto",
  940. cursorAt: false,
  941. grid: false,
  942. handle: false,
  943. helper: "original",
  944. iframeFix: false,
  945. opacity: false,
  946. refreshPositions: false,
  947. revert: false,
  948. revertDuration: 500,
  949. scope: "default",
  950. scroll: true,
  951. scrollSensitivity: 20,
  952. scrollSpeed: 20,
  953. snap: false,
  954. snapMode: "both",
  955. snapTolerance: 20,
  956. stack: false,
  957. zIndex: false,
  958. // Callbacks
  959. drag: null,
  960. start: null,
  961. stop: null
  962. },
  963. _create: function() {
  964. if ( this.options.helper === "original" ) {
  965. this._setPositionRelative();
  966. }
  967. if ( this.options.addClasses ) {
  968. this._addClass( "ui-draggable" );
  969. }
  970. this._setHandleClassName();
  971. this._mouseInit();
  972. },
  973. _setOption: function( key, value ) {
  974. this._super( key, value );
  975. if ( key === "handle" ) {
  976. this._removeHandleClassName();
  977. this._setHandleClassName();
  978. }
  979. },
  980. _destroy: function() {
  981. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  982. this.destroyOnClear = true;
  983. return;
  984. }
  985. this._removeHandleClassName();
  986. this._mouseDestroy();
  987. },
  988. _mouseCapture: function( event ) {
  989. var o = this.options;
  990. // Among others, prevent a drag on a resizable-handle
  991. if ( this.helper || o.disabled ||
  992. $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) {
  993. return false;
  994. }
  995. //Quit if we're not on a valid handle
  996. this.handle = this._getHandle( event );
  997. if ( !this.handle ) {
  998. return false;
  999. }
  1000. this._blurActiveElement( event );
  1001. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  1002. return true;
  1003. },
  1004. _blockFrames: function( selector ) {
  1005. this.iframeBlocks = this.document.find( selector ).map( function() {
  1006. var iframe = $( this );
  1007. return $( "<div>" )
  1008. .css( "position", "absolute" )
  1009. .appendTo( iframe.parent() )
  1010. .outerWidth( iframe.outerWidth() )
  1011. .outerHeight( iframe.outerHeight() )
  1012. .offset( iframe.offset() )[ 0 ];
  1013. } );
  1014. },
  1015. _unblockFrames: function() {
  1016. if ( this.iframeBlocks ) {
  1017. this.iframeBlocks.remove();
  1018. delete this.iframeBlocks;
  1019. }
  1020. },
  1021. _blurActiveElement: function( event ) {
  1022. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  1023. target = $( event.target );
  1024. // Don't blur if the event occurred on an element that is within
  1025. // the currently focused element
  1026. // See #10527, #12472
  1027. if ( target.closest( activeElement ).length ) {
  1028. return;
  1029. }
  1030. // Blur any element that currently has focus, see #4261
  1031. $.ui.safeBlur( activeElement );
  1032. },
  1033. _mouseStart: function( event ) {
  1034. var o = this.options;
  1035. //Create and append the visible helper
  1036. this.helper = this._createHelper( event );
  1037. this._addClass( this.helper, "ui-draggable-dragging" );
  1038. //Cache the helper size
  1039. this._cacheHelperProportions();
  1040. //If ddmanager is used for droppables, set the global draggable
  1041. if ( $.ui.ddmanager ) {
  1042. $.ui.ddmanager.current = this;
  1043. }
  1044. /*
  1045. * - Position generation -
  1046. * This block generates everything position related - it's the core of draggables.
  1047. */
  1048. //Cache the margins of the original element
  1049. this._cacheMargins();
  1050. //Store the helper's css position
  1051. this.cssPosition = this.helper.css( "position" );
  1052. this.scrollParent = this.helper.scrollParent( true );
  1053. this.offsetParent = this.helper.offsetParent();
  1054. this.hasFixedAncestor = this.helper.parents().filter( function() {
  1055. return $( this ).css( "position" ) === "fixed";
  1056. } ).length > 0;
  1057. //The element's absolute position on the page minus margins
  1058. this.positionAbs = this.element.offset();
  1059. this._refreshOffsets( event );
  1060. //Generate the original position
  1061. this.originalPosition = this.position = this._generatePosition( event, false );
  1062. this.originalPageX = event.pageX;
  1063. this.originalPageY = event.pageY;
  1064. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  1065. ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
  1066. //Set a containment if given in the options
  1067. this._setContainment();
  1068. //Trigger event + callbacks
  1069. if ( this._trigger( "start", event ) === false ) {
  1070. this._clear();
  1071. return false;
  1072. }
  1073. //Recache the helper size
  1074. this._cacheHelperProportions();
  1075. //Prepare the droppable offsets
  1076. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  1077. $.ui.ddmanager.prepareOffsets( this, event );
  1078. }
  1079. // Execute the drag once - this causes the helper not to be visible before getting its
  1080. // correct position
  1081. this._mouseDrag( event, true );
  1082. // If the ddmanager is used for droppables, inform the manager that dragging has started
  1083. // (see #5003)
  1084. if ( $.ui.ddmanager ) {
  1085. $.ui.ddmanager.dragStart( this, event );
  1086. }
  1087. return true;
  1088. },
  1089. _refreshOffsets: function( event ) {
  1090. this.offset = {
  1091. top: this.positionAbs.top - this.margins.top,
  1092. left: this.positionAbs.left - this.margins.left,
  1093. scroll: false,
  1094. parent: this._getParentOffset(),
  1095. relative: this._getRelativeOffset()
  1096. };
  1097. this.offset.click = {
  1098. left: event.pageX - this.offset.left,
  1099. top: event.pageY - this.offset.top
  1100. };
  1101. },
  1102. _mouseDrag: function( event, noPropagation ) {
  1103. // reset any necessary cached properties (see #5009)
  1104. if ( this.hasFixedAncestor ) {
  1105. this.offset.parent = this._getParentOffset();
  1106. }
  1107. //Compute the helpers position
  1108. this.position = this._generatePosition( event, true );
  1109. this.positionAbs = this._convertPositionTo( "absolute" );
  1110. //Call plugins and callbacks and use the resulting position if something is returned
  1111. if ( !noPropagation ) {
  1112. var ui = this._uiHash();
  1113. if ( this._trigger( "drag", event, ui ) === false ) {
  1114. this._mouseUp( new $.Event( "mouseup", event ) );
  1115. return false;
  1116. }
  1117. this.position = ui.position;
  1118. }
  1119. this.helper[ 0 ].style.left = this.position.left + "px";
  1120. this.helper[ 0 ].style.top = this.position.top + "px";
  1121. if ( $.ui.ddmanager ) {
  1122. $.ui.ddmanager.drag( this, event );
  1123. }
  1124. return false;
  1125. },
  1126. _mouseStop: function( event ) {
  1127. //If we are using droppables, inform the manager about the drop
  1128. var that = this,
  1129. dropped = false;
  1130. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  1131. dropped = $.ui.ddmanager.drop( this, event );
  1132. }
  1133. //if a drop comes from outside (a sortable)
  1134. if ( this.dropped ) {
  1135. dropped = this.dropped;
  1136. this.dropped = false;
  1137. }
  1138. if ( ( this.options.revert === "invalid" && !dropped ) ||
  1139. ( this.options.revert === "valid" && dropped ) ||
  1140. this.options.revert === true || ( $.isFunction( this.options.revert ) &&
  1141. this.options.revert.call( this.element, dropped ) )
  1142. ) {
  1143. $( this.helper ).animate(
  1144. this.originalPosition,
  1145. parseInt( this.options.revertDuration, 10 ),
  1146. function() {
  1147. if ( that._trigger( "stop", event ) !== false ) {
  1148. that._clear();
  1149. }
  1150. }
  1151. );
  1152. } else {
  1153. if ( this._trigger( "stop", event ) !== false ) {
  1154. this._clear();
  1155. }
  1156. }
  1157. return false;
  1158. },
  1159. _mouseUp: function( event ) {
  1160. this._unblockFrames();
  1161. // If the ddmanager is used for droppables, inform the manager that dragging has stopped
  1162. // (see #5003)
  1163. if ( $.ui.ddmanager ) {
  1164. $.ui.ddmanager.dragStop( this, event );
  1165. }
  1166. // Only need to focus if the event occurred on the draggable itself, see #10527
  1167. if ( this.handleElement.is( event.target ) ) {
  1168. // The interaction is over; whether or not the click resulted in a drag,
  1169. // focus the element
  1170. this.element.trigger( "focus" );
  1171. }
  1172. return $.ui.mouse.prototype._mouseUp.call( this, event );
  1173. },
  1174. cancel: function() {
  1175. if ( this.helper.is( ".ui-draggable-dragging" ) ) {
  1176. this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) );
  1177. } else {
  1178. this._clear();
  1179. }
  1180. return this;
  1181. },
  1182. _getHandle: function( event ) {
  1183. return this.options.handle ?
  1184. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1185. true;
  1186. },
  1187. _setHandleClassName: function() {
  1188. this.handleElement = this.options.handle ?
  1189. this.element.find( this.options.handle ) : this.element;
  1190. this._addClass( this.handleElement, "ui-draggable-handle" );
  1191. },
  1192. _removeHandleClassName: function() {
  1193. this._removeClass( this.handleElement, "ui-draggable-handle" );
  1194. },
  1195. _createHelper: function( event ) {
  1196. var o = this.options,
  1197. helperIsFunction = $.isFunction( o.helper ),
  1198. helper = helperIsFunction ?
  1199. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  1200. ( o.helper === "clone" ?
  1201. this.element.clone().removeAttr( "id" ) :
  1202. this.element );
  1203. if ( !helper.parents( "body" ).length ) {
  1204. helper.appendTo( ( o.appendTo === "parent" ?
  1205. this.element[ 0 ].parentNode :
  1206. o.appendTo ) );
  1207. }
  1208. // Http://bugs.jqueryui.com/ticket/9446
  1209. // a helper function can return the original element
  1210. // which wouldn't have been set to relative in _create
  1211. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  1212. this._setPositionRelative();
  1213. }
  1214. if ( helper[ 0 ] !== this.element[ 0 ] &&
  1215. !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) {
  1216. helper.css( "position", "absolute" );
  1217. }
  1218. return helper;
  1219. },
  1220. _setPositionRelative: function() {
  1221. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  1222. this.element[ 0 ].style.position = "relative";
  1223. }
  1224. },
  1225. _adjustOffsetFromHelper: function( obj ) {
  1226. if ( typeof obj === "string" ) {
  1227. obj = obj.split( " " );
  1228. }
  1229. if ( $.isArray( obj ) ) {
  1230. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  1231. }
  1232. if ( "left" in obj ) {
  1233. this.offset.click.left = obj.left + this.margins.left;
  1234. }
  1235. if ( "right" in obj ) {
  1236. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1237. }
  1238. if ( "top" in obj ) {
  1239. this.offset.click.top = obj.top + this.margins.top;
  1240. }
  1241. if ( "bottom" in obj ) {
  1242. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1243. }
  1244. },
  1245. _isRootNode: function( element ) {
  1246. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  1247. },
  1248. _getParentOffset: function() {
  1249. //Get the offsetParent and cache its position
  1250. var po = this.offsetParent.offset(),
  1251. document = this.document[ 0 ];
  1252. // This is a special case where we need to modify a offset calculated on start, since the
  1253. // following happened:
  1254. // 1. The position of the helper is absolute, so it's position is calculated based on the
  1255. // next positioned parent
  1256. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  1257. // the document, which means that the scroll is included in the initial calculation of the
  1258. // offset of the parent, and never recalculated upon drag
  1259. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document &&
  1260. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  1261. po.left += this.scrollParent.scrollLeft();
  1262. po.top += this.scrollParent.scrollTop();
  1263. }
  1264. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  1265. po = { top: 0, left: 0 };
  1266. }
  1267. return {
  1268. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  1269. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  1270. };
  1271. },
  1272. _getRelativeOffset: function() {
  1273. if ( this.cssPosition !== "relative" ) {
  1274. return { top: 0, left: 0 };
  1275. }
  1276. var p = this.element.position(),
  1277. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  1278. return {
  1279. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  1280. ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  1281. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  1282. ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  1283. };
  1284. },
  1285. _cacheMargins: function() {
  1286. this.margins = {
  1287. left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ),
  1288. top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ),
  1289. right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ),
  1290. bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 )
  1291. };
  1292. },
  1293. _cacheHelperProportions: function() {
  1294. this.helperProportions = {
  1295. width: this.helper.outerWidth(),
  1296. height: this.helper.outerHeight()
  1297. };
  1298. },
  1299. _setContainment: function() {
  1300. var isUserScrollable, c, ce,
  1301. o = this.options,
  1302. document = this.document[ 0 ];
  1303. this.relativeContainer = null;
  1304. if ( !o.containment ) {
  1305. this.containment = null;
  1306. return;
  1307. }
  1308. if ( o.containment === "window" ) {
  1309. this.containment = [
  1310. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1311. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1312. $( window ).scrollLeft() + $( window ).width() -
  1313. this.helperProportions.width - this.margins.left,
  1314. $( window ).scrollTop() +
  1315. ( $( window ).height() || document.body.parentNode.scrollHeight ) -
  1316. this.helperProportions.height - this.margins.top
  1317. ];
  1318. return;
  1319. }
  1320. if ( o.containment === "document" ) {
  1321. this.containment = [
  1322. 0,
  1323. 0,
  1324. $( document ).width() - this.helperProportions.width - this.margins.left,
  1325. ( $( document ).height() || document.body.parentNode.scrollHeight ) -
  1326. this.helperProportions.height - this.margins.top
  1327. ];
  1328. return;
  1329. }
  1330. if ( o.containment.constructor === Array ) {
  1331. this.containment = o.containment;
  1332. return;
  1333. }
  1334. if ( o.containment === "parent" ) {
  1335. o.containment = this.helper[ 0 ].parentNode;
  1336. }
  1337. c = $( o.containment );
  1338. ce = c[ 0 ];
  1339. if ( !ce ) {
  1340. return;
  1341. }
  1342. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  1343. this.containment = [
  1344. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) +
  1345. ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  1346. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) +
  1347. ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  1348. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  1349. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  1350. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  1351. this.helperProportions.width -
  1352. this.margins.left -
  1353. this.margins.right,
  1354. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  1355. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  1356. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  1357. this.helperProportions.height -
  1358. this.margins.top -
  1359. this.margins.bottom
  1360. ];
  1361. this.relativeContainer = c;
  1362. },
  1363. _convertPositionTo: function( d, pos ) {
  1364. if ( !pos ) {
  1365. pos = this.position;
  1366. }
  1367. var mod = d === "absolute" ? 1 : -1,
  1368. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  1369. return {
  1370. top: (
  1371. // The absolute mouse position
  1372. pos.top +
  1373. // Only for relative positioned nodes: Relative offset from element to offset parent
  1374. this.offset.relative.top * mod +
  1375. // The offsetParent's offset without borders (offset + border)
  1376. this.offset.parent.top * mod -
  1377. ( ( this.cssPosition === "fixed" ?
  1378. -this.offset.scroll.top :
  1379. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod )
  1380. ),
  1381. left: (
  1382. // The absolute mouse position
  1383. pos.left +
  1384. // Only for relative positioned nodes: Relative offset from element to offset parent
  1385. this.offset.relative.left * mod +
  1386. // The offsetParent's offset without borders (offset + border)
  1387. this.offset.parent.left * mod -
  1388. ( ( this.cssPosition === "fixed" ?
  1389. -this.offset.scroll.left :
  1390. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod )
  1391. )
  1392. };
  1393. },
  1394. _generatePosition: function( event, constrainPosition ) {
  1395. var containment, co, top, left,
  1396. o = this.options,
  1397. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  1398. pageX = event.pageX,
  1399. pageY = event.pageY;
  1400. // Cache the scroll
  1401. if ( !scrollIsRootNode || !this.offset.scroll ) {
  1402. this.offset.scroll = {
  1403. top: this.scrollParent.scrollTop(),
  1404. left: this.scrollParent.scrollLeft()
  1405. };
  1406. }
  1407. /*
  1408. * - Position constraining -
  1409. * Constrain the position to a mix of grid, containment.
  1410. */
  1411. // If we are not dragging yet, we won't check for options
  1412. if ( constrainPosition ) {
  1413. if ( this.containment ) {
  1414. if ( this.relativeContainer ) {
  1415. co = this.relativeContainer.offset();
  1416. containment = [
  1417. this.containment[ 0 ] + co.left,
  1418. this.containment[ 1 ] + co.top,
  1419. this.containment[ 2 ] + co.left,
  1420. this.containment[ 3 ] + co.top
  1421. ];
  1422. } else {
  1423. containment = this.containment;
  1424. }
  1425. if ( event.pageX - this.offset.click.left < containment[ 0 ] ) {
  1426. pageX = containment[ 0 ] + this.offset.click.left;
  1427. }
  1428. if ( event.pageY - this.offset.click.top < containment[ 1 ] ) {
  1429. pageY = containment[ 1 ] + this.offset.click.top;
  1430. }
  1431. if ( event.pageX - this.offset.click.left > containment[ 2 ] ) {
  1432. pageX = containment[ 2 ] + this.offset.click.left;
  1433. }
  1434. if ( event.pageY - this.offset.click.top > containment[ 3 ] ) {
  1435. pageY = containment[ 3 ] + this.offset.click.top;
  1436. }
  1437. }
  1438. if ( o.grid ) {
  1439. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid
  1440. // argument errors in IE (see ticket #6950)
  1441. top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY -
  1442. this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY;
  1443. pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] ||
  1444. top - this.offset.click.top > containment[ 3 ] ) ?
  1445. top :
  1446. ( ( top - this.offset.click.top >= containment[ 1 ] ) ?
  1447. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;
  1448. left = o.grid[ 0 ] ? this.originalPageX +
  1449. Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] :
  1450. this.originalPageX;
  1451. pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] ||
  1452. left - this.offset.click.left > containment[ 2 ] ) ?
  1453. left :
  1454. ( ( left - this.offset.click.left >= containment[ 0 ] ) ?
  1455. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left;
  1456. }
  1457. if ( o.axis === "y" ) {
  1458. pageX = this.originalPageX;
  1459. }
  1460. if ( o.axis === "x" ) {
  1461. pageY = this.originalPageY;
  1462. }
  1463. }
  1464. return {
  1465. top: (
  1466. // The absolute mouse position
  1467. pageY -
  1468. // Click offset (relative to the element)
  1469. this.offset.click.top -
  1470. // Only for relative positioned nodes: Relative offset from element to offset parent
  1471. this.offset.relative.top -
  1472. // The offsetParent's offset without borders (offset + border)
  1473. this.offset.parent.top +
  1474. ( this.cssPosition === "fixed" ?
  1475. -this.offset.scroll.top :
  1476. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  1477. ),
  1478. left: (
  1479. // The absolute mouse position
  1480. pageX -
  1481. // Click offset (relative to the element)
  1482. this.offset.click.left -
  1483. // Only for relative positioned nodes: Relative offset from element to offset parent
  1484. this.offset.relative.left -
  1485. // The offsetParent's offset without borders (offset + border)
  1486. this.offset.parent.left +
  1487. ( this.cssPosition === "fixed" ?
  1488. -this.offset.scroll.left :
  1489. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  1490. )
  1491. };
  1492. },
  1493. _clear: function() {
  1494. this._removeClass( this.helper, "ui-draggable-dragging" );
  1495. if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) {
  1496. this.helper.remove();
  1497. }
  1498. this.helper = null;
  1499. this.cancelHelperRemoval = false;
  1500. if ( this.destroyOnClear ) {
  1501. this.destroy();
  1502. }
  1503. },
  1504. // From now on bulk stuff - mainly helpers
  1505. _trigger: function( type, event, ui ) {
  1506. ui = ui || this._uiHash();
  1507. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  1508. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  1509. if ( /^(drag|start|stop)/.test( type ) ) {
  1510. this.positionAbs = this._convertPositionTo( "absolute" );
  1511. ui.offset = this.positionAbs;
  1512. }
  1513. return $.Widget.prototype._trigger.call( this, type, event, ui );
  1514. },
  1515. plugins: {},
  1516. _uiHash: function() {
  1517. return {
  1518. helper: this.helper,
  1519. position: this.position,
  1520. originalPosition: this.originalPosition,
  1521. offset: this.positionAbs
  1522. };
  1523. }
  1524. } );
  1525. $.ui.plugin.add( "draggable", "connectToSortable", {
  1526. start: function( event, ui, draggable ) {
  1527. var uiSortable = $.extend( {}, ui, {
  1528. item: draggable.element
  1529. } );
  1530. draggable.sortables = [];
  1531. $( draggable.options.connectToSortable ).each( function() {
  1532. var sortable = $( this ).sortable( "instance" );
  1533. if ( sortable && !sortable.options.disabled ) {
  1534. draggable.sortables.push( sortable );
  1535. // RefreshPositions is called at drag start to refresh the containerCache
  1536. // which is used in drag. This ensures it's initialized and synchronized
  1537. // with any changes that might have happened on the page since initialization.
  1538. sortable.refreshPositions();
  1539. sortable._trigger( "activate", event, uiSortable );
  1540. }
  1541. } );
  1542. },
  1543. stop: function( event, ui, draggable ) {
  1544. var uiSortable = $.extend( {}, ui, {
  1545. item: draggable.element
  1546. } );
  1547. draggable.cancelHelperRemoval = false;
  1548. $.each( draggable.sortables, function() {
  1549. var sortable = this;
  1550. if ( sortable.isOver ) {
  1551. sortable.isOver = 0;
  1552. // Allow this sortable to handle removing the helper
  1553. draggable.cancelHelperRemoval = true;
  1554. sortable.cancelHelperRemoval = false;
  1555. // Use _storedCSS To restore properties in the sortable,
  1556. // as this also handles revert (#9675) since the draggable
  1557. // may have modified them in unexpected ways (#8809)
  1558. sortable._storedCSS = {
  1559. position: sortable.placeholder.css( "position" ),
  1560. top: sortable.placeholder.css( "top" ),
  1561. left: sortable.placeholder.css( "left" )
  1562. };
  1563. sortable._mouseStop( event );
  1564. // Once drag has ended, the sortable should return to using
  1565. // its original helper, not the shared helper from draggable
  1566. sortable.options.helper = sortable.options._helper;
  1567. } else {
  1568. // Prevent this Sortable from removing the helper.
  1569. // However, don't set the draggable to remove the helper
  1570. // either as another connected Sortable may yet handle the removal.
  1571. sortable.cancelHelperRemoval = true;
  1572. sortable._trigger( "deactivate", event, uiSortable );
  1573. }
  1574. } );
  1575. },
  1576. drag: function( event, ui, draggable ) {
  1577. $.each( draggable.sortables, function() {
  1578. var innermostIntersecting = false,
  1579. sortable = this;
  1580. // Copy over variables that sortable's _intersectsWith uses
  1581. sortable.positionAbs = draggable.positionAbs;
  1582. sortable.helperProportions = draggable.helperProportions;
  1583. sortable.offset.click = draggable.offset.click;
  1584. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  1585. innermostIntersecting = true;
  1586. $.each( draggable.sortables, function() {
  1587. // Copy over variables that sortable's _intersectsWith uses
  1588. this.positionAbs = draggable.positionAbs;
  1589. this.helperProportions = draggable.helperProportions;
  1590. this.offset.click = draggable.offset.click;
  1591. if ( this !== sortable &&
  1592. this._intersectsWith( this.containerCache ) &&
  1593. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  1594. innermostIntersecting = false;
  1595. }
  1596. return innermostIntersecting;
  1597. } );
  1598. }
  1599. if ( innermostIntersecting ) {
  1600. // If it intersects, we use a little isOver variable and set it once,
  1601. // so that the move-in stuff gets fired only once.
  1602. if ( !sortable.isOver ) {
  1603. sortable.isOver = 1;
  1604. // Store draggable's parent in case we need to reappend to it later.
  1605. draggable._parent = ui.helper.parent();
  1606. sortable.currentItem = ui.helper
  1607. .appendTo( sortable.element )
  1608. .data( "ui-sortable-item", true );
  1609. // Store helper option to later restore it
  1610. sortable.options._helper = sortable.options.helper;
  1611. sortable.options.helper = function() {
  1612. return ui.helper[ 0 ];
  1613. };
  1614. // Fire the start events of the sortable with our passed browser event,
  1615. // and our own helper (so it doesn't create a new one)
  1616. event.target = sortable.currentItem[ 0 ];
  1617. sortable._mouseCapture( event, true );
  1618. sortable._mouseStart( event, true, true );
  1619. // Because the browser event is way off the new appended portlet,
  1620. // modify necessary variables to reflect the changes
  1621. sortable.offset.click.top = draggable.offset.click.top;
  1622. sortable.offset.click.left = draggable.offset.click.left;
  1623. sortable.offset.parent.left -= draggable.offset.parent.left -
  1624. sortable.offset.parent.left;
  1625. sortable.offset.parent.top -= draggable.offset.parent.top -
  1626. sortable.offset.parent.top;
  1627. draggable._trigger( "toSortable", event );
  1628. // Inform draggable that the helper is in a valid drop zone,
  1629. // used solely in the revert option to handle "valid/invalid".
  1630. draggable.dropped = sortable.element;
  1631. // Need to refreshPositions of all sortables in the case that
  1632. // adding to one sortable changes the location of the other sortables (#9675)
  1633. $.each( draggable.sortables, function() {
  1634. this.refreshPositions();
  1635. } );
  1636. // Hack so receive/update callbacks work (mostly)
  1637. draggable.currentItem = draggable.element;
  1638. sortable.fromOutside = draggable;
  1639. }
  1640. if ( sortable.currentItem ) {
  1641. sortable._mouseDrag( event );
  1642. // Copy the sortable's position because the draggable's can potentially reflect
  1643. // a relative position, while sortable is always absolute, which the dragged
  1644. // element has now become. (#8809)
  1645. ui.position = sortable.position;
  1646. }
  1647. } else {
  1648. // If it doesn't intersect with the sortable, and it intersected before,
  1649. // we fake the drag stop of the sortable, but make sure it doesn't remove
  1650. // the helper by using cancelHelperRemoval.
  1651. if ( sortable.isOver ) {
  1652. sortable.isOver = 0;
  1653. sortable.cancelHelperRemoval = true;
  1654. // Calling sortable's mouseStop would trigger a revert,
  1655. // so revert must be temporarily false until after mouseStop is called.
  1656. sortable.options._revert = sortable.options.revert;
  1657. sortable.options.revert = false;
  1658. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  1659. sortable._mouseStop( event, true );
  1660. // Restore sortable behaviors that were modfied
  1661. // when the draggable entered the sortable area (#9481)
  1662. sortable.options.revert = sortable.options._revert;
  1663. sortable.options.helper = sortable.options._helper;
  1664. if ( sortable.placeholder ) {
  1665. sortable.placeholder.remove();
  1666. }
  1667. // Restore and recalculate the draggable's offset considering the sortable
  1668. // may have modified them in unexpected ways. (#8809, #10669)
  1669. ui.helper.appendTo( draggable._parent );
  1670. draggable._refreshOffsets( event );
  1671. ui.position = draggable._generatePosition( event, true );
  1672. draggable._trigger( "fromSortable", event );
  1673. // Inform draggable that the helper is no longer in a valid drop zone
  1674. draggable.dropped = false;
  1675. // Need to refreshPositions of all sortables just in case removing
  1676. // from one sortable changes the location of other sortables (#9675)
  1677. $.each( draggable.sortables, function() {
  1678. this.refreshPositions();
  1679. } );
  1680. }
  1681. }
  1682. } );
  1683. }
  1684. } );
  1685. $.ui.plugin.add( "draggable", "cursor", {
  1686. start: function( event, ui, instance ) {
  1687. var t = $( "body" ),
  1688. o = instance.options;
  1689. if ( t.css( "cursor" ) ) {
  1690. o._cursor = t.css( "cursor" );
  1691. }
  1692. t.css( "cursor", o.cursor );
  1693. },
  1694. stop: function( event, ui, instance ) {
  1695. var o = instance.options;
  1696. if ( o._cursor ) {
  1697. $( "body" ).css( "cursor", o._cursor );
  1698. }
  1699. }
  1700. } );
  1701. $.ui.plugin.add( "draggable", "opacity", {
  1702. start: function( event, ui, instance ) {
  1703. var t = $( ui.helper ),
  1704. o = instance.options;
  1705. if ( t.css( "opacity" ) ) {
  1706. o._opacity = t.css( "opacity" );
  1707. }
  1708. t.css( "opacity", o.opacity );
  1709. },
  1710. stop: function( event, ui, instance ) {
  1711. var o = instance.options;
  1712. if ( o._opacity ) {
  1713. $( ui.helper ).css( "opacity", o._opacity );
  1714. }
  1715. }
  1716. } );
  1717. $.ui.plugin.add( "draggable", "scroll", {
  1718. start: function( event, ui, i ) {
  1719. if ( !i.scrollParentNotHidden ) {
  1720. i.scrollParentNotHidden = i.helper.scrollParent( false );
  1721. }
  1722. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] &&
  1723. i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  1724. i.overflowOffset = i.scrollParentNotHidden.offset();
  1725. }
  1726. },
  1727. drag: function( event, ui, i ) {
  1728. var o = i.options,
  1729. scrolled = false,
  1730. scrollParent = i.scrollParentNotHidden[ 0 ],
  1731. document = i.document[ 0 ];
  1732. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  1733. if ( !o.axis || o.axis !== "x" ) {
  1734. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY <
  1735. o.scrollSensitivity ) {
  1736. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  1737. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  1738. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  1739. }
  1740. }
  1741. if ( !o.axis || o.axis !== "y" ) {
  1742. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX <
  1743. o.scrollSensitivity ) {
  1744. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  1745. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  1746. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  1747. }
  1748. }
  1749. } else {
  1750. if ( !o.axis || o.axis !== "x" ) {
  1751. if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) {
  1752. scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed );
  1753. } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) <
  1754. o.scrollSensitivity ) {
  1755. scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed );
  1756. }
  1757. }
  1758. if ( !o.axis || o.axis !== "y" ) {
  1759. if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) {
  1760. scrolled = $( document ).scrollLeft(
  1761. $( document ).scrollLeft() - o.scrollSpeed
  1762. );
  1763. } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) <
  1764. o.scrollSensitivity ) {
  1765. scrolled = $( document ).scrollLeft(
  1766. $( document ).scrollLeft() + o.scrollSpeed
  1767. );
  1768. }
  1769. }
  1770. }
  1771. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  1772. $.ui.ddmanager.prepareOffsets( i, event );
  1773. }
  1774. }
  1775. } );
  1776. $.ui.plugin.add( "draggable", "snap", {
  1777. start: function( event, ui, i ) {
  1778. var o = i.options;
  1779. i.snapElements = [];
  1780. $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap )
  1781. .each( function() {
  1782. var $t = $( this ),
  1783. $o = $t.offset();
  1784. if ( this !== i.element[ 0 ] ) {
  1785. i.snapElements.push( {
  1786. item: this,
  1787. width: $t.outerWidth(), height: $t.outerHeight(),
  1788. top: $o.top, left: $o.left
  1789. } );
  1790. }
  1791. } );
  1792. },
  1793. drag: function( event, ui, inst ) {
  1794. var ts, bs, ls, rs, l, r, t, b, i, first,
  1795. o = inst.options,
  1796. d = o.snapTolerance,
  1797. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  1798. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  1799. for ( i = inst.snapElements.length - 1; i >= 0; i-- ) {
  1800. l = inst.snapElements[ i ].left - inst.margins.left;
  1801. r = l + inst.snapElements[ i ].width;
  1802. t = inst.snapElements[ i ].top - inst.margins.top;
  1803. b = t + inst.snapElements[ i ].height;
  1804. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d ||
  1805. !$.contains( inst.snapElements[ i ].item.ownerDocument,
  1806. inst.snapElements[ i ].item ) ) {
  1807. if ( inst.snapElements[ i ].snapping ) {
  1808. ( inst.options.snap.release &&
  1809. inst.options.snap.release.call(
  1810. inst.element,
  1811. event,
  1812. $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } )
  1813. ) );
  1814. }
  1815. inst.snapElements[ i ].snapping = false;
  1816. continue;
  1817. }
  1818. if ( o.snapMode !== "inner" ) {
  1819. ts = Math.abs( t - y2 ) <= d;
  1820. bs = Math.abs( b - y1 ) <= d;
  1821. ls = Math.abs( l - x2 ) <= d;
  1822. rs = Math.abs( r - x1 ) <= d;
  1823. if ( ts ) {
  1824. ui.position.top = inst._convertPositionTo( "relative", {
  1825. top: t - inst.helperProportions.height,
  1826. left: 0
  1827. } ).top;
  1828. }
  1829. if ( bs ) {
  1830. ui.position.top = inst._convertPositionTo( "relative", {
  1831. top: b,
  1832. left: 0
  1833. } ).top;
  1834. }
  1835. if ( ls ) {
  1836. ui.position.left = inst._convertPositionTo( "relative", {
  1837. top: 0,
  1838. left: l - inst.helperProportions.width
  1839. } ).left;
  1840. }
  1841. if ( rs ) {
  1842. ui.position.left = inst._convertPositionTo( "relative", {
  1843. top: 0,
  1844. left: r
  1845. } ).left;
  1846. }
  1847. }
  1848. first = ( ts || bs || ls || rs );
  1849. if ( o.snapMode !== "outer" ) {
  1850. ts = Math.abs( t - y1 ) <= d;
  1851. bs = Math.abs( b - y2 ) <= d;
  1852. ls = Math.abs( l - x1 ) <= d;
  1853. rs = Math.abs( r - x2 ) <= d;
  1854. if ( ts ) {
  1855. ui.position.top = inst._convertPositionTo( "relative", {
  1856. top: t,
  1857. left: 0
  1858. } ).top;
  1859. }
  1860. if ( bs ) {
  1861. ui.position.top = inst._convertPositionTo( "relative", {
  1862. top: b - inst.helperProportions.height,
  1863. left: 0
  1864. } ).top;
  1865. }
  1866. if ( ls ) {
  1867. ui.position.left = inst._convertPositionTo( "relative", {
  1868. top: 0,
  1869. left: l
  1870. } ).left;
  1871. }
  1872. if ( rs ) {
  1873. ui.position.left = inst._convertPositionTo( "relative", {
  1874. top: 0,
  1875. left: r - inst.helperProportions.width
  1876. } ).left;
  1877. }
  1878. }
  1879. if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) {
  1880. ( inst.options.snap.snap &&
  1881. inst.options.snap.snap.call(
  1882. inst.element,
  1883. event,
  1884. $.extend( inst._uiHash(), {
  1885. snapItem: inst.snapElements[ i ].item
  1886. } ) ) );
  1887. }
  1888. inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first );
  1889. }
  1890. }
  1891. } );
  1892. $.ui.plugin.add( "draggable", "stack", {
  1893. start: function( event, ui, instance ) {
  1894. var min,
  1895. o = instance.options,
  1896. group = $.makeArray( $( o.stack ) ).sort( function( a, b ) {
  1897. return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) -
  1898. ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 );
  1899. } );
  1900. if ( !group.length ) { return; }
  1901. min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0;
  1902. $( group ).each( function( i ) {
  1903. $( this ).css( "zIndex", min + i );
  1904. } );
  1905. this.css( "zIndex", ( min + group.length ) );
  1906. }
  1907. } );
  1908. $.ui.plugin.add( "draggable", "zIndex", {
  1909. start: function( event, ui, instance ) {
  1910. var t = $( ui.helper ),
  1911. o = instance.options;
  1912. if ( t.css( "zIndex" ) ) {
  1913. o._zIndex = t.css( "zIndex" );
  1914. }
  1915. t.css( "zIndex", o.zIndex );
  1916. },
  1917. stop: function( event, ui, instance ) {
  1918. var o = instance.options;
  1919. if ( o._zIndex ) {
  1920. $( ui.helper ).css( "zIndex", o._zIndex );
  1921. }
  1922. }
  1923. } );
  1924. var widgetsDraggable = $.ui.draggable;
  1925. /*!
  1926. * jQuery UI Droppable 1.12.1
  1927. * http://jqueryui.com
  1928. *
  1929. * Copyright jQuery Foundation and other contributors
  1930. * Released under the MIT license.
  1931. * http://jquery.org/license
  1932. */
  1933. //>>label: Droppable
  1934. //>>group: Interactions
  1935. //>>description: Enables drop targets for draggable elements.
  1936. //>>docs: http://api.jqueryui.com/droppable/
  1937. //>>demos: http://jqueryui.com/droppable/
  1938. $.widget( "ui.droppable", {
  1939. version: "1.12.1",
  1940. widgetEventPrefix: "drop",
  1941. options: {
  1942. accept: "*",
  1943. addClasses: true,
  1944. greedy: false,
  1945. scope: "default",
  1946. tolerance: "intersect",
  1947. // Callbacks
  1948. activate: null,
  1949. deactivate: null,
  1950. drop: null,
  1951. out: null,
  1952. over: null
  1953. },
  1954. _create: function() {
  1955. var proportions,
  1956. o = this.options,
  1957. accept = o.accept;
  1958. this.isover = false;
  1959. this.isout = true;
  1960. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  1961. return d.is( accept );
  1962. };
  1963. this.proportions = function( /* valueToWrite */ ) {
  1964. if ( arguments.length ) {
  1965. // Store the droppable's proportions
  1966. proportions = arguments[ 0 ];
  1967. } else {
  1968. // Retrieve or derive the droppable's proportions
  1969. return proportions ?
  1970. proportions :
  1971. proportions = {
  1972. width: this.element[ 0 ].offsetWidth,
  1973. height: this.element[ 0 ].offsetHeight
  1974. };
  1975. }
  1976. };
  1977. this._addToManager( o.scope );
  1978. o.addClasses && this._addClass( "ui-droppable" );
  1979. },
  1980. _addToManager: function( scope ) {
  1981. // Add the reference and positions to the manager
  1982. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  1983. $.ui.ddmanager.droppables[ scope ].push( this );
  1984. },
  1985. _splice: function( drop ) {
  1986. var i = 0;
  1987. for ( ; i < drop.length; i++ ) {
  1988. if ( drop[ i ] === this ) {
  1989. drop.splice( i, 1 );
  1990. }
  1991. }
  1992. },
  1993. _destroy: function() {
  1994. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  1995. this._splice( drop );
  1996. },
  1997. _setOption: function( key, value ) {
  1998. if ( key === "accept" ) {
  1999. this.accept = $.isFunction( value ) ? value : function( d ) {
  2000. return d.is( value );
  2001. };
  2002. } else if ( key === "scope" ) {
  2003. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2004. this._splice( drop );
  2005. this._addToManager( value );
  2006. }
  2007. this._super( key, value );
  2008. },
  2009. _activate: function( event ) {
  2010. var draggable = $.ui.ddmanager.current;
  2011. this._addActiveClass();
  2012. if ( draggable ) {
  2013. this._trigger( "activate", event, this.ui( draggable ) );
  2014. }
  2015. },
  2016. _deactivate: function( event ) {
  2017. var draggable = $.ui.ddmanager.current;
  2018. this._removeActiveClass();
  2019. if ( draggable ) {
  2020. this._trigger( "deactivate", event, this.ui( draggable ) );
  2021. }
  2022. },
  2023. _over: function( event ) {
  2024. var draggable = $.ui.ddmanager.current;
  2025. // Bail if draggable and droppable are same element
  2026. if ( !draggable || ( draggable.currentItem ||
  2027. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2028. return;
  2029. }
  2030. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  2031. draggable.element ) ) ) {
  2032. this._addHoverClass();
  2033. this._trigger( "over", event, this.ui( draggable ) );
  2034. }
  2035. },
  2036. _out: function( event ) {
  2037. var draggable = $.ui.ddmanager.current;
  2038. // Bail if draggable and droppable are same element
  2039. if ( !draggable || ( draggable.currentItem ||
  2040. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2041. return;
  2042. }
  2043. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  2044. draggable.element ) ) ) {
  2045. this._removeHoverClass();
  2046. this._trigger( "out", event, this.ui( draggable ) );
  2047. }
  2048. },
  2049. _drop: function( event, custom ) {
  2050. var draggable = custom || $.ui.ddmanager.current,
  2051. childrenIntersection = false;
  2052. // Bail if draggable and droppable are same element
  2053. if ( !draggable || ( draggable.currentItem ||
  2054. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2055. return false;
  2056. }
  2057. this.element
  2058. .find( ":data(ui-droppable)" )
  2059. .not( ".ui-draggable-dragging" )
  2060. .each( function() {
  2061. var inst = $( this ).droppable( "instance" );
  2062. if (
  2063. inst.options.greedy &&
  2064. !inst.options.disabled &&
  2065. inst.options.scope === draggable.options.scope &&
  2066. inst.accept.call(
  2067. inst.element[ 0 ], ( draggable.currentItem || draggable.element )
  2068. ) &&
  2069. intersect(
  2070. draggable,
  2071. $.extend( inst, { offset: inst.element.offset() } ),
  2072. inst.options.tolerance, event
  2073. )
  2074. ) {
  2075. childrenIntersection = true;
  2076. return false; }
  2077. } );
  2078. if ( childrenIntersection ) {
  2079. return false;
  2080. }
  2081. if ( this.accept.call( this.element[ 0 ],
  2082. ( draggable.currentItem || draggable.element ) ) ) {
  2083. this._removeActiveClass();
  2084. this._removeHoverClass();
  2085. this._trigger( "drop", event, this.ui( draggable ) );
  2086. return this.element;
  2087. }
  2088. return false;
  2089. },
  2090. ui: function( c ) {
  2091. return {
  2092. draggable: ( c.currentItem || c.element ),
  2093. helper: c.helper,
  2094. position: c.position,
  2095. offset: c.positionAbs
  2096. };
  2097. },
  2098. // Extension points just to make backcompat sane and avoid duplicating logic
  2099. // TODO: Remove in 1.13 along with call to it below
  2100. _addHoverClass: function() {
  2101. this._addClass( "ui-droppable-hover" );
  2102. },
  2103. _removeHoverClass: function() {
  2104. this._removeClass( "ui-droppable-hover" );
  2105. },
  2106. _addActiveClass: function() {
  2107. this._addClass( "ui-droppable-active" );
  2108. },
  2109. _removeActiveClass: function() {
  2110. this._removeClass( "ui-droppable-active" );
  2111. }
  2112. } );
  2113. var intersect = $.ui.intersect = ( function() {
  2114. function isOverAxis( x, reference, size ) {
  2115. return ( x >= reference ) && ( x < ( reference + size ) );
  2116. }
  2117. return function( draggable, droppable, toleranceMode, event ) {
  2118. if ( !droppable.offset ) {
  2119. return false;
  2120. }
  2121. var x1 = ( draggable.positionAbs ||
  2122. draggable.position.absolute ).left + draggable.margins.left,
  2123. y1 = ( draggable.positionAbs ||
  2124. draggable.position.absolute ).top + draggable.margins.top,
  2125. x2 = x1 + draggable.helperProportions.width,
  2126. y2 = y1 + draggable.helperProportions.height,
  2127. l = droppable.offset.left,
  2128. t = droppable.offset.top,
  2129. r = l + droppable.proportions().width,
  2130. b = t + droppable.proportions().height;
  2131. switch ( toleranceMode ) {
  2132. case "fit":
  2133. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  2134. case "intersect":
  2135. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  2136. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  2137. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  2138. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  2139. case "pointer":
  2140. return isOverAxis( event.pageY, t, droppable.proportions().height ) &&
  2141. isOverAxis( event.pageX, l, droppable.proportions().width );
  2142. case "touch":
  2143. return (
  2144. ( y1 >= t && y1 <= b ) || // Top edge touching
  2145. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  2146. ( y1 < t && y2 > b ) // Surrounded vertically
  2147. ) && (
  2148. ( x1 >= l && x1 <= r ) || // Left edge touching
  2149. ( x2 >= l && x2 <= r ) || // Right edge touching
  2150. ( x1 < l && x2 > r ) // Surrounded horizontally
  2151. );
  2152. default:
  2153. return false;
  2154. }
  2155. };
  2156. } )();
  2157. /*
  2158. This manager tracks offsets of draggables and droppables
  2159. */
  2160. $.ui.ddmanager = {
  2161. current: null,
  2162. droppables: { "default": [] },
  2163. prepareOffsets: function( t, event ) {
  2164. var i, j,
  2165. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  2166. type = event ? event.type : null, // workaround for #2317
  2167. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  2168. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  2169. // No disabled and non-accepted
  2170. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ],
  2171. ( t.currentItem || t.element ) ) ) ) {
  2172. continue;
  2173. }
  2174. // Filter out elements in the current dragged item
  2175. for ( j = 0; j < list.length; j++ ) {
  2176. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  2177. m[ i ].proportions().height = 0;
  2178. continue droppablesLoop;
  2179. }
  2180. }
  2181. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  2182. if ( !m[ i ].visible ) {
  2183. continue;
  2184. }
  2185. // Activate the droppable if used directly from draggables
  2186. if ( type === "mousedown" ) {
  2187. m[ i ]._activate.call( m[ i ], event );
  2188. }
  2189. m[ i ].offset = m[ i ].element.offset();
  2190. m[ i ].proportions( {
  2191. width: m[ i ].element[ 0 ].offsetWidth,
  2192. height: m[ i ].element[ 0 ].offsetHeight
  2193. } );
  2194. }
  2195. },
  2196. drop: function( draggable, event ) {
  2197. var dropped = false;
  2198. // Create a copy of the droppables in case the list changes during the drop (#9116)
  2199. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  2200. if ( !this.options ) {
  2201. return;
  2202. }
  2203. if ( !this.options.disabled && this.visible &&
  2204. intersect( draggable, this, this.options.tolerance, event ) ) {
  2205. dropped = this._drop.call( this, event ) || dropped;
  2206. }
  2207. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ],
  2208. ( draggable.currentItem || draggable.element ) ) ) {
  2209. this.isout = true;
  2210. this.isover = false;
  2211. this._deactivate.call( this, event );
  2212. }
  2213. } );
  2214. return dropped;
  2215. },
  2216. dragStart: function( draggable, event ) {
  2217. // Listen for scrolling so that if the dragging causes scrolling the position of the
  2218. // droppables can be recalculated (see #5003)
  2219. draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() {
  2220. if ( !draggable.options.refreshPositions ) {
  2221. $.ui.ddmanager.prepareOffsets( draggable, event );
  2222. }
  2223. } );
  2224. },
  2225. drag: function( draggable, event ) {
  2226. // If you have a highly dynamic page, you might try this option. It renders positions
  2227. // every time you move the mouse.
  2228. if ( draggable.options.refreshPositions ) {
  2229. $.ui.ddmanager.prepareOffsets( draggable, event );
  2230. }
  2231. // Run through all droppables and check their positions based on specific tolerance options
  2232. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  2233. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  2234. return;
  2235. }
  2236. var parentInstance, scope, parent,
  2237. intersects = intersect( draggable, this, this.options.tolerance, event ),
  2238. c = !intersects && this.isover ?
  2239. "isout" :
  2240. ( intersects && !this.isover ? "isover" : null );
  2241. if ( !c ) {
  2242. return;
  2243. }
  2244. if ( this.options.greedy ) {
  2245. // find droppable parents with same scope
  2246. scope = this.options.scope;
  2247. parent = this.element.parents( ":data(ui-droppable)" ).filter( function() {
  2248. return $( this ).droppable( "instance" ).options.scope === scope;
  2249. } );
  2250. if ( parent.length ) {
  2251. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  2252. parentInstance.greedyChild = ( c === "isover" );
  2253. }
  2254. }
  2255. // We just moved into a greedy child
  2256. if ( parentInstance && c === "isover" ) {
  2257. parentInstance.isover = false;
  2258. parentInstance.isout = true;
  2259. parentInstance._out.call( parentInstance, event );
  2260. }
  2261. this[ c ] = true;
  2262. this[ c === "isout" ? "isover" : "isout" ] = false;
  2263. this[ c === "isover" ? "_over" : "_out" ].call( this, event );
  2264. // We just moved out of a greedy child
  2265. if ( parentInstance && c === "isout" ) {
  2266. parentInstance.isout = false;
  2267. parentInstance.isover = true;
  2268. parentInstance._over.call( parentInstance, event );
  2269. }
  2270. } );
  2271. },
  2272. dragStop: function( draggable, event ) {
  2273. draggable.element.parentsUntil( "body" ).off( "scroll.droppable" );
  2274. // Call prepareOffsets one final time since IE does not fire return scroll events when
  2275. // overflow was caused by drag (see #5003)
  2276. if ( !draggable.options.refreshPositions ) {
  2277. $.ui.ddmanager.prepareOffsets( draggable, event );
  2278. }
  2279. }
  2280. };
  2281. // DEPRECATED
  2282. // TODO: switch return back to widget declaration at top of file when this is removed
  2283. if ( $.uiBackCompat !== false ) {
  2284. // Backcompat for activeClass and hoverClass options
  2285. $.widget( "ui.droppable", $.ui.droppable, {
  2286. options: {
  2287. hoverClass: false,
  2288. activeClass: false
  2289. },
  2290. _addActiveClass: function() {
  2291. this._super();
  2292. if ( this.options.activeClass ) {
  2293. this.element.addClass( this.options.activeClass );
  2294. }
  2295. },
  2296. _removeActiveClass: function() {
  2297. this._super();
  2298. if ( this.options.activeClass ) {
  2299. this.element.removeClass( this.options.activeClass );
  2300. }
  2301. },
  2302. _addHoverClass: function() {
  2303. this._super();
  2304. if ( this.options.hoverClass ) {
  2305. this.element.addClass( this.options.hoverClass );
  2306. }
  2307. },
  2308. _removeHoverClass: function() {
  2309. this._super();
  2310. if ( this.options.hoverClass ) {
  2311. this.element.removeClass( this.options.hoverClass );
  2312. }
  2313. }
  2314. } );
  2315. }
  2316. var widgetsDroppable = $.ui.droppable;
  2317. /*!
  2318. * jQuery UI Resizable 1.12.1
  2319. * http://jqueryui.com
  2320. *
  2321. * Copyright jQuery Foundation and other contributors
  2322. * Released under the MIT license.
  2323. * http://jquery.org/license
  2324. */
  2325. //>>label: Resizable
  2326. //>>group: Interactions
  2327. //>>description: Enables resize functionality for any element.
  2328. //>>docs: http://api.jqueryui.com/resizable/
  2329. //>>demos: http://jqueryui.com/resizable/
  2330. //>>css.structure: ../../themes/base/core.css
  2331. //>>css.structure: ../../themes/base/resizable.css
  2332. //>>css.theme: ../../themes/base/theme.css
  2333. $.widget( "ui.resizable", $.ui.mouse, {
  2334. version: "1.12.1",
  2335. widgetEventPrefix: "resize",
  2336. options: {
  2337. alsoResize: false,
  2338. animate: false,
  2339. animateDuration: "slow",
  2340. animateEasing: "swing",
  2341. aspectRatio: false,
  2342. autoHide: false,
  2343. classes: {
  2344. "ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se"
  2345. },
  2346. containment: false,
  2347. ghost: false,
  2348. grid: false,
  2349. handles: "e,s,se",
  2350. helper: false,
  2351. maxHeight: null,
  2352. maxWidth: null,
  2353. minHeight: 10,
  2354. minWidth: 10,
  2355. // See #7960
  2356. zIndex: 90,
  2357. // Callbacks
  2358. resize: null,
  2359. start: null,
  2360. stop: null
  2361. },
  2362. _num: function( value ) {
  2363. return parseFloat( value ) || 0;
  2364. },
  2365. _isNumber: function( value ) {
  2366. return !isNaN( parseFloat( value ) );
  2367. },
  2368. _hasScroll: function( el, a ) {
  2369. if ( $( el ).css( "overflow" ) === "hidden" ) {
  2370. return false;
  2371. }
  2372. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  2373. has = false;
  2374. if ( el[ scroll ] > 0 ) {
  2375. return true;
  2376. }
  2377. // TODO: determine which cases actually cause this to happen
  2378. // if the element doesn't have the scroll set, see if it's possible to
  2379. // set the scroll
  2380. el[ scroll ] = 1;
  2381. has = ( el[ scroll ] > 0 );
  2382. el[ scroll ] = 0;
  2383. return has;
  2384. },
  2385. _create: function() {
  2386. var margins,
  2387. o = this.options,
  2388. that = this;
  2389. this._addClass( "ui-resizable" );
  2390. $.extend( this, {
  2391. _aspectRatio: !!( o.aspectRatio ),
  2392. aspectRatio: o.aspectRatio,
  2393. originalElement: this.element,
  2394. _proportionallyResizeElements: [],
  2395. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  2396. } );
  2397. // Wrap the element if it cannot hold child nodes
  2398. if ( this.element[ 0 ].nodeName.match( /^(canvas|textarea|input|select|button|img)$/i ) ) {
  2399. this.element.wrap(
  2400. $( "<div class='ui-wrapper' style='overflow: hidden;'></div>" ).css( {
  2401. position: this.element.css( "position" ),
  2402. width: this.element.outerWidth(),
  2403. height: this.element.outerHeight(),
  2404. top: this.element.css( "top" ),
  2405. left: this.element.css( "left" )
  2406. } )
  2407. );
  2408. this.element = this.element.parent().data(
  2409. "ui-resizable", this.element.resizable( "instance" )
  2410. );
  2411. this.elementIsWrapper = true;
  2412. margins = {
  2413. marginTop: this.originalElement.css( "marginTop" ),
  2414. marginRight: this.originalElement.css( "marginRight" ),
  2415. marginBottom: this.originalElement.css( "marginBottom" ),
  2416. marginLeft: this.originalElement.css( "marginLeft" )
  2417. };
  2418. this.element.css( margins );
  2419. this.originalElement.css( "margin", 0 );
  2420. // support: Safari
  2421. // Prevent Safari textarea resize
  2422. this.originalResizeStyle = this.originalElement.css( "resize" );
  2423. this.originalElement.css( "resize", "none" );
  2424. this._proportionallyResizeElements.push( this.originalElement.css( {
  2425. position: "static",
  2426. zoom: 1,
  2427. display: "block"
  2428. } ) );
  2429. // Support: IE9
  2430. // avoid IE jump (hard set the margin)
  2431. this.originalElement.css( margins );
  2432. this._proportionallyResize();
  2433. }
  2434. this._setupHandles();
  2435. if ( o.autoHide ) {
  2436. $( this.element )
  2437. .on( "mouseenter", function() {
  2438. if ( o.disabled ) {
  2439. return;
  2440. }
  2441. that._removeClass( "ui-resizable-autohide" );
  2442. that._handles.show();
  2443. } )
  2444. .on( "mouseleave", function() {
  2445. if ( o.disabled ) {
  2446. return;
  2447. }
  2448. if ( !that.resizing ) {
  2449. that._addClass( "ui-resizable-autohide" );
  2450. that._handles.hide();
  2451. }
  2452. } );
  2453. }
  2454. this._mouseInit();
  2455. },
  2456. _destroy: function() {
  2457. this._mouseDestroy();
  2458. var wrapper,
  2459. _destroy = function( exp ) {
  2460. $( exp )
  2461. .removeData( "resizable" )
  2462. .removeData( "ui-resizable" )
  2463. .off( ".resizable" )
  2464. .find( ".ui-resizable-handle" )
  2465. .remove();
  2466. };
  2467. // TODO: Unwrap at same DOM position
  2468. if ( this.elementIsWrapper ) {
  2469. _destroy( this.element );
  2470. wrapper = this.element;
  2471. this.originalElement.css( {
  2472. position: wrapper.css( "position" ),
  2473. width: wrapper.outerWidth(),
  2474. height: wrapper.outerHeight(),
  2475. top: wrapper.css( "top" ),
  2476. left: wrapper.css( "left" )
  2477. } ).insertAfter( wrapper );
  2478. wrapper.remove();
  2479. }
  2480. this.originalElement.css( "resize", this.originalResizeStyle );
  2481. _destroy( this.originalElement );
  2482. return this;
  2483. },
  2484. _setOption: function( key, value ) {
  2485. this._super( key, value );
  2486. switch ( key ) {
  2487. case "handles":
  2488. this._removeHandles();
  2489. this._setupHandles();
  2490. break;
  2491. default:
  2492. break;
  2493. }
  2494. },
  2495. _setupHandles: function() {
  2496. var o = this.options, handle, i, n, hname, axis, that = this;
  2497. this.handles = o.handles ||
  2498. ( !$( ".ui-resizable-handle", this.element ).length ?
  2499. "e,s,se" : {
  2500. n: ".ui-resizable-n",
  2501. e: ".ui-resizable-e",
  2502. s: ".ui-resizable-s",
  2503. w: ".ui-resizable-w",
  2504. se: ".ui-resizable-se",
  2505. sw: ".ui-resizable-sw",
  2506. ne: ".ui-resizable-ne",
  2507. nw: ".ui-resizable-nw"
  2508. } );
  2509. this._handles = $();
  2510. if ( this.handles.constructor === String ) {
  2511. if ( this.handles === "all" ) {
  2512. this.handles = "n,e,s,w,se,sw,ne,nw";
  2513. }
  2514. n = this.handles.split( "," );
  2515. this.handles = {};
  2516. for ( i = 0; i < n.length; i++ ) {
  2517. handle = $.trim( n[ i ] );
  2518. hname = "ui-resizable-" + handle;
  2519. axis = $( "<div>" );
  2520. this._addClass( axis, "ui-resizable-handle " + hname );
  2521. axis.css( { zIndex: o.zIndex } );
  2522. this.handles[ handle ] = ".ui-resizable-" + handle;
  2523. this.element.append( axis );
  2524. }
  2525. }
  2526. this._renderAxis = function( target ) {
  2527. var i, axis, padPos, padWrapper;
  2528. target = target || this.element;
  2529. for ( i in this.handles ) {
  2530. if ( this.handles[ i ].constructor === String ) {
  2531. this.handles[ i ] = this.element.children( this.handles[ i ] ).first().show();
  2532. } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
  2533. this.handles[ i ] = $( this.handles[ i ] );
  2534. this._on( this.handles[ i ], { "mousedown": that._mouseDown } );
  2535. }
  2536. if ( this.elementIsWrapper &&
  2537. this.originalElement[ 0 ]
  2538. .nodeName
  2539. .match( /^(textarea|input|select|button)$/i ) ) {
  2540. axis = $( this.handles[ i ], this.element );
  2541. padWrapper = /sw|ne|nw|se|n|s/.test( i ) ?
  2542. axis.outerHeight() :
  2543. axis.outerWidth();
  2544. padPos = [ "padding",
  2545. /ne|nw|n/.test( i ) ? "Top" :
  2546. /se|sw|s/.test( i ) ? "Bottom" :
  2547. /^e$/.test( i ) ? "Right" : "Left" ].join( "" );
  2548. target.css( padPos, padWrapper );
  2549. this._proportionallyResize();
  2550. }
  2551. this._handles = this._handles.add( this.handles[ i ] );
  2552. }
  2553. };
  2554. // TODO: make renderAxis a prototype function
  2555. this._renderAxis( this.element );
  2556. this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
  2557. this._handles.disableSelection();
  2558. this._handles.on( "mouseover", function() {
  2559. if ( !that.resizing ) {
  2560. if ( this.className ) {
  2561. axis = this.className.match( /ui-resizable-(se|sw|ne|nw|n|e|s|w)/i );
  2562. }
  2563. that.axis = axis && axis[ 1 ] ? axis[ 1 ] : "se";
  2564. }
  2565. } );
  2566. if ( o.autoHide ) {
  2567. this._handles.hide();
  2568. this._addClass( "ui-resizable-autohide" );
  2569. }
  2570. },
  2571. _removeHandles: function() {
  2572. this._handles.remove();
  2573. },
  2574. _mouseCapture: function( event ) {
  2575. var i, handle,
  2576. capture = false;
  2577. for ( i in this.handles ) {
  2578. handle = $( this.handles[ i ] )[ 0 ];
  2579. if ( handle === event.target || $.contains( handle, event.target ) ) {
  2580. capture = true;
  2581. }
  2582. }
  2583. return !this.options.disabled && capture;
  2584. },
  2585. _mouseStart: function( event ) {
  2586. var curleft, curtop, cursor,
  2587. o = this.options,
  2588. el = this.element;
  2589. this.resizing = true;
  2590. this._renderProxy();
  2591. curleft = this._num( this.helper.css( "left" ) );
  2592. curtop = this._num( this.helper.css( "top" ) );
  2593. if ( o.containment ) {
  2594. curleft += $( o.containment ).scrollLeft() || 0;
  2595. curtop += $( o.containment ).scrollTop() || 0;
  2596. }
  2597. this.offset = this.helper.offset();
  2598. this.position = { left: curleft, top: curtop };
  2599. this.size = this._helper ? {
  2600. width: this.helper.width(),
  2601. height: this.helper.height()
  2602. } : {
  2603. width: el.width(),
  2604. height: el.height()
  2605. };
  2606. this.originalSize = this._helper ? {
  2607. width: el.outerWidth(),
  2608. height: el.outerHeight()
  2609. } : {
  2610. width: el.width(),
  2611. height: el.height()
  2612. };
  2613. this.sizeDiff = {
  2614. width: el.outerWidth() - el.width(),
  2615. height: el.outerHeight() - el.height()
  2616. };
  2617. this.originalPosition = { left: curleft, top: curtop };
  2618. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2619. this.aspectRatio = ( typeof o.aspectRatio === "number" ) ?
  2620. o.aspectRatio :
  2621. ( ( this.originalSize.width / this.originalSize.height ) || 1 );
  2622. cursor = $( ".ui-resizable-" + this.axis ).css( "cursor" );
  2623. $( "body" ).css( "cursor", cursor === "auto" ? this.axis + "-resize" : cursor );
  2624. this._addClass( "ui-resizable-resizing" );
  2625. this._propagate( "start", event );
  2626. return true;
  2627. },
  2628. _mouseDrag: function( event ) {
  2629. var data, props,
  2630. smp = this.originalMousePosition,
  2631. a = this.axis,
  2632. dx = ( event.pageX - smp.left ) || 0,
  2633. dy = ( event.pageY - smp.top ) || 0,
  2634. trigger = this._change[ a ];
  2635. this._updatePrevProperties();
  2636. if ( !trigger ) {
  2637. return false;
  2638. }
  2639. data = trigger.apply( this, [ event, dx, dy ] );
  2640. this._updateVirtualBoundaries( event.shiftKey );
  2641. if ( this._aspectRatio || event.shiftKey ) {
  2642. data = this._updateRatio( data, event );
  2643. }
  2644. data = this._respectSize( data, event );
  2645. this._updateCache( data );
  2646. this._propagate( "resize", event );
  2647. props = this._applyChanges();
  2648. if ( !this._helper && this._proportionallyResizeElements.length ) {
  2649. this._proportionallyResize();
  2650. }
  2651. if ( !$.isEmptyObject( props ) ) {
  2652. this._updatePrevProperties();
  2653. this._trigger( "resize", event, this.ui() );
  2654. this._applyChanges();
  2655. }
  2656. return false;
  2657. },
  2658. _mouseStop: function( event ) {
  2659. this.resizing = false;
  2660. var pr, ista, soffseth, soffsetw, s, left, top,
  2661. o = this.options, that = this;
  2662. if ( this._helper ) {
  2663. pr = this._proportionallyResizeElements;
  2664. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName );
  2665. soffseth = ista && this._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height;
  2666. soffsetw = ista ? 0 : that.sizeDiff.width;
  2667. s = {
  2668. width: ( that.helper.width() - soffsetw ),
  2669. height: ( that.helper.height() - soffseth )
  2670. };
  2671. left = ( parseFloat( that.element.css( "left" ) ) +
  2672. ( that.position.left - that.originalPosition.left ) ) || null;
  2673. top = ( parseFloat( that.element.css( "top" ) ) +
  2674. ( that.position.top - that.originalPosition.top ) ) || null;
  2675. if ( !o.animate ) {
  2676. this.element.css( $.extend( s, { top: top, left: left } ) );
  2677. }
  2678. that.helper.height( that.size.height );
  2679. that.helper.width( that.size.width );
  2680. if ( this._helper && !o.animate ) {
  2681. this._proportionallyResize();
  2682. }
  2683. }
  2684. $( "body" ).css( "cursor", "auto" );
  2685. this._removeClass( "ui-resizable-resizing" );
  2686. this._propagate( "stop", event );
  2687. if ( this._helper ) {
  2688. this.helper.remove();
  2689. }
  2690. return false;
  2691. },
  2692. _updatePrevProperties: function() {
  2693. this.prevPosition = {
  2694. top: this.position.top,
  2695. left: this.position.left
  2696. };
  2697. this.prevSize = {
  2698. width: this.size.width,
  2699. height: this.size.height
  2700. };
  2701. },
  2702. _applyChanges: function() {
  2703. var props = {};
  2704. if ( this.position.top !== this.prevPosition.top ) {
  2705. props.top = this.position.top + "px";
  2706. }
  2707. if ( this.position.left !== this.prevPosition.left ) {
  2708. props.left = this.position.left + "px";
  2709. }
  2710. if ( this.size.width !== this.prevSize.width ) {
  2711. props.width = this.size.width + "px";
  2712. }
  2713. if ( this.size.height !== this.prevSize.height ) {
  2714. props.height = this.size.height + "px";
  2715. }
  2716. this.helper.css( props );
  2717. return props;
  2718. },
  2719. _updateVirtualBoundaries: function( forceAspectRatio ) {
  2720. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2721. o = this.options;
  2722. b = {
  2723. minWidth: this._isNumber( o.minWidth ) ? o.minWidth : 0,
  2724. maxWidth: this._isNumber( o.maxWidth ) ? o.maxWidth : Infinity,
  2725. minHeight: this._isNumber( o.minHeight ) ? o.minHeight : 0,
  2726. maxHeight: this._isNumber( o.maxHeight ) ? o.maxHeight : Infinity
  2727. };
  2728. if ( this._aspectRatio || forceAspectRatio ) {
  2729. pMinWidth = b.minHeight * this.aspectRatio;
  2730. pMinHeight = b.minWidth / this.aspectRatio;
  2731. pMaxWidth = b.maxHeight * this.aspectRatio;
  2732. pMaxHeight = b.maxWidth / this.aspectRatio;
  2733. if ( pMinWidth > b.minWidth ) {
  2734. b.minWidth = pMinWidth;
  2735. }
  2736. if ( pMinHeight > b.minHeight ) {
  2737. b.minHeight = pMinHeight;
  2738. }
  2739. if ( pMaxWidth < b.maxWidth ) {
  2740. b.maxWidth = pMaxWidth;
  2741. }
  2742. if ( pMaxHeight < b.maxHeight ) {
  2743. b.maxHeight = pMaxHeight;
  2744. }
  2745. }
  2746. this._vBoundaries = b;
  2747. },
  2748. _updateCache: function( data ) {
  2749. this.offset = this.helper.offset();
  2750. if ( this._isNumber( data.left ) ) {
  2751. this.position.left = data.left;
  2752. }
  2753. if ( this._isNumber( data.top ) ) {
  2754. this.position.top = data.top;
  2755. }
  2756. if ( this._isNumber( data.height ) ) {
  2757. this.size.height = data.height;
  2758. }
  2759. if ( this._isNumber( data.width ) ) {
  2760. this.size.width = data.width;
  2761. }
  2762. },
  2763. _updateRatio: function( data ) {
  2764. var cpos = this.position,
  2765. csize = this.size,
  2766. a = this.axis;
  2767. if ( this._isNumber( data.height ) ) {
  2768. data.width = ( data.height * this.aspectRatio );
  2769. } else if ( this._isNumber( data.width ) ) {
  2770. data.height = ( data.width / this.aspectRatio );
  2771. }
  2772. if ( a === "sw" ) {
  2773. data.left = cpos.left + ( csize.width - data.width );
  2774. data.top = null;
  2775. }
  2776. if ( a === "nw" ) {
  2777. data.top = cpos.top + ( csize.height - data.height );
  2778. data.left = cpos.left + ( csize.width - data.width );
  2779. }
  2780. return data;
  2781. },
  2782. _respectSize: function( data ) {
  2783. var o = this._vBoundaries,
  2784. a = this.axis,
  2785. ismaxw = this._isNumber( data.width ) && o.maxWidth && ( o.maxWidth < data.width ),
  2786. ismaxh = this._isNumber( data.height ) && o.maxHeight && ( o.maxHeight < data.height ),
  2787. isminw = this._isNumber( data.width ) && o.minWidth && ( o.minWidth > data.width ),
  2788. isminh = this._isNumber( data.height ) && o.minHeight && ( o.minHeight > data.height ),
  2789. dw = this.originalPosition.left + this.originalSize.width,
  2790. dh = this.originalPosition.top + this.originalSize.height,
  2791. cw = /sw|nw|w/.test( a ), ch = /nw|ne|n/.test( a );
  2792. if ( isminw ) {
  2793. data.width = o.minWidth;
  2794. }
  2795. if ( isminh ) {
  2796. data.height = o.minHeight;
  2797. }
  2798. if ( ismaxw ) {
  2799. data.width = o.maxWidth;
  2800. }
  2801. if ( ismaxh ) {
  2802. data.height = o.maxHeight;
  2803. }
  2804. if ( isminw && cw ) {
  2805. data.left = dw - o.minWidth;
  2806. }
  2807. if ( ismaxw && cw ) {
  2808. data.left = dw - o.maxWidth;
  2809. }
  2810. if ( isminh && ch ) {
  2811. data.top = dh - o.minHeight;
  2812. }
  2813. if ( ismaxh && ch ) {
  2814. data.top = dh - o.maxHeight;
  2815. }
  2816. // Fixing jump error on top/left - bug #2330
  2817. if ( !data.width && !data.height && !data.left && data.top ) {
  2818. data.top = null;
  2819. } else if ( !data.width && !data.height && !data.top && data.left ) {
  2820. data.left = null;
  2821. }
  2822. return data;
  2823. },
  2824. _getPaddingPlusBorderDimensions: function( element ) {
  2825. var i = 0,
  2826. widths = [],
  2827. borders = [
  2828. element.css( "borderTopWidth" ),
  2829. element.css( "borderRightWidth" ),
  2830. element.css( "borderBottomWidth" ),
  2831. element.css( "borderLeftWidth" )
  2832. ],
  2833. paddings = [
  2834. element.css( "paddingTop" ),
  2835. element.css( "paddingRight" ),
  2836. element.css( "paddingBottom" ),
  2837. element.css( "paddingLeft" )
  2838. ];
  2839. for ( ; i < 4; i++ ) {
  2840. widths[ i ] = ( parseFloat( borders[ i ] ) || 0 );
  2841. widths[ i ] += ( parseFloat( paddings[ i ] ) || 0 );
  2842. }
  2843. return {
  2844. height: widths[ 0 ] + widths[ 2 ],
  2845. width: widths[ 1 ] + widths[ 3 ]
  2846. };
  2847. },
  2848. _proportionallyResize: function() {
  2849. if ( !this._proportionallyResizeElements.length ) {
  2850. return;
  2851. }
  2852. var prel,
  2853. i = 0,
  2854. element = this.helper || this.element;
  2855. for ( ; i < this._proportionallyResizeElements.length; i++ ) {
  2856. prel = this._proportionallyResizeElements[ i ];
  2857. // TODO: Seems like a bug to cache this.outerDimensions
  2858. // considering that we are in a loop.
  2859. if ( !this.outerDimensions ) {
  2860. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  2861. }
  2862. prel.css( {
  2863. height: ( element.height() - this.outerDimensions.height ) || 0,
  2864. width: ( element.width() - this.outerDimensions.width ) || 0
  2865. } );
  2866. }
  2867. },
  2868. _renderProxy: function() {
  2869. var el = this.element, o = this.options;
  2870. this.elementOffset = el.offset();
  2871. if ( this._helper ) {
  2872. this.helper = this.helper || $( "<div style='overflow:hidden;'></div>" );
  2873. this._addClass( this.helper, this._helper );
  2874. this.helper.css( {
  2875. width: this.element.outerWidth(),
  2876. height: this.element.outerHeight(),
  2877. position: "absolute",
  2878. left: this.elementOffset.left + "px",
  2879. top: this.elementOffset.top + "px",
  2880. zIndex: ++o.zIndex //TODO: Don't modify option
  2881. } );
  2882. this.helper
  2883. .appendTo( "body" )
  2884. .disableSelection();
  2885. } else {
  2886. this.helper = this.element;
  2887. }
  2888. },
  2889. _change: {
  2890. e: function( event, dx ) {
  2891. return { width: this.originalSize.width + dx };
  2892. },
  2893. w: function( event, dx ) {
  2894. var cs = this.originalSize, sp = this.originalPosition;
  2895. return { left: sp.left + dx, width: cs.width - dx };
  2896. },
  2897. n: function( event, dx, dy ) {
  2898. var cs = this.originalSize, sp = this.originalPosition;
  2899. return { top: sp.top + dy, height: cs.height - dy };
  2900. },
  2901. s: function( event, dx, dy ) {
  2902. return { height: this.originalSize.height + dy };
  2903. },
  2904. se: function( event, dx, dy ) {
  2905. return $.extend( this._change.s.apply( this, arguments ),
  2906. this._change.e.apply( this, [ event, dx, dy ] ) );
  2907. },
  2908. sw: function( event, dx, dy ) {
  2909. return $.extend( this._change.s.apply( this, arguments ),
  2910. this._change.w.apply( this, [ event, dx, dy ] ) );
  2911. },
  2912. ne: function( event, dx, dy ) {
  2913. return $.extend( this._change.n.apply( this, arguments ),
  2914. this._change.e.apply( this, [ event, dx, dy ] ) );
  2915. },
  2916. nw: function( event, dx, dy ) {
  2917. return $.extend( this._change.n.apply( this, arguments ),
  2918. this._change.w.apply( this, [ event, dx, dy ] ) );
  2919. }
  2920. },
  2921. _propagate: function( n, event ) {
  2922. $.ui.plugin.call( this, n, [ event, this.ui() ] );
  2923. ( n !== "resize" && this._trigger( n, event, this.ui() ) );
  2924. },
  2925. plugins: {},
  2926. ui: function() {
  2927. return {
  2928. originalElement: this.originalElement,
  2929. element: this.element,
  2930. helper: this.helper,
  2931. position: this.position,
  2932. size: this.size,
  2933. originalSize: this.originalSize,
  2934. originalPosition: this.originalPosition
  2935. };
  2936. }
  2937. } );
  2938. /*
  2939. * Resizable Extensions
  2940. */
  2941. $.ui.plugin.add( "resizable", "animate", {
  2942. stop: function( event ) {
  2943. var that = $( this ).resizable( "instance" ),
  2944. o = that.options,
  2945. pr = that._proportionallyResizeElements,
  2946. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ),
  2947. soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height,
  2948. soffsetw = ista ? 0 : that.sizeDiff.width,
  2949. style = {
  2950. width: ( that.size.width - soffsetw ),
  2951. height: ( that.size.height - soffseth )
  2952. },
  2953. left = ( parseFloat( that.element.css( "left" ) ) +
  2954. ( that.position.left - that.originalPosition.left ) ) || null,
  2955. top = ( parseFloat( that.element.css( "top" ) ) +
  2956. ( that.position.top - that.originalPosition.top ) ) || null;
  2957. that.element.animate(
  2958. $.extend( style, top && left ? { top: top, left: left } : {} ), {
  2959. duration: o.animateDuration,
  2960. easing: o.animateEasing,
  2961. step: function() {
  2962. var data = {
  2963. width: parseFloat( that.element.css( "width" ) ),
  2964. height: parseFloat( that.element.css( "height" ) ),
  2965. top: parseFloat( that.element.css( "top" ) ),
  2966. left: parseFloat( that.element.css( "left" ) )
  2967. };
  2968. if ( pr && pr.length ) {
  2969. $( pr[ 0 ] ).css( { width: data.width, height: data.height } );
  2970. }
  2971. // Propagating resize, and updating values for each animation step
  2972. that._updateCache( data );
  2973. that._propagate( "resize", event );
  2974. }
  2975. }
  2976. );
  2977. }
  2978. } );
  2979. $.ui.plugin.add( "resizable", "containment", {
  2980. start: function() {
  2981. var element, p, co, ch, cw, width, height,
  2982. that = $( this ).resizable( "instance" ),
  2983. o = that.options,
  2984. el = that.element,
  2985. oc = o.containment,
  2986. ce = ( oc instanceof $ ) ?
  2987. oc.get( 0 ) :
  2988. ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  2989. if ( !ce ) {
  2990. return;
  2991. }
  2992. that.containerElement = $( ce );
  2993. if ( /document/.test( oc ) || oc === document ) {
  2994. that.containerOffset = {
  2995. left: 0,
  2996. top: 0
  2997. };
  2998. that.containerPosition = {
  2999. left: 0,
  3000. top: 0
  3001. };
  3002. that.parentData = {
  3003. element: $( document ),
  3004. left: 0,
  3005. top: 0,
  3006. width: $( document ).width(),
  3007. height: $( document ).height() || document.body.parentNode.scrollHeight
  3008. };
  3009. } else {
  3010. element = $( ce );
  3011. p = [];
  3012. $( [ "Top", "Right", "Left", "Bottom" ] ).each( function( i, name ) {
  3013. p[ i ] = that._num( element.css( "padding" + name ) );
  3014. } );
  3015. that.containerOffset = element.offset();
  3016. that.containerPosition = element.position();
  3017. that.containerSize = {
  3018. height: ( element.innerHeight() - p[ 3 ] ),
  3019. width: ( element.innerWidth() - p[ 1 ] )
  3020. };
  3021. co = that.containerOffset;
  3022. ch = that.containerSize.height;
  3023. cw = that.containerSize.width;
  3024. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  3025. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  3026. that.parentData = {
  3027. element: ce,
  3028. left: co.left,
  3029. top: co.top,
  3030. width: width,
  3031. height: height
  3032. };
  3033. }
  3034. },
  3035. resize: function( event ) {
  3036. var woset, hoset, isParent, isOffsetRelative,
  3037. that = $( this ).resizable( "instance" ),
  3038. o = that.options,
  3039. co = that.containerOffset,
  3040. cp = that.position,
  3041. pRatio = that._aspectRatio || event.shiftKey,
  3042. cop = {
  3043. top: 0,
  3044. left: 0
  3045. },
  3046. ce = that.containerElement,
  3047. continueResize = true;
  3048. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  3049. cop = co;
  3050. }
  3051. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  3052. that.size.width = that.size.width +
  3053. ( that._helper ?
  3054. ( that.position.left - co.left ) :
  3055. ( that.position.left - cop.left ) );
  3056. if ( pRatio ) {
  3057. that.size.height = that.size.width / that.aspectRatio;
  3058. continueResize = false;
  3059. }
  3060. that.position.left = o.helper ? co.left : 0;
  3061. }
  3062. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  3063. that.size.height = that.size.height +
  3064. ( that._helper ?
  3065. ( that.position.top - co.top ) :
  3066. that.position.top );
  3067. if ( pRatio ) {
  3068. that.size.width = that.size.height * that.aspectRatio;
  3069. continueResize = false;
  3070. }
  3071. that.position.top = that._helper ? co.top : 0;
  3072. }
  3073. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  3074. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  3075. if ( isParent && isOffsetRelative ) {
  3076. that.offset.left = that.parentData.left + that.position.left;
  3077. that.offset.top = that.parentData.top + that.position.top;
  3078. } else {
  3079. that.offset.left = that.element.offset().left;
  3080. that.offset.top = that.element.offset().top;
  3081. }
  3082. woset = Math.abs( that.sizeDiff.width +
  3083. ( that._helper ?
  3084. that.offset.left - cop.left :
  3085. ( that.offset.left - co.left ) ) );
  3086. hoset = Math.abs( that.sizeDiff.height +
  3087. ( that._helper ?
  3088. that.offset.top - cop.top :
  3089. ( that.offset.top - co.top ) ) );
  3090. if ( woset + that.size.width >= that.parentData.width ) {
  3091. that.size.width = that.parentData.width - woset;
  3092. if ( pRatio ) {
  3093. that.size.height = that.size.width / that.aspectRatio;
  3094. continueResize = false;
  3095. }
  3096. }
  3097. if ( hoset + that.size.height >= that.parentData.height ) {
  3098. that.size.height = that.parentData.height - hoset;
  3099. if ( pRatio ) {
  3100. that.size.width = that.size.height * that.aspectRatio;
  3101. continueResize = false;
  3102. }
  3103. }
  3104. if ( !continueResize ) {
  3105. that.position.left = that.prevPosition.left;
  3106. that.position.top = that.prevPosition.top;
  3107. that.size.width = that.prevSize.width;
  3108. that.size.height = that.prevSize.height;
  3109. }
  3110. },
  3111. stop: function() {
  3112. var that = $( this ).resizable( "instance" ),
  3113. o = that.options,
  3114. co = that.containerOffset,
  3115. cop = that.containerPosition,
  3116. ce = that.containerElement,
  3117. helper = $( that.helper ),
  3118. ho = helper.offset(),
  3119. w = helper.outerWidth() - that.sizeDiff.width,
  3120. h = helper.outerHeight() - that.sizeDiff.height;
  3121. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  3122. $( this ).css( {
  3123. left: ho.left - cop.left - co.left,
  3124. width: w,
  3125. height: h
  3126. } );
  3127. }
  3128. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  3129. $( this ).css( {
  3130. left: ho.left - cop.left - co.left,
  3131. width: w,
  3132. height: h
  3133. } );
  3134. }
  3135. }
  3136. } );
  3137. $.ui.plugin.add( "resizable", "alsoResize", {
  3138. start: function() {
  3139. var that = $( this ).resizable( "instance" ),
  3140. o = that.options;
  3141. $( o.alsoResize ).each( function() {
  3142. var el = $( this );
  3143. el.data( "ui-resizable-alsoresize", {
  3144. width: parseFloat( el.width() ), height: parseFloat( el.height() ),
  3145. left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) )
  3146. } );
  3147. } );
  3148. },
  3149. resize: function( event, ui ) {
  3150. var that = $( this ).resizable( "instance" ),
  3151. o = that.options,
  3152. os = that.originalSize,
  3153. op = that.originalPosition,
  3154. delta = {
  3155. height: ( that.size.height - os.height ) || 0,
  3156. width: ( that.size.width - os.width ) || 0,
  3157. top: ( that.position.top - op.top ) || 0,
  3158. left: ( that.position.left - op.left ) || 0
  3159. };
  3160. $( o.alsoResize ).each( function() {
  3161. var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {},
  3162. css = el.parents( ui.originalElement[ 0 ] ).length ?
  3163. [ "width", "height" ] :
  3164. [ "width", "height", "top", "left" ];
  3165. $.each( css, function( i, prop ) {
  3166. var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 );
  3167. if ( sum && sum >= 0 ) {
  3168. style[ prop ] = sum || null;
  3169. }
  3170. } );
  3171. el.css( style );
  3172. } );
  3173. },
  3174. stop: function() {
  3175. $( this ).removeData( "ui-resizable-alsoresize" );
  3176. }
  3177. } );
  3178. $.ui.plugin.add( "resizable", "ghost", {
  3179. start: function() {
  3180. var that = $( this ).resizable( "instance" ), cs = that.size;
  3181. that.ghost = that.originalElement.clone();
  3182. that.ghost.css( {
  3183. opacity: 0.25,
  3184. display: "block",
  3185. position: "relative",
  3186. height: cs.height,
  3187. width: cs.width,
  3188. margin: 0,
  3189. left: 0,
  3190. top: 0
  3191. } );
  3192. that._addClass( that.ghost, "ui-resizable-ghost" );
  3193. // DEPRECATED
  3194. // TODO: remove after 1.12
  3195. if ( $.uiBackCompat !== false && typeof that.options.ghost === "string" ) {
  3196. // Ghost option
  3197. that.ghost.addClass( this.options.ghost );
  3198. }
  3199. that.ghost.appendTo( that.helper );
  3200. },
  3201. resize: function() {
  3202. var that = $( this ).resizable( "instance" );
  3203. if ( that.ghost ) {
  3204. that.ghost.css( {
  3205. position: "relative",
  3206. height: that.size.height,
  3207. width: that.size.width
  3208. } );
  3209. }
  3210. },
  3211. stop: function() {
  3212. var that = $( this ).resizable( "instance" );
  3213. if ( that.ghost && that.helper ) {
  3214. that.helper.get( 0 ).removeChild( that.ghost.get( 0 ) );
  3215. }
  3216. }
  3217. } );
  3218. $.ui.plugin.add( "resizable", "grid", {
  3219. resize: function() {
  3220. var outerDimensions,
  3221. that = $( this ).resizable( "instance" ),
  3222. o = that.options,
  3223. cs = that.size,
  3224. os = that.originalSize,
  3225. op = that.originalPosition,
  3226. a = that.axis,
  3227. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  3228. gridX = ( grid[ 0 ] || 1 ),
  3229. gridY = ( grid[ 1 ] || 1 ),
  3230. ox = Math.round( ( cs.width - os.width ) / gridX ) * gridX,
  3231. oy = Math.round( ( cs.height - os.height ) / gridY ) * gridY,
  3232. newWidth = os.width + ox,
  3233. newHeight = os.height + oy,
  3234. isMaxWidth = o.maxWidth && ( o.maxWidth < newWidth ),
  3235. isMaxHeight = o.maxHeight && ( o.maxHeight < newHeight ),
  3236. isMinWidth = o.minWidth && ( o.minWidth > newWidth ),
  3237. isMinHeight = o.minHeight && ( o.minHeight > newHeight );
  3238. o.grid = grid;
  3239. if ( isMinWidth ) {
  3240. newWidth += gridX;
  3241. }
  3242. if ( isMinHeight ) {
  3243. newHeight += gridY;
  3244. }
  3245. if ( isMaxWidth ) {
  3246. newWidth -= gridX;
  3247. }
  3248. if ( isMaxHeight ) {
  3249. newHeight -= gridY;
  3250. }
  3251. if ( /^(se|s|e)$/.test( a ) ) {
  3252. that.size.width = newWidth;
  3253. that.size.height = newHeight;
  3254. } else if ( /^(ne)$/.test( a ) ) {
  3255. that.size.width = newWidth;
  3256. that.size.height = newHeight;
  3257. that.position.top = op.top - oy;
  3258. } else if ( /^(sw)$/.test( a ) ) {
  3259. that.size.width = newWidth;
  3260. that.size.height = newHeight;
  3261. that.position.left = op.left - ox;
  3262. } else {
  3263. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0 ) {
  3264. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  3265. }
  3266. if ( newHeight - gridY > 0 ) {
  3267. that.size.height = newHeight;
  3268. that.position.top = op.top - oy;
  3269. } else {
  3270. newHeight = gridY - outerDimensions.height;
  3271. that.size.height = newHeight;
  3272. that.position.top = op.top + os.height - newHeight;
  3273. }
  3274. if ( newWidth - gridX > 0 ) {
  3275. that.size.width = newWidth;
  3276. that.position.left = op.left - ox;
  3277. } else {
  3278. newWidth = gridX - outerDimensions.width;
  3279. that.size.width = newWidth;
  3280. that.position.left = op.left + os.width - newWidth;
  3281. }
  3282. }
  3283. }
  3284. } );
  3285. var widgetsResizable = $.ui.resizable;
  3286. }));