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

yui-base-debug.js 148KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901
  1. /*
  2. Copyright (c) 2010, Yahoo! Inc. All rights reserved.
  3. Code licensed under the BSD License:
  4. http://developer.yahoo.com/yui/license.html
  5. version: 3.4.0
  6. build: nightly
  7. */
  8. /**
  9. * The YUI module contains the components required for building the YUI seed
  10. * file. This includes the script loading mechanism, a simple queue, and
  11. * the core utilities for the library.
  12. * @module yui
  13. * @submodule yui-base
  14. */
  15. if (typeof YUI != 'undefined') {
  16. YUI._YUI = YUI;
  17. }
  18. /**
  19. The YUI global namespace object. If YUI is already defined, the
  20. existing YUI object will not be overwritten so that defined
  21. namespaces are preserved. It is the constructor for the object
  22. the end user interacts with. As indicated below, each instance
  23. has full custom event support, but only if the event system
  24. is available. This is a self-instantiable factory function. You
  25. can invoke it directly like this:
  26. YUI().use('*', function(Y) {
  27. // ready
  28. });
  29. But it also works like this:
  30. var Y = YUI();
  31. @class YUI
  32. @constructor
  33. @global
  34. @uses EventTarget
  35. @param o* {Object} 0..n optional configuration objects. these values
  36. are store in Y.config. See <a href="config.html">Config</a> for the list of supported
  37. properties.
  38. */
  39. /*global YUI*/
  40. /*global YUI_config*/
  41. var YUI = function() {
  42. var i = 0,
  43. Y = this,
  44. args = arguments,
  45. l = args.length,
  46. instanceOf = function(o, type) {
  47. return (o && o.hasOwnProperty && (o instanceof type));
  48. },
  49. gconf = (typeof YUI_config !== 'undefined') && YUI_config;
  50. if (!(instanceOf(Y, YUI))) {
  51. Y = new YUI();
  52. } else {
  53. // set up the core environment
  54. Y._init();
  55. /**
  56. YUI.GlobalConfig is a master configuration that might span
  57. multiple contexts in a non-browser environment. It is applied
  58. first to all instances in all contexts.
  59. @property GlobalConfig
  60. @type {Object}
  61. @global
  62. @static
  63. @example
  64. YUI.GlobalConfig = {
  65. filter: 'debug'
  66. };
  67. YUI().use('node', function(Y) {
  68. //debug files used here
  69. });
  70. YUI({
  71. filter: 'min'
  72. }).use('node', function(Y) {
  73. //min files used here
  74. });
  75. */
  76. if (YUI.GlobalConfig) {
  77. Y.applyConfig(YUI.GlobalConfig);
  78. }
  79. /**
  80. YUI_config is a page-level config. It is applied to all
  81. instances created on the page. This is applied after
  82. YUI.GlobalConfig, and before the instance level configuration
  83. objects.
  84. @global
  85. @property YUI_config
  86. @type {Object}
  87. @example
  88. //Single global var to include before YUI seed file
  89. YUI_config = {
  90. filter: 'debug'
  91. };
  92. YUI().use('node', function(Y) {
  93. //debug files used here
  94. });
  95. YUI({
  96. filter: 'min'
  97. }).use('node', function(Y) {
  98. //min files used here
  99. });
  100. */
  101. if (gconf) {
  102. Y.applyConfig(gconf);
  103. }
  104. // bind the specified additional modules for this instance
  105. if (!l) {
  106. Y._setup();
  107. }
  108. }
  109. if (l) {
  110. // Each instance can accept one or more configuration objects.
  111. // These are applied after YUI.GlobalConfig and YUI_Config,
  112. // overriding values set in those config files if there is a '
  113. // matching property.
  114. for (; i < l; i++) {
  115. Y.applyConfig(args[i]);
  116. }
  117. Y._setup();
  118. }
  119. Y.instanceOf = instanceOf;
  120. return Y;
  121. };
  122. (function() {
  123. var proto, prop,
  124. VERSION = '3.4.0',
  125. PERIOD = '.',
  126. BASE = 'http://yui.yahooapis.com/',
  127. DOC_LABEL = 'yui3-js-enabled',
  128. NOOP = function() {},
  129. SLICE = Array.prototype.slice,
  130. APPLY_TO_AUTH = { 'io.xdrReady': 1, // the functions applyTo
  131. 'io.xdrResponse': 1, // can call. this should
  132. 'SWF.eventHandler': 1 }, // be done at build time
  133. hasWin = (typeof window != 'undefined'),
  134. win = (hasWin) ? window : null,
  135. doc = (hasWin) ? win.document : null,
  136. docEl = doc && doc.documentElement,
  137. docClass = docEl && docEl.className,
  138. instances = {},
  139. time = new Date().getTime(),
  140. add = function(el, type, fn, capture) {
  141. if (el && el.addEventListener) {
  142. el.addEventListener(type, fn, capture);
  143. } else if (el && el.attachEvent) {
  144. el.attachEvent('on' + type, fn);
  145. }
  146. },
  147. remove = function(el, type, fn, capture) {
  148. if (el && el.removeEventListener) {
  149. // this can throw an uncaught exception in FF
  150. try {
  151. el.removeEventListener(type, fn, capture);
  152. } catch (ex) {}
  153. } else if (el && el.detachEvent) {
  154. el.detachEvent('on' + type, fn);
  155. }
  156. },
  157. handleLoad = function() {
  158. YUI.Env.windowLoaded = true;
  159. YUI.Env.DOMReady = true;
  160. if (hasWin) {
  161. remove(window, 'load', handleLoad);
  162. }
  163. },
  164. getLoader = function(Y, o) {
  165. var loader = Y.Env._loader;
  166. if (loader) {
  167. //loader._config(Y.config);
  168. loader.ignoreRegistered = false;
  169. loader.onEnd = null;
  170. loader.data = null;
  171. loader.required = [];
  172. loader.loadType = null;
  173. } else {
  174. loader = new Y.Loader(Y.config);
  175. Y.Env._loader = loader;
  176. }
  177. YUI.Env.core = Y.Array.dedupe([].concat(YUI.Env.core, [ 'loader-base', 'loader-rollup', 'loader-yui3' ]));
  178. return loader;
  179. },
  180. clobber = function(r, s) {
  181. for (var i in s) {
  182. if (s.hasOwnProperty(i)) {
  183. r[i] = s[i];
  184. }
  185. }
  186. },
  187. ALREADY_DONE = { success: true };
  188. // Stamp the documentElement (HTML) with a class of "yui-loaded" to
  189. // enable styles that need to key off of JS being enabled.
  190. if (docEl && docClass.indexOf(DOC_LABEL) == -1) {
  191. if (docClass) {
  192. docClass += ' ';
  193. }
  194. docClass += DOC_LABEL;
  195. docEl.className = docClass;
  196. }
  197. if (VERSION.indexOf('@') > -1) {
  198. VERSION = '3.3.0'; // dev time hack for cdn test
  199. }
  200. proto = {
  201. /**
  202. * Applies a new configuration object to the YUI instance config.
  203. * This will merge new group/module definitions, and will also
  204. * update the loader cache if necessary. Updating Y.config directly
  205. * will not update the cache.
  206. * @method applyConfig
  207. * @param {Object} o the configuration object.
  208. * @since 3.2.0
  209. */
  210. applyConfig: function(o) {
  211. o = o || NOOP;
  212. var attr,
  213. name,
  214. // detail,
  215. config = this.config,
  216. mods = config.modules,
  217. groups = config.groups,
  218. rls = config.rls,
  219. loader = this.Env._loader;
  220. for (name in o) {
  221. if (o.hasOwnProperty(name)) {
  222. attr = o[name];
  223. if (mods && name == 'modules') {
  224. clobber(mods, attr);
  225. } else if (groups && name == 'groups') {
  226. clobber(groups, attr);
  227. } else if (rls && name == 'rls') {
  228. clobber(rls, attr);
  229. } else if (name == 'win') {
  230. config[name] = attr.contentWindow || attr;
  231. config.doc = config[name].document;
  232. } else if (name == '_yuid') {
  233. // preserve the guid
  234. } else {
  235. config[name] = attr;
  236. }
  237. }
  238. }
  239. if (loader) {
  240. loader._config(o);
  241. }
  242. },
  243. /**
  244. * Old way to apply a config to the instance (calls `applyConfig` under the hood)
  245. * @private
  246. * @method _config
  247. * @param {Object} o The config to apply
  248. */
  249. _config: function(o) {
  250. this.applyConfig(o);
  251. },
  252. /**
  253. * Initialize this YUI instance
  254. * @private
  255. * @method _init
  256. */
  257. _init: function() {
  258. var filter,
  259. Y = this,
  260. G_ENV = YUI.Env,
  261. Env = Y.Env,
  262. prop;
  263. /**
  264. * The version number of the YUI instance.
  265. * @property version
  266. * @type string
  267. */
  268. Y.version = VERSION;
  269. if (!Env) {
  270. Y.Env = {
  271. core: ['get','features','intl-base','yui-log','yui-later'],
  272. mods: {}, // flat module map
  273. versions: {}, // version module map
  274. base: BASE,
  275. cdn: BASE + VERSION + '/build/',
  276. // bootstrapped: false,
  277. _idx: 0,
  278. _used: {},
  279. _attached: {},
  280. _missed: [],
  281. _yidx: 0,
  282. _uidx: 0,
  283. _guidp: 'y',
  284. _loaded: {},
  285. // serviced: {},
  286. // Regex in English:
  287. // I'll start at the \b(simpleyui).
  288. // 1. Look in the test string for "simpleyui" or "yui" or
  289. // "yui-base" or "yui-rls" or "yui-foobar" that comes after a word break. That is, it
  290. // can't match "foyui" or "i_heart_simpleyui". This can be anywhere in the string.
  291. // 2. After #1 must come a forward slash followed by the string matched in #1, so
  292. // "yui-base/yui-base" or "simpleyui/simpleyui" or "yui-pants/yui-pants".
  293. // 3. The second occurence of the #1 token can optionally be followed by "-debug" or "-min",
  294. // so "yui/yui-min", "yui/yui-debug", "yui-base/yui-base-debug". NOT "yui/yui-tshirt".
  295. // 4. This is followed by ".js", so "yui/yui.js", "simpleyui/simpleyui-min.js"
  296. // 0. Going back to the beginning, now. If all that stuff in 1-4 comes after a "?" in the string,
  297. // then capture the junk between the LAST "&" and the string in 1-4. So
  298. // "blah?foo/yui/yui.js" will capture "foo/" and "blah?some/thing.js&3.3.0/build/yui-rls/yui-rls.js"
  299. // will capture "3.3.0/build/"
  300. //
  301. // Regex Exploded:
  302. // (?:\? Find a ?
  303. // (?:[^&]*&) followed by 0..n characters followed by an &
  304. // * in fact, find as many sets of characters followed by a & as you can
  305. // ([^&]*) capture the stuff after the last & in \1
  306. // )? but it's ok if all this ?junk&more_junk stuff isn't even there
  307. // \b(simpleyui| after a word break find either the string "simpleyui" or
  308. // yui(?:-\w+)? the string "yui" optionally followed by a -, then more characters
  309. // ) and store the simpleyui or yui-* string in \2
  310. // \/\2 then comes a / followed by the simpleyui or yui-* string in \2
  311. // (?:-(min|debug))? optionally followed by "-min" or "-debug"
  312. // .js and ending in ".js"
  313. _BASE_RE: /(?:\?(?:[^&]*&)*([^&]*))?\b(simpleyui|yui(?:-\w+)?)\/\2(?:-(min|debug))?\.js/,
  314. parseBasePath: function(src, pattern) {
  315. var match = src.match(pattern),
  316. path, filter;
  317. if (match) {
  318. path = RegExp.leftContext || src.slice(0, src.indexOf(match[0]));
  319. // this is to set up the path to the loader. The file
  320. // filter for loader should match the yui include.
  321. filter = match[3];
  322. // extract correct path for mixed combo urls
  323. // http://yuilibrary.com/projects/yui3/ticket/2528423
  324. if (match[1]) {
  325. path += '?' + match[1];
  326. }
  327. path = {
  328. filter: filter,
  329. path: path
  330. }
  331. }
  332. return path;
  333. },
  334. getBase: G_ENV && G_ENV.getBase ||
  335. function(pattern) {
  336. var nodes = (doc && doc.getElementsByTagName('script')) || [],
  337. path = Env.cdn, parsed,
  338. i, len, src;
  339. for (i = 0, len = nodes.length; i < len; ++i) {
  340. src = nodes[i].src;
  341. if (src) {
  342. parsed = Y.Env.parseBasePath(src, pattern);
  343. if (parsed) {
  344. filter = parsed.filter;
  345. path = parsed.path;
  346. break;
  347. }
  348. }
  349. }
  350. // use CDN default
  351. return path;
  352. }
  353. };
  354. Env = Y.Env;
  355. Env._loaded[VERSION] = {};
  356. if (G_ENV && Y !== YUI) {
  357. Env._yidx = ++G_ENV._yidx;
  358. Env._guidp = ('yui_' + VERSION + '_' +
  359. Env._yidx + '_' + time).replace(/\./g, '_');
  360. } else if (YUI._YUI) {
  361. G_ENV = YUI._YUI.Env;
  362. Env._yidx += G_ENV._yidx;
  363. Env._uidx += G_ENV._uidx;
  364. for (prop in G_ENV) {
  365. if (!(prop in Env)) {
  366. Env[prop] = G_ENV[prop];
  367. }
  368. }
  369. delete YUI._YUI;
  370. }
  371. Y.id = Y.stamp(Y);
  372. instances[Y.id] = Y;
  373. }
  374. Y.constructor = YUI;
  375. // configuration defaults
  376. Y.config = Y.config || {
  377. win: win,
  378. doc: doc,
  379. debug: true,
  380. useBrowserConsole: true,
  381. throwFail: true,
  382. bootstrap: true,
  383. cacheUse: true,
  384. fetchCSS: true,
  385. use_rls: false,
  386. rls_timeout: 2000
  387. };
  388. if (YUI.Env.rls_disabled) {
  389. Y.config.use_rls = false;
  390. }
  391. Y.config.lang = Y.config.lang || 'en-US';
  392. Y.config.base = YUI.config.base || Y.Env.getBase(Y.Env._BASE_RE);
  393. if (!filter || (!('mindebug').indexOf(filter))) {
  394. filter = 'min';
  395. }
  396. filter = (filter) ? '-' + filter : filter;
  397. Y.config.loaderPath = YUI.config.loaderPath || 'loader/loader' + filter + '.js';
  398. },
  399. /**
  400. * Finishes the instance setup. Attaches whatever modules were defined
  401. * when the yui modules was registered.
  402. * @method _setup
  403. * @private
  404. */
  405. _setup: function(o) {
  406. var i, Y = this,
  407. core = [],
  408. mods = YUI.Env.mods,
  409. //extras = Y.config.core || ['get','features','intl-base','yui-log','yui-later'];
  410. extras = Y.config.core || [].concat(YUI.Env.core); //Clone it..
  411. for (i = 0; i < extras.length; i++) {
  412. if (mods[extras[i]]) {
  413. core.push(extras[i]);
  414. }
  415. }
  416. Y._attach(['yui-base']);
  417. Y._attach(core);
  418. if (Y.Loader) {
  419. getLoader(Y);
  420. }
  421. // Y.log(Y.id + ' initialized', 'info', 'yui');
  422. },
  423. /**
  424. * Executes a method on a YUI instance with
  425. * the specified id if the specified method is whitelisted.
  426. * @method applyTo
  427. * @param id {String} the YUI instance id.
  428. * @param method {String} the name of the method to exectute.
  429. * Ex: 'Object.keys'.
  430. * @param args {Array} the arguments to apply to the method.
  431. * @return {Object} the return value from the applied method or null.
  432. */
  433. applyTo: function(id, method, args) {
  434. if (!(method in APPLY_TO_AUTH)) {
  435. this.log(method + ': applyTo not allowed', 'warn', 'yui');
  436. return null;
  437. }
  438. var instance = instances[id], nest, m, i;
  439. if (instance) {
  440. nest = method.split('.');
  441. m = instance;
  442. for (i = 0; i < nest.length; i = i + 1) {
  443. m = m[nest[i]];
  444. if (!m) {
  445. this.log('applyTo not found: ' + method, 'warn', 'yui');
  446. }
  447. }
  448. return m.apply(instance, args);
  449. }
  450. return null;
  451. },
  452. /**
  453. Registers a module with the YUI global. The easiest way to create a
  454. first-class YUI module is to use the YUI component build tool.
  455. http://yuilibrary.com/projects/builder
  456. The build system will produce the `YUI.add` wrapper for you module, along
  457. with any configuration info required for the module.
  458. @method add
  459. @param name {String} module name.
  460. @param fn {Function} entry point into the module that is used to bind module to the YUI instance.
  461. @param {YUI} fn.Y The YUI instance this module is executed in.
  462. @param {String} fn.name The name of the module
  463. @param version {String} version string.
  464. @param details {Object} optional config data:
  465. @param details.requires {Array} features that must be present before this module can be attached.
  466. @param details.optional {Array} optional features that should be present if loadOptional
  467. is defined. Note: modules are not often loaded this way in YUI 3,
  468. but this field is still useful to inform the user that certain
  469. features in the component will require additional dependencies.
  470. @param details.use {Array} features that are included within this module which need to
  471. be attached automatically when this module is attached. This
  472. supports the YUI 3 rollup system -- a module with submodules
  473. defined will need to have the submodules listed in the 'use'
  474. config. The YUI component build tool does this for you.
  475. @return {YUI} the YUI instance.
  476. @example
  477. YUI.add('davglass', function(Y, name) {
  478. Y.davglass = function() {
  479. alert('Dav was here!');
  480. };
  481. }, '3.4.0', { requires: ['yui-base', 'harley-davidson', 'mt-dew'] });
  482. */
  483. add: function(name, fn, version, details) {
  484. details = details || {};
  485. var env = YUI.Env,
  486. mod = {
  487. name: name,
  488. fn: fn,
  489. version: version,
  490. details: details
  491. },
  492. loader,
  493. i, versions = env.versions;
  494. env.mods[name] = mod;
  495. versions[version] = versions[version] || {};
  496. versions[version][name] = mod;
  497. for (i in instances) {
  498. if (instances.hasOwnProperty(i)) {
  499. loader = instances[i].Env._loader;
  500. if (loader) {
  501. if (!loader.moduleInfo[name]) {
  502. loader.addModule(details, name);
  503. }
  504. }
  505. }
  506. }
  507. return this;
  508. },
  509. /**
  510. * Executes the function associated with each required
  511. * module, binding the module to the YUI instance.
  512. * @param {Array} r The array of modules to attach
  513. * @param {Boolean} [moot=false] Don't throw a warning if the module is not attached
  514. * @method _attach
  515. * @private
  516. */
  517. _attach: function(r, moot) {
  518. var i, name, mod, details, req, use, after,
  519. mods = YUI.Env.mods,
  520. aliases = YUI.Env.aliases,
  521. Y = this, j,
  522. loader = Y.Env._loader,
  523. done = Y.Env._attached,
  524. len = r.length, loader,
  525. c = [];
  526. //Check for conditional modules (in a second+ instance) and add their requirements
  527. //TODO I hate this entire method, it needs to be fixed ASAP (3.5.0) ^davglass
  528. for (i = 0; i < len; i++) {
  529. name = r[i];
  530. mod = mods[name];
  531. c.push(name);
  532. if (loader && loader.conditions[name]) {
  533. Y.Object.each(loader.conditions[name], function(def) {
  534. var go = def && ((def.ua && Y.UA[def.ua]) || (def.test && def.test(Y)));
  535. if (go) {
  536. c.push(def.name);
  537. }
  538. });
  539. }
  540. }
  541. r = c;
  542. len = r.length;
  543. for (i = 0; i < len; i++) {
  544. if (!done[r[i]]) {
  545. name = r[i];
  546. mod = mods[name];
  547. if (aliases && aliases[name]) {
  548. Y._attach(aliases[name]);
  549. continue;
  550. }
  551. if (!mod) {
  552. if (loader && loader.moduleInfo[name]) {
  553. mod = loader.moduleInfo[name];
  554. moot = true;
  555. }
  556. // Y.log('no js def for: ' + name, 'info', 'yui');
  557. //if (!loader || !loader.moduleInfo[name]) {
  558. //if ((!loader || !loader.moduleInfo[name]) && !moot) {
  559. if (!moot) {
  560. if ((name.indexOf('skin-') === -1) && (name.indexOf('css') === -1)) {
  561. Y.Env._missed.push(name);
  562. Y.Env._missed = Y.Array.dedupe(Y.Env._missed);
  563. Y.message('NOT loaded: ' + name, 'warn', 'yui');
  564. }
  565. }
  566. } else {
  567. done[name] = true;
  568. //Don't like this, but in case a mod was asked for once, then we fetch it
  569. //We need to remove it from the missed list ^davglass
  570. for (j = 0; j < Y.Env._missed.length; j++) {
  571. if (Y.Env._missed[j] === name) {
  572. Y.message('Found: ' + name + ' (was reported as missing earlier)', 'warn', 'yui');
  573. Y.Env._missed.splice(j, 1);
  574. }
  575. }
  576. details = mod.details;
  577. req = details.requires;
  578. use = details.use;
  579. after = details.after;
  580. if (req) {
  581. for (j = 0; j < req.length; j++) {
  582. if (!done[req[j]]) {
  583. if (!Y._attach(req)) {
  584. return false;
  585. }
  586. break;
  587. }
  588. }
  589. }
  590. if (after) {
  591. for (j = 0; j < after.length; j++) {
  592. if (!done[after[j]]) {
  593. if (!Y._attach(after, true)) {
  594. return false;
  595. }
  596. break;
  597. }
  598. }
  599. }
  600. if (mod.fn) {
  601. try {
  602. mod.fn(Y, name);
  603. } catch (e) {
  604. Y.error('Attach error: ' + name, e, name);
  605. return false;
  606. }
  607. }
  608. if (use) {
  609. for (j = 0; j < use.length; j++) {
  610. if (!done[use[j]]) {
  611. if (!Y._attach(use)) {
  612. return false;
  613. }
  614. break;
  615. }
  616. }
  617. }
  618. }
  619. }
  620. }
  621. return true;
  622. },
  623. /**
  624. * Attaches one or more modules to the YUI instance. When this
  625. * is executed, the requirements are analyzed, and one of
  626. * several things can happen:
  627. *
  628. * * All requirements are available on the page -- The modules
  629. * are attached to the instance. If supplied, the use callback
  630. * is executed synchronously.
  631. *
  632. * * Modules are missing, the Get utility is not available OR
  633. * the 'bootstrap' config is false -- A warning is issued about
  634. * the missing modules and all available modules are attached.
  635. *
  636. * * Modules are missing, the Loader is not available but the Get
  637. * utility is and boostrap is not false -- The loader is bootstrapped
  638. * before doing the following....
  639. *
  640. * * Modules are missing and the Loader is available -- The loader
  641. * expands the dependency tree and fetches missing modules. When
  642. * the loader is finshed the callback supplied to use is executed
  643. * asynchronously.
  644. *
  645. * @method use
  646. * @param modules* {String} 1-n modules to bind (uses arguments array).
  647. * @param *callback {Function} callback function executed when
  648. * the instance has the required functionality. If included, it
  649. * must be the last parameter.
  650. *
  651. * @example
  652. * // loads and attaches dd and its dependencies
  653. * YUI().use('dd', function(Y) {});
  654. *
  655. * // loads and attaches dd and node as well as all of their dependencies (since 3.4.0)
  656. * YUI().use(['dd', 'node'], function(Y) {});
  657. *
  658. * // attaches all modules that are available on the page
  659. * YUI().use('*', function(Y) {});
  660. *
  661. * // intrinsic YUI gallery support (since 3.1.0)
  662. * YUI().use('gallery-yql', function(Y) {});
  663. *
  664. * // intrinsic YUI 2in3 support (since 3.1.0)
  665. * YUI().use('yui2-datatable', function(Y) {});
  666. *
  667. * @return {YUI} the YUI instance.
  668. */
  669. use: function() {
  670. var args = SLICE.call(arguments, 0),
  671. callback = args[args.length - 1],
  672. Y = this,
  673. i = 0,
  674. name,
  675. Env = Y.Env,
  676. provisioned = true;
  677. // The last argument supplied to use can be a load complete callback
  678. if (Y.Lang.isFunction(callback)) {
  679. args.pop();
  680. } else {
  681. callback = null;
  682. }
  683. if (Y.Lang.isArray(args[0])) {
  684. args = args[0];
  685. }
  686. if (Y.config.cacheUse) {
  687. while ((name = args[i++])) {
  688. if (!Env._attached[name]) {
  689. provisioned = false;
  690. break;
  691. }
  692. }
  693. if (provisioned) {
  694. if (args.length) {
  695. Y.log('already provisioned: ' + args, 'info', 'yui');
  696. }
  697. Y._notify(callback, ALREADY_DONE, args);
  698. return Y;
  699. }
  700. }
  701. if (Y._loading) {
  702. Y._useQueue = Y._useQueue || new Y.Queue();
  703. Y._useQueue.add([args, callback]);
  704. } else {
  705. Y._use(args, function(Y, response) {
  706. Y._notify(callback, response, args);
  707. });
  708. }
  709. return Y;
  710. },
  711. /**
  712. * Notify handler from Loader for attachment/load errors
  713. * @method _notify
  714. * @param callback {Function} The callback to pass to the `Y.config.loadErrorFn`
  715. * @param response {Object} The response returned from Loader
  716. * @param args {Array} The aruments passed from Loader
  717. * @private
  718. */
  719. _notify: function(callback, response, args) {
  720. if (!response.success && this.config.loadErrorFn) {
  721. this.config.loadErrorFn.call(this, this, callback, response, args);
  722. } else if (callback) {
  723. try {
  724. callback(this, response);
  725. } catch (e) {
  726. this.error('use callback error', e, args);
  727. }
  728. }
  729. },
  730. /**
  731. * This private method is called from the `use` method queue. To ensure that only one set of loading
  732. * logic is performed at a time.
  733. * @method _use
  734. * @private
  735. * @param args* {String} 1-n modules to bind (uses arguments array).
  736. * @param *callback {Function} callback function executed when
  737. * the instance has the required functionality. If included, it
  738. * must be the last parameter.
  739. */
  740. _use: function(args, callback) {
  741. if (!this.Array) {
  742. this._attach(['yui-base']);
  743. }
  744. var len, loader, handleBoot, handleRLS,
  745. Y = this,
  746. G_ENV = YUI.Env,
  747. mods = G_ENV.mods,
  748. Env = Y.Env,
  749. used = Env._used,
  750. queue = G_ENV._loaderQueue,
  751. firstArg = args[0],
  752. YArray = Y.Array,
  753. config = Y.config,
  754. boot = config.bootstrap,
  755. missing = [],
  756. r = [],
  757. ret = true,
  758. fetchCSS = config.fetchCSS,
  759. process = function(names, skip) {
  760. if (!names.length) {
  761. return;
  762. }
  763. YArray.each(names, function(name) {
  764. // add this module to full list of things to attach
  765. if (!skip) {
  766. r.push(name);
  767. }
  768. // only attach a module once
  769. if (used[name]) {
  770. return;
  771. }
  772. var m = mods[name], req, use;
  773. if (m) {
  774. used[name] = true;
  775. req = m.details.requires;
  776. use = m.details.use;
  777. } else {
  778. // CSS files don't register themselves, see if it has
  779. // been loaded
  780. if (!G_ENV._loaded[VERSION][name]) {
  781. missing.push(name);
  782. } else {
  783. used[name] = true; // probably css
  784. }
  785. }
  786. // make sure requirements are attached
  787. if (req && req.length) {
  788. process(req);
  789. }
  790. // make sure we grab the submodule dependencies too
  791. if (use && use.length) {
  792. process(use, 1);
  793. }
  794. });
  795. },
  796. handleLoader = function(fromLoader) {
  797. var response = fromLoader || {
  798. success: true,
  799. msg: 'not dynamic'
  800. },
  801. redo, origMissing,
  802. ret = true,
  803. data = response.data;
  804. Y._loading = false;
  805. if (data) {
  806. origMissing = missing;
  807. missing = [];
  808. r = [];
  809. process(data);
  810. redo = missing.length;
  811. if (redo) {
  812. if (missing.sort().join() ==
  813. origMissing.sort().join()) {
  814. redo = false;
  815. }
  816. }
  817. }
  818. if (redo && data) {
  819. Y._loading = false;
  820. Y._use(args, function() {
  821. Y.log('Nested use callback: ' + data, 'info', 'yui');
  822. if (Y._attach(data)) {
  823. Y._notify(callback, response, data);
  824. }
  825. });
  826. } else {
  827. if (data) {
  828. // Y.log('attaching from loader: ' + data, 'info', 'yui');
  829. ret = Y._attach(data);
  830. }
  831. if (ret) {
  832. Y._notify(callback, response, args);
  833. }
  834. }
  835. if (Y._useQueue && Y._useQueue.size() && !Y._loading) {
  836. Y._use.apply(Y, Y._useQueue.next());
  837. }
  838. };
  839. // Y.log(Y.id + ': use called: ' + a + ' :: ' + callback, 'info', 'yui');
  840. // YUI().use('*'); // bind everything available
  841. if (firstArg === '*') {
  842. ret = Y._attach(Y.Object.keys(mods));
  843. if (ret) {
  844. handleLoader();
  845. }
  846. return Y;
  847. }
  848. // Y.log('before loader requirements: ' + args, 'info', 'yui');
  849. // use loader to expand dependencies and sort the
  850. // requirements if it is available.
  851. if (boot && Y.Loader && args.length) {
  852. loader = getLoader(Y);
  853. loader.require(args);
  854. loader.ignoreRegistered = true;
  855. loader.calculate(null, (fetchCSS) ? null : 'js');
  856. args = loader.sorted;
  857. }
  858. // process each requirement and any additional requirements
  859. // the module metadata specifies
  860. process(args);
  861. len = missing.length;
  862. if (len) {
  863. missing = Y.Object.keys(YArray.hash(missing));
  864. len = missing.length;
  865. Y.log('Modules missing: ' + missing + ', ' + missing.length, 'info', 'yui');
  866. }
  867. // dynamic load
  868. if (boot && len && Y.Loader) {
  869. // Y.log('Using loader to fetch missing deps: ' + missing, 'info', 'yui');
  870. Y.log('Using Loader', 'info', 'yui');
  871. Y._loading = true;
  872. loader = getLoader(Y);
  873. loader.onEnd = handleLoader;
  874. loader.context = Y;
  875. loader.data = args;
  876. loader.ignoreRegistered = false;
  877. loader.require(args);
  878. loader.insert(null, (fetchCSS) ? null : 'js');
  879. // loader.partial(missing, (fetchCSS) ? null : 'js');
  880. } else if (len && Y.config.use_rls && !YUI.Env.rls_enabled) {
  881. G_ENV._rls_queue = G_ENV._rls_queue || new Y.Queue();
  882. // server side loader service
  883. handleRLS = function(instance, argz) {
  884. var rls_end = function(o) {
  885. handleLoader(o);
  886. instance.rls_advance();
  887. },
  888. rls_url = instance._rls(argz);
  889. if (rls_url) {
  890. Y.log('Fetching RLS url', 'info', 'rls');
  891. instance.rls_oncomplete(function(o) {
  892. rls_end(o);
  893. });
  894. instance.Get.script(rls_url, {
  895. data: argz,
  896. timeout: instance.config.rls_timeout,
  897. onFailure: instance.rls_handleFailure,
  898. onTimeout: instance.rls_handleTimeout
  899. });
  900. } else {
  901. rls_end({
  902. success: true,
  903. data: argz
  904. });
  905. }
  906. };
  907. G_ENV._rls_queue.add(function() {
  908. Y.log('executing queued rls request', 'info', 'rls');
  909. G_ENV._rls_in_progress = true;
  910. Y.rls_callback = callback;
  911. Y.rls_locals(Y, args, handleRLS);
  912. });
  913. if (!G_ENV._rls_in_progress && G_ENV._rls_queue.size()) {
  914. G_ENV._rls_queue.next()();
  915. }
  916. } else if (boot && len && Y.Get && !Env.bootstrapped) {
  917. Y._loading = true;
  918. handleBoot = function() {
  919. Y._loading = false;
  920. queue.running = false;
  921. Env.bootstrapped = true;
  922. G_ENV._bootstrapping = false;
  923. if (Y._attach(['loader'])) {
  924. Y._use(args, callback);
  925. }
  926. };
  927. if (G_ENV._bootstrapping) {
  928. Y.log('Waiting for loader', 'info', 'yui');
  929. queue.add(handleBoot);
  930. } else {
  931. G_ENV._bootstrapping = true;
  932. Y.log('Fetching loader: ' + config.base + config.loaderPath, 'info', 'yui');
  933. Y.Get.script(config.base + config.loaderPath, {
  934. onEnd: handleBoot
  935. });
  936. }
  937. } else {
  938. Y.log('Attaching available dependencies: ' + args, 'info', 'yui');
  939. ret = Y._attach(args);
  940. if (ret) {
  941. handleLoader();
  942. }
  943. }
  944. return Y;
  945. },
  946. /**
  947. Adds a namespace object onto the YUI global if called statically.
  948. // creates YUI.your.namespace.here as nested objects
  949. YUI.namespace("your.namespace.here");
  950. If called as a method on a YUI <em>instance</em>, it creates the
  951. namespace on the instance.
  952. // creates Y.property.package
  953. Y.namespace("property.package");
  954. Dots in the input string cause `namespace` to create nested objects for
  955. each token. If any part of the requested namespace already exists, the
  956. current object will be left in place. This allows multiple calls to
  957. `namespace` to preserve existing namespaced properties.
  958. If the first token in the namespace string is "YAHOO", the token is
  959. discarded.
  960. Be careful with namespace tokens. Reserved words may work in some browsers
  961. and not others. For instance, the following will fail in some browsers
  962. because the supported version of JavaScript reserves the word "long":
  963. Y.namespace("really.long.nested.namespace");
  964. @method namespace
  965. @param {String} namespace* namespaces to create.
  966. @return {Object} A reference to the last namespace object created.
  967. **/
  968. namespace: function() {
  969. var a = arguments, o = this, i = 0, j, d, arg;
  970. for (; i < a.length; i++) {
  971. // d = ('' + a[i]).split('.');
  972. arg = a[i];
  973. if (arg.indexOf(PERIOD)) {
  974. d = arg.split(PERIOD);
  975. for (j = (d[0] == 'YAHOO') ? 1 : 0; j < d.length; j++) {
  976. o[d[j]] = o[d[j]] || {};
  977. o = o[d[j]];
  978. }
  979. } else {
  980. o[arg] = o[arg] || {};
  981. }
  982. }
  983. return o;
  984. },
  985. // this is replaced if the log module is included
  986. log: NOOP,
  987. message: NOOP,
  988. // this is replaced if the dump module is included
  989. dump: function (o) { return ''+o; },
  990. /**
  991. * Report an error. The reporting mechanism is controled by
  992. * the `throwFail` configuration attribute. If throwFail is
  993. * not specified, the message is written to the Logger, otherwise
  994. * a JS error is thrown
  995. * @method error
  996. * @param msg {String} the error message.
  997. * @param e {Error|String} Optional JS error that was caught, or an error string.
  998. * @param data Optional additional info
  999. * and `throwFail` is specified, this error will be re-thrown.
  1000. * @return {YUI} this YUI instance.
  1001. */
  1002. error: function(msg, e, data) {
  1003. var Y = this, ret;
  1004. if (Y.config.errorFn) {
  1005. ret = Y.config.errorFn.apply(Y, arguments);
  1006. }
  1007. if (Y.config.throwFail && !ret) {
  1008. throw (e || new Error(msg));
  1009. } else {
  1010. Y.message(msg, 'error'); // don't scrub this one
  1011. }
  1012. return Y;
  1013. },
  1014. /**
  1015. * Generate an id that is unique among all YUI instances
  1016. * @method guid
  1017. * @param pre {String} optional guid prefix.
  1018. * @return {String} the guid.
  1019. */
  1020. guid: function(pre) {
  1021. var id = this.Env._guidp + '_' + (++this.Env._uidx);
  1022. return (pre) ? (pre + id) : id;
  1023. },
  1024. /**
  1025. * Returns a `guid` associated with an object. If the object
  1026. * does not have one, a new one is created unless `readOnly`
  1027. * is specified.
  1028. * @method stamp
  1029. * @param o {Object} The object to stamp.
  1030. * @param readOnly {Boolean} if `true`, a valid guid will only
  1031. * be returned if the object has one assigned to it.
  1032. * @return {String} The object's guid or null.
  1033. */
  1034. stamp: function(o, readOnly) {
  1035. var uid;
  1036. if (!o) {
  1037. return o;
  1038. }
  1039. // IE generates its own unique ID for dom nodes
  1040. // The uniqueID property of a document node returns a new ID
  1041. if (o.uniqueID && o.nodeType && o.nodeType !== 9) {
  1042. uid = o.uniqueID;
  1043. } else {
  1044. uid = (typeof o === 'string') ? o : o._yuid;
  1045. }
  1046. if (!uid) {
  1047. uid = this.guid();
  1048. if (!readOnly) {
  1049. try {
  1050. o._yuid = uid;
  1051. } catch (e) {
  1052. uid = null;
  1053. }
  1054. }
  1055. }
  1056. return uid;
  1057. },
  1058. /**
  1059. * Destroys the YUI instance
  1060. * @method destroy
  1061. * @since 3.3.0
  1062. */
  1063. destroy: function() {
  1064. var Y = this;
  1065. if (Y.Event) {
  1066. Y.Event._unload();
  1067. }
  1068. delete instances[Y.id];
  1069. delete Y.Env;
  1070. delete Y.config;
  1071. }
  1072. /**
  1073. * instanceof check for objects that works around
  1074. * memory leak in IE when the item tested is
  1075. * window/document
  1076. * @method instanceOf
  1077. * @since 3.3.0
  1078. */
  1079. };
  1080. YUI.prototype = proto;
  1081. // inheritance utilities are not available yet
  1082. for (prop in proto) {
  1083. if (proto.hasOwnProperty(prop)) {
  1084. YUI[prop] = proto[prop];
  1085. }
  1086. }
  1087. // set up the environment
  1088. YUI._init();
  1089. if (hasWin) {
  1090. // add a window load event at load time so we can capture
  1091. // the case where it fires before dynamic loading is
  1092. // complete.
  1093. add(window, 'load', handleLoad);
  1094. } else {
  1095. handleLoad();
  1096. }
  1097. YUI.Env.add = add;
  1098. YUI.Env.remove = remove;
  1099. /*global exports*/
  1100. // Support the CommonJS method for exporting our single global
  1101. if (typeof exports == 'object') {
  1102. exports.YUI = YUI;
  1103. }
  1104. }());
  1105. /**
  1106. * The config object contains all of the configuration options for
  1107. * the `YUI` instance. This object is supplied by the implementer
  1108. * when instantiating a `YUI` instance. Some properties have default
  1109. * values if they are not supplied by the implementer. This should
  1110. * not be updated directly because some values are cached. Use
  1111. * `applyConfig()` to update the config object on a YUI instance that
  1112. * has already been configured.
  1113. *
  1114. * @class config
  1115. * @static
  1116. */
  1117. /**
  1118. * Allows the YUI seed file to fetch the loader component and library
  1119. * metadata to dynamically load additional dependencies.
  1120. *
  1121. * @property bootstrap
  1122. * @type boolean
  1123. * @default true
  1124. */
  1125. /**
  1126. * Log to the browser console if debug is on and the browser has a
  1127. * supported console.
  1128. *
  1129. * @property useBrowserConsole
  1130. * @type boolean
  1131. * @default true
  1132. */
  1133. /**
  1134. * A hash of log sources that should be logged. If specified, only
  1135. * log messages from these sources will be logged.
  1136. *
  1137. * @property logInclude
  1138. * @type object
  1139. */
  1140. /**
  1141. * A hash of log sources that should be not be logged. If specified,
  1142. * all sources are logged if not on this list.
  1143. *
  1144. * @property logExclude
  1145. * @type object
  1146. */
  1147. /**
  1148. * Set to true if the yui seed file was dynamically loaded in
  1149. * order to bootstrap components relying on the window load event
  1150. * and the `domready` custom event.
  1151. *
  1152. * @property injected
  1153. * @type boolean
  1154. * @default false
  1155. */
  1156. /**
  1157. * If `throwFail` is set, `Y.error` will generate or re-throw a JS Error.
  1158. * Otherwise the failure is logged.
  1159. *
  1160. * @property throwFail
  1161. * @type boolean
  1162. * @default true
  1163. */
  1164. /**
  1165. * The window/frame that this instance should operate in.
  1166. *
  1167. * @property win
  1168. * @type Window
  1169. * @default the window hosting YUI
  1170. */
  1171. /**
  1172. * The document associated with the 'win' configuration.
  1173. *
  1174. * @property doc
  1175. * @type Document
  1176. * @default the document hosting YUI
  1177. */
  1178. /**
  1179. * A list of modules that defines the YUI core (overrides the default).
  1180. *
  1181. * @property core
  1182. * @type string[]
  1183. */
  1184. /**
  1185. * A list of languages in order of preference. This list is matched against
  1186. * the list of available languages in modules that the YUI instance uses to
  1187. * determine the best possible localization of language sensitive modules.
  1188. * Languages are represented using BCP 47 language tags, such as "en-GB" for
  1189. * English as used in the United Kingdom, or "zh-Hans-CN" for simplified
  1190. * Chinese as used in China. The list can be provided as a comma-separated
  1191. * list or as an array.
  1192. *
  1193. * @property lang
  1194. * @type string|string[]
  1195. */
  1196. /**
  1197. * The default date format
  1198. * @property dateFormat
  1199. * @type string
  1200. * @deprecated use configuration in `DataType.Date.format()` instead.
  1201. */
  1202. /**
  1203. * The default locale
  1204. * @property locale
  1205. * @type string
  1206. * @deprecated use `config.lang` instead.
  1207. */
  1208. /**
  1209. * The default interval when polling in milliseconds.
  1210. * @property pollInterval
  1211. * @type int
  1212. * @default 20
  1213. */
  1214. /**
  1215. * The number of dynamic nodes to insert by default before
  1216. * automatically removing them. This applies to script nodes
  1217. * because removing the node will not make the evaluated script
  1218. * unavailable. Dynamic CSS is not auto purged, because removing
  1219. * a linked style sheet will also remove the style definitions.
  1220. * @property purgethreshold
  1221. * @type int
  1222. * @default 20
  1223. */
  1224. /**
  1225. * The default interval when polling in milliseconds.
  1226. * @property windowResizeDelay
  1227. * @type int
  1228. * @default 40
  1229. */
  1230. /**
  1231. * Base directory for dynamic loading
  1232. * @property base
  1233. * @type string
  1234. */
  1235. /*
  1236. * The secure base dir (not implemented)
  1237. * For dynamic loading.
  1238. * @property secureBase
  1239. * @type string
  1240. */
  1241. /**
  1242. * The YUI combo service base dir. Ex: `http://yui.yahooapis.com/combo?`
  1243. * For dynamic loading.
  1244. * @property comboBase
  1245. * @type string
  1246. */
  1247. /**
  1248. * The root path to prepend to module path for the combo service.
  1249. * Ex: 3.0.0b1/build/
  1250. * For dynamic loading.
  1251. * @property root
  1252. * @type string
  1253. */
  1254. /**
  1255. * A filter to apply to result urls. This filter will modify the default
  1256. * path for all modules. The default path for the YUI library is the
  1257. * minified version of the files (e.g., event-min.js). The filter property
  1258. * can be a predefined filter or a custom filter. The valid predefined
  1259. * filters are:
  1260. * <dl>
  1261. * <dt>DEBUG</dt>
  1262. * <dd>Selects the debug versions of the library (e.g., event-debug.js).
  1263. * This option will automatically include the Logger widget</dd>
  1264. * <dt>RAW</dt>
  1265. * <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
  1266. * </dl>
  1267. * You can also define a custom filter, which must be an object literal
  1268. * containing a search expression and a replace string:
  1269. *
  1270. * myFilter: {
  1271. * 'searchExp': "-min\\.js",
  1272. * 'replaceStr': "-debug.js"
  1273. * }
  1274. *
  1275. * For dynamic loading.
  1276. *
  1277. * @property filter
  1278. * @type string|object
  1279. */
  1280. /**
  1281. * The `skin` config let's you configure application level skin
  1282. * customizations. It contains the following attributes which
  1283. * can be specified to override the defaults:
  1284. *
  1285. * // The default skin, which is automatically applied if not
  1286. * // overriden by a component-specific skin definition.
  1287. * // Change this in to apply a different skin globally
  1288. * defaultSkin: 'sam',
  1289. *
  1290. * // This is combined with the loader base property to get
  1291. * // the default root directory for a skin.
  1292. * base: 'assets/skins/',
  1293. *
  1294. * // Any component-specific overrides can be specified here,
  1295. * // making it possible to load different skins for different
  1296. * // components. It is possible to load more than one skin
  1297. * // for a given component as well.
  1298. * overrides: {
  1299. * slider: ['capsule', 'round']
  1300. * }
  1301. *
  1302. * For dynamic loading.
  1303. *
  1304. * @property skin
  1305. */
  1306. /**
  1307. * Hash of per-component filter specification. If specified for a given
  1308. * component, this overrides the filter config.
  1309. *
  1310. * For dynamic loading.
  1311. *
  1312. * @property filters
  1313. */
  1314. /**
  1315. * Use the YUI combo service to reduce the number of http connections
  1316. * required to load your dependencies. Turning this off will
  1317. * disable combo handling for YUI and all module groups configured
  1318. * with a combo service.
  1319. *
  1320. * For dynamic loading.
  1321. *
  1322. * @property combine
  1323. * @type boolean
  1324. * @default true if 'base' is not supplied, false if it is.
  1325. */
  1326. /**
  1327. * A list of modules that should never be dynamically loaded
  1328. *
  1329. * @property ignore
  1330. * @type string[]
  1331. */
  1332. /**
  1333. * A list of modules that should always be loaded when required, even if already
  1334. * present on the page.
  1335. *
  1336. * @property force
  1337. * @type string[]
  1338. */
  1339. /**
  1340. * Node or id for a node that should be used as the insertion point for new
  1341. * nodes. For dynamic loading.
  1342. *
  1343. * @property insertBefore
  1344. * @type string
  1345. */
  1346. /**
  1347. * Object literal containing attributes to add to dynamically loaded script
  1348. * nodes.
  1349. * @property jsAttributes
  1350. * @type string
  1351. */
  1352. /**
  1353. * Object literal containing attributes to add to dynamically loaded link
  1354. * nodes.
  1355. * @property cssAttributes
  1356. * @type string
  1357. */
  1358. /**
  1359. * Number of milliseconds before a timeout occurs when dynamically
  1360. * loading nodes. If not set, there is no timeout.
  1361. * @property timeout
  1362. * @type int
  1363. */
  1364. /**
  1365. * Callback for the 'CSSComplete' event. When dynamically loading YUI
  1366. * components with CSS, this property fires when the CSS is finished
  1367. * loading but script loading is still ongoing. This provides an
  1368. * opportunity to enhance the presentation of a loading page a little
  1369. * bit before the entire loading process is done.
  1370. *
  1371. * @property onCSS
  1372. * @type function
  1373. */
  1374. /**
  1375. * A hash of module definitions to add to the list of YUI components.
  1376. * These components can then be dynamically loaded side by side with
  1377. * YUI via the `use()` method. This is a hash, the key is the module
  1378. * name, and the value is an object literal specifying the metdata
  1379. * for the module. See `Loader.addModule` for the supported module
  1380. * metadata fields. Also see groups, which provides a way to
  1381. * configure the base and combo spec for a set of modules.
  1382. *
  1383. * modules: {
  1384. * mymod1: {
  1385. * requires: ['node'],
  1386. * fullpath: 'http://myserver.mydomain.com/mymod1/mymod1.js'
  1387. * },
  1388. * mymod2: {
  1389. * requires: ['mymod1'],
  1390. * fullpath: 'http://myserver.mydomain.com/mymod2/mymod2.js'
  1391. * }
  1392. * }
  1393. *
  1394. * @property modules
  1395. * @type object
  1396. */
  1397. /**
  1398. * A hash of module group definitions. It for each group you
  1399. * can specify a list of modules and the base path and
  1400. * combo spec to use when dynamically loading the modules.
  1401. *
  1402. * groups: {
  1403. * yui2: {
  1404. * // specify whether or not this group has a combo service
  1405. * combine: true,
  1406. *
  1407. * // the base path for non-combo paths
  1408. * base: 'http://yui.yahooapis.com/2.8.0r4/build/',
  1409. *
  1410. * // the path to the combo service
  1411. * comboBase: 'http://yui.yahooapis.com/combo?',
  1412. *
  1413. * // a fragment to prepend to the path attribute when
  1414. * // when building combo urls
  1415. * root: '2.8.0r4/build/',
  1416. *
  1417. * // the module definitions
  1418. * modules: {
  1419. * yui2_yde: {
  1420. * path: "yahoo-dom-event/yahoo-dom-event.js"
  1421. * },
  1422. * yui2_anim: {
  1423. * path: "animation/animation.js",
  1424. * requires: ['yui2_yde']
  1425. * }
  1426. * }
  1427. * }
  1428. * }
  1429. *
  1430. * @property groups
  1431. * @type object
  1432. */
  1433. /**
  1434. * The loader 'path' attribute to the loader itself. This is combined
  1435. * with the 'base' attribute to dynamically load the loader component
  1436. * when boostrapping with the get utility alone.
  1437. *
  1438. * @property loaderPath
  1439. * @type string
  1440. * @default loader/loader-min.js
  1441. */
  1442. /**
  1443. * Specifies whether or not YUI().use(...) will attempt to load CSS
  1444. * resources at all. Any truthy value will cause CSS dependencies
  1445. * to load when fetching script. The special value 'force' will
  1446. * cause CSS dependencies to be loaded even if no script is needed.
  1447. *
  1448. * @property fetchCSS
  1449. * @type boolean|string
  1450. * @default true
  1451. */
  1452. /**
  1453. * The default gallery version to build gallery module urls
  1454. * @property gallery
  1455. * @type string
  1456. * @since 3.1.0
  1457. */
  1458. /**
  1459. * The default YUI 2 version to build yui2 module urls. This is for
  1460. * intrinsic YUI 2 support via the 2in3 project. Also see the '2in3'
  1461. * config for pulling different revisions of the wrapped YUI 2
  1462. * modules.
  1463. * @since 3.1.0
  1464. * @property yui2
  1465. * @type string
  1466. * @default 2.8.1
  1467. */
  1468. /**
  1469. * The 2in3 project is a deployment of the various versions of YUI 2
  1470. * deployed as first-class YUI 3 modules. Eventually, the wrapper
  1471. * for the modules will change (but the underlying YUI 2 code will
  1472. * be the same), and you can select a particular version of
  1473. * the wrapper modules via this config.
  1474. * @since 3.1.0
  1475. * @property 2in3
  1476. * @type string
  1477. * @default 1
  1478. */
  1479. /**
  1480. * Alternative console log function for use in environments without
  1481. * a supported native console. The function is executed in the
  1482. * YUI instance context.
  1483. * @since 3.1.0
  1484. * @property logFn
  1485. * @type Function
  1486. */
  1487. /**
  1488. * A callback to execute when Y.error is called. It receives the
  1489. * error message and an javascript error object if Y.error was
  1490. * executed because a javascript error was caught. The function
  1491. * is executed in the YUI instance context.
  1492. *
  1493. * @since 3.2.0
  1494. * @property errorFn
  1495. * @type Function
  1496. */
  1497. /**
  1498. * A callback to execute when the loader fails to load one or
  1499. * more resource. This could be because of a script load
  1500. * failure. It can also fail if a javascript module fails
  1501. * to register itself, but only when the 'requireRegistration'
  1502. * is true. If this function is defined, the use() callback will
  1503. * only be called when the loader succeeds, otherwise it always
  1504. * executes unless there was a javascript error when attaching
  1505. * a module.
  1506. *
  1507. * @since 3.3.0
  1508. * @property loadErrorFn
  1509. * @type Function
  1510. */
  1511. /**
  1512. * When set to true, the YUI loader will expect that all modules
  1513. * it is responsible for loading will be first-class YUI modules
  1514. * that register themselves with the YUI global. If this is
  1515. * set to true, loader will fail if the module registration fails
  1516. * to happen after the script is loaded.
  1517. *
  1518. * @since 3.3.0
  1519. * @property requireRegistration
  1520. * @type boolean
  1521. * @default false
  1522. */
  1523. /**
  1524. * Cache serviced use() requests.
  1525. * @since 3.3.0
  1526. * @property cacheUse
  1527. * @type boolean
  1528. * @default true
  1529. * @deprecated no longer used
  1530. */
  1531. /**
  1532. * The parameter defaults for the remote loader service. **Requires the rls seed file.** The properties that are supported:
  1533. *
  1534. * * `m`: comma separated list of module requirements. This
  1535. * must be the param name even for custom implemetations.
  1536. * * `v`: the version of YUI to load. Defaults to the version
  1537. * of YUI that is being used.
  1538. * * `gv`: the version of the gallery to load (see the gallery config)
  1539. * * `env`: comma separated list of modules already on the page.
  1540. * this must be the param name even for custom implemetations.
  1541. * * `lang`: the languages supported on the page (see the lang config)
  1542. * * `'2in3v'`: the version of the 2in3 wrapper to use (see the 2in3 config).
  1543. * * `'2v'`: the version of yui2 to use in the yui 2in3 wrappers
  1544. * * `filt`: a filter def to apply to the urls (see the filter config).
  1545. * * `filts`: a list of custom filters to apply per module
  1546. * * `tests`: this is a map of conditional module test function id keys
  1547. * with the values of 1 if the test passes, 0 if not. This must be
  1548. * the name of the querystring param in custom templates.
  1549. *
  1550. * @since 3.2.0
  1551. * @property rls
  1552. * @type {Object}
  1553. */
  1554. /**
  1555. * The base path to the remote loader service. **Requires the rls seed file.**
  1556. *
  1557. * @since 3.2.0
  1558. * @property rls_base
  1559. * @type {String}
  1560. */
  1561. /**
  1562. * The template to use for building the querystring portion
  1563. * of the remote loader service url. The default is determined
  1564. * by the rls config -- each property that has a value will be
  1565. * represented. **Requires the rls seed file.**
  1566. *
  1567. * @since 3.2.0
  1568. * @property rls_tmpl
  1569. * @type {String}
  1570. * @example
  1571. * m={m}&v={v}&env={env}&lang={lang}&filt={filt}&tests={tests}
  1572. *
  1573. */
  1574. /**
  1575. * Configure the instance to use a remote loader service instead of
  1576. * the client loader. **Requires the rls seed file.**
  1577. *
  1578. * @since 3.2.0
  1579. * @property use_rls
  1580. * @type {Boolean}
  1581. */
  1582. YUI.add('yui-base', function(Y) {
  1583. /*
  1584. * YUI stub
  1585. * @module yui
  1586. * @submodule yui-base
  1587. */
  1588. /**
  1589. * The YUI module contains the components required for building the YUI
  1590. * seed file. This includes the script loading mechanism, a simple queue,
  1591. * and the core utilities for the library.
  1592. * @module yui
  1593. * @submodule yui-base
  1594. */
  1595. /**
  1596. * Provides core language utilites and extensions used throughout YUI.
  1597. *
  1598. * @class Lang
  1599. * @static
  1600. */
  1601. var L = Y.Lang || (Y.Lang = {}),
  1602. STRING_PROTO = String.prototype,
  1603. TOSTRING = Object.prototype.toString,
  1604. TYPES = {
  1605. 'undefined' : 'undefined',
  1606. 'number' : 'number',
  1607. 'boolean' : 'boolean',
  1608. 'string' : 'string',
  1609. '[object Function]': 'function',
  1610. '[object RegExp]' : 'regexp',
  1611. '[object Array]' : 'array',
  1612. '[object Date]' : 'date',
  1613. '[object Error]' : 'error'
  1614. },
  1615. SUBREGEX = /\{\s*([^|}]+?)\s*(?:\|([^}]*))?\s*\}/g,
  1616. TRIMREGEX = /^\s+|\s+$/g,
  1617. // If either MooTools or Prototype is on the page, then there's a chance that we
  1618. // can't trust "native" language features to actually be native. When this is
  1619. // the case, we take the safe route and fall back to our own non-native
  1620. // implementation.
  1621. win = Y.config.win,
  1622. unsafeNatives = win && !!(win.MooTools || win.Prototype);
  1623. /**
  1624. * Determines whether or not the provided item is an array.
  1625. *
  1626. * Returns `false` for array-like collections such as the function `arguments`
  1627. * collection or `HTMLElement` collections. Use `Y.Array.test()` if you want to
  1628. * test for an array-like collection.
  1629. *
  1630. * @method isArray
  1631. * @param o The object to test.
  1632. * @return {boolean} true if o is an array.
  1633. * @static
  1634. */
  1635. L.isArray = (!unsafeNatives && Array.isArray) || function (o) {
  1636. return L.type(o) === 'array';
  1637. };
  1638. /**
  1639. * Determines whether or not the provided item is a boolean.
  1640. * @method isBoolean
  1641. * @static
  1642. * @param o The object to test.
  1643. * @return {boolean} true if o is a boolean.
  1644. */
  1645. L.isBoolean = function(o) {
  1646. return typeof o === 'boolean';
  1647. };
  1648. /**
  1649. * <p>
  1650. * Determines whether or not the provided item is a function.
  1651. * Note: Internet Explorer thinks certain functions are objects:
  1652. * </p>
  1653. *
  1654. * <pre>
  1655. * var obj = document.createElement("object");
  1656. * Y.Lang.isFunction(obj.getAttribute) // reports false in IE
  1657. * &nbsp;
  1658. * var input = document.createElement("input"); // append to body
  1659. * Y.Lang.isFunction(input.focus) // reports false in IE
  1660. * </pre>
  1661. *
  1662. * <p>
  1663. * You will have to implement additional tests if these functions
  1664. * matter to you.
  1665. * </p>
  1666. *
  1667. * @method isFunction
  1668. * @static
  1669. * @param o The object to test.
  1670. * @return {boolean} true if o is a function.
  1671. */
  1672. L.isFunction = function(o) {
  1673. return L.type(o) === 'function';
  1674. };
  1675. /**
  1676. * Determines whether or not the supplied item is a date instance.
  1677. * @method isDate
  1678. * @static
  1679. * @param o The object to test.
  1680. * @return {boolean} true if o is a date.
  1681. */
  1682. L.isDate = function(o) {
  1683. return L.type(o) === 'date' && o.toString() !== 'Invalid Date' && !isNaN(o);
  1684. };
  1685. /**
  1686. * Determines whether or not the provided item is null.
  1687. * @method isNull
  1688. * @static
  1689. * @param o The object to test.
  1690. * @return {boolean} true if o is null.
  1691. */
  1692. L.isNull = function(o) {
  1693. return o === null;
  1694. };
  1695. /**
  1696. * Determines whether or not the provided item is a legal number.
  1697. * @method isNumber
  1698. * @static
  1699. * @param o The object to test.
  1700. * @return {boolean} true if o is a number.
  1701. */
  1702. L.isNumber = function(o) {
  1703. return typeof o === 'number' && isFinite(o);
  1704. };
  1705. /**
  1706. * Determines whether or not the provided item is of type object
  1707. * or function. Note that arrays are also objects, so
  1708. * <code>Y.Lang.isObject([]) === true</code>.
  1709. * @method isObject
  1710. * @static
  1711. * @param o The object to test.
  1712. * @param failfn {boolean} fail if the input is a function.
  1713. * @return {boolean} true if o is an object.
  1714. * @see isPlainObject
  1715. */
  1716. L.isObject = function(o, failfn) {
  1717. var t = typeof o;
  1718. return (o && (t === 'object' ||
  1719. (!failfn && (t === 'function' || L.isFunction(o))))) || false;
  1720. };
  1721. /**
  1722. * Determines whether or not the provided item is a string.
  1723. * @method isString
  1724. * @static
  1725. * @param o The object to test.
  1726. * @return {boolean} true if o is a string.
  1727. */
  1728. L.isString = function(o) {
  1729. return typeof o === 'string';
  1730. };
  1731. /**
  1732. * Determines whether or not the provided item is undefined.
  1733. * @method isUndefined
  1734. * @static
  1735. * @param o The object to test.
  1736. * @return {boolean} true if o is undefined.
  1737. */
  1738. L.isUndefined = function(o) {
  1739. return typeof o === 'undefined';
  1740. };
  1741. /**
  1742. * Returns a string without any leading or trailing whitespace. If
  1743. * the input is not a string, the input will be returned untouched.
  1744. * @method trim
  1745. * @static
  1746. * @param s {string} the string to trim.
  1747. * @return {string} the trimmed string.
  1748. */
  1749. L.trim = STRING_PROTO.trim ? function(s) {
  1750. return s && s.trim ? s.trim() : s;
  1751. } : function (s) {
  1752. try {
  1753. return s.replace(TRIMREGEX, '');
  1754. } catch (e) {
  1755. return s;
  1756. }
  1757. };
  1758. /**
  1759. * Returns a string without any leading whitespace.
  1760. * @method trimLeft
  1761. * @static
  1762. * @param s {string} the string to trim.
  1763. * @return {string} the trimmed string.
  1764. */
  1765. L.trimLeft = STRING_PROTO.trimLeft ? function (s) {
  1766. return s.trimLeft();
  1767. } : function (s) {
  1768. return s.replace(/^\s+/, '');
  1769. };
  1770. /**
  1771. * Returns a string without any trailing whitespace.
  1772. * @method trimRight
  1773. * @static
  1774. * @param s {string} the string to trim.
  1775. * @return {string} the trimmed string.
  1776. */
  1777. L.trimRight = STRING_PROTO.trimRight ? function (s) {
  1778. return s.trimRight();
  1779. } : function (s) {
  1780. return s.replace(/\s+$/, '');
  1781. };
  1782. /**
  1783. * A convenience method for detecting a legitimate non-null value.
  1784. * Returns false for null/undefined/NaN, true for other values,
  1785. * including 0/false/''
  1786. * @method isValue
  1787. * @static
  1788. * @param o The item to test.
  1789. * @return {boolean} true if it is not null/undefined/NaN || false.
  1790. */
  1791. L.isValue = function(o) {
  1792. var t = L.type(o);
  1793. switch (t) {
  1794. case 'number':
  1795. return isFinite(o);
  1796. case 'null': // fallthru
  1797. case 'undefined':
  1798. return false;
  1799. default:
  1800. return !!t;
  1801. }
  1802. };
  1803. /**
  1804. * <p>
  1805. * Returns a string representing the type of the item passed in.
  1806. * </p>
  1807. *
  1808. * <p>
  1809. * Known issues:
  1810. * </p>
  1811. *
  1812. * <ul>
  1813. * <li>
  1814. * <code>typeof HTMLElementCollection</code> returns function in Safari, but
  1815. * <code>Y.type()</code> reports object, which could be a good thing --
  1816. * but it actually caused the logic in <code>Y.Lang.isObject</code> to fail.
  1817. * </li>
  1818. * </ul>
  1819. *
  1820. * @method type
  1821. * @param o the item to test.
  1822. * @return {string} the detected type.
  1823. * @static
  1824. */
  1825. L.type = function(o) {
  1826. return TYPES[typeof o] || TYPES[TOSTRING.call(o)] || (o ? 'object' : 'null');
  1827. };
  1828. /**
  1829. * Lightweight version of <code>Y.substitute</code>. Uses the same template
  1830. * structure as <code>Y.substitute</code>, but doesn't support recursion,
  1831. * auto-object coersion, or formats.
  1832. * @method sub
  1833. * @param {string} s String to be modified.
  1834. * @param {object} o Object containing replacement values.
  1835. * @return {string} the substitute result.
  1836. * @static
  1837. * @since 3.2.0
  1838. */
  1839. L.sub = function(s, o) {
  1840. return s.replace ? s.replace(SUBREGEX, function (match, key) {
  1841. return L.isUndefined(o[key]) ? match : o[key];
  1842. }) : s;
  1843. };
  1844. /**
  1845. * Returns the current time in milliseconds.
  1846. *
  1847. * @method now
  1848. * @return {Number} Current time in milliseconds.
  1849. * @static
  1850. * @since 3.3.0
  1851. */
  1852. L.now = Date.now || function () {
  1853. return new Date().getTime();
  1854. };
  1855. /**
  1856. @module yui
  1857. @submodule yui-base
  1858. */
  1859. var Lang = Y.Lang,
  1860. Native = Array.prototype,
  1861. hasOwn = Object.prototype.hasOwnProperty;
  1862. /**
  1863. Provides utility methods for working with arrays. Additional array helpers can
  1864. be found in the `collection` and `array-extras` modules.
  1865. `Y.Array(thing)` returns a native array created from _thing_. Depending on
  1866. _thing_'s type, one of the following will happen:
  1867. * Arrays are returned unmodified unless a non-zero _startIndex_ is
  1868. specified.
  1869. * Array-like collections (see `Array.test()`) are converted to arrays.
  1870. * For everything else, a new array is created with _thing_ as the sole
  1871. item.
  1872. Note: elements that are also collections, such as `<form>` and `<select>`
  1873. elements, are not automatically converted to arrays. To force a conversion,
  1874. pass `true` as the value of the _force_ parameter.
  1875. @class Array
  1876. @constructor
  1877. @param {Any} thing The thing to arrayify.
  1878. @param {Number} [startIndex=0] If non-zero and _thing_ is an array or array-like
  1879. collection, a subset of items starting at the specified index will be
  1880. returned.
  1881. @param {Boolean} [force=false] If `true`, _thing_ will be treated as an
  1882. array-like collection no matter what.
  1883. @return {Array} A native array created from _thing_, according to the rules
  1884. described above.
  1885. **/
  1886. function YArray(thing, startIndex, force) {
  1887. var len, result;
  1888. startIndex || (startIndex = 0);
  1889. if (force || YArray.test(thing)) {
  1890. // IE throws when trying to slice HTMLElement collections.
  1891. try {
  1892. return Native.slice.call(thing, startIndex);
  1893. } catch (ex) {
  1894. result = [];
  1895. for (len = thing.length; startIndex < len; ++startIndex) {
  1896. result.push(thing[startIndex]);
  1897. }
  1898. return result;
  1899. }
  1900. }
  1901. return [thing];
  1902. }
  1903. Y.Array = YArray;
  1904. /**
  1905. Dedupes an array of strings, returning an array that's guaranteed to contain
  1906. only one copy of a given string.
  1907. This method differs from `Array.unique()` in that it's optimized for use only
  1908. with strings, whereas `unique` may be used with other types (but is slower).
  1909. Using `dedupe()` with non-string values may result in unexpected behavior.
  1910. @method dedupe
  1911. @param {String[]} array Array of strings to dedupe.
  1912. @return {Array} Deduped copy of _array_.
  1913. @static
  1914. @since 3.4.0
  1915. **/
  1916. YArray.dedupe = function (array) {
  1917. var hash = {},
  1918. results = [],
  1919. i, item, len;
  1920. for (i = 0, len = array.length; i < len; ++i) {
  1921. item = array[i];
  1922. if (!hasOwn.call(hash, item)) {
  1923. hash[item] = 1;
  1924. results.push(item);
  1925. }
  1926. }
  1927. return results;
  1928. };
  1929. /**
  1930. Executes the supplied function on each item in the array. This method wraps
  1931. the native ES5 `Array.forEach()` method if available.
  1932. @method each
  1933. @param {Array} array Array to iterate.
  1934. @param {Function} fn Function to execute on each item in the array. The function
  1935. will receive the following arguments:
  1936. @param {Any} fn.item Current array item.
  1937. @param {Number} fn.index Current array index.
  1938. @param {Array} fn.array Array being iterated.
  1939. @param {Object} [thisObj] `this` object to use when calling _fn_.
  1940. @return {YUI} The YUI instance.
  1941. @static
  1942. **/
  1943. YArray.each = YArray.forEach = Native.forEach ? function (array, fn, thisObj) {
  1944. Native.forEach.call(array || [], fn, thisObj || Y);
  1945. return Y;
  1946. } : function (array, fn, thisObj) {
  1947. for (var i = 0, len = (array && array.length) || 0; i < len; ++i) {
  1948. if (i in array) {
  1949. fn.call(thisObj || Y, array[i], i, array);
  1950. }
  1951. }
  1952. return Y;
  1953. };
  1954. /**
  1955. Alias for `each()`.
  1956. @method forEach
  1957. @static
  1958. **/
  1959. /**
  1960. Returns an object using the first array as keys and the second as values. If
  1961. the second array is not provided, or if it doesn't contain the same number of
  1962. values as the first array, then `true` will be used in place of the missing
  1963. values.
  1964. @example
  1965. Y.Array.hash(['a', 'b', 'c'], ['foo', 'bar']);
  1966. // => {a: 'foo', b: 'bar', c: true}
  1967. @method hash
  1968. @param {String[]} keys Array of strings to use as keys.
  1969. @param {Array} [values] Array to use as values.
  1970. @return {Object} Hash using the first array as keys and the second as values.
  1971. @static
  1972. **/
  1973. YArray.hash = function (keys, values) {
  1974. var hash = {},
  1975. vlen = (values && values.length) || 0,
  1976. i, len;
  1977. for (i = 0, len = keys.length; i < len; ++i) {
  1978. if (i in keys) {
  1979. hash[keys[i]] = vlen > i && i in values ? values[i] : true;
  1980. }
  1981. }
  1982. return hash;
  1983. };
  1984. /**
  1985. Returns the index of the first item in the array that's equal (using a strict
  1986. equality check) to the specified _value_, or `-1` if the value isn't found.
  1987. This method wraps the native ES5 `Array.indexOf()` method if available.
  1988. @method indexOf
  1989. @param {Array} array Array to search.
  1990. @param {Any} value Value to search for.
  1991. @return {Number} Index of the item strictly equal to _value_, or `-1` if not
  1992. found.
  1993. @static
  1994. **/
  1995. YArray.indexOf = Native.indexOf ? function (array, value) {
  1996. // TODO: support fromIndex
  1997. return Native.indexOf.call(array, value);
  1998. } : function (array, value) {
  1999. for (var i = 0, len = array.length; i < len; ++i) {
  2000. if (i in array && array[i] === value) {
  2001. return i;
  2002. }
  2003. }
  2004. return -1;
  2005. };
  2006. /**
  2007. Numeric sort convenience function.
  2008. The native `Array.prototype.sort()` function converts values to strings and
  2009. sorts them in lexicographic order, which is unsuitable for sorting numeric
  2010. values. Provide `Array.numericSort` as a custom sort function when you want
  2011. to sort values in numeric order.
  2012. @example
  2013. [42, 23, 8, 16, 4, 15].sort(Y.Array.numericSort);
  2014. // => [4, 8, 15, 16, 23, 42]
  2015. @method numericSort
  2016. @param {Number} a First value to compare.
  2017. @param {Number} b Second value to compare.
  2018. @return {Number} Difference between _a_ and _b_.
  2019. @static
  2020. **/
  2021. YArray.numericSort = function (a, b) {
  2022. return a - b;
  2023. };
  2024. /**
  2025. Executes the supplied function on each item in the array. Returning a truthy
  2026. value from the function will stop the processing of remaining items.
  2027. @method some
  2028. @param {Array} array Array to iterate over.
  2029. @param {Function} fn Function to execute on each item. The function will receive
  2030. the following arguments:
  2031. @param {Any} fn.value Current array item.
  2032. @param {Number} fn.index Current array index.
  2033. @param {Array} fn.array Array being iterated over.
  2034. @param {Object} [thisObj] `this` object to use when calling _fn_.
  2035. @return {Boolean} `true` if the function returns a truthy value on any of the
  2036. items in the array; `false` otherwise.
  2037. @static
  2038. **/
  2039. YArray.some = Native.some ? function (array, fn, thisObj) {
  2040. return Native.some.call(array, fn, thisObj);
  2041. } : function (array, fn, thisObj) {
  2042. for (var i = 0, len = array.length; i < len; ++i) {
  2043. if (i in array && fn.call(thisObj, array[i], i, array)) {
  2044. return true;
  2045. }
  2046. }
  2047. return false;
  2048. };
  2049. /**
  2050. Evaluates _obj_ to determine if it's an array, an array-like collection, or
  2051. something else. This is useful when working with the function `arguments`
  2052. collection and `HTMLElement` collections.
  2053. Note: This implementation doesn't consider elements that are also
  2054. collections, such as `<form>` and `<select>`, to be array-like.
  2055. @method test
  2056. @param {Object} obj Object to test.
  2057. @return {Number} A number indicating the results of the test:
  2058. * 0: Neither an array nor an array-like collection.
  2059. * 1: Real array.
  2060. * 2: Array-like collection.
  2061. @static
  2062. **/
  2063. YArray.test = function (obj) {
  2064. var result = 0;
  2065. if (Lang.isArray(obj)) {
  2066. result = 1;
  2067. } else if (Lang.isObject(obj)) {
  2068. try {
  2069. // indexed, but no tagName (element) or alert (window),
  2070. // or functions without apply/call (Safari
  2071. // HTMLElementCollection bug).
  2072. if ('length' in obj && !obj.tagName && !obj.alert && !obj.apply) {
  2073. result = 2;
  2074. }
  2075. } catch (ex) {}
  2076. }
  2077. return result;
  2078. };
  2079. /**
  2080. * The YUI module contains the components required for building the YUI
  2081. * seed file. This includes the script loading mechanism, a simple queue,
  2082. * and the core utilities for the library.
  2083. * @module yui
  2084. * @submodule yui-base
  2085. */
  2086. /**
  2087. * A simple FIFO queue. Items are added to the Queue with add(1..n items) and
  2088. * removed using next().
  2089. *
  2090. * @class Queue
  2091. * @constructor
  2092. * @param {MIXED} item* 0..n items to seed the queue.
  2093. */
  2094. function Queue() {
  2095. this._init();
  2096. this.add.apply(this, arguments);
  2097. }
  2098. Queue.prototype = {
  2099. /**
  2100. * Initialize the queue
  2101. *
  2102. * @method _init
  2103. * @protected
  2104. */
  2105. _init: function() {
  2106. /**
  2107. * The collection of enqueued items
  2108. *
  2109. * @property _q
  2110. * @type Array
  2111. * @protected
  2112. */
  2113. this._q = [];
  2114. },
  2115. /**
  2116. * Get the next item in the queue. FIFO support
  2117. *
  2118. * @method next
  2119. * @return {MIXED} the next item in the queue.
  2120. */
  2121. next: function() {
  2122. return this._q.shift();
  2123. },
  2124. /**
  2125. * Get the last in the queue. LIFO support.
  2126. *
  2127. * @method last
  2128. * @return {MIXED} the last item in the queue.
  2129. */
  2130. last: function() {
  2131. return this._q.pop();
  2132. },
  2133. /**
  2134. * Add 0..n items to the end of the queue.
  2135. *
  2136. * @method add
  2137. * @param {MIXED} item* 0..n items.
  2138. * @return {object} this queue.
  2139. */
  2140. add: function() {
  2141. this._q.push.apply(this._q, arguments);
  2142. return this;
  2143. },
  2144. /**
  2145. * Returns the current number of queued items.
  2146. *
  2147. * @method size
  2148. * @return {Number} The size.
  2149. */
  2150. size: function() {
  2151. return this._q.length;
  2152. }
  2153. };
  2154. Y.Queue = Queue;
  2155. YUI.Env._loaderQueue = YUI.Env._loaderQueue || new Queue();
  2156. /**
  2157. The YUI module contains the components required for building the YUI seed file.
  2158. This includes the script loading mechanism, a simple queue, and the core
  2159. utilities for the library.
  2160. @module yui
  2161. @submodule yui-base
  2162. **/
  2163. var CACHED_DELIMITER = '__',
  2164. hasOwn = Object.prototype.hasOwnProperty,
  2165. isObject = Y.Lang.isObject;
  2166. /**
  2167. Returns a wrapper for a function which caches the return value of that function,
  2168. keyed off of the combined string representation of the argument values provided
  2169. when the wrapper is called.
  2170. Calling this function again with the same arguments will return the cached value
  2171. rather than executing the wrapped function.
  2172. Note that since the cache is keyed off of the string representation of arguments
  2173. passed to the wrapper function, arguments that aren't strings and don't provide
  2174. a meaningful `toString()` method may result in unexpected caching behavior. For
  2175. example, the objects `{}` and `{foo: 'bar'}` would both be converted to the
  2176. string `[object Object]` when used as a cache key.
  2177. @method cached
  2178. @param {Function} source The function to memoize.
  2179. @param {Object} [cache={}] Object in which to store cached values. You may seed
  2180. this object with pre-existing cached values if desired.
  2181. @param {any} [refetch] If supplied, this value is compared with the cached value
  2182. using a `==` comparison. If the values are equal, the wrapped function is
  2183. executed again even though a cached value exists.
  2184. @return {Function} Wrapped function.
  2185. @for YUI
  2186. **/
  2187. Y.cached = function (source, cache, refetch) {
  2188. cache || (cache = {});
  2189. return function (arg) {
  2190. var key = arguments.length > 1 ?
  2191. Array.prototype.join.call(arguments, CACHED_DELIMITER) :
  2192. String(arg);
  2193. if (!(key in cache) || (refetch && cache[key] == refetch)) {
  2194. cache[key] = source.apply(source, arguments);
  2195. }
  2196. return cache[key];
  2197. };
  2198. };
  2199. /**
  2200. Returns a new object containing all of the properties of all the supplied
  2201. objects. The properties from later objects will overwrite those in earlier
  2202. objects.
  2203. Passing in a single object will create a shallow copy of it. For a deep copy,
  2204. use `clone()`.
  2205. @method merge
  2206. @param {Object} objects* One or more objects to merge.
  2207. @return {Object} A new merged object.
  2208. **/
  2209. Y.merge = function () {
  2210. var args = arguments,
  2211. i = 0,
  2212. len = args.length,
  2213. result = {};
  2214. for (; i < len; ++i) {
  2215. Y.mix(result, args[i], true);
  2216. }
  2217. return result;
  2218. };
  2219. /**
  2220. Mixes _supplier_'s properties into _receiver_.
  2221. Properties on _receiver_ or _receiver_'s prototype will not be overwritten or
  2222. shadowed unless the _overwrite_ parameter is `true`, and will not be merged
  2223. unless the _merge_ parameter is `true`.
  2224. In the default mode (0), only properties the supplier owns are copied (prototype
  2225. properties are not copied). The following copying modes are available:
  2226. * `0`: _Default_. Object to object.
  2227. * `1`: Prototype to prototype.
  2228. * `2`: Prototype to prototype and object to object.
  2229. * `3`: Prototype to object.
  2230. * `4`: Object to prototype.
  2231. @method mix
  2232. @param {Function|Object} receiver The object or function to receive the mixed
  2233. properties.
  2234. @param {Function|Object} supplier The object or function supplying the
  2235. properties to be mixed.
  2236. @param {Boolean} [overwrite=false] If `true`, properties that already exist
  2237. on the receiver will be overwritten with properties from the supplier.
  2238. @param {String[]} [whitelist] An array of property names to copy. If
  2239. specified, only the whitelisted properties will be copied, and all others
  2240. will be ignored.
  2241. @param {Number} [mode=0] Mix mode to use. See above for available modes.
  2242. @param {Boolean} [merge=false] If `true`, objects and arrays that already
  2243. exist on the receiver will have the corresponding object/array from the
  2244. supplier merged into them, rather than being skipped or overwritten. When
  2245. both _overwrite_ and _merge_ are `true`, _merge_ takes precedence.
  2246. @return {Function|Object|YUI} The receiver, or the YUI instance if the
  2247. specified receiver is falsy.
  2248. **/
  2249. Y.mix = function(receiver, supplier, overwrite, whitelist, mode, merge) {
  2250. var alwaysOverwrite, exists, from, i, key, len, to;
  2251. // If no supplier is given, we return the receiver. If no receiver is given,
  2252. // we return Y. Returning Y doesn't make much sense to me, but it's
  2253. // grandfathered in for backcompat reasons.
  2254. if (!receiver || !supplier) {
  2255. return receiver || Y;
  2256. }
  2257. if (mode) {
  2258. // In mode 2 (prototype to prototype and object to object), we recurse
  2259. // once To Do the proto to proto mix. The object to object mix will be
  2260. // handled later on.
  2261. if (mode === 2) {
  2262. Y.mix(receiver.prototype, supplier.prototype, overwrite,
  2263. whitelist, 0, merge);
  2264. }
  2265. // Depending on which mode is specified, we may be copying from or to
  2266. // the prototypes of the supplier and receiver.
  2267. from = mode === 1 || mode === 3 ? supplier.prototype : supplier;
  2268. to = mode === 1 || mode === 4 ? receiver.prototype : receiver;
  2269. // If either the supplier or receiver doesn't actually have a
  2270. // prototype property, then we could end up with an undefined `from`
  2271. // or `to`. If that happens, we abort and return the receiver.
  2272. if (!from || !to) {
  2273. return receiver;
  2274. }
  2275. } else {
  2276. from = supplier;
  2277. to = receiver;
  2278. }
  2279. // If `overwrite` is truthy and `merge` is falsy, then we can skip a
  2280. // property existence check on each iteration and save some time.
  2281. alwaysOverwrite = overwrite && !merge;
  2282. if (whitelist) {
  2283. for (i = 0, len = whitelist.length; i < len; ++i) {
  2284. key = whitelist[i];
  2285. // We call `Object.prototype.hasOwnProperty` instead of calling
  2286. // `hasOwnProperty` on the object itself, since the object's
  2287. // `hasOwnProperty` method may have been overridden or removed.
  2288. // Also, some native objects don't implement a `hasOwnProperty`
  2289. // method.
  2290. if (!hasOwn.call(from, key)) {
  2291. continue;
  2292. }
  2293. // The `key in to` check here is (sadly) intentional for backwards
  2294. // compatibility reasons. It prevents undesired shadowing of
  2295. // prototype members on `to`.
  2296. exists = alwaysOverwrite ? false : key in to;
  2297. if (merge && exists && isObject(to[key], true)
  2298. && isObject(from[key], true)) {
  2299. // If we're in merge mode, and the key is present on both
  2300. // objects, and the value on both objects is either an object or
  2301. // an array (but not a function), then we recurse to merge the
  2302. // `from` value into the `to` value instead of overwriting it.
  2303. //
  2304. // Note: It's intentional that the whitelist isn't passed to the
  2305. // recursive call here. This is legacy behavior that lots of
  2306. // code still depends on.
  2307. Y.mix(to[key], from[key], overwrite, null, 0, merge);
  2308. } else if (overwrite || !exists) {
  2309. // We're not in merge mode, so we'll only copy the `from` value
  2310. // to the `to` value if we're in overwrite mode or if the
  2311. // current key doesn't exist on the `to` object.
  2312. to[key] = from[key];
  2313. }
  2314. }
  2315. } else {
  2316. for (key in from) {
  2317. // The code duplication here is for runtime performance reasons.
  2318. // Combining whitelist and non-whitelist operations into a single
  2319. // loop or breaking the shared logic out into a function both result
  2320. // in worse performance, and Y.mix is critical enough that the byte
  2321. // tradeoff is worth it.
  2322. if (!hasOwn.call(from, key)) {
  2323. continue;
  2324. }
  2325. // The `key in to` check here is (sadly) intentional for backwards
  2326. // compatibility reasons. It prevents undesired shadowing of
  2327. // prototype members on `to`.
  2328. exists = alwaysOverwrite ? false : key in to;
  2329. if (merge && exists && isObject(to[key], true)
  2330. && isObject(from[key], true)) {
  2331. Y.mix(to[key], from[key], overwrite, null, 0, merge);
  2332. } else if (overwrite || !exists) {
  2333. to[key] = from[key];
  2334. }
  2335. }
  2336. // If this is an IE browser with the JScript enumeration bug, force
  2337. // enumeration of the buggy properties by making a recursive call with
  2338. // the buggy properties as the whitelist.
  2339. if (Y.Object._hasEnumBug) {
  2340. Y.mix(to, from, overwrite, Y.Object._forceEnum, mode, merge);
  2341. }
  2342. }
  2343. return receiver;
  2344. };
  2345. /**
  2346. * The YUI module contains the components required for building the YUI
  2347. * seed file. This includes the script loading mechanism, a simple queue,
  2348. * and the core utilities for the library.
  2349. * @module yui
  2350. * @submodule yui-base
  2351. */
  2352. /**
  2353. * Adds utilities to the YUI instance for working with objects.
  2354. *
  2355. * @class Object
  2356. */
  2357. var hasOwn = Object.prototype.hasOwnProperty,
  2358. // If either MooTools or Prototype is on the page, then there's a chance that we
  2359. // can't trust "native" language features to actually be native. When this is
  2360. // the case, we take the safe route and fall back to our own non-native
  2361. // implementations.
  2362. win = Y.config.win,
  2363. unsafeNatives = win && !!(win.MooTools || win.Prototype),
  2364. UNDEFINED, // <-- Note the comma. We're still declaring vars.
  2365. /**
  2366. * Returns a new object that uses _obj_ as its prototype. This method wraps the
  2367. * native ES5 `Object.create()` method if available, but doesn't currently
  2368. * pass through `Object.create()`'s second argument (properties) in order to
  2369. * ensure compatibility with older browsers.
  2370. *
  2371. * @method ()
  2372. * @param {Object} obj Prototype object.
  2373. * @return {Object} New object using _obj_ as its prototype.
  2374. * @static
  2375. */
  2376. O = Y.Object = (!unsafeNatives && Object.create) ? function (obj) {
  2377. // We currently wrap the native Object.create instead of simply aliasing it
  2378. // to ensure consistency with our fallback shim, which currently doesn't
  2379. // support Object.create()'s second argument (properties). Once we have a
  2380. // safe fallback for the properties arg, we can stop wrapping
  2381. // Object.create().
  2382. return Object.create(obj);
  2383. } : (function () {
  2384. // Reusable constructor function for the Object.create() shim.
  2385. function F() {}
  2386. // The actual shim.
  2387. return function (obj) {
  2388. F.prototype = obj;
  2389. return new F();
  2390. };
  2391. }()),
  2392. /**
  2393. * Property names that IE doesn't enumerate in for..in loops, even when they
  2394. * should be enumerable. When `_hasEnumBug` is `true`, it's necessary to
  2395. * manually enumerate these properties.
  2396. *
  2397. * @property _forceEnum
  2398. * @type String[]
  2399. * @protected
  2400. * @static
  2401. */
  2402. forceEnum = O._forceEnum = [
  2403. 'hasOwnProperty',
  2404. 'isPrototypeOf',
  2405. 'propertyIsEnumerable',
  2406. 'toString',
  2407. 'toLocaleString',
  2408. 'valueOf'
  2409. ],
  2410. /**
  2411. * `true` if this browser has the JScript enumeration bug that prevents
  2412. * enumeration of the properties named in the `_forceEnum` array, `false`
  2413. * otherwise.
  2414. *
  2415. * See:
  2416. * - <https://developer.mozilla.org/en/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug>
  2417. * - <http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation>
  2418. *
  2419. * @property _hasEnumBug
  2420. * @type Boolean
  2421. * @protected
  2422. * @static
  2423. */
  2424. hasEnumBug = O._hasEnumBug = !{valueOf: 0}.propertyIsEnumerable('valueOf'),
  2425. /**
  2426. * `true` if this browser incorrectly considers the `prototype` property of
  2427. * functions to be enumerable. Currently known to affect Opera 11.50.
  2428. *
  2429. * @property _hasProtoEnumBug
  2430. * @type Boolean
  2431. * @protected
  2432. * @static
  2433. */
  2434. hasProtoEnumBug = O._hasProtoEnumBug = (function () {}).propertyIsEnumerable('prototype'),
  2435. /**
  2436. * Returns `true` if _key_ exists on _obj_, `false` if _key_ doesn't exist or
  2437. * exists only on _obj_'s prototype. This is essentially a safer version of
  2438. * `obj.hasOwnProperty()`.
  2439. *
  2440. * @method owns
  2441. * @param {Object} obj Object to test.
  2442. * @param {String} key Property name to look for.
  2443. * @return {Boolean} `true` if _key_ exists on _obj_, `false` otherwise.
  2444. * @static
  2445. */
  2446. owns = O.owns = function (obj, key) {
  2447. return !!obj && hasOwn.call(obj, key);
  2448. }; // <-- End of var declarations.
  2449. /**
  2450. * Alias for `owns()`.
  2451. *
  2452. * @method hasKey
  2453. * @param {Object} obj Object to test.
  2454. * @param {String} key Property name to look for.
  2455. * @return {Boolean} `true` if _key_ exists on _obj_, `false` otherwise.
  2456. * @static
  2457. */
  2458. O.hasKey = owns;
  2459. /**
  2460. * Returns an array containing the object's enumerable keys. Does not include
  2461. * prototype keys or non-enumerable keys.
  2462. *
  2463. * Note that keys are returned in enumeration order (that is, in the same order
  2464. * that they would be enumerated by a `for-in` loop), which may not be the same
  2465. * as the order in which they were defined.
  2466. *
  2467. * This method is an alias for the native ES5 `Object.keys()` method if
  2468. * available.
  2469. *
  2470. * @example
  2471. *
  2472. * Y.Object.keys({a: 'foo', b: 'bar', c: 'baz'});
  2473. * // => ['a', 'b', 'c']
  2474. *
  2475. * @method keys
  2476. * @param {Object} obj An object.
  2477. * @return {String[]} Array of keys.
  2478. * @static
  2479. */
  2480. O.keys = (!unsafeNatives && Object.keys) || function (obj) {
  2481. if (!Y.Lang.isObject(obj)) {
  2482. throw new TypeError('Object.keys called on a non-object');
  2483. }
  2484. var keys = [],
  2485. i, key, len;
  2486. if (hasProtoEnumBug && typeof obj === 'function') {
  2487. for (key in obj) {
  2488. if (owns(obj, key) && key !== 'prototype') {
  2489. keys.push(key);
  2490. }
  2491. }
  2492. } else {
  2493. for (key in obj) {
  2494. if (owns(obj, key)) {
  2495. keys.push(key);
  2496. }
  2497. }
  2498. }
  2499. if (hasEnumBug) {
  2500. for (i = 0, len = forceEnum.length; i < len; ++i) {
  2501. key = forceEnum[i];
  2502. if (owns(obj, key)) {
  2503. keys.push(key);
  2504. }
  2505. }
  2506. }
  2507. return keys;
  2508. };
  2509. /**
  2510. * Returns an array containing the values of the object's enumerable keys.
  2511. *
  2512. * Note that values are returned in enumeration order (that is, in the same
  2513. * order that they would be enumerated by a `for-in` loop), which may not be the
  2514. * same as the order in which they were defined.
  2515. *
  2516. * @example
  2517. *
  2518. * Y.Object.values({a: 'foo', b: 'bar', c: 'baz'});
  2519. * // => ['foo', 'bar', 'baz']
  2520. *
  2521. * @method values
  2522. * @param {Object} obj An object.
  2523. * @return {Array} Array of values.
  2524. * @static
  2525. */
  2526. O.values = function (obj) {
  2527. var keys = O.keys(obj),
  2528. i = 0,
  2529. len = keys.length,
  2530. values = [];
  2531. for (; i < len; ++i) {
  2532. values.push(obj[keys[i]]);
  2533. }
  2534. return values;
  2535. };
  2536. /**
  2537. * Returns the number of enumerable keys owned by an object.
  2538. *
  2539. * @method size
  2540. * @param {Object} obj An object.
  2541. * @return {Number} The object's size.
  2542. * @static
  2543. */
  2544. O.size = function (obj) {
  2545. try {
  2546. return O.keys(obj).length;
  2547. } catch (ex) {
  2548. return 0; // Legacy behavior for non-objects.
  2549. }
  2550. };
  2551. /**
  2552. * Returns `true` if the object owns an enumerable property with the specified
  2553. * value.
  2554. *
  2555. * @method hasValue
  2556. * @param {Object} obj An object.
  2557. * @param {any} value The value to search for.
  2558. * @return {Boolean} `true` if _obj_ contains _value_, `false` otherwise.
  2559. * @static
  2560. */
  2561. O.hasValue = function (obj, value) {
  2562. return Y.Array.indexOf(O.values(obj), value) > -1;
  2563. };
  2564. /**
  2565. * Executes a function on each enumerable property in _obj_. The function
  2566. * receives the value, the key, and the object itself as parameters (in that
  2567. * order).
  2568. *
  2569. * By default, only properties owned by _obj_ are enumerated. To include
  2570. * prototype properties, set the _proto_ parameter to `true`.
  2571. *
  2572. * @method each
  2573. * @param {Object} obj Object to enumerate.
  2574. * @param {Function} fn Function to execute on each enumerable property.
  2575. * @param {mixed} fn.value Value of the current property.
  2576. * @param {String} fn.key Key of the current property.
  2577. * @param {Object} fn.obj Object being enumerated.
  2578. * @param {Object} [thisObj] `this` object to use when calling _fn_.
  2579. * @param {Boolean} [proto=false] Include prototype properties.
  2580. * @return {YUI} the YUI instance.
  2581. * @chainable
  2582. * @static
  2583. */
  2584. O.each = function (obj, fn, thisObj, proto) {
  2585. var key;
  2586. for (key in obj) {
  2587. if (proto || owns(obj, key)) {
  2588. fn.call(thisObj || Y, obj[key], key, obj);
  2589. }
  2590. }
  2591. return Y;
  2592. };
  2593. /**
  2594. * Executes a function on each enumerable property in _obj_, but halts if the
  2595. * function returns a truthy value. The function receives the value, the key,
  2596. * and the object itself as paramters (in that order).
  2597. *
  2598. * By default, only properties owned by _obj_ are enumerated. To include
  2599. * prototype properties, set the _proto_ parameter to `true`.
  2600. *
  2601. * @method some
  2602. * @param {Object} obj Object to enumerate.
  2603. * @param {Function} fn Function to execute on each enumerable property.
  2604. * @param {mixed} fn.value Value of the current property.
  2605. * @param {String} fn.key Key of the current property.
  2606. * @param {Object} fn.obj Object being enumerated.
  2607. * @param {Object} [thisObj] `this` object to use when calling _fn_.
  2608. * @param {Boolean} [proto=false] Include prototype properties.
  2609. * @return {Boolean} `true` if any execution of _fn_ returns a truthy value,
  2610. * `false` otherwise.
  2611. * @static
  2612. */
  2613. O.some = function (obj, fn, thisObj, proto) {
  2614. var key;
  2615. for (key in obj) {
  2616. if (proto || owns(obj, key)) {
  2617. if (fn.call(thisObj || Y, obj[key], key, obj)) {
  2618. return true;
  2619. }
  2620. }
  2621. }
  2622. return false;
  2623. };
  2624. /**
  2625. * Retrieves the sub value at the provided path,
  2626. * from the value object provided.
  2627. *
  2628. * @method getValue
  2629. * @static
  2630. * @param o The object from which to extract the property value.
  2631. * @param path {Array} A path array, specifying the object traversal path
  2632. * from which to obtain the sub value.
  2633. * @return {Any} The value stored in the path, undefined if not found,
  2634. * undefined if the source is not an object. Returns the source object
  2635. * if an empty path is provided.
  2636. */
  2637. O.getValue = function(o, path) {
  2638. if (!Y.Lang.isObject(o)) {
  2639. return UNDEFINED;
  2640. }
  2641. var i,
  2642. p = Y.Array(path),
  2643. l = p.length;
  2644. for (i = 0; o !== UNDEFINED && i < l; i++) {
  2645. o = o[p[i]];
  2646. }
  2647. return o;
  2648. };
  2649. /**
  2650. * Sets the sub-attribute value at the provided path on the
  2651. * value object. Returns the modified value object, or
  2652. * undefined if the path is invalid.
  2653. *
  2654. * @method setValue
  2655. * @static
  2656. * @param o The object on which to set the sub value.
  2657. * @param path {Array} A path array, specifying the object traversal path
  2658. * at which to set the sub value.
  2659. * @param val {Any} The new value for the sub-attribute.
  2660. * @return {Object} The modified object, with the new sub value set, or
  2661. * undefined, if the path was invalid.
  2662. */
  2663. O.setValue = function(o, path, val) {
  2664. var i,
  2665. p = Y.Array(path),
  2666. leafIdx = p.length - 1,
  2667. ref = o;
  2668. if (leafIdx >= 0) {
  2669. for (i = 0; ref !== UNDEFINED && i < leafIdx; i++) {
  2670. ref = ref[p[i]];
  2671. }
  2672. if (ref !== UNDEFINED) {
  2673. ref[p[i]] = val;
  2674. } else {
  2675. return UNDEFINED;
  2676. }
  2677. }
  2678. return o;
  2679. };
  2680. /**
  2681. * Returns `true` if the object has no enumerable properties of its own.
  2682. *
  2683. * @method isEmpty
  2684. * @param {Object} obj An object.
  2685. * @return {Boolean} `true` if the object is empty.
  2686. * @static
  2687. * @since 3.2.0
  2688. */
  2689. O.isEmpty = function (obj) {
  2690. return !O.keys(obj).length;
  2691. };
  2692. /**
  2693. * The YUI module contains the components required for building the YUI seed
  2694. * file. This includes the script loading mechanism, a simple queue, and the
  2695. * core utilities for the library.
  2696. * @module yui
  2697. * @submodule yui-base
  2698. */
  2699. /**
  2700. * YUI user agent detection.
  2701. * Do not fork for a browser if it can be avoided. Use feature detection when
  2702. * you can. Use the user agent as a last resort. For all fields listed
  2703. * as @type float, UA stores a version number for the browser engine,
  2704. * 0 otherwise. This value may or may not map to the version number of
  2705. * the browser using the engine. The value is presented as a float so
  2706. * that it can easily be used for boolean evaluation as well as for
  2707. * looking for a particular range of versions. Because of this,
  2708. * some of the granularity of the version info may be lost. The fields that
  2709. * are @type string default to null. The API docs list the values that
  2710. * these fields can have.
  2711. * @class UA
  2712. * @static
  2713. */
  2714. /**
  2715. * Static method on `YUI.Env` for parsing a UA string. Called at instantiation
  2716. * to populate `Y.UA`.
  2717. *
  2718. * @static
  2719. * @method parseUA
  2720. * @param {String} [subUA=navigator.userAgent] UA string to parse
  2721. * @returns {Object} The Y.UA object
  2722. */
  2723. YUI.Env.parseUA = function(subUA) {
  2724. var numberify = function(s) {
  2725. var c = 0;
  2726. return parseFloat(s.replace(/\./g, function() {
  2727. return (c++ == 1) ? '' : '.';
  2728. }));
  2729. },
  2730. win = Y.config.win,
  2731. nav = win && win.navigator,
  2732. o = {
  2733. /**
  2734. * Internet Explorer version number or 0. Example: 6
  2735. * @property ie
  2736. * @type float
  2737. * @static
  2738. */
  2739. ie: 0,
  2740. /**
  2741. * Opera version number or 0. Example: 9.2
  2742. * @property opera
  2743. * @type float
  2744. * @static
  2745. */
  2746. opera: 0,
  2747. /**
  2748. * Gecko engine revision number. Will evaluate to 1 if Gecko
  2749. * is detected but the revision could not be found. Other browsers
  2750. * will be 0. Example: 1.8
  2751. * <pre>
  2752. * Firefox 1.0.0.4: 1.7.8 <-- Reports 1.7
  2753. * Firefox 1.5.0.9: 1.8.0.9 <-- 1.8
  2754. * Firefox 2.0.0.3: 1.8.1.3 <-- 1.81
  2755. * Firefox 3.0 <-- 1.9
  2756. * Firefox 3.5 <-- 1.91
  2757. * </pre>
  2758. * @property gecko
  2759. * @type float
  2760. * @static
  2761. */
  2762. gecko: 0,
  2763. /**
  2764. * AppleWebKit version. KHTML browsers that are not WebKit browsers
  2765. * will evaluate to 1, other browsers 0. Example: 418.9
  2766. * <pre>
  2767. * Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the
  2768. * latest available for Mac OSX 10.3.
  2769. * Safari 2.0.2: 416 <-- hasOwnProperty introduced
  2770. * Safari 2.0.4: 418 <-- preventDefault fixed
  2771. * Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run
  2772. * different versions of webkit
  2773. * Safari 2.0.4 (419.3): 419 <-- Tiger installations that have been
  2774. * updated, but not updated
  2775. * to the latest patch.
  2776. * Webkit 212 nightly: 522+ <-- Safari 3.0 precursor (with native
  2777. * SVG and many major issues fixed).
  2778. * Safari 3.0.4 (523.12) 523.12 <-- First Tiger release - automatic
  2779. * update from 2.x via the 10.4.11 OS patch.
  2780. * Webkit nightly 1/2008:525+ <-- Supports DOMContentLoaded event.
  2781. * yahoo.com user agent hack removed.
  2782. * </pre>
  2783. * http://en.wikipedia.org/wiki/Safari_version_history
  2784. * @property webkit
  2785. * @type float
  2786. * @static
  2787. */
  2788. webkit: 0,
  2789. /**
  2790. * Safari will be detected as webkit, but this property will also
  2791. * be populated with the Safari version number
  2792. * @property safari
  2793. * @type float
  2794. * @static
  2795. */
  2796. safari: 0,
  2797. /**
  2798. * Chrome will be detected as webkit, but this property will also
  2799. * be populated with the Chrome version number
  2800. * @property chrome
  2801. * @type float
  2802. * @static
  2803. */
  2804. chrome: 0,
  2805. /**
  2806. * The mobile property will be set to a string containing any relevant
  2807. * user agent information when a modern mobile browser is detected.
  2808. * Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series
  2809. * devices with the WebKit-based browser, and Opera Mini.
  2810. * @property mobile
  2811. * @type string
  2812. * @default null
  2813. * @static
  2814. */
  2815. mobile: null,
  2816. /**
  2817. * Adobe AIR version number or 0. Only populated if webkit is detected.
  2818. * Example: 1.0
  2819. * @property air
  2820. * @type float
  2821. */
  2822. air: 0,
  2823. /**
  2824. * Detects Apple iPad's OS version
  2825. * @property ipad
  2826. * @type float
  2827. * @static
  2828. */
  2829. ipad: 0,
  2830. /**
  2831. * Detects Apple iPhone's OS version
  2832. * @property iphone
  2833. * @type float
  2834. * @static
  2835. */
  2836. iphone: 0,
  2837. /**
  2838. * Detects Apples iPod's OS version
  2839. * @property ipod
  2840. * @type float
  2841. * @static
  2842. */
  2843. ipod: 0,
  2844. /**
  2845. * General truthy check for iPad, iPhone or iPod
  2846. * @property ios
  2847. * @type float
  2848. * @default null
  2849. * @static
  2850. */
  2851. ios: null,
  2852. /**
  2853. * Detects Googles Android OS version
  2854. * @property android
  2855. * @type float
  2856. * @static
  2857. */
  2858. android: 0,
  2859. /**
  2860. * Detects Palms WebOS version
  2861. * @property webos
  2862. * @type float
  2863. * @static
  2864. */
  2865. webos: 0,
  2866. /**
  2867. * Google Caja version number or 0.
  2868. * @property caja
  2869. * @type float
  2870. */
  2871. caja: nav && nav.cajaVersion,
  2872. /**
  2873. * Set to true if the page appears to be in SSL
  2874. * @property secure
  2875. * @type boolean
  2876. * @static
  2877. */
  2878. secure: false,
  2879. /**
  2880. * The operating system. Currently only detecting windows or macintosh
  2881. * @property os
  2882. * @type string
  2883. * @default null
  2884. * @static
  2885. */
  2886. os: null
  2887. },
  2888. ua = subUA || nav && nav.userAgent,
  2889. loc = win && win.location,
  2890. href = loc && loc.href,
  2891. m;
  2892. /**
  2893. * The User Agent string that was parsed
  2894. * @property userAgent
  2895. * @type String
  2896. * @static
  2897. */
  2898. o.userAgent = ua;
  2899. o.secure = href && (href.toLowerCase().indexOf('https') === 0);
  2900. if (ua) {
  2901. if ((/windows|win32/i).test(ua)) {
  2902. o.os = 'windows';
  2903. } else if ((/macintosh/i).test(ua)) {
  2904. o.os = 'macintosh';
  2905. } else if ((/rhino/i).test(ua)) {
  2906. o.os = 'rhino';
  2907. }
  2908. // Modern KHTML browsers should qualify as Safari X-Grade
  2909. if ((/KHTML/).test(ua)) {
  2910. o.webkit = 1;
  2911. }
  2912. // Modern WebKit browsers are at least X-Grade
  2913. m = ua.match(/AppleWebKit\/([^\s]*)/);
  2914. if (m && m[1]) {
  2915. o.webkit = numberify(m[1]);
  2916. o.safari = o.webkit;
  2917. // Mobile browser check
  2918. if (/ Mobile\//.test(ua)) {
  2919. o.mobile = 'Apple'; // iPhone or iPod Touch
  2920. m = ua.match(/OS ([^\s]*)/);
  2921. if (m && m[1]) {
  2922. m = numberify(m[1].replace('_', '.'));
  2923. }
  2924. o.ios = m;
  2925. o.ipad = o.ipod = o.iphone = 0;
  2926. m = ua.match(/iPad|iPod|iPhone/);
  2927. if (m && m[0]) {
  2928. o[m[0].toLowerCase()] = o.ios;
  2929. }
  2930. } else {
  2931. m = ua.match(/NokiaN[^\/]*|webOS\/\d\.\d/);
  2932. if (m) {
  2933. // Nokia N-series, webOS, ex: NokiaN95
  2934. o.mobile = m[0];
  2935. }
  2936. if (/webOS/.test(ua)) {
  2937. o.mobile = 'WebOS';
  2938. m = ua.match(/webOS\/([^\s]*);/);
  2939. if (m && m[1]) {
  2940. o.webos = numberify(m[1]);
  2941. }
  2942. }
  2943. if (/ Android/.test(ua)) {
  2944. if (/Mobile/.test(ua)) {
  2945. o.mobile = 'Android';
  2946. }
  2947. m = ua.match(/Android ([^\s]*);/);
  2948. if (m && m[1]) {
  2949. o.android = numberify(m[1]);
  2950. }
  2951. }
  2952. }
  2953. m = ua.match(/Chrome\/([^\s]*)/);
  2954. if (m && m[1]) {
  2955. o.chrome = numberify(m[1]); // Chrome
  2956. o.safari = 0; //Reset safari back to 0
  2957. } else {
  2958. m = ua.match(/AdobeAIR\/([^\s]*)/);
  2959. if (m) {
  2960. o.air = m[0]; // Adobe AIR 1.0 or better
  2961. }
  2962. }
  2963. }
  2964. if (!o.webkit) { // not webkit
  2965. // @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr)
  2966. m = ua.match(/Opera[\s\/]([^\s]*)/);
  2967. if (m && m[1]) {
  2968. o.opera = numberify(m[1]);
  2969. m = ua.match(/Version\/([^\s]*)/);
  2970. if (m && m[1]) {
  2971. o.opera = numberify(m[1]); // opera 10+
  2972. }
  2973. m = ua.match(/Opera Mini[^;]*/);
  2974. if (m) {
  2975. o.mobile = m[0]; // ex: Opera Mini/2.0.4509/1316
  2976. }
  2977. } else { // not opera or webkit
  2978. m = ua.match(/MSIE\s([^;]*)/);
  2979. if (m && m[1]) {
  2980. o.ie = numberify(m[1]);
  2981. } else { // not opera, webkit, or ie
  2982. m = ua.match(/Gecko\/([^\s]*)/);
  2983. if (m) {
  2984. o.gecko = 1; // Gecko detected, look for revision
  2985. m = ua.match(/rv:([^\s\)]*)/);
  2986. if (m && m[1]) {
  2987. o.gecko = numberify(m[1]);
  2988. }
  2989. }
  2990. }
  2991. }
  2992. }
  2993. }
  2994. //It was a parsed UA, do not assign the global value.
  2995. if (!subUA) {
  2996. YUI.Env.UA = o;
  2997. }
  2998. return o;
  2999. };
  3000. Y.UA = YUI.Env.UA || YUI.Env.parseUA();
  3001. YUI.Env.aliases = {
  3002. "anim": ["anim-base","anim-color","anim-curve","anim-easing","anim-node-plugin","anim-scroll","anim-xy"],
  3003. "app": ["controller","model","model-list","view"],
  3004. "attribute": ["attribute-base","attribute-complex"],
  3005. "autocomplete": ["autocomplete-base","autocomplete-sources","autocomplete-list","autocomplete-plugin"],
  3006. "base": ["base-base","base-pluginhost","base-build"],
  3007. "cache": ["cache-base","cache-offline","cache-plugin"],
  3008. "collection": ["array-extras","arraylist","arraylist-add","arraylist-filter","array-invoke"],
  3009. "dataschema": ["dataschema-base","dataschema-json","dataschema-xml","dataschema-array","dataschema-text"],
  3010. "datasource": ["datasource-local","datasource-io","datasource-get","datasource-function","datasource-cache","datasource-jsonschema","datasource-xmlschema","datasource-arrayschema","datasource-textschema","datasource-polling"],
  3011. "datatable": ["datatable-base","datatable-datasource","datatable-sort","datatable-scroll"],
  3012. "datatype": ["datatype-number","datatype-date","datatype-xml"],
  3013. "datatype-date": ["datatype-date-parse","datatype-date-format"],
  3014. "datatype-number": ["datatype-number-parse","datatype-number-format"],
  3015. "datatype-xml": ["datatype-xml-parse","datatype-xml-format"],
  3016. "dd": ["dd-ddm-base","dd-ddm","dd-ddm-drop","dd-drag","dd-proxy","dd-constrain","dd-drop","dd-scroll","dd-delegate"],
  3017. "dom": ["dom-base","dom-screen","dom-style","selector-native","selector"],
  3018. "editor": ["frame","selection","exec-command","editor-base","editor-para","editor-br","editor-bidi","editor-tab","createlink-base"],
  3019. "event": ["event-base","event-delegate","event-synthetic","event-mousewheel","event-mouseenter","event-key","event-focus","event-resize","event-hover","event-outside"],
  3020. "event-custom": ["event-custom-base","event-custom-complex"],
  3021. "event-gestures": ["event-flick","event-move"],
  3022. "highlight": ["highlight-base","highlight-accentfold"],
  3023. "history": ["history-base","history-hash","history-hash-ie","history-html5"],
  3024. "io": ["io-base","io-xdr","io-form","io-upload-iframe","io-queue"],
  3025. "json": ["json-parse","json-stringify"],
  3026. "loader": ["loader-base","loader-rollup","loader-yui3"],
  3027. "node": ["node-base","node-event-delegate","node-pluginhost","node-screen","node-style"],
  3028. "pluginhost": ["pluginhost-base","pluginhost-config"],
  3029. "querystring": ["querystring-parse","querystring-stringify"],
  3030. "recordset": ["recordset-base","recordset-sort","recordset-filter","recordset-indexer"],
  3031. "resize": ["resize-base","resize-proxy","resize-constrain"],
  3032. "slider": ["slider-base","slider-value-range","clickable-rail","range-slider"],
  3033. "text": ["text-accentfold","text-wordbreak"],
  3034. "widget": ["widget-base","widget-htmlparser","widget-uievents","widget-skin"]
  3035. };
  3036. }, '3.4.0' );
  3037. YUI.add('get', function(Y) {
  3038. /**
  3039. * Provides a mechanism to fetch remote resources and
  3040. * insert them into a document.
  3041. * @module yui
  3042. * @submodule get
  3043. */
  3044. /**
  3045. * Fetches and inserts one or more script or link nodes into the document
  3046. * @class Get
  3047. * @static
  3048. */
  3049. var ua = Y.UA,
  3050. L = Y.Lang,
  3051. TYPE_JS = 'text/javascript',
  3052. TYPE_CSS = 'text/css',
  3053. STYLESHEET = 'stylesheet',
  3054. SCRIPT = 'script',
  3055. AUTOPURGE = 'autopurge',
  3056. UTF8 = 'utf-8',
  3057. LINK = 'link',
  3058. ASYNC = 'async',
  3059. ALL = true,
  3060. // FireFox does not support the onload event for link nodes, so
  3061. // there is no way to make the css requests synchronous. This means
  3062. // that the css rules in multiple files could be applied out of order
  3063. // in this browser if a later request returns before an earlier one.
  3064. // Safari too.
  3065. ONLOAD_SUPPORTED = {
  3066. script: ALL,
  3067. css: !(ua.webkit || ua.gecko)
  3068. },
  3069. /**
  3070. * hash of queues to manage multiple requests
  3071. * @property queues
  3072. * @private
  3073. */
  3074. queues = {},
  3075. /**
  3076. * queue index used to generate transaction ids
  3077. * @property qidx
  3078. * @type int
  3079. * @private
  3080. */
  3081. qidx = 0,
  3082. /**
  3083. * interal property used to prevent multiple simultaneous purge
  3084. * processes
  3085. * @property purging
  3086. * @type boolean
  3087. * @private
  3088. */
  3089. purging,
  3090. /**
  3091. * Clear timeout state
  3092. *
  3093. * @method _clearTimeout
  3094. * @param {Object} q Queue data
  3095. * @private
  3096. */
  3097. _clearTimeout = function(q) {
  3098. var timer = q.timer;
  3099. if (timer) {
  3100. clearTimeout(timer);
  3101. q.timer = null;
  3102. }
  3103. },
  3104. /**
  3105. * Generates an HTML element, this is not appended to a document
  3106. * @method _node
  3107. * @param {string} type the type of element.
  3108. * @param {Object} attr the fixed set of attribute for the type.
  3109. * @param {Object} custAttrs optional Any custom attributes provided by the user.
  3110. * @param {Window} win optional window to create the element in.
  3111. * @return {HTMLElement} the generated node.
  3112. * @private
  3113. */
  3114. _node = function(type, attr, custAttrs, win) {
  3115. var w = win || Y.config.win,
  3116. d = w.document,
  3117. n = d.createElement(type),
  3118. i;
  3119. if (custAttrs) {
  3120. Y.mix(attr, custAttrs);
  3121. }
  3122. for (i in attr) {
  3123. if (attr[i] && attr.hasOwnProperty(i)) {
  3124. n.setAttribute(i, attr[i]);
  3125. }
  3126. }
  3127. return n;
  3128. },
  3129. /**
  3130. * Generates a link node
  3131. * @method _linkNode
  3132. * @param {string} url the url for the css file.
  3133. * @param {Window} win optional window to create the node in.
  3134. * @param {object} attributes optional attributes collection to apply to the
  3135. * new node.
  3136. * @return {HTMLElement} the generated node.
  3137. * @private
  3138. */
  3139. _linkNode = function(url, win, attributes) {
  3140. return _node(LINK, {
  3141. id: Y.guid(),
  3142. type: TYPE_CSS,
  3143. rel: STYLESHEET,
  3144. href: url
  3145. }, attributes, win);
  3146. },
  3147. /**
  3148. * Generates a script node
  3149. * @method _scriptNode
  3150. * @param {string} url the url for the script file.
  3151. * @param {Window} win optional window to create the node in.
  3152. * @param {object} attributes optional attributes collection to apply to the
  3153. * new node.
  3154. * @return {HTMLElement} the generated node.
  3155. * @private
  3156. */
  3157. _scriptNode = function(url, win, attributes) {
  3158. return _node(SCRIPT, {
  3159. id: Y.guid(),
  3160. type: TYPE_JS,
  3161. src: url
  3162. }, attributes, win);
  3163. },
  3164. /**
  3165. * Returns the data payload for callback functions.
  3166. * @method _returnData
  3167. * @param {object} q the queue.
  3168. * @param {string} msg the result message.
  3169. * @param {string} result the status message from the request.
  3170. * @return {object} the state data from the request.
  3171. * @private
  3172. */
  3173. _returnData = function(q, msg, result) {
  3174. return {
  3175. tId: q.tId,
  3176. win: q.win,
  3177. data: q.data,
  3178. nodes: q.nodes,
  3179. msg: msg,
  3180. statusText: result,
  3181. purge: function() {
  3182. _purge(this.tId);
  3183. }
  3184. };
  3185. },
  3186. /**
  3187. * The transaction is finished
  3188. * @method _end
  3189. * @param {string} id the id of the request.
  3190. * @param {string} msg the result message.
  3191. * @param {string} result the status message from the request.
  3192. * @private
  3193. */
  3194. _end = function(id, msg, result) {
  3195. var q = queues[id],
  3196. onEnd = q && q.onEnd;
  3197. q.finished = true;
  3198. if (onEnd) {
  3199. onEnd.call(q.context, _returnData(q, msg, result));
  3200. }
  3201. },
  3202. /**
  3203. * The request failed, execute fail handler with whatever
  3204. * was accomplished. There isn't a failure case at the
  3205. * moment unless you count aborted transactions
  3206. * @method _fail
  3207. * @param {string} id the id of the request
  3208. * @private
  3209. */
  3210. _fail = function(id, msg) {
  3211. Y.log('get failure: ' + msg, 'warn', 'get');
  3212. var q = queues[id],
  3213. onFailure = q.onFailure;
  3214. _clearTimeout(q);
  3215. if (onFailure) {
  3216. onFailure.call(q.context, _returnData(q, msg));
  3217. }
  3218. _end(id, msg, 'failure');
  3219. },
  3220. /**
  3221. * Abort the transaction
  3222. *
  3223. * @method _abort
  3224. * @param {Object} id
  3225. * @private
  3226. */
  3227. _abort = function(id) {
  3228. _fail(id, 'transaction ' + id + ' was aborted');
  3229. },
  3230. /**
  3231. * The request is complete, so executing the requester's callback
  3232. * @method _complete
  3233. * @param {string} id the id of the request.
  3234. * @private
  3235. */
  3236. _complete = function(id) {
  3237. Y.log("Finishing transaction " + id, "info", "get");
  3238. var q = queues[id],
  3239. onSuccess = q.onSuccess;
  3240. _clearTimeout(q);
  3241. if (q.aborted) {
  3242. _abort(id);
  3243. } else {
  3244. if (onSuccess) {
  3245. onSuccess.call(q.context, _returnData(q));
  3246. }
  3247. // 3.3.0 had undefined msg for this path.
  3248. _end(id, undefined, 'OK');
  3249. }
  3250. },
  3251. /**
  3252. * Get node reference, from string
  3253. *
  3254. * @method _getNodeRef
  3255. * @param {String|HTMLElement} nId The node id to find. If an HTMLElement is passed in, it will be returned.
  3256. * @param {String} tId Queue id, used to determine document for queue
  3257. * @private
  3258. */
  3259. _getNodeRef = function(nId, tId) {
  3260. var q = queues[tId],
  3261. n = (L.isString(nId)) ? q.win.document.getElementById(nId) : nId;
  3262. if (!n) {
  3263. _fail(tId, 'target node not found: ' + nId);
  3264. }
  3265. return n;
  3266. },
  3267. /**
  3268. * Removes the nodes for the specified queue
  3269. * @method _purge
  3270. * @param {string} tId the transaction id.
  3271. * @private
  3272. */
  3273. _purge = function(tId) {
  3274. var nodes, doc, parent, sibling, node, attr, insertBefore,
  3275. i, l,
  3276. q = queues[tId];
  3277. if (q) {
  3278. nodes = q.nodes;
  3279. l = nodes.length;
  3280. // TODO: Why is node.parentNode undefined? Which forces us To Do this...
  3281. /*
  3282. doc = q.win.document;
  3283. parent = doc.getElementsByTagName('head')[0];
  3284. insertBefore = q.insertBefore || doc.getElementsByTagName('base')[0];
  3285. if (insertBefore) {
  3286. sibling = _getNodeRef(insertBefore, tId);
  3287. if (sibling) {
  3288. parent = sibling.parentNode;
  3289. }
  3290. }
  3291. */
  3292. for (i = 0; i < l; i++) {
  3293. node = nodes[i];
  3294. parent = node.parentNode;
  3295. if (node.clearAttributes) {
  3296. node.clearAttributes();
  3297. } else {
  3298. // This destroys parentNode ref, so we hold onto it above first.
  3299. for (attr in node) {
  3300. if (node.hasOwnProperty(attr)) {
  3301. delete node[attr];
  3302. }
  3303. }
  3304. }
  3305. parent.removeChild(node);
  3306. }
  3307. }
  3308. q.nodes = [];
  3309. },
  3310. /**
  3311. * Progress callback
  3312. *
  3313. * @method _progress
  3314. * @param {string} id The id of the request.
  3315. * @param {string} The url which just completed.
  3316. * @private
  3317. */
  3318. _progress = function(id, url) {
  3319. var q = queues[id],
  3320. onProgress = q.onProgress,
  3321. o;
  3322. if (onProgress) {
  3323. o = _returnData(q);
  3324. o.url = url;
  3325. onProgress.call(q.context, o);
  3326. }
  3327. },
  3328. /**
  3329. * Timeout detected
  3330. * @method _timeout
  3331. * @param {string} id the id of the request.
  3332. * @private
  3333. */
  3334. _timeout = function(id) {
  3335. Y.log('Timeout ' + id, 'info', 'get');
  3336. var q = queues[id],
  3337. onTimeout = q.onTimeout;
  3338. if (onTimeout) {
  3339. onTimeout.call(q.context, _returnData(q));
  3340. }
  3341. _end(id, 'timeout', 'timeout');
  3342. },
  3343. /**
  3344. * onload callback
  3345. * @method _loaded
  3346. * @param {string} id the id of the request.
  3347. * @return {string} the result.
  3348. * @private
  3349. */
  3350. _loaded = function(id, url) {
  3351. var q = queues[id],
  3352. sync = (q && !q.async);
  3353. if (!q) {
  3354. return;
  3355. }
  3356. if (sync) {
  3357. _clearTimeout(q);
  3358. }
  3359. _progress(id, url);
  3360. // TODO: Cleaning up flow to have a consistent end point
  3361. // !q.finished check is for the async case,
  3362. // where scripts may still be loading when we've
  3363. // already aborted. Ideally there should be a single path
  3364. // for this.
  3365. if (!q.finished) {
  3366. if (q.aborted) {
  3367. _abort(id);
  3368. } else {
  3369. if ((--q.remaining) === 0) {
  3370. _complete(id);
  3371. } else if (sync) {
  3372. _next(id);
  3373. }
  3374. }
  3375. }
  3376. },
  3377. /**
  3378. * Detects when a node has been loaded. In the case of
  3379. * script nodes, this does not guarantee that contained
  3380. * script is ready to use.
  3381. * @method _trackLoad
  3382. * @param {string} type the type of node to track.
  3383. * @param {HTMLElement} n the node to track.
  3384. * @param {string} id the id of the request.
  3385. * @param {string} url the url that is being loaded.
  3386. * @private
  3387. */
  3388. _trackLoad = function(type, n, id, url) {
  3389. // TODO: Can we massage this to use ONLOAD_SUPPORTED[type]?
  3390. // IE supports the readystatechange event for script and css nodes
  3391. // Opera only for script nodes. Opera support onload for script
  3392. // nodes, but this doesn't fire when there is a load failure.
  3393. // The onreadystatechange appears to be a better way to respond
  3394. // to both success and failure.
  3395. if (ua.ie) {
  3396. n.onreadystatechange = function() {
  3397. var rs = this.readyState;
  3398. if ('loaded' === rs || 'complete' === rs) {
  3399. // Y.log(id + " onreadstatechange " + url, "info", "get");
  3400. n.onreadystatechange = null;
  3401. _loaded(id, url);
  3402. }
  3403. };
  3404. } else if (ua.webkit) {
  3405. // webkit prior to 3.x is no longer supported
  3406. if (type === SCRIPT) {
  3407. // Safari 3.x supports the load event for script nodes (DOM2)
  3408. n.addEventListener('load', function() {
  3409. _loaded(id, url);
  3410. }, false);
  3411. }
  3412. } else {
  3413. // FireFox and Opera support onload (but not DOM2 in FF) handlers for
  3414. // script nodes. Opera, but not FF, supports the onload event for link nodes.
  3415. n.onload = function() {
  3416. // Y.log(id + " onload " + url, "info", "get");
  3417. _loaded(id, url);
  3418. };
  3419. n.onerror = function(e) {
  3420. _fail(id, e + ': ' + url);
  3421. };
  3422. }
  3423. },
  3424. _insertInDoc = function(node, id, win) {
  3425. // Add it to the head or insert it before 'insertBefore'.
  3426. // Work around IE bug if there is a base tag.
  3427. var q = queues[id],
  3428. doc = win.document,
  3429. insertBefore = q.insertBefore || doc.getElementsByTagName('base')[0],
  3430. sibling;
  3431. if (insertBefore) {
  3432. sibling = _getNodeRef(insertBefore, id);
  3433. if (sibling) {
  3434. Y.log('inserting before: ' + insertBefore, 'info', 'get');
  3435. sibling.parentNode.insertBefore(node, sibling);
  3436. }
  3437. } else {
  3438. // 3.3.0 assumed head is always around.
  3439. doc.getElementsByTagName('head')[0].appendChild(node);
  3440. }
  3441. },
  3442. /**
  3443. * Loads the next item for a given request
  3444. * @method _next
  3445. * @param {string} id the id of the request.
  3446. * @return {string} the result.
  3447. * @private
  3448. */
  3449. _next = function(id) {
  3450. // Assigning out here for readability
  3451. var q = queues[id],
  3452. type = q.type,
  3453. attrs = q.attributes,
  3454. win = q.win,
  3455. timeout = q.timeout,
  3456. node,
  3457. url;
  3458. if (q.url.length > 0) {
  3459. url = q.url.shift();
  3460. Y.log('attempting to load ' + url, 'info', 'get');
  3461. // !q.timer ensures that this only happens once for async
  3462. if (timeout && !q.timer) {
  3463. q.timer = setTimeout(function() {
  3464. _timeout(id);
  3465. }, timeout);
  3466. }
  3467. if (type === SCRIPT) {
  3468. node = _scriptNode(url, win, attrs);
  3469. } else {
  3470. node = _linkNode(url, win, attrs);
  3471. }
  3472. // add the node to the queue so we can return it in the callback
  3473. q.nodes.push(node);
  3474. _trackLoad(type, node, id, url);
  3475. _insertInDoc(node, id, win);
  3476. if (!ONLOAD_SUPPORTED[type]) {
  3477. _loaded(id, url);
  3478. }
  3479. if (q.async) {
  3480. // For sync, the _next call is chained in _loaded
  3481. _next(id);
  3482. }
  3483. }
  3484. },
  3485. /**
  3486. * Removes processed queues and corresponding nodes
  3487. * @method _autoPurge
  3488. * @private
  3489. */
  3490. _autoPurge = function() {
  3491. if (purging) {
  3492. return;
  3493. }
  3494. purging = true;
  3495. var i, q;
  3496. for (i in queues) {
  3497. if (queues.hasOwnProperty(i)) {
  3498. q = queues[i];
  3499. if (q.autopurge && q.finished) {
  3500. _purge(q.tId);
  3501. delete queues[i];
  3502. }
  3503. }
  3504. }
  3505. purging = false;
  3506. },
  3507. /**
  3508. * Saves the state for the request and begins loading
  3509. * the requested urls
  3510. * @method queue
  3511. * @param {string} type the type of node to insert.
  3512. * @param {string} url the url to load.
  3513. * @param {object} opts the hash of options for this request.
  3514. * @return {object} transaction object.
  3515. * @private
  3516. */
  3517. _queue = function(type, url, opts) {
  3518. opts = opts || {};
  3519. var id = 'q' + (qidx++),
  3520. thresh = opts.purgethreshold || Y.Get.PURGE_THRESH,
  3521. q;
  3522. if (qidx % thresh === 0) {
  3523. _autoPurge();
  3524. }
  3525. // Merge to protect opts (grandfathered in).
  3526. q = queues[id] = Y.merge(opts);
  3527. // Avoid mix, merge overhead. Known set of props.
  3528. q.tId = id;
  3529. q.type = type;
  3530. q.url = url;
  3531. q.finished = false;
  3532. q.nodes = [];
  3533. q.win = q.win || Y.config.win;
  3534. q.context = q.context || q;
  3535. q.autopurge = (AUTOPURGE in q) ? q.autopurge : (type === SCRIPT) ? true : false;
  3536. q.attributes = q.attributes || {};
  3537. q.attributes.charset = opts.charset || q.attributes.charset || UTF8;
  3538. if (ASYNC in q && type === SCRIPT) {
  3539. q.attributes.async = q.async;
  3540. }
  3541. q.url = (L.isString(q.url)) ? [q.url] : q.url;
  3542. // TODO: Do we really need to account for this developer error?
  3543. // If the url is undefined, this is probably a trailing comma problem in IE.
  3544. if (!q.url[0]) {
  3545. q.url.shift();
  3546. Y.log('skipping empty url');
  3547. }
  3548. q.remaining = q.url.length;
  3549. _next(id);
  3550. return {
  3551. tId: id
  3552. };
  3553. };
  3554. Y.Get = {
  3555. /**
  3556. * The number of request required before an automatic purge.
  3557. * Can be configured via the 'purgethreshold' config
  3558. * @property PURGE_THRESH
  3559. * @static
  3560. * @type int
  3561. * @default 20
  3562. * @private
  3563. */
  3564. PURGE_THRESH: 20,
  3565. /**
  3566. * Abort a transaction
  3567. * @method abort
  3568. * @static
  3569. * @param {string|object} o Either the tId or the object returned from
  3570. * script() or css().
  3571. */
  3572. abort : function(o) {
  3573. var id = (L.isString(o)) ? o : o.tId,
  3574. q = queues[id];
  3575. if (q) {
  3576. Y.log('Aborting ' + id, 'info', 'get');
  3577. q.aborted = true;
  3578. }
  3579. },
  3580. /**
  3581. * Fetches and inserts one or more script nodes into the head
  3582. * of the current document or the document in a specified window.
  3583. *
  3584. * @method script
  3585. * @static
  3586. * @param {string|string[]} url the url or urls to the script(s).
  3587. * @param {object} opts Options:
  3588. * <dl>
  3589. * <dt>onSuccess</dt>
  3590. * <dd>
  3591. * callback to execute when the script(s) are finished loading
  3592. * The callback receives an object back with the following
  3593. * data:
  3594. * <dl>
  3595. * <dt>win</dt>
  3596. * <dd>the window the script(s) were inserted into</dd>
  3597. * <dt>data</dt>
  3598. * <dd>the data object passed in when the request was made</dd>
  3599. * <dt>nodes</dt>
  3600. * <dd>An array containing references to the nodes that were
  3601. * inserted</dd>
  3602. * <dt>purge</dt>
  3603. * <dd>A function that, when executed, will remove the nodes
  3604. * that were inserted</dd>
  3605. * <dt>
  3606. * </dl>
  3607. * </dd>
  3608. * <dt>onTimeout</dt>
  3609. * <dd>
  3610. * callback to execute when a timeout occurs.
  3611. * The callback receives an object back with the following
  3612. * data:
  3613. * <dl>
  3614. * <dt>win</dt>
  3615. * <dd>the window the script(s) were inserted into</dd>
  3616. * <dt>data</dt>
  3617. * <dd>the data object passed in when the request was made</dd>
  3618. * <dt>nodes</dt>
  3619. * <dd>An array containing references to the nodes that were
  3620. * inserted</dd>
  3621. * <dt>purge</dt>
  3622. * <dd>A function that, when executed, will remove the nodes
  3623. * that were inserted</dd>
  3624. * <dt>
  3625. * </dl>
  3626. * </dd>
  3627. * <dt>onEnd</dt>
  3628. * <dd>a function that executes when the transaction finishes,
  3629. * regardless of the exit path</dd>
  3630. * <dt>onFailure</dt>
  3631. * <dd>
  3632. * callback to execute when the script load operation fails
  3633. * The callback receives an object back with the following
  3634. * data:
  3635. * <dl>
  3636. * <dt>win</dt>
  3637. * <dd>the window the script(s) were inserted into</dd>
  3638. * <dt>data</dt>
  3639. * <dd>the data object passed in when the request was made</dd>
  3640. * <dt>nodes</dt>
  3641. * <dd>An array containing references to the nodes that were
  3642. * inserted successfully</dd>
  3643. * <dt>purge</dt>
  3644. * <dd>A function that, when executed, will remove any nodes
  3645. * that were inserted</dd>
  3646. * <dt>
  3647. * </dl>
  3648. * </dd>
  3649. * <dt>onProgress</dt>
  3650. * <dd>callback to execute when each individual file is done loading
  3651. * (useful when passing in an array of js files). Receives the same
  3652. * payload as onSuccess, with the addition of a <code>url</code>
  3653. * property, which identifies the file which was loaded.</dd>
  3654. * <dt>async</dt>
  3655. * <dd>
  3656. * <p>When passing in an array of JS files, setting this flag to true
  3657. * will insert them into the document in parallel, as opposed to the
  3658. * default behavior, which is to chain load them serially. It will also
  3659. * set the async attribute on the script node to true.</p>
  3660. * <p>Setting async:true
  3661. * will lead to optimal file download performance allowing the browser to
  3662. * download multiple scripts in parallel, and execute them as soon as they
  3663. * are available.</p>
  3664. * <p>Note that async:true does not guarantee execution order of the
  3665. * scripts being downloaded. They are executed in whichever order they
  3666. * are received.</p>
  3667. * </dd>
  3668. * <dt>context</dt>
  3669. * <dd>the execution context for the callbacks</dd>
  3670. * <dt>win</dt>
  3671. * <dd>a window other than the one the utility occupies</dd>
  3672. * <dt>autopurge</dt>
  3673. * <dd>
  3674. * setting to true will let the utilities cleanup routine purge
  3675. * the script once loaded
  3676. * </dd>
  3677. * <dt>purgethreshold</dt>
  3678. * <dd>
  3679. * The number of transaction before autopurge should be initiated
  3680. * </dd>
  3681. * <dt>data</dt>
  3682. * <dd>
  3683. * data that is supplied to the callback when the script(s) are
  3684. * loaded.
  3685. * </dd>
  3686. * <dt>insertBefore</dt>
  3687. * <dd>node or node id that will become the new node's nextSibling.
  3688. * If this is not specified, nodes will be inserted before a base
  3689. * tag should it exist. Otherwise, the nodes will be appended to the
  3690. * end of the document head.</dd>
  3691. * </dl>
  3692. * <dt>charset</dt>
  3693. * <dd>Node charset, default utf-8 (deprecated, use the attributes
  3694. * config)</dd>
  3695. * <dt>attributes</dt>
  3696. * <dd>An object literal containing additional attributes to add to
  3697. * the link tags</dd>
  3698. * <dt>timeout</dt>
  3699. * <dd>Number of milliseconds to wait before aborting and firing
  3700. * the timeout event</dd>
  3701. * <pre>
  3702. * &nbsp; Y.Get.script(
  3703. * &nbsp; ["http://yui.yahooapis.com/2.5.2/build/yahoo/yahoo-min.js",
  3704. * &nbsp; "http://yui.yahooapis.com/2.5.2/build/event/event-min.js"],
  3705. * &nbsp; &#123;
  3706. * &nbsp; onSuccess: function(o) &#123;
  3707. * &nbsp; this.log("won't cause error because Y is the context");
  3708. * &nbsp; Y.log(o.data); // foo
  3709. * &nbsp; Y.log(o.nodes.length === 2) // true
  3710. * &nbsp; // o.purge(); // optionally remove the script nodes
  3711. * &nbsp; // immediately
  3712. * &nbsp; &#125;,
  3713. * &nbsp; onFailure: function(o) &#123;
  3714. * &nbsp; Y.log("transaction failed");
  3715. * &nbsp; &#125;,
  3716. * &nbsp; onTimeout: function(o) &#123;
  3717. * &nbsp; Y.log("transaction timed out");
  3718. * &nbsp; &#125;,
  3719. * &nbsp; data: "foo",
  3720. * &nbsp; timeout: 10000, // 10 second timeout
  3721. * &nbsp; context: Y, // make the YUI instance
  3722. * &nbsp; // win: otherframe // target another window/frame
  3723. * &nbsp; autopurge: true // allow the utility to choose when to
  3724. * &nbsp; // remove the nodes
  3725. * &nbsp; purgetheshold: 1 // purge previous transaction before
  3726. * &nbsp; // next transaction
  3727. * &nbsp; &#125;);.
  3728. * </pre>
  3729. * @return {tId: string} an object containing info about the
  3730. * transaction.
  3731. */
  3732. script: function(url, opts) {
  3733. return _queue(SCRIPT, url, opts);
  3734. },
  3735. /**
  3736. * Fetches and inserts one or more css link nodes into the
  3737. * head of the current document or the document in a specified
  3738. * window.
  3739. * @method css
  3740. * @static
  3741. * @param {string} url the url or urls to the css file(s).
  3742. * @param {object} opts Options:
  3743. * <dl>
  3744. * <dt>onSuccess</dt>
  3745. * <dd>
  3746. * callback to execute when the css file(s) are finished loading
  3747. * The callback receives an object back with the following
  3748. * data:
  3749. * <dl>win</dl>
  3750. * <dd>the window the link nodes(s) were inserted into</dd>
  3751. * <dt>data</dt>
  3752. * <dd>the data object passed in when the request was made</dd>
  3753. * <dt>nodes</dt>
  3754. * <dd>An array containing references to the nodes that were
  3755. * inserted</dd>
  3756. * <dt>purge</dt>
  3757. * <dd>A function that, when executed, will remove the nodes
  3758. * that were inserted</dd>
  3759. * <dt>
  3760. * </dl>
  3761. * </dd>
  3762. * <dt>onProgress</dt>
  3763. * <dd>callback to execute when each individual file is done loading (useful when passing in an array of css files). Receives the same
  3764. * payload as onSuccess, with the addition of a <code>url</code> property, which identifies the file which was loaded. Currently only useful for non Webkit/Gecko browsers,
  3765. * where onload for css is detected accurately.</dd>
  3766. * <dt>async</dt>
  3767. * <dd>When passing in an array of css files, setting this flag to true will insert them
  3768. * into the document in parallel, as oppposed to the default behavior, which is to chain load them (where possible).
  3769. * This flag is more useful for scripts currently, since for css Get only chains if not Webkit/Gecko.</dd>
  3770. * <dt>context</dt>
  3771. * <dd>the execution context for the callbacks</dd>
  3772. * <dt>win</dt>
  3773. * <dd>a window other than the one the utility occupies</dd>
  3774. * <dt>data</dt>
  3775. * <dd>
  3776. * data that is supplied to the callbacks when the nodes(s) are
  3777. * loaded.
  3778. * </dd>
  3779. * <dt>insertBefore</dt>
  3780. * <dd>node or node id that will become the new node's nextSibling</dd>
  3781. * <dt>charset</dt>
  3782. * <dd>Node charset, default utf-8 (deprecated, use the attributes
  3783. * config)</dd>
  3784. * <dt>attributes</dt>
  3785. * <dd>An object literal containing additional attributes to add to
  3786. * the link tags</dd>
  3787. * </dl>
  3788. * <pre>
  3789. * Y.Get.css("http://localhost/css/menu.css");
  3790. * </pre>
  3791. * <pre>
  3792. * &nbsp; Y.Get.css(
  3793. * &nbsp; ["http://localhost/css/menu.css",
  3794. * &nbsp; "http://localhost/css/logger.css"], &#123;
  3795. * &nbsp; insertBefore: 'custom-styles' // nodes will be inserted
  3796. * &nbsp; // before the specified node
  3797. * &nbsp; &#125;);.
  3798. * </pre>
  3799. * @return {tId: string} an object containing info about the
  3800. * transaction.
  3801. */
  3802. css: function(url, opts) {
  3803. return _queue('css', url, opts);
  3804. }
  3805. };
  3806. }, '3.4.0' ,{requires:['yui-base']});
  3807. YUI.add('features', function(Y) {
  3808. var feature_tests = {};
  3809. /**
  3810. Contains the core of YUI's feature test architecture.
  3811. @module features
  3812. */
  3813. /**
  3814. * Feature detection
  3815. * @class Features
  3816. * @static
  3817. */
  3818. Y.mix(Y.namespace('Features'), {
  3819. /**
  3820. * Object hash of all registered feature tests
  3821. * @property tests
  3822. * @type Object
  3823. */
  3824. tests: feature_tests,
  3825. /**
  3826. * Add a test to the system
  3827. *
  3828. * ```
  3829. * Y.Features.add("load", "1", {});
  3830. * ```
  3831. *
  3832. * @method add
  3833. * @param {String} cat The category, right now only 'load' is supported
  3834. * @param {String} name The number sequence of the test, how it's reported in the URL or config: 1, 2, 3
  3835. * @param {Object} o Object containing test properties
  3836. * @param {String} o.name The name of the test
  3837. * @param {Function} o.test The test function to execute, the only argument to the function is the `Y` instance
  3838. * @param {String} o.trigger The module that triggers this test.
  3839. */
  3840. add: function(cat, name, o) {
  3841. feature_tests[cat] = feature_tests[cat] || {};
  3842. feature_tests[cat][name] = o;
  3843. },
  3844. /**
  3845. * Execute all tests of a given category and return the serialized results
  3846. *
  3847. * ```
  3848. * caps=1:1;2:1;3:0
  3849. * ```
  3850. * @method all
  3851. * @param {String} cat The category to execute
  3852. * @param {Array} args The arguments to pass to the test function
  3853. * @return {String} A semi-colon separated string of tests and their success/failure: 1:1;2:1;3:0
  3854. */
  3855. all: function(cat, args) {
  3856. var cat_o = feature_tests[cat],
  3857. // results = {};
  3858. result = [];
  3859. if (cat_o) {
  3860. Y.Object.each(cat_o, function(v, k) {
  3861. result.push(k + ':' + (Y.Features.test(cat, k, args) ? 1 : 0));
  3862. });
  3863. }
  3864. return (result.length) ? result.join(';') : '';
  3865. },
  3866. /**
  3867. * Run a sepecific test and return a Boolean response.
  3868. *
  3869. * ```
  3870. * Y.Features.test("load", "1");
  3871. * ```
  3872. *
  3873. * @method test
  3874. * @param {String} cat The category of the test to run
  3875. * @param {String} name The name of the test to run
  3876. * @param {Array} args The arguments to pass to the test function
  3877. * @return {Boolean} True or false if the test passed/failed.
  3878. */
  3879. test: function(cat, name, args) {
  3880. args = args || [];
  3881. var result, ua, test,
  3882. cat_o = feature_tests[cat],
  3883. feature = cat_o && cat_o[name];
  3884. if (!feature) {
  3885. Y.log('Feature test ' + cat + ', ' + name + ' not found');
  3886. } else {
  3887. result = feature.result;
  3888. if (Y.Lang.isUndefined(result)) {
  3889. ua = feature.ua;
  3890. if (ua) {
  3891. result = (Y.UA[ua]);
  3892. }
  3893. test = feature.test;
  3894. if (test && ((!ua) || result)) {
  3895. result = test.apply(Y, args);
  3896. }
  3897. feature.result = result;
  3898. }
  3899. }
  3900. return result;
  3901. }
  3902. });
  3903. // Y.Features.add("load", "1", {});
  3904. // Y.Features.test("load", "1");
  3905. // caps=1:1;2:0;3:1;
  3906. /* This file is auto-generated by src/loader/scripts/meta_join.py */
  3907. var add = Y.Features.add;
  3908. // graphics-canvas-default
  3909. add('load', '0', {
  3910. "name": "graphics-canvas-default",
  3911. "test": function(Y) {
  3912. var DOCUMENT = Y.config.doc,
  3913. canvas = DOCUMENT && DOCUMENT.createElement("canvas");
  3914. return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (canvas && canvas.getContext && canvas.getContext("2d")));
  3915. },
  3916. "trigger": "graphics"
  3917. });
  3918. // autocomplete-list-keys
  3919. add('load', '1', {
  3920. "name": "autocomplete-list-keys",
  3921. "test": function (Y) {
  3922. // Only add keyboard support to autocomplete-list if this doesn't appear to
  3923. // be an iOS or Android-based mobile device.
  3924. //
  3925. // There's currently no feasible way to actually detect whether a device has
  3926. // a hardware keyboard, so this sniff will have To Do. It can easily be
  3927. // overridden by manually loading the autocomplete-list-keys module.
  3928. //
  3929. // Worth noting: even though iOS supports bluetooth keyboards, Mobile Safari
  3930. // doesn't fire the keyboard events used by AutoCompleteList, so there's
  3931. // no point loading the -keys module even when a bluetooth keyboard may be
  3932. // available.
  3933. return !(Y.UA.ios || Y.UA.android);
  3934. },
  3935. "trigger": "autocomplete-list"
  3936. });
  3937. // graphics-svg
  3938. add('load', '2', {
  3939. "name": "graphics-svg",
  3940. "test": function(Y) {
  3941. var DOCUMENT = Y.config.doc;
  3942. return (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"));
  3943. },
  3944. "trigger": "graphics"
  3945. });
  3946. // history-hash-ie
  3947. add('load', '3', {
  3948. "name": "history-hash-ie",
  3949. "test": function (Y) {
  3950. var docMode = Y.config.doc && Y.config.doc.documentMode;
  3951. return Y.UA.ie && (!('onhashchange' in Y.config.win) ||
  3952. !docMode || docMode < 8);
  3953. },
  3954. "trigger": "history-hash"
  3955. });
  3956. // graphics-vml-default
  3957. add('load', '4', {
  3958. "name": "graphics-vml-default",
  3959. "test": function(Y) {
  3960. var DOCUMENT = Y.config.doc,
  3961. canvas = DOCUMENT && DOCUMENT.createElement("canvas");
  3962. return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (!canvas || !canvas.getContext || !canvas.getContext("2d")));
  3963. },
  3964. "trigger": "graphics"
  3965. });
  3966. // graphics-svg-default
  3967. add('load', '5', {
  3968. "name": "graphics-svg-default",
  3969. "test": function(Y) {
  3970. var DOCUMENT = Y.config.doc;
  3971. return (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"));
  3972. },
  3973. "trigger": "graphics"
  3974. });
  3975. // widget-base-ie
  3976. add('load', '6', {
  3977. "name": "widget-base-ie",
  3978. "trigger": "widget-base",
  3979. "ua": "ie"
  3980. });
  3981. // transition-timer
  3982. add('load', '7', {
  3983. "name": "transition-timer",
  3984. "test": function (Y) {
  3985. var DOCUMENT = Y.config.doc,
  3986. node = (DOCUMENT) ? DOCUMENT.documentElement: null,
  3987. ret = true;
  3988. if (node && node.style) {
  3989. ret = !('MozTransition' in node.style || 'WebkitTransition' in node.style);
  3990. }
  3991. return ret;
  3992. },
  3993. "trigger": "transition"
  3994. });
  3995. // dom-style-ie
  3996. add('load', '8', {
  3997. "name": "dom-style-ie",
  3998. "test": function (Y) {
  3999. var testFeature = Y.Features.test,
  4000. addFeature = Y.Features.add,
  4001. WINDOW = Y.config.win,
  4002. DOCUMENT = Y.config.doc,
  4003. DOCUMENT_ELEMENT = 'documentElement',
  4004. ret = false;
  4005. addFeature('style', 'computedStyle', {
  4006. test: function() {
  4007. return WINDOW && 'getComputedStyle' in WINDOW;
  4008. }
  4009. });
  4010. addFeature('style', 'opacity', {
  4011. test: function() {
  4012. return DOCUMENT && 'opacity' in DOCUMENT[DOCUMENT_ELEMENT].style;
  4013. }
  4014. });
  4015. ret = (!testFeature('style', 'opacity') &&
  4016. !testFeature('style', 'computedStyle'));
  4017. return ret;
  4018. },
  4019. "trigger": "dom-style"
  4020. });
  4021. // selector-css2
  4022. add('load', '9', {
  4023. "name": "selector-css2",
  4024. "test": function (Y) {
  4025. var DOCUMENT = Y.config.doc,
  4026. ret = DOCUMENT && !('querySelectorAll' in DOCUMENT);
  4027. return ret;
  4028. },
  4029. "trigger": "selector"
  4030. });
  4031. // event-base-ie
  4032. add('load', '10', {
  4033. "name": "event-base-ie",
  4034. "test": function(Y) {
  4035. var imp = Y.config.doc && Y.config.doc.implementation;
  4036. return (imp && (!imp.hasFeature('Events', '2.0')));
  4037. },
  4038. "trigger": "node-base"
  4039. });
  4040. // dd-gestures
  4041. add('load', '11', {
  4042. "name": "dd-gestures",
  4043. "test": function(Y) {
  4044. var UA = Y.UA;
  4045. return ((UA.mobile || UA.android || UA.ios) && UA.touch);
  4046. },
  4047. "trigger": "dd-drag"
  4048. });
  4049. // scrollview-base-ie
  4050. add('load', '12', {
  4051. "name": "scrollview-base-ie",
  4052. "trigger": "scrollview-base",
  4053. "ua": "ie"
  4054. });
  4055. // graphics-canvas
  4056. add('load', '13', {
  4057. "name": "graphics-canvas",
  4058. "test": function(Y) {
  4059. var DOCUMENT = Y.config.doc,
  4060. canvas = DOCUMENT && DOCUMENT.createElement("canvas");
  4061. return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (canvas && canvas.getContext && canvas.getContext("2d")));
  4062. },
  4063. "trigger": "graphics"
  4064. });
  4065. // graphics-vml
  4066. add('load', '14', {
  4067. "name": "graphics-vml",
  4068. "test": function(Y) {
  4069. var DOCUMENT = Y.config.doc,
  4070. canvas = DOCUMENT && DOCUMENT.createElement("canvas");
  4071. return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (!canvas || !canvas.getContext || !canvas.getContext("2d")));
  4072. },
  4073. "trigger": "graphics"
  4074. });
  4075. }, '3.4.0' ,{requires:['yui-base']});
  4076. YUI.add('intl-base', function(Y) {
  4077. /**
  4078. * The Intl utility provides a central location for managing sets of
  4079. * localized resources (strings and formatting patterns).
  4080. *
  4081. * @class Intl
  4082. * @uses EventTarget
  4083. * @static
  4084. */
  4085. var SPLIT_REGEX = /[, ]/;
  4086. Y.mix(Y.namespace('Intl'), {
  4087. /**
  4088. * Returns the language among those available that
  4089. * best matches the preferred language list, using the Lookup
  4090. * algorithm of BCP 47.
  4091. * If none of the available languages meets the user's preferences,
  4092. * then "" is returned.
  4093. * Extended language ranges are not supported.
  4094. *
  4095. * @method lookupBestLang
  4096. * @param {String[] | String} preferredLanguages The list of preferred
  4097. * languages in descending preference order, represented as BCP 47
  4098. * language tags. A string array or a comma-separated list.
  4099. * @param {String[]} availableLanguages The list of languages
  4100. * that the application supports, represented as BCP 47 language
  4101. * tags.
  4102. *
  4103. * @return {String} The available language that best matches the
  4104. * preferred language list, or "".
  4105. * @since 3.1.0
  4106. */
  4107. lookupBestLang: function(preferredLanguages, availableLanguages) {
  4108. var i, language, result, index;
  4109. // check whether the list of available languages contains language;
  4110. // if so return it
  4111. function scan(language) {
  4112. var i;
  4113. for (i = 0; i < availableLanguages.length; i += 1) {
  4114. if (language.toLowerCase() ===
  4115. availableLanguages[i].toLowerCase()) {
  4116. return availableLanguages[i];
  4117. }
  4118. }
  4119. }
  4120. if (Y.Lang.isString(preferredLanguages)) {
  4121. preferredLanguages = preferredLanguages.split(SPLIT_REGEX);
  4122. }
  4123. for (i = 0; i < preferredLanguages.length; i += 1) {
  4124. language = preferredLanguages[i];
  4125. if (!language || language === '*') {
  4126. continue;
  4127. }
  4128. // check the fallback sequence for one language
  4129. while (language.length > 0) {
  4130. result = scan(language);
  4131. if (result) {
  4132. return result;
  4133. } else {
  4134. index = language.lastIndexOf('-');
  4135. if (index >= 0) {
  4136. language = language.substring(0, index);
  4137. // one-character subtags get cut along with the
  4138. // following subtag
  4139. if (index >= 2 && language.charAt(index - 2) === '-') {
  4140. language = language.substring(0, index - 2);
  4141. }
  4142. } else {
  4143. // nothing available for this language
  4144. break;
  4145. }
  4146. }
  4147. }
  4148. }
  4149. return '';
  4150. }
  4151. });
  4152. }, '3.4.0' ,{requires:['yui-base']});
  4153. YUI.add('yui-log', function(Y) {
  4154. /**
  4155. * Provides console log capability and exposes a custom event for
  4156. * console implementations. This module is a `core` YUI module, <a href="../classes/YUI.html#method_log">it's documentation is located under the YUI class</a>.
  4157. *
  4158. * @module yui
  4159. * @submodule yui-log
  4160. */
  4161. var INSTANCE = Y,
  4162. LOGEVENT = 'yui:log',
  4163. UNDEFINED = 'undefined',
  4164. LEVELS = { debug: 1,
  4165. info: 1,
  4166. warn: 1,
  4167. error: 1 };
  4168. /**
  4169. * If the 'debug' config is true, a 'yui:log' event will be
  4170. * dispatched, which the Console widget and anything else
  4171. * can consume. If the 'useBrowserConsole' config is true, it will
  4172. * write to the browser console if available. YUI-specific log
  4173. * messages will only be present in the -debug versions of the
  4174. * JS files. The build system is supposed to remove log statements
  4175. * from the raw and minified versions of the files.
  4176. *
  4177. * @method log
  4178. * @for YUI
  4179. * @param {String} msg The message to log.
  4180. * @param {String} cat The log category for the message. Default
  4181. * categories are "info", "warn", "error", time".
  4182. * Custom categories can be used as well. (opt).
  4183. * @param {String} src The source of the the message (opt).
  4184. * @param {boolean} silent If true, the log event won't fire.
  4185. * @return {YUI} YUI instance.
  4186. */
  4187. INSTANCE.log = function(msg, cat, src, silent) {
  4188. var bail, excl, incl, m, f,
  4189. Y = INSTANCE,
  4190. c = Y.config,
  4191. publisher = (Y.fire) ? Y : YUI.Env.globalEvents;
  4192. // suppress log message if the config is off or the event stack
  4193. // or the event call stack contains a consumer of the yui:log event
  4194. if (c.debug) {
  4195. // apply source filters
  4196. if (src) {
  4197. excl = c.logExclude;
  4198. incl = c.logInclude;
  4199. if (incl && !(src in incl)) {
  4200. bail = 1;
  4201. } else if (incl && (src in incl)) {
  4202. bail = !incl[src];
  4203. } else if (excl && (src in excl)) {
  4204. bail = excl[src];
  4205. }
  4206. }
  4207. if (!bail) {
  4208. if (c.useBrowserConsole) {
  4209. m = (src) ? src + ': ' + msg : msg;
  4210. if (Y.Lang.isFunction(c.logFn)) {
  4211. c.logFn.call(Y, msg, cat, src);
  4212. } else if (typeof console != UNDEFINED && console.log) {
  4213. f = (cat && console[cat] && (cat in LEVELS)) ? cat : 'log';
  4214. console[f](m);
  4215. } else if (typeof opera != UNDEFINED) {
  4216. opera.postError(m);
  4217. }
  4218. }
  4219. if (publisher && !silent) {
  4220. if (publisher == Y && (!publisher.getEvent(LOGEVENT))) {
  4221. publisher.publish(LOGEVENT, {
  4222. broadcast: 2
  4223. });
  4224. }
  4225. publisher.fire(LOGEVENT, {
  4226. msg: msg,
  4227. cat: cat,
  4228. src: src
  4229. });
  4230. }
  4231. }
  4232. }
  4233. return Y;
  4234. };
  4235. /**
  4236. * Write a system message. This message will be preserved in the
  4237. * minified and raw versions of the YUI files, unlike log statements.
  4238. * @method message
  4239. * @for YUI
  4240. * @param {String} msg The message to log.
  4241. * @param {String} cat The log category for the message. Default
  4242. * categories are "info", "warn", "error", time".
  4243. * Custom categories can be used as well. (opt).
  4244. * @param {String} src The source of the the message (opt).
  4245. * @param {boolean} silent If true, the log event won't fire.
  4246. * @return {YUI} YUI instance.
  4247. */
  4248. INSTANCE.message = function() {
  4249. return INSTANCE.log.apply(INSTANCE, arguments);
  4250. };
  4251. }, '3.4.0' ,{requires:['yui-base']});
  4252. YUI.add('yui-later', function(Y) {
  4253. /**
  4254. * Provides a setTimeout/setInterval wrapper. This module is a `core` YUI module, <a href="../classes/YUI.html#method_later">it's documentation is located under the YUI class</a>.
  4255. *
  4256. * @module yui
  4257. * @submodule yui-later
  4258. */
  4259. var NO_ARGS = [];
  4260. /**
  4261. * Executes the supplied function in the context of the supplied
  4262. * object 'when' milliseconds later. Executes the function a
  4263. * single time unless periodic is set to true.
  4264. * @for YUI
  4265. * @method later
  4266. * @param when {int} the number of milliseconds to wait until the fn
  4267. * is executed.
  4268. * @param o the context object.
  4269. * @param fn {Function|String} the function to execute or the name of
  4270. * the method in the 'o' object to execute.
  4271. * @param data [Array] data that is provided to the function. This
  4272. * accepts either a single item or an array. If an array is provided,
  4273. * the function is executed with one parameter for each array item.
  4274. * If you need to pass a single array parameter, it needs to be wrapped
  4275. * in an array [myarray].
  4276. *
  4277. * Note: native methods in IE may not have the call and apply methods.
  4278. * In this case, it will work, but you are limited to four arguments.
  4279. *
  4280. * @param periodic {boolean} if true, executes continuously at supplied
  4281. * interval until canceled.
  4282. * @return {object} a timer object. Call the cancel() method on this
  4283. * object to stop the timer.
  4284. */
  4285. Y.later = function(when, o, fn, data, periodic) {
  4286. when = when || 0;
  4287. data = (!Y.Lang.isUndefined(data)) ? Y.Array(data) : NO_ARGS;
  4288. o = o || Y.config.win || Y;
  4289. var cancelled = false,
  4290. method = (o && Y.Lang.isString(fn)) ? o[fn] : fn,
  4291. wrapper = function() {
  4292. // IE 8- may execute a setInterval callback one last time
  4293. // after clearInterval was called, so in order to preserve
  4294. // the cancel() === no more runny-run, we have to jump through
  4295. // an extra hoop.
  4296. if (!cancelled) {
  4297. if (!method.apply) {
  4298. method(data[0], data[1], data[2], data[3]);
  4299. } else {
  4300. method.apply(o, data || NO_ARGS);
  4301. }
  4302. }
  4303. },
  4304. id = (periodic) ? setInterval(wrapper, when) : setTimeout(wrapper, when);
  4305. return {
  4306. id: id,
  4307. interval: periodic,
  4308. cancel: function() {
  4309. cancelled = true;
  4310. if (this.interval) {
  4311. clearInterval(id);
  4312. } else {
  4313. clearTimeout(id);
  4314. }
  4315. }
  4316. };
  4317. };
  4318. Y.Lang.later = Y.later;
  4319. }, '3.4.0' ,{requires:['yui-base']});
  4320. YUI.add('yui', function(Y){}, '3.4.0' ,{use:['yui-base','get','features','intl-base','yui-log','yui-later']});