jquery-ui.js 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611
  1. /*! jQuery UI - v1.11.4 - 2015-05-20
  2. * http://jqueryui.com
  3. * Includes: core.js, widget.js, position.js, autocomplete.js, menu.js
  4. * Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */
  5. (function( factory ) {
  6. if ( typeof define === "function" && define.amd ) {
  7. // AMD. Register as an anonymous module.
  8. define([ "jquery" ], factory );
  9. } else {
  10. // Browser globals
  11. factory( jQuery );
  12. }
  13. }(function( $ ) {
  14. /*!
  15. * jQuery UI Core 1.11.4
  16. * http://jqueryui.com
  17. *
  18. * Copyright jQuery Foundation and other contributors
  19. * Released under the MIT license.
  20. * http://jquery.org/license
  21. *
  22. * http://api.jqueryui.com/category/ui-core/
  23. */
  24. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  25. $.ui = $.ui || {};
  26. $.extend( $.ui, {
  27. version: "1.11.4",
  28. keyCode: {
  29. BACKSPACE: 8,
  30. COMMA: 188,
  31. DELETE: 46,
  32. DOWN: 40,
  33. END: 35,
  34. ENTER: 13,
  35. ESCAPE: 27,
  36. HOME: 36,
  37. LEFT: 37,
  38. PAGE_DOWN: 34,
  39. PAGE_UP: 33,
  40. PERIOD: 190,
  41. RIGHT: 39,
  42. SPACE: 32,
  43. TAB: 9,
  44. UP: 38
  45. }
  46. });
  47. // plugins
  48. $.fn.extend({
  49. scrollParent: function( includeHidden ) {
  50. var position = this.css( "position" ),
  51. excludeStaticParent = position === "absolute",
  52. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  53. scrollParent = this.parents().filter( function() {
  54. var parent = $( this );
  55. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  56. return false;
  57. }
  58. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
  59. }).eq( 0 );
  60. return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
  61. },
  62. uniqueId: (function() {
  63. var uuid = 0;
  64. return function() {
  65. return this.each(function() {
  66. if ( !this.id ) {
  67. this.id = "ui-id-" + ( ++uuid );
  68. }
  69. });
  70. };
  71. })(),
  72. removeUniqueId: function() {
  73. return this.each(function() {
  74. if ( /^ui-id-\d+$/.test( this.id ) ) {
  75. $( this ).removeAttr( "id" );
  76. }
  77. });
  78. }
  79. });
  80. // selectors
  81. function focusable( element, isTabIndexNotNaN ) {
  82. var map, mapName, img,
  83. nodeName = element.nodeName.toLowerCase();
  84. if ( "area" === nodeName ) {
  85. map = element.parentNode;
  86. mapName = map.name;
  87. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  88. return false;
  89. }
  90. img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
  91. return !!img && visible( img );
  92. }
  93. return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ?
  94. !element.disabled :
  95. "a" === nodeName ?
  96. element.href || isTabIndexNotNaN :
  97. isTabIndexNotNaN) &&
  98. // the element and all of its ancestors must be visible
  99. visible( element );
  100. }
  101. function visible( element ) {
  102. return $.expr.filters.visible( element ) &&
  103. !$( element ).parents().addBack().filter(function() {
  104. return $.css( this, "visibility" ) === "hidden";
  105. }).length;
  106. }
  107. $.extend( $.expr[ ":" ], {
  108. data: $.expr.createPseudo ?
  109. $.expr.createPseudo(function( dataName ) {
  110. return function( elem ) {
  111. return !!$.data( elem, dataName );
  112. };
  113. }) :
  114. // support: jQuery <1.8
  115. function( elem, i, match ) {
  116. return !!$.data( elem, match[ 3 ] );
  117. },
  118. focusable: function( element ) {
  119. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  120. },
  121. tabbable: function( element ) {
  122. var tabIndex = $.attr( element, "tabindex" ),
  123. isTabIndexNaN = isNaN( tabIndex );
  124. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  125. }
  126. });
  127. // support: jQuery <1.8
  128. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  129. $.each( [ "Width", "Height" ], function( i, name ) {
  130. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  131. type = name.toLowerCase(),
  132. orig = {
  133. innerWidth: $.fn.innerWidth,
  134. innerHeight: $.fn.innerHeight,
  135. outerWidth: $.fn.outerWidth,
  136. outerHeight: $.fn.outerHeight
  137. };
  138. function reduce( elem, size, border, margin ) {
  139. $.each( side, function() {
  140. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  141. if ( border ) {
  142. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  143. }
  144. if ( margin ) {
  145. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  146. }
  147. });
  148. return size;
  149. }
  150. $.fn[ "inner" + name ] = function( size ) {
  151. if ( size === undefined ) {
  152. return orig[ "inner" + name ].call( this );
  153. }
  154. return this.each(function() {
  155. $( this ).css( type, reduce( this, size ) + "px" );
  156. });
  157. };
  158. $.fn[ "outer" + name] = function( size, margin ) {
  159. if ( typeof size !== "number" ) {
  160. return orig[ "outer" + name ].call( this, size );
  161. }
  162. return this.each(function() {
  163. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  164. });
  165. };
  166. });
  167. }
  168. // support: jQuery <1.8
  169. if ( !$.fn.addBack ) {
  170. $.fn.addBack = function( selector ) {
  171. return this.add( selector == null ?
  172. this.prevObject : this.prevObject.filter( selector )
  173. );
  174. };
  175. }
  176. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  177. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  178. $.fn.removeData = (function( removeData ) {
  179. return function( key ) {
  180. if ( arguments.length ) {
  181. return removeData.call( this, $.camelCase( key ) );
  182. } else {
  183. return removeData.call( this );
  184. }
  185. };
  186. })( $.fn.removeData );
  187. }
  188. // deprecated
  189. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  190. $.fn.extend({
  191. focus: (function( orig ) {
  192. return function( delay, fn ) {
  193. return typeof delay === "number" ?
  194. this.each(function() {
  195. var elem = this;
  196. setTimeout(function() {
  197. $( elem ).focus();
  198. if ( fn ) {
  199. fn.call( elem );
  200. }
  201. }, delay );
  202. }) :
  203. orig.apply( this, arguments );
  204. };
  205. })( $.fn.focus ),
  206. disableSelection: (function() {
  207. var eventType = "onselectstart" in document.createElement( "div" ) ?
  208. "selectstart" :
  209. "mousedown";
  210. return function() {
  211. return this.bind( eventType + ".ui-disableSelection", function( event ) {
  212. event.preventDefault();
  213. });
  214. };
  215. })(),
  216. enableSelection: function() {
  217. return this.unbind( ".ui-disableSelection" );
  218. },
  219. zIndex: function( zIndex ) {
  220. if ( zIndex !== undefined ) {
  221. return this.css( "zIndex", zIndex );
  222. }
  223. if ( this.length ) {
  224. var elem = $( this[ 0 ] ), position, value;
  225. while ( elem.length && elem[ 0 ] !== document ) {
  226. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  227. // This makes behavior of this function consistent across browsers
  228. // WebKit always returns auto if the element is positioned
  229. position = elem.css( "position" );
  230. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  231. // IE returns 0 when zIndex is not specified
  232. // other browsers return a string
  233. // we ignore the case of nested elements with an explicit value of 0
  234. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  235. value = parseInt( elem.css( "zIndex" ), 10 );
  236. if ( !isNaN( value ) && value !== 0 ) {
  237. return value;
  238. }
  239. }
  240. elem = elem.parent();
  241. }
  242. }
  243. return 0;
  244. }
  245. });
  246. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  247. $.ui.plugin = {
  248. add: function( module, option, set ) {
  249. var i,
  250. proto = $.ui[ module ].prototype;
  251. for ( i in set ) {
  252. proto.plugins[ i ] = proto.plugins[ i ] || [];
  253. proto.plugins[ i ].push( [ option, set[ i ] ] );
  254. }
  255. },
  256. call: function( instance, name, args, allowDisconnected ) {
  257. var i,
  258. set = instance.plugins[ name ];
  259. if ( !set ) {
  260. return;
  261. }
  262. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  263. return;
  264. }
  265. for ( i = 0; i < set.length; i++ ) {
  266. if ( instance.options[ set[ i ][ 0 ] ] ) {
  267. set[ i ][ 1 ].apply( instance.element, args );
  268. }
  269. }
  270. }
  271. };
  272. /*!
  273. * jQuery UI Widget 1.11.4
  274. * http://jqueryui.com
  275. *
  276. * Copyright jQuery Foundation and other contributors
  277. * Released under the MIT license.
  278. * http://jquery.org/license
  279. *
  280. * http://api.jqueryui.com/jQuery.widget/
  281. */
  282. var widget_uuid = 0,
  283. widget_slice = Array.prototype.slice;
  284. $.cleanData = (function( orig ) {
  285. return function( elems ) {
  286. var events, elem, i;
  287. for ( i = 0; (elem = elems[i]) != null; i++ ) {
  288. try {
  289. // Only trigger remove when necessary to save time
  290. events = $._data( elem, "events" );
  291. if ( events && events.remove ) {
  292. $( elem ).triggerHandler( "remove" );
  293. }
  294. // http://bugs.jquery.com/ticket/8235
  295. } catch ( e ) {}
  296. }
  297. orig( elems );
  298. };
  299. })( $.cleanData );
  300. $.widget = function( name, base, prototype ) {
  301. var fullName, existingConstructor, constructor, basePrototype,
  302. // proxiedPrototype allows the provided prototype to remain unmodified
  303. // so that it can be used as a mixin for multiple widgets (#8876)
  304. proxiedPrototype = {},
  305. namespace = name.split( "." )[ 0 ];
  306. name = name.split( "." )[ 1 ];
  307. fullName = namespace + "-" + name;
  308. if ( !prototype ) {
  309. prototype = base;
  310. base = $.Widget;
  311. }
  312. // create selector for plugin
  313. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  314. return !!$.data( elem, fullName );
  315. };
  316. $[ namespace ] = $[ namespace ] || {};
  317. existingConstructor = $[ namespace ][ name ];
  318. constructor = $[ namespace ][ name ] = function( options, element ) {
  319. // allow instantiation without "new" keyword
  320. if ( !this._createWidget ) {
  321. return new constructor( options, element );
  322. }
  323. // allow instantiation without initializing for simple inheritance
  324. // must use "new" keyword (the code above always passes args)
  325. if ( arguments.length ) {
  326. this._createWidget( options, element );
  327. }
  328. };
  329. // extend with the existing constructor to carry over any static properties
  330. $.extend( constructor, existingConstructor, {
  331. version: prototype.version,
  332. // copy the object used to create the prototype in case we need to
  333. // redefine the widget later
  334. _proto: $.extend( {}, prototype ),
  335. // track widgets that inherit from this widget in case this widget is
  336. // redefined after a widget inherits from it
  337. _childConstructors: []
  338. });
  339. basePrototype = new base();
  340. // we need to make the options hash a property directly on the new instance
  341. // otherwise we'll modify the options hash on the prototype that we're
  342. // inheriting from
  343. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  344. $.each( prototype, function( prop, value ) {
  345. if ( !$.isFunction( value ) ) {
  346. proxiedPrototype[ prop ] = value;
  347. return;
  348. }
  349. proxiedPrototype[ prop ] = (function() {
  350. var _super = function() {
  351. return base.prototype[ prop ].apply( this, arguments );
  352. },
  353. _superApply = function( args ) {
  354. return base.prototype[ prop ].apply( this, args );
  355. };
  356. return function() {
  357. var __super = this._super,
  358. __superApply = this._superApply,
  359. returnValue;
  360. this._super = _super;
  361. this._superApply = _superApply;
  362. returnValue = value.apply( this, arguments );
  363. this._super = __super;
  364. this._superApply = __superApply;
  365. return returnValue;
  366. };
  367. })();
  368. });
  369. constructor.prototype = $.widget.extend( basePrototype, {
  370. // TODO: remove support for widgetEventPrefix
  371. // always use the name + a colon as the prefix, e.g., draggable:start
  372. // don't prefix for widgets that aren't DOM-based
  373. widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
  374. }, proxiedPrototype, {
  375. constructor: constructor,
  376. namespace: namespace,
  377. widgetName: name,
  378. widgetFullName: fullName
  379. });
  380. // If this widget is being redefined then we need to find all widgets that
  381. // are inheriting from it and redefine all of them so that they inherit from
  382. // the new version of this widget. We're essentially trying to replace one
  383. // level in the prototype chain.
  384. if ( existingConstructor ) {
  385. $.each( existingConstructor._childConstructors, function( i, child ) {
  386. var childPrototype = child.prototype;
  387. // redefine the child widget using the same prototype that was
  388. // originally used, but inherit from the new version of the base
  389. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  390. });
  391. // remove the list of existing child constructors from the old constructor
  392. // so the old child constructors can be garbage collected
  393. delete existingConstructor._childConstructors;
  394. } else {
  395. base._childConstructors.push( constructor );
  396. }
  397. $.widget.bridge( name, constructor );
  398. return constructor;
  399. };
  400. $.widget.extend = function( target ) {
  401. var input = widget_slice.call( arguments, 1 ),
  402. inputIndex = 0,
  403. inputLength = input.length,
  404. key,
  405. value;
  406. for ( ; inputIndex < inputLength; inputIndex++ ) {
  407. for ( key in input[ inputIndex ] ) {
  408. value = input[ inputIndex ][ key ];
  409. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  410. // Clone objects
  411. if ( $.isPlainObject( value ) ) {
  412. target[ key ] = $.isPlainObject( target[ key ] ) ?
  413. $.widget.extend( {}, target[ key ], value ) :
  414. // Don't extend strings, arrays, etc. with objects
  415. $.widget.extend( {}, value );
  416. // Copy everything else by reference
  417. } else {
  418. target[ key ] = value;
  419. }
  420. }
  421. }
  422. }
  423. return target;
  424. };
  425. $.widget.bridge = function( name, object ) {
  426. var fullName = object.prototype.widgetFullName || name;
  427. $.fn[ name ] = function( options ) {
  428. var isMethodCall = typeof options === "string",
  429. args = widget_slice.call( arguments, 1 ),
  430. returnValue = this;
  431. if ( isMethodCall ) {
  432. this.each(function() {
  433. var methodValue,
  434. instance = $.data( this, fullName );
  435. if ( options === "instance" ) {
  436. returnValue = instance;
  437. return false;
  438. }
  439. if ( !instance ) {
  440. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  441. "attempted to call method '" + options + "'" );
  442. }
  443. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  444. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  445. }
  446. methodValue = instance[ options ].apply( instance, args );
  447. if ( methodValue !== instance && methodValue !== undefined ) {
  448. returnValue = methodValue && methodValue.jquery ?
  449. returnValue.pushStack( methodValue.get() ) :
  450. methodValue;
  451. return false;
  452. }
  453. });
  454. } else {
  455. // Allow multiple hashes to be passed on init
  456. if ( args.length ) {
  457. options = $.widget.extend.apply( null, [ options ].concat(args) );
  458. }
  459. this.each(function() {
  460. var instance = $.data( this, fullName );
  461. if ( instance ) {
  462. instance.option( options || {} );
  463. if ( instance._init ) {
  464. instance._init();
  465. }
  466. } else {
  467. $.data( this, fullName, new object( options, this ) );
  468. }
  469. });
  470. }
  471. return returnValue;
  472. };
  473. };
  474. $.Widget = function( /* options, element */ ) {};
  475. $.Widget._childConstructors = [];
  476. $.Widget.prototype = {
  477. widgetName: "widget",
  478. widgetEventPrefix: "",
  479. defaultElement: "<div>",
  480. options: {
  481. disabled: false,
  482. // callbacks
  483. create: null
  484. },
  485. _createWidget: function( options, element ) {
  486. element = $( element || this.defaultElement || this )[ 0 ];
  487. this.element = $( element );
  488. this.uuid = widget_uuid++;
  489. this.eventNamespace = "." + this.widgetName + this.uuid;
  490. this.bindings = $();
  491. this.hoverable = $();
  492. this.focusable = $();
  493. if ( element !== this ) {
  494. $.data( element, this.widgetFullName, this );
  495. this._on( true, this.element, {
  496. remove: function( event ) {
  497. if ( event.target === element ) {
  498. this.destroy();
  499. }
  500. }
  501. });
  502. this.document = $( element.style ?
  503. // element within the document
  504. element.ownerDocument :
  505. // element is window or document
  506. element.document || element );
  507. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  508. }
  509. this.options = $.widget.extend( {},
  510. this.options,
  511. this._getCreateOptions(),
  512. options );
  513. this._create();
  514. this._trigger( "create", null, this._getCreateEventData() );
  515. this._init();
  516. },
  517. _getCreateOptions: $.noop,
  518. _getCreateEventData: $.noop,
  519. _create: $.noop,
  520. _init: $.noop,
  521. destroy: function() {
  522. this._destroy();
  523. // we can probably remove the unbind calls in 2.0
  524. // all event bindings should go through this._on()
  525. this.element
  526. .unbind( this.eventNamespace )
  527. .removeData( this.widgetFullName )
  528. // support: jquery <1.6.3
  529. // http://bugs.jquery.com/ticket/9413
  530. .removeData( $.camelCase( this.widgetFullName ) );
  531. this.widget()
  532. .unbind( this.eventNamespace )
  533. .removeAttr( "aria-disabled" )
  534. .removeClass(
  535. this.widgetFullName + "-disabled " +
  536. "ui-state-disabled" );
  537. // clean up events and states
  538. this.bindings.unbind( this.eventNamespace );
  539. this.hoverable.removeClass( "ui-state-hover" );
  540. this.focusable.removeClass( "ui-state-focus" );
  541. },
  542. _destroy: $.noop,
  543. widget: function() {
  544. return this.element;
  545. },
  546. option: function( key, value ) {
  547. var options = key,
  548. parts,
  549. curOption,
  550. i;
  551. if ( arguments.length === 0 ) {
  552. // don't return a reference to the internal hash
  553. return $.widget.extend( {}, this.options );
  554. }
  555. if ( typeof key === "string" ) {
  556. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  557. options = {};
  558. parts = key.split( "." );
  559. key = parts.shift();
  560. if ( parts.length ) {
  561. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  562. for ( i = 0; i < parts.length - 1; i++ ) {
  563. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  564. curOption = curOption[ parts[ i ] ];
  565. }
  566. key = parts.pop();
  567. if ( arguments.length === 1 ) {
  568. return curOption[ key ] === undefined ? null : curOption[ key ];
  569. }
  570. curOption[ key ] = value;
  571. } else {
  572. if ( arguments.length === 1 ) {
  573. return this.options[ key ] === undefined ? null : this.options[ key ];
  574. }
  575. options[ key ] = value;
  576. }
  577. }
  578. this._setOptions( options );
  579. return this;
  580. },
  581. _setOptions: function( options ) {
  582. var key;
  583. for ( key in options ) {
  584. this._setOption( key, options[ key ] );
  585. }
  586. return this;
  587. },
  588. _setOption: function( key, value ) {
  589. this.options[ key ] = value;
  590. if ( key === "disabled" ) {
  591. this.widget()
  592. .toggleClass( this.widgetFullName + "-disabled", !!value );
  593. // If the widget is becoming disabled, then nothing is interactive
  594. if ( value ) {
  595. this.hoverable.removeClass( "ui-state-hover" );
  596. this.focusable.removeClass( "ui-state-focus" );
  597. }
  598. }
  599. return this;
  600. },
  601. enable: function() {
  602. return this._setOptions({ disabled: false });
  603. },
  604. disable: function() {
  605. return this._setOptions({ disabled: true });
  606. },
  607. _on: function( suppressDisabledCheck, element, handlers ) {
  608. var delegateElement,
  609. instance = this;
  610. // no suppressDisabledCheck flag, shuffle arguments
  611. if ( typeof suppressDisabledCheck !== "boolean" ) {
  612. handlers = element;
  613. element = suppressDisabledCheck;
  614. suppressDisabledCheck = false;
  615. }
  616. // no element argument, shuffle and use this.element
  617. if ( !handlers ) {
  618. handlers = element;
  619. element = this.element;
  620. delegateElement = this.widget();
  621. } else {
  622. element = delegateElement = $( element );
  623. this.bindings = this.bindings.add( element );
  624. }
  625. $.each( handlers, function( event, handler ) {
  626. function handlerProxy() {
  627. // allow widgets to customize the disabled handling
  628. // - disabled as an array instead of boolean
  629. // - disabled class as method for disabling individual parts
  630. if ( !suppressDisabledCheck &&
  631. ( instance.options.disabled === true ||
  632. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  633. return;
  634. }
  635. return ( typeof handler === "string" ? instance[ handler ] : handler )
  636. .apply( instance, arguments );
  637. }
  638. // copy the guid so direct unbinding works
  639. if ( typeof handler !== "string" ) {
  640. handlerProxy.guid = handler.guid =
  641. handler.guid || handlerProxy.guid || $.guid++;
  642. }
  643. var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
  644. eventName = match[1] + instance.eventNamespace,
  645. selector = match[2];
  646. if ( selector ) {
  647. delegateElement.delegate( selector, eventName, handlerProxy );
  648. } else {
  649. element.bind( eventName, handlerProxy );
  650. }
  651. });
  652. },
  653. _off: function( element, eventName ) {
  654. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) +
  655. this.eventNamespace;
  656. element.unbind( eventName ).undelegate( eventName );
  657. // Clear the stack to avoid memory leaks (#10056)
  658. this.bindings = $( this.bindings.not( element ).get() );
  659. this.focusable = $( this.focusable.not( element ).get() );
  660. this.hoverable = $( this.hoverable.not( element ).get() );
  661. },
  662. _delay: function( handler, delay ) {
  663. function handlerProxy() {
  664. return ( typeof handler === "string" ? instance[ handler ] : handler )
  665. .apply( instance, arguments );
  666. }
  667. var instance = this;
  668. return setTimeout( handlerProxy, delay || 0 );
  669. },
  670. _hoverable: function( element ) {
  671. this.hoverable = this.hoverable.add( element );
  672. this._on( element, {
  673. mouseenter: function( event ) {
  674. $( event.currentTarget ).addClass( "ui-state-hover" );
  675. },
  676. mouseleave: function( event ) {
  677. $( event.currentTarget ).removeClass( "ui-state-hover" );
  678. }
  679. });
  680. },
  681. _focusable: function( element ) {
  682. this.focusable = this.focusable.add( element );
  683. this._on( element, {
  684. focusin: function( event ) {
  685. $( event.currentTarget ).addClass( "ui-state-focus" );
  686. },
  687. focusout: function( event ) {
  688. $( event.currentTarget ).removeClass( "ui-state-focus" );
  689. }
  690. });
  691. },
  692. _trigger: function( type, event, data ) {
  693. var prop, orig,
  694. callback = this.options[ type ];
  695. data = data || {};
  696. event = $.Event( event );
  697. event.type = ( type === this.widgetEventPrefix ?
  698. type :
  699. this.widgetEventPrefix + type ).toLowerCase();
  700. // the original event may come from any element
  701. // so we need to reset the target on the new event
  702. event.target = this.element[ 0 ];
  703. // copy original event properties over to the new event
  704. orig = event.originalEvent;
  705. if ( orig ) {
  706. for ( prop in orig ) {
  707. if ( !( prop in event ) ) {
  708. event[ prop ] = orig[ prop ];
  709. }
  710. }
  711. }
  712. this.element.trigger( event, data );
  713. return !( $.isFunction( callback ) &&
  714. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  715. event.isDefaultPrevented() );
  716. }
  717. };
  718. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  719. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  720. if ( typeof options === "string" ) {
  721. options = { effect: options };
  722. }
  723. var hasOptions,
  724. effectName = !options ?
  725. method :
  726. options === true || typeof options === "number" ?
  727. defaultEffect :
  728. options.effect || defaultEffect;
  729. options = options || {};
  730. if ( typeof options === "number" ) {
  731. options = { duration: options };
  732. }
  733. hasOptions = !$.isEmptyObject( options );
  734. options.complete = callback;
  735. if ( options.delay ) {
  736. element.delay( options.delay );
  737. }
  738. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  739. element[ method ]( options );
  740. } else if ( effectName !== method && element[ effectName ] ) {
  741. element[ effectName ]( options.duration, options.easing, callback );
  742. } else {
  743. element.queue(function( next ) {
  744. $( this )[ method ]();
  745. if ( callback ) {
  746. callback.call( element[ 0 ] );
  747. }
  748. next();
  749. });
  750. }
  751. };
  752. });
  753. var widget = $.widget;
  754. /*!
  755. * jQuery UI Position 1.11.4
  756. * http://jqueryui.com
  757. *
  758. * Copyright jQuery Foundation and other contributors
  759. * Released under the MIT license.
  760. * http://jquery.org/license
  761. *
  762. * http://api.jqueryui.com/position/
  763. */
  764. (function() {
  765. $.ui = $.ui || {};
  766. var cachedScrollbarWidth, supportsOffsetFractions,
  767. max = Math.max,
  768. abs = Math.abs,
  769. round = Math.round,
  770. rhorizontal = /left|center|right/,
  771. rvertical = /top|center|bottom/,
  772. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  773. rposition = /^\w+/,
  774. rpercent = /%$/,
  775. _position = $.fn.position;
  776. function getOffsets( offsets, width, height ) {
  777. return [
  778. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  779. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  780. ];
  781. }
  782. function parseCss( element, property ) {
  783. return parseInt( $.css( element, property ), 10 ) || 0;
  784. }
  785. function getDimensions( elem ) {
  786. var raw = elem[0];
  787. if ( raw.nodeType === 9 ) {
  788. return {
  789. width: elem.width(),
  790. height: elem.height(),
  791. offset: { top: 0, left: 0 }
  792. };
  793. }
  794. if ( $.isWindow( raw ) ) {
  795. return {
  796. width: elem.width(),
  797. height: elem.height(),
  798. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  799. };
  800. }
  801. if ( raw.preventDefault ) {
  802. return {
  803. width: 0,
  804. height: 0,
  805. offset: { top: raw.pageY, left: raw.pageX }
  806. };
  807. }
  808. return {
  809. width: elem.outerWidth(),
  810. height: elem.outerHeight(),
  811. offset: elem.offset()
  812. };
  813. }
  814. $.position = {
  815. scrollbarWidth: function() {
  816. if ( cachedScrollbarWidth !== undefined ) {
  817. return cachedScrollbarWidth;
  818. }
  819. var w1, w2,
  820. div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  821. innerDiv = div.children()[0];
  822. $( "body" ).append( div );
  823. w1 = innerDiv.offsetWidth;
  824. div.css( "overflow", "scroll" );
  825. w2 = innerDiv.offsetWidth;
  826. if ( w1 === w2 ) {
  827. w2 = div[0].clientWidth;
  828. }
  829. div.remove();
  830. return (cachedScrollbarWidth = w1 - w2);
  831. },
  832. getScrollInfo: function( within ) {
  833. var overflowX = within.isWindow || within.isDocument ? "" :
  834. within.element.css( "overflow-x" ),
  835. overflowY = within.isWindow || within.isDocument ? "" :
  836. within.element.css( "overflow-y" ),
  837. hasOverflowX = overflowX === "scroll" ||
  838. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  839. hasOverflowY = overflowY === "scroll" ||
  840. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  841. return {
  842. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  843. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  844. };
  845. },
  846. getWithinInfo: function( element ) {
  847. var withinElement = $( element || window ),
  848. isWindow = $.isWindow( withinElement[0] ),
  849. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
  850. return {
  851. element: withinElement,
  852. isWindow: isWindow,
  853. isDocument: isDocument,
  854. offset: withinElement.offset() || { left: 0, top: 0 },
  855. scrollLeft: withinElement.scrollLeft(),
  856. scrollTop: withinElement.scrollTop(),
  857. // support: jQuery 1.6.x
  858. // jQuery 1.6 doesn't support .outerWidth/Height() on documents or windows
  859. width: isWindow || isDocument ? withinElement.width() : withinElement.outerWidth(),
  860. height: isWindow || isDocument ? withinElement.height() : withinElement.outerHeight()
  861. };
  862. }
  863. };
  864. $.fn.position = function( options ) {
  865. if ( !options || !options.of ) {
  866. return _position.apply( this, arguments );
  867. }
  868. // make a copy, we don't want to modify arguments
  869. options = $.extend( {}, options );
  870. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  871. target = $( options.of ),
  872. within = $.position.getWithinInfo( options.within ),
  873. scrollInfo = $.position.getScrollInfo( within ),
  874. collision = ( options.collision || "flip" ).split( " " ),
  875. offsets = {};
  876. dimensions = getDimensions( target );
  877. if ( target[0].preventDefault ) {
  878. // force left top to allow flipping
  879. options.at = "left top";
  880. }
  881. targetWidth = dimensions.width;
  882. targetHeight = dimensions.height;
  883. targetOffset = dimensions.offset;
  884. // clone to reuse original targetOffset later
  885. basePosition = $.extend( {}, targetOffset );
  886. // force my and at to have valid horizontal and vertical positions
  887. // if a value is missing or invalid, it will be converted to center
  888. $.each( [ "my", "at" ], function() {
  889. var pos = ( options[ this ] || "" ).split( " " ),
  890. horizontalOffset,
  891. verticalOffset;
  892. if ( pos.length === 1) {
  893. pos = rhorizontal.test( pos[ 0 ] ) ?
  894. pos.concat( [ "center" ] ) :
  895. rvertical.test( pos[ 0 ] ) ?
  896. [ "center" ].concat( pos ) :
  897. [ "center", "center" ];
  898. }
  899. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  900. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  901. // calculate offsets
  902. horizontalOffset = roffset.exec( pos[ 0 ] );
  903. verticalOffset = roffset.exec( pos[ 1 ] );
  904. offsets[ this ] = [
  905. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  906. verticalOffset ? verticalOffset[ 0 ] : 0
  907. ];
  908. // reduce to just the positions without the offsets
  909. options[ this ] = [
  910. rposition.exec( pos[ 0 ] )[ 0 ],
  911. rposition.exec( pos[ 1 ] )[ 0 ]
  912. ];
  913. });
  914. // normalize collision option
  915. if ( collision.length === 1 ) {
  916. collision[ 1 ] = collision[ 0 ];
  917. }
  918. if ( options.at[ 0 ] === "right" ) {
  919. basePosition.left += targetWidth;
  920. } else if ( options.at[ 0 ] === "center" ) {
  921. basePosition.left += targetWidth / 2;
  922. }
  923. if ( options.at[ 1 ] === "bottom" ) {
  924. basePosition.top += targetHeight;
  925. } else if ( options.at[ 1 ] === "center" ) {
  926. basePosition.top += targetHeight / 2;
  927. }
  928. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  929. basePosition.left += atOffset[ 0 ];
  930. basePosition.top += atOffset[ 1 ];
  931. return this.each(function() {
  932. var collisionPosition, using,
  933. elem = $( this ),
  934. elemWidth = elem.outerWidth(),
  935. elemHeight = elem.outerHeight(),
  936. marginLeft = parseCss( this, "marginLeft" ),
  937. marginTop = parseCss( this, "marginTop" ),
  938. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  939. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  940. position = $.extend( {}, basePosition ),
  941. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  942. if ( options.my[ 0 ] === "right" ) {
  943. position.left -= elemWidth;
  944. } else if ( options.my[ 0 ] === "center" ) {
  945. position.left -= elemWidth / 2;
  946. }
  947. if ( options.my[ 1 ] === "bottom" ) {
  948. position.top -= elemHeight;
  949. } else if ( options.my[ 1 ] === "center" ) {
  950. position.top -= elemHeight / 2;
  951. }
  952. position.left += myOffset[ 0 ];
  953. position.top += myOffset[ 1 ];
  954. // if the browser doesn't support fractions, then round for consistent results
  955. if ( !supportsOffsetFractions ) {
  956. position.left = round( position.left );
  957. position.top = round( position.top );
  958. }
  959. collisionPosition = {
  960. marginLeft: marginLeft,
  961. marginTop: marginTop
  962. };
  963. $.each( [ "left", "top" ], function( i, dir ) {
  964. if ( $.ui.position[ collision[ i ] ] ) {
  965. $.ui.position[ collision[ i ] ][ dir ]( position, {
  966. targetWidth: targetWidth,
  967. targetHeight: targetHeight,
  968. elemWidth: elemWidth,
  969. elemHeight: elemHeight,
  970. collisionPosition: collisionPosition,
  971. collisionWidth: collisionWidth,
  972. collisionHeight: collisionHeight,
  973. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  974. my: options.my,
  975. at: options.at,
  976. within: within,
  977. elem: elem
  978. });
  979. }
  980. });
  981. if ( options.using ) {
  982. // adds feedback as second argument to using callback, if present
  983. using = function( props ) {
  984. var left = targetOffset.left - position.left,
  985. right = left + targetWidth - elemWidth,
  986. top = targetOffset.top - position.top,
  987. bottom = top + targetHeight - elemHeight,
  988. feedback = {
  989. target: {
  990. element: target,
  991. left: targetOffset.left,
  992. top: targetOffset.top,
  993. width: targetWidth,
  994. height: targetHeight
  995. },
  996. element: {
  997. element: elem,
  998. left: position.left,
  999. top: position.top,
  1000. width: elemWidth,
  1001. height: elemHeight
  1002. },
  1003. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1004. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1005. };
  1006. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  1007. feedback.horizontal = "center";
  1008. }
  1009. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  1010. feedback.vertical = "middle";
  1011. }
  1012. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  1013. feedback.important = "horizontal";
  1014. } else {
  1015. feedback.important = "vertical";
  1016. }
  1017. options.using.call( this, props, feedback );
  1018. };
  1019. }
  1020. elem.offset( $.extend( position, { using: using } ) );
  1021. });
  1022. };
  1023. $.ui.position = {
  1024. fit: {
  1025. left: function( position, data ) {
  1026. var within = data.within,
  1027. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1028. outerWidth = within.width,
  1029. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1030. overLeft = withinOffset - collisionPosLeft,
  1031. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1032. newOverRight;
  1033. // element is wider than within
  1034. if ( data.collisionWidth > outerWidth ) {
  1035. // element is initially over the left side of within
  1036. if ( overLeft > 0 && overRight <= 0 ) {
  1037. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1038. position.left += overLeft - newOverRight;
  1039. // element is initially over right side of within
  1040. } else if ( overRight > 0 && overLeft <= 0 ) {
  1041. position.left = withinOffset;
  1042. // element is initially over both left and right sides of within
  1043. } else {
  1044. if ( overLeft > overRight ) {
  1045. position.left = withinOffset + outerWidth - data.collisionWidth;
  1046. } else {
  1047. position.left = withinOffset;
  1048. }
  1049. }
  1050. // too far left -> align with left edge
  1051. } else if ( overLeft > 0 ) {
  1052. position.left += overLeft;
  1053. // too far right -> align with right edge
  1054. } else if ( overRight > 0 ) {
  1055. position.left -= overRight;
  1056. // adjust based on position and margin
  1057. } else {
  1058. position.left = max( position.left - collisionPosLeft, position.left );
  1059. }
  1060. },
  1061. top: function( position, data ) {
  1062. var within = data.within,
  1063. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1064. outerHeight = data.within.height,
  1065. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1066. overTop = withinOffset - collisionPosTop,
  1067. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1068. newOverBottom;
  1069. // element is taller than within
  1070. if ( data.collisionHeight > outerHeight ) {
  1071. // element is initially over the top of within
  1072. if ( overTop > 0 && overBottom <= 0 ) {
  1073. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1074. position.top += overTop - newOverBottom;
  1075. // element is initially over bottom of within
  1076. } else if ( overBottom > 0 && overTop <= 0 ) {
  1077. position.top = withinOffset;
  1078. // element is initially over both top and bottom of within
  1079. } else {
  1080. if ( overTop > overBottom ) {
  1081. position.top = withinOffset + outerHeight - data.collisionHeight;
  1082. } else {
  1083. position.top = withinOffset;
  1084. }
  1085. }
  1086. // too far up -> align with top
  1087. } else if ( overTop > 0 ) {
  1088. position.top += overTop;
  1089. // too far down -> align with bottom edge
  1090. } else if ( overBottom > 0 ) {
  1091. position.top -= overBottom;
  1092. // adjust based on position and margin
  1093. } else {
  1094. position.top = max( position.top - collisionPosTop, position.top );
  1095. }
  1096. }
  1097. },
  1098. flip: {
  1099. left: function( position, data ) {
  1100. var within = data.within,
  1101. withinOffset = within.offset.left + within.scrollLeft,
  1102. outerWidth = within.width,
  1103. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1104. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1105. overLeft = collisionPosLeft - offsetLeft,
  1106. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1107. myOffset = data.my[ 0 ] === "left" ?
  1108. -data.elemWidth :
  1109. data.my[ 0 ] === "right" ?
  1110. data.elemWidth :
  1111. 0,
  1112. atOffset = data.at[ 0 ] === "left" ?
  1113. data.targetWidth :
  1114. data.at[ 0 ] === "right" ?
  1115. -data.targetWidth :
  1116. 0,
  1117. offset = -2 * data.offset[ 0 ],
  1118. newOverRight,
  1119. newOverLeft;
  1120. if ( overLeft < 0 ) {
  1121. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1122. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1123. position.left += myOffset + atOffset + offset;
  1124. }
  1125. } else if ( overRight > 0 ) {
  1126. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1127. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1128. position.left += myOffset + atOffset + offset;
  1129. }
  1130. }
  1131. },
  1132. top: function( position, data ) {
  1133. var within = data.within,
  1134. withinOffset = within.offset.top + within.scrollTop,
  1135. outerHeight = within.height,
  1136. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1137. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1138. overTop = collisionPosTop - offsetTop,
  1139. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1140. top = data.my[ 1 ] === "top",
  1141. myOffset = top ?
  1142. -data.elemHeight :
  1143. data.my[ 1 ] === "bottom" ?
  1144. data.elemHeight :
  1145. 0,
  1146. atOffset = data.at[ 1 ] === "top" ?
  1147. data.targetHeight :
  1148. data.at[ 1 ] === "bottom" ?
  1149. -data.targetHeight :
  1150. 0,
  1151. offset = -2 * data.offset[ 1 ],
  1152. newOverTop,
  1153. newOverBottom;
  1154. if ( overTop < 0 ) {
  1155. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1156. if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
  1157. position.top += myOffset + atOffset + offset;
  1158. }
  1159. } else if ( overBottom > 0 ) {
  1160. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1161. if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
  1162. position.top += myOffset + atOffset + offset;
  1163. }
  1164. }
  1165. }
  1166. },
  1167. flipfit: {
  1168. left: function() {
  1169. $.ui.position.flip.left.apply( this, arguments );
  1170. $.ui.position.fit.left.apply( this, arguments );
  1171. },
  1172. top: function() {
  1173. $.ui.position.flip.top.apply( this, arguments );
  1174. $.ui.position.fit.top.apply( this, arguments );
  1175. }
  1176. }
  1177. };
  1178. // fraction support test
  1179. (function() {
  1180. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1181. body = document.getElementsByTagName( "body" )[ 0 ],
  1182. div = document.createElement( "div" );
  1183. //Create a "fake body" for testing based on method used in jQuery.support
  1184. testElement = document.createElement( body ? "div" : "body" );
  1185. testElementStyle = {
  1186. visibility: "hidden",
  1187. width: 0,
  1188. height: 0,
  1189. border: 0,
  1190. margin: 0,
  1191. background: "none"
  1192. };
  1193. if ( body ) {
  1194. $.extend( testElementStyle, {
  1195. position: "absolute",
  1196. left: "-1000px",
  1197. top: "-1000px"
  1198. });
  1199. }
  1200. for ( i in testElementStyle ) {
  1201. testElement.style[ i ] = testElementStyle[ i ];
  1202. }
  1203. testElement.appendChild( div );
  1204. testElementParent = body || document.documentElement;
  1205. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1206. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1207. offsetLeft = $( div ).offset().left;
  1208. supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1209. testElement.innerHTML = "";
  1210. testElementParent.removeChild( testElement );
  1211. })();
  1212. })();
  1213. var position = $.ui.position;
  1214. /*!
  1215. * jQuery UI Menu 1.11.4
  1216. * http://jqueryui.com
  1217. *
  1218. * Copyright jQuery Foundation and other contributors
  1219. * Released under the MIT license.
  1220. * http://jquery.org/license
  1221. *
  1222. * http://api.jqueryui.com/menu/
  1223. */
  1224. var menu = $.widget( "ui.menu", {
  1225. version: "1.11.4",
  1226. defaultElement: "<ul>",
  1227. delay: 300,
  1228. options: {
  1229. icons: {
  1230. submenu: "ui-icon-carat-1-e"
  1231. },
  1232. items: "> *",
  1233. menus: "ul",
  1234. position: {
  1235. my: "left-1 top",
  1236. at: "right top"
  1237. },
  1238. role: "menu",
  1239. // callbacks
  1240. blur: null,
  1241. focus: null,
  1242. select: null
  1243. },
  1244. _create: function() {
  1245. this.activeMenu = this.element;
  1246. // Flag used to prevent firing of the click handler
  1247. // as the event bubbles up through nested menus
  1248. this.mouseHandled = false;
  1249. this.element
  1250. .uniqueId()
  1251. .addClass( "ui-menu ui-widget ui-widget-content" )
  1252. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  1253. .attr({
  1254. role: this.options.role,
  1255. tabIndex: 0
  1256. });
  1257. if ( this.options.disabled ) {
  1258. this.element
  1259. .addClass( "ui-state-disabled" )
  1260. .attr( "aria-disabled", "true" );
  1261. }
  1262. this._on({
  1263. // Prevent focus from sticking to links inside menu after clicking
  1264. // them (focus should always stay on UL during navigation).
  1265. "mousedown .ui-menu-item": function( event ) {
  1266. event.preventDefault();
  1267. },
  1268. "click .ui-menu-item": function( event ) {
  1269. var target = $( event.target );
  1270. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  1271. this.select( event );
  1272. // Only set the mouseHandled flag if the event will bubble, see #9469.
  1273. if ( !event.isPropagationStopped() ) {
  1274. this.mouseHandled = true;
  1275. }
  1276. // Open submenu on click
  1277. if ( target.has( ".ui-menu" ).length ) {
  1278. this.expand( event );
  1279. } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
  1280. // Redirect focus to the menu
  1281. this.element.trigger( "focus", [ true ] );
  1282. // If the active item is on the top level, let it stay active.
  1283. // Otherwise, blur the active item since it is no longer visible.
  1284. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  1285. clearTimeout( this.timer );
  1286. }
  1287. }
  1288. }
  1289. },
  1290. "mouseenter .ui-menu-item": function( event ) {
  1291. // Ignore mouse events while typeahead is active, see #10458.
  1292. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  1293. // is over an item in the menu
  1294. if ( this.previousFilter ) {
  1295. return;
  1296. }
  1297. var target = $( event.currentTarget );
  1298. // Remove ui-state-active class from siblings of the newly focused menu item
  1299. // to avoid a jump caused by adjacent elements both having a class with a border
  1300. target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
  1301. this.focus( event, target );
  1302. },
  1303. mouseleave: "collapseAll",
  1304. "mouseleave .ui-menu": "collapseAll",
  1305. focus: function( event, keepActiveItem ) {
  1306. // If there's already an active item, keep it active
  1307. // If not, activate the first item
  1308. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  1309. if ( !keepActiveItem ) {
  1310. this.focus( event, item );
  1311. }
  1312. },
  1313. blur: function( event ) {
  1314. this._delay(function() {
  1315. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  1316. this.collapseAll( event );
  1317. }
  1318. });
  1319. },
  1320. keydown: "_keydown"
  1321. });
  1322. this.refresh();
  1323. // Clicks outside of a menu collapse any open menus
  1324. this._on( this.document, {
  1325. click: function( event ) {
  1326. if ( this._closeOnDocumentClick( event ) ) {
  1327. this.collapseAll( event );
  1328. }
  1329. // Reset the mouseHandled flag
  1330. this.mouseHandled = false;
  1331. }
  1332. });
  1333. },
  1334. _destroy: function() {
  1335. // Destroy (sub)menus
  1336. this.element
  1337. .removeAttr( "aria-activedescendant" )
  1338. .find( ".ui-menu" ).addBack()
  1339. .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
  1340. .removeAttr( "role" )
  1341. .removeAttr( "tabIndex" )
  1342. .removeAttr( "aria-labelledby" )
  1343. .removeAttr( "aria-expanded" )
  1344. .removeAttr( "aria-hidden" )
  1345. .removeAttr( "aria-disabled" )
  1346. .removeUniqueId()
  1347. .show();
  1348. // Destroy menu items
  1349. this.element.find( ".ui-menu-item" )
  1350. .removeClass( "ui-menu-item" )
  1351. .removeAttr( "role" )
  1352. .removeAttr( "aria-disabled" )
  1353. .removeUniqueId()
  1354. .removeClass( "ui-state-hover" )
  1355. .removeAttr( "tabIndex" )
  1356. .removeAttr( "role" )
  1357. .removeAttr( "aria-haspopup" )
  1358. .children().each( function() {
  1359. var elem = $( this );
  1360. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  1361. elem.remove();
  1362. }
  1363. });
  1364. // Destroy menu dividers
  1365. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  1366. },
  1367. _keydown: function( event ) {
  1368. var match, prev, character, skip,
  1369. preventDefault = true;
  1370. switch ( event.keyCode ) {
  1371. case $.ui.keyCode.PAGE_UP:
  1372. this.previousPage( event );
  1373. break;
  1374. case $.ui.keyCode.PAGE_DOWN:
  1375. this.nextPage( event );
  1376. break;
  1377. case $.ui.keyCode.HOME:
  1378. this._move( "first", "first", event );
  1379. break;
  1380. case $.ui.keyCode.END:
  1381. this._move( "last", "last", event );
  1382. break;
  1383. case $.ui.keyCode.UP:
  1384. this.previous( event );
  1385. break;
  1386. case $.ui.keyCode.DOWN:
  1387. this.next( event );
  1388. break;
  1389. case $.ui.keyCode.LEFT:
  1390. this.collapse( event );
  1391. break;
  1392. case $.ui.keyCode.RIGHT:
  1393. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  1394. this.expand( event );
  1395. }
  1396. break;
  1397. case $.ui.keyCode.ENTER:
  1398. case $.ui.keyCode.SPACE:
  1399. this._activate( event );
  1400. break;
  1401. case $.ui.keyCode.ESCAPE:
  1402. this.collapse( event );
  1403. break;
  1404. default:
  1405. preventDefault = false;
  1406. prev = this.previousFilter || "";
  1407. character = String.fromCharCode( event.keyCode );
  1408. skip = false;
  1409. clearTimeout( this.filterTimer );
  1410. if ( character === prev ) {
  1411. skip = true;
  1412. } else {
  1413. character = prev + character;
  1414. }
  1415. match = this._filterMenuItems( character );
  1416. match = skip && match.index( this.active.next() ) !== -1 ?
  1417. this.active.nextAll( ".ui-menu-item" ) :
  1418. match;
  1419. // If no matches on the current filter, reset to the last character pressed
  1420. // to move down the menu to the first item that starts with that character
  1421. if ( !match.length ) {
  1422. character = String.fromCharCode( event.keyCode );
  1423. match = this._filterMenuItems( character );
  1424. }
  1425. if ( match.length ) {
  1426. this.focus( event, match );
  1427. this.previousFilter = character;
  1428. this.filterTimer = this._delay(function() {
  1429. delete this.previousFilter;
  1430. }, 1000 );
  1431. } else {
  1432. delete this.previousFilter;
  1433. }
  1434. }
  1435. if ( preventDefault ) {
  1436. event.preventDefault();
  1437. }
  1438. },
  1439. _activate: function( event ) {
  1440. if ( !this.active.is( ".ui-state-disabled" ) ) {
  1441. if ( this.active.is( "[aria-haspopup='true']" ) ) {
  1442. this.expand( event );
  1443. } else {
  1444. this.select( event );
  1445. }
  1446. }
  1447. },
  1448. refresh: function() {
  1449. var menus, items,
  1450. that = this,
  1451. icon = this.options.icons.submenu,
  1452. submenus = this.element.find( this.options.menus );
  1453. this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
  1454. // Initialize nested menus
  1455. submenus.filter( ":not(.ui-menu)" )
  1456. .addClass( "ui-menu ui-widget ui-widget-content ui-front" )
  1457. .hide()
  1458. .attr({
  1459. role: this.options.role,
  1460. "aria-hidden": "true",
  1461. "aria-expanded": "false"
  1462. })
  1463. .each(function() {
  1464. var menu = $( this ),
  1465. item = menu.parent(),
  1466. submenuCarat = $( "<span>" )
  1467. .addClass( "ui-menu-icon ui-icon " + icon )
  1468. .data( "ui-menu-submenu-carat", true );
  1469. item
  1470. .attr( "aria-haspopup", "true" )
  1471. .prepend( submenuCarat );
  1472. menu.attr( "aria-labelledby", item.attr( "id" ) );
  1473. });
  1474. menus = submenus.add( this.element );
  1475. items = menus.find( this.options.items );
  1476. // Initialize menu-items containing spaces and/or dashes only as dividers
  1477. items.not( ".ui-menu-item" ).each(function() {
  1478. var item = $( this );
  1479. if ( that._isDivider( item ) ) {
  1480. item.addClass( "ui-widget-content ui-menu-divider" );
  1481. }
  1482. });
  1483. // Don't refresh list items that are already adapted
  1484. items.not( ".ui-menu-item, .ui-menu-divider" )
  1485. .addClass( "ui-menu-item" )
  1486. .uniqueId()
  1487. .attr({
  1488. tabIndex: -1,
  1489. role: this._itemRole()
  1490. });
  1491. // Add aria-disabled attribute to any disabled menu item
  1492. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  1493. // If the active item has been removed, blur the menu
  1494. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  1495. this.blur();
  1496. }
  1497. },
  1498. _itemRole: function() {
  1499. return {
  1500. menu: "menuitem",
  1501. listbox: "option"
  1502. }[ this.options.role ];
  1503. },
  1504. _setOption: function( key, value ) {
  1505. if ( key === "icons" ) {
  1506. this.element.find( ".ui-menu-icon" )
  1507. .removeClass( this.options.icons.submenu )
  1508. .addClass( value.submenu );
  1509. }
  1510. if ( key === "disabled" ) {
  1511. this.element
  1512. .toggleClass( "ui-state-disabled", !!value )
  1513. .attr( "aria-disabled", value );
  1514. }
  1515. this._super( key, value );
  1516. },
  1517. focus: function( event, item ) {
  1518. var nested, focused;
  1519. this.blur( event, event && event.type === "focus" );
  1520. this._scrollIntoView( item );
  1521. this.active = item.first();
  1522. focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
  1523. // Only update aria-activedescendant if there's a role
  1524. // otherwise we assume focus is managed elsewhere
  1525. if ( this.options.role ) {
  1526. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  1527. }
  1528. // Highlight active parent menu item, if any
  1529. this.active
  1530. .parent()
  1531. .closest( ".ui-menu-item" )
  1532. .addClass( "ui-state-active" );
  1533. if ( event && event.type === "keydown" ) {
  1534. this._close();
  1535. } else {
  1536. this.timer = this._delay(function() {
  1537. this._close();
  1538. }, this.delay );
  1539. }
  1540. nested = item.children( ".ui-menu" );
  1541. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  1542. this._startOpening(nested);
  1543. }
  1544. this.activeMenu = item.parent();
  1545. this._trigger( "focus", event, { item: item } );
  1546. },
  1547. _scrollIntoView: function( item ) {
  1548. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  1549. if ( this._hasScroll() ) {
  1550. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  1551. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  1552. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  1553. scroll = this.activeMenu.scrollTop();
  1554. elementHeight = this.activeMenu.height();
  1555. itemHeight = item.outerHeight();
  1556. if ( offset < 0 ) {
  1557. this.activeMenu.scrollTop( scroll + offset );
  1558. } else if ( offset + itemHeight > elementHeight ) {
  1559. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  1560. }
  1561. }
  1562. },
  1563. blur: function( event, fromFocus ) {
  1564. if ( !fromFocus ) {
  1565. clearTimeout( this.timer );
  1566. }
  1567. if ( !this.active ) {
  1568. return;
  1569. }
  1570. this.active.removeClass( "ui-state-focus" );
  1571. this.active = null;
  1572. this._trigger( "blur", event, { item: this.active } );
  1573. },
  1574. _startOpening: function( submenu ) {
  1575. clearTimeout( this.timer );
  1576. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  1577. // shift in the submenu position when mousing over the carat icon
  1578. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  1579. return;
  1580. }
  1581. this.timer = this._delay(function() {
  1582. this._close();
  1583. this._open( submenu );
  1584. }, this.delay );
  1585. },
  1586. _open: function( submenu ) {
  1587. var position = $.extend({
  1588. of: this.active
  1589. }, this.options.position );
  1590. clearTimeout( this.timer );
  1591. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  1592. .hide()
  1593. .attr( "aria-hidden", "true" );
  1594. submenu
  1595. .show()
  1596. .removeAttr( "aria-hidden" )
  1597. .attr( "aria-expanded", "true" )
  1598. .position( position );
  1599. },
  1600. collapseAll: function( event, all ) {
  1601. clearTimeout( this.timer );
  1602. this.timer = this._delay(function() {
  1603. // If we were passed an event, look for the submenu that contains the event
  1604. var currentMenu = all ? this.element :
  1605. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  1606. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  1607. if ( !currentMenu.length ) {
  1608. currentMenu = this.element;
  1609. }
  1610. this._close( currentMenu );
  1611. this.blur( event );
  1612. this.activeMenu = currentMenu;
  1613. }, this.delay );
  1614. },
  1615. // With no arguments, closes the currently active menu - if nothing is active
  1616. // it closes all menus. If passed an argument, it will search for menus BELOW
  1617. _close: function( startMenu ) {
  1618. if ( !startMenu ) {
  1619. startMenu = this.active ? this.active.parent() : this.element;
  1620. }
  1621. startMenu
  1622. .find( ".ui-menu" )
  1623. .hide()
  1624. .attr( "aria-hidden", "true" )
  1625. .attr( "aria-expanded", "false" )
  1626. .end()
  1627. .find( ".ui-state-active" ).not( ".ui-state-focus" )
  1628. .removeClass( "ui-state-active" );
  1629. },
  1630. _closeOnDocumentClick: function( event ) {
  1631. return !$( event.target ).closest( ".ui-menu" ).length;
  1632. },
  1633. _isDivider: function( item ) {
  1634. // Match hyphen, em dash, en dash
  1635. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  1636. },
  1637. collapse: function( event ) {
  1638. var newItem = this.active &&
  1639. this.active.parent().closest( ".ui-menu-item", this.element );
  1640. if ( newItem && newItem.length ) {
  1641. this._close();
  1642. this.focus( event, newItem );
  1643. }
  1644. },
  1645. expand: function( event ) {
  1646. var newItem = this.active &&
  1647. this.active
  1648. .children( ".ui-menu " )
  1649. .find( this.options.items )
  1650. .first();
  1651. if ( newItem && newItem.length ) {
  1652. this._open( newItem.parent() );
  1653. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  1654. this._delay(function() {
  1655. this.focus( event, newItem );
  1656. });
  1657. }
  1658. },
  1659. next: function( event ) {
  1660. this._move( "next", "first", event );
  1661. },
  1662. previous: function( event ) {
  1663. this._move( "prev", "last", event );
  1664. },
  1665. isFirstItem: function() {
  1666. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  1667. },
  1668. isLastItem: function() {
  1669. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  1670. },
  1671. _move: function( direction, filter, event ) {
  1672. var next;
  1673. if ( this.active ) {
  1674. if ( direction === "first" || direction === "last" ) {
  1675. next = this.active
  1676. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  1677. .eq( -1 );
  1678. } else {
  1679. next = this.active
  1680. [ direction + "All" ]( ".ui-menu-item" )
  1681. .eq( 0 );
  1682. }
  1683. }
  1684. if ( !next || !next.length || !this.active ) {
  1685. next = this.activeMenu.find( this.options.items )[ filter ]();
  1686. }
  1687. this.focus( event, next );
  1688. },
  1689. nextPage: function( event ) {
  1690. var item, base, height;
  1691. if ( !this.active ) {
  1692. this.next( event );
  1693. return;
  1694. }
  1695. if ( this.isLastItem() ) {
  1696. return;
  1697. }
  1698. if ( this._hasScroll() ) {
  1699. base = this.active.offset().top;
  1700. height = this.element.height();
  1701. this.active.nextAll( ".ui-menu-item" ).each(function() {
  1702. item = $( this );
  1703. return item.offset().top - base - height < 0;
  1704. });
  1705. this.focus( event, item );
  1706. } else {
  1707. this.focus( event, this.activeMenu.find( this.options.items )
  1708. [ !this.active ? "first" : "last" ]() );
  1709. }
  1710. },
  1711. previousPage: function( event ) {
  1712. var item, base, height;
  1713. if ( !this.active ) {
  1714. this.next( event );
  1715. return;
  1716. }
  1717. if ( this.isFirstItem() ) {
  1718. return;
  1719. }
  1720. if ( this._hasScroll() ) {
  1721. base = this.active.offset().top;
  1722. height = this.element.height();
  1723. this.active.prevAll( ".ui-menu-item" ).each(function() {
  1724. item = $( this );
  1725. return item.offset().top - base + height > 0;
  1726. });
  1727. this.focus( event, item );
  1728. } else {
  1729. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  1730. }
  1731. },
  1732. _hasScroll: function() {
  1733. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  1734. },
  1735. select: function( event ) {
  1736. // TODO: It should never be possible to not have an active item at this
  1737. // point, but the tests don't trigger mouseenter before click.
  1738. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  1739. var ui = { item: this.active };
  1740. if ( !this.active.has( ".ui-menu" ).length ) {
  1741. this.collapseAll( event, true );
  1742. }
  1743. this._trigger( "select", event, ui );
  1744. },
  1745. _filterMenuItems: function(character) {
  1746. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  1747. regex = new RegExp( "^" + escapedCharacter, "i" );
  1748. return this.activeMenu
  1749. .find( this.options.items )
  1750. // Only match on items, not dividers or other content (#10571)
  1751. .filter( ".ui-menu-item" )
  1752. .filter(function() {
  1753. return regex.test( $.trim( $( this ).text() ) );
  1754. });
  1755. }
  1756. });
  1757. /*!
  1758. * jQuery UI Autocomplete 1.11.4
  1759. * http://jqueryui.com
  1760. *
  1761. * Copyright jQuery Foundation and other contributors
  1762. * Released under the MIT license.
  1763. * http://jquery.org/license
  1764. *
  1765. * http://api.jqueryui.com/autocomplete/
  1766. */
  1767. $.widget( "ui.autocomplete", {
  1768. version: "1.11.4",
  1769. defaultElement: "<input>",
  1770. options: {
  1771. appendTo: null,
  1772. autoFocus: false,
  1773. delay: 300,
  1774. minLength: 1,
  1775. position: {
  1776. my: "left top",
  1777. at: "left bottom",
  1778. collision: "none"
  1779. },
  1780. source: null,
  1781. // callbacks
  1782. change: null,
  1783. close: null,
  1784. focus: null,
  1785. open: null,
  1786. response: null,
  1787. search: null,
  1788. select: null
  1789. },
  1790. requestIndex: 0,
  1791. pending: 0,
  1792. _create: function() {
  1793. // Some browsers only repeat keydown events, not keypress events,
  1794. // so we use the suppressKeyPress flag to determine if we've already
  1795. // handled the keydown event. #7269
  1796. // Unfortunately the code for & in keypress is the same as the up arrow,
  1797. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  1798. // events when we know the keydown event was used to modify the
  1799. // search term. #7799
  1800. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  1801. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  1802. isTextarea = nodeName === "textarea",
  1803. isInput = nodeName === "input";
  1804. this.isMultiLine =
  1805. // Textareas are always multi-line
  1806. isTextarea ? true :
  1807. // Inputs are always single-line, even if inside a contentEditable element
  1808. // IE also treats inputs as contentEditable
  1809. isInput ? false :
  1810. // All other element types are determined by whether or not they're contentEditable
  1811. this.element.prop( "isContentEditable" );
  1812. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  1813. this.isNewMenu = true;
  1814. this.element
  1815. .addClass( "ui-autocomplete-input" )
  1816. .attr( "autocomplete", "off" );
  1817. this._on( this.element, {
  1818. keydown: function( event ) {
  1819. if ( this.element.prop( "readOnly" ) ) {
  1820. suppressKeyPress = true;
  1821. suppressInput = true;
  1822. suppressKeyPressRepeat = true;
  1823. return;
  1824. }
  1825. suppressKeyPress = false;
  1826. suppressInput = false;
  1827. suppressKeyPressRepeat = false;
  1828. var keyCode = $.ui.keyCode;
  1829. switch ( event.keyCode ) {
  1830. case keyCode.PAGE_UP:
  1831. suppressKeyPress = true;
  1832. this._move( "previousPage", event );
  1833. break;
  1834. case keyCode.PAGE_DOWN:
  1835. suppressKeyPress = true;
  1836. this._move( "nextPage", event );
  1837. break;
  1838. case keyCode.UP:
  1839. suppressKeyPress = true;
  1840. this._keyEvent( "previous", event );
  1841. break;
  1842. case keyCode.DOWN:
  1843. suppressKeyPress = true;
  1844. this._keyEvent( "next", event );
  1845. break;
  1846. case keyCode.ENTER:
  1847. // when menu is open and has focus
  1848. if ( this.menu.active ) {
  1849. // #6055 - Opera still allows the keypress to occur
  1850. // which causes forms to submit
  1851. suppressKeyPress = true;
  1852. event.preventDefault();
  1853. this.menu.select( event );
  1854. }
  1855. break;
  1856. case keyCode.TAB:
  1857. if ( this.menu.active ) {
  1858. this.menu.select( event );
  1859. }
  1860. break;
  1861. case keyCode.ESCAPE:
  1862. if ( this.menu.element.is( ":visible" ) ) {
  1863. if ( !this.isMultiLine ) {
  1864. this._value( this.term );
  1865. }
  1866. this.close( event );
  1867. // Different browsers have different default behavior for escape
  1868. // Single press can mean undo or clear
  1869. // Double press in IE means clear the whole form
  1870. event.preventDefault();
  1871. }
  1872. break;
  1873. default:
  1874. suppressKeyPressRepeat = true;
  1875. // search timeout should be triggered before the input value is changed
  1876. this._searchTimeout( event );
  1877. break;
  1878. }
  1879. },
  1880. keypress: function( event ) {
  1881. if ( suppressKeyPress ) {
  1882. suppressKeyPress = false;
  1883. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  1884. event.preventDefault();
  1885. }
  1886. return;
  1887. }
  1888. if ( suppressKeyPressRepeat ) {
  1889. return;
  1890. }
  1891. // replicate some key handlers to allow them to repeat in Firefox and Opera
  1892. var keyCode = $.ui.keyCode;
  1893. switch ( event.keyCode ) {
  1894. case keyCode.PAGE_UP:
  1895. this._move( "previousPage", event );
  1896. break;
  1897. case keyCode.PAGE_DOWN:
  1898. this._move( "nextPage", event );
  1899. break;
  1900. case keyCode.UP:
  1901. this._keyEvent( "previous", event );
  1902. break;
  1903. case keyCode.DOWN:
  1904. this._keyEvent( "next", event );
  1905. break;
  1906. }
  1907. },
  1908. input: function( event ) {
  1909. if ( suppressInput ) {
  1910. suppressInput = false;
  1911. event.preventDefault();
  1912. return;
  1913. }
  1914. this._searchTimeout( event );
  1915. },
  1916. focus: function() {
  1917. this.selectedItem = null;
  1918. this.previous = this._value();
  1919. },
  1920. blur: function( event ) {
  1921. if ( this.cancelBlur ) {
  1922. delete this.cancelBlur;
  1923. return;
  1924. }
  1925. clearTimeout( this.searching );
  1926. this.close( event );
  1927. this._change( event );
  1928. }
  1929. });
  1930. this._initSource();
  1931. this.menu = $( "<ul>" )
  1932. .addClass( "ui-autocomplete ui-front" )
  1933. .appendTo( this._appendTo() )
  1934. .menu({
  1935. // disable ARIA support, the live region takes care of that
  1936. role: null
  1937. })
  1938. .hide()
  1939. .menu( "instance" );
  1940. this._on( this.menu.element, {
  1941. mousedown: function( event ) {
  1942. // prevent moving focus out of the text field
  1943. event.preventDefault();
  1944. // IE doesn't prevent moving focus even with event.preventDefault()
  1945. // so we set a flag to know when we should ignore the blur event
  1946. this.cancelBlur = true;
  1947. this._delay(function() {
  1948. delete this.cancelBlur;
  1949. });
  1950. // clicking on the scrollbar causes focus to shift to the body
  1951. // but we can't detect a mouseup or a click immediately afterward
  1952. // so we have to track the next mousedown and close the menu if
  1953. // the user clicks somewhere outside of the autocomplete
  1954. var menuElement = this.menu.element[ 0 ];
  1955. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  1956. this._delay(function() {
  1957. var that = this;
  1958. this.document.one( "mousedown", function( event ) {
  1959. if ( event.target !== that.element[ 0 ] &&
  1960. event.target !== menuElement &&
  1961. !$.contains( menuElement, event.target ) ) {
  1962. that.close();
  1963. }
  1964. });
  1965. });
  1966. }
  1967. },
  1968. menufocus: function( event, ui ) {
  1969. var label, item;
  1970. // support: Firefox
  1971. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  1972. if ( this.isNewMenu ) {
  1973. this.isNewMenu = false;
  1974. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  1975. this.menu.blur();
  1976. this.document.one( "mousemove", function() {
  1977. $( event.target ).trigger( event.originalEvent );
  1978. });
  1979. return;
  1980. }
  1981. }
  1982. item = ui.item.data( "ui-autocomplete-item" );
  1983. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  1984. // use value to match what will end up in the input, if it was a key event
  1985. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  1986. this._value( item.value );
  1987. }
  1988. }
  1989. // Announce the value in the liveRegion
  1990. label = ui.item.attr( "aria-label" ) || item.value;
  1991. if ( label && $.trim( label ).length ) {
  1992. this.liveRegion.children().hide();
  1993. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  1994. }
  1995. },
  1996. menuselect: function( event, ui ) {
  1997. var item = ui.item.data( "ui-autocomplete-item" ),
  1998. previous = this.previous;
  1999. // only trigger when focus was lost (click on menu)
  2000. if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) {
  2001. this.element.focus();
  2002. this.previous = previous;
  2003. // #6109 - IE triggers two focus events and the second
  2004. // is asynchronous, so we need to reset the previous
  2005. // term synchronously and asynchronously :-(
  2006. this._delay(function() {
  2007. this.previous = previous;
  2008. this.selectedItem = item;
  2009. });
  2010. }
  2011. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  2012. this._value( item.value );
  2013. }
  2014. // reset the term after the select event
  2015. // this allows custom select handling to work properly
  2016. this.term = this._value();
  2017. this.close( event );
  2018. this.selectedItem = item;
  2019. }
  2020. });
  2021. this.liveRegion = $( "<span>", {
  2022. role: "status",
  2023. "aria-live": "assertive",
  2024. "aria-relevant": "additions"
  2025. })
  2026. .addClass( "ui-helper-hidden-accessible" )
  2027. .appendTo( this.document[ 0 ].body );
  2028. // turning off autocomplete prevents the browser from remembering the
  2029. // value when navigating through history, so we re-enable autocomplete
  2030. // if the page is unloaded before the widget is destroyed. #7790
  2031. this._on( this.window, {
  2032. beforeunload: function() {
  2033. this.element.removeAttr( "autocomplete" );
  2034. }
  2035. });
  2036. },
  2037. _destroy: function() {
  2038. clearTimeout( this.searching );
  2039. this.element
  2040. .removeClass( "ui-autocomplete-input" )
  2041. .removeAttr( "autocomplete" );
  2042. this.menu.element.remove();
  2043. this.liveRegion.remove();
  2044. },
  2045. _setOption: function( key, value ) {
  2046. this._super( key, value );
  2047. if ( key === "source" ) {
  2048. this._initSource();
  2049. }
  2050. if ( key === "appendTo" ) {
  2051. this.menu.element.appendTo( this._appendTo() );
  2052. }
  2053. if ( key === "disabled" && value && this.xhr ) {
  2054. this.xhr.abort();
  2055. }
  2056. },
  2057. _appendTo: function() {
  2058. var element = this.options.appendTo;
  2059. if ( element ) {
  2060. element = element.jquery || element.nodeType ?
  2061. $( element ) :
  2062. this.document.find( element ).eq( 0 );
  2063. }
  2064. if ( !element || !element[ 0 ] ) {
  2065. element = this.element.closest( ".ui-front" );
  2066. }
  2067. if ( !element.length ) {
  2068. element = this.document[ 0 ].body;
  2069. }
  2070. return element;
  2071. },
  2072. _initSource: function() {
  2073. var array, url,
  2074. that = this;
  2075. if ( $.isArray( this.options.source ) ) {
  2076. array = this.options.source;
  2077. this.source = function( request, response ) {
  2078. response( $.ui.autocomplete.filter( array, request.term ) );
  2079. };
  2080. } else if ( typeof this.options.source === "string" ) {
  2081. url = this.options.source;
  2082. this.source = function( request, response ) {
  2083. if ( that.xhr ) {
  2084. that.xhr.abort();
  2085. }
  2086. that.xhr = $.ajax({
  2087. url: url,
  2088. data: request,
  2089. dataType: "json",
  2090. success: function( data ) {
  2091. response( data );
  2092. },
  2093. error: function() {
  2094. response([]);
  2095. }
  2096. });
  2097. };
  2098. } else {
  2099. this.source = this.options.source;
  2100. }
  2101. },
  2102. _searchTimeout: function( event ) {
  2103. clearTimeout( this.searching );
  2104. this.searching = this._delay(function() {
  2105. // Search if the value has changed, or if the user retypes the same value (see #7434)
  2106. var equalValues = this.term === this._value(),
  2107. menuVisible = this.menu.element.is( ":visible" ),
  2108. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  2109. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  2110. this.selectedItem = null;
  2111. this.search( null, event );
  2112. }
  2113. }, this.options.delay );
  2114. },
  2115. search: function( value, event ) {
  2116. value = value != null ? value : this._value();
  2117. // always save the actual value, not the one passed as an argument
  2118. this.term = this._value();
  2119. if ( value.length < this.options.minLength ) {
  2120. return this.close( event );
  2121. }
  2122. if ( this._trigger( "search", event ) === false ) {
  2123. return;
  2124. }
  2125. return this._search( value );
  2126. },
  2127. _search: function( value ) {
  2128. this.pending++;
  2129. this.element.addClass( "ui-autocomplete-loading" );
  2130. this.cancelSearch = false;
  2131. this.source( { term: value }, this._response() );
  2132. },
  2133. _response: function() {
  2134. var index = ++this.requestIndex;
  2135. return $.proxy(function( content ) {
  2136. if ( index === this.requestIndex ) {
  2137. this.__response( content );
  2138. }
  2139. this.pending--;
  2140. if ( !this.pending ) {
  2141. this.element.removeClass( "ui-autocomplete-loading" );
  2142. }
  2143. }, this );
  2144. },
  2145. __response: function( content ) {
  2146. if ( content ) {
  2147. content = this._normalize( content );
  2148. }
  2149. this._trigger( "response", null, { content: content } );
  2150. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  2151. this._suggest( content );
  2152. this._trigger( "open" );
  2153. } else {
  2154. // use ._close() instead of .close() so we don't cancel future searches
  2155. this._close();
  2156. }
  2157. },
  2158. close: function( event ) {
  2159. this.cancelSearch = true;
  2160. this._close( event );
  2161. },
  2162. _close: function( event ) {
  2163. if ( this.menu.element.is( ":visible" ) ) {
  2164. this.menu.element.hide();
  2165. this.menu.blur();
  2166. this.isNewMenu = true;
  2167. this._trigger( "close", event );
  2168. }
  2169. },
  2170. _change: function( event ) {
  2171. if ( this.previous !== this._value() ) {
  2172. this._trigger( "change", event, { item: this.selectedItem } );
  2173. }
  2174. },
  2175. _normalize: function( items ) {
  2176. // assume all items have the right format when the first item is complete
  2177. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  2178. return items;
  2179. }
  2180. return $.map( items, function( item ) {
  2181. if ( typeof item === "string" ) {
  2182. return {
  2183. label: item,
  2184. value: item
  2185. };
  2186. }
  2187. return $.extend( {}, item, {
  2188. label: item.label || item.value,
  2189. value: item.value || item.label
  2190. });
  2191. });
  2192. },
  2193. _suggest: function( items ) {
  2194. var ul = this.menu.element.empty();
  2195. this._renderMenu( ul, items );
  2196. this.isNewMenu = true;
  2197. this.menu.refresh();
  2198. // size and position menu
  2199. ul.show();
  2200. this._resizeMenu();
  2201. ul.position( $.extend({
  2202. of: this.element
  2203. }, this.options.position ) );
  2204. if ( this.options.autoFocus ) {
  2205. this.menu.next();
  2206. }
  2207. },
  2208. _resizeMenu: function() {
  2209. var ul = this.menu.element;
  2210. ul.outerWidth( Math.max(
  2211. // Firefox wraps long text (possibly a rounding bug)
  2212. // so we add 1px to avoid the wrapping (#7513)
  2213. ul.width( "" ).outerWidth() + 1,
  2214. this.element.outerWidth()
  2215. ) );
  2216. },
  2217. _renderMenu: function( ul, items ) {
  2218. var that = this;
  2219. $.each( items, function( index, item ) {
  2220. that._renderItemData( ul, item );
  2221. });
  2222. },
  2223. _renderItemData: function( ul, item ) {
  2224. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  2225. },
  2226. _renderItem: function( ul, item ) {
  2227. return $( "<li>" ).text( item.label ).appendTo( ul );
  2228. },
  2229. _move: function( direction, event ) {
  2230. if ( !this.menu.element.is( ":visible" ) ) {
  2231. this.search( null, event );
  2232. return;
  2233. }
  2234. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  2235. this.menu.isLastItem() && /^next/.test( direction ) ) {
  2236. if ( !this.isMultiLine ) {
  2237. this._value( this.term );
  2238. }
  2239. this.menu.blur();
  2240. return;
  2241. }
  2242. this.menu[ direction ]( event );
  2243. },
  2244. widget: function() {
  2245. return this.menu.element;
  2246. },
  2247. _value: function() {
  2248. return this.valueMethod.apply( this.element, arguments );
  2249. },
  2250. _keyEvent: function( keyEvent, event ) {
  2251. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2252. this._move( keyEvent, event );
  2253. // prevents moving cursor to beginning/end of the text field in some browsers
  2254. event.preventDefault();
  2255. }
  2256. }
  2257. });
  2258. $.extend( $.ui.autocomplete, {
  2259. escapeRegex: function( value ) {
  2260. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  2261. },
  2262. filter: function( array, term ) {
  2263. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  2264. return $.grep( array, function( value ) {
  2265. return matcher.test( value.label || value.value || value );
  2266. });
  2267. }
  2268. });
  2269. // live region extension, adding a `messages` option
  2270. // NOTE: This is an experimental API. We are still investigating
  2271. // a full solution for string manipulation and internationalization.
  2272. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  2273. options: {
  2274. messages: {
  2275. noResults: "No search results.",
  2276. results: function( amount ) {
  2277. return amount + ( amount > 1 ? " results are" : " result is" ) +
  2278. " available, use up and down arrow keys to navigate.";
  2279. }
  2280. }
  2281. },
  2282. __response: function( content ) {
  2283. var message;
  2284. this._superApply( arguments );
  2285. if ( this.options.disabled || this.cancelSearch ) {
  2286. return;
  2287. }
  2288. if ( content && content.length ) {
  2289. message = this.options.messages.results( content.length );
  2290. } else {
  2291. message = this.options.messages.noResults;
  2292. }
  2293. this.liveRegion.children().hide();
  2294. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  2295. }
  2296. });
  2297. var autocomplete = $.ui.autocomplete;
  2298. }));