jquery-ui.js 79 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992
  1. /*! jQuery UI - v1.11.2 - 2014-11-13
  2. * http://jqueryui.com
  3. * Includes: core.js, widget.js, mouse.js, button.js, slider.js, tabs.js
  4. * Copyright 2014 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.2
  16. * http://jqueryui.com
  17. *
  18. * Copyright 2014 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.2",
  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.2
  274. * http://jqueryui.com
  275. *
  276. * Copyright 2014 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. // allow multiple hashes to be passed on init
  432. options = !isMethodCall && args.length ?
  433. $.widget.extend.apply( null, [ options ].concat(args) ) :
  434. options;
  435. if ( isMethodCall ) {
  436. this.each(function() {
  437. var methodValue,
  438. instance = $.data( this, fullName );
  439. if ( options === "instance" ) {
  440. returnValue = instance;
  441. return false;
  442. }
  443. if ( !instance ) {
  444. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  445. "attempted to call method '" + options + "'" );
  446. }
  447. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  448. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  449. }
  450. methodValue = instance[ options ].apply( instance, args );
  451. if ( methodValue !== instance && methodValue !== undefined ) {
  452. returnValue = methodValue && methodValue.jquery ?
  453. returnValue.pushStack( methodValue.get() ) :
  454. methodValue;
  455. return false;
  456. }
  457. });
  458. } else {
  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 Mouse 1.11.2
  756. * http://jqueryui.com
  757. *
  758. * Copyright 2014 jQuery Foundation and other contributors
  759. * Released under the MIT license.
  760. * http://jquery.org/license
  761. *
  762. * http://api.jqueryui.com/mouse/
  763. */
  764. var mouseHandled = false;
  765. $( document ).mouseup( function() {
  766. mouseHandled = false;
  767. });
  768. var mouse = $.widget("ui.mouse", {
  769. version: "1.11.2",
  770. options: {
  771. cancel: "input,textarea,button,select,option",
  772. distance: 1,
  773. delay: 0
  774. },
  775. _mouseInit: function() {
  776. var that = this;
  777. this.element
  778. .bind("mousedown." + this.widgetName, function(event) {
  779. return that._mouseDown(event);
  780. })
  781. .bind("click." + this.widgetName, function(event) {
  782. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  783. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  784. event.stopImmediatePropagation();
  785. return false;
  786. }
  787. });
  788. this.started = false;
  789. },
  790. // TODO: make sure destroying one instance of mouse doesn't mess with
  791. // other instances of mouse
  792. _mouseDestroy: function() {
  793. this.element.unbind("." + this.widgetName);
  794. if ( this._mouseMoveDelegate ) {
  795. this.document
  796. .unbind("mousemove." + this.widgetName, this._mouseMoveDelegate)
  797. .unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
  798. }
  799. },
  800. _mouseDown: function(event) {
  801. // don't let more than one widget handle mouseStart
  802. if ( mouseHandled ) {
  803. return;
  804. }
  805. this._mouseMoved = false;
  806. // we may have missed mouseup (out of window)
  807. (this._mouseStarted && this._mouseUp(event));
  808. this._mouseDownEvent = event;
  809. var that = this,
  810. btnIsLeft = (event.which === 1),
  811. // event.target.nodeName works around a bug in IE 8 with
  812. // disabled inputs (#7620)
  813. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  814. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  815. return true;
  816. }
  817. this.mouseDelayMet = !this.options.delay;
  818. if (!this.mouseDelayMet) {
  819. this._mouseDelayTimer = setTimeout(function() {
  820. that.mouseDelayMet = true;
  821. }, this.options.delay);
  822. }
  823. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  824. this._mouseStarted = (this._mouseStart(event) !== false);
  825. if (!this._mouseStarted) {
  826. event.preventDefault();
  827. return true;
  828. }
  829. }
  830. // Click event may never have fired (Gecko & Opera)
  831. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  832. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  833. }
  834. // these delegates are required to keep context
  835. this._mouseMoveDelegate = function(event) {
  836. return that._mouseMove(event);
  837. };
  838. this._mouseUpDelegate = function(event) {
  839. return that._mouseUp(event);
  840. };
  841. this.document
  842. .bind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  843. .bind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  844. event.preventDefault();
  845. mouseHandled = true;
  846. return true;
  847. },
  848. _mouseMove: function(event) {
  849. // Only check for mouseups outside the document if you've moved inside the document
  850. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  851. // fire a mousemove event if content is placed under the cursor. See #7778
  852. // Support: IE <9
  853. if ( this._mouseMoved ) {
  854. // IE mouseup check - mouseup happened when mouse was out of window
  855. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  856. return this._mouseUp(event);
  857. // Iframe mouseup check - mouseup occurred in another document
  858. } else if ( !event.which ) {
  859. return this._mouseUp( event );
  860. }
  861. }
  862. if ( event.which || event.button ) {
  863. this._mouseMoved = true;
  864. }
  865. if (this._mouseStarted) {
  866. this._mouseDrag(event);
  867. return event.preventDefault();
  868. }
  869. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  870. this._mouseStarted =
  871. (this._mouseStart(this._mouseDownEvent, event) !== false);
  872. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  873. }
  874. return !this._mouseStarted;
  875. },
  876. _mouseUp: function(event) {
  877. this.document
  878. .unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  879. .unbind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  880. if (this._mouseStarted) {
  881. this._mouseStarted = false;
  882. if (event.target === this._mouseDownEvent.target) {
  883. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  884. }
  885. this._mouseStop(event);
  886. }
  887. mouseHandled = false;
  888. return false;
  889. },
  890. _mouseDistanceMet: function(event) {
  891. return (Math.max(
  892. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  893. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  894. ) >= this.options.distance
  895. );
  896. },
  897. _mouseDelayMet: function(/* event */) {
  898. return this.mouseDelayMet;
  899. },
  900. // These are placeholder methods, to be overriden by extending plugin
  901. _mouseStart: function(/* event */) {},
  902. _mouseDrag: function(/* event */) {},
  903. _mouseStop: function(/* event */) {},
  904. _mouseCapture: function(/* event */) { return true; }
  905. });
  906. /*!
  907. * jQuery UI Button 1.11.2
  908. * http://jqueryui.com
  909. *
  910. * Copyright 2014 jQuery Foundation and other contributors
  911. * Released under the MIT license.
  912. * http://jquery.org/license
  913. *
  914. * http://api.jqueryui.com/button/
  915. */
  916. var lastActive,
  917. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  918. typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
  919. formResetHandler = function() {
  920. var form = $( this );
  921. setTimeout(function() {
  922. form.find( ":ui-button" ).button( "refresh" );
  923. }, 1 );
  924. },
  925. radioGroup = function( radio ) {
  926. var name = radio.name,
  927. form = radio.form,
  928. radios = $( [] );
  929. if ( name ) {
  930. name = name.replace( /'/g, "\\'" );
  931. if ( form ) {
  932. radios = $( form ).find( "[name='" + name + "'][type=radio]" );
  933. } else {
  934. radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument )
  935. .filter(function() {
  936. return !this.form;
  937. });
  938. }
  939. }
  940. return radios;
  941. };
  942. $.widget( "ui.button", {
  943. version: "1.11.2",
  944. defaultElement: "<button>",
  945. options: {
  946. disabled: null,
  947. text: true,
  948. label: null,
  949. icons: {
  950. primary: null,
  951. secondary: null
  952. }
  953. },
  954. _create: function() {
  955. this.element.closest( "form" )
  956. .unbind( "reset" + this.eventNamespace )
  957. .bind( "reset" + this.eventNamespace, formResetHandler );
  958. if ( typeof this.options.disabled !== "boolean" ) {
  959. this.options.disabled = !!this.element.prop( "disabled" );
  960. } else {
  961. this.element.prop( "disabled", this.options.disabled );
  962. }
  963. this._determineButtonType();
  964. this.hasTitle = !!this.buttonElement.attr( "title" );
  965. var that = this,
  966. options = this.options,
  967. toggleButton = this.type === "checkbox" || this.type === "radio",
  968. activeClass = !toggleButton ? "ui-state-active" : "";
  969. if ( options.label === null ) {
  970. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  971. }
  972. this._hoverable( this.buttonElement );
  973. this.buttonElement
  974. .addClass( baseClasses )
  975. .attr( "role", "button" )
  976. .bind( "mouseenter" + this.eventNamespace, function() {
  977. if ( options.disabled ) {
  978. return;
  979. }
  980. if ( this === lastActive ) {
  981. $( this ).addClass( "ui-state-active" );
  982. }
  983. })
  984. .bind( "mouseleave" + this.eventNamespace, function() {
  985. if ( options.disabled ) {
  986. return;
  987. }
  988. $( this ).removeClass( activeClass );
  989. })
  990. .bind( "click" + this.eventNamespace, function( event ) {
  991. if ( options.disabled ) {
  992. event.preventDefault();
  993. event.stopImmediatePropagation();
  994. }
  995. });
  996. // Can't use _focusable() because the element that receives focus
  997. // and the element that gets the ui-state-focus class are different
  998. this._on({
  999. focus: function() {
  1000. this.buttonElement.addClass( "ui-state-focus" );
  1001. },
  1002. blur: function() {
  1003. this.buttonElement.removeClass( "ui-state-focus" );
  1004. }
  1005. });
  1006. if ( toggleButton ) {
  1007. this.element.bind( "change" + this.eventNamespace, function() {
  1008. that.refresh();
  1009. });
  1010. }
  1011. if ( this.type === "checkbox" ) {
  1012. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  1013. if ( options.disabled ) {
  1014. return false;
  1015. }
  1016. });
  1017. } else if ( this.type === "radio" ) {
  1018. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  1019. if ( options.disabled ) {
  1020. return false;
  1021. }
  1022. $( this ).addClass( "ui-state-active" );
  1023. that.buttonElement.attr( "aria-pressed", "true" );
  1024. var radio = that.element[ 0 ];
  1025. radioGroup( radio )
  1026. .not( radio )
  1027. .map(function() {
  1028. return $( this ).button( "widget" )[ 0 ];
  1029. })
  1030. .removeClass( "ui-state-active" )
  1031. .attr( "aria-pressed", "false" );
  1032. });
  1033. } else {
  1034. this.buttonElement
  1035. .bind( "mousedown" + this.eventNamespace, function() {
  1036. if ( options.disabled ) {
  1037. return false;
  1038. }
  1039. $( this ).addClass( "ui-state-active" );
  1040. lastActive = this;
  1041. that.document.one( "mouseup", function() {
  1042. lastActive = null;
  1043. });
  1044. })
  1045. .bind( "mouseup" + this.eventNamespace, function() {
  1046. if ( options.disabled ) {
  1047. return false;
  1048. }
  1049. $( this ).removeClass( "ui-state-active" );
  1050. })
  1051. .bind( "keydown" + this.eventNamespace, function(event) {
  1052. if ( options.disabled ) {
  1053. return false;
  1054. }
  1055. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  1056. $( this ).addClass( "ui-state-active" );
  1057. }
  1058. })
  1059. // see #8559, we bind to blur here in case the button element loses
  1060. // focus between keydown and keyup, it would be left in an "active" state
  1061. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  1062. $( this ).removeClass( "ui-state-active" );
  1063. });
  1064. if ( this.buttonElement.is("a") ) {
  1065. this.buttonElement.keyup(function(event) {
  1066. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  1067. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  1068. $( this ).click();
  1069. }
  1070. });
  1071. }
  1072. }
  1073. this._setOption( "disabled", options.disabled );
  1074. this._resetButton();
  1075. },
  1076. _determineButtonType: function() {
  1077. var ancestor, labelSelector, checked;
  1078. if ( this.element.is("[type=checkbox]") ) {
  1079. this.type = "checkbox";
  1080. } else if ( this.element.is("[type=radio]") ) {
  1081. this.type = "radio";
  1082. } else if ( this.element.is("input") ) {
  1083. this.type = "input";
  1084. } else {
  1085. this.type = "button";
  1086. }
  1087. if ( this.type === "checkbox" || this.type === "radio" ) {
  1088. // we don't search against the document in case the element
  1089. // is disconnected from the DOM
  1090. ancestor = this.element.parents().last();
  1091. labelSelector = "label[for='" + this.element.attr("id") + "']";
  1092. this.buttonElement = ancestor.find( labelSelector );
  1093. if ( !this.buttonElement.length ) {
  1094. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  1095. this.buttonElement = ancestor.filter( labelSelector );
  1096. if ( !this.buttonElement.length ) {
  1097. this.buttonElement = ancestor.find( labelSelector );
  1098. }
  1099. }
  1100. this.element.addClass( "ui-helper-hidden-accessible" );
  1101. checked = this.element.is( ":checked" );
  1102. if ( checked ) {
  1103. this.buttonElement.addClass( "ui-state-active" );
  1104. }
  1105. this.buttonElement.prop( "aria-pressed", checked );
  1106. } else {
  1107. this.buttonElement = this.element;
  1108. }
  1109. },
  1110. widget: function() {
  1111. return this.buttonElement;
  1112. },
  1113. _destroy: function() {
  1114. this.element
  1115. .removeClass( "ui-helper-hidden-accessible" );
  1116. this.buttonElement
  1117. .removeClass( baseClasses + " ui-state-active " + typeClasses )
  1118. .removeAttr( "role" )
  1119. .removeAttr( "aria-pressed" )
  1120. .html( this.buttonElement.find(".ui-button-text").html() );
  1121. if ( !this.hasTitle ) {
  1122. this.buttonElement.removeAttr( "title" );
  1123. }
  1124. },
  1125. _setOption: function( key, value ) {
  1126. this._super( key, value );
  1127. if ( key === "disabled" ) {
  1128. this.widget().toggleClass( "ui-state-disabled", !!value );
  1129. this.element.prop( "disabled", !!value );
  1130. if ( value ) {
  1131. if ( this.type === "checkbox" || this.type === "radio" ) {
  1132. this.buttonElement.removeClass( "ui-state-focus" );
  1133. } else {
  1134. this.buttonElement.removeClass( "ui-state-focus ui-state-active" );
  1135. }
  1136. }
  1137. return;
  1138. }
  1139. this._resetButton();
  1140. },
  1141. refresh: function() {
  1142. //See #8237 & #8828
  1143. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  1144. if ( isDisabled !== this.options.disabled ) {
  1145. this._setOption( "disabled", isDisabled );
  1146. }
  1147. if ( this.type === "radio" ) {
  1148. radioGroup( this.element[0] ).each(function() {
  1149. if ( $( this ).is( ":checked" ) ) {
  1150. $( this ).button( "widget" )
  1151. .addClass( "ui-state-active" )
  1152. .attr( "aria-pressed", "true" );
  1153. } else {
  1154. $( this ).button( "widget" )
  1155. .removeClass( "ui-state-active" )
  1156. .attr( "aria-pressed", "false" );
  1157. }
  1158. });
  1159. } else if ( this.type === "checkbox" ) {
  1160. if ( this.element.is( ":checked" ) ) {
  1161. this.buttonElement
  1162. .addClass( "ui-state-active" )
  1163. .attr( "aria-pressed", "true" );
  1164. } else {
  1165. this.buttonElement
  1166. .removeClass( "ui-state-active" )
  1167. .attr( "aria-pressed", "false" );
  1168. }
  1169. }
  1170. },
  1171. _resetButton: function() {
  1172. if ( this.type === "input" ) {
  1173. if ( this.options.label ) {
  1174. this.element.val( this.options.label );
  1175. }
  1176. return;
  1177. }
  1178. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  1179. buttonText = $( "<span></span>", this.document[0] )
  1180. .addClass( "ui-button-text" )
  1181. .html( this.options.label )
  1182. .appendTo( buttonElement.empty() )
  1183. .text(),
  1184. icons = this.options.icons,
  1185. multipleIcons = icons.primary && icons.secondary,
  1186. buttonClasses = [];
  1187. if ( icons.primary || icons.secondary ) {
  1188. if ( this.options.text ) {
  1189. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  1190. }
  1191. if ( icons.primary ) {
  1192. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  1193. }
  1194. if ( icons.secondary ) {
  1195. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  1196. }
  1197. if ( !this.options.text ) {
  1198. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  1199. if ( !this.hasTitle ) {
  1200. buttonElement.attr( "title", $.trim( buttonText ) );
  1201. }
  1202. }
  1203. } else {
  1204. buttonClasses.push( "ui-button-text-only" );
  1205. }
  1206. buttonElement.addClass( buttonClasses.join( " " ) );
  1207. }
  1208. });
  1209. $.widget( "ui.buttonset", {
  1210. version: "1.11.2",
  1211. options: {
  1212. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  1213. },
  1214. _create: function() {
  1215. this.element.addClass( "ui-buttonset" );
  1216. },
  1217. _init: function() {
  1218. this.refresh();
  1219. },
  1220. _setOption: function( key, value ) {
  1221. if ( key === "disabled" ) {
  1222. this.buttons.button( "option", key, value );
  1223. }
  1224. this._super( key, value );
  1225. },
  1226. refresh: function() {
  1227. var rtl = this.element.css( "direction" ) === "rtl",
  1228. allButtons = this.element.find( this.options.items ),
  1229. existingButtons = allButtons.filter( ":ui-button" );
  1230. // Initialize new buttons
  1231. allButtons.not( ":ui-button" ).button();
  1232. // Refresh existing buttons
  1233. existingButtons.button( "refresh" );
  1234. this.buttons = allButtons
  1235. .map(function() {
  1236. return $( this ).button( "widget" )[ 0 ];
  1237. })
  1238. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  1239. .filter( ":first" )
  1240. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  1241. .end()
  1242. .filter( ":last" )
  1243. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  1244. .end()
  1245. .end();
  1246. },
  1247. _destroy: function() {
  1248. this.element.removeClass( "ui-buttonset" );
  1249. this.buttons
  1250. .map(function() {
  1251. return $( this ).button( "widget" )[ 0 ];
  1252. })
  1253. .removeClass( "ui-corner-left ui-corner-right" )
  1254. .end()
  1255. .button( "destroy" );
  1256. }
  1257. });
  1258. var button = $.ui.button;
  1259. /*!
  1260. * jQuery UI Slider 1.11.2
  1261. * http://jqueryui.com
  1262. *
  1263. * Copyright 2014 jQuery Foundation and other contributors
  1264. * Released under the MIT license.
  1265. * http://jquery.org/license
  1266. *
  1267. * http://api.jqueryui.com/slider/
  1268. */
  1269. var slider = $.widget( "ui.slider", $.ui.mouse, {
  1270. version: "1.11.2",
  1271. widgetEventPrefix: "slide",
  1272. options: {
  1273. animate: false,
  1274. distance: 0,
  1275. max: 100,
  1276. min: 0,
  1277. orientation: "horizontal",
  1278. range: false,
  1279. step: 1,
  1280. value: 0,
  1281. values: null,
  1282. // callbacks
  1283. change: null,
  1284. slide: null,
  1285. start: null,
  1286. stop: null
  1287. },
  1288. // number of pages in a slider
  1289. // (how many times can you page up/down to go through the whole range)
  1290. numPages: 5,
  1291. _create: function() {
  1292. this._keySliding = false;
  1293. this._mouseSliding = false;
  1294. this._animateOff = true;
  1295. this._handleIndex = null;
  1296. this._detectOrientation();
  1297. this._mouseInit();
  1298. this._calculateNewMax();
  1299. this.element
  1300. .addClass( "ui-slider" +
  1301. " ui-slider-" + this.orientation +
  1302. " ui-widget" +
  1303. " ui-widget-content" +
  1304. " ui-corner-all");
  1305. this._refresh();
  1306. this._setOption( "disabled", this.options.disabled );
  1307. this._animateOff = false;
  1308. },
  1309. _refresh: function() {
  1310. this._createRange();
  1311. this._createHandles();
  1312. this._setupEvents();
  1313. this._refreshValue();
  1314. },
  1315. _createHandles: function() {
  1316. var i, handleCount,
  1317. options = this.options,
  1318. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  1319. handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>",
  1320. handles = [];
  1321. handleCount = ( options.values && options.values.length ) || 1;
  1322. if ( existingHandles.length > handleCount ) {
  1323. existingHandles.slice( handleCount ).remove();
  1324. existingHandles = existingHandles.slice( 0, handleCount );
  1325. }
  1326. for ( i = existingHandles.length; i < handleCount; i++ ) {
  1327. handles.push( handle );
  1328. }
  1329. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  1330. this.handle = this.handles.eq( 0 );
  1331. this.handles.each(function( i ) {
  1332. $( this ).data( "ui-slider-handle-index", i );
  1333. });
  1334. },
  1335. _createRange: function() {
  1336. var options = this.options,
  1337. classes = "";
  1338. if ( options.range ) {
  1339. if ( options.range === true ) {
  1340. if ( !options.values ) {
  1341. options.values = [ this._valueMin(), this._valueMin() ];
  1342. } else if ( options.values.length && options.values.length !== 2 ) {
  1343. options.values = [ options.values[0], options.values[0] ];
  1344. } else if ( $.isArray( options.values ) ) {
  1345. options.values = options.values.slice(0);
  1346. }
  1347. }
  1348. if ( !this.range || !this.range.length ) {
  1349. this.range = $( "<div></div>" )
  1350. .appendTo( this.element );
  1351. classes = "ui-slider-range" +
  1352. // note: this isn't the most fittingly semantic framework class for this element,
  1353. // but worked best visually with a variety of themes
  1354. " ui-widget-header ui-corner-all";
  1355. } else {
  1356. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  1357. // Handle range switching from true to min/max
  1358. .css({
  1359. "left": "",
  1360. "bottom": ""
  1361. });
  1362. }
  1363. this.range.addClass( classes +
  1364. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  1365. } else {
  1366. if ( this.range ) {
  1367. this.range.remove();
  1368. }
  1369. this.range = null;
  1370. }
  1371. },
  1372. _setupEvents: function() {
  1373. this._off( this.handles );
  1374. this._on( this.handles, this._handleEvents );
  1375. this._hoverable( this.handles );
  1376. this._focusable( this.handles );
  1377. },
  1378. _destroy: function() {
  1379. this.handles.remove();
  1380. if ( this.range ) {
  1381. this.range.remove();
  1382. }
  1383. this.element
  1384. .removeClass( "ui-slider" +
  1385. " ui-slider-horizontal" +
  1386. " ui-slider-vertical" +
  1387. " ui-widget" +
  1388. " ui-widget-content" +
  1389. " ui-corner-all" );
  1390. this._mouseDestroy();
  1391. },
  1392. _mouseCapture: function( event ) {
  1393. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  1394. that = this,
  1395. o = this.options;
  1396. if ( o.disabled ) {
  1397. return false;
  1398. }
  1399. this.elementSize = {
  1400. width: this.element.outerWidth(),
  1401. height: this.element.outerHeight()
  1402. };
  1403. this.elementOffset = this.element.offset();
  1404. position = { x: event.pageX, y: event.pageY };
  1405. normValue = this._normValueFromMouse( position );
  1406. distance = this._valueMax() - this._valueMin() + 1;
  1407. this.handles.each(function( i ) {
  1408. var thisDistance = Math.abs( normValue - that.values(i) );
  1409. if (( distance > thisDistance ) ||
  1410. ( distance === thisDistance &&
  1411. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  1412. distance = thisDistance;
  1413. closestHandle = $( this );
  1414. index = i;
  1415. }
  1416. });
  1417. allowed = this._start( event, index );
  1418. if ( allowed === false ) {
  1419. return false;
  1420. }
  1421. this._mouseSliding = true;
  1422. this._handleIndex = index;
  1423. closestHandle
  1424. .addClass( "ui-state-active" )
  1425. .focus();
  1426. offset = closestHandle.offset();
  1427. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  1428. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  1429. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  1430. top: event.pageY - offset.top -
  1431. ( closestHandle.height() / 2 ) -
  1432. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  1433. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  1434. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  1435. };
  1436. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  1437. this._slide( event, index, normValue );
  1438. }
  1439. this._animateOff = true;
  1440. return true;
  1441. },
  1442. _mouseStart: function() {
  1443. return true;
  1444. },
  1445. _mouseDrag: function( event ) {
  1446. var position = { x: event.pageX, y: event.pageY },
  1447. normValue = this._normValueFromMouse( position );
  1448. this._slide( event, this._handleIndex, normValue );
  1449. return false;
  1450. },
  1451. _mouseStop: function( event ) {
  1452. this.handles.removeClass( "ui-state-active" );
  1453. this._mouseSliding = false;
  1454. this._stop( event, this._handleIndex );
  1455. this._change( event, this._handleIndex );
  1456. this._handleIndex = null;
  1457. this._clickOffset = null;
  1458. this._animateOff = false;
  1459. return false;
  1460. },
  1461. _detectOrientation: function() {
  1462. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  1463. },
  1464. _normValueFromMouse: function( position ) {
  1465. var pixelTotal,
  1466. pixelMouse,
  1467. percentMouse,
  1468. valueTotal,
  1469. valueMouse;
  1470. if ( this.orientation === "horizontal" ) {
  1471. pixelTotal = this.elementSize.width;
  1472. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  1473. } else {
  1474. pixelTotal = this.elementSize.height;
  1475. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  1476. }
  1477. percentMouse = ( pixelMouse / pixelTotal );
  1478. if ( percentMouse > 1 ) {
  1479. percentMouse = 1;
  1480. }
  1481. if ( percentMouse < 0 ) {
  1482. percentMouse = 0;
  1483. }
  1484. if ( this.orientation === "vertical" ) {
  1485. percentMouse = 1 - percentMouse;
  1486. }
  1487. valueTotal = this._valueMax() - this._valueMin();
  1488. valueMouse = this._valueMin() + percentMouse * valueTotal;
  1489. return this._trimAlignValue( valueMouse );
  1490. },
  1491. _start: function( event, index ) {
  1492. var uiHash = {
  1493. handle: this.handles[ index ],
  1494. value: this.value()
  1495. };
  1496. if ( this.options.values && this.options.values.length ) {
  1497. uiHash.value = this.values( index );
  1498. uiHash.values = this.values();
  1499. }
  1500. return this._trigger( "start", event, uiHash );
  1501. },
  1502. _slide: function( event, index, newVal ) {
  1503. var otherVal,
  1504. newValues,
  1505. allowed;
  1506. if ( this.options.values && this.options.values.length ) {
  1507. otherVal = this.values( index ? 0 : 1 );
  1508. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  1509. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  1510. ) {
  1511. newVal = otherVal;
  1512. }
  1513. if ( newVal !== this.values( index ) ) {
  1514. newValues = this.values();
  1515. newValues[ index ] = newVal;
  1516. // A slide can be canceled by returning false from the slide callback
  1517. allowed = this._trigger( "slide", event, {
  1518. handle: this.handles[ index ],
  1519. value: newVal,
  1520. values: newValues
  1521. } );
  1522. otherVal = this.values( index ? 0 : 1 );
  1523. if ( allowed !== false ) {
  1524. this.values( index, newVal );
  1525. }
  1526. }
  1527. } else {
  1528. if ( newVal !== this.value() ) {
  1529. // A slide can be canceled by returning false from the slide callback
  1530. allowed = this._trigger( "slide", event, {
  1531. handle: this.handles[ index ],
  1532. value: newVal
  1533. } );
  1534. if ( allowed !== false ) {
  1535. this.value( newVal );
  1536. }
  1537. }
  1538. }
  1539. },
  1540. _stop: function( event, index ) {
  1541. var uiHash = {
  1542. handle: this.handles[ index ],
  1543. value: this.value()
  1544. };
  1545. if ( this.options.values && this.options.values.length ) {
  1546. uiHash.value = this.values( index );
  1547. uiHash.values = this.values();
  1548. }
  1549. this._trigger( "stop", event, uiHash );
  1550. },
  1551. _change: function( event, index ) {
  1552. if ( !this._keySliding && !this._mouseSliding ) {
  1553. var uiHash = {
  1554. handle: this.handles[ index ],
  1555. value: this.value()
  1556. };
  1557. if ( this.options.values && this.options.values.length ) {
  1558. uiHash.value = this.values( index );
  1559. uiHash.values = this.values();
  1560. }
  1561. //store the last changed value index for reference when handles overlap
  1562. this._lastChangedValue = index;
  1563. this._trigger( "change", event, uiHash );
  1564. }
  1565. },
  1566. value: function( newValue ) {
  1567. if ( arguments.length ) {
  1568. this.options.value = this._trimAlignValue( newValue );
  1569. this._refreshValue();
  1570. this._change( null, 0 );
  1571. return;
  1572. }
  1573. return this._value();
  1574. },
  1575. values: function( index, newValue ) {
  1576. var vals,
  1577. newValues,
  1578. i;
  1579. if ( arguments.length > 1 ) {
  1580. this.options.values[ index ] = this._trimAlignValue( newValue );
  1581. this._refreshValue();
  1582. this._change( null, index );
  1583. return;
  1584. }
  1585. if ( arguments.length ) {
  1586. if ( $.isArray( arguments[ 0 ] ) ) {
  1587. vals = this.options.values;
  1588. newValues = arguments[ 0 ];
  1589. for ( i = 0; i < vals.length; i += 1 ) {
  1590. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  1591. this._change( null, i );
  1592. }
  1593. this._refreshValue();
  1594. } else {
  1595. if ( this.options.values && this.options.values.length ) {
  1596. return this._values( index );
  1597. } else {
  1598. return this.value();
  1599. }
  1600. }
  1601. } else {
  1602. return this._values();
  1603. }
  1604. },
  1605. _setOption: function( key, value ) {
  1606. var i,
  1607. valsLength = 0;
  1608. if ( key === "range" && this.options.range === true ) {
  1609. if ( value === "min" ) {
  1610. this.options.value = this._values( 0 );
  1611. this.options.values = null;
  1612. } else if ( value === "max" ) {
  1613. this.options.value = this._values( this.options.values.length - 1 );
  1614. this.options.values = null;
  1615. }
  1616. }
  1617. if ( $.isArray( this.options.values ) ) {
  1618. valsLength = this.options.values.length;
  1619. }
  1620. if ( key === "disabled" ) {
  1621. this.element.toggleClass( "ui-state-disabled", !!value );
  1622. }
  1623. this._super( key, value );
  1624. switch ( key ) {
  1625. case "orientation":
  1626. this._detectOrientation();
  1627. this.element
  1628. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  1629. .addClass( "ui-slider-" + this.orientation );
  1630. this._refreshValue();
  1631. // Reset positioning from previous orientation
  1632. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  1633. break;
  1634. case "value":
  1635. this._animateOff = true;
  1636. this._refreshValue();
  1637. this._change( null, 0 );
  1638. this._animateOff = false;
  1639. break;
  1640. case "values":
  1641. this._animateOff = true;
  1642. this._refreshValue();
  1643. for ( i = 0; i < valsLength; i += 1 ) {
  1644. this._change( null, i );
  1645. }
  1646. this._animateOff = false;
  1647. break;
  1648. case "step":
  1649. case "min":
  1650. case "max":
  1651. this._animateOff = true;
  1652. this._calculateNewMax();
  1653. this._refreshValue();
  1654. this._animateOff = false;
  1655. break;
  1656. case "range":
  1657. this._animateOff = true;
  1658. this._refresh();
  1659. this._animateOff = false;
  1660. break;
  1661. }
  1662. },
  1663. //internal value getter
  1664. // _value() returns value trimmed by min and max, aligned by step
  1665. _value: function() {
  1666. var val = this.options.value;
  1667. val = this._trimAlignValue( val );
  1668. return val;
  1669. },
  1670. //internal values getter
  1671. // _values() returns array of values trimmed by min and max, aligned by step
  1672. // _values( index ) returns single value trimmed by min and max, aligned by step
  1673. _values: function( index ) {
  1674. var val,
  1675. vals,
  1676. i;
  1677. if ( arguments.length ) {
  1678. val = this.options.values[ index ];
  1679. val = this._trimAlignValue( val );
  1680. return val;
  1681. } else if ( this.options.values && this.options.values.length ) {
  1682. // .slice() creates a copy of the array
  1683. // this copy gets trimmed by min and max and then returned
  1684. vals = this.options.values.slice();
  1685. for ( i = 0; i < vals.length; i += 1) {
  1686. vals[ i ] = this._trimAlignValue( vals[ i ] );
  1687. }
  1688. return vals;
  1689. } else {
  1690. return [];
  1691. }
  1692. },
  1693. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  1694. _trimAlignValue: function( val ) {
  1695. if ( val <= this._valueMin() ) {
  1696. return this._valueMin();
  1697. }
  1698. if ( val >= this._valueMax() ) {
  1699. return this._valueMax();
  1700. }
  1701. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  1702. valModStep = (val - this._valueMin()) % step,
  1703. alignValue = val - valModStep;
  1704. if ( Math.abs(valModStep) * 2 >= step ) {
  1705. alignValue += ( valModStep > 0 ) ? step : ( -step );
  1706. }
  1707. // Since JavaScript has problems with large floats, round
  1708. // the final value to 5 digits after the decimal point (see #4124)
  1709. return parseFloat( alignValue.toFixed(5) );
  1710. },
  1711. _calculateNewMax: function() {
  1712. var remainder = ( this.options.max - this._valueMin() ) % this.options.step;
  1713. this.max = this.options.max - remainder;
  1714. },
  1715. _valueMin: function() {
  1716. return this.options.min;
  1717. },
  1718. _valueMax: function() {
  1719. return this.max;
  1720. },
  1721. _refreshValue: function() {
  1722. var lastValPercent, valPercent, value, valueMin, valueMax,
  1723. oRange = this.options.range,
  1724. o = this.options,
  1725. that = this,
  1726. animate = ( !this._animateOff ) ? o.animate : false,
  1727. _set = {};
  1728. if ( this.options.values && this.options.values.length ) {
  1729. this.handles.each(function( i ) {
  1730. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  1731. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  1732. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  1733. if ( that.options.range === true ) {
  1734. if ( that.orientation === "horizontal" ) {
  1735. if ( i === 0 ) {
  1736. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  1737. }
  1738. if ( i === 1 ) {
  1739. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  1740. }
  1741. } else {
  1742. if ( i === 0 ) {
  1743. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  1744. }
  1745. if ( i === 1 ) {
  1746. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  1747. }
  1748. }
  1749. }
  1750. lastValPercent = valPercent;
  1751. });
  1752. } else {
  1753. value = this.value();
  1754. valueMin = this._valueMin();
  1755. valueMax = this._valueMax();
  1756. valPercent = ( valueMax !== valueMin ) ?
  1757. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  1758. 0;
  1759. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  1760. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  1761. if ( oRange === "min" && this.orientation === "horizontal" ) {
  1762. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  1763. }
  1764. if ( oRange === "max" && this.orientation === "horizontal" ) {
  1765. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  1766. }
  1767. if ( oRange === "min" && this.orientation === "vertical" ) {
  1768. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  1769. }
  1770. if ( oRange === "max" && this.orientation === "vertical" ) {
  1771. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  1772. }
  1773. }
  1774. },
  1775. _handleEvents: {
  1776. keydown: function( event ) {
  1777. var allowed, curVal, newVal, step,
  1778. index = $( event.target ).data( "ui-slider-handle-index" );
  1779. switch ( event.keyCode ) {
  1780. case $.ui.keyCode.HOME:
  1781. case $.ui.keyCode.END:
  1782. case $.ui.keyCode.PAGE_UP:
  1783. case $.ui.keyCode.PAGE_DOWN:
  1784. case $.ui.keyCode.UP:
  1785. case $.ui.keyCode.RIGHT:
  1786. case $.ui.keyCode.DOWN:
  1787. case $.ui.keyCode.LEFT:
  1788. event.preventDefault();
  1789. if ( !this._keySliding ) {
  1790. this._keySliding = true;
  1791. $( event.target ).addClass( "ui-state-active" );
  1792. allowed = this._start( event, index );
  1793. if ( allowed === false ) {
  1794. return;
  1795. }
  1796. }
  1797. break;
  1798. }
  1799. step = this.options.step;
  1800. if ( this.options.values && this.options.values.length ) {
  1801. curVal = newVal = this.values( index );
  1802. } else {
  1803. curVal = newVal = this.value();
  1804. }
  1805. switch ( event.keyCode ) {
  1806. case $.ui.keyCode.HOME:
  1807. newVal = this._valueMin();
  1808. break;
  1809. case $.ui.keyCode.END:
  1810. newVal = this._valueMax();
  1811. break;
  1812. case $.ui.keyCode.PAGE_UP:
  1813. newVal = this._trimAlignValue(
  1814. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  1815. );
  1816. break;
  1817. case $.ui.keyCode.PAGE_DOWN:
  1818. newVal = this._trimAlignValue(
  1819. curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
  1820. break;
  1821. case $.ui.keyCode.UP:
  1822. case $.ui.keyCode.RIGHT:
  1823. if ( curVal === this._valueMax() ) {
  1824. return;
  1825. }
  1826. newVal = this._trimAlignValue( curVal + step );
  1827. break;
  1828. case $.ui.keyCode.DOWN:
  1829. case $.ui.keyCode.LEFT:
  1830. if ( curVal === this._valueMin() ) {
  1831. return;
  1832. }
  1833. newVal = this._trimAlignValue( curVal - step );
  1834. break;
  1835. }
  1836. this._slide( event, index, newVal );
  1837. },
  1838. keyup: function( event ) {
  1839. var index = $( event.target ).data( "ui-slider-handle-index" );
  1840. if ( this._keySliding ) {
  1841. this._keySliding = false;
  1842. this._stop( event, index );
  1843. this._change( event, index );
  1844. $( event.target ).removeClass( "ui-state-active" );
  1845. }
  1846. }
  1847. }
  1848. });
  1849. /*!
  1850. * jQuery UI Tabs 1.11.2
  1851. * http://jqueryui.com
  1852. *
  1853. * Copyright 2014 jQuery Foundation and other contributors
  1854. * Released under the MIT license.
  1855. * http://jquery.org/license
  1856. *
  1857. * http://api.jqueryui.com/tabs/
  1858. */
  1859. var tabs = $.widget( "ui.tabs", {
  1860. version: "1.11.2",
  1861. delay: 300,
  1862. options: {
  1863. active: null,
  1864. collapsible: false,
  1865. event: "click",
  1866. heightStyle: "content",
  1867. hide: null,
  1868. show: null,
  1869. // callbacks
  1870. activate: null,
  1871. beforeActivate: null,
  1872. beforeLoad: null,
  1873. load: null
  1874. },
  1875. _isLocal: (function() {
  1876. var rhash = /#.*$/;
  1877. return function( anchor ) {
  1878. var anchorUrl, locationUrl;
  1879. // support: IE7
  1880. // IE7 doesn't normalize the href property when set via script (#9317)
  1881. anchor = anchor.cloneNode( false );
  1882. anchorUrl = anchor.href.replace( rhash, "" );
  1883. locationUrl = location.href.replace( rhash, "" );
  1884. // decoding may throw an error if the URL isn't UTF-8 (#9518)
  1885. try {
  1886. anchorUrl = decodeURIComponent( anchorUrl );
  1887. } catch ( error ) {}
  1888. try {
  1889. locationUrl = decodeURIComponent( locationUrl );
  1890. } catch ( error ) {}
  1891. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  1892. };
  1893. })(),
  1894. _create: function() {
  1895. var that = this,
  1896. options = this.options;
  1897. this.running = false;
  1898. this.element
  1899. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  1900. .toggleClass( "ui-tabs-collapsible", options.collapsible );
  1901. this._processTabs();
  1902. options.active = this._initialActive();
  1903. // Take disabling tabs via class attribute from HTML
  1904. // into account and update option properly.
  1905. if ( $.isArray( options.disabled ) ) {
  1906. options.disabled = $.unique( options.disabled.concat(
  1907. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  1908. return that.tabs.index( li );
  1909. })
  1910. ) ).sort();
  1911. }
  1912. // check for length avoids error when initializing empty list
  1913. if ( this.options.active !== false && this.anchors.length ) {
  1914. this.active = this._findActive( options.active );
  1915. } else {
  1916. this.active = $();
  1917. }
  1918. this._refresh();
  1919. if ( this.active.length ) {
  1920. this.load( options.active );
  1921. }
  1922. },
  1923. _initialActive: function() {
  1924. var active = this.options.active,
  1925. collapsible = this.options.collapsible,
  1926. locationHash = location.hash.substring( 1 );
  1927. if ( active === null ) {
  1928. // check the fragment identifier in the URL
  1929. if ( locationHash ) {
  1930. this.tabs.each(function( i, tab ) {
  1931. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  1932. active = i;
  1933. return false;
  1934. }
  1935. });
  1936. }
  1937. // check for a tab marked active via a class
  1938. if ( active === null ) {
  1939. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  1940. }
  1941. // no active tab, set to false
  1942. if ( active === null || active === -1 ) {
  1943. active = this.tabs.length ? 0 : false;
  1944. }
  1945. }
  1946. // handle numbers: negative, out of range
  1947. if ( active !== false ) {
  1948. active = this.tabs.index( this.tabs.eq( active ) );
  1949. if ( active === -1 ) {
  1950. active = collapsible ? false : 0;
  1951. }
  1952. }
  1953. // don't allow collapsible: false and active: false
  1954. if ( !collapsible && active === false && this.anchors.length ) {
  1955. active = 0;
  1956. }
  1957. return active;
  1958. },
  1959. _getCreateEventData: function() {
  1960. return {
  1961. tab: this.active,
  1962. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  1963. };
  1964. },
  1965. _tabKeydown: function( event ) {
  1966. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  1967. selectedIndex = this.tabs.index( focusedTab ),
  1968. goingForward = true;
  1969. if ( this._handlePageNav( event ) ) {
  1970. return;
  1971. }
  1972. switch ( event.keyCode ) {
  1973. case $.ui.keyCode.RIGHT:
  1974. case $.ui.keyCode.DOWN:
  1975. selectedIndex++;
  1976. break;
  1977. case $.ui.keyCode.UP:
  1978. case $.ui.keyCode.LEFT:
  1979. goingForward = false;
  1980. selectedIndex--;
  1981. break;
  1982. case $.ui.keyCode.END:
  1983. selectedIndex = this.anchors.length - 1;
  1984. break;
  1985. case $.ui.keyCode.HOME:
  1986. selectedIndex = 0;
  1987. break;
  1988. case $.ui.keyCode.SPACE:
  1989. // Activate only, no collapsing
  1990. event.preventDefault();
  1991. clearTimeout( this.activating );
  1992. this._activate( selectedIndex );
  1993. return;
  1994. case $.ui.keyCode.ENTER:
  1995. // Toggle (cancel delayed activation, allow collapsing)
  1996. event.preventDefault();
  1997. clearTimeout( this.activating );
  1998. // Determine if we should collapse or activate
  1999. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  2000. return;
  2001. default:
  2002. return;
  2003. }
  2004. // Focus the appropriate tab, based on which key was pressed
  2005. event.preventDefault();
  2006. clearTimeout( this.activating );
  2007. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  2008. // Navigating with control key will prevent automatic activation
  2009. if ( !event.ctrlKey ) {
  2010. // Update aria-selected immediately so that AT think the tab is already selected.
  2011. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  2012. // but the tab will already be activated by the time the announcement finishes.
  2013. focusedTab.attr( "aria-selected", "false" );
  2014. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  2015. this.activating = this._delay(function() {
  2016. this.option( "active", selectedIndex );
  2017. }, this.delay );
  2018. }
  2019. },
  2020. _panelKeydown: function( event ) {
  2021. if ( this._handlePageNav( event ) ) {
  2022. return;
  2023. }
  2024. // Ctrl+up moves focus to the current tab
  2025. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  2026. event.preventDefault();
  2027. this.active.focus();
  2028. }
  2029. },
  2030. // Alt+page up/down moves focus to the previous/next tab (and activates)
  2031. _handlePageNav: function( event ) {
  2032. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  2033. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  2034. return true;
  2035. }
  2036. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  2037. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  2038. return true;
  2039. }
  2040. },
  2041. _findNextTab: function( index, goingForward ) {
  2042. var lastTabIndex = this.tabs.length - 1;
  2043. function constrain() {
  2044. if ( index > lastTabIndex ) {
  2045. index = 0;
  2046. }
  2047. if ( index < 0 ) {
  2048. index = lastTabIndex;
  2049. }
  2050. return index;
  2051. }
  2052. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  2053. index = goingForward ? index + 1 : index - 1;
  2054. }
  2055. return index;
  2056. },
  2057. _focusNextTab: function( index, goingForward ) {
  2058. index = this._findNextTab( index, goingForward );
  2059. this.tabs.eq( index ).focus();
  2060. return index;
  2061. },
  2062. _setOption: function( key, value ) {
  2063. if ( key === "active" ) {
  2064. // _activate() will handle invalid values and update this.options
  2065. this._activate( value );
  2066. return;
  2067. }
  2068. if ( key === "disabled" ) {
  2069. // don't use the widget factory's disabled handling
  2070. this._setupDisabled( value );
  2071. return;
  2072. }
  2073. this._super( key, value);
  2074. if ( key === "collapsible" ) {
  2075. this.element.toggleClass( "ui-tabs-collapsible", value );
  2076. // Setting collapsible: false while collapsed; open first panel
  2077. if ( !value && this.options.active === false ) {
  2078. this._activate( 0 );
  2079. }
  2080. }
  2081. if ( key === "event" ) {
  2082. this._setupEvents( value );
  2083. }
  2084. if ( key === "heightStyle" ) {
  2085. this._setupHeightStyle( value );
  2086. }
  2087. },
  2088. _sanitizeSelector: function( hash ) {
  2089. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  2090. },
  2091. refresh: function() {
  2092. var options = this.options,
  2093. lis = this.tablist.children( ":has(a[href])" );
  2094. // get disabled tabs from class attribute from HTML
  2095. // this will get converted to a boolean if needed in _refresh()
  2096. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  2097. return lis.index( tab );
  2098. });
  2099. this._processTabs();
  2100. // was collapsed or no tabs
  2101. if ( options.active === false || !this.anchors.length ) {
  2102. options.active = false;
  2103. this.active = $();
  2104. // was active, but active tab is gone
  2105. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  2106. // all remaining tabs are disabled
  2107. if ( this.tabs.length === options.disabled.length ) {
  2108. options.active = false;
  2109. this.active = $();
  2110. // activate previous tab
  2111. } else {
  2112. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  2113. }
  2114. // was active, active tab still exists
  2115. } else {
  2116. // make sure active index is correct
  2117. options.active = this.tabs.index( this.active );
  2118. }
  2119. this._refresh();
  2120. },
  2121. _refresh: function() {
  2122. this._setupDisabled( this.options.disabled );
  2123. this._setupEvents( this.options.event );
  2124. this._setupHeightStyle( this.options.heightStyle );
  2125. this.tabs.not( this.active ).attr({
  2126. "aria-selected": "false",
  2127. "aria-expanded": "false",
  2128. tabIndex: -1
  2129. });
  2130. this.panels.not( this._getPanelForTab( this.active ) )
  2131. .hide()
  2132. .attr({
  2133. "aria-hidden": "true"
  2134. });
  2135. // Make sure one tab is in the tab order
  2136. if ( !this.active.length ) {
  2137. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  2138. } else {
  2139. this.active
  2140. .addClass( "ui-tabs-active ui-state-active" )
  2141. .attr({
  2142. "aria-selected": "true",
  2143. "aria-expanded": "true",
  2144. tabIndex: 0
  2145. });
  2146. this._getPanelForTab( this.active )
  2147. .show()
  2148. .attr({
  2149. "aria-hidden": "false"
  2150. });
  2151. }
  2152. },
  2153. _processTabs: function() {
  2154. var that = this,
  2155. prevTabs = this.tabs,
  2156. prevAnchors = this.anchors,
  2157. prevPanels = this.panels;
  2158. this.tablist = this._getList()
  2159. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  2160. .attr( "role", "tablist" )
  2161. // Prevent users from focusing disabled tabs via click
  2162. .delegate( "> li", "mousedown" + this.eventNamespace, function( event ) {
  2163. if ( $( this ).is( ".ui-state-disabled" ) ) {
  2164. event.preventDefault();
  2165. }
  2166. })
  2167. // support: IE <9
  2168. // Preventing the default action in mousedown doesn't prevent IE
  2169. // from focusing the element, so if the anchor gets focused, blur.
  2170. // We don't have to worry about focusing the previously focused
  2171. // element since clicking on a non-focusable element should focus
  2172. // the body anyway.
  2173. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  2174. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  2175. this.blur();
  2176. }
  2177. });
  2178. this.tabs = this.tablist.find( "> li:has(a[href])" )
  2179. .addClass( "ui-state-default ui-corner-top" )
  2180. .attr({
  2181. role: "tab",
  2182. tabIndex: -1
  2183. });
  2184. this.anchors = this.tabs.map(function() {
  2185. return $( "a", this )[ 0 ];
  2186. })
  2187. .addClass( "ui-tabs-anchor" )
  2188. .attr({
  2189. role: "presentation",
  2190. tabIndex: -1
  2191. });
  2192. this.panels = $();
  2193. this.anchors.each(function( i, anchor ) {
  2194. var selector, panel, panelId,
  2195. anchorId = $( anchor ).uniqueId().attr( "id" ),
  2196. tab = $( anchor ).closest( "li" ),
  2197. originalAriaControls = tab.attr( "aria-controls" );
  2198. // inline tab
  2199. if ( that._isLocal( anchor ) ) {
  2200. selector = anchor.hash;
  2201. panelId = selector.substring( 1 );
  2202. panel = that.element.find( that._sanitizeSelector( selector ) );
  2203. // remote tab
  2204. } else {
  2205. // If the tab doesn't already have aria-controls,
  2206. // generate an id by using a throw-away element
  2207. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  2208. selector = "#" + panelId;
  2209. panel = that.element.find( selector );
  2210. if ( !panel.length ) {
  2211. panel = that._createPanel( panelId );
  2212. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  2213. }
  2214. panel.attr( "aria-live", "polite" );
  2215. }
  2216. if ( panel.length) {
  2217. that.panels = that.panels.add( panel );
  2218. }
  2219. if ( originalAriaControls ) {
  2220. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  2221. }
  2222. tab.attr({
  2223. "aria-controls": panelId,
  2224. "aria-labelledby": anchorId
  2225. });
  2226. panel.attr( "aria-labelledby", anchorId );
  2227. });
  2228. this.panels
  2229. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  2230. .attr( "role", "tabpanel" );
  2231. // Avoid memory leaks (#10056)
  2232. if ( prevTabs ) {
  2233. this._off( prevTabs.not( this.tabs ) );
  2234. this._off( prevAnchors.not( this.anchors ) );
  2235. this._off( prevPanels.not( this.panels ) );
  2236. }
  2237. },
  2238. // allow overriding how to find the list for rare usage scenarios (#7715)
  2239. _getList: function() {
  2240. return this.tablist || this.element.find( "ol,ul" ).eq( 0 );
  2241. },
  2242. _createPanel: function( id ) {
  2243. return $( "<div>" )
  2244. .attr( "id", id )
  2245. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  2246. .data( "ui-tabs-destroy", true );
  2247. },
  2248. _setupDisabled: function( disabled ) {
  2249. if ( $.isArray( disabled ) ) {
  2250. if ( !disabled.length ) {
  2251. disabled = false;
  2252. } else if ( disabled.length === this.anchors.length ) {
  2253. disabled = true;
  2254. }
  2255. }
  2256. // disable tabs
  2257. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  2258. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  2259. $( li )
  2260. .addClass( "ui-state-disabled" )
  2261. .attr( "aria-disabled", "true" );
  2262. } else {
  2263. $( li )
  2264. .removeClass( "ui-state-disabled" )
  2265. .removeAttr( "aria-disabled" );
  2266. }
  2267. }
  2268. this.options.disabled = disabled;
  2269. },
  2270. _setupEvents: function( event ) {
  2271. var events = {};
  2272. if ( event ) {
  2273. $.each( event.split(" "), function( index, eventName ) {
  2274. events[ eventName ] = "_eventHandler";
  2275. });
  2276. }
  2277. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  2278. // Always prevent the default action, even when disabled
  2279. this._on( true, this.anchors, {
  2280. click: function( event ) {
  2281. event.preventDefault();
  2282. }
  2283. });
  2284. this._on( this.anchors, events );
  2285. this._on( this.tabs, { keydown: "_tabKeydown" } );
  2286. this._on( this.panels, { keydown: "_panelKeydown" } );
  2287. this._focusable( this.tabs );
  2288. this._hoverable( this.tabs );
  2289. },
  2290. _setupHeightStyle: function( heightStyle ) {
  2291. var maxHeight,
  2292. parent = this.element.parent();
  2293. if ( heightStyle === "fill" ) {
  2294. maxHeight = parent.height();
  2295. maxHeight -= this.element.outerHeight() - this.element.height();
  2296. this.element.siblings( ":visible" ).each(function() {
  2297. var elem = $( this ),
  2298. position = elem.css( "position" );
  2299. if ( position === "absolute" || position === "fixed" ) {
  2300. return;
  2301. }
  2302. maxHeight -= elem.outerHeight( true );
  2303. });
  2304. this.element.children().not( this.panels ).each(function() {
  2305. maxHeight -= $( this ).outerHeight( true );
  2306. });
  2307. this.panels.each(function() {
  2308. $( this ).height( Math.max( 0, maxHeight -
  2309. $( this ).innerHeight() + $( this ).height() ) );
  2310. })
  2311. .css( "overflow", "auto" );
  2312. } else if ( heightStyle === "auto" ) {
  2313. maxHeight = 0;
  2314. this.panels.each(function() {
  2315. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  2316. }).height( maxHeight );
  2317. }
  2318. },
  2319. _eventHandler: function( event ) {
  2320. var options = this.options,
  2321. active = this.active,
  2322. anchor = $( event.currentTarget ),
  2323. tab = anchor.closest( "li" ),
  2324. clickedIsActive = tab[ 0 ] === active[ 0 ],
  2325. collapsing = clickedIsActive && options.collapsible,
  2326. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  2327. toHide = !active.length ? $() : this._getPanelForTab( active ),
  2328. eventData = {
  2329. oldTab: active,
  2330. oldPanel: toHide,
  2331. newTab: collapsing ? $() : tab,
  2332. newPanel: toShow
  2333. };
  2334. event.preventDefault();
  2335. if ( tab.hasClass( "ui-state-disabled" ) ||
  2336. // tab is already loading
  2337. tab.hasClass( "ui-tabs-loading" ) ||
  2338. // can't switch durning an animation
  2339. this.running ||
  2340. // click on active header, but not collapsible
  2341. ( clickedIsActive && !options.collapsible ) ||
  2342. // allow canceling activation
  2343. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  2344. return;
  2345. }
  2346. options.active = collapsing ? false : this.tabs.index( tab );
  2347. this.active = clickedIsActive ? $() : tab;
  2348. if ( this.xhr ) {
  2349. this.xhr.abort();
  2350. }
  2351. if ( !toHide.length && !toShow.length ) {
  2352. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  2353. }
  2354. if ( toShow.length ) {
  2355. this.load( this.tabs.index( tab ), event );
  2356. }
  2357. this._toggle( event, eventData );
  2358. },
  2359. // handles show/hide for selecting tabs
  2360. _toggle: function( event, eventData ) {
  2361. var that = this,
  2362. toShow = eventData.newPanel,
  2363. toHide = eventData.oldPanel;
  2364. this.running = true;
  2365. function complete() {
  2366. that.running = false;
  2367. that._trigger( "activate", event, eventData );
  2368. }
  2369. function show() {
  2370. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  2371. if ( toShow.length && that.options.show ) {
  2372. that._show( toShow, that.options.show, complete );
  2373. } else {
  2374. toShow.show();
  2375. complete();
  2376. }
  2377. }
  2378. // start out by hiding, then showing, then completing
  2379. if ( toHide.length && this.options.hide ) {
  2380. this._hide( toHide, this.options.hide, function() {
  2381. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  2382. show();
  2383. });
  2384. } else {
  2385. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  2386. toHide.hide();
  2387. show();
  2388. }
  2389. toHide.attr( "aria-hidden", "true" );
  2390. eventData.oldTab.attr({
  2391. "aria-selected": "false",
  2392. "aria-expanded": "false"
  2393. });
  2394. // If we're switching tabs, remove the old tab from the tab order.
  2395. // If we're opening from collapsed state, remove the previous tab from the tab order.
  2396. // If we're collapsing, then keep the collapsing tab in the tab order.
  2397. if ( toShow.length && toHide.length ) {
  2398. eventData.oldTab.attr( "tabIndex", -1 );
  2399. } else if ( toShow.length ) {
  2400. this.tabs.filter(function() {
  2401. return $( this ).attr( "tabIndex" ) === 0;
  2402. })
  2403. .attr( "tabIndex", -1 );
  2404. }
  2405. toShow.attr( "aria-hidden", "false" );
  2406. eventData.newTab.attr({
  2407. "aria-selected": "true",
  2408. "aria-expanded": "true",
  2409. tabIndex: 0
  2410. });
  2411. },
  2412. _activate: function( index ) {
  2413. var anchor,
  2414. active = this._findActive( index );
  2415. // trying to activate the already active panel
  2416. if ( active[ 0 ] === this.active[ 0 ] ) {
  2417. return;
  2418. }
  2419. // trying to collapse, simulate a click on the current active header
  2420. if ( !active.length ) {
  2421. active = this.active;
  2422. }
  2423. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  2424. this._eventHandler({
  2425. target: anchor,
  2426. currentTarget: anchor,
  2427. preventDefault: $.noop
  2428. });
  2429. },
  2430. _findActive: function( index ) {
  2431. return index === false ? $() : this.tabs.eq( index );
  2432. },
  2433. _getIndex: function( index ) {
  2434. // meta-function to give users option to provide a href string instead of a numerical index.
  2435. if ( typeof index === "string" ) {
  2436. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  2437. }
  2438. return index;
  2439. },
  2440. _destroy: function() {
  2441. if ( this.xhr ) {
  2442. this.xhr.abort();
  2443. }
  2444. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  2445. this.tablist
  2446. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  2447. .removeAttr( "role" );
  2448. this.anchors
  2449. .removeClass( "ui-tabs-anchor" )
  2450. .removeAttr( "role" )
  2451. .removeAttr( "tabIndex" )
  2452. .removeUniqueId();
  2453. this.tablist.unbind( this.eventNamespace );
  2454. this.tabs.add( this.panels ).each(function() {
  2455. if ( $.data( this, "ui-tabs-destroy" ) ) {
  2456. $( this ).remove();
  2457. } else {
  2458. $( this )
  2459. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  2460. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  2461. .removeAttr( "tabIndex" )
  2462. .removeAttr( "aria-live" )
  2463. .removeAttr( "aria-busy" )
  2464. .removeAttr( "aria-selected" )
  2465. .removeAttr( "aria-labelledby" )
  2466. .removeAttr( "aria-hidden" )
  2467. .removeAttr( "aria-expanded" )
  2468. .removeAttr( "role" );
  2469. }
  2470. });
  2471. this.tabs.each(function() {
  2472. var li = $( this ),
  2473. prev = li.data( "ui-tabs-aria-controls" );
  2474. if ( prev ) {
  2475. li
  2476. .attr( "aria-controls", prev )
  2477. .removeData( "ui-tabs-aria-controls" );
  2478. } else {
  2479. li.removeAttr( "aria-controls" );
  2480. }
  2481. });
  2482. this.panels.show();
  2483. if ( this.options.heightStyle !== "content" ) {
  2484. this.panels.css( "height", "" );
  2485. }
  2486. },
  2487. enable: function( index ) {
  2488. var disabled = this.options.disabled;
  2489. if ( disabled === false ) {
  2490. return;
  2491. }
  2492. if ( index === undefined ) {
  2493. disabled = false;
  2494. } else {
  2495. index = this._getIndex( index );
  2496. if ( $.isArray( disabled ) ) {
  2497. disabled = $.map( disabled, function( num ) {
  2498. return num !== index ? num : null;
  2499. });
  2500. } else {
  2501. disabled = $.map( this.tabs, function( li, num ) {
  2502. return num !== index ? num : null;
  2503. });
  2504. }
  2505. }
  2506. this._setupDisabled( disabled );
  2507. },
  2508. disable: function( index ) {
  2509. var disabled = this.options.disabled;
  2510. if ( disabled === true ) {
  2511. return;
  2512. }
  2513. if ( index === undefined ) {
  2514. disabled = true;
  2515. } else {
  2516. index = this._getIndex( index );
  2517. if ( $.inArray( index, disabled ) !== -1 ) {
  2518. return;
  2519. }
  2520. if ( $.isArray( disabled ) ) {
  2521. disabled = $.merge( [ index ], disabled ).sort();
  2522. } else {
  2523. disabled = [ index ];
  2524. }
  2525. }
  2526. this._setupDisabled( disabled );
  2527. },
  2528. load: function( index, event ) {
  2529. index = this._getIndex( index );
  2530. var that = this,
  2531. tab = this.tabs.eq( index ),
  2532. anchor = tab.find( ".ui-tabs-anchor" ),
  2533. panel = this._getPanelForTab( tab ),
  2534. eventData = {
  2535. tab: tab,
  2536. panel: panel
  2537. };
  2538. // not remote
  2539. if ( this._isLocal( anchor[ 0 ] ) ) {
  2540. return;
  2541. }
  2542. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  2543. // support: jQuery <1.8
  2544. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  2545. // but as of 1.8, $.ajax() always returns a jqXHR object.
  2546. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  2547. tab.addClass( "ui-tabs-loading" );
  2548. panel.attr( "aria-busy", "true" );
  2549. this.xhr
  2550. .success(function( response ) {
  2551. // support: jQuery <1.8
  2552. // http://bugs.jquery.com/ticket/11778
  2553. setTimeout(function() {
  2554. panel.html( response );
  2555. that._trigger( "load", event, eventData );
  2556. }, 1 );
  2557. })
  2558. .complete(function( jqXHR, status ) {
  2559. // support: jQuery <1.8
  2560. // http://bugs.jquery.com/ticket/11778
  2561. setTimeout(function() {
  2562. if ( status === "abort" ) {
  2563. that.panels.stop( false, true );
  2564. }
  2565. tab.removeClass( "ui-tabs-loading" );
  2566. panel.removeAttr( "aria-busy" );
  2567. if ( jqXHR === that.xhr ) {
  2568. delete that.xhr;
  2569. }
  2570. }, 1 );
  2571. });
  2572. }
  2573. },
  2574. _ajaxSettings: function( anchor, event, eventData ) {
  2575. var that = this;
  2576. return {
  2577. url: anchor.attr( "href" ),
  2578. beforeSend: function( jqXHR, settings ) {
  2579. return that._trigger( "beforeLoad", event,
  2580. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  2581. }
  2582. };
  2583. },
  2584. _getPanelForTab: function( tab ) {
  2585. var id = $( tab ).attr( "aria-controls" );
  2586. return this.element.find( this._sanitizeSelector( "#" + id ) );
  2587. }
  2588. });
  2589. }));