yuiloader-debug.js 122 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880
  1. /*
  2. Copyright (c) 2009, Yahoo! Inc. All rights reserved.
  3. Code licensed under the BSD License:
  4. http://developer.yahoo.net/yui/license.txt
  5. version: 2.8.0r4
  6. */
  7. /**
  8. * The YAHOO object is the single global object used by YUI Library. It
  9. * contains utility function for setting up namespaces, inheritance, and
  10. * logging. YAHOO.util, YAHOO.widget, and YAHOO.example are namespaces
  11. * created automatically for and used by the library.
  12. * @module yahoo
  13. * @title YAHOO Global
  14. */
  15. /**
  16. * YAHOO_config is not included as part of the library. Instead it is an
  17. * object that can be defined by the implementer immediately before
  18. * including the YUI library. The properties included in this object
  19. * will be used to configure global properties needed as soon as the
  20. * library begins to load.
  21. * @class YAHOO_config
  22. * @static
  23. */
  24. /**
  25. * A reference to a function that will be executed every time a YAHOO module
  26. * is loaded. As parameter, this function will receive the version
  27. * information for the module. See <a href="YAHOO.env.html#getVersion">
  28. * YAHOO.env.getVersion</a> for the description of the version data structure.
  29. * @property listener
  30. * @type Function
  31. * @static
  32. * @default undefined
  33. */
  34. /**
  35. * Set to true if the library will be dynamically loaded after window.onload.
  36. * Defaults to false
  37. * @property injecting
  38. * @type boolean
  39. * @static
  40. * @default undefined
  41. */
  42. /**
  43. * Instructs the yuiloader component to dynamically load yui components and
  44. * their dependencies. See the yuiloader documentation for more information
  45. * about dynamic loading
  46. * @property load
  47. * @static
  48. * @default undefined
  49. * @see yuiloader
  50. */
  51. /**
  52. * Forces the use of the supplied locale where applicable in the library
  53. * @property locale
  54. * @type string
  55. * @static
  56. * @default undefined
  57. */
  58. if (typeof YAHOO == "undefined" || !YAHOO) {
  59. /**
  60. * The YAHOO global namespace object. If YAHOO is already defined, the
  61. * existing YAHOO object will not be overwritten so that defined
  62. * namespaces are preserved.
  63. * @class YAHOO
  64. * @static
  65. */
  66. var YAHOO = {};
  67. }
  68. /**
  69. * Returns the namespace specified and creates it if it doesn't exist
  70. * <pre>
  71. * YAHOO.namespace("property.package");
  72. * YAHOO.namespace("YAHOO.property.package");
  73. * </pre>
  74. * Either of the above would create YAHOO.property, then
  75. * YAHOO.property.package
  76. *
  77. * Be careful when naming packages. Reserved words may work in some browsers
  78. * and not others. For instance, the following will fail in Safari:
  79. * <pre>
  80. * YAHOO.namespace("really.long.nested.namespace");
  81. * </pre>
  82. * This fails because "long" is a future reserved word in ECMAScript
  83. *
  84. * For implementation code that uses YUI, do not create your components
  85. * in the namespaces defined by YUI (
  86. * <code>YAHOO.util</code>,
  87. * <code>YAHOO.widget</code>,
  88. * <code>YAHOO.lang</code>,
  89. * <code>YAHOO.tool</code>,
  90. * <code>YAHOO.example</code>,
  91. * <code>YAHOO.env</code>) -- create your own namespace (e.g., 'companyname').
  92. *
  93. * @method namespace
  94. * @static
  95. * @param {String*} arguments 1-n namespaces to create
  96. * @return {Object} A reference to the last namespace object created
  97. */
  98. YAHOO.namespace = function() {
  99. var a=arguments, o=null, i, j, d;
  100. for (i=0; i<a.length; i=i+1) {
  101. d=(""+a[i]).split(".");
  102. o=YAHOO;
  103. // YAHOO is implied, so it is ignored if it is included
  104. for (j=(d[0] == "YAHOO") ? 1 : 0; j<d.length; j=j+1) {
  105. o[d[j]]=o[d[j]] || {};
  106. o=o[d[j]];
  107. }
  108. }
  109. return o;
  110. };
  111. /**
  112. * Uses YAHOO.widget.Logger to output a log message, if the widget is
  113. * available.
  114. *
  115. * @method log
  116. * @static
  117. * @param {String} msg The message to log.
  118. * @param {String} cat The log category for the message. Default
  119. * categories are "info", "warn", "error", time".
  120. * Custom categories can be used as well. (opt)
  121. * @param {String} src The source of the the message (opt)
  122. * @return {Boolean} True if the log operation was successful.
  123. */
  124. YAHOO.log = function(msg, cat, src) {
  125. var l=YAHOO.widget.Logger;
  126. if(l && l.log) {
  127. return l.log(msg, cat, src);
  128. } else {
  129. return false;
  130. }
  131. };
  132. /**
  133. * Registers a module with the YAHOO object
  134. * @method register
  135. * @static
  136. * @param {String} name the name of the module (event, slider, etc)
  137. * @param {Function} mainClass a reference to class in the module. This
  138. * class will be tagged with the version info
  139. * so that it will be possible to identify the
  140. * version that is in use when multiple versions
  141. * have loaded
  142. * @param {Object} data metadata object for the module. Currently it
  143. * is expected to contain a "version" property
  144. * and a "build" property at minimum.
  145. */
  146. YAHOO.register = function(name, mainClass, data) {
  147. var mods = YAHOO.env.modules, m, v, b, ls, i;
  148. if (!mods[name]) {
  149. mods[name] = {
  150. versions:[],
  151. builds:[]
  152. };
  153. }
  154. m = mods[name];
  155. v = data.version;
  156. b = data.build;
  157. ls = YAHOO.env.listeners;
  158. m.name = name;
  159. m.version = v;
  160. m.build = b;
  161. m.versions.push(v);
  162. m.builds.push(b);
  163. m.mainClass = mainClass;
  164. // fire the module load listeners
  165. for (i=0;i<ls.length;i=i+1) {
  166. ls[i](m);
  167. }
  168. // label the main class
  169. if (mainClass) {
  170. mainClass.VERSION = v;
  171. mainClass.BUILD = b;
  172. } else {
  173. YAHOO.log("mainClass is undefined for module " + name, "warn");
  174. }
  175. };
  176. /**
  177. * YAHOO.env is used to keep track of what is known about the YUI library and
  178. * the browsing environment
  179. * @class YAHOO.env
  180. * @static
  181. */
  182. YAHOO.env = YAHOO.env || {
  183. /**
  184. * Keeps the version info for all YUI modules that have reported themselves
  185. * @property modules
  186. * @type Object[]
  187. */
  188. modules: [],
  189. /**
  190. * List of functions that should be executed every time a YUI module
  191. * reports itself.
  192. * @property listeners
  193. * @type Function[]
  194. */
  195. listeners: []
  196. };
  197. /**
  198. * Returns the version data for the specified module:
  199. * <dl>
  200. * <dt>name:</dt> <dd>The name of the module</dd>
  201. * <dt>version:</dt> <dd>The version in use</dd>
  202. * <dt>build:</dt> <dd>The build number in use</dd>
  203. * <dt>versions:</dt> <dd>All versions that were registered</dd>
  204. * <dt>builds:</dt> <dd>All builds that were registered.</dd>
  205. * <dt>mainClass:</dt> <dd>An object that was was stamped with the
  206. * current version and build. If
  207. * mainClass.VERSION != version or mainClass.BUILD != build,
  208. * multiple versions of pieces of the library have been
  209. * loaded, potentially causing issues.</dd>
  210. * </dl>
  211. *
  212. * @method getVersion
  213. * @static
  214. * @param {String} name the name of the module (event, slider, etc)
  215. * @return {Object} The version info
  216. */
  217. YAHOO.env.getVersion = function(name) {
  218. return YAHOO.env.modules[name] || null;
  219. };
  220. /**
  221. * Do not fork for a browser if it can be avoided. Use feature detection when
  222. * you can. Use the user agent as a last resort. YAHOO.env.ua stores a version
  223. * number for the browser engine, 0 otherwise. This value may or may not map
  224. * to the version number of the browser using the engine. The value is
  225. * presented as a float so that it can easily be used for boolean evaluation
  226. * as well as for looking for a particular range of versions. Because of this,
  227. * some of the granularity of the version info may be lost (e.g., Gecko 1.8.0.9
  228. * reports 1.8).
  229. * @class YAHOO.env.ua
  230. * @static
  231. */
  232. YAHOO.env.ua = function() {
  233. var numberfy = function(s) {
  234. var c = 0;
  235. return parseFloat(s.replace(/\./g, function() {
  236. return (c++ == 1) ? '' : '.';
  237. }));
  238. },
  239. nav = navigator,
  240. o = {
  241. /**
  242. * Internet Explorer version number or 0. Example: 6
  243. * @property ie
  244. * @type float
  245. */
  246. ie: 0,
  247. /**
  248. * Opera version number or 0. Example: 9.2
  249. * @property opera
  250. * @type float
  251. */
  252. opera: 0,
  253. /**
  254. * Gecko engine revision number. Will evaluate to 1 if Gecko
  255. * is detected but the revision could not be found. Other browsers
  256. * will be 0. Example: 1.8
  257. * <pre>
  258. * Firefox 1.0.0.4: 1.7.8 <-- Reports 1.7
  259. * Firefox 1.5.0.9: 1.8.0.9 <-- Reports 1.8
  260. * Firefox 2.0.0.3: 1.8.1.3 <-- Reports 1.8
  261. * Firefox 3 alpha: 1.9a4 <-- Reports 1.9
  262. * </pre>
  263. * @property gecko
  264. * @type float
  265. */
  266. gecko: 0,
  267. /**
  268. * AppleWebKit version. KHTML browsers that are not WebKit browsers
  269. * will evaluate to 1, other browsers 0. Example: 418.9.1
  270. * <pre>
  271. * Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the
  272. * latest available for Mac OSX 10.3.
  273. * Safari 2.0.2: 416 <-- hasOwnProperty introduced
  274. * Safari 2.0.4: 418 <-- preventDefault fixed
  275. * Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run
  276. * different versions of webkit
  277. * Safari 2.0.4 (419.3): 419 <-- Tiger installations that have been
  278. * updated, but not updated
  279. * to the latest patch.
  280. * Webkit 212 nightly: 522+ <-- Safari 3.0 precursor (with native SVG
  281. * and many major issues fixed).
  282. * 3.x yahoo.com, flickr:422 <-- Safari 3.x hacks the user agent
  283. * string when hitting yahoo.com and
  284. * flickr.com.
  285. * Safari 3.0.4 (523.12):523.12 <-- First Tiger release - automatic update
  286. * from 2.x via the 10.4.11 OS patch
  287. * Webkit nightly 1/2008:525+ <-- Supports DOMContentLoaded event.
  288. * yahoo.com user agent hack removed.
  289. *
  290. * </pre>
  291. * http://developer.apple.com/internet/safari/uamatrix.html
  292. * @property webkit
  293. * @type float
  294. */
  295. webkit: 0,
  296. /**
  297. * The mobile property will be set to a string containing any relevant
  298. * user agent information when a modern mobile browser is detected.
  299. * Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series
  300. * devices with the WebKit-based browser, and Opera Mini.
  301. * @property mobile
  302. * @type string
  303. */
  304. mobile: null,
  305. /**
  306. * Adobe AIR version number or 0. Only populated if webkit is detected.
  307. * Example: 1.0
  308. * @property air
  309. * @type float
  310. */
  311. air: 0,
  312. /**
  313. * Google Caja version number or 0.
  314. * @property caja
  315. * @type float
  316. */
  317. caja: nav.cajaVersion,
  318. /**
  319. * Set to true if the page appears to be in SSL
  320. * @property secure
  321. * @type boolean
  322. * @static
  323. */
  324. secure: false,
  325. /**
  326. * The operating system. Currently only detecting windows or macintosh
  327. * @property os
  328. * @type string
  329. * @static
  330. */
  331. os: null
  332. },
  333. ua = navigator && navigator.userAgent,
  334. loc = window && window.location,
  335. href = loc && loc.href,
  336. m;
  337. o.secure = href && (href.toLowerCase().indexOf("https") === 0);
  338. if (ua) {
  339. if ((/windows|win32/i).test(ua)) {
  340. o.os = 'windows';
  341. } else if ((/macintosh/i).test(ua)) {
  342. o.os = 'macintosh';
  343. }
  344. // Modern KHTML browsers should qualify as Safari X-Grade
  345. if ((/KHTML/).test(ua)) {
  346. o.webkit=1;
  347. }
  348. // Modern WebKit browsers are at least X-Grade
  349. m=ua.match(/AppleWebKit\/([^\s]*)/);
  350. if (m&&m[1]) {
  351. o.webkit=numberfy(m[1]);
  352. // Mobile browser check
  353. if (/ Mobile\//.test(ua)) {
  354. o.mobile = "Apple"; // iPhone or iPod Touch
  355. } else {
  356. m=ua.match(/NokiaN[^\/]*/);
  357. if (m) {
  358. o.mobile = m[0]; // Nokia N-series, ex: NokiaN95
  359. }
  360. }
  361. m=ua.match(/AdobeAIR\/([^\s]*)/);
  362. if (m) {
  363. o.air = m[0]; // Adobe AIR 1.0 or better
  364. }
  365. }
  366. if (!o.webkit) { // not webkit
  367. // @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr)
  368. m=ua.match(/Opera[\s\/]([^\s]*)/);
  369. if (m&&m[1]) {
  370. o.opera=numberfy(m[1]);
  371. m=ua.match(/Opera Mini[^;]*/);
  372. if (m) {
  373. o.mobile = m[0]; // ex: Opera Mini/2.0.4509/1316
  374. }
  375. } else { // not opera or webkit
  376. m=ua.match(/MSIE\s([^;]*)/);
  377. if (m&&m[1]) {
  378. o.ie=numberfy(m[1]);
  379. } else { // not opera, webkit, or ie
  380. m=ua.match(/Gecko\/([^\s]*)/);
  381. if (m) {
  382. o.gecko=1; // Gecko detected, look for revision
  383. m=ua.match(/rv:([^\s\)]*)/);
  384. if (m&&m[1]) {
  385. o.gecko=numberfy(m[1]);
  386. }
  387. }
  388. }
  389. }
  390. }
  391. }
  392. return o;
  393. }();
  394. /*
  395. * Initializes the global by creating the default namespaces and applying
  396. * any new configuration information that is detected. This is the setup
  397. * for env.
  398. * @method init
  399. * @static
  400. * @private
  401. */
  402. (function() {
  403. YAHOO.namespace("util", "widget", "example");
  404. /*global YAHOO_config*/
  405. if ("undefined" !== typeof YAHOO_config) {
  406. var l=YAHOO_config.listener, ls=YAHOO.env.listeners,unique=true, i;
  407. if (l) {
  408. // if YAHOO is loaded multiple times we need to check to see if
  409. // this is a new config object. If it is, add the new component
  410. // load listener to the stack
  411. for (i=0; i<ls.length; i++) {
  412. if (ls[i] == l) {
  413. unique = false;
  414. break;
  415. }
  416. }
  417. if (unique) {
  418. ls.push(l);
  419. }
  420. }
  421. }
  422. })();
  423. /**
  424. * Provides the language utilites and extensions used by the library
  425. * @class YAHOO.lang
  426. */
  427. YAHOO.lang = YAHOO.lang || {};
  428. (function() {
  429. var L = YAHOO.lang,
  430. OP = Object.prototype,
  431. ARRAY_TOSTRING = '[object Array]',
  432. FUNCTION_TOSTRING = '[object Function]',
  433. OBJECT_TOSTRING = '[object Object]',
  434. NOTHING = [],
  435. // ADD = ["toString", "valueOf", "hasOwnProperty"],
  436. ADD = ["toString", "valueOf"],
  437. OB = {
  438. /**
  439. * Determines wheather or not the provided object is an array.
  440. * @method isArray
  441. * @param {any} o The object being testing
  442. * @return {boolean} the result
  443. */
  444. isArray: function(o) {
  445. return OP.toString.apply(o) === ARRAY_TOSTRING;
  446. },
  447. /**
  448. * Determines whether or not the provided object is a boolean
  449. * @method isBoolean
  450. * @param {any} o The object being testing
  451. * @return {boolean} the result
  452. */
  453. isBoolean: function(o) {
  454. return typeof o === 'boolean';
  455. },
  456. /**
  457. * Determines whether or not the provided object is a function.
  458. * Note: Internet Explorer thinks certain functions are objects:
  459. *
  460. * var obj = document.createElement("object");
  461. * YAHOO.lang.isFunction(obj.getAttribute) // reports false in IE
  462. *
  463. * var input = document.createElement("input"); // append to body
  464. * YAHOO.lang.isFunction(input.focus) // reports false in IE
  465. *
  466. * You will have to implement additional tests if these functions
  467. * matter to you.
  468. *
  469. * @method isFunction
  470. * @param {any} o The object being testing
  471. * @return {boolean} the result
  472. */
  473. isFunction: function(o) {
  474. return (typeof o === 'function') || OP.toString.apply(o) === FUNCTION_TOSTRING;
  475. },
  476. /**
  477. * Determines whether or not the provided object is null
  478. * @method isNull
  479. * @param {any} o The object being testing
  480. * @return {boolean} the result
  481. */
  482. isNull: function(o) {
  483. return o === null;
  484. },
  485. /**
  486. * Determines whether or not the provided object is a legal number
  487. * @method isNumber
  488. * @param {any} o The object being testing
  489. * @return {boolean} the result
  490. */
  491. isNumber: function(o) {
  492. return typeof o === 'number' && isFinite(o);
  493. },
  494. /**
  495. * Determines whether or not the provided object is of type object
  496. * or function
  497. * @method isObject
  498. * @param {any} o The object being testing
  499. * @return {boolean} the result
  500. */
  501. isObject: function(o) {
  502. return (o && (typeof o === 'object' || L.isFunction(o))) || false;
  503. },
  504. /**
  505. * Determines whether or not the provided object is a string
  506. * @method isString
  507. * @param {any} o The object being testing
  508. * @return {boolean} the result
  509. */
  510. isString: function(o) {
  511. return typeof o === 'string';
  512. },
  513. /**
  514. * Determines whether or not the provided object is undefined
  515. * @method isUndefined
  516. * @param {any} o The object being testing
  517. * @return {boolean} the result
  518. */
  519. isUndefined: function(o) {
  520. return typeof o === 'undefined';
  521. },
  522. /**
  523. * IE will not enumerate native functions in a derived object even if the
  524. * function was overridden. This is a workaround for specific functions
  525. * we care about on the Object prototype.
  526. * @property _IEEnumFix
  527. * @param {Function} r the object to receive the augmentation
  528. * @param {Function} s the object that supplies the properties to augment
  529. * @static
  530. * @private
  531. */
  532. _IEEnumFix: (YAHOO.env.ua.ie) ? function(r, s) {
  533. var i, fname, f;
  534. for (i=0;i<ADD.length;i=i+1) {
  535. fname = ADD[i];
  536. f = s[fname];
  537. if (L.isFunction(f) && f!=OP[fname]) {
  538. r[fname]=f;
  539. }
  540. }
  541. } : function(){},
  542. /**
  543. * Utility to set up the prototype, constructor and superclass properties to
  544. * support an inheritance strategy that can chain constructors and methods.
  545. * Static members will not be inherited.
  546. *
  547. * @method extend
  548. * @static
  549. * @param {Function} subc the object to modify
  550. * @param {Function} superc the object to inherit
  551. * @param {Object} overrides additional properties/methods to add to the
  552. * subclass prototype. These will override the
  553. * matching items obtained from the superclass
  554. * if present.
  555. */
  556. extend: function(subc, superc, overrides) {
  557. if (!superc||!subc) {
  558. throw new Error("extend failed, please check that " +
  559. "all dependencies are included.");
  560. }
  561. var F = function() {}, i;
  562. F.prototype=superc.prototype;
  563. subc.prototype=new F();
  564. subc.prototype.constructor=subc;
  565. subc.superclass=superc.prototype;
  566. if (superc.prototype.constructor == OP.constructor) {
  567. superc.prototype.constructor=superc;
  568. }
  569. if (overrides) {
  570. for (i in overrides) {
  571. if (L.hasOwnProperty(overrides, i)) {
  572. subc.prototype[i]=overrides[i];
  573. }
  574. }
  575. L._IEEnumFix(subc.prototype, overrides);
  576. }
  577. },
  578. /**
  579. * Applies all properties in the supplier to the receiver if the
  580. * receiver does not have these properties yet. Optionally, one or
  581. * more methods/properties can be specified (as additional
  582. * parameters). This option will overwrite the property if receiver
  583. * has it already. If true is passed as the third parameter, all
  584. * properties will be applied and _will_ overwrite properties in
  585. * the receiver.
  586. *
  587. * @method augmentObject
  588. * @static
  589. * @since 2.3.0
  590. * @param {Function} r the object to receive the augmentation
  591. * @param {Function} s the object that supplies the properties to augment
  592. * @param {String*|boolean} arguments zero or more properties methods
  593. * to augment the receiver with. If none specified, everything
  594. * in the supplier will be used unless it would
  595. * overwrite an existing property in the receiver. If true
  596. * is specified as the third parameter, all properties will
  597. * be applied and will overwrite an existing property in
  598. * the receiver
  599. */
  600. augmentObject: function(r, s) {
  601. if (!s||!r) {
  602. throw new Error("Absorb failed, verify dependencies.");
  603. }
  604. var a=arguments, i, p, overrideList=a[2];
  605. if (overrideList && overrideList!==true) { // only absorb the specified properties
  606. for (i=2; i<a.length; i=i+1) {
  607. r[a[i]] = s[a[i]];
  608. }
  609. } else { // take everything, overwriting only if the third parameter is true
  610. for (p in s) {
  611. if (overrideList || !(p in r)) {
  612. r[p] = s[p];
  613. }
  614. }
  615. L._IEEnumFix(r, s);
  616. }
  617. },
  618. /**
  619. * Same as YAHOO.lang.augmentObject, except it only applies prototype properties
  620. * @see YAHOO.lang.augmentObject
  621. * @method augmentProto
  622. * @static
  623. * @param {Function} r the object to receive the augmentation
  624. * @param {Function} s the object that supplies the properties to augment
  625. * @param {String*|boolean} arguments zero or more properties methods
  626. * to augment the receiver with. If none specified, everything
  627. * in the supplier will be used unless it would overwrite an existing
  628. * property in the receiver. if true is specified as the third
  629. * parameter, all properties will be applied and will overwrite an
  630. * existing property in the receiver
  631. */
  632. augmentProto: function(r, s) {
  633. if (!s||!r) {
  634. throw new Error("Augment failed, verify dependencies.");
  635. }
  636. //var a=[].concat(arguments);
  637. var a=[r.prototype,s.prototype], i;
  638. for (i=2;i<arguments.length;i=i+1) {
  639. a.push(arguments[i]);
  640. }
  641. L.augmentObject.apply(this, a);
  642. },
  643. /**
  644. * Returns a simple string representation of the object or array.
  645. * Other types of objects will be returned unprocessed. Arrays
  646. * are expected to be indexed. Use object notation for
  647. * associative arrays.
  648. * @method dump
  649. * @since 2.3.0
  650. * @param o {Object} The object to dump
  651. * @param d {int} How deep to recurse child objects, default 3
  652. * @return {String} the dump result
  653. */
  654. dump: function(o, d) {
  655. var i,len,s=[],OBJ="{...}",FUN="f(){...}",
  656. COMMA=', ', ARROW=' => ';
  657. // Cast non-objects to string
  658. // Skip dates because the std toString is what we want
  659. // Skip HTMLElement-like objects because trying to dump
  660. // an element will cause an unhandled exception in FF 2.x
  661. if (!L.isObject(o)) {
  662. return o + "";
  663. } else if (o instanceof Date || ("nodeType" in o && "tagName" in o)) {
  664. return o;
  665. } else if (L.isFunction(o)) {
  666. return FUN;
  667. }
  668. // dig into child objects the depth specifed. Default 3
  669. d = (L.isNumber(d)) ? d : 3;
  670. // arrays [1, 2, 3]
  671. if (L.isArray(o)) {
  672. s.push("[");
  673. for (i=0,len=o.length;i<len;i=i+1) {
  674. if (L.isObject(o[i])) {
  675. s.push((d > 0) ? L.dump(o[i], d-1) : OBJ);
  676. } else {
  677. s.push(o[i]);
  678. }
  679. s.push(COMMA);
  680. }
  681. if (s.length > 1) {
  682. s.pop();
  683. }
  684. s.push("]");
  685. // objects {k1 => v1, k2 => v2}
  686. } else {
  687. s.push("{");
  688. for (i in o) {
  689. if (L.hasOwnProperty(o, i)) {
  690. s.push(i + ARROW);
  691. if (L.isObject(o[i])) {
  692. s.push((d > 0) ? L.dump(o[i], d-1) : OBJ);
  693. } else {
  694. s.push(o[i]);
  695. }
  696. s.push(COMMA);
  697. }
  698. }
  699. if (s.length > 1) {
  700. s.pop();
  701. }
  702. s.push("}");
  703. }
  704. return s.join("");
  705. },
  706. /**
  707. * Does variable substitution on a string. It scans through the string
  708. * looking for expressions enclosed in { } braces. If an expression
  709. * is found, it is used a key on the object. If there is a space in
  710. * the key, the first word is used for the key and the rest is provided
  711. * to an optional function to be used to programatically determine the
  712. * value (the extra information might be used for this decision). If
  713. * the value for the key in the object, or what is returned from the
  714. * function has a string value, number value, or object value, it is
  715. * substituted for the bracket expression and it repeats. If this
  716. * value is an object, it uses the Object's toString() if this has
  717. * been overridden, otherwise it does a shallow dump of the key/value
  718. * pairs.
  719. * @method substitute
  720. * @since 2.3.0
  721. * @param s {String} The string that will be modified.
  722. * @param o {Object} An object containing the replacement values
  723. * @param f {Function} An optional function that can be used to
  724. * process each match. It receives the key,
  725. * value, and any extra metadata included with
  726. * the key inside of the braces.
  727. * @return {String} the substituted string
  728. */
  729. substitute: function (s, o, f) {
  730. var i, j, k, key, v, meta, saved=[], token,
  731. DUMP='dump', SPACE=' ', LBRACE='{', RBRACE='}',
  732. dump, objstr;
  733. for (;;) {
  734. i = s.lastIndexOf(LBRACE);
  735. if (i < 0) {
  736. break;
  737. }
  738. j = s.indexOf(RBRACE, i);
  739. if (i + 1 >= j) {
  740. break;
  741. }
  742. //Extract key and meta info
  743. token = s.substring(i + 1, j);
  744. key = token;
  745. meta = null;
  746. k = key.indexOf(SPACE);
  747. if (k > -1) {
  748. meta = key.substring(k + 1);
  749. key = key.substring(0, k);
  750. }
  751. // lookup the value
  752. v = o[key];
  753. // if a substitution function was provided, execute it
  754. if (f) {
  755. v = f(key, v, meta);
  756. }
  757. if (L.isObject(v)) {
  758. if (L.isArray(v)) {
  759. v = L.dump(v, parseInt(meta, 10));
  760. } else {
  761. meta = meta || "";
  762. // look for the keyword 'dump', if found force obj dump
  763. dump = meta.indexOf(DUMP);
  764. if (dump > -1) {
  765. meta = meta.substring(4);
  766. }
  767. objstr = v.toString();
  768. // use the toString if it is not the Object toString
  769. // and the 'dump' meta info was not found
  770. if (objstr === OBJECT_TOSTRING || dump > -1) {
  771. v = L.dump(v, parseInt(meta, 10));
  772. } else {
  773. v = objstr;
  774. }
  775. }
  776. } else if (!L.isString(v) && !L.isNumber(v)) {
  777. // This {block} has no replace string. Save it for later.
  778. v = "~-" + saved.length + "-~";
  779. saved[saved.length] = token;
  780. // break;
  781. }
  782. s = s.substring(0, i) + v + s.substring(j + 1);
  783. }
  784. // restore saved {block}s
  785. for (i=saved.length-1; i>=0; i=i-1) {
  786. s = s.replace(new RegExp("~-" + i + "-~"), "{" + saved[i] + "}", "g");
  787. }
  788. return s;
  789. },
  790. /**
  791. * Returns a string without any leading or trailing whitespace. If
  792. * the input is not a string, the input will be returned untouched.
  793. * @method trim
  794. * @since 2.3.0
  795. * @param s {string} the string to trim
  796. * @return {string} the trimmed string
  797. */
  798. trim: function(s){
  799. try {
  800. return s.replace(/^\s+|\s+$/g, "");
  801. } catch(e) {
  802. return s;
  803. }
  804. },
  805. /**
  806. * Returns a new object containing all of the properties of
  807. * all the supplied objects. The properties from later objects
  808. * will overwrite those in earlier objects.
  809. * @method merge
  810. * @since 2.3.0
  811. * @param arguments {Object*} the objects to merge
  812. * @return the new merged object
  813. */
  814. merge: function() {
  815. var o={}, a=arguments, l=a.length, i;
  816. for (i=0; i<l; i=i+1) {
  817. L.augmentObject(o, a[i], true);
  818. }
  819. return o;
  820. },
  821. /**
  822. * Executes the supplied function in the context of the supplied
  823. * object 'when' milliseconds later. Executes the function a
  824. * single time unless periodic is set to true.
  825. * @method later
  826. * @since 2.4.0
  827. * @param when {int} the number of milliseconds to wait until the fn
  828. * is executed
  829. * @param o the context object
  830. * @param fn {Function|String} the function to execute or the name of
  831. * the method in the 'o' object to execute
  832. * @param data [Array] data that is provided to the function. This accepts
  833. * either a single item or an array. If an array is provided, the
  834. * function is executed with one parameter for each array item. If
  835. * you need to pass a single array parameter, it needs to be wrapped in
  836. * an array [myarray]
  837. * @param periodic {boolean} if true, executes continuously at supplied
  838. * interval until canceled
  839. * @return a timer object. Call the cancel() method on this object to
  840. * stop the timer.
  841. */
  842. later: function(when, o, fn, data, periodic) {
  843. when = when || 0;
  844. o = o || {};
  845. var m=fn, d=data, f, r;
  846. if (L.isString(fn)) {
  847. m = o[fn];
  848. }
  849. if (!m) {
  850. throw new TypeError("method undefined");
  851. }
  852. if (d && !L.isArray(d)) {
  853. d = [data];
  854. }
  855. f = function() {
  856. m.apply(o, d || NOTHING);
  857. };
  858. r = (periodic) ? setInterval(f, when) : setTimeout(f, when);
  859. return {
  860. interval: periodic,
  861. cancel: function() {
  862. if (this.interval) {
  863. clearInterval(r);
  864. } else {
  865. clearTimeout(r);
  866. }
  867. }
  868. };
  869. },
  870. /**
  871. * A convenience method for detecting a legitimate non-null value.
  872. * Returns false for null/undefined/NaN, true for other values,
  873. * including 0/false/''
  874. * @method isValue
  875. * @since 2.3.0
  876. * @param o {any} the item to test
  877. * @return {boolean} true if it is not null/undefined/NaN || false
  878. */
  879. isValue: function(o) {
  880. // return (o || o === false || o === 0 || o === ''); // Infinity fails
  881. return (L.isObject(o) || L.isString(o) || L.isNumber(o) || L.isBoolean(o));
  882. }
  883. };
  884. /**
  885. * Determines whether or not the property was added
  886. * to the object instance. Returns false if the property is not present
  887. * in the object, or was inherited from the prototype.
  888. * This abstraction is provided to enable hasOwnProperty for Safari 1.3.x.
  889. * There is a discrepancy between YAHOO.lang.hasOwnProperty and
  890. * Object.prototype.hasOwnProperty when the property is a primitive added to
  891. * both the instance AND prototype with the same value:
  892. * <pre>
  893. * var A = function() {};
  894. * A.prototype.foo = 'foo';
  895. * var a = new A();
  896. * a.foo = 'foo';
  897. * alert(a.hasOwnProperty('foo')); // true
  898. * alert(YAHOO.lang.hasOwnProperty(a, 'foo')); // false when using fallback
  899. * </pre>
  900. * @method hasOwnProperty
  901. * @param {any} o The object being testing
  902. * @param prop {string} the name of the property to test
  903. * @return {boolean} the result
  904. */
  905. L.hasOwnProperty = (OP.hasOwnProperty) ?
  906. function(o, prop) {
  907. return o && o.hasOwnProperty(prop);
  908. } : function(o, prop) {
  909. return !L.isUndefined(o[prop]) &&
  910. o.constructor.prototype[prop] !== o[prop];
  911. };
  912. // new lang wins
  913. OB.augmentObject(L, OB, true);
  914. /*
  915. * An alias for <a href="YAHOO.lang.html">YAHOO.lang</a>
  916. * @class YAHOO.util.Lang
  917. */
  918. YAHOO.util.Lang = L;
  919. /**
  920. * Same as YAHOO.lang.augmentObject, except it only applies prototype
  921. * properties. This is an alias for augmentProto.
  922. * @see YAHOO.lang.augmentObject
  923. * @method augment
  924. * @static
  925. * @param {Function} r the object to receive the augmentation
  926. * @param {Function} s the object that supplies the properties to augment
  927. * @param {String*|boolean} arguments zero or more properties methods to
  928. * augment the receiver with. If none specified, everything
  929. * in the supplier will be used unless it would
  930. * overwrite an existing property in the receiver. if true
  931. * is specified as the third parameter, all properties will
  932. * be applied and will overwrite an existing property in
  933. * the receiver
  934. */
  935. L.augment = L.augmentProto;
  936. /**
  937. * An alias for <a href="YAHOO.lang.html#augment">YAHOO.lang.augment</a>
  938. * @for YAHOO
  939. * @method augment
  940. * @static
  941. * @param {Function} r the object to receive the augmentation
  942. * @param {Function} s the object that supplies the properties to augment
  943. * @param {String*} arguments zero or more properties methods to
  944. * augment the receiver with. If none specified, everything
  945. * in the supplier will be used unless it would
  946. * overwrite an existing property in the receiver
  947. */
  948. YAHOO.augment = L.augmentProto;
  949. /**
  950. * An alias for <a href="YAHOO.lang.html#extend">YAHOO.lang.extend</a>
  951. * @method extend
  952. * @static
  953. * @param {Function} subc the object to modify
  954. * @param {Function} superc the object to inherit
  955. * @param {Object} overrides additional properties/methods to add to the
  956. * subclass prototype. These will override the
  957. * matching items obtained from the superclass if present.
  958. */
  959. YAHOO.extend = L.extend;
  960. })();
  961. YAHOO.register("yahoo", YAHOO, {version: "2.8.0r4", build: "2449"});
  962. /**
  963. * Provides a mechanism to fetch remote resources and
  964. * insert them into a document
  965. * @module get
  966. * @requires yahoo
  967. */
  968. /**
  969. * Fetches and inserts one or more script or link nodes into the document
  970. * @namespace YAHOO.util
  971. * @class YAHOO.util.Get
  972. */
  973. YAHOO.util.Get = function() {
  974. /**
  975. * hash of queues to manage multiple requests
  976. * @property queues
  977. * @private
  978. */
  979. var queues={},
  980. /**
  981. * queue index used to generate transaction ids
  982. * @property qidx
  983. * @type int
  984. * @private
  985. */
  986. qidx=0,
  987. /**
  988. * node index used to generate unique node ids
  989. * @property nidx
  990. * @type int
  991. * @private
  992. */
  993. nidx=0,
  994. // ridx=0,
  995. // sandboxFrame=null,
  996. /**
  997. * interal property used to prevent multiple simultaneous purge
  998. * processes
  999. * @property purging
  1000. * @type boolean
  1001. * @private
  1002. */
  1003. purging=false,
  1004. ua=YAHOO.env.ua,
  1005. lang=YAHOO.lang;
  1006. /**
  1007. * Generates an HTML element, this is not appended to a document
  1008. * @method _node
  1009. * @param type {string} the type of element
  1010. * @param attr {string} the attributes
  1011. * @param win {Window} optional window to create the element in
  1012. * @return {HTMLElement} the generated node
  1013. * @private
  1014. */
  1015. var _node = function(type, attr, win) {
  1016. var w = win || window, d=w.document, n=d.createElement(type);
  1017. for (var i in attr) {
  1018. if (attr[i] && YAHOO.lang.hasOwnProperty(attr, i)) {
  1019. n.setAttribute(i, attr[i]);
  1020. }
  1021. }
  1022. return n;
  1023. };
  1024. /**
  1025. * Generates a link node
  1026. * @method _linkNode
  1027. * @param url {string} the url for the css file
  1028. * @param win {Window} optional window to create the node in
  1029. * @return {HTMLElement} the generated node
  1030. * @private
  1031. */
  1032. var _linkNode = function(url, win, attributes) {
  1033. var o = {
  1034. id: "yui__dyn_" + (nidx++),
  1035. type: "text/css",
  1036. rel: "stylesheet",
  1037. href: url
  1038. };
  1039. if (attributes) {
  1040. lang.augmentObject(o, attributes);
  1041. }
  1042. return _node("link", o, win);
  1043. };
  1044. /**
  1045. * Generates a script node
  1046. * @method _scriptNode
  1047. * @param url {string} the url for the script file
  1048. * @param win {Window} optional window to create the node in
  1049. * @return {HTMLElement} the generated node
  1050. * @private
  1051. */
  1052. var _scriptNode = function(url, win, attributes) {
  1053. var o = {
  1054. id: "yui__dyn_" + (nidx++),
  1055. type: "text/javascript",
  1056. src: url
  1057. };
  1058. if (attributes) {
  1059. lang.augmentObject(o, attributes);
  1060. }
  1061. return _node("script", o, win);
  1062. };
  1063. /**
  1064. * Returns the data payload for callback functions
  1065. * @method _returnData
  1066. * @private
  1067. */
  1068. var _returnData = function(q, msg) {
  1069. return {
  1070. tId: q.tId,
  1071. win: q.win,
  1072. data: q.data,
  1073. nodes: q.nodes,
  1074. msg: msg,
  1075. purge: function() {
  1076. _purge(this.tId);
  1077. }
  1078. };
  1079. };
  1080. var _get = function(nId, tId) {
  1081. var q = queues[tId],
  1082. n = (lang.isString(nId)) ? q.win.document.getElementById(nId) : nId;
  1083. if (!n) {
  1084. _fail(tId, "target node not found: " + nId);
  1085. }
  1086. return n;
  1087. };
  1088. /*
  1089. * The request failed, execute fail handler with whatever
  1090. * was accomplished. There isn't a failure case at the
  1091. * moment unless you count aborted transactions
  1092. * @method _fail
  1093. * @param id {string} the id of the request
  1094. * @private
  1095. */
  1096. var _fail = function(id, msg) {
  1097. var q = queues[id];
  1098. // execute failure callback
  1099. if (q.onFailure) {
  1100. var sc=q.scope || q.win;
  1101. q.onFailure.call(sc, _returnData(q, msg));
  1102. }
  1103. };
  1104. /**
  1105. * The request is complete, so executing the requester's callback
  1106. * @method _finish
  1107. * @param id {string} the id of the request
  1108. * @private
  1109. */
  1110. var _finish = function(id) {
  1111. var q = queues[id];
  1112. q.finished = true;
  1113. if (q.aborted) {
  1114. var msg = "transaction " + id + " was aborted";
  1115. _fail(id, msg);
  1116. return;
  1117. }
  1118. // execute success callback
  1119. if (q.onSuccess) {
  1120. var sc=q.scope || q.win;
  1121. q.onSuccess.call(sc, _returnData(q));
  1122. }
  1123. };
  1124. /**
  1125. * Timeout detected
  1126. * @method _timeout
  1127. * @param id {string} the id of the request
  1128. * @private
  1129. */
  1130. var _timeout = function(id) {
  1131. var q = queues[id];
  1132. if (q.onTimeout) {
  1133. var sc=q.scope || q;
  1134. q.onTimeout.call(sc, _returnData(q));
  1135. }
  1136. };
  1137. /**
  1138. * Loads the next item for a given request
  1139. * @method _next
  1140. * @param id {string} the id of the request
  1141. * @param loaded {string} the url that was just loaded, if any
  1142. * @private
  1143. */
  1144. var _next = function(id, loaded) {
  1145. var q = queues[id];
  1146. if (q.timer) {
  1147. // Y.log('cancel timer');
  1148. q.timer.cancel();
  1149. }
  1150. if (q.aborted) {
  1151. var msg = "transaction " + id + " was aborted";
  1152. _fail(id, msg);
  1153. return;
  1154. }
  1155. if (loaded) {
  1156. q.url.shift();
  1157. if (q.varName) {
  1158. q.varName.shift();
  1159. }
  1160. } else {
  1161. // This is the first pass: make sure the url is an array
  1162. q.url = (lang.isString(q.url)) ? [q.url] : q.url;
  1163. if (q.varName) {
  1164. q.varName = (lang.isString(q.varName)) ? [q.varName] : q.varName;
  1165. }
  1166. }
  1167. var w=q.win, d=w.document, h=d.getElementsByTagName("head")[0], n;
  1168. if (q.url.length === 0) {
  1169. // Safari 2.x workaround - There is no way to know when
  1170. // a script is ready in versions of Safari prior to 3.x.
  1171. // Adding an extra node reduces the problem, but doesn't
  1172. // eliminate it completely because the browser executes
  1173. // them asynchronously.
  1174. if (q.type === "script" && ua.webkit && ua.webkit < 420 &&
  1175. !q.finalpass && !q.varName) {
  1176. // Add another script node. This does not guarantee that the
  1177. // scripts will execute in order, but it does appear to fix the
  1178. // problem on fast connections more effectively than using an
  1179. // arbitrary timeout. It is possible that the browser does
  1180. // block subsequent script execution in this case for a limited
  1181. // time.
  1182. var extra = _scriptNode(null, q.win, q.attributes);
  1183. extra.innerHTML='YAHOO.util.Get._finalize("' + id + '");';
  1184. q.nodes.push(extra); h.appendChild(extra);
  1185. } else {
  1186. _finish(id);
  1187. }
  1188. return;
  1189. }
  1190. var url = q.url[0];
  1191. // if the url is undefined, this is probably a trailing comma problem in IE
  1192. if (!url) {
  1193. q.url.shift();
  1194. return _next(id);
  1195. }
  1196. if (q.timeout) {
  1197. // Y.log('create timer');
  1198. q.timer = lang.later(q.timeout, q, _timeout, id);
  1199. }
  1200. if (q.type === "script") {
  1201. n = _scriptNode(url, w, q.attributes);
  1202. } else {
  1203. n = _linkNode(url, w, q.attributes);
  1204. }
  1205. // track this node's load progress
  1206. _track(q.type, n, id, url, w, q.url.length);
  1207. // add the node to the queue so we can return it to the user supplied callback
  1208. q.nodes.push(n);
  1209. // add it to the head or insert it before 'insertBefore'
  1210. if (q.insertBefore) {
  1211. var s = _get(q.insertBefore, id);
  1212. if (s) {
  1213. s.parentNode.insertBefore(n, s);
  1214. }
  1215. } else {
  1216. h.appendChild(n);
  1217. }
  1218. // FireFox does not support the onload event for link nodes, so there is
  1219. // no way to make the css requests synchronous. This means that the css
  1220. // rules in multiple files could be applied out of order in this browser
  1221. // if a later request returns before an earlier one. Safari too.
  1222. if ((ua.webkit || ua.gecko) && q.type === "css") {
  1223. _next(id, url);
  1224. }
  1225. };
  1226. /**
  1227. * Removes processed queues and corresponding nodes
  1228. * @method _autoPurge
  1229. * @private
  1230. */
  1231. var _autoPurge = function() {
  1232. if (purging) {
  1233. return;
  1234. }
  1235. purging = true;
  1236. for (var i in queues) {
  1237. var q = queues[i];
  1238. if (q.autopurge && q.finished) {
  1239. _purge(q.tId);
  1240. delete queues[i];
  1241. }
  1242. }
  1243. purging = false;
  1244. };
  1245. /**
  1246. * Removes the nodes for the specified queue
  1247. * @method _purge
  1248. * @private
  1249. */
  1250. var _purge = function(tId) {
  1251. if (queues[tId]) {
  1252. var q = queues[tId],
  1253. nodes = q.nodes,
  1254. l = nodes.length,
  1255. d = q.win.document,
  1256. h = d.getElementsByTagName("head")[0],
  1257. sib, i, node, attr;
  1258. if (q.insertBefore) {
  1259. sib = _get(q.insertBefore, tId);
  1260. if (sib) {
  1261. h = sib.parentNode;
  1262. }
  1263. }
  1264. for (i=0; i<l; i=i+1) {
  1265. node = nodes[i];
  1266. if (node.clearAttributes) {
  1267. node.clearAttributes();
  1268. } else {
  1269. for (attr in node) {
  1270. delete node[attr];
  1271. }
  1272. }
  1273. h.removeChild(node);
  1274. }
  1275. q.nodes = [];
  1276. }
  1277. };
  1278. /**
  1279. * Saves the state for the request and begins loading
  1280. * the requested urls
  1281. * @method queue
  1282. * @param type {string} the type of node to insert
  1283. * @param url {string} the url to load
  1284. * @param opts the hash of options for this request
  1285. * @private
  1286. */
  1287. var _queue = function(type, url, opts) {
  1288. var id = "q" + (qidx++);
  1289. opts = opts || {};
  1290. if (qidx % YAHOO.util.Get.PURGE_THRESH === 0) {
  1291. _autoPurge();
  1292. }
  1293. queues[id] = lang.merge(opts, {
  1294. tId: id,
  1295. type: type,
  1296. url: url,
  1297. finished: false,
  1298. aborted: false,
  1299. nodes: []
  1300. });
  1301. var q = queues[id];
  1302. q.win = q.win || window;
  1303. q.scope = q.scope || q.win;
  1304. q.autopurge = ("autopurge" in q) ? q.autopurge :
  1305. (type === "script") ? true : false;
  1306. if (opts.charset) {
  1307. q.attributes = q.attributes || {};
  1308. q.attributes.charset = opts.charset;
  1309. }
  1310. lang.later(0, q, _next, id);
  1311. return {
  1312. tId: id
  1313. };
  1314. };
  1315. /**
  1316. * Detects when a node has been loaded. In the case of
  1317. * script nodes, this does not guarantee that contained
  1318. * script is ready to use.
  1319. * @method _track
  1320. * @param type {string} the type of node to track
  1321. * @param n {HTMLElement} the node to track
  1322. * @param id {string} the id of the request
  1323. * @param url {string} the url that is being loaded
  1324. * @param win {Window} the targeted window
  1325. * @param qlength the number of remaining items in the queue,
  1326. * including this one
  1327. * @param trackfn {Function} function to execute when finished
  1328. * the default is _next
  1329. * @private
  1330. */
  1331. var _track = function(type, n, id, url, win, qlength, trackfn) {
  1332. var f = trackfn || _next;
  1333. // IE supports the readystatechange event for script and css nodes
  1334. if (ua.ie) {
  1335. n.onreadystatechange = function() {
  1336. var rs = this.readyState;
  1337. if ("loaded" === rs || "complete" === rs) {
  1338. n.onreadystatechange = null;
  1339. f(id, url);
  1340. }
  1341. };
  1342. // webkit prior to 3.x is problemmatic
  1343. } else if (ua.webkit) {
  1344. if (type === "script") {
  1345. // Safari 3.x supports the load event for script nodes (DOM2)
  1346. if (ua.webkit >= 420) {
  1347. n.addEventListener("load", function() {
  1348. f(id, url);
  1349. });
  1350. // Nothing can be done with Safari < 3.x except to pause and hope
  1351. // for the best, particularly after last script is inserted. The
  1352. // scripts will always execute in the order they arrive, not
  1353. // necessarily the order in which they were inserted. To support
  1354. // script nodes with complete reliability in these browsers, script
  1355. // nodes either need to invoke a function in the window once they
  1356. // are loaded or the implementer needs to provide a well-known
  1357. // property that the utility can poll for.
  1358. } else {
  1359. // Poll for the existence of the named variable, if it
  1360. // was supplied.
  1361. var q = queues[id];
  1362. if (q.varName) {
  1363. var freq=YAHOO.util.Get.POLL_FREQ;
  1364. q.maxattempts = YAHOO.util.Get.TIMEOUT/freq;
  1365. q.attempts = 0;
  1366. q._cache = q.varName[0].split(".");
  1367. q.timer = lang.later(freq, q, function(o) {
  1368. var a=this._cache, l=a.length, w=this.win, i;
  1369. for (i=0; i<l; i=i+1) {
  1370. w = w[a[i]];
  1371. if (!w) {
  1372. // if we have exausted our attempts, give up
  1373. this.attempts++;
  1374. if (this.attempts++ > this.maxattempts) {
  1375. var msg = "Over retry limit, giving up";
  1376. q.timer.cancel();
  1377. _fail(id, msg);
  1378. } else {
  1379. }
  1380. return;
  1381. }
  1382. }
  1383. q.timer.cancel();
  1384. f(id, url);
  1385. }, null, true);
  1386. } else {
  1387. lang.later(YAHOO.util.Get.POLL_FREQ, null, f, [id, url]);
  1388. }
  1389. }
  1390. }
  1391. // FireFox and Opera support onload (but not DOM2 in FF) handlers for
  1392. // script nodes. Opera, but not FF, supports the onload event for link
  1393. // nodes.
  1394. } else {
  1395. n.onload = function() {
  1396. f(id, url);
  1397. };
  1398. }
  1399. };
  1400. return {
  1401. /**
  1402. * The default poll freqency in ms, when needed
  1403. * @property POLL_FREQ
  1404. * @static
  1405. * @type int
  1406. * @default 10
  1407. */
  1408. POLL_FREQ: 10,
  1409. /**
  1410. * The number of request required before an automatic purge.
  1411. * property PURGE_THRESH
  1412. * @static
  1413. * @type int
  1414. * @default 20
  1415. */
  1416. PURGE_THRESH: 20,
  1417. /**
  1418. * The length time to poll for varName when loading a script in
  1419. * Safari 2.x before the transaction fails.
  1420. * property TIMEOUT
  1421. * @static
  1422. * @type int
  1423. * @default 2000
  1424. */
  1425. TIMEOUT: 2000,
  1426. /**
  1427. * Called by the the helper for detecting script load in Safari
  1428. * @method _finalize
  1429. * @param id {string} the transaction id
  1430. * @private
  1431. */
  1432. _finalize: function(id) {
  1433. lang.later(0, null, _finish, id);
  1434. },
  1435. /**
  1436. * Abort a transaction
  1437. * @method abort
  1438. * @param {string|object} either the tId or the object returned from
  1439. * script() or css()
  1440. */
  1441. abort: function(o) {
  1442. var id = (lang.isString(o)) ? o : o.tId;
  1443. var q = queues[id];
  1444. if (q) {
  1445. q.aborted = true;
  1446. }
  1447. },
  1448. /**
  1449. * Fetches and inserts one or more script nodes into the head
  1450. * of the current document or the document in a specified window.
  1451. *
  1452. * @method script
  1453. * @static
  1454. * @param url {string|string[]} the url or urls to the script(s)
  1455. * @param opts {object} Options:
  1456. * <dl>
  1457. * <dt>onSuccess</dt>
  1458. * <dd>
  1459. * callback to execute when the script(s) are finished loading
  1460. * The callback receives an object back with the following
  1461. * data:
  1462. * <dl>
  1463. * <dt>win</dt>
  1464. * <dd>the window the script(s) were inserted into</dd>
  1465. * <dt>data</dt>
  1466. * <dd>the data object passed in when the request was made</dd>
  1467. * <dt>nodes</dt>
  1468. * <dd>An array containing references to the nodes that were
  1469. * inserted</dd>
  1470. * <dt>purge</dt>
  1471. * <dd>A function that, when executed, will remove the nodes
  1472. * that were inserted</dd>
  1473. * <dt>
  1474. * </dl>
  1475. * </dd>
  1476. * <dt>onFailure</dt>
  1477. * <dd>
  1478. * callback to execute when the script load operation fails
  1479. * The callback receives an object back with the following
  1480. * data:
  1481. * <dl>
  1482. * <dt>win</dt>
  1483. * <dd>the window the script(s) were inserted into</dd>
  1484. * <dt>data</dt>
  1485. * <dd>the data object passed in when the request was made</dd>
  1486. * <dt>nodes</dt>
  1487. * <dd>An array containing references to the nodes that were
  1488. * inserted successfully</dd>
  1489. * <dt>purge</dt>
  1490. * <dd>A function that, when executed, will remove any nodes
  1491. * that were inserted</dd>
  1492. * <dt>
  1493. * </dl>
  1494. * </dd>
  1495. * <dt>onTimeout</dt>
  1496. * <dd>
  1497. * callback to execute when a timeout occurs.
  1498. * The callback receives an object back with the following
  1499. * data:
  1500. * <dl>
  1501. * <dt>win</dt>
  1502. * <dd>the window the script(s) were inserted into</dd>
  1503. * <dt>data</dt>
  1504. * <dd>the data object passed in when the request was made</dd>
  1505. * <dt>nodes</dt>
  1506. * <dd>An array containing references to the nodes that were
  1507. * inserted</dd>
  1508. * <dt>purge</dt>
  1509. * <dd>A function that, when executed, will remove the nodes
  1510. * that were inserted</dd>
  1511. * <dt>
  1512. * </dl>
  1513. * </dd>
  1514. * <dt>scope</dt>
  1515. * <dd>the execution context for the callbacks</dd>
  1516. * <dt>win</dt>
  1517. * <dd>a window other than the one the utility occupies</dd>
  1518. * <dt>autopurge</dt>
  1519. * <dd>
  1520. * setting to true will let the utilities cleanup routine purge
  1521. * the script once loaded
  1522. * </dd>
  1523. * <dt>data</dt>
  1524. * <dd>
  1525. * data that is supplied to the callback when the script(s) are
  1526. * loaded.
  1527. * </dd>
  1528. * <dt>varName</dt>
  1529. * <dd>
  1530. * variable that should be available when a script is finished
  1531. * loading. Used to help Safari 2.x and below with script load
  1532. * detection. The type of this property should match what was
  1533. * passed into the url parameter: if loading a single url, a
  1534. * string can be supplied. If loading multiple scripts, you
  1535. * must supply an array that contains the variable name for
  1536. * each script.
  1537. * </dd>
  1538. * <dt>insertBefore</dt>
  1539. * <dd>node or node id that will become the new node's nextSibling</dd>
  1540. * </dl>
  1541. * <dt>charset</dt>
  1542. * <dd>Node charset, deprecated, use 'attributes'</dd>
  1543. * <dt>attributes</dt>
  1544. * <dd>A hash of attributes to apply to dynamic nodes.</dd>
  1545. * <dt>timeout</dt>
  1546. * <dd>Number of milliseconds to wait before aborting and firing the timeout event</dd>
  1547. * <pre>
  1548. * // assumes yahoo, dom, and event are already on the page
  1549. * &nbsp;&nbsp;YAHOO.util.Get.script(
  1550. * &nbsp;&nbsp;["http://yui.yahooapis.com/2.7.0/build/dragdrop/dragdrop-min.js",
  1551. * &nbsp;&nbsp;&nbsp;"http://yui.yahooapis.com/2.7.0/build/animation/animation-min.js"], &#123;
  1552. * &nbsp;&nbsp;&nbsp;&nbsp;onSuccess: function(o) &#123;
  1553. * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new YAHOO.util.DDProxy("dd1"); // also new o.reference("dd1"); would work
  1554. * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.log("won't cause error because YAHOO is the scope");
  1555. * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.log(o.nodes.length === 2) // true
  1556. * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// o.purge(); // optionally remove the script nodes immediately
  1557. * &nbsp;&nbsp;&nbsp;&nbsp;&#125;,
  1558. * &nbsp;&nbsp;&nbsp;&nbsp;onFailure: function(o) &#123;
  1559. * &nbsp;&nbsp;&nbsp;&nbsp;&#125;,
  1560. * &nbsp;&nbsp;&nbsp;&nbsp;data: "foo",
  1561. * &nbsp;&nbsp;&nbsp;&nbsp;timeout: 10000, // 10 second timeout
  1562. * &nbsp;&nbsp;&nbsp;&nbsp;scope: YAHOO,
  1563. * &nbsp;&nbsp;&nbsp;&nbsp;// win: otherframe // target another window/frame
  1564. * &nbsp;&nbsp;&nbsp;&nbsp;autopurge: true // allow the utility to choose when to remove the nodes
  1565. * &nbsp;&nbsp;&#125;);
  1566. * </pre>
  1567. * @return {tId: string} an object containing info about the transaction
  1568. */
  1569. script: function(url, opts) { return _queue("script", url, opts); },
  1570. /**
  1571. * Fetches and inserts one or more css link nodes into the
  1572. * head of the current document or the document in a specified
  1573. * window.
  1574. * @method css
  1575. * @static
  1576. * @param url {string} the url or urls to the css file(s)
  1577. * @param opts Options:
  1578. * <dl>
  1579. * <dt>onSuccess</dt>
  1580. * <dd>
  1581. * callback to execute when the css file(s) are finished loading
  1582. * The callback receives an object back with the following
  1583. * data:
  1584. * <dl>win</dl>
  1585. * <dd>the window the link nodes(s) were inserted into</dd>
  1586. * <dt>data</dt>
  1587. * <dd>the data object passed in when the request was made</dd>
  1588. * <dt>nodes</dt>
  1589. * <dd>An array containing references to the nodes that were
  1590. * inserted</dd>
  1591. * <dt>purge</dt>
  1592. * <dd>A function that, when executed, will remove the nodes
  1593. * that were inserted</dd>
  1594. * <dt>
  1595. * </dl>
  1596. * </dd>
  1597. * <dt>scope</dt>
  1598. * <dd>the execution context for the callbacks</dd>
  1599. * <dt>win</dt>
  1600. * <dd>a window other than the one the utility occupies</dd>
  1601. * <dt>data</dt>
  1602. * <dd>
  1603. * data that is supplied to the callbacks when the nodes(s) are
  1604. * loaded.
  1605. * </dd>
  1606. * <dt>insertBefore</dt>
  1607. * <dd>node or node id that will become the new node's nextSibling</dd>
  1608. * <dt>charset</dt>
  1609. * <dd>Node charset, deprecated, use 'attributes'</dd>
  1610. * <dt>attributes</dt>
  1611. * <dd>A hash of attributes to apply to dynamic nodes.</dd>
  1612. * </dl>
  1613. * <pre>
  1614. * YAHOO.util.Get.css("http://yui.yahooapis.com/2.7.0/build/menu/assets/skins/sam/menu.css");
  1615. * </pre>
  1616. * <pre>
  1617. * YAHOO.util.Get.css(["http://yui.yahooapis.com/2.7.0/build/menu/assets/skins/sam/menu.css",
  1618. * </pre>
  1619. * @return {tId: string} an object containing info about the transaction
  1620. */
  1621. css: function(url, opts) {
  1622. return _queue("css", url, opts);
  1623. }
  1624. };
  1625. }();
  1626. YAHOO.register("get", YAHOO.util.Get, {version: "2.8.0r4", build: "2449"});
  1627. /**
  1628. * Provides dynamic loading for the YUI library. It includes the dependency
  1629. * info for the library, and will automatically pull in dependencies for
  1630. * the modules requested. It supports rollup files (such as utilities.js
  1631. * and yahoo-dom-event.js), and will automatically use these when
  1632. * appropriate in order to minimize the number of http connections
  1633. * required to load all of the dependencies.
  1634. *
  1635. * @module yuiloader
  1636. * @namespace YAHOO.util
  1637. */
  1638. /**
  1639. * YUILoader provides dynamic loading for YUI.
  1640. * @class YAHOO.util.YUILoader
  1641. * @todo
  1642. * version management, automatic sandboxing
  1643. */
  1644. (function() {
  1645. var Y=YAHOO, util=Y.util, lang=Y.lang, env=Y.env,
  1646. PROV = "_provides", SUPER = "_supersedes",
  1647. REQ = "expanded", AFTER = "_after";
  1648. var YUI = {
  1649. dupsAllowed: {'yahoo': true, 'get': true},
  1650. /*
  1651. * The library metadata for the current release The is the default
  1652. * value for YAHOO.util.YUILoader.moduleInfo
  1653. * @property YUIInfo
  1654. * @static
  1655. */
  1656. info: {
  1657. // 'root': '2.5.2/build/',
  1658. // 'base': 'http://yui.yahooapis.com/2.5.2/build/',
  1659. 'root': '2.8.0r4/build/',
  1660. 'base': 'http://yui.yahooapis.com/2.8.0r4/build/',
  1661. 'comboBase': 'http://yui.yahooapis.com/combo?',
  1662. 'skin': {
  1663. 'defaultSkin': 'sam',
  1664. 'base': 'assets/skins/',
  1665. 'path': 'skin.css',
  1666. 'after': ['reset', 'fonts', 'grids', 'base'],
  1667. 'rollup': 3
  1668. },
  1669. dupsAllowed: ['yahoo', 'get'],
  1670. 'moduleInfo': {
  1671. 'animation': {
  1672. 'type': 'js',
  1673. 'path': 'animation/animation-min.js',
  1674. 'requires': ['dom', 'event']
  1675. },
  1676. 'autocomplete': {
  1677. 'type': 'js',
  1678. 'path': 'autocomplete/autocomplete-min.js',
  1679. 'requires': ['dom', 'event', 'datasource'],
  1680. 'optional': ['connection', 'animation'],
  1681. 'skinnable': true
  1682. },
  1683. 'base': {
  1684. 'type': 'css',
  1685. 'path': 'base/base-min.css',
  1686. 'after': ['reset', 'fonts', 'grids']
  1687. },
  1688. 'button': {
  1689. 'type': 'js',
  1690. 'path': 'button/button-min.js',
  1691. 'requires': ['element'],
  1692. 'optional': ['menu'],
  1693. 'skinnable': true
  1694. },
  1695. 'calendar': {
  1696. 'type': 'js',
  1697. 'path': 'calendar/calendar-min.js',
  1698. 'requires': ['event', 'dom'],
  1699. supersedes: ['datemeth'],
  1700. 'skinnable': true
  1701. },
  1702. 'carousel': {
  1703. 'type': 'js',
  1704. 'path': 'carousel/carousel-min.js',
  1705. 'requires': ['element'],
  1706. 'optional': ['animation'],
  1707. 'skinnable': true
  1708. },
  1709. 'charts': {
  1710. 'type': 'js',
  1711. 'path': 'charts/charts-min.js',
  1712. 'requires': ['element', 'json', 'datasource', 'swf']
  1713. },
  1714. 'colorpicker': {
  1715. 'type': 'js',
  1716. 'path': 'colorpicker/colorpicker-min.js',
  1717. 'requires': ['slider', 'element'],
  1718. 'optional': ['animation'],
  1719. 'skinnable': true
  1720. },
  1721. 'connection': {
  1722. 'type': 'js',
  1723. 'path': 'connection/connection-min.js',
  1724. 'requires': ['event'],
  1725. 'supersedes': ['connectioncore']
  1726. },
  1727. 'connectioncore': {
  1728. 'type': 'js',
  1729. 'path': 'connection/connection_core-min.js',
  1730. 'requires': ['event'],
  1731. 'pkg': 'connection'
  1732. },
  1733. 'container': {
  1734. 'type': 'js',
  1735. 'path': 'container/container-min.js',
  1736. 'requires': ['dom', 'event'],
  1737. // button is also optional, but this creates a circular
  1738. // dependency when loadOptional is specified. button
  1739. // optionally includes menu, menu requires container.
  1740. 'optional': ['dragdrop', 'animation', 'connection'],
  1741. 'supersedes': ['containercore'],
  1742. 'skinnable': true
  1743. },
  1744. 'containercore': {
  1745. 'type': 'js',
  1746. 'path': 'container/container_core-min.js',
  1747. 'requires': ['dom', 'event'],
  1748. 'pkg': 'container'
  1749. },
  1750. 'cookie': {
  1751. 'type': 'js',
  1752. 'path': 'cookie/cookie-min.js',
  1753. 'requires': ['yahoo']
  1754. },
  1755. 'datasource': {
  1756. 'type': 'js',
  1757. 'path': 'datasource/datasource-min.js',
  1758. 'requires': ['event'],
  1759. 'optional': ['connection']
  1760. },
  1761. 'datatable': {
  1762. 'type': 'js',
  1763. 'path': 'datatable/datatable-min.js',
  1764. 'requires': ['element', 'datasource'],
  1765. 'optional': ['calendar', 'dragdrop', 'paginator'],
  1766. 'skinnable': true
  1767. },
  1768. datemath: {
  1769. 'type': 'js',
  1770. 'path': 'datemath/datemath-min.js',
  1771. 'requires': ['yahoo']
  1772. },
  1773. 'dom': {
  1774. 'type': 'js',
  1775. 'path': 'dom/dom-min.js',
  1776. 'requires': ['yahoo']
  1777. },
  1778. 'dragdrop': {
  1779. 'type': 'js',
  1780. 'path': 'dragdrop/dragdrop-min.js',
  1781. 'requires': ['dom', 'event']
  1782. },
  1783. 'editor': {
  1784. 'type': 'js',
  1785. 'path': 'editor/editor-min.js',
  1786. 'requires': ['menu', 'element', 'button'],
  1787. 'optional': ['animation', 'dragdrop'],
  1788. 'supersedes': ['simpleeditor'],
  1789. 'skinnable': true
  1790. },
  1791. 'element': {
  1792. 'type': 'js',
  1793. 'path': 'element/element-min.js',
  1794. 'requires': ['dom', 'event'],
  1795. 'optional': ['event-mouseenter', 'event-delegate']
  1796. },
  1797. 'element-delegate': {
  1798. 'type': 'js',
  1799. 'path': 'element-delegate/element-delegate-min.js',
  1800. 'requires': ['element']
  1801. },
  1802. 'event': {
  1803. 'type': 'js',
  1804. 'path': 'event/event-min.js',
  1805. 'requires': ['yahoo']
  1806. },
  1807. 'event-simulate': {
  1808. 'type': 'js',
  1809. 'path': 'event-simulate/event-simulate-min.js',
  1810. 'requires': ['event']
  1811. },
  1812. 'event-delegate': {
  1813. 'type': 'js',
  1814. 'path': 'event-delegate/event-delegate-min.js',
  1815. 'requires': ['event'],
  1816. 'optional': ['selector']
  1817. },
  1818. 'event-mouseenter': {
  1819. 'type': 'js',
  1820. 'path': 'event-mouseenter/event-mouseenter-min.js',
  1821. 'requires': ['dom', 'event']
  1822. },
  1823. 'fonts': {
  1824. 'type': 'css',
  1825. 'path': 'fonts/fonts-min.css'
  1826. },
  1827. 'get': {
  1828. 'type': 'js',
  1829. 'path': 'get/get-min.js',
  1830. 'requires': ['yahoo']
  1831. },
  1832. 'grids': {
  1833. 'type': 'css',
  1834. 'path': 'grids/grids-min.css',
  1835. 'requires': ['fonts'],
  1836. 'optional': ['reset']
  1837. },
  1838. 'history': {
  1839. 'type': 'js',
  1840. 'path': 'history/history-min.js',
  1841. 'requires': ['event']
  1842. },
  1843. 'imagecropper': {
  1844. 'type': 'js',
  1845. 'path': 'imagecropper/imagecropper-min.js',
  1846. 'requires': ['dragdrop', 'element', 'resize'],
  1847. 'skinnable': true
  1848. },
  1849. 'imageloader': {
  1850. 'type': 'js',
  1851. 'path': 'imageloader/imageloader-min.js',
  1852. 'requires': ['event', 'dom']
  1853. },
  1854. 'json': {
  1855. 'type': 'js',
  1856. 'path': 'json/json-min.js',
  1857. 'requires': ['yahoo']
  1858. },
  1859. 'layout': {
  1860. 'type': 'js',
  1861. 'path': 'layout/layout-min.js',
  1862. 'requires': ['element'],
  1863. 'optional': ['animation', 'dragdrop', 'resize', 'selector'],
  1864. 'skinnable': true
  1865. },
  1866. 'logger': {
  1867. 'type': 'js',
  1868. 'path': 'logger/logger-min.js',
  1869. 'requires': ['event', 'dom'],
  1870. 'optional': ['dragdrop'],
  1871. 'skinnable': true
  1872. },
  1873. 'menu': {
  1874. 'type': 'js',
  1875. 'path': 'menu/menu-min.js',
  1876. 'requires': ['containercore'],
  1877. 'skinnable': true
  1878. },
  1879. 'paginator': {
  1880. 'type': 'js',
  1881. 'path': 'paginator/paginator-min.js',
  1882. 'requires': ['element'],
  1883. 'skinnable': true
  1884. },
  1885. 'profiler': {
  1886. 'type': 'js',
  1887. 'path': 'profiler/profiler-min.js',
  1888. 'requires': ['yahoo']
  1889. },
  1890. 'profilerviewer': {
  1891. 'type': 'js',
  1892. 'path': 'profilerviewer/profilerviewer-min.js',
  1893. 'requires': ['profiler', 'yuiloader', 'element'],
  1894. 'skinnable': true
  1895. },
  1896. 'progressbar': {
  1897. 'type': 'js',
  1898. 'path': 'progressbar/progressbar-min.js',
  1899. 'requires': ['element'],
  1900. 'optional': ['animation'],
  1901. 'skinnable': true
  1902. },
  1903. 'reset': {
  1904. 'type': 'css',
  1905. 'path': 'reset/reset-min.css'
  1906. },
  1907. 'reset-fonts-grids': {
  1908. 'type': 'css',
  1909. 'path': 'reset-fonts-grids/reset-fonts-grids.css',
  1910. 'supersedes': ['reset', 'fonts', 'grids', 'reset-fonts'],
  1911. 'rollup': 4
  1912. },
  1913. 'reset-fonts': {
  1914. 'type': 'css',
  1915. 'path': 'reset-fonts/reset-fonts.css',
  1916. 'supersedes': ['reset', 'fonts'],
  1917. 'rollup': 2
  1918. },
  1919. 'resize': {
  1920. 'type': 'js',
  1921. 'path': 'resize/resize-min.js',
  1922. 'requires': ['dragdrop', 'element'],
  1923. 'optional': ['animation'],
  1924. 'skinnable': true
  1925. },
  1926. 'selector': {
  1927. 'type': 'js',
  1928. 'path': 'selector/selector-min.js',
  1929. 'requires': ['yahoo', 'dom']
  1930. },
  1931. 'simpleeditor': {
  1932. 'type': 'js',
  1933. 'path': 'editor/simpleeditor-min.js',
  1934. 'requires': ['element'],
  1935. 'optional': ['containercore', 'menu', 'button', 'animation', 'dragdrop'],
  1936. 'skinnable': true,
  1937. 'pkg': 'editor'
  1938. },
  1939. 'slider': {
  1940. 'type': 'js',
  1941. 'path': 'slider/slider-min.js',
  1942. 'requires': ['dragdrop'],
  1943. 'optional': ['animation'],
  1944. 'skinnable': true
  1945. },
  1946. 'storage': {
  1947. 'type': 'js',
  1948. 'path': 'storage/storage-min.js',
  1949. 'requires': ['yahoo', 'event', 'cookie'],
  1950. 'optional': ['swfstore']
  1951. },
  1952. 'stylesheet': {
  1953. 'type': 'js',
  1954. 'path': 'stylesheet/stylesheet-min.js',
  1955. 'requires': ['yahoo']
  1956. },
  1957. 'swf': {
  1958. 'type': 'js',
  1959. 'path': 'swf/swf-min.js',
  1960. 'requires': ['element'],
  1961. 'supersedes': ['swfdetect']
  1962. },
  1963. 'swfdetect': {
  1964. 'type': 'js',
  1965. 'path': 'swfdetect/swfdetect-min.js',
  1966. 'requires': ['yahoo']
  1967. },
  1968. 'swfstore': {
  1969. 'type': 'js',
  1970. 'path': 'swfstore/swfstore-min.js',
  1971. 'requires': ['element', 'cookie', 'swf']
  1972. },
  1973. 'tabview': {
  1974. 'type': 'js',
  1975. 'path': 'tabview/tabview-min.js',
  1976. 'requires': ['element'],
  1977. 'optional': ['connection'],
  1978. 'skinnable': true
  1979. },
  1980. 'treeview': {
  1981. 'type': 'js',
  1982. 'path': 'treeview/treeview-min.js',
  1983. 'requires': ['event', 'dom'],
  1984. 'optional': ['json', 'animation', 'calendar'],
  1985. 'skinnable': true
  1986. },
  1987. 'uploader': {
  1988. 'type': 'js',
  1989. 'path': 'uploader/uploader-min.js',
  1990. 'requires': ['element']
  1991. },
  1992. 'utilities': {
  1993. 'type': 'js',
  1994. 'path': 'utilities/utilities.js',
  1995. 'supersedes': ['yahoo', 'event', 'dragdrop', 'animation', 'dom', 'connection', 'element', 'yahoo-dom-event', 'get', 'yuiloader', 'yuiloader-dom-event'],
  1996. 'rollup': 8
  1997. },
  1998. 'yahoo': {
  1999. 'type': 'js',
  2000. 'path': 'yahoo/yahoo-min.js'
  2001. },
  2002. 'yahoo-dom-event': {
  2003. 'type': 'js',
  2004. 'path': 'yahoo-dom-event/yahoo-dom-event.js',
  2005. 'supersedes': ['yahoo', 'event', 'dom'],
  2006. 'rollup': 3
  2007. },
  2008. 'yuiloader': {
  2009. 'type': 'js',
  2010. 'path': 'yuiloader/yuiloader-min.js',
  2011. 'supersedes': ['yahoo', 'get']
  2012. },
  2013. 'yuiloader-dom-event': {
  2014. 'type': 'js',
  2015. 'path': 'yuiloader-dom-event/yuiloader-dom-event.js',
  2016. 'supersedes': ['yahoo', 'dom', 'event', 'get', 'yuiloader', 'yahoo-dom-event'],
  2017. 'rollup': 5
  2018. },
  2019. 'yuitest': {
  2020. 'type': 'js',
  2021. 'path': 'yuitest/yuitest-min.js',
  2022. 'requires': ['logger'],
  2023. 'optional': ['event-simulate'],
  2024. 'skinnable': true
  2025. }
  2026. }
  2027. }
  2028. ,
  2029. ObjectUtil: {
  2030. appendArray: function(o, a) {
  2031. if (a) {
  2032. for (var i=0; i<a.length; i=i+1) {
  2033. o[a[i]] = true;
  2034. }
  2035. }
  2036. },
  2037. keys: function(o, ordered) {
  2038. var a=[], i;
  2039. for (i in o) {
  2040. if (lang.hasOwnProperty(o, i)) {
  2041. a.push(i);
  2042. }
  2043. }
  2044. return a;
  2045. }
  2046. },
  2047. ArrayUtil: {
  2048. appendArray: function(a1, a2) {
  2049. Array.prototype.push.apply(a1, a2);
  2050. /*
  2051. for (var i=0; i<a2.length; i=i+1) {
  2052. a1.push(a2[i]);
  2053. }
  2054. */
  2055. },
  2056. indexOf: function(a, val) {
  2057. for (var i=0; i<a.length; i=i+1) {
  2058. if (a[i] === val) {
  2059. return i;
  2060. }
  2061. }
  2062. return -1;
  2063. },
  2064. toObject: function(a) {
  2065. var o = {};
  2066. for (var i=0; i<a.length; i=i+1) {
  2067. o[a[i]] = true;
  2068. }
  2069. return o;
  2070. },
  2071. /*
  2072. * Returns a unique array. Does not maintain order, which is fine
  2073. * for this application, and performs better than it would if it
  2074. * did.
  2075. */
  2076. uniq: function(a) {
  2077. return YUI.ObjectUtil.keys(YUI.ArrayUtil.toObject(a));
  2078. }
  2079. }
  2080. };
  2081. YAHOO.util.YUILoader = function(o) {
  2082. /**
  2083. * Internal callback to handle multiple internal insert() calls
  2084. * so that css is inserted prior to js
  2085. * @property _internalCallback
  2086. * @private
  2087. */
  2088. this._internalCallback = null;
  2089. /**
  2090. * Use the YAHOO environment listener to detect script load. This
  2091. * is only switched on for Safari 2.x and below.
  2092. * @property _useYahooListener
  2093. * @private
  2094. */
  2095. this._useYahooListener = false;
  2096. /**
  2097. * Callback that will be executed when the loader is finished
  2098. * with an insert
  2099. * @method onSuccess
  2100. * @type function
  2101. */
  2102. this.onSuccess = null;
  2103. /**
  2104. * Callback that will be executed if there is a failure
  2105. * @method onFailure
  2106. * @type function
  2107. */
  2108. this.onFailure = Y.log;
  2109. /**
  2110. * Callback that will be executed each time a new module is loaded
  2111. * @method onProgress
  2112. * @type function
  2113. */
  2114. this.onProgress = null;
  2115. /**
  2116. * Callback that will be executed if a timeout occurs
  2117. * @method onTimeout
  2118. * @type function
  2119. */
  2120. this.onTimeout = null;
  2121. /**
  2122. * The execution scope for all callbacks
  2123. * @property scope
  2124. * @default this
  2125. */
  2126. this.scope = this;
  2127. /**
  2128. * Data that is passed to all callbacks
  2129. * @property data
  2130. */
  2131. this.data = null;
  2132. /**
  2133. * Node reference or id where new nodes should be inserted before
  2134. * @property insertBefore
  2135. * @type string|HTMLElement
  2136. */
  2137. this.insertBefore = null;
  2138. /**
  2139. * The charset attribute for inserted nodes
  2140. * @property charset
  2141. * @type string
  2142. * @default utf-8
  2143. */
  2144. this.charset = null;
  2145. /**
  2146. * The name of the variable in a sandbox or script node
  2147. * (for external script support in Safari 2.x and earlier)
  2148. * to reference when the load is complete. If this variable
  2149. * is not available in the specified scripts, the operation will
  2150. * fail.
  2151. * @property varName
  2152. * @type string
  2153. */
  2154. this.varName = null;
  2155. /**
  2156. * The base directory.
  2157. * @property base
  2158. * @type string
  2159. * @default http://yui.yahooapis.com/[YUI VERSION]/build/
  2160. */
  2161. this.base = YUI.info.base;
  2162. /**
  2163. * Base path for the combo service
  2164. * @property comboBase
  2165. * @type string
  2166. * @default http://yui.yahooapis.com/combo?
  2167. */
  2168. this.comboBase = YUI.info.comboBase;
  2169. /**
  2170. * If configured, YUI will use the the combo handler on the
  2171. * Yahoo! CDN to pontentially reduce the number of http requests
  2172. * required.
  2173. * @property combine
  2174. * @type boolean
  2175. * @default false
  2176. */
  2177. // this.combine = (o && !('base' in o));
  2178. this.combine = false;
  2179. /**
  2180. * Root path to prepend to module path for the combo
  2181. * service
  2182. * @property root
  2183. * @type string
  2184. * @default [YUI VERSION]/build/
  2185. */
  2186. this.root = YUI.info.root;
  2187. /**
  2188. * Timeout value in milliseconds. If set, this value will be used by
  2189. * the get utility. the timeout event will fire if
  2190. * a timeout occurs.
  2191. * @property timeout
  2192. * @type int
  2193. */
  2194. this.timeout = 0;
  2195. /**
  2196. * A list of modules that should not be loaded, even if
  2197. * they turn up in the dependency tree
  2198. * @property ignore
  2199. * @type string[]
  2200. */
  2201. this.ignore = null;
  2202. /**
  2203. * A list of modules that should always be loaded, even
  2204. * if they have already been inserted into the page.
  2205. * @property force
  2206. * @type string[]
  2207. */
  2208. this.force = null;
  2209. /**
  2210. * Should we allow rollups
  2211. * @property allowRollup
  2212. * @type boolean
  2213. * @default true
  2214. */
  2215. this.allowRollup = true;
  2216. /**
  2217. * A filter to apply to result urls. This filter will modify the default
  2218. * path for all modules. The default path for the YUI library is the
  2219. * minified version of the files (e.g., event-min.js). The filter property
  2220. * can be a predefined filter or a custom filter. The valid predefined
  2221. * filters are:
  2222. * <dl>
  2223. * <dt>DEBUG</dt>
  2224. * <dd>Selects the debug versions of the library (e.g., event-debug.js).
  2225. * This option will automatically include the logger widget</dd>
  2226. * <dt>RAW</dt>
  2227. * <dd>Selects the non-minified version of the library (e.g., event.js).
  2228. * </dl>
  2229. * You can also define a custom filter, which must be an object literal
  2230. * containing a search expression and a replace string:
  2231. * <pre>
  2232. * myFilter: &#123;
  2233. * 'searchExp': "-min\\.js",
  2234. * 'replaceStr': "-debug.js"
  2235. * &#125;
  2236. * </pre>
  2237. * @property filter
  2238. * @type string|{searchExp: string, replaceStr: string}
  2239. */
  2240. this.filter = null;
  2241. /**
  2242. * The list of requested modules
  2243. * @property required
  2244. * @type {string: boolean}
  2245. */
  2246. this.required = {};
  2247. /**
  2248. * The library metadata
  2249. * @property moduleInfo
  2250. */
  2251. this.moduleInfo = lang.merge(YUI.info.moduleInfo);
  2252. /**
  2253. * List of rollup files found in the library metadata
  2254. * @property rollups
  2255. */
  2256. this.rollups = null;
  2257. /**
  2258. * Whether or not to load optional dependencies for
  2259. * the requested modules
  2260. * @property loadOptional
  2261. * @type boolean
  2262. * @default false
  2263. */
  2264. this.loadOptional = false;
  2265. /**
  2266. * All of the derived dependencies in sorted order, which
  2267. * will be populated when either calculate() or insert()
  2268. * is called
  2269. * @property sorted
  2270. * @type string[]
  2271. */
  2272. this.sorted = [];
  2273. /**
  2274. * Set when beginning to compute the dependency tree.
  2275. * Composed of what YAHOO reports to be loaded combined
  2276. * with what has been loaded by the tool
  2277. * @propery loaded
  2278. * @type {string: boolean}
  2279. */
  2280. this.loaded = {};
  2281. /**
  2282. * Flag to indicate the dependency tree needs to be recomputed
  2283. * if insert is called again.
  2284. * @property dirty
  2285. * @type boolean
  2286. * @default true
  2287. */
  2288. this.dirty = true;
  2289. /**
  2290. * List of modules inserted by the utility
  2291. * @property inserted
  2292. * @type {string: boolean}
  2293. */
  2294. this.inserted = {};
  2295. /**
  2296. * Provides the information used to skin the skinnable components.
  2297. * The following skin definition would result in 'skin1' and 'skin2'
  2298. * being loaded for calendar (if calendar was requested), and
  2299. * 'sam' for all other skinnable components:
  2300. *
  2301. * <code>
  2302. * skin: {
  2303. *
  2304. * // The default skin, which is automatically applied if not
  2305. * // overriden by a component-specific skin definition.
  2306. * // Change this in to apply a different skin globally
  2307. * defaultSkin: 'sam',
  2308. *
  2309. * // This is combined with the loader base property to get
  2310. * // the default root directory for a skin. ex:
  2311. * // http://yui.yahooapis.com/2.3.0/build/assets/skins/sam/
  2312. * base: 'assets/skins/',
  2313. *
  2314. * // The name of the rollup css file for the skin
  2315. * path: 'skin.css',
  2316. *
  2317. * // The number of skinnable components requested that are
  2318. * // required before using the rollup file rather than the
  2319. * // individual component css files
  2320. * rollup: 3,
  2321. *
  2322. * // Any component-specific overrides can be specified here,
  2323. * // making it possible to load different skins for different
  2324. * // components. It is possible to load more than one skin
  2325. * // for a given component as well.
  2326. * overrides: {
  2327. * calendar: ['skin1', 'skin2']
  2328. * }
  2329. * }
  2330. * </code>
  2331. * @property skin
  2332. */
  2333. var self = this;
  2334. env.listeners.push(function(m) {
  2335. if (self._useYahooListener) {
  2336. //Y.log("YAHOO listener: " + m.name);
  2337. self.loadNext(m.name);
  2338. }
  2339. });
  2340. this.skin = lang.merge(YUI.info.skin);
  2341. this._config(o);
  2342. };
  2343. Y.util.YUILoader.prototype = {
  2344. FILTERS: {
  2345. RAW: {
  2346. 'searchExp': "-min\\.js",
  2347. 'replaceStr': ".js"
  2348. },
  2349. DEBUG: {
  2350. 'searchExp': "-min\\.js",
  2351. 'replaceStr': "-debug.js"
  2352. }
  2353. },
  2354. SKIN_PREFIX: "skin-",
  2355. _config: function(o) {
  2356. // apply config values
  2357. if (o) {
  2358. for (var i in o) {
  2359. if (lang.hasOwnProperty(o, i)) {
  2360. if (i == "require") {
  2361. this.require(o[i]);
  2362. } else {
  2363. this[i] = o[i];
  2364. }
  2365. }
  2366. }
  2367. }
  2368. // fix filter
  2369. var f = this.filter;
  2370. if (lang.isString(f)) {
  2371. f = f.toUpperCase();
  2372. // the logger must be available in order to use the debug
  2373. // versions of the library
  2374. if (f === "DEBUG") {
  2375. this.require("logger");
  2376. }
  2377. // hack to handle a a bug where LogWriter is being instantiated
  2378. // at load time, and the loader has no way to sort above it
  2379. // at the moment.
  2380. if (!Y.widget.LogWriter) {
  2381. Y.widget.LogWriter = function() {
  2382. return Y;
  2383. };
  2384. }
  2385. this.filter = this.FILTERS[f];
  2386. }
  2387. },
  2388. /** Add a new module to the component metadata.
  2389. * <dl>
  2390. * <dt>name:</dt> <dd>required, the component name</dd>
  2391. * <dt>type:</dt> <dd>required, the component type (js or css)</dd>
  2392. * <dt>path:</dt> <dd>required, the path to the script from "base"</dd>
  2393. * <dt>requires:</dt> <dd>array of modules required by this component</dd>
  2394. * <dt>optional:</dt> <dd>array of optional modules for this component</dd>
  2395. * <dt>supersedes:</dt> <dd>array of the modules this component replaces</dd>
  2396. * <dt>after:</dt> <dd>array of modules the components which, if present, should be sorted above this one</dd>
  2397. * <dt>rollup:</dt> <dd>the number of superseded modules required for automatic rollup</dd>
  2398. * <dt>fullpath:</dt> <dd>If fullpath is specified, this is used instead of the configured base + path</dd>
  2399. * <dt>skinnable:</dt> <dd>flag to determine if skin assets should automatically be pulled in</dd>
  2400. * </dl>
  2401. * @method addModule
  2402. * @param o An object containing the module data
  2403. * @return {boolean} true if the module was added, false if
  2404. * the object passed in did not provide all required attributes
  2405. */
  2406. addModule: function(o) {
  2407. if (!o || !o.name || !o.type || (!o.path && !o.fullpath)) {
  2408. return false;
  2409. }
  2410. o.ext = ('ext' in o) ? o.ext : true;
  2411. o.requires = o.requires || [];
  2412. this.moduleInfo[o.name] = o;
  2413. this.dirty = true;
  2414. return true;
  2415. },
  2416. /**
  2417. * Add a requirement for one or more module
  2418. * @method require
  2419. * @param what {string[] | string*} the modules to load
  2420. */
  2421. require: function(what) {
  2422. var a = (typeof what === "string") ? arguments : what;
  2423. this.dirty = true;
  2424. YUI.ObjectUtil.appendArray(this.required, a);
  2425. },
  2426. /**
  2427. * Adds the skin def to the module info
  2428. * @method _addSkin
  2429. * @param skin {string} the name of the skin
  2430. * @param mod {string} the name of the module
  2431. * @return {string} the module name for the skin
  2432. * @private
  2433. */
  2434. _addSkin: function(skin, mod) {
  2435. // Add a module definition for the skin rollup css
  2436. var name = this.formatSkin(skin), info = this.moduleInfo,
  2437. sinf = this.skin, ext = info[mod] && info[mod].ext;
  2438. // Y.log('ext? ' + mod + ": " + ext);
  2439. if (!info[name]) {
  2440. // Y.log('adding skin ' + name);
  2441. this.addModule({
  2442. 'name': name,
  2443. 'type': 'css',
  2444. 'path': sinf.base + skin + '/' + sinf.path,
  2445. //'supersedes': '*',
  2446. 'after': sinf.after,
  2447. 'rollup': sinf.rollup,
  2448. 'ext': ext
  2449. });
  2450. }
  2451. // Add a module definition for the module-specific skin css
  2452. if (mod) {
  2453. name = this.formatSkin(skin, mod);
  2454. if (!info[name]) {
  2455. var mdef = info[mod], pkg = mdef.pkg || mod;
  2456. // Y.log('adding skin ' + name);
  2457. this.addModule({
  2458. 'name': name,
  2459. 'type': 'css',
  2460. 'after': sinf.after,
  2461. 'path': pkg + '/' + sinf.base + skin + '/' + mod + '.css',
  2462. 'ext': ext
  2463. });
  2464. }
  2465. }
  2466. return name;
  2467. },
  2468. /**
  2469. * Returns an object containing properties for all modules required
  2470. * in order to load the requested module
  2471. * @method getRequires
  2472. * @param mod The module definition from moduleInfo
  2473. */
  2474. getRequires: function(mod) {
  2475. if (!mod) {
  2476. return [];
  2477. }
  2478. if (!this.dirty && mod.expanded) {
  2479. return mod.expanded;
  2480. }
  2481. mod.requires=mod.requires || [];
  2482. var i, d=[], r=mod.requires, o=mod.optional, info=this.moduleInfo, m;
  2483. for (i=0; i<r.length; i=i+1) {
  2484. d.push(r[i]);
  2485. m = info[r[i]];
  2486. YUI.ArrayUtil.appendArray(d, this.getRequires(m));
  2487. // add existing skins for skinnable modules as well. The only
  2488. // way to do this is go through the list of required items (this
  2489. // assumes that _skin is called before getRequires is called on
  2490. // the module.
  2491. // if (m.skinnable) {
  2492. // var req=this.required, l=req.length;
  2493. // for (var j=0; j<l; j=j+1) {
  2494. // // YAHOO.log('checking ' + r[j]);
  2495. // if (req[j].indexOf(r[j]) > -1) {
  2496. // // YAHOO.log('adding ' + r[j]);
  2497. // d.push(req[j]);
  2498. // }
  2499. // }
  2500. // }
  2501. }
  2502. if (o && this.loadOptional) {
  2503. for (i=0; i<o.length; i=i+1) {
  2504. d.push(o[i]);
  2505. YUI.ArrayUtil.appendArray(d, this.getRequires(info[o[i]]));
  2506. }
  2507. }
  2508. mod.expanded = YUI.ArrayUtil.uniq(d);
  2509. return mod.expanded;
  2510. },
  2511. /**
  2512. * Returns an object literal of the modules the supplied module satisfies
  2513. * @method getProvides
  2514. * @param name{string} The name of the module
  2515. * @param notMe {string} don't add this module name, only include superseded modules
  2516. * @return what this module provides
  2517. */
  2518. getProvides: function(name, notMe) {
  2519. var addMe = !(notMe), ckey = (addMe) ? PROV : SUPER,
  2520. m = this.moduleInfo[name], o = {};
  2521. if (!m) {
  2522. return o;
  2523. }
  2524. if (m[ckey]) {
  2525. // Y.log('cached: ' + name + ' ' + ckey + ' ' + lang.dump(this.moduleInfo[name][ckey], 0));
  2526. return m[ckey];
  2527. }
  2528. var s = m.supersedes, done={}, me = this;
  2529. // use worker to break cycles
  2530. var add = function(mm) {
  2531. if (!done[mm]) {
  2532. // Y.log(name + ' provides worker trying: ' + mm);
  2533. done[mm] = true;
  2534. // we always want the return value normal behavior
  2535. // (provides) for superseded modules.
  2536. lang.augmentObject(o, me.getProvides(mm));
  2537. }
  2538. // else {
  2539. // Y.log(name + ' provides worker skipping done: ' + mm);
  2540. // }
  2541. };
  2542. // calculate superseded modules
  2543. if (s) {
  2544. for (var i=0; i<s.length; i=i+1) {
  2545. add(s[i]);
  2546. }
  2547. }
  2548. // supersedes cache
  2549. m[SUPER] = o;
  2550. // provides cache
  2551. m[PROV] = lang.merge(o);
  2552. m[PROV][name] = true;
  2553. // Y.log(name + " supersedes " + lang.dump(m[SUPER], 0));
  2554. // Y.log(name + " provides " + lang.dump(m[PROV], 0));
  2555. return m[ckey];
  2556. },
  2557. /**
  2558. * Calculates the dependency tree, the result is stored in the sorted
  2559. * property
  2560. * @method calculate
  2561. * @param o optional options object
  2562. */
  2563. calculate: function(o) {
  2564. if (o || this.dirty) {
  2565. this._config(o);
  2566. this._setup();
  2567. this._explode();
  2568. // this._skin(); // deprecated
  2569. if (this.allowRollup) {
  2570. this._rollup();
  2571. }
  2572. this._reduce();
  2573. this._sort();
  2574. // Y.log("after calculate: " + lang.dump(this.required));
  2575. this.dirty = false;
  2576. }
  2577. },
  2578. /**
  2579. * Investigates the current YUI configuration on the page. By default,
  2580. * modules already detected will not be loaded again unless a force
  2581. * option is encountered. Called by calculate()
  2582. * @method _setup
  2583. * @private
  2584. */
  2585. _setup: function() {
  2586. var info = this.moduleInfo, name, i, j;
  2587. // Create skin modules
  2588. for (name in info) {
  2589. if (lang.hasOwnProperty(info, name)) {
  2590. var m = info[name];
  2591. if (m && m.skinnable) {
  2592. // Y.log("skinning: " + name);
  2593. var o=this.skin.overrides, smod;
  2594. if (o && o[name]) {
  2595. for (i=0; i<o[name].length; i=i+1) {
  2596. smod = this._addSkin(o[name][i], name);
  2597. }
  2598. } else {
  2599. smod = this._addSkin(this.skin.defaultSkin, name);
  2600. }
  2601. m.requires.push(smod);
  2602. }
  2603. }
  2604. }
  2605. var l = lang.merge(this.inserted); // shallow clone
  2606. if (!this._sandbox) {
  2607. l = lang.merge(l, env.modules);
  2608. }
  2609. // Y.log("Already loaded stuff: " + lang.dump(l, 0));
  2610. // add the ignore list to the list of loaded packages
  2611. if (this.ignore) {
  2612. YUI.ObjectUtil.appendArray(l, this.ignore);
  2613. }
  2614. // remove modules on the force list from the loaded list
  2615. if (this.force) {
  2616. for (i=0; i<this.force.length; i=i+1) {
  2617. if (this.force[i] in l) {
  2618. delete l[this.force[i]];
  2619. }
  2620. }
  2621. }
  2622. // expand the list to include superseded modules
  2623. for (j in l) {
  2624. // Y.log("expanding: " + j);
  2625. if (lang.hasOwnProperty(l, j)) {
  2626. lang.augmentObject(l, this.getProvides(j));
  2627. }
  2628. }
  2629. // Y.log("loaded expanded: " + lang.dump(l, 0));
  2630. this.loaded = l;
  2631. },
  2632. /**
  2633. * Inspects the required modules list looking for additional
  2634. * dependencies. Expands the required list to include all
  2635. * required modules. Called by calculate()
  2636. * @method _explode
  2637. * @private
  2638. */
  2639. _explode: function() {
  2640. var r=this.required, i, mod;
  2641. for (i in r) {
  2642. if (lang.hasOwnProperty(r, i)) {
  2643. mod = this.moduleInfo[i];
  2644. if (mod) {
  2645. var req = this.getRequires(mod);
  2646. if (req) {
  2647. YUI.ObjectUtil.appendArray(r, req);
  2648. }
  2649. }
  2650. }
  2651. }
  2652. },
  2653. /**
  2654. * Sets up the requirements for the skin assets if any of the
  2655. * requested modules are skinnable
  2656. * @method _skin
  2657. * @private
  2658. * @deprecated skin modules are generated for all skinnable
  2659. * components during _setup(), and the components
  2660. * are configured to require the skin.
  2661. */
  2662. _skin: function() {
  2663. },
  2664. /**
  2665. * Returns the skin module name for the specified skin name. If a
  2666. * module name is supplied, the returned skin module name is
  2667. * specific to the module passed in.
  2668. * @method formatSkin
  2669. * @param skin {string} the name of the skin
  2670. * @param mod {string} optional: the name of a module to skin
  2671. * @return {string} the full skin module name
  2672. */
  2673. formatSkin: function(skin, mod) {
  2674. var s = this.SKIN_PREFIX + skin;
  2675. if (mod) {
  2676. s = s + "-" + mod;
  2677. }
  2678. return s;
  2679. },
  2680. /**
  2681. * Reverses <code>formatSkin</code>, providing the skin name and
  2682. * module name if the string matches the pattern for skins.
  2683. * @method parseSkin
  2684. * @param mod {string} the module name to parse
  2685. * @return {skin: string, module: string} the parsed skin name
  2686. * and module name, or null if the supplied string does not match
  2687. * the skin pattern
  2688. */
  2689. parseSkin: function(mod) {
  2690. if (mod.indexOf(this.SKIN_PREFIX) === 0) {
  2691. var a = mod.split("-");
  2692. return {skin: a[1], module: a[2]};
  2693. }
  2694. return null;
  2695. },
  2696. /**
  2697. * Look for rollup packages to determine if all of the modules a
  2698. * rollup supersedes are required. If so, include the rollup to
  2699. * help reduce the total number of connections required. Called
  2700. * by calculate()
  2701. * @method _rollup
  2702. * @private
  2703. */
  2704. _rollup: function() {
  2705. var i, j, m, s, rollups={}, r=this.required, roll,
  2706. info = this.moduleInfo;
  2707. // find and cache rollup modules
  2708. if (this.dirty || !this.rollups) {
  2709. for (i in info) {
  2710. if (lang.hasOwnProperty(info, i)) {
  2711. m = info[i];
  2712. //if (m && m.rollup && m.supersedes) {
  2713. if (m && m.rollup) {
  2714. rollups[i] = m;
  2715. }
  2716. }
  2717. }
  2718. this.rollups = rollups;
  2719. }
  2720. // make as many passes as needed to pick up rollup rollups
  2721. for (;;) {
  2722. var rolled = false;
  2723. // go through the rollup candidates
  2724. for (i in rollups) {
  2725. // there can be only one
  2726. if (!r[i] && !this.loaded[i]) {
  2727. m =info[i]; s = m.supersedes; roll=false;
  2728. if (!m.rollup) {
  2729. continue;
  2730. }
  2731. var skin = (m.ext) ? false : this.parseSkin(i), c = 0;
  2732. // Y.log('skin? ' + i + ": " + skin);
  2733. if (skin) {
  2734. for (j in r) {
  2735. if (lang.hasOwnProperty(r, j)) {
  2736. if (i !== j && this.parseSkin(j)) {
  2737. c++;
  2738. roll = (c >= m.rollup);
  2739. if (roll) {
  2740. // Y.log("skin rollup " + lang.dump(r));
  2741. break;
  2742. }
  2743. }
  2744. }
  2745. }
  2746. } else {
  2747. // check the threshold
  2748. for (j=0;j<s.length;j=j+1) {
  2749. // if the superseded module is loaded, we can't load the rollup
  2750. if (this.loaded[s[j]] && (!YUI.dupsAllowed[s[j]])) {
  2751. roll = false;
  2752. break;
  2753. // increment the counter if this module is required. if we are
  2754. // beyond the rollup threshold, we will use the rollup module
  2755. } else if (r[s[j]]) {
  2756. c++;
  2757. roll = (c >= m.rollup);
  2758. if (roll) {
  2759. // Y.log("over thresh " + c + ", " + lang.dump(r));
  2760. break;
  2761. }
  2762. }
  2763. }
  2764. }
  2765. if (roll) {
  2766. // Y.log("rollup: " + i + ", " + lang.dump(this, 1));
  2767. // add the rollup
  2768. r[i] = true;
  2769. rolled = true;
  2770. // expand the rollup's dependencies
  2771. this.getRequires(m);
  2772. }
  2773. }
  2774. }
  2775. // if we made it here w/o rolling up something, we are done
  2776. if (!rolled) {
  2777. break;
  2778. }
  2779. }
  2780. },
  2781. /**
  2782. * Remove superceded modules and loaded modules. Called by
  2783. * calculate() after we have the mega list of all dependencies
  2784. * @method _reduce
  2785. * @private
  2786. */
  2787. _reduce: function() {
  2788. var i, j, s, m, r=this.required;
  2789. for (i in r) {
  2790. // remove if already loaded
  2791. if (i in this.loaded) {
  2792. delete r[i];
  2793. // remove anything this module supersedes
  2794. } else {
  2795. var skinDef = this.parseSkin(i);
  2796. if (skinDef) {
  2797. //YAHOO.log("skin found in reduce: " + skinDef.skin + ", " + skinDef.module);
  2798. // the skin rollup will not have a module name
  2799. if (!skinDef.module) {
  2800. var skin_pre = this.SKIN_PREFIX + skinDef.skin;
  2801. //YAHOO.log("skin_pre: " + skin_pre);
  2802. for (j in r) {
  2803. if (lang.hasOwnProperty(r, j)) {
  2804. m = this.moduleInfo[j];
  2805. var ext = m && m.ext;
  2806. if (!ext && j !== i && j.indexOf(skin_pre) > -1) {
  2807. // Y.log ("removing component skin: " + j);
  2808. delete r[j];
  2809. }
  2810. }
  2811. }
  2812. }
  2813. } else {
  2814. m = this.moduleInfo[i];
  2815. s = m && m.supersedes;
  2816. if (s) {
  2817. for (j=0; j<s.length; j=j+1) {
  2818. if (s[j] in r) {
  2819. delete r[s[j]];
  2820. }
  2821. }
  2822. }
  2823. }
  2824. }
  2825. }
  2826. },
  2827. _onFailure: function(msg) {
  2828. YAHOO.log('Failure', 'info', 'loader');
  2829. var f = this.onFailure;
  2830. if (f) {
  2831. f.call(this.scope, {
  2832. msg: 'failure: ' + msg,
  2833. data: this.data,
  2834. success: false
  2835. });
  2836. }
  2837. },
  2838. _onTimeout: function() {
  2839. YAHOO.log('Timeout', 'info', 'loader');
  2840. var f = this.onTimeout;
  2841. if (f) {
  2842. f.call(this.scope, {
  2843. msg: 'timeout',
  2844. data: this.data,
  2845. success: false
  2846. });
  2847. }
  2848. },
  2849. /**
  2850. * Sorts the dependency tree. The last step of calculate()
  2851. * @method _sort
  2852. * @private
  2853. */
  2854. _sort: function() {
  2855. // create an indexed list
  2856. var s=[], info=this.moduleInfo, loaded=this.loaded,
  2857. checkOptional=!this.loadOptional, me = this;
  2858. // returns true if b is not loaded, and is required
  2859. // directly or by means of modules it supersedes.
  2860. var requires = function(aa, bb) {
  2861. var mm=info[aa];
  2862. if (loaded[bb] || !mm) {
  2863. return false;
  2864. }
  2865. var ii,
  2866. rr = mm.expanded,
  2867. after = mm.after,
  2868. other = info[bb],
  2869. optional = mm.optional;
  2870. // check if this module requires the other directly
  2871. if (rr && YUI.ArrayUtil.indexOf(rr, bb) > -1) {
  2872. return true;
  2873. }
  2874. // check if this module should be sorted after the other
  2875. if (after && YUI.ArrayUtil.indexOf(after, bb) > -1) {
  2876. return true;
  2877. }
  2878. // if loadOptional is not specified, optional dependencies still
  2879. // must be sorted correctly when present.
  2880. if (checkOptional && optional && YUI.ArrayUtil.indexOf(optional, bb) > -1) {
  2881. return true;
  2882. }
  2883. // check if this module requires one the other supersedes
  2884. var ss=info[bb] && info[bb].supersedes;
  2885. if (ss) {
  2886. for (ii=0; ii<ss.length; ii=ii+1) {
  2887. if (requires(aa, ss[ii])) {
  2888. return true;
  2889. }
  2890. }
  2891. }
  2892. // var ss=me.getProvides(bb, true);
  2893. // if (ss) {
  2894. // for (ii in ss) {
  2895. // if (requires(aa, ii)) {
  2896. // return true;
  2897. // }
  2898. // }
  2899. // }
  2900. // external css files should be sorted below yui css
  2901. if (mm.ext && mm.type == 'css' && !other.ext && other.type == 'css') {
  2902. return true;
  2903. }
  2904. return false;
  2905. };
  2906. // get the required items out of the obj into an array so we
  2907. // can sort
  2908. for (var i in this.required) {
  2909. if (lang.hasOwnProperty(this.required, i)) {
  2910. s.push(i);
  2911. }
  2912. }
  2913. // pointer to the first unsorted item
  2914. var p=0;
  2915. // keep going until we make a pass without moving anything
  2916. for (;;) {
  2917. var l=s.length, a, b, j, k, moved=false;
  2918. // start the loop after items that are already sorted
  2919. for (j=p; j<l; j=j+1) {
  2920. // check the next module on the list to see if its
  2921. // dependencies have been met
  2922. a = s[j];
  2923. // check everything below current item and move if we
  2924. // find a requirement for the current item
  2925. for (k=j+1; k<l; k=k+1) {
  2926. if (requires(a, s[k])) {
  2927. // extract the dependency so we can move it up
  2928. b = s.splice(k, 1);
  2929. // insert the dependency above the item that
  2930. // requires it
  2931. s.splice(j, 0, b[0]);
  2932. moved = true;
  2933. break;
  2934. }
  2935. }
  2936. // jump out of loop if we moved something
  2937. if (moved) {
  2938. break;
  2939. // this item is sorted, move our pointer and keep going
  2940. } else {
  2941. p = p + 1;
  2942. }
  2943. }
  2944. // when we make it here and moved is false, we are
  2945. // finished sorting
  2946. if (!moved) {
  2947. break;
  2948. }
  2949. }
  2950. this.sorted = s;
  2951. },
  2952. toString: function() {
  2953. var o = {
  2954. type: "YUILoader",
  2955. base: this.base,
  2956. filter: this.filter,
  2957. required: this.required,
  2958. loaded: this.loaded,
  2959. inserted: this.inserted
  2960. };
  2961. lang.dump(o, 1);
  2962. },
  2963. _combine: function() {
  2964. this._combining = [];
  2965. var self = this,
  2966. s=this.sorted,
  2967. len = s.length,
  2968. js = this.comboBase,
  2969. css = this.comboBase,
  2970. target,
  2971. startLen = js.length,
  2972. i, m, type = this.loadType;
  2973. YAHOO.log('type ' + type);
  2974. for (i=0; i<len; i=i+1) {
  2975. m = this.moduleInfo[s[i]];
  2976. if (m && !m.ext && (!type || type === m.type)) {
  2977. target = this.root + m.path;
  2978. // if (i < len-1) {
  2979. target += '&';
  2980. // }
  2981. if (m.type == 'js') {
  2982. js += target;
  2983. } else {
  2984. css += target;
  2985. }
  2986. // YAHOO.log(target);
  2987. this._combining.push(s[i]);
  2988. }
  2989. }
  2990. if (this._combining.length) {
  2991. YAHOO.log('Attempting to combine: ' + this._combining, "info", "loader");
  2992. var callback=function(o) {
  2993. // YAHOO.log('Combo complete: ' + o.data, "info", "loader");
  2994. // this._combineComplete = true;
  2995. var c=this._combining, len=c.length, i, m;
  2996. for (i=0; i<len; i=i+1) {
  2997. this.inserted[c[i]] = true;
  2998. }
  2999. this.loadNext(o.data);
  3000. },
  3001. loadScript = function() {
  3002. // YAHOO.log('combining js: ' + js);
  3003. if (js.length > startLen) {
  3004. YAHOO.util.Get.script(self._filter(js), {
  3005. data: self._loading,
  3006. onSuccess: callback,
  3007. onFailure: self._onFailure,
  3008. onTimeout: self._onTimeout,
  3009. insertBefore: self.insertBefore,
  3010. charset: self.charset,
  3011. timeout: self.timeout,
  3012. scope: self
  3013. });
  3014. }
  3015. };
  3016. // load the css first
  3017. // YAHOO.log('combining css: ' + css);
  3018. if (css.length > startLen) {
  3019. YAHOO.util.Get.css(this._filter(css), {
  3020. data: this._loading,
  3021. onSuccess: loadScript,
  3022. onFailure: this._onFailure,
  3023. onTimeout: this._onTimeout,
  3024. insertBefore: this.insertBefore,
  3025. charset: this.charset,
  3026. timeout: this.timeout,
  3027. scope: self
  3028. });
  3029. } else {
  3030. loadScript();
  3031. }
  3032. return;
  3033. } else {
  3034. // this._combineComplete = true;
  3035. this.loadNext(this._loading);
  3036. }
  3037. },
  3038. /**
  3039. * inserts the requested modules and their dependencies.
  3040. * <code>type</code> can be "js" or "css". Both script and
  3041. * css are inserted if type is not provided.
  3042. * @method insert
  3043. * @param o optional options object
  3044. * @param type {string} the type of dependency to insert
  3045. */
  3046. insert: function(o, type) {
  3047. // if (o) {
  3048. // Y.log("insert: " + lang.dump(o, 1) + ", " + type);
  3049. // } else {
  3050. // Y.log("insert: " + this.toString() + ", " + type);
  3051. // }
  3052. // build the dependency list
  3053. this.calculate(o);
  3054. // set a flag to indicate the load has started
  3055. this._loading = true;
  3056. // flag to indicate we are done with the combo service
  3057. // and any additional files will need to be loaded
  3058. // individually
  3059. // this._combineComplete = false;
  3060. // keep the loadType (js, css or undefined) cached
  3061. this.loadType = type;
  3062. if (this.combine) {
  3063. return this._combine();
  3064. }
  3065. if (!type) {
  3066. // Y.log("trying to load css first");
  3067. var self = this;
  3068. this._internalCallback = function() {
  3069. self._internalCallback = null;
  3070. self.insert(null, "js");
  3071. };
  3072. this.insert(null, "css");
  3073. return;
  3074. }
  3075. // start the load
  3076. this.loadNext();
  3077. },
  3078. /**
  3079. * Interns the script for the requested modules. The callback is
  3080. * provided a reference to the sandboxed YAHOO object. This only
  3081. * applies to the script: css can not be sandboxed; css will be
  3082. * loaded into the page normally if specified.
  3083. * @method sandbox
  3084. * @param callback {Function} the callback to exectued when the load is
  3085. * complete.
  3086. */
  3087. sandbox: function(o, type) {
  3088. // if (o) {
  3089. // YAHOO.log("sandbox: " + lang.dump(o, 1) + ", " + type);
  3090. // } else {
  3091. // YAHOO.log("sandbox: " + this.toString() + ", " + type);
  3092. // }
  3093. this._config(o);
  3094. if (!this.onSuccess) {
  3095. throw new Error("You must supply an onSuccess handler for your sandbox");
  3096. }
  3097. this._sandbox = true;
  3098. var self = this;
  3099. // take care of any css first (this can't be sandboxed)
  3100. if (!type || type !== "js") {
  3101. this._internalCallback = function() {
  3102. self._internalCallback = null;
  3103. self.sandbox(null, "js");
  3104. };
  3105. this.insert(null, "css");
  3106. return;
  3107. }
  3108. // get the connection manager if not on the page
  3109. if (!util.Connect) {
  3110. // get a new loader instance to load connection.
  3111. var ld = new YAHOO.util.YUILoader();
  3112. ld.insert({
  3113. base: this.base,
  3114. filter: this.filter,
  3115. require: "connection",
  3116. insertBefore: this.insertBefore,
  3117. charset: this.charset,
  3118. onSuccess: function() {
  3119. this.sandbox(null, "js");
  3120. },
  3121. scope: this
  3122. }, "js");
  3123. return;
  3124. }
  3125. this._scriptText = [];
  3126. this._loadCount = 0;
  3127. this._stopCount = this.sorted.length;
  3128. this._xhr = [];
  3129. this.calculate();
  3130. var s=this.sorted, l=s.length, i, m, url;
  3131. for (i=0; i<l; i=i+1) {
  3132. m = this.moduleInfo[s[i]];
  3133. // undefined modules cause a failure
  3134. if (!m) {
  3135. this._onFailure("undefined module " + m);
  3136. for (var j=0;j<this._xhr.length;j=j+1) {
  3137. this._xhr[j].abort();
  3138. }
  3139. return;
  3140. }
  3141. // css files should be done
  3142. if (m.type !== "js") {
  3143. this._loadCount++;
  3144. continue;
  3145. }
  3146. url = m.fullpath;
  3147. url = (url) ? this._filter(url) : this._url(m.path);
  3148. // YAHOO.log("xhr request: " + url + ", " + i);
  3149. var xhrData = {
  3150. success: function(o) {
  3151. var idx=o.argument[0], name=o.argument[2];
  3152. // store the response in the position it was requested
  3153. this._scriptText[idx] = o.responseText;
  3154. // YAHOO.log("received: " + o.responseText.substr(0, 100) + ", " + idx);
  3155. if (this.onProgress) {
  3156. this.onProgress.call(this.scope, {
  3157. name: name,
  3158. scriptText: o.responseText,
  3159. xhrResponse: o,
  3160. data: this.data
  3161. });
  3162. }
  3163. // only generate the sandbox once everything is loaded
  3164. this._loadCount++;
  3165. if (this._loadCount >= this._stopCount) {
  3166. // the variable to find
  3167. var v = this.varName || "YAHOO";
  3168. // wrap the contents of the requested modules in an anonymous function
  3169. var t = "(function() {\n";
  3170. // return the locally scoped reference.
  3171. var b = "\nreturn " + v + ";\n})();";
  3172. var ref = eval(t + this._scriptText.join("\n") + b);
  3173. this._pushEvents(ref);
  3174. if (ref) {
  3175. this.onSuccess.call(this.scope, {
  3176. reference: ref,
  3177. data: this.data
  3178. });
  3179. } else {
  3180. this._onFailure.call(this.varName + " reference failure");
  3181. }
  3182. }
  3183. },
  3184. failure: function(o) {
  3185. this.onFailure.call(this.scope, {
  3186. msg: "XHR failure",
  3187. xhrResponse: o,
  3188. data: this.data
  3189. });
  3190. },
  3191. scope: this,
  3192. // module index, module name, sandbox name
  3193. argument: [i, url, s[i]]
  3194. };
  3195. this._xhr.push(util.Connect.asyncRequest('GET', url, xhrData));
  3196. }
  3197. },
  3198. /**
  3199. * Executed every time a module is loaded, and if we are in a load
  3200. * cycle, we attempt to load the next script. Public so that it
  3201. * is possible to call this if using a method other than
  3202. * YAHOO.register to determine when scripts are fully loaded
  3203. * @method loadNext
  3204. * @param mname {string} optional the name of the module that has
  3205. * been loaded (which is usually why it is time to load the next
  3206. * one)
  3207. */
  3208. loadNext: function(mname) {
  3209. // It is possible that this function is executed due to something
  3210. // else one the page loading a YUI module. Only react when we
  3211. // are actively loading something
  3212. if (!this._loading) {
  3213. return;
  3214. }
  3215. if (mname) {
  3216. // if the module that was just loaded isn't what we were expecting,
  3217. // continue to wait
  3218. if (mname !== this._loading) {
  3219. return;
  3220. }
  3221. // YAHOO.log("loadNext executing, just loaded " + mname);
  3222. // The global handler that is called when each module is loaded
  3223. // will pass that module name to this function. Storing this
  3224. // data to avoid loading the same module multiple times
  3225. this.inserted[mname] = true;
  3226. if (this.onProgress) {
  3227. this.onProgress.call(this.scope, {
  3228. name: mname,
  3229. data: this.data
  3230. });
  3231. }
  3232. //var o = this.getProvides(mname);
  3233. //this.inserted = lang.merge(this.inserted, o);
  3234. }
  3235. var s=this.sorted, len=s.length, i, m;
  3236. for (i=0; i<len; i=i+1) {
  3237. // This.inserted keeps track of what the loader has loaded
  3238. if (s[i] in this.inserted) {
  3239. // YAHOO.log(s[i] + " alread loaded ");
  3240. continue;
  3241. }
  3242. // Because rollups will cause multiple load notifications
  3243. // from YAHOO, loadNext may be called multiple times for
  3244. // the same module when loading a rollup. We can safely
  3245. // skip the subsequent requests
  3246. if (s[i] === this._loading) {
  3247. // YAHOO.log("still loading " + s[i] + ", waiting");
  3248. return;
  3249. }
  3250. // log("inserting " + s[i]);
  3251. m = this.moduleInfo[s[i]];
  3252. if (!m) {
  3253. this.onFailure.call(this.scope, {
  3254. msg: "undefined module " + m,
  3255. data: this.data
  3256. });
  3257. return;
  3258. }
  3259. // The load type is stored to offer the possibility to load
  3260. // the css separately from the script.
  3261. if (!this.loadType || this.loadType === m.type) {
  3262. this._loading = s[i];
  3263. //YAHOO.log("attempting to load " + s[i] + ", " + this.base);
  3264. var fn=(m.type === "css") ? util.Get.css : util.Get.script,
  3265. url = m.fullpath,
  3266. self=this,
  3267. c=function(o) {
  3268. self.loadNext(o.data);
  3269. };
  3270. url = (url) ? this._filter(url) : this._url(m.path);
  3271. // safari 2.x or lower, script, and part of YUI
  3272. if (env.ua.webkit && env.ua.webkit < 420 && m.type === "js" &&
  3273. !m.varName) {
  3274. //YUI.info.moduleInfo[s[i]]) {
  3275. //YAHOO.log("using YAHOO env " + s[i] + ", " + m.varName);
  3276. c = null;
  3277. this._useYahooListener = true;
  3278. }
  3279. fn(url, {
  3280. data: s[i],
  3281. onSuccess: c,
  3282. onFailure: this._onFailure,
  3283. onTimeout: this._onTimeout,
  3284. insertBefore: this.insertBefore,
  3285. charset: this.charset,
  3286. timeout: this.timeout,
  3287. varName: m.varName,
  3288. scope: self
  3289. });
  3290. return;
  3291. }
  3292. }
  3293. // we are finished
  3294. this._loading = null;
  3295. // internal callback for loading css first
  3296. if (this._internalCallback) {
  3297. var f = this._internalCallback;
  3298. this._internalCallback = null;
  3299. f.call(this);
  3300. } else if (this.onSuccess) {
  3301. this._pushEvents();
  3302. this.onSuccess.call(this.scope, {
  3303. data: this.data
  3304. });
  3305. }
  3306. },
  3307. /**
  3308. * In IE, the onAvailable/onDOMReady events need help when Event is
  3309. * loaded dynamically
  3310. * @method _pushEvents
  3311. * @param {Function} optional function reference
  3312. * @private
  3313. */
  3314. _pushEvents: function(ref) {
  3315. var r = ref || YAHOO;
  3316. if (r.util && r.util.Event) {
  3317. r.util.Event._load();
  3318. }
  3319. },
  3320. /**
  3321. * Applies filter
  3322. * method _filter
  3323. * @return {string} the filtered string
  3324. * @private
  3325. */
  3326. _filter: function(str) {
  3327. var f = this.filter;
  3328. return (f) ? str.replace(new RegExp(f.searchExp, 'g'), f.replaceStr) : str;
  3329. },
  3330. /**
  3331. * Generates the full url for a module
  3332. * method _url
  3333. * @param path {string} the path fragment
  3334. * @return {string} the full url
  3335. * @private
  3336. */
  3337. _url: function(path) {
  3338. return this._filter((this.base || "") + path);
  3339. }
  3340. };
  3341. })();
  3342. YAHOO.register("yuiloader", YAHOO.util.YUILoader, {version: "2.8.0r4", build: "2449"});